Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix line break disappearing with pasted text in IE11 under contentEditable mode #5383

Merged
merged 3 commits into from
Apr 27, 2018

Conversation

muan
Copy link
Contributor

@muan muan commented Apr 26, 2018

Problem

Line breaks disappear when pasting plain text from nodepad/textarea/command prompt in IE11 in contentEditable mode.

Specifically, this is because in domTextBetween a fromNode like<span cm-text="">1<br>2<br>3<br>4<br>5</span> is handled with addText(node.textContent); return, ignoring the <br>s inside.

This PR does a few things:

  • only addText & return if cm-text has value
  • otherwise walk the child nodes
  • treat br along with table, li as blocks
  • ignore empty elements (except for br which should be empty) to avoid unnecessary line breaks
  • add extra line breaks for p and pre

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.

muan added 3 commits April 26, 2018 15:45
- walk child of [cm-text] if [cm-text] is empty in order to find line breaks
- treat br/li/table as blocks
- always addText from on textNode not node.textContent
@marijnh marijnh merged commit 2893e58 into codemirror:master Apr 27, 2018
@marijnh
Copy link
Member

marijnh commented Apr 27, 2018

That looks reasonable. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants