Repository navigation
feat(lab): add getHTML() to RichTextEditor imperative ref - #4550
Merged
Merged
Conversation
Adds `getHTML()` to the RichTextEditorRef handle, serializing the current content to an HTML string via $generateHtmlFromNodes (run in a read context; requires a DOM — available in the browser and jsdom tests). Adds `@lexical/html` as a new OPTIONAL peer dependency (peerDependencies + peerDependenciesMeta.optional + devDependencies), matching the other @lexical/* peers. `@lexical/html` is a subpackage (built dist) so this adds no top-level `lexical` value import — the sandbox build stays safe. - Extended RichTextEditorRef + EditorRefBridge - Updated doc.mjs ref best-practice note - Added getHTML() button to the ImperativeRef storybook story - Added a unit test asserting the HTML contains the seeded paragraph text Stacked on the getMarkdown PR (meta#4509) since both extend the same ref handle.
potatowagon
requested review from
cixzhang,
ejhammond and
imdreamrunner
as code owners
July 30, 2026 16:20
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
approved these changes
Jul 31, 2026
cixzhang
enabled auto-merge (squash)
July 31, 2026 06:26
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
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
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
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
getHTML()to theRichTextEditorimperative ref handle (RichTextEditorRef), serializing the current editor content to an HTML string.Why
Completes the EPS
RichTextArearef parity — its ref exposes bothgetMarkdown()(landed in #4509) andgetHTML(). Useful for copy/paste, email bodies, or handing content to non-Lexical consumers.How
getHTML: () => stringtoRichTextEditorRef.EditorRefBridgeimplements it aseditor.getEditorState().read(() => $generateHtmlFromNodes(editor, null))— run in a read context (as the$-API requires);nullselection serializes the whole document. Requires a DOM (present in the browser and in jsdom-based tests).$generateHtmlFromNodescomes from@lexical/html, added as a new optional peer dependency (peerDependencies + peerDependenciesMetaoptional: true+ devDependencies), matching every other@lexical/*peer. It's a subpackage (built dist), so this adds no top-levellexicalvalue import (avoiding the sandbox-build trap).pnpm-lock.yaml: added the@lexical/htmlimporter entry forpackages/lab. The package + its transitives already existed in the lockfile (pulled in transitively), so only the direct-dependency declaration was needed.Docs / stories / tests (SYNC contract)
RichTextEditor.doc.mjs— ref best-practice note now mentionsgetHTML().RichTextEditor.stories.tsx— added agetHTML()button to theImperativeRefstory.RichTextEditor.test.tsx— added a test asserting the HTML contains the seeded paragraph markup/text; handle-shape test updated.Testing
CI runs the full build/typecheck/lint/test. (Authored on a devserver without a local pnpm toolchain, so relying on CI. Only
@lexical/htmlsubpackage is imported — no top-levellexicalimport.)in lab https://facebook.github.io/astryx/pr/4550/?path=/docs/lab-richtexteditor--docs

Notes
main.