Repository navigation
feat(lab): add link support to RichTextEditor - #4670
Merged
Merged
Conversation
potatowagon
requested review from
cixzhang,
ejhammond and
imdreamrunner
as code owners
August 3, 2026 05:28
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
potatowagon
force-pushed
the
navi/feat/richtext-links
branch
from
August 3, 2026 05:47
91a0f25 to
4149440
Compare
Add link creation/editing to the experimental RichTextEditor, matching
the command + node contract of Meta's EPS eps-lexical editor so its
internals can later be backed by this component.
- RichTextEditorToolbar: Link button + Cmd/Ctrl+K toggle a link on the
selection via Lexical TOGGLE_LINK_COMMAND; active state synced with
$isLinkNode(parent) || $isLinkNode(node). URL obtained via an
overridable promptForUrl (window.prompt default), sanitized to
http/https/mailto/tel. Collapsed-caret fallback inserts a link node.
- New-tab is baked into the link node data (target=_blank + rel via the
TOGGLE_LINK_COMMAND {url, target, rel} payload), so it serializes and
round-trips — no DOM-patching plugin. Toggle with linkOpensInNewTab.
- RichTextEditorAutoLinkPlugin: auto-linkify typed/pasted URLs + emails
with new-tab attributes; matchers overridable.
- linkUtils: sanitizeUrl/validateUrl + URL/EMAIL matchers.
- Tests, storybook stories, docs.
potatowagon
force-pushed
the
navi/feat/richtext-links
branch
from
August 3, 2026 06:14
4149440 to
1fda690
Compare
cixzhang
approved these changes
Aug 3, 2026
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsRichTextEditor (@astryxdesign/lab) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
added a commit
that referenced
this pull request
Aug 12, 2026
RichTextEditor's input wrapper spread `themeProps('rich-text-editor', ...)`
and then overwrote it with both `stylex.props(...)` and
`className={className}`. Each of those carries its own `className`, so React
kept only the last one: the stable `astryx-rich-text-editor` class never
reached the DOM, and with it went every StyleX class on the wrapper — border,
padding, disabled and status styling — plus the `xstyle` passthrough. Merged
through `mergeProps` instead, so the theme target, the StyleX classes and any
consumer `className`/`style` all survive.
The ChatSendButton half of this change landed separately on main in #4634
(`fix(Chat): add missing themeProps and fix className clobber`) with the same
`mergeProps` call, so only its regression test remains here.
The changeset goes with it: what is left changes `@astryxdesign/lab` only,
which is `private: true` / canary-only and so cannot be named in changeset
frontmatter (`check:changesets` rejects it), matching how other lab-only
fixes land (#4670, #4550, #4380, #4891).
@cixzhang
cixzhang
added a commit
that referenced
this pull request
Aug 12, 2026
`With Links` and `With Auto Link` arrived with link support in #4670, which touched no `packages/core/src` component, so `check-components` skipped pr-a11y and the two stories were never added to the baseline. They violate `aria-input-field-name` for exactly the reason the twelve baselined sibling stories do: the contenteditable carries `aria-labelledby` pointing at the control's own id, which no element in the DOM has, so the editor has no accessible name. Measured: an audit of unmodified origin/main reports the identical fifteen violations, including these two, so this is pre-existing debt this PR only surfaces (pr-a11y audits the stories of the components a PR touches). Fixing the accessible name properly is a component-level change that would resolve all fourteen stories and retire the twelve existing entries — out of scope for a theme-class fix. @cixzhang
cixzhang
added a commit
that referenced
this pull request
Aug 12, 2026
… scope pr-a11y audits the components a PR touches. This PR touches only `*.doc.mjs` metadata for these components — Storybook never reads `.doc.mjs` — so it renders nothing differently; it just widens the audit's scope onto violations that were already there. Each entry was verified by auditing the story at unmodified `origin/main` and reproducing it: - `RichTextEditor::With Links` / `With Auto Link` — `aria-input-field-name`. The Lexical `role="textbox"` host has no accessible name in ALL 14 RichTextEditor stories; twelve of them are already baselined. These two arrived with link support (#4670, 2026-08-04) after the baseline snapshot was generated (2026-07-31), which is the only reason they are missing. - `Schedule::List` — `color-contrast`. Schedule's stories anchor their events to `new Date()`, and past events render dimmed (#a9a9a9 on #ffffff, 2.35:1). Whether a given view contains a past event depends on the wall-clock time of the run, so the violation moves between stories: with the clock pinned to the failing CI run's date it reproduces on `List` at unmodified main; pinned to today it does not. Its five sibling Schedule stories are already baselined for the same rule. - `ListInput::*` (5 stories) — `aria-allowed-attr`. ListInput puts `aria-required` on a `role="group"` element, which does not support it. ListInput landed (#4740) after the baseline snapshot and has never been gated. NEEDS A REAL FIX in its own PR: Slider and FileInput already work around the same restriction (see the comments at Slider.tsx:452 and FileInput.tsx:472), and picking between those remedies is a call for ListInput's owner, not this chore. Hand-added rather than regenerated: `pnpm a11y:baseline` rewrites every entry for the components it audits, which would have dropped the Schedule, LogStream and Chat contrast entries that happen not to reproduce on this machine today. @cixzhang
cixzhang
added a commit
that referenced
this pull request
Aug 12, 2026
RichTextEditor's input wrapper spread `themeProps('rich-text-editor', ...)`
and then overwrote it with both `stylex.props(...)` and
`className={className}`. Each of those carries its own `className`, so React
kept only the last one: the stable `astryx-rich-text-editor` class never
reached the DOM, and with it went every StyleX class on the wrapper — border,
padding, disabled and status styling — plus the `xstyle` passthrough. Merged
through `mergeProps` instead, so the theme target, the StyleX classes and any
consumer `className`/`style` all survive.
The ChatSendButton half of this change landed separately on main in #4634
(`fix(Chat): add missing themeProps and fix className clobber`) with the same
`mergeProps` call, so only its regression test remains here.
The changeset goes with it: what is left changes `@astryxdesign/lab` only,
which is `private: true` / canary-only and so cannot be named in changeset
frontmatter (`check:changesets` rejects it), matching how other lab-only
fixes land (#4670, #4550, #4380, #4891).
@cixzhang
cixzhang
added a commit
that referenced
this pull request
Aug 12, 2026
`With Links` and `With Auto Link` arrived with link support in #4670, which touched no `packages/core/src` component, so `check-components` skipped pr-a11y and the two stories were never added to the baseline. They violate `aria-input-field-name` for exactly the reason the twelve baselined sibling stories do: the contenteditable carries `aria-labelledby` pointing at the control's own id, which no element in the DOM has, so the editor has no accessible name. Measured: an audit of unmodified origin/main reports the identical fifteen violations, including these two, so this is pre-existing debt this PR only surfaces (pr-a11y audits the stories of the components a PR touches). Fixing the accessible name properly is a component-level change that would resolve all fourteen stories and retire the twelve existing entries — out of scope for a theme-class fix. @cixzhang
cixzhang
added a commit
that referenced
this pull request
Aug 12, 2026
… scope pr-a11y audits the components a PR touches. This PR touches only `*.doc.mjs` metadata for these components — Storybook never reads `.doc.mjs` — so it renders nothing differently; it just widens the audit's scope onto violations that were already there. Each entry was verified by auditing the story at unmodified `origin/main` and reproducing it: - `RichTextEditor::With Links` / `With Auto Link` — `aria-input-field-name`. The Lexical `role="textbox"` host has no accessible name in ALL 14 RichTextEditor stories; twelve of them are already baselined. These two arrived with link support (#4670, 2026-08-04) after the baseline snapshot was generated (2026-07-31), which is the only reason they are missing. - `Schedule::List` — `color-contrast`. Schedule's stories anchor their events to `new Date()`, and past events render dimmed (#a9a9a9 on #ffffff, 2.35:1). Whether a given view contains a past event depends on the wall-clock time of the run, so the violation moves between stories: with the clock pinned to the failing CI run's date it reproduces on `List` at unmodified main; pinned to today it does not. Its five sibling Schedule stories are already baselined for the same rule. - `ListInput::*` (5 stories) — `aria-allowed-attr`. ListInput puts `aria-required` on a `role="group"` element, which does not support it. ListInput landed (#4740) after the baseline snapshot and has never been gated. NEEDS A REAL FIX in its own PR: Slider and FileInput already work around the same restriction (see the comments at Slider.tsx:452 and FileInput.tsx:472), and picking between those remedies is a call for ListInput's owner, not this chore. Hand-added rather than regenerated: `pnpm a11y:baseline` rewrites every entry for the components it audits, which would have dropped the Schedule, LogStream and Chat contrast entries that happen not to reproduce on this machine today. @cixzhang
cixzhang
added a commit
that referenced
this pull request
Aug 14, 2026
RichTextEditor's input wrapper spread `themeProps('rich-text-editor', ...)`
and then overwrote it with both `stylex.props(...)` and
`className={className}`. Each of those carries its own `className`, so React
kept only the last one: the stable `astryx-rich-text-editor` class never
reached the DOM, and with it went every StyleX class on the wrapper — border,
padding, disabled and status styling — plus the `xstyle` passthrough. Merged
through `mergeProps` instead, so the theme target, the StyleX classes and any
consumer `className`/`style` all survive.
The ChatSendButton half of this change landed separately on main in #4634
(`fix(Chat): add missing themeProps and fix className clobber`) with the same
`mergeProps` call, so only its regression test remains here.
The changeset goes with it: what is left changes `@astryxdesign/lab` only,
which is `private: true` / canary-only and so cannot be named in changeset
frontmatter (`check:changesets` rejects it), matching how other lab-only
fixes land (#4670, #4550, #4380, #4891).
@cixzhang
cixzhang
added a commit
that referenced
this pull request
Aug 14, 2026
`With Links` and `With Auto Link` arrived with link support in #4670, which touched no `packages/core/src` component, so `check-components` skipped pr-a11y and the two stories were never added to the baseline. They violate `aria-input-field-name` for exactly the reason the twelve baselined sibling stories do: the contenteditable carries `aria-labelledby` pointing at the control's own id, which no element in the DOM has, so the editor has no accessible name. Measured: an audit of unmodified origin/main reports the identical fifteen violations, including these two, so this is pre-existing debt this PR only surfaces (pr-a11y audits the stories of the components a PR touches). Fixing the accessible name properly is a component-level change that would resolve all fourteen stories and retire the twelve existing entries — out of scope for a theme-class fix. @cixzhang
cixzhang
added a commit
that referenced
this pull request
Aug 14, 2026
… scope pr-a11y audits the components a PR touches. This PR touches only `*.doc.mjs` metadata for these components — Storybook never reads `.doc.mjs` — so it renders nothing differently; it just widens the audit's scope onto violations that were already there. Each entry was verified by auditing the story at unmodified `origin/main` and reproducing it: - `RichTextEditor::With Links` / `With Auto Link` — `aria-input-field-name`. The Lexical `role="textbox"` host has no accessible name in ALL 14 RichTextEditor stories; twelve of them are already baselined. These two arrived with link support (#4670, 2026-08-04) after the baseline snapshot was generated (2026-07-31), which is the only reason they are missing. - `Schedule::List` — `color-contrast`. Schedule's stories anchor their events to `new Date()`, and past events render dimmed (#a9a9a9 on #ffffff, 2.35:1). Whether a given view contains a past event depends on the wall-clock time of the run, so the violation moves between stories: with the clock pinned to the failing CI run's date it reproduces on `List` at unmodified main; pinned to today it does not. Its five sibling Schedule stories are already baselined for the same rule. - `ListInput::*` (5 stories) — `aria-allowed-attr`. ListInput puts `aria-required` on a `role="group"` element, which does not support it. ListInput landed (#4740) after the baseline snapshot and has never been gated. NEEDS A REAL FIX in its own PR: Slider and FileInput already work around the same restriction (see the comments at Slider.tsx:452 and FileInput.tsx:472), and picking between those remedies is a call for ListInput's owner, not this chore. Hand-added rather than regenerated: `pnpm a11y:baseline` rewrites every entry for the components it audits, which would have dropped the Schedule, LogStream and Chat contrast entries that happen not to reproduce on this machine today. @cixzhang
cixzhang
added a commit
that referenced
this pull request
Aug 14, 2026
… scope pr-a11y audits the components a PR touches. This PR touches only `*.doc.mjs` metadata for these components — Storybook never reads `.doc.mjs` — so it renders nothing differently; it just widens the audit's scope onto violations that were already there. Each entry was verified by auditing the story at unmodified `origin/main` and reproducing it: - `RichTextEditor::With Links` / `With Auto Link` — `aria-input-field-name`. The Lexical `role="textbox"` host has no accessible name in ALL 14 RichTextEditor stories; twelve of them are already baselined. These two arrived with link support (#4670, 2026-08-04) after the baseline snapshot was generated (2026-07-31), which is the only reason they are missing. - `Schedule::List` — `color-contrast`. Schedule's stories anchor their events to `new Date()`, and past events render dimmed (#a9a9a9 on #ffffff, 2.35:1). Whether a given view contains a past event depends on the wall-clock time of the run, so the violation moves between stories: with the clock pinned to the failing CI run's date it reproduces on `List` at unmodified main; pinned to today it does not. Its five sibling Schedule stories are already baselined for the same rule. - `ListInput::*` (5 stories) — `aria-allowed-attr`. ListInput puts `aria-required` on a `role="group"` element, which does not support it. ListInput landed (#4740) after the baseline snapshot and has never been gated. NEEDS A REAL FIX in its own PR: Slider and FileInput already work around the same restriction (see the comments at Slider.tsx:452 and FileInput.tsx:472), and picking between those remedies is a call for ListInput's owner, not this chore. Hand-added rather than regenerated: `pnpm a11y:baseline` rewrites every entry for the components it audits, which would have dropped the Schedule, LogStream and Chat contrast entries that happen not to reproduce on this machine today. @cixzhang
cixzhang
added a commit
that referenced
this pull request
Aug 25, 2026
… scope pr-a11y audits the components a PR touches. This PR touches only `*.doc.mjs` metadata for these components — Storybook never reads `.doc.mjs` — so it renders nothing differently; it just widens the audit's scope onto violations that were already there. Each entry was verified by auditing the story at unmodified `origin/main` and reproducing it: - `RichTextEditor::With Links` / `With Auto Link` — `aria-input-field-name`. The Lexical `role="textbox"` host has no accessible name in ALL 14 RichTextEditor stories; twelve of them are already baselined. These two arrived with link support (#4670, 2026-08-04) after the baseline snapshot was generated (2026-07-31), which is the only reason they are missing. - `Schedule::List` — `color-contrast`. Schedule's stories anchor their events to `new Date()`, and past events render dimmed (#a9a9a9 on #ffffff, 2.35:1). Whether a given view contains a past event depends on the wall-clock time of the run, so the violation moves between stories: with the clock pinned to the failing CI run's date it reproduces on `List` at unmodified main; pinned to today it does not. Its five sibling Schedule stories are already baselined for the same rule. - `ListInput::*` (5 stories) — `aria-allowed-attr`. ListInput puts `aria-required` on a `role="group"` element, which does not support it. ListInput landed (#4740) after the baseline snapshot and has never been gated. NEEDS A REAL FIX in its own PR: Slider and FileInput already work around the same restriction (see the comments at Slider.tsx:452 and FileInput.tsx:472), and picking between those remedies is a call for ListInput's owner, not this chore. Hand-added rather than regenerated: `pnpm a11y:baseline` rewrites every entry for the components it audits, which would have dropped the Schedule, LogStream and Chat contrast entries that happen not to reproduce on this machine today. @cixzhang
This branch was successfully deployed
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.
What
Adds link support to the experimental
RichTextEditor(@astryxdesign/lab). PreviouslyLinkNode/AutoLinkNode+LinkPluginwere registered, so links rendered — but there was no way to create one. This adds creation, auto-linking, and new-tab behavior.Why this shape — EPS eps-lexical compatibility
The end goal is to back Meta's EPS
EPSRichTextArea(nest/libs/eps-lexical) with this editor. So the design deliberately matches EPS's command + node contract, not its UI chrome:TOGGLE_LINK_COMMAND(same as eps-lexical'sLinkPopoverPlugin.handleSubmit)$isLinkNode(parent) || $isLinkNode(node)(identical to the EPS toolbar)$createLinkNode(matches EPS)createLinkMatcherWithRegExp+attributes) and new-tab defaults — EPS can pass its own richer matchers (e.g.D123/T456/S789intern URLs)target/relvia theTOGGLE_LINK_COMMAND {url, target, rel}payload) so it serializes and round-trips — no DOM-patching pluginEPS keeps its own popover UI / hardened auto-link fork; astryx stays OSS-minimal and exposes the extension points (
promptForUrl,matchers,linkOpensInNewTab) so EPS drops in without changing the contract.Changes
RichTextEditorToolbar: Link button (on by default;hasLink={false}to hide) +Cmd/Ctrl+K(via Lexical'sisExactShortcutMatch, mirroring the playground'sShortcutsPlugin). Prompts for a URL via overridablepromptForUrl(defaultwindow.prompt), sanitizes it, toggles the link. Themeable icon via therichtext:linkregistry key.target="_blank"+rel="noopener noreferrer"by default;linkOpensInNewTab={false}opts out.RichTextEditorAutoLinkPlugin: auto-linkify typed/pasted URLs + emails (new-tab);matchersoverridable.linkUtils:sanitizeUrl/validateUrl(only http/https/mailto/tel; rejectsjavascript:/data:) +URL_MATCHER/EMAIL_MATCHER.WithLinks,WithAutoLink), doc updates.Testing
pnpm -F @astryxdesign/lab typecheck— clean (pre-existing.doc.mjsimplicit-any warnings unrelated)RichTextEditor.test.tsx— passing (incl. new link/sanitizer/autolink/new-tab/shortcut tests)check:sync/check:package-boundaries/check:changesets— clean