Skip to content

feat: support custom scheme autolinks via autolinkSchemes#214

Closed
maccman wants to merge 1 commit into
prosekit:masterfrom
maccman:feat/autolink-schemes
Closed

feat: support custom scheme autolinks via autolinkSchemes#214
maccman wants to merge 1 commit into
prosekit:masterfrom
maccman:feat/autolink-schemes

Conversation

@maccman

@maccman maccman commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Problem

Typing a bare custom-scheme URL like reflect://today stays plain text: lezer's GFM autolink only matches www. / http(s):// / emails / mailto: / xmpp:, so app schemes never linkify the way https://… does.

Changes

  • New schemeAutolink lezer inline parser (packages/core/src/lezer/scheme-autolink.ts), modeled on the existing bareAutolink: matches <scheme>://<rest> for each configured scheme (case-insensitive), applies the same before-boundary rule and the trailing-punctuation trimming ported from @lezer/markdown, and emits the shared URL node so the existing mark walk renders it like any other autolink (getAutolinkHref already returns scheme URLs as-is). Scheme names are validated against the RFC 3986 grammar at configuration time.
  • New creation-time editor option autolinkSchemes: string[] (default: none), threaded defineEditorExtensiondefineInlineMarkPlugininlineTextToMarkChunksparseInline, which now picks a per-scheme-list configured parser (cached, one per distinct list; only inline parsing is extended, so LEZER_NODE_IDS stays valid).
  • Renamed FileLinkOptionsInlineParseOptions: the threaded options interface now carries both resolveFileLink and autolinkSchemes, matching its existing "host options that influence inline parsing" doc. (FileLinkResolver is unchanged.)
  • New autolinkSchemes prop on @meowdown/react's MeowdownEditor / ProseKitEditor, read once on mount like resolveFileLink.
  • README note in the autolinks section.

Tests

  • lezer/scheme-autolink.test.ts: detection (start/whitespace/paren boundaries, path+query+fragment, uppercase scheme, multiple schemes), rejection (unconfigured scheme, default parse, empty rest, mid-word, prefix scheme), trailing-punctuation trimming, coexistence with GFM/bare-domain autolinks and inline code/link labels, and config-time scheme validation.
  • extensions/autolink.test.ts: browser-mode rendering — reflect://today renders as a link with the right href when configured, stays plain text by default.
  • converters/roundtrip.test.ts: a custom-scheme URL round-trips byte-identical (it's plain text in the source).

Full suite (1218 tests), tsc -b, eslint, oxfmt, and knip all pass.

Notes

Downstream, Reflect will pass autolinkSchemes={['reflect']} once this ships in a release.

🤖 Generated with Claude Code

GFM's autolink only recognizes `www.` / `http(s)://` / email /
`mailto:` / `xmpp:` forms, so custom app schemes like
`reflect://today` stay plain text. Add a creation-time
`autolinkSchemes: string[]` editor option (and matching
`@meowdown/react` prop) that registers a `SchemeAutolink` lezer
inline parser for each configured scheme, with the same boundary and
trailing-punctuation rules as the bare-domain autolink. It emits the
shared `URL` node, so the existing mark walk renders and click-handles
it like any other autolink, and the markdown source round-trips
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

@maccman is attempting to deploy a commit to the ocavue's projects Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new

pkg-pr-new Bot commented Jul 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/prosekit/meowdown/@meowdown/core@214
npm i https://pkg.pr.new/prosekit/meowdown/@meowdown/react@214

commit: 5b98ded

@maccman

maccman commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator Author

We decided to scrap this one

@maccman maccman closed this Jul 4, 2026
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