GithubHelp home page GithubHelp logo

onlyoffice / sdkjs-plugins Goto Github PK

View Code? Open in Web Editor NEW
132.0 41.0 133.0 214.69 MB

The add-ons for ONLYOFFICE Document Server and ONLYOFFICE Desktop Editors.

Home Page: https://www.onlyoffice.com

License: Apache License 2.0

JavaScript 98.06% HTML 1.89% CSS 0.05%
onlyoffice onlyoffice-plugins

sdkjs-plugins's Introduction

Overview

In this folder, you will find the simplest plugins to be used as an examples while creating your own ones.

List of available examples

Inserting content

  • helloworld shows how to insert text into the document.
  • templates - shows how to insert content generated using DocBuilder script into your doc.
  • CBR shows how to get data from third party service and insert it into your spreadsheet.
  • example_autocomplete - an example of an input assistant/non-standard keyboard. It has its own window that appears and disappears when you type the text. Its location is tied to the cursor.

Search and replace

  • example_search_replace - an example of search & replace feature with settings.
  • searchAndReplaceOnStart shows how to automatically replace content when you start the editor. In this case, text “ONLYOFFICE” will be replaced with the text "ONLYOFFICE is cool".

Work with comments

Work with content controls

Third-party services integration

  • chrome_extension_example shows how to turn your plugin into a Chrome extension to add its functionality to the cloud version of ONLYOFFICE.
  • externallistener shows how to manipulate the editor from an external panel of a 3rd party service.

Other

  • settings shows how to protect a document using a watermark.
  • chess shows how to work with OLE-objects and save data to your document.

Documentation

ONLYOFFICE API - https://api.onlyoffice.com/plugin/basic

User feedback and support

If you have any problems or question about ONLYOFFICE plugins, use the issues section here, in this repository.

sdkjs-plugins's People

Contributors

agolybev avatar alexeymatveev686 avatar ayuzhin avatar catbasilio avatar denisdeesign avatar hellonadya avatar juliaradzhabova avatar k0r0l avatar khromovnikita avatar kirillovilya avatar konovalovsergey avatar nikprime avatar p-bo avatar sergeyluzyanin avatar shockwavenn avatar trofim24 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdkjs-plugins's Issues

update plugin list in readme.md

The list of available plugins seems to be incomplete.
Please make especially sure to point out if the plugin exchanges any document data with external services' APIs.
Thanks.

get the value of focus cell

I have an idea that when I select a cell, I will get the name and value of that cell
and I can fill in a certain value in the cell I am selecting
example: When I click on cell B2 I get it address "B2", and it value is "hello"
image

I am using sample python code so how can I write it in file editor.html?

Thank you for reading this question

PasteHtml method can paste data only with default style

Method PasteHtml paste text with default style, if it style is not setted in html.
Example:

(function(window, undefined) {
  window.Asc.plugin.init = function() {
    window.Asc.plugin.executeMethod("PasteHtml", ['<span>text</span>'], false);
    this.executeCommand("close", '');
  };
})(window, undefined);

gifout

It is correct behavior? Or text must paste with paragraph style?

Macros Plugin doesn't keep the macro definition

Hey guys,

I just installed the macro plugin on my document server instance by drag 'n' dropping the macros folder.

The macros plugin is displayed accordingly and works like expected. After leaving the macro editor and entering again all macro definitions are gone.

Any hints or same issues with that plugin?

Thanks in advance.
-Using Onlyoffice Document Server v5.0.7-38
-plugin base v0.7.1
-macro version pulled today

Translation through Yandex doesn't work anymore because API limit reached.

What is the current behavior?

Try to translate text through the plugin "translate".

What is the expected behavior?

Translation should work, instead [translator] : Maximum monthly translated text volume exceeded is shown in the browser console:

