mirror of
https://github.com/ONLYOFFICE/onlyoffice.github.io.git
synced 2026-04-07 14:04:30 +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)
|
AssistantHint.prototype.onAccept = async function(paraId, rangeId)
|
||||||
{
|
{
|
||||||
|
await CustomAnnotator.prototype.onAccept.call(this);
|
||||||
await Asc.Editor.callMethod("StartAction", ["GroupActions"]);
|
await Asc.Editor.callMethod("StartAction", ["GroupActions"]);
|
||||||
|
|
||||||
let range = this.getAnnotationRangeObj(paraId, rangeId);
|
let range = this.getAnnotationRangeObj(paraId, rangeId);
|
||||||
|
|||||||
@ -217,6 +217,7 @@ AssistantReplaceHint.prototype.getInfoForPopup = function(paraId, rangeId)
|
|||||||
*/
|
*/
|
||||||
AssistantReplaceHint.prototype.onAccept = async 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"];
|
let text = this.getAnnotation(paraId, rangeId)["suggestion"];
|
||||||
|
|
||||||
await Asc.Editor.callMethod("StartAction", ["GroupActions"]);
|
await Asc.Editor.callMethod("StartAction", ["GroupActions"]);
|
||||||
|
|||||||
@ -204,6 +204,7 @@ AssistantReplace.prototype.getInfoForPopup = function(paraId, rangeId)
|
|||||||
*/
|
*/
|
||||||
AssistantReplace.prototype.onAccept = async function(paraId, rangeId)
|
AssistantReplace.prototype.onAccept = async function(paraId, rangeId)
|
||||||
{
|
{
|
||||||
|
await CustomAnnotator.prototype.onAccept.call(this);
|
||||||
let text = this.getAnnotation(paraId, rangeId)["suggestion"];
|
let text = this.getAnnotation(paraId, rangeId)["suggestion"];
|
||||||
|
|
||||||
await Asc.Editor.callMethod("StartAction", ["GroupActions"]);
|
await Asc.Editor.callMethod("StartAction", ["GroupActions"]);
|
||||||
|
|||||||
@ -42,6 +42,7 @@ function CustomAnnotator(annotationPopup, assistantData)
|
|||||||
TextAnnotator.call(this, annotationPopup);
|
TextAnnotator.call(this, annotationPopup);
|
||||||
this.assistantData = assistantData;
|
this.assistantData = assistantData;
|
||||||
this.type = assistantData.type;
|
this.type = assistantData.type;
|
||||||
|
this._skipNextChangeParagraph = false;
|
||||||
}
|
}
|
||||||
CustomAnnotator.prototype = Object.create(TextAnnotator.prototype);
|
CustomAnnotator.prototype = Object.create(TextAnnotator.prototype);
|
||||||
CustomAnnotator.prototype.constructor = CustomAnnotator;
|
CustomAnnotator.prototype.constructor = CustomAnnotator;
|
||||||
@ -78,3 +79,19 @@ CustomAnnotator.prototype._handleNewRangePositions = async function(range, paraI
|
|||||||
Asc.Editor.callMethod("RemoveAnnotationRange", [annotRange]);
|
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;
|
assistant.type = assistantData.type;
|
||||||
|
|
||||||
const isRunning = this._isCustomAssistantRunning.get(assistantData.id);
|
const isRunning = this._isCustomAssistantRunning.get(assistantData.id);
|
||||||
|
if (!isRunning) {
|
||||||
|
return assistant;
|
||||||
|
}
|
||||||
|
|
||||||
this._paragraphsStack.forEach((value, paraId) => {
|
this._paragraphsStack.forEach((value, paraId) => {
|
||||||
assistant.onChangeParagraph(
|
assistant.onChangeParagraph(
|
||||||
@ -103,9 +106,7 @@ class CustomAssistantManager {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
const paragraphIdsToUpdate = [...assistant.checked];
|
const paragraphIdsToUpdate = [...assistant.checked];
|
||||||
if (isRunning) {
|
|
||||||
assistant.checkParagraphs(paragraphIdsToUpdate);
|
assistant.checkParagraphs(paragraphIdsToUpdate);
|
||||||
}
|
|
||||||
|
|
||||||
return assistant;
|
return assistant;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user