mirror of
https://github.com/ONLYOFFICE/onlyoffice.github.io.git
synced 2026-02-10 18:05:06 +08:00
Made it so that the assistant does not re-check a paragraph if it was changed automatically by the assistant itself.
This commit is contained in:
@ -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);
|
||||
|
||||
@ -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"]);
|
||||
|
||||
@ -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"]);
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user