Do return values from handlePaste have different effects?

Based on how the rest of “handle*” named functions in ProseMirror worked, I assume returning false would mean that ProseMirror would fallback to its default behavior but it seems like no matter what value you return, the behavior is simply to do nothing except what is explicitly prescribed in the custom handlePaste function.

Am I overlooking something? Is what I’m experiencing not the expected outcome?

I would imagine what will happen will depend on how/whether the clipboard data was parsed. You can look at the usage of handlePaste. Returning true will prevent any default handling and returning false will do the default logic but you don’t say what is in the slice. If there was nothing parseable from the clipboard data I assume there would be no or an empty slice and that would basically do nothing if you happened to return false.

1 Like

Thanks for pointing me to the source code. I’ll take a look shortly to see if it is indeed missing a slice there, but it seems doubtful. Still, I don’t know why else returning false would result in no pasted content.

Hm! You were right @andrews!

I noticed that the slice is empty if I try to paste lists I copied from within ProseMirror into the same editor while holding Ctrl+Shift+V - but with Ctrl+V the slice is not empty. Additionally the slice is never empty, even with Ctrl+Shift+V when I paste copied paragraphs or other content.

It seems this might be a limitation at the browser level, but I’m not so sure because our previous editor (Slate) didn’t have this problem.

I tracked it down to that event.clipboardData seems to be empty here: prosemirror-view/src/input.ts at 5f7203cfc3dbc4231fe4214f3b4d5e572516d57b · ProseMirror/prosemirror-view · GitHub

@marijn; if you’re interested, I’m guessing this is not a bug per se, but pinging you because of the curiosity that this didn’t affect our previous editor. I guess it could indicate a copy-bug (or at least limitation) on ProseMirror’s side?

I tried setting a breakpoint to determine for myself here but it never seems to run.

When we paste lists from Slate into ProseMirror they’re pasted as plaintext (one paragraph per listItem) - which is the same way Slate handles when they’re pasted.

The event.clipboardData.items from Slate looks like below.


My apologies - the slice being empty is because of a custom copy handler I’d overlooked while investigating this earlier. We failed to properly serialize a text/plain - only a text/html - resulting in this issue.