Get Started
Plugins
Macros
More information
|
Global type definitionsButtonThe skinnable plugin button used in the plugin interface (used for visual plugins with their own window only, i.e. isVisual == true and isInsideMode == false). Type:
Properties:
Examplevar config = { "variations": [ { "buttons": [ { "text": "Cancel", "primary": false, "isviewer": false, "textLocale": { "fr": "Annuler", "es": "Cancelar" } } ], ... } ] }; commentComment object. Type:
Properties:
Examplevar 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 } ] } } CommentDataThe comment data. Type:
Properties:
Examplevar 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]); ContentControlContent control object. Type:
Properties:
Examplevar oContentControl = { "Tag": "Document", "Id": 0, "Lock": 0, "InternalId": "1_713" }; ContentControlCheckBoxPropertiesThe content control checkbox properties. Type:
Properties:
Examplevar oControlCkeckBoxPr = { "Checked" : false, "CheckedSymbol" : 9756, "UncheckedSymbol" : 9744 }; window.Asc.plugin.executeMethod ("AddContentControlCheckBox", [oControlCkeckBoxPr, {"Id" : 7, "Tag" : "{tag}", "Lock" : 0}]); ContentControlDatePickerPropertiesThe content control datepicker properties. Type:
Properties:
Examplevar Date = new window.Date(); var oControlDatePickerPr = { "DateFormat" : "DD\ MMMM\ YYYY", "Date" : Date }; window.Asc.plugin.executeMethod ("AddContentControlDatePicker", [oControlDatePickerPr, {"Id" : 7, "Tag" : "{tag}", "Lock" : 0}]); ContentControlLockA value that defines if it is possible to delete and/or edit the content control or not:
Type:
Examplevar 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]); ContentControlParentPrThe content control parent properties. Type:
Properties:
Examplevar oContentControlParentPr = { "Parent" : oParagraph, "Pos" : 0, "Count" : 1 }; ContentControlPropertiesThe content control properties. Type:
Properties:
Examplevar oContentControlPr = { "Id" : 7, "Tag" : "{tag}", "Lock" : 0 }; window.Asc.plugin.executeMethod ("AddContentControl", [1, oContentControlPr]); ContentControlPropertiesAndContentThe content control properties and contents. Type:
Properties:
Examplevar 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]); ContentControlTypeA numeric value that specifies the content control type:
Type:
Examplevar nContentControlType = 1; window.Asc.plugin.executeMethod ("AddContentControl", [nContentControlType, {"Id" : 7, "Tag" : "{tag}", "Lock" : 0}]); editorTypeThe editors which the plugin is available for:
Type:
Examplevar config = { "variations": [ { "EditorsSupport": ["word", "cell", "slide"], ... } ] }; EventTypePlugin event ("onDocumentContentReady", "onTargetPositionChanged", onClick", "onInputHelperClear", "onInputHelperInput", etc.). Type:
Examplevar config = { "variations": [ { "events": ["onClick"], ... } ] }; fillFormsAn object containing the form properties. Type:
Properties:
Examplevar 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]); FontInfoAn object containing the font information. Type:
Properties:
Examplevar 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 }; ImageDataAn object containing the information about the base64 encoded png image. Type:
Properties:
Examplewindow.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 }; window.Asc.plugin.executeMethod ("PutImageDataToSelection", [oImageData]); window.Asc.plugin.executeCommand("close", ""); }; initDataTypeThe data type selected in the editor and sent to the plugin:
Type:
Examplevar config = { "variations": [ { "initDataType": "ole", ... } ] }; InputHelperItemDefines the input helper item. Type:
Properties:
Examplevar 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); localeTranslateTranslations 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" : "имя" } Type:
Examplevar config = { "variations": [ { "name": "plugin name", "nameLocale": { "fr": "french plugin name", "es": "spanish plugin name" }, ... } ] }; MacrosAn object containing the data about all the macros from the document. Type:
Properties:
Examplevar 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]); OLEObjectDataThe OLE object data. Type:
Properties:
Examplevar 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]); PluginDataThe plugin object. Type:
Properties:
Examplevar 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", ... } }; SelectionTypeThe current selection type ("none", "text", "drawing", or "slide"). Type:
Examplewindow.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; } }); watermark_on_drawAn object containing the watermark properties. Type:
Properties:
Examplevar 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]); |