Plugin example

To understand how the plugins work and how they can be written and added to document editors, please see the example of the helloworld.js plugin below:

(function (window, undefined) {
    window.Asc.plugin.init = function () {
        var sScript = 'var oDocument = Api.GetDocument();';
        sScript += 'oDocument.CreateNewHistoryPoint();';
        sScript += 'oParagraph = Api.CreateParagraph();';
        sScript += 'oParagraph.AddText(\'Hello world!\');';
        sScript += 'oDocument.InsertContent([oParagraph]);';
        window.Asc.plugin.info.recalculate = true;
        this.executeCommand("close", sScript);
    };
    window.Asc.plugin.button = function (id) {
    };
})(window, undefined);

It is the easiest plugin that will insert the 'Hello world!' phrase into your document whenever you press the plugin button.

This plugin and all the other currently existing open source plugin examples are available here: https://github.com/ONLYOFFICE/sdkjs-plugins. Feel free to fork them, use them with your editors and create your own plugins.

Support

If you have any questions, you can ask our developers at dev.onlyoffice.org (registration required).