syntax highlighting
This commit is contained in:
parent
b9218c8ace
commit
d9b351ad64
5 changed files with 213 additions and 9 deletions
10
static/js/vendor/codejar.js
vendored
10
static/js/vendor/codejar.js
vendored
|
@ -34,11 +34,12 @@ export function CodeJar(editor, highlight, opt = {}) {
|
|||
isLegacy = true;
|
||||
if (isLegacy)
|
||||
editor.setAttribute('contenteditable', 'true');
|
||||
const debounceHighlight = debounce(() => {
|
||||
// PATCH(liquidex): Remove debouncing here.
|
||||
const debounceHighlight = () => {
|
||||
const pos = save();
|
||||
doHighlight(editor, pos);
|
||||
restore(pos);
|
||||
}, 30);
|
||||
};
|
||||
let recording = false;
|
||||
const shouldRecord = (event) => {
|
||||
return !isUndo(event) && !isRedo(event)
|
||||
|
@ -78,14 +79,15 @@ export function CodeJar(editor, highlight, opt = {}) {
|
|||
}
|
||||
if (isLegacy && !isCopy(event))
|
||||
restore(save());
|
||||
|
||||
// PATCH(liquidex): Do highlighting on keypress for faster feedback.
|
||||
requestAnimationFrame(debounceHighlight);
|
||||
});
|
||||
on('keyup', event => {
|
||||
if (event.defaultPrevented)
|
||||
return;
|
||||
if (event.isComposing)
|
||||
return;
|
||||
if (prev !== toString())
|
||||
debounceHighlight();
|
||||
debounceRecordHistory(event);
|
||||
onUpdate(toString());
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue