Hello, I have a problem and I’m hoping someone can help me figure this out
getSelectedText in HTML format
I want to be able to save the selection (including tables and text boxes) into a variable and then paste it later (possibly using pasteHTML). Currently getSelectedText seems to parse it into string. I tried leaving it empty, but it doesn’t seem to parse it as HTML. Is there a way to do this or would this be a feature that could be implemented in the future (possibly another executeMethod)?
Calling paste from the context menu via callCommand or executeMethod
A feature that may help me with my problem would be to use the paste from the context menu. It seems to work differently than paste event listener made via plugins. it has it’s own stored clipboard that can save the selection (with tables, textboxes, and formatting) and paste it exactly the same. I have access to callCommand and executeMethod via plugins so I was wondering if there is a command or method that could call that paste. I want to call that paste instead of pasting the user’s clipboard (i already accomplished this via event.preventDefault and event.stopPropogation).
Prevent use of user clipboard
Another idea I thought of may involve preventing using the user clipboard and using the clipboard from OnlyOffice. (this is probably similar to my previous idea)
Hello @pautan getSelectedText in HTML format
Unfortunately, this method gets text without html wrapper and there’re no necessary methods to HTML. However, probably you can achieve it through a plugin and specify the init parameter to ‘html’. Here’s our plugin sample and necessary parameter for your reference:
Calling paste from the context menu via callCommand or executeMethod
Probably you can use the mentioned getSelectedText method and pass it via Scope for further usage. Please clarify if I misunderstood the scenario.
Thank you for responding to my question. I was wondering if you could point me to the specific part of the code where you grabbed the selection the user has selected. I want to be able to grab the selection as HTML and save it.
In regards to the context menu question, I was wondering more about whether the context menu “copy” and “paste” was special and was able to be invoked from a plugin.
For the prevent use of user clipboard, this was more in regards to using the Only Office clipboard that the context menu uses. My issue could be resolved if we ignore the users clipboard and use a special clipboard in OnlyOffice that stays within OnlyOffice (preventing the user from copying it to their own clipboard or pasting from their own clipboard).
For the prevent use of user clipboard, this was more in regards to using the Only Office clipboard that the context menu uses. My issue could be resolved if we ignore the users clipboard and use a special clipboard in OnlyOffice that stays within OnlyOffice (preventing the user from copying it to their own clipboard or pasting from their own clipboard).
Probably I misunderstood the desired scenario, but mentioned permissions.copy parameter already disables copying from the editor.
As for the situation in general, you are right, there’re two clipboard, and we notify users about it when they try to use copy-paste scenarios:
As for the usage of the editor clipboard from a plugin, unfortunately there’re no such methods. The only way is using the mentioned get and paste html plugin. However, it has its own logic of work with the editor clipboard. If you need to achieve the same result for a plugin, please let us know. We will check the possibility of implementations of such methods.
As for the getandpastehtml plugin and specific part of code, it’s a little bit difficult to specify the exact part. You need to use this parameter: ONLYOFFICE Api Documentation - Config at the init event in the plugin. With each select, the data will come in the form of html.
Thank you Alexandre. Yes I was hoping to be able to use the editor clipboard. Since there is no method to use that editor clipboard currently, I will have to look into other solutions like the one you mentioned about changing the initDataType.
If y’all ever allow plugins to paste and copy using that clipboard, please let me know as that would be extremely helpful for my use case. Thank you again!