texera
texera copied to clipboard
Copy and Paste Operators with System Clipboard
This pull request is intended to solve the issue #1609
I changed the method of copying and pasting from storing components in the WorkflowEditorComponent to serializing the operator and storing the JSON string into the system clipboard. In this way, the operators can be copied and pasted across browsers and browser tabs, with one complication being in Firefox, in order for the pasting to work, users need to type about:config in the navigation bar, select "accept the risk and continue", and set "dom.events.asyncClipboard.readText" to true. This extra step is required due to the fact that the access to clipboard permission works a little differently in Firefox than other browsers, and for now, this is the only approach that works, as far as I am concerned.
During the unit testing using Jasmine and Karma, it seems like the permission to access clipboard needs to be granted somehow in the testing environment's browsers for the copy-and-paste functionality to actually work. There is no easy way of doing this to the best of my knowledge, this can be further looked into in the future, and for now I commented out all the unit tests regarding copying, cutting, and pasting. However, I don't think the absense of these unit test will cause a problem in the app, since when I was testing it on my own browswer, after toggling on the clipboard permission manually, everything works as expected.