Skip to content

Commit

Permalink
Extend Firefox incorrect-cursor-position bug workaround to check for …
Browse files Browse the repository at this point in the history
…newlines

FIX: Fix an issue where pressing enter at the start of a line in a code block
would leave the visible cursor in the wrong place on Firefox.

Issue ProseMirror/prosemirror#1106
  • Loading branch information
marijnh committed Nov 20, 2020
1 parent 9c0bad9 commit 4d067de
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/viewdesc.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,12 @@ class ViewDesc {
// the cursor sometimes inexplicable visually lags behind its
// reported position in such situations (#1092).
if ((browser.gecko || browser.safari) && anchor == head) {
let prev = anchorDOM.node.childNodes[anchorDOM.offset - 1]
brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false")
if (anchorDOM.node.nodeType == 3) {
brKludge = anchorDOM.offset && anchorDOM.node.nodeValue[anchorDOM.offset - 1] == "\n"
} else {
let prev = anchorDOM.node.childNodes[anchorDOM.offset - 1]
brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false")
}
}

if (!(force || brKludge && browser.safari) &&
Expand Down

0 comments on commit 4d067de

Please sign in to comment.