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]);'; = 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: Feel free to fork them, use them with your editors and create your own plugins.


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