Repository navigation
fix(core): strip comments from copied text - #3260
Merged
nperez0111 merged 3 commits intoOct 28, 2026
Merged
Conversation
Copying text that has a comment and pasting it kept the comment mark with the same thread id. The pasted text was highlighted as part of the thread, but the thread now had two anchored ranges, and resolving or deleting the thread had to deal with both. Strip the comment mark from pasted slices in the comments extension. A drag-and-drop move keeps its comments, since it moves the text instead of copying it. Closes TypeCellOS#3158
|
@adarshsm is attempting to deploy a commit to the TypeCell Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Caution Review failedThe pull request is closed. Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/diagram-block
@blocknote/mantine
@blocknote/math-block
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
@blocknote/xl-typst-exporter
commit: |
Collaborator
|
Thanks! I think it would be cleaner though if the comment mark is not put on the clipboard at all (so filter-on-copy instead of filter-on-paste?) |
nperez0111
marked this pull request as ready for review
October 28, 2026 06:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #3158.
Copying text that has a comment and pasting it kept the comment mark, with the same thread id. This PR removes comment marks from pasted content, so only the original text stays attached to the thread. This is what the issue asks for, and what Notion does.
Rationale
The comment mark is serialized into the clipboard HTML (
<span class="bn-thread-mark" data-bn-thread-id="…">) and parsed back on paste, like any other mark. The pasted text then shows the thread highlight, but the thread's anchor is now two ranges. The comments UI only tracks one position per thread (getUpdatedThreadPositionskeeps the smallestfromand the largestto), so a copy pasted elsewhere stretches the thread's apparent range between the two places.Changes
comments/extension.ts: add atransformPastedprop to the comments plugin that removes the comment mark from the pasted slice (removeMarkFromFragment).view.dragging.move) is left alone, since the text moves along with its comment and nothing is duplicated. A drag-copy (Alt/Ctrl) is a copy, so it's stripped like a paste.Impact
Testing
packages/core/src/comments/extension.test.ts:selectedFragmentToHTML→pasteHTML) pastes plain text, and the thread is still anchored on the original text only. This fails without the fix (the pasted text carriesthread-1).@blocknote/coresuite: everything passes except thesrc/y/**andsrc/yjs/**suites, which fail at import in my local checkout (TypeError: Node is not a constructor/defaultTransformer is not a functionfrom the installed@y/y), unrelated to this change.vp lintandvp fmtare clean on the touched files.Screenshots/Video
n/a
Checklist