nytimes / ice

track changes with javascript
Other
1.71k stars 194 forks source link

IE 9: First letter on a new line is outside of <insert> tag. #97

Open jnssn opened 10 years ago

jnssn commented 10 years ago

The first letter typed in a new line is excluded from the tracked changes because it's outside the <insert> tag. Using the tinymce plugin demo (http://nytimes.github.io/ice/demo), starting a new line after the first paragraph, I type:

This is a test

Viewing the HTML shows this: <p><span style="background-color: #e5ffcd;">T<insert class="ins cts-3" title="Inserted by Geoffrey Jellineck - 12/17/2013 5:25pm" data-cid="9" data-userid="11" data-username="Geoffrey Jellineck" data-time="1387329905681">his is a test</insert></span></p>

Deleting that line leaves you with a single redacted "T", while clicking Accept Changes removes the <insert> tag, but it doesn't appear to accept them because the editor leaves the green span intact.

NullVoxPopuli commented 10 years ago

this isn't just IE9. maybe not this specific issue, but there is an issue with chrome even where the first word of a new line is outside of the insert tag. Though it could be an issue with some compatibility thing with TinyMCE 4.x.x (see: https://github.com/NYTimes/ice/pull/105)

ghost commented 10 years ago

Is there a solution for this issue?

roberthenderson commented 8 years ago

I am seeing this issue in IE11.

msmith-ncs commented 7 years ago

For what it is worth, I was able to fix this issue by changing the following code in ice.js in the function _insertNode.

Change:

if (insertingDummy) { // Create a selection of the dummy character we inserted // which will be removed after it bubbles up to the final handler. range.setStart(node, 0); } else { range.collapse(); }

to if (insertingDummy) { // Create a selection of the dummy character we inserted // which will be removed after it bubbles up to the final handler. //range.setStart(node, 0); // FIX FOR IE range.collapse(); } else { range.collapse(); }

I have a vague idea of why it works, but really need to study the code a bit more. I fixed it mostly though trial and error.