fix(core): link lookups at the edges of a link - #3058
Draft
YousefED wants to merge 1 commit into
Draft
Conversation
…l only from the selected text The link mark is not inclusive, so a mark lookup at either edge of a link misses it, and editLink / deleteLink compensated with a +1 that covers the left edge only. getLinkMarkAtPos now uses tiptap's getMarkRange, which looks after and then before the position, and reads the mark off the node the range starts with; the callers drop the +1. getSelectedLinkUrl, which decides whether the link form opens pre-filled, deliberately reads only the node the selection starts in: a selection that starts right after a link must not pre-fill that link's URL, while selecting only the last character of a link, or a one-character link, must. Tests: headless cases for the selection lookup at every edge, and a mounted case where editing a link with only its last character selected used to split it.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks 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
Author
|
@nperez0111 this was claude generated, not directly related to what I was working on, so might be worth a look at any time. I didn't really review this atm |
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.
Two link lookups in
StyleManagerdisagreed about what happens at the edges of a link, because the link mark is non-inclusive.Edit and delete (
editLink,deleteLink→getLinkMarkAtPos): the position comes from the link toolbar and can sit at either edge of the link (caret at the end of a link is normal). The lookup now uses tiptap'sgetMarkRange, which looks at the node after the position and then the one before, so the link is found at both ends; the+ 1nudge the callers used, which only covered the left edge, is gone.Pre-filling the link form (
getSelectedLinkUrl): this answers "is the selected text a link?", so it deliberately reads only the node the selection starts in. Looking on both sides would pre-fill the previous link's URL when a selection starts right after a link. The bug it fixes: selecting only the last character of a link, or a one-character link, read as "no link" and opened the form empty.Tests:
StyleManager.test.ts(headless, the selection lookup at every edge; two cases fail on the old lookup) andStyleManager.browser.test.ts(mounted editor; editing a link with only its last character selected used to split the link).Extracted from the mobile stack so it can be reviewed on its own; the stack currently carries a
+ 1ingetSelectedLinkUrlthat this replaces.