Skip to content

Fix RangeError on multi-line link/image titles#1

Merged
kenforthewin merged 1 commit intomainfrom
fix/multiline-replace-decorations
Apr 23, 2026
Merged

Fix RangeError on multi-line link/image titles#1
kenforthewin merged 1 commit intomainfrom
fix/multiline-replace-decorations

Conversation

@kenforthewin
Copy link
Copy Markdown
Owner

Lezer emits LinkTitle / URL nodes that span newlines when CommonMark allows (multi-line titles, wrapped autolinks). The inline-preview ViewPlugin was pushing Decoration.replace for those nodes directly, which throws "Decorations that replace line breaks may not be specified via plugins" at build time.

Route every replace in the plugin through a pushReplace helper that per-line-splits the range (first segment carries any widget, rest are plain hides). Single-line ranges hit the early-return and push the original spec unchanged, so common-case output is byte-identical.

Covered by a new multiline-decoration.test.tsx regression test; the Playwright harness still passes 50/50 with no CLS deltas.

Lezer emits LinkTitle / URL nodes that span newlines when CommonMark
allows (multi-line titles, wrapped autolinks). The inline-preview
ViewPlugin was pushing Decoration.replace for those nodes directly,
which throws "Decorations that replace line breaks may not be
specified via plugins" at build time.

Route every replace in the plugin through a pushReplace helper that
per-line-splits the range (first segment carries any widget, rest are
plain hides). Single-line ranges hit the early-return and push the
original spec unchanged, so common-case output is byte-identical.

Covered by a new multiline-decoration.test.tsx regression test; the
Playwright harness still passes 50/50 with no CLS deltas.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kenforthewin kenforthewin merged commit efb98bc into main Apr 23, 2026
1 of 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