Repository navigation
fix(core): separate blocks with newlines in getSelectedText - #3210
Merged
nperez0111 merged 1 commit intoOct 27, 2026
Merged
Conversation
|
@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: |
`getSelectedText` called `doc.textBetween(from, to)` without a block
separator, so a selection across blocks returned the block texts glued
together ("FirstSecond" for two paragraphs "First" and "Second").
Pass "\n" as the block separator so text from each block is on its own
line. Selections inside a single block are unchanged.
Closes TypeCellOS#710
nperez0111
force-pushed
the
fix/710-selected-text-block-separator
branch
from
October 27, 2026 13:58
b91981c to
4ba1ec1
Compare
nperez0111
marked this pull request as ready for review
October 27, 2026 14:08
Contributor
|
Thanks for this @adarshsm |
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 #710.
editor.getSelectedText()joined the text of every selected block with nothing in between. If you select two paragraphs, "First" and "Second", you get"FirstSecond". With this change you get"First\nSecond".Rationale
StyleManager.getSelectedTextreturnstr.doc.textBetween(from, to). Without the thirdblockSeparatorargument, ProseMirror concatenates textblocks directly. Passing"\n"adds one newline between textblocks. Nested block containers and block groups don't add extra newlines, becausetextBetweenonly inserts the separator before a textblock (or a leaf block with text), not before every block node.Changes
StyleManager.getSelectedText: pass"\n"as the block separator.BlockNoteEditor.getSelectedTextand themanipulating-content.mdxreference: mention the newline between blocks.Impact
CreateLinkButton, which uses the result as the default link text. Cross-block link creation now gets newline-separated text instead of run-together words.Testing
getSelectedTextcases insrc/editor/managers/StyleManager.test.ts:"First\nSecond\nNested\nThird". Onmainit returns"FirstSecondNestedThird".packages/coresuite: everything passes except thesrc/y/*/ Versioning suites. Those fail at import (Node is not a constructorfrom@y/y) in my local install (a stale@y/yin node_modules), which is unrelated to this change.vp lintandvp fmt --checkare clean on the touched files.Screenshots/Video
n/a
Checklist
Additional Notes
None.
🤖 Generated with Claude Code