window.Asc.plugin.callCommand(fCommand, isClose)

Description

The new method used to send the data back to the editor. Replaced the executeCommand method when working with texts so that to simplify the syntax of the script you want to pass to the editors using ONLYOFFICE Document Builder API. It allows the plugin to send structured data which can be inserted to the resulting document file (formatted paragraphs, tables, text parts and single words, etc.).

ONLYOFFICE Document Builder commands can be only used to create content and insert it to the document editor (using the Api.GetDocument().InsertContent(...)). This limitation is made due to the co-editing possibility in online editors. If you create a plugin for desktop editors working with local files, no such limitation is applied.
Parameters
Name Description Type
fCommand The command JavaScript code, which forms the structured data which can be inserted to the resulting document file (formatted paragraphs, tables, text parts and single words, etc.) to be sent to the editors. Must be compatible with ONLYOFFICE Document Builder syntax. string
isClose Specifies either the plugin window must be closed after the code execution or be left open and wait for some other command or action. The true value is used to close the plugin window after executing the function in the fCommand parameter. The false is used to execute the command and leave the window open, awaiting for the next command. boolean

The window.Asc.plugin.callCommand method is executed in its own context, isolated from other JavaScript code data. If you want to pass some parameters or other data to it, you will need to use the Asc.scope object for that.

Example
window.Asc.plugin.init = function () {
    this.callCommand(function() {
        var oDocument = Api.GetDocument();
        var oParagraph = Api.CreateParagraph();
        oParagraph.AddText("Hello world!");
        oDocument.InsertContent([oParagraph]);
    }, true);
};