ONLYOFFICE DocSpace released: improve document collaboration with offices, customers, and partners. Use it for free!
ONLYOFFICE DocSpace released

How plugins interact with documents for data

Do you want to: Suggest a feature / Report a bug / Ask a how-to question
For feature suggestions, describe the result you would like to achieve in detail:
For bug reports, provide the steps to reproduce and if possible a minimal demo of the problem:
Document Server version: 7.3
Installation method: install editor desktop
OS: windows 11
Browser version:

1、The content of the first cell is 10
2、Select a cell and click on the plugin
3、How to display the content of this cell on the plugin page

I tried all the methods but they didn’t work Asc. scope object will only pass strings

Hey @huzedong2022

Did I understand correctly that you need something like this?
(without translation function)

window.Asc.plugin.callCommand(() => {
// 1. Obtaining annotation content for multiple cells cannot be passed externally
// 2. The use of fetch (method="POST") in this will forcibly change to fetch (method="GET")

It is in the config that we specify two flags:

  1. initOnSelectionChanged is the first flag (determines whether each select will transmit data to the plugin or only once at startup.
  2. initDataType is the second flag (it determines in what format this data will be sent to the plugin).

The data will come in the init event in the plugin as a parameter.


My requirement is to develop a plugin

For example, if I selected a “A4” cell, I need to obtain the annotation information on the first column of the selected cell, which is “A1”.

Then I need to send a request based on the information on “A1” to obtain the data from the database and import it into the “A4” cell

But because callCommand is isolated. I can’t call external methods

const insertData = () => {}

window.Asc.plugin.callCommand(() => {
    // coding
    insertData(10) // insertData is undefined

How to get data from a cell:

I also suggest that you familiarize yourself with the following plugin:
Thesaurus - сonnects Big Huge Thesaurus to search for word synonyms and antonyms.

More detailed:

XMLHttpRequest - javascript request

window.Asc.plugin.executeMethod - method for inserting text into a document

Here is an example of a “Hello World” plugin. You can use builder methods to insert data from the plugin into a document. The same applies to tables.