The addin field data.
Name | Type | Description |
FieldId | string | Field identifier. |
Value | string | Field value. |
Content | string | Field text content. |
var oAddinFieldData = {"FieldId": "1", "Value": "Addin №1", "Content": "This is the first addin field"}; window.Asc.plugin.executeMethod("AddAddinField", [oAddinFieldData]);
The skinnable plugin button used in the plugin interface (used for visual plugins with their own window only, i.e. isVisual == true and isInsideMode == false).
Name | Type | Description |
text | string | The label which is displayed on the button. |
primary | boolean | Defines if the button is primary or not. The primary flag affects the button skin only. |
isViewer | boolean | Defines if the button is shown in the viewer mode only or not. |
textLocale | localeTranslate | Translations for the text field. The object keys are the two letter language codes (ru, de, it, etc.) and the values are the button label translation for each language. |
var config = { "variations": [ { "buttons": [ { "text": "Cancel", "primary": false, "isviewer": false, "textLocale": { "fr": "Annuler", "es": "Cancelar" } } ], ... } ] };
Comment object.
Name | Type | Description |
Id | string | The comment ID. |
Data | CommentData | An object which contains the comment data. |
var comment = { "Id": "1_631", "Data": { "UserName": "John Smith", "Text": "comment", "Time": "1662737941471", "Solved": true, "Replies": [ { "UserName": "Mark Potato", "Text": "reply 1", "Time": "1662740895892", "Solved": false } ] } }
The comment data.
Name | Type | Description |
UserName | string | The comment author. |
QuoteText | string | The quote comment text. |
Text | string | The comment text. |
Time | string | The time when the comment was posted (in milliseconds). |
Solved | boolean | Specifies if the comment is resolved (true) or not (false). |
Replies | Array. |
An array containing the comment replies represented as the CommentData object. |
var oCommentData = { "UserName": "John Smith", "Text": "comment", "Time": "1662737941471", "Solved": true, "Replies": [ { "UserName": "Mark Potato", "Text": "reply 1", "Time": "1662740895892", "Solved": false } ] }; window.Asc.plugin.executeMethod ("AddComment", [oCommentData]);
Content control object.
Name | Type | Description |
Tag | string | A tag assigned to the content control. The same tag can be assigned to several content controls so that it is possible to make reference to them in your code. |
Id | string | A unique identifier of the content control. It can be used to search for a certain content control and make reference to it in the code. |
Lock | ContentControlLock | A value that defines if it is possible to delete and/or edit the content control or not: 0 - only deleting, 1 - no deleting or editing, 2 - only editing, 3 - full access. |
InternalId | string | A unique internal identifier of the content control. It is used for all operations with content controls. |
var oContentControl = { "Tag": "Document", "Id": 0, "Lock": 0, "InternalId": "1_713" };
The content control checkbox properties.
Name | Type | Description |
Checked | boolean | Defines if the content control checkbox is checked or not. |
CheckedSymbol | number | A symbol in the HTML code format that is used when the checkbox is checked. |
UncheckedSymbol | number | A symbol in the HTML code format that is used when the checkbox is not checked. |
var oControlCkeckBoxPr = { "Checked" : false, "CheckedSymbol" : 9756, "UncheckedSymbol" : 9744 }; window.Asc.plugin.executeMethod ("AddContentControlCheckBox", [oControlCkeckBoxPr, {"Id" : 7, "Tag" : "{tag}", "Lock" : 0}]);
The content control datepicker properties.
Name | Type | Description |
DateFormat | string | A format in which the date will be displayed. For example: "MM/DD/YYYY", "dddd,\ mmmm\ dd,\ yyyy", "DD\ MMMM\ YYYY", "MMMM\ DD,\ YYYY", "DD-MMM-YY", "MMMM\ YY", "MMM-YY", "MM/DD/YYYY\ hh:mm\ AM/PM", "MM/DD/YYYY\ hh:mm:ss\ AM/PM", "hh:mm", "hh:mm:ss", "hh:mm\ AM/PM", "hh:mm:ss:\ AM/PM". |
Date | object | The current date and time. |
var Date = new window.Date(); var oControlDatePickerPr = { "DateFormat" : "DD\ MMMM\ YYYY", "Date" : Date }; window.Asc.plugin.executeMethod ("AddContentControlDatePicker", [oControlDatePickerPr, {"Id" : 7, "Tag" : "{tag}", "Lock" : 0}]);
A value that defines if it is possible to delete and/or edit the content control or not:
var arrDocuments = [{ "Props": { "Id": 100, "Tag": "CC_Tag", "Lock": 3 }, "Script": "var oParagraph = Api.CreateParagraph();oParagraph.AddText('Hello world!');Api.GetDocument().InsertContent([oParagraph]);" }]; window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [arrDocuments]);
The content control parent properties.
Name | Type | Description |
Parent | object | The content control parent. For example, oParagraph. |
Pos | number | The content control position within the parent object. |
Count | number | A number of elements in the parent object. |
var oContentControlParentPr = { "Parent" : oParagraph, "Pos" : 0, "Count" : 1 };
The content control properties.
Name | Type | Description |
Id | string | A unique identifier of the content control. It can be used to search for a certain content control and make reference to it in the code. |
Tag | string | A tag assigned to the content control. The same tag can be assigned to several content controls so that it is possible to make reference to them in the code. |
Lock | ContentControlLock | A value that defines if it is possible to delete and/or edit the content control or not. |
InternalId | string | A unique internal identifier of the content control. |
Alias | string | The alias attribute. |
PlaceHolderText | string | The content control placeholder text. |
Appearance | number | Defines if the content control is shown as the bounding box (1) or not (2). |
Color | object | The color for the current content control in the RGB format. |
Color.R | number | Red color component value. |
Color.G | number | Green color component value. |
Color.B | number | Blue color component value. |
var oContentControlPr = { "Id" : 7, "Tag" : "{tag}", "Lock" : 0 }; window.Asc.plugin.executeMethod ("AddContentControl", [1, oContentControlPr]);
The content control properties and contents.
Name | Type | Description |
ContentControlProperties | ContentControlProperties | The content control properties. |
Script | string | A script that will be executed to generate the data within the content control (can be replaced with the Url parameter). |
Url | string | A link to the shared file (can be replaced with the Script parameter). |
var oControlPrContent = { "Props": { "Id": 100, "Tag": "CC_Tag", "Lock": 3 }, "Script": "var oParagraph = Api.CreateParagraph();oParagraph.AddText('Hello world!');Api.GetDocument().InsertContent([oParagraph]);" }; var arrDocuments = [oControlPrContent]; window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [arrDocuments]);
A numeric value that specifies the content control type:
var nContentControlType = 1; window.Asc.plugin.executeMethod ("AddContentControl", [nContentControlType, {"Id" : 7, "Tag" : "{tag}", "Lock" : 0}]);
The context menu item.
Name | Type | Description |
id | string | The item ID. |
text | localeTranslate | The item text. |
disabled | boolean | Specifies if the current item is disabled or not. |
items | Array. |
An array containing the context menu items for the current item. |
var aContextMenuItems = function getContextMenuItems() { let settings = { guid: window.Asc.plugin.guid, items: [ { id : 'onConvert', text : getMessage('Convert to Markdown or HTML') } ] }; return settings; }; window.Asc.plugin.attachEvent('onContextMenuShow', function(options) { if (!options) return; if (options.type === 'Selection' || options.type === 'Target') this.executeMethod('AddContextMenuItem', [aContextMenuItems]); });
The document editing restrictions:
var sDocumentEditingRestrictions = "readOnly"; window.Asc.plugin.executeMethod("SetEditingRestrictions", [sDocumentEditingRestrictions]);
The editors which the plugin is available for:
var config = { "variations": [ { "EditorsSupport": ["word", "cell", "slide"], ... } ] };
Plugin event ("onDocumentContentReady", "onTargetPositionChanged", onClick", "onInputHelperClear", "onInputHelperInput", etc.).
var config = { "variations": [ { "events": ["onClick"], ... } ] };
An object containing the form properties.
Name | Type | Description |
tags | object | The form tags which specify the content for each form type with such a tag. |
tags.text | string | The text field value (some text). |
tags.checkBox | string | The checkbox form value (true - checked, false - unchecked). |
tags.picture | string | The image form value (a link to the image). |
tags.comboBox | string | The combo box form value (one of the items from the combo box list values). |
var initSettings = { "copyoutenabled" : false, "hideContentControlTrack" : false, "watermark_on_draw" : JSON.stringify({ "transparent" : 0.3, "type" : "rect", "width" : 100, "height" : 100, "rotate" : -45, "margins" : [ 10, 10, 10, 10 ], "fill" : [255, 0, 0], "stroke-width" : 1, "stroke" : [0, 0, 255], "align" : 1, "paragraphs" : [ { "align" : 2, "fill" : [255, 0, 0], "linespacing" : 1, "runs" : [ { "text" : "Do not steal, %user_name%!", "fill" : [0, 0, 0], "font-family" : "Arial", "font-size" : 40, "bold" : true, "italic" : false, "strikeout" : false, "underline" : false }, { "text" : "<%br%>" } ] } ] }), "disableAutostartMacros" : true, "fillForms" : JSON.stringify({ "tags" : { "111" : { "text" : "Text in form with tag 111", "checkBox" : "true", "picture" : "https://upload.wikimedia.org/wikipedia/commons/9/91/ONLYOFFICE_logo.png", "comboBox" : "item1" }, "222" : { "text" : "Text in form with tag 222", "checkBox" : "false", "comboBox" : "item2" }, "333" : { "text" : "OnlyOffice" } } }) }; window.Asc.plugin.executeMethod("SetProperties", [initSettings]);
An object containing the font information.
Name | Type | Description |
m_wsFontName | string | The font name. |
m_wsFontPath | string | The path to the file with the current font. |
m_lIndex | number | The font number in the file if there is more than one font in the file. |
m_bBold | boolean | Specifies if the font characters are bold or not. |
m_bItalic | boolean | Specifies if the font characters are italic or not. |
m_bIsFixed | boolean | Specifies if the current font is monospaced or not. |
m_aPanose | Array. |
The PANOSE Typeface Classification Number, a compact 10-byte description of the font critical visual characteristics, such as contrast, weight, and serif style. |
m_ulUnicodeRange1 | number | The Unicode range encompassed by the font file (Bits 0-31). |
m_ulUnicodeRange2 | number | The Unicode range encompassed by the font file (Bits 32-63). |
m_ulUnicodeRange3 | number | The Unicode range encompassed by the font file (Bits 64-95). |
m_ulUnicodeRange4 | number | The Unicode range encompassed by the font file (Bits 96-127). |
m_ulCodePageRange1 | number | The code pages encompassed by the font file (Bits 0-31). |
m_ulCodePageRange2 | number | The code pages encompassed by the font file (Bits 32-63). |
m_usWeigth | number | The visual weight (stroke blackness or thickness) of the font characters (1-1000). |
m_usWidth | number | The relative change from the normal aspect ratio (width to height ratio). |
m_sFamilyClass | number | The font family class which values are assigned by IBM to each font family. |
m_eFontFormat | number | The specific file type(s) used to store font data: 0 - *.fon, 1 - *.ttf, 2 - *.ttf, *.otf (CFF), 3 - unknown font format. |
m_shAvgCharWidth | number | The arithmetic average of the escapement (width) of all non-zero width glyphs in the font. |
m_shAscent | number | The height above the baseline for a clipping region. |
m_shDescent | number | The vertical extent below the baseline for a clipping region. |
m_shLineGap | number | The typographic line gap for the current font. |
m_shXHeight | number | The distance between the baseline and the approximate height of non-ascending lowercase letters measured in FUnits. |
m_shCapHeight | number | The distance between the baseline and the approximate height of uppercase letters measured in FUnits. |
var oFontInfo = { "m_wsFontName": "Open Sans", "m_wsFontPath": "OpenSans-Bold.ttf", "m_lIndex": 0, "m_bBold": true, "m_bItalic": false, "m_bIsFixed": false, "m_aPanose": [2, 11, 8, 6, 3, 5, 4, 2, 2, 4], "m_ulUnicodeRange1": 3758097135, "m_ulUnicodeRange2": 1073750107, "m_ulUnicodeRange3": 40, "m_ulUnicodeRange4": 0, "m_ulCodePageRange1": 536871327, "m_ulCodePageRange2": 0, "m_usWeigth": 700, "m_usWidth": 5, "m_sFamilyClass": 2050, "m_eFontFormat": 1, "m_shAvgCharWidth": 632, "m_shAscent": 765, "m_shDescent": -240, "m_shLineGap": 64, "m_shXHeight": 545, "m_shCapHeight": 713 };
An object containing the information about the base64 encoded png image.
Name | Type | Description |
src | string | The image source in the base64 format. |
width | number | The image width in pixels. |
height | number | The image height in pixels. |
replaceMode | ReplaceImageMode | Specifies how to adjust the image object in case of replacing the selected image. |
window.saveImage = function () { let sImageSrc = imageEditor.toDataURL(); let editorDimension = imageEditor.getCanvasSize(); let nWidth = editorDimension.width; let nHeight = editorDimension.height; let oImageData = { "src": sImageSrc, "width": nWidth, "height": nHeight, "replaceMode": "original" }; window.Asc.plugin.executeMethod ("PutImageDataToSelection", [oImageData]); window.Asc.plugin.executeCommand("close", ""); };
The data type selected in the editor and sent to the plugin:
var config = { "variations": [ { "initDataType": "ole", ... } ] };
Defines the input helper item.
Name | Type | Description |
id | string | The item index. |
text | string | The item text. |
var items = [ { text: "Name1.Family1", id : "0" }, { text: "Name2.Family2", id : "1" }, { text: "Name3.Family3", id : "2" }, { text: "Name4.Family4", id : "3" }, { text: "Name5.Family5", id : "4" }, { text: "Name6.Family6", id : "5" }, { text: "Name7.Family7", id : "6" }, { text: "Name8.Family8", id : "7" }, { text: "Name9.Family9", id : "8" }, { text: "Name10.Family10", id : "9" }, { text: "Name11.Family11", id : "10" }, { text: "Name12.Family12", id : "11" }, { text: "Name13.Family13", id : "12" } ]; window.Asc.plugin.getInputHelper().setItems(items); var _sizes = getInputHelperSize(); window.Asc.plugin.getInputHelper().show(_sizes.w, _sizes.h, true);
Translations for the text field. The object keys are the two letter language codes (ru, de, it, etc.) and the values are the button label translation for each language. Example: { "en" : "name", "ru" : "имя" }
var config = { "variations": [ { "name": "plugin name", "nameLocale": { "fr": "french plugin name", "es": "spanish plugin name" }, ... } ] };
An object containing the data about all the macros from the document.
Name | Type | Description |
macrosArray | Array. |
An array of macros codes ([{"name": "Macros1", "value": "{macrosCode}"}]). |
current | number | A current macro index. |
var oMacros = { "macrosArray": [ { "name": "Macros 1", "value": "(function()\n{oDocument = Api.GetDocument();\noParagraph = Api.CreateParagraph();\noParagraph.AddText(\"This is a new paragraph\");\noDocument.Push(oParagraph);\n})();" }, { "name": "Macros 2", "value": "(function()\n{oDocument = Api.GetDocument();\noParagraph = oDocument.GetElement(0);\noParagraph.AddText(\"ONLYOFFICE Document Builder\");\noRange = oDocument.GetRange(0, 24);\noRange.SetBold(true);\n})();" } ], "current": 1 }; window.Asc.plugin.executeMethod("SetMacros", [oMacros]);
The OLE object data.
Name | Type | Description |
Data | string | OLE object data (internal format). |
ImageData | string | An image in the base64 format stored in the OLE object and used by the plugin. |
ApplicationId | string | An identifier of the plugin which can edit the current OLE object and must be of the asc.{UUID} type. |
InternalId | string | The OLE object identifier which is used to work with OLE object added to the document. |
ParaDrawingId | string | An identifier of the drawing object containing the current OLE object. |
Width | number | The OLE object width measured in millimeters. |
Height | number | The OLE object height measured in millimeters. |
WidthPix | number | The OLE object image width in pixels. |
HeightPix | number | The OLE object image height in pixels. |
var oOLEObjectData = { "Data": "{data}", "ImageData": "data:image/png;base64,image-in-the-base64-format", "ApplicationId": "asc.{38E022EA-AD92-45FC-B22B-49DF39746DB4}", "Width": 70, "Height": 70, "WidthPix": 60 * 36000, "HeightPix": 60 * 36000 }; window.Asc.plugin.executeMethod("InsertOleObject", [oOLEObjectData, true]);
The plugin object.
Name | Type | Description |
url | string | The URL to plugin config. |
guid | string | The plugin identifier. It must be of the asc.{UUID} type. |
canRemoved | boolean | Specifies if the plugin can be removed (true) or not (false). |
obj | object | The config of the installed plugin. The version is taken from the config and compared with the current one to check for updates. |
var oPlugin = { "url": "https://example.com/plugin/config.json", "guid": "asc.{38E022EA-AD92-45FC-B22B-49DF39746DB4}", "canRemoved": true, "obj": { "baseUrl": "", "guid": "asc.{FFE1F462-1EA2-4391-990D-4CC84940B754}", "version": "1.0", "minVersion": "6.3.0", ... } };
Specifies how to adjust the image object in case of replacing the selected image.
window.saveImage = function () { let sImageSrc = imageEditor.toDataURL(); let editorDimension = imageEditor.getCanvasSize(); let nWidth = editorDimension.width; let nHeight = editorDimension.height; let oImageData = { "src": sImageSrc, "width": nWidth, "height": nHeight, "replaceMode": "original" }; window.Asc.plugin.executeMethod ("PutImageDataToSelection", [oImageData]); window.Asc.plugin.executeCommand("close", ""); };
The current selection type ("none", "text", "drawing", or "slide").
window.Asc.plugin.executeMethod ("GetSelectionType", [], function(sType) { switch (sType) { case "none": case "drawing": window.Asc.plugin.executeMethod ("PasteText", [$("#txt_shower")[0].innerText]); break; case "text": window.Asc.plugin.callCommand (function() { Api.ReplaceTextSmart (Asc.scope.arr); }); break; } });
Specifies if the whole text or only its part will be returned or replaced:
window.Asc.plugin.executeMethod ("GetCurrentWord", ["entirely"], function (res) { console.log (res) });
An object containing the watermark properties.
Name | Type | Description |
transparent | float | The watermark transparency degree. |
type | string | The shape type which specifies the preset shape geometry for the current watermark. |
width | number | The watermark width measured in millimeters. |
height | number | The watermark height measured in millimeters. |
rotate | number | The watermark rotation angle measured in degrees. |
margins | Array. |
The text margins measured in millimeters in the watermark shape. |
fill | Array. |
The watermark fill color in the RGB format, or the URL to image (base64 support: data:image/png;...). The empty array [] means that the watermark has no fill. |
stroke-width | number | The watermark stroke width measured in millimeters. |
stroke | Array. |
The watermark stroke color in the RGB format. The empty array [] means that the watermark stroke has no fill. |
align | number | The vertical text align in the watermark shape: 0 - bottom, 1 - center, 4 - top. |
paragraphs | Array. | The array with paragraphs from the current watermark with their properties. |
paragraphs.align | number | The horizontal text align in the current paragraph: 0 - right, 1 - left, 2 - center, 3 - justify. |
paragraphs.fill | Array. |
The paragraph highlight in the RGB format. The empty array [] means that the paragraph is not highlighted. |
paragraphs.linespacing | number | The text linespecing in the current paragraph. |
paragraphs.runs | Array. | The array with runs from the current paragraph with their properties. |
paragraphs.runs.text | string | The run text. |
paragraphs.runs.fill | Array. |
The text highlight in the RGB format. The empty array [] means that the text is not highlighted. |
paragraphs.runs.font-family | string | The text font family. |
paragraphs.runs.font-size | string | The text font size measured in points (pt). |
paragraphs.runs.bold | boolean | Defines if the current text is displayed bold or not. |
paragraphs.runs.italic | boolean | Defines if the current text is displayed italic or not. |
paragraphs.runs.strikeout | boolean | Defines if the current text is displayed struck through or not. |
paragraphs.runs.underline | boolean | Defines if the current text is displayed underlined or not. |
var initSettings = { "copyoutenabled" : false, "hideContentControlTrack" : false, "watermark_on_draw" : JSON.stringify({ "transparent" : 0.3, "type" : "rect", "width" : 100, "height" : 100, "rotate" : -45, "margins" : [ 10, 10, 10, 10 ], "fill" : [255, 0, 0], "stroke-width" : 1, "stroke" : [0, 0, 255], "align" : 1, "paragraphs" : [ { "align" : 2, "fill" : [255, 0, 0], "linespacing" : 1, "runs" : [ { "text" : "Do not steal, %user_name%!", "fill" : [0, 0, 0], "font-family" : "Arial", "font-size" : 40, "bold" : true, "italic" : false, "strikeout" : false, "underline" : false }, { "text" : "<%br%>" } ] } ] }), "disableAutostartMacros" : true, "fillForms" : JSON.stringify({ "tags" : { "111" : { "text" : "Text in form with tag 111", "checkBox" : "true", "picture" : "https://upload.wikimedia.org/wikipedia/commons/9/91/ONLYOFFICE_logo.png", "comboBox" : "item1" }, "222" : { "text" : "Text in form with tag 222", "checkBox" : "false", "comboBox" : "item2" }, "333" : { "text" : "OnlyOffice" } } }) }; window.Asc.plugin.executeMethod("SetProperties", [initSettings]);