make the editor a bit more usable
This commit is contained in:
parent
668e9a050e
commit
6ec7c40f8e
24
static/js/vendor/codejar.js
vendored
24
static/js/vendor/codejar.js
vendored
|
@ -58,6 +58,30 @@ export function CodeJar(editor, highlight, opt = {}) {
|
||||||
listeners.push([type, fn]);
|
listeners.push([type, fn]);
|
||||||
editor.addEventListener(type, fn);
|
editor.addEventListener(type, fn);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// PATCH(liquidex): Prevent cursor jank in Firefox.
|
||||||
|
on('beforeinput', event => {
|
||||||
|
if (isLegacy) {
|
||||||
|
if (event.inputType == "deleteContentBackward") {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
let position = save();
|
||||||
|
document.execCommand("delete");
|
||||||
|
if (position.end != position.start) {
|
||||||
|
if (position.dir == "->") {
|
||||||
|
position.end = position.start;
|
||||||
|
} else {
|
||||||
|
position.start = position.end;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
position.start -= 1;
|
||||||
|
position.end = position.start;
|
||||||
|
}
|
||||||
|
restore(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
on('keydown', event => {
|
on('keydown', event => {
|
||||||
if (event.defaultPrevented)
|
if (event.defaultPrevented)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue