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

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

philmcmahon opened this issue · comments

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.

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."

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.