Hi, I use dom event to add custom data into the clipboard in addition to the other data that is copied. I used this plugin but I don’t get my custom data (no metter if I return true or false). If I use preventDefault() I get only my custom data without the copied data. How can I do it? this is what I tried:
Seems I was misremembering—browsers isolate the native clipboard from custom web clipboard data for security reasons, but do allow reading such data inside the browser itself.
ProseMirror’s event model doesn’t really intend handlers to do something, then return false, and let other handlers do their thing in addition to that. The idea is that a single handler handles the entire event (and returns true when it does). As such, the native copy handler assumes it is responsible for the entire event, and will clear the clipboardData before adding its data. There’s not currently any way to add to this without, as you found, registering an independent DOM event handler that runs after the built-in one.
The native copy handler assumes it is responsible for the entire event, and will clear the clipboardData before adding its data.
With this in mind, would it be possible for ProseMirror to export its serializeForClipboard function so that a handler that wants to add metadata can do so without having to reimplement the whole clipboard serialization logic?