ONLYOFFICE / sdkjs-plugins

The add-ons for ONLYOFFICE Document Server and ONLYOFFICE Desktop Editors.
https://www.onlyoffice.com
Apache License 2.0
136 stars 134 forks source link

Unable to get cell value outside of command scope #154

Open vese opened 3 years ago

vese commented 3 years ago

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?

ShockwaveNN commented 3 years ago

@askonev Please take a look

vese commented 3 years ago

It is possible to get selected value if specify "initOnSelectionChanged": true and "initDataType": "text" or "initDataType": "html" in config.json. But it seems like workaround instead of an actual way to get value. Also it is impossible to get selected cells adresses this way because init data has no this information

askonev commented 3 years ago

Hello @vese. This is exactly how the implementation of data access from the editor to the plugin was conceived. I think you have already familiarized yourself with the implementation of the Thesaurus plugin in which this configuration is used.

But direct access to the cell address is not implemented, but you can add it to the cell using Api methods and then take the data into the plugin.

vese commented 3 years ago

Hello @askonev. Is it possible to add parameters to callbacks from callCommand https://github.com/ONLYOFFICE/sdkjs/pull/1964 ?