Performance fixes in cledit

This commit is contained in:
benweet 2018-02-17 18:04:58 +00:00
parent d57d2bb969
commit 0b74d48bc8
3 changed files with 10 additions and 9 deletions

View File

@ -145,9 +145,6 @@ function cledit(contentElt, scrollEltOpt) {
let watcher;
let skipSaveSelection;
function checkContentChange(mutations) {
if (contentElt.textContent.indexOf('.') >= 0) {
debugger;
}
watcher.noWatch(() => {
const removedSections = [];
const modifiedSections = [];
@ -175,17 +172,17 @@ function cledit(contentElt, scrollEltOpt) {
noContentFix = false;
});
if (!skipSaveSelection) {
selectionMgr.saveSelectionState();
}
skipSaveSelection = false;
const newTextContent = getTextContent();
const diffs = diffMatchPatch.diff_main(lastTextContent, newTextContent);
editor.$markers.cl_each((marker) => {
marker.adjustOffset(diffs);
});
if (!skipSaveSelection) {
selectionMgr.saveSelectionState();
}
skipSaveSelection = false;
const sectionList = highlighter.parseSections(newTextContent);
editor.$trigger('contentChanged', newTextContent, diffs, sectionList);
if (!ignoreUndo) {
@ -315,6 +312,9 @@ function cledit(contentElt, scrollEltOpt) {
setTimeout(() => {
if (highlighter.isComposing) {
highlighter.isComposing -= 1;
if (!highlighter.isComposing) {
checkContentChange([]);
}
}
}, 1);
});

View File

@ -62,7 +62,7 @@ function Highlighter(editor) {
}
this.parseSections = (content, isInit) => {
if (true) {
if (this.isComposing) {
return sectionList;
}

View File

@ -67,6 +67,7 @@ Utils.createEventHooks = (object) => {
try {
listener.apply(object, args);
} catch (e) {
// eslint-disable-next-line no-console
console.error(e.message, e.stack);
}
});