I'm listening to a Ctrl-C
event and creating a JSON
, I'll need this JSON
in a different part of my application where I intend to use the JSON
for a custom paste on Ctrl-V
; but I don't have any reference here to the previous part, where the copy was done. Not even a global variable (long story).
Basically, these Ctrl-C
and Ctrl-V
events are supposed to copy and paste complex custom-made HTML elements, with their own events and keyframe animations, from one part of the application to the other. Working with the JSON
is the only way to go.
I did some digging and came across questions like this, but they only address the case of putting selected text on the clipboard. I'm looking for something which can put custom content on the clipboard of the system or the browser.
Is there any inbuilt method, or an external utility or plugin, that would help me achieve this?
Thanks.
EDIT: This copy-paste feature will be used on a website by users, not just developers. Therefore, we can't assume anything. Cookies won't work because cookies might be turned off. localstorage
or sessionstorage
won't work because the application may be open for different projects in different windows; and the user might want to copy from one window and paste into another.