Clipboard content lifetime

Hello,

what is the lifetime of the clipboard content?
In which cases is the clipboard cleared? I can see that for example diagram.clear() empties the clipboard
If I have two diagrams in two different divs, do they share the same clipboard?
If I have a single diagram, copy something to the clipboard, delete the div and create a new diagram, will the clipboard data still be available?

I couldn’t find some documentation about the clipboard where the exact behaviour is described. If anything exists, could you point me to it?

Thanks, Dominic

Think of the default clipboard storage as a global variable, since that works in all browsers and environments.

Use: LocalStorageCommandHandler | GoJS API

I rather have the problem that I have multiple diagrams and I don’t want some clipboard content to be shared between them.
So if it is a global variable, the clipboard is by default shared by all diagrams in my SPA. This global variable is only cleared if I reload the page or if I call diagram.clear()? Or are there any other events which clear the clipboard?

So you are only asking about how to clear the clipboard? Call https://gojs.net/latest/api/symbols/CommandHandler.html#copyToClipboard with an argument of null.

Basically I wanted to know when the clipboard is cleared automatically, so I know in which cases I have to clear it manually.

Each call to CommandHandler.copyToClipboard causes a “ClipboardCopied” DiagramEvent.