Check grammar and spelling only when pressing button
Also change icons for grammar and spelling
BIN
sdkjs-plugins/content/ai/resources/icons/dark/big/grammar.png
Normal file
|
After Width: | Height: | Size: 429 B |
|
After Width: | Height: | Size: 539 B |
|
After Width: | Height: | Size: 613 B |
|
After Width: | Height: | Size: 789 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/big/grammar@2x.png
Normal file
|
After Width: | Height: | Size: 815 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/grammar.png
Normal file
|
After Width: | Height: | Size: 414 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/grammar@1.25x.png
Normal file
|
After Width: | Height: | Size: 477 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/grammar@1.5x.png
Normal file
|
After Width: | Height: | Size: 534 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/grammar@1.75x.png
Normal file
|
After Width: | Height: | Size: 603 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/grammar@2x.png
Normal file
|
After Width: | Height: | Size: 624 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/grammar.png
Normal file
|
After Width: | Height: | Size: 415 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/grammar@1.25x.png
Normal file
|
After Width: | Height: | Size: 456 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/grammar@1.5x.png
Normal file
|
After Width: | Height: | Size: 516 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/grammar@1.75x.png
Normal file
|
After Width: | Height: | Size: 562 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/grammar@2x.png
Normal file
|
After Width: | Height: | Size: 607 B |
@ -828,10 +828,32 @@ function onTranslateSettingsModal() {
|
||||
translateSettingsWindow.show(variation);
|
||||
}
|
||||
|
||||
function onCheckGrammarSpelling(isCurrent)
|
||||
async function onCheckGrammarSpelling(isCurrent)
|
||||
{
|
||||
// TODO: implement
|
||||
console.log(`Check grammar & spelling all= ${!isCurrent}`);
|
||||
console.log(`Check grammar & spelling all= ${!isCurrent}`);
|
||||
if (isCurrent)
|
||||
{
|
||||
let paraIds = await Asc.Editor.callCommand(function(){
|
||||
let result = [];
|
||||
let paragraphs = Api.GetDocument().GetRangeBySelect().GetAllParagraphs();
|
||||
paragraphs.forEach(p => result.push(p.GetInternalId()));
|
||||
return result;
|
||||
});
|
||||
|
||||
if (spellchecker)
|
||||
spellchecker.checkParagraphs(paraIds);
|
||||
|
||||
if (grammar)
|
||||
grammar.checkParagraphs(paraIds);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (spellchecker)
|
||||
spellchecker.checkAll();
|
||||
|
||||
if (grammar)
|
||||
grammar.checkAll();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -142,13 +142,12 @@ function registerButtons(window, undefined)
|
||||
{
|
||||
let buttonSub = new Asc.ButtonContextMenu(buttonMain);
|
||||
buttonSub.text = "Grammar & Spelling";
|
||||
buttonSub.icons = getContextMenuButtonIcons("summarization");
|
||||
buttonSub.icons = getContextMenuButtonIcons("grammar");
|
||||
buttonSub.editors = ["word"];
|
||||
buttonSub.addCheckers("Target", "Selection");
|
||||
|
||||
let buttonAll = new Asc.ButtonContextMenu(buttonSub);
|
||||
buttonAll.text = "Check all";
|
||||
buttonAll.icons = getContextMenuButtonIcons("text-analysis-ai");
|
||||
buttonAll.editors = ["word"];
|
||||
buttonAll.addCheckers("Target", "Selection");
|
||||
|
||||
@ -158,7 +157,6 @@ function registerButtons(window, undefined)
|
||||
|
||||
let buttonCurrent = new Asc.ButtonContextMenu(buttonSub);
|
||||
buttonCurrent.text = "Check current selection";
|
||||
buttonCurrent.icons = getContextMenuButtonIcons("text-analysis-ai");
|
||||
buttonCurrent.editors = ["word"];
|
||||
buttonCurrent.addCheckers("Target", "Selection");
|
||||
|
||||
|
||||
@ -36,42 +36,63 @@ function TextAnnotator()
|
||||
this.rangeId = null;
|
||||
|
||||
this.paragraphs = {};
|
||||
this.waitParagraphs = {};
|
||||
this.paraToCheck = new Set();
|
||||
this.isCheckAll = true;
|
||||
|
||||
this.checked = {};
|
||||
|
||||
this.type = -1;
|
||||
}
|
||||
TextAnnotator.prototype.onChangeParagraph = async function(paraId, recalcId, text, ranges)
|
||||
{
|
||||
// TODO: Update ranges
|
||||
|
||||
this.waitParagraphs[paraId] = {
|
||||
recalcId : recalcId,
|
||||
text : text
|
||||
};
|
||||
|
||||
this._checkParagraph();
|
||||
//this.annotateParagraph(paraId, recalcId, text, ranges);
|
||||
this._checkParagraph(paraId);
|
||||
};
|
||||
TextAnnotator.prototype.checkParagraphs = async function(paraIds)
|
||||
{
|
||||
this.isCheckAll = false;
|
||||
|
||||
this.paraToCheck.clear()
|
||||
paraIds.array.forEach(paraId => this.paraToCheck.add(paraId));
|
||||
//for (let paraId in )
|
||||
paraIds.forEach(paraId => this.paraToCheck.add(paraId));
|
||||
this.paraToCheck.forEach(paraId => this._checkParagraph(paraId));
|
||||
};
|
||||
TextAnnotator.prototype.checkAll = async function()
|
||||
{
|
||||
if (this.isCheckAll)
|
||||
return;
|
||||
|
||||
this.isCheckAll = true;
|
||||
|
||||
this.checked = {};
|
||||
};
|
||||
TextAnnotator.prototype._checkParagraph = function(paraId)
|
||||
{
|
||||
if (!this.paraToCheck[paraId] || !this.waitParagraphs[paraId])
|
||||
if (!this.paraToCheck.has(paraId) || !this.waitParagraphs[paraId])
|
||||
return;
|
||||
|
||||
let recalcId = this.waitParagraphs[paraId].recalcId;
|
||||
let text = this.waitParagraphs[paraId].text;
|
||||
|
||||
// TODO: Temporarily for simplicity
|
||||
let range = this.getAnnotationRangeObj(paraId);
|
||||
range["rangeId"] = undefined;
|
||||
range["all"] = true;
|
||||
Asc.Editor.callMethod("RemoveAnnotationRange", [range]);
|
||||
|
||||
this.annotateParagraph(paraId, recalcId, text);
|
||||
|
||||
delete this.waitParagraphs[paraId];
|
||||
this.paraToCheck.remove;
|
||||
this.paraToCheck.delete(paraId);
|
||||
};
|
||||
TextAnnotator.prototype.annotateParagraph = async function(paraId, recalcId, text)
|
||||
{
|
||||
|
||||
};
|
||||
TextAnnotator.prototype.openPopup = async function(paraId, rangeId)
|
||||
{
|
||||
|
||||