GET https://server/5.3.0-243//sdkjs-plugins/translate/translations/de-DE.json 404
u.plugin_onMessage @ VM629:1
onMessage @ VM601 pluginBase.js:497
postMessage (async)
we @ sdk-all.js:9747
h @ sdk-all.js:9731
postMessage (async)
u.plugin_sendMessage @ VM629:1
(anonymous) @ VM629:1
(anonymous) @ VM629:1
onMessage @ VM601 pluginBase.js:514
postMessage (async)
h @ sdk-all.js:9733
postMessage (async)
xhr.onload @ VM601 pluginBase.js:484
load (async)
window.onload @ VM601 pluginBase.js:443
load (async)
(anonymous) @ VM601 pluginBase.js:435
(anonymous) @ VM601 pluginBase.js:561
VM602 translate.js:111 POST https://translate.yandex.net/api/v1.5/tr.json/getLangs?key=trnsl.1.1.20160604T115612Z.107ebb05a7757bcc.804e900f347ddfbeadd7ca5999bd5cb6ca32805b&ui=en 403 (Forbidden)
getLanguagesSupport @ VM602 translate.js:111
window.Asc.plugin.init @ VM602 translate.js:298
u.plugin_onMessage @ VM629:1
onMessage @ VM601 pluginBase.js:497
postMessage (async)
we @ sdk-all.js:9747
h @ sdk-all.js:9731
postMessage (async)
u.plugin_sendMessage @ VM629:1
(anonymous) @ VM629:1
(anonymous) @ VM629:1
onMessage @ VM601 pluginBase.js:514
postMessage (async)
h @ sdk-all.js:9733
postMessage (async)
xhr.onload @ VM601 pluginBase.js:484
load (async)
window.onload @ VM601 pluginBase.js:443
load (async)
(anonymous) @ VM601 pluginBase.js:435
(anonymous) @ VM601 pluginBase.js:561
VM602 translate.js:104 [translator] : Maximum monthly translated text volume exceeded

The search for synonyms of words does not work using the plugin "Thesaurus"

Steps to reproduce:

  1. Open a new DOCX document.
  2. Enter the word "Hello".
  3. Highlight the word "Hello".
  4. Start plugin "Thesaurus".
  5. In the plugin tab "Thesaurus" press "Lookup".

Result:
Synonyms for the word "Hello" are not displayed.
The word “Hello” is used as an example; the plugin does not work with other words.

Method "GetCurrentContentControlPr" return minified data

Method "GetCurrentContentControlPr" return minified data.
I think, it is wrong behaveor, data is must be full

Return example:

 {"Ga":100,"Mw":"CC_Tag","aA":"","vf":3,"fbb":"8_838","yYd":1,"Ux":1}

Plugin code example

(function(window, undefined) {
  window.Asc.plugin.init = function() {
    var type = 1;
    var properties = {
      "Id": 100,
      "Tag": "CC_Tag",
      "Lock": 3
    };
    window.Asc.plugin.executeMethod("AddContentControl", [type, properties], function() {
 
          window.Asc.plugin.executeMethod("GetCurrentContentControlPr", [], function (result) {
            console.log("Result: " + JSON.stringify(result))
            window.Asc.plugin.executeCommand("close", '')
          });
    });
  };
})(window, undefined);

Version: 5.3.2 (build:20)

  • All plugin files is attached to this issue
    plugin.zip

[feature]I hope to get the content and the coords of a selected cell range in plugins

in the version 5.4

When I selected a range, then I open a plugin the plugin.init(text) is called, the param text just has the cell content, but no the coordinates of the range.

can we add a param in the plugin.init(text, range) , param range is a string like E9:G12, means the the left top corner coordinates and right bottom coordinates of cell range.

photo editor plugin: Why DOCX only?

Photo Editor is cool!
But ss there an important reason why the photo editor works only in "Documents" and not in "Spreadsheets"? Because that feature (especially: cropping) is sorely missing there!

Geneva m adams

there's a new one in their own home state Anderson cooper is responsible for all this case because he has a very high profile in the history of this investigation **Do you want to request a feature or report a bug?**

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

What is the expected behavior?

Which versions of sdkjs-plugins, and which browser / OS are affected by this issue? Did this work in previous versions of sdkjs-plugins?

Definition cell name cannot be saved to excel file

var _script = "";
_script += "var oSheet = Api.GetActiveSheet();\r\n";
_script += "oSheet.AddDefName('def_xxxxx', '表格1!$A$8', false);\r\n";
_script += "var active = oSheet.GetActiveCell();\r\n";
_script += "var row = active.GetRow();\r\n";
_script += "var col = active.GetCol();\r\n";
_script += "oSheet.GetRangeByNumber(row, col).SetValue('{{测试}}');\r\n";
window.Asc.plugin.executeCommand("command", _script);

The name manager is displayed successfully. But reopen this file will not exist "def_xxxxx"。

