Copy/paste of a single inline block(chip) does not work#128
Conversation
judithroth
left a comment
There was a problem hiding this comment.
Ok, I have a hard time deciding what to do with this.
First - your code looks good! It's nice and short.
However, I don't see it working:
In OpenProject:
Screencast.from.2026-05-05.17-27-03.webm
In op-blocknote-extensions test project in the regular dom it only works for the block ones (which the code didn't change?!):
Screencast.from.2026-05-05.17-20-27.webm
But not in the shadow DOM:
Screencast.from.2026-05-05.17-21-43.webm
Can you reproduce this? If it works for you, please add a screen recording 🙂
|
Sorry about that! I was developing in Firefox and didn't test across all browsers, so I missed this completely - my bad |
judithroth
left a comment
There was a problem hiding this comment.
It works now ✨ it's good we're testing on different browsers 😅 In the end we aim to support all major browsers (I think it was chrome, firefox, safari and edge).
I would prefer to have integration tests for that, but I know testing copy and paste is hard.
So I would love if you tried to add tests for 30-60 minutes and if you fail to get results after that amount of time, we keep it without tests. If you see you're making progress I don't think we need to limit the time. You can just merge now and try testing it on a new branch (with the same ticket number), ok?
Ticket
https://community.openproject.org/projects/communicator-stream/work_packages/74538
What are you trying to accomplish?
Fix copy/paste for inline work package chips.
Clicking a chip opened the options popover but did not create a browser selection, so ProseMirror had nothing to copy. Ctrl+C produced no output. The previous fix using document.createRange() + window.getSelection().addRange() worked in Firefox but was ignored by Chrome.
What approach did you choose and why?
Instead of manipulating the DOM selection, we now intercept the native copy event and manually write the serialized chip data to the clipboard. This approach works across all browsers since it fires before the browser decides what to copy, giving us full control over clipboard contents.
For block work packages, the listener is attached to the nearest shadow root via getRootNode() so clipboardData is correctly exposed in shadow DOM environments.
Additionally, toExternalHTML and parse were added to both specs so BlockNote can correctly serialize and deserialize work package nodes on copy/paste.
Merge checklist