diff --git a/src/services/cledit/cleditCore.js b/src/services/cledit/cleditCore.js index 42b0d65c..00a04c33 100644 --- a/src/services/cledit/cleditCore.js +++ b/src/services/cledit/cleditCore.js @@ -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); }); diff --git a/src/services/cledit/cleditHighlighter.js b/src/services/cledit/cleditHighlighter.js index a23c2aea..dc685b19 100644 --- a/src/services/cledit/cleditHighlighter.js +++ b/src/services/cledit/cleditHighlighter.js @@ -62,7 +62,7 @@ function Highlighter(editor) { } this.parseSections = (content, isInit) => { - if (true) { + if (this.isComposing) { return sectionList; } diff --git a/src/services/cledit/cleditUtils.js b/src/services/cledit/cleditUtils.js index 1c5e9ca6..bbb365d5 100644 --- a/src/services/cledit/cleditUtils.js +++ b/src/services/cledit/cleditUtils.js @@ -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); } });