guardian / scribe

DEPRECATED: A rich text editor framework for the web platform

Home Page:http://guardian.github.io/scribe/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

allowBlockElements=false in Safari prevents entering new lines

danburzo opened this issue · comments

If you instantiate Scribe with allowBlockElements=false in Safari, you're not able to insert new lines with the Enter key. I'm investigating the source of the bug and will propose a PR, but any guidance in the meantime is appreciated!

I have narrowed it down to this piece of code https://github.com/guardian/scribe/blob/master/src/plugins/core/inline-elements-mode.js#L89 and at first brush it seems Safari and Chrome end up with different ranges, and thus the call to hasContent returns true in Safari (which catches a <br> in the process) and false in Chrome.

I'm now investigating why Safari has a different range than Chrome.

Later edit: Seems like Safari does not respect the DOM 2 insertNode spec, specifically If range’s start and end are the same, set range’s end to (parent, newOffset).

@danburzo thank you for all the detail on this issue 😄

❤️ documentation