version: 5.4.2-46
thanks

Any info on the JS Macros Plugin?

Just installed the latest OO Desktop editor, excited to see a "JS Macro" Plugin there.
But... Is there any documentation for it? I'd love to give it a go, but it's a little ... undocumented ... given it's not even found in here? Can you let us know when documentation might be published?

Add description and purpose of the project

This project looks interesting. I wonder what I can do with it.
Is it a way to write plugins to the onlyoffice editor without changing the source code? It would be great if we could do that (like we can do on the CKEditor).

Content control does not refresh after AddText() / crashes on oRun.ClearContent()

Do you want to request a feature or report a bug?
Bug
What is the current behavior?

  1. When you add text to an inline content control surrounded by text that already has text in it, it will not become visible before editing that content
    control.
  2. When you modify a run within a content control, the app will crash on re-render.
    If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
  • Create an empty document
  • add some text
  • add a content control
  • add some text to the content control aand place it somewhere between the regular text
  • Make sure to put the cursor outside of the content control so it will not get locked
    Run the following macro code for the first issue:
let oDocument = Api.GetDocument();
let oContentControls = oDocument.GetAllContentControls();
    
for (const oCC of oContentControls) {
        oCC.SetLock("Unlocked");
        oCC.AddText("TEST");
        oCC.SetLock("contentLocked");
    }
}

If you exit the macro screen, the content control still shows the previous text content. If you edit it, it will show "TEST" in addition.

Run the following macro code for the second issue:

let oDocument = Api.GetDocument();
let oContentControls = oDocument.GetAllContentControls();
    
for (const oCC of oContentControls) {
       oCC.SetLock("Unlocked");
       for (let i=0; i < oCC.GetElementsCount(); i++) {
            const elem = oCC.GetElement(i);
            if (elem.GetClassType() == 'run') {
                elem.ClearContent();
                elem.AddText("TEST");
            }
        }
        oCC.SetLock("contentLocked");
}

When you move the cursor near the content control, the app crashes.
What is the expected behavior?

  1. The content control will update whenever it's content has changed.
  2. Calling ClearContent() on a text run within a content control does not crash the app.

Which versions of sdkjs-plugins, and which browser / OS are affected by this issue? Did this work in previous versions of sdkjs-plugins?
6.2.0 / Safari 14.0.3

Plugins which use the document object don't work with the minified production code

I've managed to run the plugins by replacing the folder /var/www/onlyoffice/documentserver/ inside the docker with the the original sources. Without it my plugin code cannot use some Document methods.
I keep getting:
oDocument.Document.Get_CurrentParagraph is not a function(…)
It happens with this code:

var oDocument = Api.GetDocument();
var oCurrentParagraph = oDocument.Document.Get_CurrentParagraph();

Is this plugin mechanism production ready? I didn't see any documentation anywhere. Thanks.

Failed to execute 'postMessage' on 'DOMWindow' for youtube window

Steps:

  1. Create new document and open in DocumentEditor
  2. TopToolbar -> Plugins -> Youtube
  3. Add https://www.youtube.com/watch?v=D49vvl7BPro and press OK for loading preview

What is the expected behavior?
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin"

Which versions of sdkjs-plugins, and which browser / OS are affected by this issue? Did this work in previous versions of sdkjs-plugins?
DocumentServer 5.3

Unable to add keyboard listening event

Excuse me, I want to add the monitoring of keyboard function keys to formulate some special behaviors, but I can't find the corresponding API on the official website.I want to ask if the existing API supports listening for keyboard events

[Feature Request] endnote.com plugin (Mendeley-analogue)

Hi,
we are planning to use OO in conjunction with Nextcloud in our research institute.
For publications in scientific journals it's very important to cite correctly. Currently we are using Endnote. Is there a plugin for Endnote in the "Word"-application from OO ?

Bernd

Youtube, Clipart, Photoeditor not working

BUG

Youtube wont put in a video, Clipart wont find Cliparts and Photoeditor opens new frame with white Background and forces me to reload the website.

  • I open a or create a document in nextcloud and onlyoffice shows me the document

  • I click on Plugins and select the plugin i want

Should work

Using: Newest, Chrome, Firefox, Edge, Windows 10, Windows 7

Deleted and reinstalled plugins via Git...

Unable to get cell value outside of command scope

Hi! I need to parse value from cell and display it in plugin's window.
How can I do this?

