How to pass extra data to docx editor

Hello, when I render the <DocumentEditor /> component, is there any way to pass in extra data to the editor such that it can read it from the plugin? For example

<DocumentEditor 
  id="myEditor"
  documentServerUrl="https://example.com"
  ...
  extraData={{ foo: "bar" }}
/>

Hello @fr3fou

Do I understand correctly that you are trying to integrate Document Server to your app via custom HTML tag? If that is so then please visit this page to check out which div tag should be used:
https://api.onlyoffice.com/editors/basic

I’m using the @onlyoffice/document-editor-react package. I’d like to to pass in extra data from my React app to my Plugin inside the editor. How can I achieve that?

Hello again @fr3fou

Thank you for clarifying.
We are checking the situation. I will update this thread once I get any information.

Hello again @fr3fou

In the next version 8.1.1 we will introduce the way to pass data to the plugin. Here is spoiler:

"document": {
    "fileType": "docx",
    "title": "Example Document Title.docx",
    "url": "https://documentserver/assets/docs/samples/new.docx"
},
"documentType": "word",
"editorConfig": {
    "user": {
        "id": "userID",
        "name": "Developer"
    },
    "plugins" : {
        "options" : {
            "asc. {38E022EA-AD92-45FC-B22B-49DF39746DB4}" : {
                "keyYoutube" : "valueYoutube"
            },
            "all" : {
                "keyAll" : "valueAll"
            }
        }
    }
},

More information will be available once new version is officially released, as well as the documentation on how to use it.

Stay tuned.

@Constantine any update on this?? is this feature available now??

Hello @anand.mainali

Yes, these parameters are now available in initialization config:
https://api.onlyoffice.com/docs/docs-api/usage-api/config/editor/plugins/#options

@Constantine is there any example plugin for this?? how do we access the passed data in plugin??

Here is an example that demonstrates basic usage of this parameter:

  1. I’ve added some data to the initialization config that I’d like to pass to the plugin:
            "plugins": {
                "options": {
                    "asc.{0616AE85-5DBE-4B6B-A0A9-455C4F1503AD}": {
                        "somedata": "Info"
                    }
                }
            }
  1. In the plugin itself, I’ve added a simple var just for demonstration that will obtain the array with all data and print it into the console:
            var someVar = Asc.plugin.info.options;
            console.log(someVar);
  1. When running the plugin, I am receiving the result in the browser console:
    image

As you can see, the data is available inside Asc.plugin.info.options object which is defined as an array. You can define your data in plugins.options parameter and parse it further in the plugin interface according to your custom logic.

thanks its working… :slightly_smiling_face:

1 Like

Glad to know. Closing the topic as solved.

1 Like