Get Started
Plugins
Macros
More information
|
executeCommandexecuteCommand(type, data, callback)Defines the method used to send the data back to the editor.
Now this method is mainly used to work with the OLE objects or close the plugin without any other commands. It is also retained for using with text so that the previous versions of the plugin remain compatible. The callback is the result that the command returns. It is an optional parameter. In case it is missing, the window.Asc.plugin.onCommandCallback function will be used to return the result of the command execution. The second parameter is the JavaScript code for working with ONLYOFFICE Document Builder API
that allows the plugin to send structured data inserted to the resulting document file (formatted paragraphs, tables, text parts, and separate words, etc.).
When creating/editing OLE objects, two extensions are used to work with them:
When creating/editing the objects, their properties can be passed to the window.Asc.plugin.info object that defines how the object should look. Parameters:
Returns:
Examplewindow.Asc.plugin.button = function (id) { var _info = window.Asc.plugin.info; var _method = (_info.objectId === undefined) ? "asc_addOleObject" : "asc_editOleObject"; _info.width = _info.width ? _info.width : 70; _info.height = _info.height ? _info.height : 70; _info.widthPix = (_info.mmToPx * _info.width) >> 0; _info.heightPix = (_info.mmToPx * _info.height) >> 0; _info.imgSrc = window.g_board.getResult(_info.widthPix, _info.heightPix).image; _info.data = window.g_board.getData(); var _code = "Api." + _method + "(" + JSON.stringify(_info) + ");"; this.executeCommand("close", _code); }; |