Can't get selected text from Document as a STRING

Hi all, I’m new to OnlyOffice and I can’t find a solution to get selected text from Document as a STRING. I want to create a plugin that does something with selected text.

Example : from sentence “Hello world!” I want to select “Hello” and get it as a STRING. I tried this (and many other solutions), but it doesn’t work :

function GetText() {
var sText = window.getSelection().toString();
sText = “123” + sText + “456”;
return sText;
};

It returns “123456” instead od “123Hello456”.

I use desktop computer with Windows OS and Onlyoffice version 8.0.1.31 (x64 exe).

Hi @rade.pantelic.

OnlyOffice, and your plugin run in different window scopes. Please follow the documentation on the “Get+Paste” plugin to understand how to get the selected text.

1 Like

@rade.pantelic
Could you please clarify if you’ve implemented your idea?