diff --git a/sdkjs-plugins/content/ai/scripts/custom-annotations/assistant-hint.js b/sdkjs-plugins/content/ai/scripts/custom-annotations/assistant-hint.js index ff925a51..3cbf5801 100644 --- a/sdkjs-plugins/content/ai/scripts/custom-annotations/assistant-hint.js +++ b/sdkjs-plugins/content/ai/scripts/custom-annotations/assistant-hint.js @@ -207,6 +207,7 @@ AssistantHint.prototype.getInfoForPopup = function(paraId, rangeId) */ AssistantHint.prototype.onAccept = async function(paraId, rangeId) { + await CustomAnnotator.prototype.onAccept.call(this); await Asc.Editor.callMethod("StartAction", ["GroupActions"]); let range = this.getAnnotationRangeObj(paraId, rangeId); diff --git a/sdkjs-plugins/content/ai/scripts/custom-annotations/assistant-replace-hint.js b/sdkjs-plugins/content/ai/scripts/custom-annotations/assistant-replace-hint.js index 378b483f..065890d3 100644 --- a/sdkjs-plugins/content/ai/scripts/custom-annotations/assistant-replace-hint.js +++ b/sdkjs-plugins/content/ai/scripts/custom-annotations/assistant-replace-hint.js @@ -217,6 +217,7 @@ AssistantReplaceHint.prototype.getInfoForPopup = function(paraId, rangeId) */ AssistantReplaceHint.prototype.onAccept = async function(paraId, rangeId) { + await CustomAnnotator.prototype.onAccept.call(this, paraId, rangeId); let text = this.getAnnotation(paraId, rangeId)["suggestion"]; await Asc.Editor.callMethod("StartAction", ["GroupActions"]); diff --git a/sdkjs-plugins/content/ai/scripts/custom-annotations/assistant-replace.js b/sdkjs-plugins/content/ai/scripts/custom-annotations/assistant-replace.js index 630523be..01bac3c8 100644 --- a/sdkjs-plugins/content/ai/scripts/custom-annotations/assistant-replace.js +++ b/sdkjs-plugins/content/ai/scripts/custom-annotations/assistant-replace.js @@ -204,6 +204,7 @@ AssistantReplace.prototype.getInfoForPopup = function(paraId, rangeId) */ AssistantReplace.prototype.onAccept = async function(paraId, rangeId) { + await CustomAnnotator.prototype.onAccept.call(this); let text = this.getAnnotation(paraId, rangeId)["suggestion"]; await Asc.Editor.callMethod("StartAction", ["GroupActions"]); diff --git a/sdkjs-plugins/content/ai/scripts/custom-annotations/custom-annotator.js b/sdkjs-plugins/content/ai/scripts/custom-annotations/custom-annotator.js index 23146d26..3f573b94 100644 --- a/sdkjs-plugins/content/ai/scripts/custom-annotations/custom-annotator.js +++ b/sdkjs-plugins/content/ai/scripts/custom-annotations/custom-annotator.js @@ -42,6 +42,7 @@ function CustomAnnotator(annotationPopup, assistantData) TextAnnotator.call(this, annotationPopup); this.assistantData = assistantData; this.type = assistantData.type; + this._skipNextChangeParagraph = false; } CustomAnnotator.prototype = Object.create(TextAnnotator.prototype); CustomAnnotator.prototype.constructor = CustomAnnotator; @@ -78,3 +79,19 @@ CustomAnnotator.prototype._handleNewRangePositions = async function(range, paraI Asc.Editor.callMethod("RemoveAnnotationRange", [annotRange]); } }; +/** + * @param {string[]} paraIds + */ +CustomAnnotator.prototype.checkParagraphs = async function(paraIds) +{ + if (this._skipNextChangeParagraph) + { + this._skipNextChangeParagraph = false; + return; + } + TextAnnotator.prototype.checkParagraphs.call(this, paraIds); +}; +CustomAnnotator.prototype.onAccept = async function(paraId, rangeId) +{ + this._skipNextChangeParagraph = true; +}; diff --git a/sdkjs-plugins/content/ai/scripts/custom-annotations/manager.js b/sdkjs-plugins/content/ai/scripts/custom-annotations/manager.js index 8b131abe..08306e2b 100644 --- a/sdkjs-plugins/content/ai/scripts/custom-annotations/manager.js +++ b/sdkjs-plugins/content/ai/scripts/custom-annotations/manager.js @@ -93,6 +93,9 @@ class CustomAssistantManager { assistant.type = assistantData.type; const isRunning = this._isCustomAssistantRunning.get(assistantData.id); + if (!isRunning) { + return assistant; + } this._paragraphsStack.forEach((value, paraId) => { assistant.onChangeParagraph( @@ -103,9 +106,7 @@ class CustomAssistantManager { ); }); const paragraphIdsToUpdate = [...assistant.checked]; - if (isRunning) { - assistant.checkParagraphs(paragraphIdsToUpdate); - } + assistant.checkParagraphs(paragraphIdsToUpdate); return assistant; }