document.getElementById("parse").onclick = function () {
  callCommand(function () {
    const value = Api.ActiveSheet.ActiveCell.Value;
    // need to get value outside of command scope
  }, false);
};

If use onCommandCallback I also can't get the value

window.Asc.plugin.onCommandCallback = function (returnValue) {
//returnValue is null

}

If use executeMethod I get returnValue in onMethodReturn for some methods, e. g. GetFontList

  window.Asc.plugin.executeMethod('GetFontList');

But I can't get cell value. ('GetActiveSheet', 'GetActiveCell')
Is there any method to get cell value?

[feature] Get element's page number

I'm trying to auto-generate a table of content. I wonder if it's possible to have an API that returns the current page number for a given element. Something like:

var oDocument = Api.GetDocument();
var elm = oDocument.GetElement(0);
elm.getPageNumber();

Not sure if this is the right place to ask this.

InsertAndReplaceContentControls changes ContentControlType to BlockLevelSdt

Do you want to request a feature or report a bug?
Bug
What is the current behavior?
The method InsertAndReplaceContentControls changes Inline content controls elements to Block content controls Elements.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Create an inline content control like this:

           const ContentControlyType = {
                Block: 1,
                Inline: 2
            };
            const contentControl = {
                Id: kpiId,
                Lock: 0,
                Tag: kpiSlug,
                Alias: kpiName,
                Appearance: 1,
                Color: {
                    R: 24,
                    G: 193,
                    B: 197
                }
            };
            window.Asc.plugin.executeMethod("AddContentControl", [ContentControlyType.Inline, contentControl]);  

Replace the content of the inline content control:

    window.Asc.plugin.onMethodReturn = function (returnValue) {
        const _plugin = window.Asc.plugin;

        if (_plugin.info.methodName == "AddContentControl" && returnValue && returnValue.InternalId) {
            console.log(returnValue);

            const contentControls = [
                {
                    Props: {
                        InternalId: returnValue.InternalId,
                    },
                    Script: `var oDocument = Api.GetDocument();var oParagraph = Api.CreateParagraph();oParagraph.AddText('${kpiValue}');oDocument.InsertContent([oParagraph]);`
                }
            ];

            window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [contentControls]);
        } else if (_plugin.info.methodName == "InsertAndReplaceContentControls") {
            console.log(returnValue[0]);

            window.Asc.plugin.executeCommand("close", "");
        }
    };

The inline content control will become a block level content control. I think it is due to this line of code: https://github.com/ONLYOFFICE/sdkjs/blob/19a9abb25e28698f8074bac80bc518820997e0fb/word/api.js#L589

What is the expected behavior?
The method should consider the ContentControl Type.
Which versions of sdkjs-plugins, and which browser / OS are affected by this issue? Did this work in previous versions of sdkjs-plugins?
v1, browser-independent, I don't know if it worked before

InsertAndReplaceContentControls is broken for files being edited by multiple users

Do you want to request a feature or report a bug?
This is a bug with the "InsertAndReplaceContentControls" feature.

What is the current behavior?
Step 1:
Put the sdkjs-plugins/examples/example_insert_content_and_document folder into sdkjs-plugins/ to install the provided example plugin. (This issue exists with other uses of the "InsertAndReplaceContentControls" command as well, however, this is a good common ground)

Step 2:
Create a shared document and open it. Run the "Example insert content & document" plugin. It works as expected and inserts the 7 content controls.

Step 3:
Now open the document with two users simultaneously. Place the cursor at the end of the document and run the plugin again. It works as expected and inserts the 7 content controls again.

Step 4:
Make a page break (not needed, but makes it easier to visualize) and then type some arbitrary text with one user.
Place the cursor of the other user somewhere INSIDE of that text and run the plugin again.

The window freezes and nothing works anymore, no content control is inserted and the page needs to be reloaded.

What is the expected behavior?
It should be possible to insert content controls inside of existing text.

Which versions of sdkjs-plugins, and which browser / OS are affected by this issue? Did this work in previous versions of sdkjs-plugins?
I have the version 5.2.8.24 and am using the provided docker installation from the "Linux Docker Image" over at https://www.onlyoffice.com/download.aspx

Help/Readme using feature/zotero branch ?

Do you want to request a feature or report a bug? feature

