Try the fastest and simplest way to install ONLYOFFICE

setting up a new plugin

Integration questions/issues

setting up a new plugin

Postby robertotomas » Thu Aug 31, 2017 4:16 pm

Please help me get my plugin loaded so I can debug it? It is a fairly simple plugin to allow inserting text into a document.

I have a server that is instantiating a document editor with this code:

Code: Select all
            this.docEditor = new DocsAPI.DocEditor("onlyoffice", {
               document: {
                  fileType: "doc",
                  key: response.data.cache_key,
                  title: "proposal.doc",
                  url: response.data.url,
               },
               documentType: "text",
               editorConfig: {
                  callbackUrl: ENV.API_BASE_URL+"/api/letters/template/callback"
               },
                    plugins: {
                   pluginsData: [
                       "http://localhost:8080/static/onlyoffice/addTag/config.json"
                        ]
                    }
            });
            window.Asc = this.docEditor


In my server I have a static/ folder that serves assets directly. In it, I have the following folder structure:

/static/onlyoffice/
/static/onlyoffice/addTag

and the files:
/static/onlyoffice/pluginBase.js (from https://github.com/ONLYOFFICE/sdkjs-plu ... ginBase.js )
/static/onlyoffice/addTag/config.json
/static/onlyoffice/addTag/index.html
/static/onlyoffice/addTag/icon.png
/static/onlyoffice/addTag/icon@2x.png
/static/onlyoffice/addTag/code.js

my config.json:
Code: Select all
{
    "name"       : "AddTag",
    "guid"       : "asc.{91835b50-2828-4c76-9208-a25e3a6c6efe}",
    "baseUrl"    : "",
    "variations" : [
        {
            "description"         : "Adds a tag",
            "url"                 : "http://localhost:8080/static/onlyoffice/addTag/index.html",
            "icons"               : [
                "http://localhost:8080/static/onlyoffice/addTag/icon.png",
                "http://localhost:8080/static/onlyoffice/addTag/icon@2x.png"],
            "isViewer"            : false,
            "EditorsSupport"      : ["word"],
            "isVisual"            : false,
            "isModal"             : true,
            "isInsideMode"        : false,
            "initDataType"        : "none",
            "initData"            : "",
            "isUpdateOleOnResize" : true,
            "buttons"             : []
        }
    ]
}


If I load any of these absolute paths directly with the browser, that file displays as text (it loads). I've also tried this config.json with relative urls like 'index.html'.

My index.html:
Code: Select all
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Example insert content and document</title>
    <script type="text/javascript" src="http://localhost:8080/static/onlyoffice/pluginBase.js"></script>
    <script type="text/javascript" src="http://localhost:8080/static/onlyoffice/addTag/code.js"></script>
</head>
<body>
</body>
</html>


My code.js:
Code: Select all
(function (window, undefined) {
    window.Asc.plugin.init = function () {
        var sScript = 'var oDocument = Api.GetDocument();';
        sScript += 'oDocument.CreateNewHistoryPoint();';
        sScript += 'oParagraph = Api.CreateParagraph();';
        sScript += `oParagraph.AddText('${window.site.addTag}');`;
        sScript += 'oDocument.InsertContent([oParagraph]);';
        window.Asc.plugin.info.recalculate = true;
        this.executeCommand("close", sScript);
    };

    window.Asc.plugin.button = function (id) {
    };

    window.Asc.plugin.addTag = window.Asc.plugin.addTag || 'Hello world!'
})(window, undefined);


and I've modified pluginBase.js, adding the following line to the top so I can tell if it has attempted to load:

window.pluginBaseLoaded = true


However, it does not load. window.Asc looks correct but window.Asc.plugin is undefined.
robertotomas
 
Posts: 3
Joined: Thu Aug 31, 2017 4:05 pm

Re: setting up a new plugin

Postby Maxim » Wed Sep 06, 2017 6:43 am

Hello robertotomas!
1 There is no need to modify pluginBase.js
2 HTML plugin will work only being connected to the Document Server
Maxim
 
Posts: 993
Joined: Tue Oct 11, 2016 2:34 pm

Re: setting up a new plugin

Postby robertotomas » Wed Sep 06, 2017 10:29 am

Hi Maxim,

How could the document editor (client) use a plugin if it does not load it?
robertotomas
 
Posts: 3
Joined: Thu Aug 31, 2017 4:05 pm

Re: setting up a new plugin

Postby robertotomas » Thu Sep 07, 2017 11:30 am

I did install it in sdkjs-plugins in the documentserver, however nothing changed. In fact, I don't feel 100% that our install was set up for it - the correct place to install on the server was not there - sdkjs was an existing folder but I had to create sdkjs-plugins.

Still, this is clearly a documenteditor plugin. I wanted to explore this option in case for some reason it would work, but I feel like my plugin makes a lot more sense installed on the client, in the documenteditor, not on our backend, in the documentserver.
robertotomas
 
Posts: 3
Joined: Thu Aug 31, 2017 4:05 pm

Re: setting up a new plugin

Postby Maxim » Tue Sep 12, 2017 7:18 am

Hello robertotomas!
1 Plugin will not work out of the Document Server (DS), only as a part of DS in sdkjs-plugins folder.
2 Does your plugin work?
Maxim
 
Posts: 993
Joined: Tue Oct 11, 2016 2:34 pm


Return to API

Who is online

Users browsing this forum: No registered users and 1 guest

cron