In the developer trial version, the automation API doesn't work

462d432e8b12cb7598e5502a5199453
In a component of my Vue 2.x project, I followed the example in the official documentation to create a listener using the automation API, but it didn’t work.





const docEditor = new DocsAPI.DocEditor(“placeholder”, initConfig);
const connector = docEditor.createConnector();
connector.attachEvent(“onChangeContentControl”, (obj) => {
console.log([EVENT] onChangeContentControl: ${JSON.stringify(obj)});
});
connector.executeMethod(“GetSelectedText”, , (selectedText) => {
console.log(“Selected text:”, selectedText);
});
Is it because there is something wrong with my usage method?

Hello @peng,
Could you please clarify in more detail the scenario you want to implement and what exactly is not working in this function?

If you don’t mind, I will join this thread as well.
Please try to use this sample as a guideline:

connector.attachEvent("onChangeContentControl", (obj) => {
  console.log("[EVENT] onChangeContentControl:", JSON.stringify(obj));
});

connector.executeMethod("GetSelectedText", [], (selectedText) => {
  console.log("Selected text:", selectedText);
});
1 Like

Thank you for your previous response, which resolved my initial issue. However, I am now facing a new challenge. When a user clicks on a hyperlink, how can I retrieve the tooltip text associated with it? We embed parameters within the tooltip, so if capturing it on click isn’t possible, selecting the text and using a right-click menu would also be acceptable. Unfortunately, the API documentation only shows methods like onRange.GetText() for retrieving text. How can I access the ApiHyperlink object directly?

We use ApiHyperlink because we need to display custom presentation text when the user hovers over a hyperlink, and we want to allow users to trigger modifications to this text directly within the plugin.

Thank you for your reply. The previous issue has been resolved, but I am now encountering a new problem.How can the plugin obtain the ApiHyperlink object via a user click or selection so that it can extract the Screen Tip text and allow the user to modify it?

Hello @peng
Sorry for the late reply.
Do you mean ScreenTip text? GetScreenTipText | ONLYOFFICE
If I misunderstood the request, please clarify it.

No, I need users to retrieve the Tip text of a hyperlink after clicking on it; if that isn’t possible, then obtaining it via the right-click menu is acceptable.

Yes, it seems you can implement it via the context menu: Context menu | ONLYOFFICE
and bind the method above to the button.