Performance fixes in cledit
This commit is contained in:
parent
d57d2bb969
commit
0b74d48bc8
@ -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);
|
||||
});
|
||||
|
@ -62,7 +62,7 @@ function Highlighter(editor) {
|
||||
}
|
||||
|
||||
this.parseSections = (content, isInit) => {
|
||||
if (true) {
|
||||
if (this.isComposing) {
|
||||
return sectionList;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user