Skip to content

Commit

Permalink
fix cursor issue in Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
zamfofex-dummy committed Sep 6, 2024
1 parent f4eba92 commit de81e23
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions codejar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement, pos?: P
let {anchorNode, anchorOffset, focusNode, focusOffset} = s
if (!anchorNode || !focusNode) throw 'error1'

// If the anchor and focus are the editor element, return either a full
// highlight or a start/end cursor position depending on the selection
if (anchorNode === editor && focusNode === editor) {
pos.start = (anchorOffset > 0 && editor.textContent) ? editor.textContent.length : 0
pos.end = (focusOffset > 0 && editor.textContent) ? editor.textContent.length : 0
pos.dir = (focusOffset >= anchorOffset) ? '->' : '<-'
return pos
}

// Selection anchor and focus are expected to be text nodes,
// so normalize them.
if (anchorNode.nodeType === Node.ELEMENT_NODE) {
Expand Down

0 comments on commit de81e23

Please sign in to comment.