Performance fixes in cledit
This commit is contained in:
parent
d57d2bb969
commit
0b74d48bc8
@ -145,9 +145,6 @@ function cledit(contentElt, scrollEltOpt) {
|
|||||||
let watcher;
|
let watcher;
|
||||||
let skipSaveSelection;
|
let skipSaveSelection;
|
||||||
function checkContentChange(mutations) {
|
function checkContentChange(mutations) {
|
||||||
if (contentElt.textContent.indexOf('.') >= 0) {
|
|
||||||
debugger;
|
|
||||||
}
|
|
||||||
watcher.noWatch(() => {
|
watcher.noWatch(() => {
|
||||||
const removedSections = [];
|
const removedSections = [];
|
||||||
const modifiedSections = [];
|
const modifiedSections = [];
|
||||||
@ -175,17 +172,17 @@ function cledit(contentElt, scrollEltOpt) {
|
|||||||
noContentFix = false;
|
noContentFix = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!skipSaveSelection) {
|
||||||
|
selectionMgr.saveSelectionState();
|
||||||
|
}
|
||||||
|
skipSaveSelection = false;
|
||||||
|
|
||||||
const newTextContent = getTextContent();
|
const newTextContent = getTextContent();
|
||||||
const diffs = diffMatchPatch.diff_main(lastTextContent, newTextContent);
|
const diffs = diffMatchPatch.diff_main(lastTextContent, newTextContent);
|
||||||
editor.$markers.cl_each((marker) => {
|
editor.$markers.cl_each((marker) => {
|
||||||
marker.adjustOffset(diffs);
|
marker.adjustOffset(diffs);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!skipSaveSelection) {
|
|
||||||
selectionMgr.saveSelectionState();
|
|
||||||
}
|
|
||||||
skipSaveSelection = false;
|
|
||||||
|
|
||||||
const sectionList = highlighter.parseSections(newTextContent);
|
const sectionList = highlighter.parseSections(newTextContent);
|
||||||
editor.$trigger('contentChanged', newTextContent, diffs, sectionList);
|
editor.$trigger('contentChanged', newTextContent, diffs, sectionList);
|
||||||
if (!ignoreUndo) {
|
if (!ignoreUndo) {
|
||||||
@ -315,6 +312,9 @@ function cledit(contentElt, scrollEltOpt) {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (highlighter.isComposing) {
|
if (highlighter.isComposing) {
|
||||||
highlighter.isComposing -= 1;
|
highlighter.isComposing -= 1;
|
||||||
|
if (!highlighter.isComposing) {
|
||||||
|
checkContentChange([]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
});
|
});
|
||||||
|
@ -62,7 +62,7 @@ function Highlighter(editor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.parseSections = (content, isInit) => {
|
this.parseSections = (content, isInit) => {
|
||||||
if (true) {
|
if (this.isComposing) {
|
||||||
return sectionList;
|
return sectionList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ Utils.createEventHooks = (object) => {
|
|||||||
try {
|
try {
|
||||||
listener.apply(object, args);
|
listener.apply(object, args);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.error(e.message, e.stack);
|
console.error(e.message, e.stack);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user