Skip to content

Copy/paste of a single inline block(chip) does not work#128

Merged
ihordubas99 merged 2 commits intodevfrom
bug/74538-copy-paste-of-single-inline-chip-not-work
May 7, 2026
Merged

Copy/paste of a single inline block(chip) does not work#128
ihordubas99 merged 2 commits intodevfrom
bug/74538-copy-paste-of-single-inline-chip-not-work

Conversation

@ihordubas99
Copy link
Copy Markdown
Collaborator

@ihordubas99 ihordubas99 commented Apr 28, 2026

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

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@ihordubas99 ihordubas99 self-assigned this Apr 28, 2026
@ihordubas99 ihordubas99 requested a review from judithroth April 28, 2026 14:07
@ihordubas99 ihordubas99 marked this pull request as ready for review April 28, 2026 14:07
Copy link
Copy Markdown
Contributor

@judithroth judithroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🙂

@ihordubas99
Copy link
Copy Markdown
Collaborator Author

Sorry about that! I was developing in Firefox and didn't test across all browsers, so I missed this completely - my bad

@ihordubas99 ihordubas99 requested a review from judithroth May 6, 2026 12:20
Copy link
Copy Markdown
Contributor

@judithroth judithroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@ihordubas99 ihordubas99 merged commit fdd42f2 into dev May 7, 2026
5 checks passed
@ihordubas99 ihordubas99 deleted the bug/74538-copy-paste-of-single-inline-chip-not-work branch May 7, 2026 15:07
@github-actions github-actions Bot locked and limited conversation to collaborators May 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants