Fix line break disappearing with pasted text in IE11 under contentEditable mode #5383
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Line breaks disappear when pasting plain text from nodepad/textarea/command prompt in IE11 in
contentEditable
mode.Specifically, this is because in
domTextBetween
afromNode
like<span cm-text="">1<br>2<br>3<br>4<br>5</span>
is handled withaddText(node.textContent); return
, ignoring the<br>
s inside.This PR does a few things:
addText
&return
ifcm-text
has valuebr
along withtable
,li
as blocksbr
which should be empty) to avoid unnecessary line breaksp
andpre
FWIW this issue reportedly is also on archlinux/debian in Firefox 52/58, but I have yet been able to reproduce them.
As far as I can see changes to this method effects IME input in modern browsers and IE11 plus pasting in IE11. I've manually tested for the IME issues I sent PR for previously (#5379, #5354) and they're still OK.
Before (IE11)
Text flashes, line breaks disappear.
Expected behavior (Chrome)
After (IE11)
Line breaks preserved.