What is the current behavior?
The installed feature/zotero plugin seems to be a demo with no link to my zotero extension. any Readme, help or documentation available ?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

  • Installed the zotero plugin
  • Trying to use it with my own Zotero library

What is the expected behavior?

  • Get a link between my zotero library through the zotero browser extension ?

Which versions of sdkjs-plugins, and which browser / OS are affected by this issue? Did this work in previous versions of sdkjs-plugins?

  • Nextcloud 17 up-to-date

How to replace paragraphs?

hi~~

I have a section of JSON data. I need to replace a section of the word document. How should I operate it? Thank you.

example:
date=[ {"company":"abc","title":"bbbbbbbbbb","content":"eeeeeeeeeeeeeeeeeeeee"}, {"company":"abc","title":"bbbbbbbbbb","content":"eeeeeeeeeeeeeeeeeeeee111"}, {"company":"abc","title":"bbbbbbbbbb","content":"eeeeeeeeeeeeeeeeeeeee222"}, {"company":"abc","title":"bbbbbbbbbb","content":"eeeeeeeeeeeeeeeeeeeee333"} ]

replace word paragraph:
rr

[SOLVED] No plugin menu in onlyoffice Doc community edition

Hi !! I'm using onlyoffice Doc community edition 6.2 and I have Nodejs 12.21

Do you want to request a feature or report a bug?
Maybe a bug
What is the current behaviour?
There is no plugins menu in onlyoffice interfaces but there is plugins in sdkjs-plugins folder
image
image

The only error i have found: in /var/log/onlyoffice/documentserver/docservice/out.log
image

plugin code only works in the edit mode

Hello, I wrote a plugin which can find text in the document editor, code like this:
...
Asc.scope.text="sometext";
window.Asc.plugin.callCommand(function() {
Api.asc_findText(Asc.scope.text, true, true);
}, true);
...
when I open a docx file, it only works in the edit mode, does not works in the view mode
when I open a pdf file in the document editor, the plugin code does not work in both modes

OpenClipart noch availiable

bug Plugin "Clipart"

The OnlyOffice Plugin "Clipart" uses the Web-Service provided by OpenClipart.org.
Since April 2019 this Web-Service is no longer availiable.

As long as the external Web-Service is not reachable, the Clipart Plugin should be deaktivated and not be dsiplayed in the GUI. Error-Message: Error has occured when loading data.

Desktop-Version of OnlyOffice where the Clipart-Plugin is included by default. If online-Versions (developer, community Editition... are affected ist unknown to me)

PluginClipart_not_working

How insert content control to excel cell?

var _script = "";
_script += 'var oWorksheet = Api.GetActiveSheet();\r\n';
_script += 'var oParagraph = Api.CreateParagraph();\r\n';
_script += 'var oRun = oParagraph.AddText(\'' + Label + '\');\r\n';
_script += 'var oCell = oWorksheet.GetActiveCell();\r\n';
_script += 'var row = oCell.GetRow();\r\n';
_script += 'var col = oCell.GetCol();\r\n';
_script += 'oWorksheet.GetRangeByNumber(row,col).SetFillColor(Api.CreateColorFromRGB(255,224,204));\r\n';
_script += 'oWorksheet.GetRangeByNumber(row, col).InsertContent([oParagraph], true);\r\n';

var _scriptObject = {
    "Props" : {
        "Tag"        : Tag,
        "Lock"       : 0,
        "InternalId" : InternalId
    },
    "Script" : _script
};

window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [[_scriptObject]]);

it's not work

Image Editor Non-Functional in Desktop Editors

Currently the photo editor is broken within desktop editors, when editing a photo, any changes will caused the photo become transparent and replaced with an empty box.

Tested under 5.2.80.470 of desktop editors on Ubuntu 18.04

Execute method options

Hello,

This is not to report a bug but I didn't know where to write a question.

I can see in your plugin examples that you use several options on executeMethod, for example.
window.Asc.plugin.executeMethod("MoveCursorToStart",[true]);

My question is, where can I see all the available options in the first parameter ?

Because the official documentation only mention 6 and MoveCursorToStart is not one of them.

How to capture worksheet/cell change events?

Hi,
Thank for the great project.
As we know, Microsoft Excel and OfficeJs addins allow us to listen event when a worksheet and/or a cell changed.
Is there anyway to listen these change events with OnlyOffice via plugin/macro?
Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.