Skip to content

Commit 4d19174

Browse files
authored
fix: bug with contenteditable plaintext-only mode on Firefox versions >136 (#126)
1 parent ab52adb commit 4d19174

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

codejar.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,16 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement, pos?: P
6767
const doHighlight = (editor: HTMLElement, pos?: Position) => {
6868
highlight(editor, pos)
6969
}
70-
71-
let isLegacy = false // true if plaintext-only is not supported
72-
if (editor.contentEditable !== 'plaintext-only') isLegacy = true
73-
if (isLegacy) editor.setAttribute('contenteditable', 'true')
70+
71+
const matchFirefoxVersion =
72+
window.navigator.userAgent.match(/Firefox\/([0-9]+)\./);
73+
const firefoxVersion = matchFirefoxVersion
74+
? parseInt(matchFirefoxVersion[1])
75+
: 0;
76+
let isLegacy = false; // true if plaintext-only is not supported
77+
if (editor.contentEditable !== "plaintext-only" || firefoxVersion >= 136)
78+
isLegacy = true;
79+
if (isLegacy) editor.setAttribute("contenteditable", "true");
7480

7581
const debounceHighlight = debounce(() => {
7682
const pos = save()

0 commit comments

Comments
 (0)