Reorganize context menu
BIN
sdkjs-plugins/content/ai/resources/icons/dark/big/ocr.png
Normal file
|
After Width: | Height: | Size: 125 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/big/ocr@1.25x.png
Normal file
|
After Width: | Height: | Size: 131 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/big/ocr@1.5x.png
Normal file
|
After Width: | Height: | Size: 141 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/big/ocr@1.75x.png
Normal file
|
After Width: | Height: | Size: 143 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/big/ocr@2x.png
Normal file
|
After Width: | Height: | Size: 173 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/general-ai.png
Normal file
|
After Width: | Height: | Size: 211 B |
|
After Width: | Height: | Size: 245 B |
|
After Width: | Height: | Size: 262 B |
|
After Width: | Height: | Size: 330 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/general-ai@2x.png
Normal file
|
After Width: | Height: | Size: 335 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/image-ai.png
Normal file
|
After Width: | Height: | Size: 206 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/image-ai@1.25x.png
Normal file
|
After Width: | Height: | Size: 212 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/image-ai@1.5x.png
Normal file
|
After Width: | Height: | Size: 261 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/image-ai@1.75x.png
Normal file
|
After Width: | Height: | Size: 270 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/image-ai@2x.png
Normal file
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 154 B |
|
After Width: | Height: | Size: 164 B |
|
After Width: | Height: | Size: 181 B |
|
After Width: | Height: | Size: 190 B |
|
After Width: | Height: | Size: 222 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/vision-ai.png
Normal file
|
After Width: | Height: | Size: 197 B |
|
After Width: | Height: | Size: 238 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/vision-ai@1.5x.png
Normal file
|
After Width: | Height: | Size: 277 B |
|
After Width: | Height: | Size: 296 B |
BIN
sdkjs-plugins/content/ai/resources/icons/dark/vision-ai@2x.png
Normal file
|
After Width: | Height: | Size: 329 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/big/ocr.png
Normal file
|
After Width: | Height: | Size: 124 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/big/ocr@1.25x.png
Normal file
|
After Width: | Height: | Size: 130 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/big/ocr@1.5x.png
Normal file
|
After Width: | Height: | Size: 140 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/big/ocr@1.75x.png
Normal file
|
After Width: | Height: | Size: 143 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/big/ocr@2x.png
Normal file
|
After Width: | Height: | Size: 175 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/general-ai.png
Normal file
|
After Width: | Height: | Size: 198 B |
|
After Width: | Height: | Size: 226 B |
|
After Width: | Height: | Size: 246 B |
|
After Width: | Height: | Size: 304 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/general-ai@2x.png
Normal file
|
After Width: | Height: | Size: 334 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/image-ai.png
Normal file
|
After Width: | Height: | Size: 204 B |
|
After Width: | Height: | Size: 209 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/image-ai@1.5x.png
Normal file
|
After Width: | Height: | Size: 255 B |
|
After Width: | Height: | Size: 263 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/image-ai@2x.png
Normal file
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 152 B |
|
After Width: | Height: | Size: 162 B |
|
After Width: | Height: | Size: 178 B |
|
After Width: | Height: | Size: 187 B |
|
After Width: | Height: | Size: 225 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/vision-ai.png
Normal file
|
After Width: | Height: | Size: 193 B |
|
After Width: | Height: | Size: 236 B |
|
After Width: | Height: | Size: 268 B |
|
After Width: | Height: | Size: 280 B |
BIN
sdkjs-plugins/content/ai/resources/icons/light/vision-ai@2x.png
Normal file
|
After Width: | Height: | Size: 326 B |
@ -145,7 +145,7 @@ window.Asc.plugin.init = async function() {
|
||||
|
||||
let buttonOCRPage = new Asc.ButtonToolbar(null);
|
||||
buttonOCRPage.text = "OCR";
|
||||
buttonOCRPage.icons = window.getToolBarButtonIcons("settings");
|
||||
buttonOCRPage.icons = window.getToolBarButtonIcons("ocr");
|
||||
window.buttonOCRPage = buttonOCRPage;
|
||||
|
||||
if (0x80 & restriction)
|
||||
|
||||
@ -1,8 +1,17 @@
|
||||
(function(window, undefined)
|
||||
{
|
||||
function getToolBarButtonIcons(icon) {
|
||||
return "resources/icons/%theme-type%(light|dark)/big/" + icon + "%scale%(default).png";
|
||||
}
|
||||
|
||||
function getContextMenuButtonIcons(icon) {
|
||||
return "resources/icons/%theme-type%(light|dark)/" + icon + "%scale%(default).png";
|
||||
}
|
||||
|
||||
// register contextmenu buttons
|
||||
let buttonMain = new Asc.ButtonContextMenu();
|
||||
buttonMain.text = "AI";
|
||||
buttonMain.icons = getContextMenuButtonIcons("general-ai");
|
||||
buttonMain.addCheckers("All");
|
||||
|
||||
function chatWindowShow(attachedText)
|
||||
@ -93,53 +102,40 @@
|
||||
|
||||
window.chatWindow = chatWindow;
|
||||
}
|
||||
|
||||
|
||||
// Submenu summarize:
|
||||
if (true)
|
||||
{
|
||||
let button1 = new Asc.ButtonContextMenu(buttonMain);
|
||||
button1.text = "Explain text in comment";
|
||||
button1.addCheckers("Target");
|
||||
button1.attachOnClick(async function(){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.TextAnalyze);
|
||||
if (!requestEngine)
|
||||
return;
|
||||
|
||||
let content = await Asc.Library.GetCurrentWord();
|
||||
if (!content)
|
||||
return;
|
||||
let prompt = Asc.Prompts.getExplainPrompt(content);
|
||||
let result = await requestEngine.chatRequest(prompt);
|
||||
if (!result) return;
|
||||
|
||||
result = result.replace(/\n\n/g, '\n');
|
||||
await Asc.Library.InsertAsComment(result);
|
||||
});
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
let button1 = new Asc.ButtonContextMenu(buttonMain);
|
||||
button1.text = "Fix spelling & grammar";
|
||||
button1.editors = ["word"];
|
||||
button1.addCheckers("Selection");
|
||||
button1.attachOnClick(async function(){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.TextAnalyze);
|
||||
let button = new Asc.ButtonContextMenu(buttonMain);
|
||||
button.text = "Summarization";
|
||||
button.icons = getContextMenuButtonIcons("summarization");
|
||||
button.editors = ["word"];
|
||||
button.addCheckers("Selection");
|
||||
button.attachOnClick(async function(data){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.Summarization);
|
||||
if (!requestEngine)
|
||||
return;
|
||||
|
||||
let content = await Asc.Library.GetSelectedText();
|
||||
let prompt = Asc.Prompts.getFixAndSpellPrompt(content);
|
||||
|
||||
let prompt = Asc.Prompts.getSummarizationPrompt(content);
|
||||
let result = await requestEngine.chatRequest(prompt);
|
||||
if (!result) return;
|
||||
|
||||
if (result !== 'The text is correct, there are no errors in it.')
|
||||
await Asc.Library.ReplaceTextSmart([result]);
|
||||
else
|
||||
console.log('The text is correct, there are no errors in it.');
|
||||
result = "Summary:\n\n" + result;
|
||||
await Asc.Library.InsertAsText(result);
|
||||
});
|
||||
}
|
||||
|
||||
let button2 = new Asc.ButtonContextMenu(buttonMain);
|
||||
// Submenu Text Analysis
|
||||
if (true)
|
||||
{
|
||||
let button1 = new Asc.ButtonContextMenu(buttonMain);
|
||||
button1.text = "Text analysis";
|
||||
button1.icons = getContextMenuButtonIcons("text-analysis-ai");
|
||||
button1.editors = ["word"];
|
||||
button1.addCheckers("Target", "Selection");
|
||||
|
||||
let button2 = new Asc.ButtonContextMenu(button1);
|
||||
button2.text = "Rewrite differently";
|
||||
button2.editors = ["word"];
|
||||
button2.addCheckers("Selection");
|
||||
@ -157,7 +153,7 @@
|
||||
await Asc.Library.PasteText(result);
|
||||
});
|
||||
|
||||
let button3 = new Asc.ButtonContextMenu(buttonMain);
|
||||
let button3 = new Asc.ButtonContextMenu(button1);
|
||||
button3.text = "Make longer";
|
||||
button3.editors = ["word"];
|
||||
button3.addCheckers("Selection");
|
||||
@ -175,7 +171,7 @@
|
||||
await Asc.Library.PasteText(result);
|
||||
});
|
||||
|
||||
let button4 = new Asc.ButtonContextMenu(buttonMain);
|
||||
let button4 = new Asc.ButtonContextMenu(button1);
|
||||
button4.text = "Make shorter";
|
||||
button4.editors = ["word"];
|
||||
button4.addCheckers("Selection");
|
||||
@ -192,38 +188,78 @@
|
||||
result = result.replace(/\n\n/g, '\n');
|
||||
await Asc.Library.PasteText(result);
|
||||
});
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
let button1 = new Asc.ButtonContextMenu(buttonMain);
|
||||
button1.text = "Text analysis";
|
||||
button1.editors = ["word"];
|
||||
button1.addCheckers("Selection");
|
||||
|
||||
let button2 = new Asc.ButtonContextMenu(button1);
|
||||
button2.text = "Summarize";
|
||||
button2.editors = ["word"];
|
||||
button2.addCheckers("Selection");
|
||||
button2.attachOnClick(async function(data){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.Summarization);
|
||||
let button5 = new Asc.ButtonContextMenu(button1);
|
||||
button5.text = "Explain text in comment";
|
||||
button5.separator = true;
|
||||
button5.editors = ["word"];
|
||||
button5.addCheckers("Target", "Selection");
|
||||
button5.attachOnClick(async function(){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.TextAnalyze);
|
||||
if (!requestEngine)
|
||||
return;
|
||||
|
||||
let content = await Asc.Library.GetSelectedText();
|
||||
let prompt = Asc.Prompts.getSummarizationPrompt(content);
|
||||
if (!content)
|
||||
content = await Asc.Library.GetCurrentWord();
|
||||
|
||||
if (!content)
|
||||
return;
|
||||
|
||||
let prompt = Asc.Prompts.getExplainPrompt(content);
|
||||
let result = await requestEngine.chatRequest(prompt);
|
||||
if (!result) return;
|
||||
|
||||
result = "Summary:\n\n" + result;
|
||||
await Asc.Library.InsertAsText(result);
|
||||
result = result.replace(/\n\n/g, '\n');
|
||||
await Asc.Library.InsertAsComment(result);
|
||||
});
|
||||
|
||||
let button3 = new Asc.ButtonContextMenu(button1);
|
||||
button3.text = "Keywords";
|
||||
button3.editors = ["word"];
|
||||
button3.addCheckers("Selection");
|
||||
button3.attachOnClick(async function(){
|
||||
let button6 = new Asc.ButtonContextMenu(button1);
|
||||
button6.text = "Explain text in hyperlink";
|
||||
button6.separator = true;
|
||||
button6.editors = ["word"];
|
||||
button6.addCheckers("Selection");
|
||||
button6.attachOnClick(async function(){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.TextAnalyze);
|
||||
if (!requestEngine)
|
||||
return;
|
||||
|
||||
let content = await Asc.Library.GetSelectedText();
|
||||
let prompt = Asc.Prompts.getExplainAsLinkPrompt(content);
|
||||
let result = await requestEngine.chatRequest(prompt);
|
||||
if (!result) return;
|
||||
|
||||
result = result.replace(/\n\n/g, '\n');
|
||||
await Asc.Library.InsertAsHyperlink(result);
|
||||
});
|
||||
|
||||
let button7 = new Asc.ButtonContextMenu(button1);
|
||||
button7.text = "Fix spelling & grammar";
|
||||
button7.separator = true;
|
||||
button7.editors = ["word"];
|
||||
button7.addCheckers("Selection");
|
||||
button7.attachOnClick(async function(){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.TextAnalyze);
|
||||
if (!requestEngine)
|
||||
return;
|
||||
|
||||
let content = await Asc.Library.GetSelectedText();
|
||||
let prompt = Asc.Prompts.getFixAndSpellPrompt(content);
|
||||
|
||||
let result = await requestEngine.chatRequest(prompt);
|
||||
if (!result) return;
|
||||
|
||||
if (result !== 'The text is correct, there are no errors in it.')
|
||||
await Asc.Library.ReplaceTextSmart([result]);
|
||||
else
|
||||
console.log('The text is correct, there are no errors in it.');
|
||||
});
|
||||
|
||||
let button8 = new Asc.ButtonContextMenu(button1);
|
||||
button8.text = "Keywords";
|
||||
button8.editors = ["word"];
|
||||
button8.addCheckers("Selection");
|
||||
button8.attachOnClick(async function(){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.TextAnalyze);
|
||||
if (!requestEngine)
|
||||
return;
|
||||
@ -237,61 +273,18 @@
|
||||
});
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
let button1 = new Asc.ButtonContextMenu(buttonMain);
|
||||
button1.text = "Word analysis";
|
||||
button1.editors = ["word"];
|
||||
button1.separator = true,
|
||||
button1.addCheckers("Selection");
|
||||
|
||||
let button2 = new Asc.ButtonContextMenu(button1);
|
||||
button2.text = "Explain text in comment";
|
||||
button2.editors = ["word"];
|
||||
button2.addCheckers("Selection");
|
||||
button2.attachOnClick(async function(){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.TextAnalyze);
|
||||
if (!requestEngine)
|
||||
return;
|
||||
|
||||
let content = await Asc.Library.GetSelectedText();
|
||||
let prompt = Asc.Prompts.getExplainPrompt(content);
|
||||
let result = await requestEngine.chatRequest(prompt);
|
||||
if (!result) return;
|
||||
|
||||
result = result.replace(/\n\n/g, '\n');
|
||||
await Asc.Library.InsertAsComment(result);
|
||||
});
|
||||
|
||||
let button3 = new Asc.ButtonContextMenu(button1);
|
||||
button3.text = "Explain text in hyperlink";
|
||||
button3.editors = ["word"];
|
||||
button3.addCheckers("Selection");
|
||||
button3.attachOnClick(async function(){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.TextAnalyze);
|
||||
if (!requestEngine)
|
||||
return;
|
||||
|
||||
let content = await Asc.Library.GetSelectedText();
|
||||
let prompt = Asc.Prompts.getExplainAsLinkPrompt(content);
|
||||
let result = await requestEngine.chatRequest(prompt);
|
||||
if (!result) return;
|
||||
|
||||
result = result.replace(/\n\n/g, '\n');
|
||||
await Asc.Library.InsertAsHyperlink(result);
|
||||
});
|
||||
}
|
||||
|
||||
// Submenu Translate
|
||||
if (true)
|
||||
{
|
||||
let button1 = new Asc.ButtonContextMenu(buttonMain);
|
||||
button1.text = "Translate";
|
||||
button1.editors = ["word"];
|
||||
button1.icons = getContextMenuButtonIcons("translation");
|
||||
button1.editors = ["word", "slide", "cell"];
|
||||
button1.addCheckers("Selection");
|
||||
|
||||
let button2 = new Asc.ButtonContextMenu(button1);
|
||||
button2.text = "English";
|
||||
button2.editors = ["word"];
|
||||
button2.editors = ["word", "slide", "cell"];
|
||||
button2.addCheckers("Selection");
|
||||
button2.data = "English";
|
||||
button2.attachOnClick(async function(data){
|
||||
@ -346,43 +339,6 @@
|
||||
button10.data = "Italian";
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
// TODO:
|
||||
let button1 = new Asc.ButtonContextMenu(buttonMain);
|
||||
button1.text = "Generate image from text";
|
||||
button1.editors = ["word"];
|
||||
button1.addCheckers("Selection");
|
||||
|
||||
let button2 = new Asc.ButtonContextMenu(button1);
|
||||
button2.text = "256x256";
|
||||
button2.editors = ["word"];
|
||||
button2.addCheckers("Selection");
|
||||
button2.data = "256";
|
||||
button2.attachOnClick(function(data){
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
let button3 = button2.copy();
|
||||
button3.text = "512x512";
|
||||
button3.data = "512";
|
||||
|
||||
let button4 = button2.copy();
|
||||
button4.text = "1024x1024";
|
||||
button4.data = "1024";
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
// TODO:
|
||||
let button1 = new Asc.ButtonContextMenu(buttonMain);
|
||||
button1.text = "Generate image variation";
|
||||
button1.addCheckers("Shape", "Image");
|
||||
button1.attachOnClick(function(data){
|
||||
console.log(data);
|
||||
});
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
let button1 = new Asc.ButtonContextMenu(buttonMain);
|
||||
@ -422,11 +378,11 @@
|
||||
{
|
||||
let buttonImages = new Asc.ButtonContextMenu(buttonMain);
|
||||
buttonImages.text = "Image";
|
||||
buttonImages.icons = getContextMenuButtonIcons("image-ai");
|
||||
buttonImages.addCheckers("Selection", "Image");
|
||||
buttonImages.separator = true;
|
||||
|
||||
let buttonGen = new Asc.ButtonContextMenu(buttonImages);
|
||||
buttonGen.text = "Generate by selection text";
|
||||
buttonGen.text = "Text to Image";
|
||||
buttonGen.addCheckers("Selection");
|
||||
buttonGen.attachOnClick(async function(){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.ImageGeneration);
|
||||
@ -462,7 +418,7 @@
|
||||
});
|
||||
|
||||
let buttonExplainImage = new Asc.ButtonContextMenu(buttonImages);
|
||||
buttonExplainImage.text = "Description";
|
||||
buttonExplainImage.text = "Image to Text";
|
||||
buttonExplainImage.addCheckers("Image");
|
||||
buttonExplainImage.attachOnClick(async function(){
|
||||
let requestEngine = AI.Request.create(AI.ActionType.Vision);
|
||||
@ -488,6 +444,7 @@
|
||||
let button1 = new Asc.ButtonContextMenu(buttonMain);
|
||||
button1.text = "Chatbot";
|
||||
button1.separator = true;
|
||||
button1.icons = getContextMenuButtonIcons("ask-ai");
|
||||
button1.addCheckers("All");
|
||||
button1.attachOnClick(async function(){
|
||||
let selectedText = await Asc.Library.GetSelectedText();
|
||||
@ -495,7 +452,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
if (true)
|
||||
if (false)
|
||||
{
|
||||
let button1 = new Asc.ButtonContextMenu(buttonMain);
|
||||
button1.text = "Settings";
|
||||
@ -510,10 +467,6 @@
|
||||
let buttonMainToolbar = new Asc.ButtonToolbar();
|
||||
buttonMainToolbar.text = "AI";
|
||||
|
||||
function getToolBarButtonIcons(icon) {
|
||||
return "resources/icons/%theme-type%(light|dark)/big/" + icon + "%scale%(default).png";
|
||||
}
|
||||
|
||||
window.buttonMainToolbar = buttonMainToolbar;
|
||||
window.getToolBarButtonIcons = getToolBarButtonIcons;
|
||||
|
||||
@ -618,10 +571,10 @@
|
||||
AI.Actions[AI.ActionType.Summarization] = new ActionUI("Summarization", "summarization");
|
||||
//AI.Actions[AI.ActionType.Text2Image] = new ActionUI("Text to image", "text-to-image", "", AI.CapabilitiesUI.Image);
|
||||
AI.Actions[AI.ActionType.Translation] = new ActionUI("Translation", "translation");
|
||||
AI.Actions[AI.ActionType.TextAnalyze] = new ActionUI("Text analysis", "");
|
||||
AI.Actions[AI.ActionType.ImageGeneration] = new ActionUI("Image generation", "", "", AI.CapabilitiesUI.Image);
|
||||
AI.Actions[AI.ActionType.OCR] = new ActionUI("OCR", "", "", AI.CapabilitiesUI.Vision);
|
||||
AI.Actions[AI.ActionType.Vision] = new ActionUI("Vision", "", "", AI.CapabilitiesUI.Vision);
|
||||
AI.Actions[AI.ActionType.TextAnalyze] = new ActionUI("Text analysis", "text-analysis-ai");
|
||||
AI.Actions[AI.ActionType.ImageGeneration] = new ActionUI("Image generation", "image-ai", "", AI.CapabilitiesUI.Image);
|
||||
AI.Actions[AI.ActionType.OCR] = new ActionUI("OCR", "text-analysis-ai", "", AI.CapabilitiesUI.Vision);
|
||||
AI.Actions[AI.ActionType.Vision] = new ActionUI("Vision", "vision-ai", "", AI.CapabilitiesUI.Vision);
|
||||
|
||||
AI.ActionsGetKeys = function()
|
||||
{
|
||||
|
||||