Now ONLYOFFICE can do anything: add plugins to document editors

    What if you could add any functions you want to the document editors? Now you can: ONLYOFFICE editors have the ability to connect plugins. We wrote some examples ourselves - all of them can be viewed in our open repository on GitHub'e. Now your move - write what you lacked.

    Details below.



    Why did we do this?


    So, we decided to give developers the opportunity to add the necessary (but not directly related to OOXML formats) functionality to ONLYOFFICE editors.

    It all started with one company in which they really wanted to write their own button to generate content and paste the resulting data into the editor. Okay, we thought, that makes sense. There is a functionality that only certain people need and no one else. We can’t do everything for everyone, but we can give the opportunity to cut everything that is needed. Therefore, here is the API for working with the editor, the first version.

    So plugins appeared.

    You can use a code in them that we ourselves will not be able to take due to licensing restrictions. We make a commercial product and sell it, you can’t just take it and (* at this moment the author of the text is interrupted to brush off the ghost of Sean Bean emerging from the depths of the subconscious) you can’t just take and use any code from the Internet. That is, we cannot. And you can. Those things that we for objective reasons cannot, our users can.

    Types of Plugin


    We divide them into three types:

    Visual . When we use this extension of the editor, a window opens and a specific interface is drawn. For example, Glavred, who was asked by our PR specialists.

    A visual plugin may change something in the document itself, or it may not change anything. The editor-in-chief does not change anything - he only highlights a certain part of the text (stamps, extra words, etc.).

    You can write a plugin that searches on Google. Pictures and inserts what you like into the text. This plugin changes the document.

    Non-visual . For example, a simple button, when clicked, the document is manipulated. The simplest example of such a plugin is an extension that, when a button is clicked, adds the words Hello World!

    (function (window, undefined) {
        window.Asc.plugin.init = function () {
            var sScript = 'var oDocument = Api.GetDocument();';
            sScript += 'var 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);
    

    You can also add, for example, your own Bold button. Or a button, when clicked, a report is generated.

    OLE objects . These are our favorite plugins. And the only way for a third-party developer to "fit" into the format part of the document, i.e. write down your information not only during the work of the editor, but also directly to the file. This, for example, is our chess.

    What solution are plugins connected to and how is this done?


    In fact, to anyone.

    For the server version,

    Plugins must be registered in editors' configs - they will automatically appear for all portal users.

    For the desktop

    , we archive the plugins, change the file extension to .plugin and drop it on the main page. They will be picked up right away, we promise. In addition, if you connect the application to the portal with plugins enabled, they will automatically work in the desktop.

    For the web version

    In the near future we will upload something like a store or gallery where plug-ins from users will be added (after moderation).

    While there is no "store", plugins can be added through the extension in the browser. This path so far only works for Chrome. On GitHub we have a folder with the speaking name chrome_extension_example: this is a sample of how to make an extension in Chrome for our plugins.

    Here, by the way, is a short video about what our plugins can do and how to add them to an existing installation (desktop, server).



    How to write your own plugin?


    Here we wanted to write detailed instructions on how to do this. But they remembered that we already have a good and detailed documentation, where the structure of the plug-in is described in all necessary details. So everything is here . You can also learn the device add-ons that we personally posted on GitHub .

    That’s probably all. And yes - we hope to see a riot of plugins created by the community over time. In any case, it is very curious what features our users will add.

    Also popular now: