Add link utilities and reorder marks#33
Merged
Merged
Conversation
Provides getMarkRange (generic) and getLinkRange (link-specific) for finding the contiguous extent of a mark containing a given ResolvedPos. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Mark rank (and thus DOM nesting) is determined by schema order. New order: link > strikethrough > code > strong > em This ensures links wrap all other formatting, which is better for click handling and screen reader announcements. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Returns full extent of each link span (not clipped to query range). Dedupes by start position to handle links spanning multiple text nodes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Removes link marks from selection, or from the full link span when cursor is inside a link. Returns false if no links to remove. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Removes existing links then adds new link with given href. Returns transaction for chaining. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
src/editor/linkUtils.tswith utilities for working with link marks:getMarkRange/getLinkRange- find contiguous mark span at a positionlinkSpansInRange- find all link spans overlapping a rangeunlinkCommand- remove links from selection or cursor positionsetLinkHref- apply/replace link href on a rangeTest plan
<a><strong>text</strong></a>not<strong><a>text</a></strong>)🤖 Generated with Claude Code