Skip to content

Add link utilities and reorder marks#33

Merged
wandering-logic merged 5 commits into
mainfrom
link-abstractions
Feb 19, 2026
Merged

Add link utilities and reorder marks#33
wandering-logic merged 5 commits into
mainfrom
link-abstractions

Conversation

@wandering-logic
Copy link
Copy Markdown
Owner

@wandering-logic wandering-logic commented Feb 19, 2026

Summary

  • Add src/editor/linkUtils.ts with utilities for working with link marks:
    • getMarkRange / getLinkRange - find contiguous mark span at a position
    • linkSpansInRange - find all link spans overlapping a range
    • unlinkCommand - remove links from selection or cursor position
    • setLinkHref - apply/replace link href on a range
  • Reorder marks in schema so links nest outermost in DOM (better for click handling and screen readers)
  • Add Mod-Shift-K keybinding for unlink

Test plan

  • Verify Cmd/Ctrl-Shift-K removes link when cursor is inside a link
  • Verify Cmd/Ctrl-Shift-K removes all links in a selection
  • Verify links render as outermost element (e.g., <a><strong>text</strong></a> not <strong><a>text</a></strong>)

🤖 Generated with Claude Code

wandering-logic and others added 5 commits February 19, 2026 09:43
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>
@wandering-logic wandering-logic merged commit e46dcfb into main Feb 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant