guardian / scribe

DEPRECATED: A rich text editor framework for the web platform
http://guardian.github.io/scribe/
Apache License 2.0
3.51k stars 245 forks source link

Linking doesn't work correctly when keyboard used to select text in firefox #437

Open philmcmahon opened 8 years ago

philmcmahon commented 8 years ago

If you select text using the keyboard in firefox (e.g. shift+left) then add a link (either with the button or cmd+k) then the link itself gets pasted in instead of the text being linked. This doesn't happen in chrome.

rrees commented 8 years ago

https://github.com/guardian/scribe-plugin-link-prompt-command/issues/12

philmcmahon commented 8 years ago

From Lydia:"It's not the most urgent issue, but it's consistently affecting one of our users, so it would be good to get it fixed."

shaundillon commented 8 years ago

Okay, this appears to be caused by selecting the first piece of text in a node (usually a <p>) with the keyboard. This causes firefox to return the <p> as the currently selection, rather that its content.

We can check is the type of the selection is text, as per the nodeType property and if it isn't (i.e. it's an element) move the selection to its firstChild but this doesn't account for the anchorOffset either. As a result, there is no obvious fix.