Skip to content

[lexical][lexical-headless][lexical-website] Documentation Update: Rewrite the introduction and modernize the Concepts, Serialization docs and examples - #9249

Merged
etrepum merged 53 commits into
meta:mainfrom
etrepum:claude/docs-intro-rewrite-tidq0q
Sep 27, 2026
Merged

etrepum merged 53 commits into
meta:mainfrom
etrepum:claude/docs-intro-rewrite-tidq0q

Conversation

@etrepum

@etrepum etrepum commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Description

The docs introduction was a long page of framework internals, and much of the rest of the docs and examples taught older setup (createEditor(), registerRichText(), LexicalComposer, hand-written importJSON/exportJSON, importDOM) before the extension-based APIs that most apps should use now.

This PR rewrites the introduction and brings the Concepts and Serialization docs and several examples up to date. Modern APIs come first, and older approaches are kept in clearly marked Legacy sections.

Follow-up to the #9237 getting-started PR

Introduction and Concepts

  • A shorter introduction with Mermaid diagrams (package layout, update lifecycle) and an interactive update lifecycle stepper. It links out to concept pages instead of explaining everything inline.
  • The Concepts sidebar is split into sub-groups. Document Model has a tree diagram with named slots and block decorators, and a new "Compared with ProseMirror" page collects the comparisons that were scattered across pages.
  • Concept page examples build editors with buildEditorFromExtensions() / LexicalExtensionComposer and register listeners from an extension's register.
  • Node Properties teaches $config with a JSON serialization schema (v0.51.0+), with a Legacy section for nodes without one. NodeState is presented for ad-hoc properties and properties on nodes you don't own, and points at the schema combinators for parsing. Node Cloning documents afterCloneFrom and when it isn't needed.
  • The transforms lifecycle image and the tree-view screenshot are replaced with a Mermaid diagram and text, and the relevant content of an external blog post is folded into the docs.
  • Commands: @group Commands is added to LexicalCommand exports in the API reference (a small TypeDoc plugin), and dispatchCommand notes that it should not be called from a read-only context.
  • Pages describe current behavior rather than release-note history ("Breaking change", "as of vX").
  • extensions/react.md documents LexicalExtensionEditorComposer for editors whose lifecycle you manage yourself.

Serialization

  • JSON comes first and starts with the $config serialization schema. HTML export starts with $generateHtmlFromNodes plus DOMRenderExtension, and it says which render hooks reach export. HTML import uses $generateNodesFromDOMViaExtension with the rules the node extensions register.
  • The extended HTML styling recipe is a DOMImportExtension import rule instead of an ExtendedTextNode subclass.
  • A new "Legacy HTML and JSON Serialization" page holds importDOM/exportDOM, the html editor config and hand-written JSON methods.
  • The lexical package README sets up the editor with extensions.

Code

  • @lexical/headless: adds HeadlessExtension, so a DOM-free editor can be built with buildEditorFromExtensions(), and uses invariant() for its unsupported-method errors.
  • lexical: JSDoc only (dispatchCommand note, updated serialization links).

Examples

  • node-replacement, node-state-style and vanilla-js-iframe use extensions, and node-state-style parses style with schema combinators.
  • The shadow-dom examples move from dev-examples/ to examples/ as standalone projects that run outside the monorepo. They are no longer deployed under /dev-examples/ on the website.
  • extension-vanilla-tailwind and extension-vanilla-react-plugin-host no longer copy source from the monorepo (their standalone vite build failed). Tailwind reads the theme classes from the installed @lexical/tailwind package via @source.

Test plan

Before

  • A copy of examples/extension-vanilla-tailwind or examples/extension-vanilla-react-plugin-host outside the monorepo failed pnpm install && pnpm run build (ELIFECYCLE Command failed with exit code 1), because its Vite config copied files from ../../packages.
  • Two docs snippets were wrong when run:
    • The commands page's TOGGLE_LINK_COMMAND logger registered at the same priority as LinkExtension, so it never received the command.
    • The serialization page said $decorateDOM output reaches HTML export, which it does not.

After

  • pnpm exec docusaurus build in packages/lexical-website: [SUCCESS] Generated static files in "build". with no broken links or anchors (onBrokenLinks/onBrokenAnchors throw).
  • New unit tests for HeadlessExtension in packages/lexical-headless/src/__tests__/unit/HeadlessExtension.test.ts pass under pnpm run test-unit.
  • Code samples on the rewritten pages (editor setup, schema-based nodes, the DOMImportExtension styling rule, the DOMRenderExtension export override, headless import with withDOM(), the command logger, the README examples) were run as temporary Vitest tests against the monorepo sources.
  • Each changed example was installed and built standalone against the published 0.51.0 packages and exercised in Chromium with Playwright:
    • The shadow-dom and shadow-dom-web-component Playwright suites pass (5 and 35 tests).
    • node-replacement, node-state-style, vanilla-js-iframe and the two Tailwind examples were exercised by typing, formatting, undo and each example's own controls.
    • StackBlitz was not exercised.
  • CI (lint, prettier, tsc, flow, unit tests) is green on the fork PR.

… with Mermaid diagrams

## Description

The introduction page (/docs/intro) had not been revised in a long time. It
claimed the core is 22kb min+gzip (a production build of `lexical` is now
about 64kB), mentioned Workplace, did not mention extensions at all, and
used two draw.io SVG diagrams that are hard to edit and had drifted from the
code.

This rewrite:

- Tightens the overview and the "what can you build" list, and drops the
  outdated size claim.
- Adds a "How it fits together" section that introduces extensions with a
  short `buildEditorFromExtensions` example and links to the quick starts.
- Restructures the core concepts (editor, editor state, reading and
  updating, updates and the reconciler, commands/transforms/listeners) to be
  shorter and consistent with the current read modes (`editor.read(fn)`,
  `'pending'`, `'latest'`), with an update example and links to the concept
  pages for depth. The "Reading and Updating Editor State" heading is kept
  because the ESLint plugin README links to its anchor.
- Replaces both SVG diagrams with Mermaid diagrams (already enabled in the
  site config) and deletes the unused SVG files.

## Test plan

### Before

The page rendered the two `.drawio.svg` images and the old text.

### After

`npx docusaurus build` in packages/lexical-website succeeds (onBrokenLinks
and onBrokenAnchors are `throw`), and `prettier --check` passes on the page.
Served the build and loaded /docs/intro in Chromium with Playwright: both
Mermaid diagrams render as SVG with no page errors, and at 390px width the
page has no horizontal scroll (scrollWidth 390). Firefox and WebKit were not
checked.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ee with ProseMirror in the intro

## Description

The intro described the editor state as a node tree but did not explain the
design choice behind its shape. This adds a "A DOM-like document tree"
section explaining that Lexical's tree mirrors the HTML it renders (inline
wrappers such as links are element nodes, positions are a node key plus an
offset), and a short table of similarities and differences with
ProseMirror's text-first model (marks, integer positions, schema).

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes and
`npx docusaurus build` in packages/lexical-website succeeds with broken link
and anchor checks set to throw.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… in the intro

## Description

The intro only mentioned Meta as a user of Lexical. This adds Ghost, Payload
CMS, Proton Docs, and Sveltia CMS, each confirmed from the project's own
changelog, docs, or package.json.

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes. The
change adds only external links, which the Docusaurus link check does not
validate.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…of adopters

## Description

Adds Dify, whose web app depends on `lexical`, `@lexical/react` and several
other `@lexical/*` packages, to the list of projects built on Lexical.

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ecorators in the intro's ProseMirror comparison

## Description

The intro's comparison table with ProseMirror did not mention named slots,
which let one node own several isolated, named editable regions, and it
implied that `DecoratorNode` is only inline content. This adds a named slots
row (linking the experimental Named Slots page) and notes that a
`DecoratorNode` can be inline or a block.

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes and
`npx docusaurus build` in packages/lexical-website succeeds with broken link
and anchor checks set to throw.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…', fn) in the intro

## Description

The intro described the committing read as `editor.read(fn)`. It now names
the explicit `editor.read('force-commit', fn)` form, in both the example and
the list of read modes, and notes that the no-mode `editor.read(fn)` does
the same thing and is kept for convenience and backwards compatibility.

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…mmands in the intro's update diagram

## Description

The update lifecycle diagram in the intro only showed commands being
dispatched from user input. It now also shows application code dispatching
commands with `editor.dispatchCommand()`.

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes, and
the diagram renders with the site's Mermaid version in Chromium.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…and running without a browser DOM in the intro

## Description

The intro did not explain how Lexical handles DOM changes it did not make,
or that it can run without a browser DOM. This change:

- Explains that the editor state is the source of truth, and that Lexical
  watches its root element with a `MutationObserver` (paused while the
  reconciler writes) to read outside text edits back into the editor state
  and revert other outside DOM changes, with `setDOMUnmanaged()` as the
  opt-out. The update diagram gains a dotted edge from the DOM back to the
  pending state for these changes.
- Adds a "Running without a browser" section covering `@lexical/headless`
  with no DOM and `withDOM()` from `@lexical/headless/dom` with a virtual
  DOM (happy-dom) for HTML import and export.

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes and
`npx docusaurus build` in packages/lexical-website succeeds with broken link
and anchor checks set to throw.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…JSON claim, and add accessible diagrams

## Description

Ports improvements from an alternate rewrite of the intro:

- Restores the original section anchors (`#what-can-be-built-with-lexical`,
  `#lexicals-design`, `#editor-instances`, `#editor-states`,
  `#reading-and-updating-editor-state`, `#dom-reconciler`,
  `#listeners-node-transforms-and-commands`) with explicit heading ids, so
  existing links keep working.
- Corrects serialization: `toJSON()` covers the document tree only
  (`SerializedEditorState` is `{root}`), not the selection or node keys, and
  only committed editor states are immutable.
- Adds `accTitle`/`accDescr` to every Mermaid diagram, plus a small diagram
  of an example editor state (tree and selection).
- Adds "Node identity and navigation" and "Applying edits" rows to the
  ProseMirror comparison.
- Links adopters to pages that show their Lexical use, and ends with a
  "Get started" section.

## Test plan

### After

`npx prettier --check` passes on the page. `npx docusaurus build` succeeds
with broken link and anchor checks set to throw, and the built
`docs/intro/index.html` contains all seven original anchor ids. Served the
build in Chromium: three Mermaid diagrams render with no page errors.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…rom named slots in the intro

## Description

The intro's comparison table labeled named slots as experimental. That
distinction is expected to go away soon and is not useful in an overview,
so the label is removed; the linked Named Slots page still carries its own
status note.

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes and
the page no longer contains "experimental".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…, and read-mode wording in the intro

## Description

- Describes ProseMirror accurately: its document is a tree whose blocks can
  contain blocks, and a textblock's inline content is a flat sequence of
  nodes with marks, rather than "a flat run of text".
- Adds a caveat that Lexical's DOM resemblance is structural: bold and
  italic are `TextNode` formats, not separate element nodes.
- Says update listeners run after a commit, while root and editable
  listeners have their own triggers.
- Adds what the application supplies versus Lexical, `editorState.read(fn)`
  for reading a specific snapshot, guidance to do async work before entering
  an update, why transforms run inside the update, and links collaboration
  to the Yjs guide.

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes and
`npx docusaurus build` in packages/lexical-website succeeds with broken link
and anchor checks set to throw.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…gram as an ordered sequence

## Description

The update diagram was a flowchart of connections that did not show the
order in which an update happens. It is now a numbered sequence diagram
that follows `$beginUpdate` and `$commitPendingUpdates`: start an update
(directly or through command handlers), clone the pending state for the
first update in a batch, run the callback, run node transforms until
nothing is dirty, batch further updates, commit (microtask or discrete),
reconcile the DOM and then the DOM selection, call mutation, text content,
and update listeners, and show outside DOM changes starting a new update.
The paragraph above it is reworded to match that order.

## Test plan

### After

`npx prettier --check` passes on the page and `npx docusaurus build`
succeeds with broken link and anchor checks set to throw. Rendered the
diagram with the site's Mermaid version in Chromium; all eight numbered
steps are legible.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ram into phases

## Description

The numbered sequence diagram implied a single starting point, but an
update can start in several ways. The diagram is now a top-to-bottom
flowchart of phases, following `$beginUpdate` and `$commitPendingUpdates`:
what starts an update (user input via commands, `dispatchCommand()`,
`update()`/`setEditorState()`, outside DOM changes seen by the
MutationObserver), what happens during it (clone, callback or handlers,
node transforms), after it (nested updates, garbage collection, commit
scheduling and batching), when the batch is reconciled (state becomes
current, DOM patched with the observer paused, DOM selection), and after
reconciliation (mutation, text content, and update listeners, then
`onUpdate` callbacks).

## Test plan

### After

`npx prettier --check` passes on the page and `npx docusaurus build`
succeeds with broken link and anchor checks set to throw. Rendered the
diagram with the site's Mermaid version in Chromium and checked the layout.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ty project and link adopters' homepages

## Description

The intro said Lexical "is developed at Meta", which no longer reflects who
builds it. It now says Lexical started at Meta, which still uses it, and is
an open-source project where most development comes from community
volunteers. Links to projects built on Lexical now point at each project's
homepage instead of announcement posts or GitHub repositories.

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes. The
change only edits prose and external links, which the Docusaurus link check
does not validate.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ty project that includes Meta

## Description

The previous wording ("started at Meta ... now an open-source project built
by a community of volunteers") read as though Meta had stepped away. The
intro now says Lexical is an open-source community project that began at
Meta, whose contributors include Meta engineers alongside volunteers and
developers from other companies, and that it powers Meta's web products.

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…r to the intro

## Description

The intro's update diagram shows the phases of an update but not how a
concrete change moves through them. This adds an `UpdateLifecycle` React
component below the diagram. The reader picks what starts the update
(typing a character, a Bold button dispatching a command, two
`editor.update()` calls in the same tick, or an outside DOM change caught by
the MutationObserver) and steps through the phases with Back/Next/Play.
Three panes show the current state, the pending state, and the DOM at each
step, highlighting the one that just changed. The steps follow
`$beginUpdate`, `$commitPendingUpdates`, `onBeforeInput`/`onInput`,
`FORMAT_TEXT_COMMAND`'s rich text handler, and `flushMutations`.

The static Mermaid diagram stays for readers who do not interact and for
screen readers; the stepper announces each step through an `aria-live`
region, uses real buttons with `aria-pressed`/`aria-current`, follows the
site's light and dark themes, and turns off transitions under
`prefers-reduced-motion`.

## Test plan

### After

`npx eslint` and `npx prettier --check` pass on the component, `tsc
--noEmit -p packages/lexical-website` reports no errors, and `npx docusaurus
build` succeeds with broken link and anchor checks set to throw. Served the
build and drove the stepper in Chromium with Playwright in light and dark
themes: selecting an example, Next, and Play all advance the step with no
page errors; at 390px width the page has no horizontal scroll. Firefox and
WebKit were not checked.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…e.read in the intro

## Description

The intro showed `editorState.read(fn)` without an editor, so `$getEditor()`
and extension lookups would not work inside the callback. Both the read-mode
list and the update listener example now use `editorState.read(fn, {editor})`
and explain why.

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…nges Lexical keeps or reverts

## Description

The intro's description of outside DOM changes implied that any text edit is
read back and other changes reverted, without saying why. It now states the
rule the MutationObserver handler (`flushMutations`) applies: a change is
kept only if it looks like native text input, and everything else is
reverted.

- Kept: character changes inside a DOM text node Lexical rendered (typing,
  spellcheck, autocorrect, IME), read into the matching `TextNode`; changes
  right after a text input event are left to the `input` handler.
- Reverted: added or removed DOM nodes (extensions, scripts, the browser's
  own block edits): added nodes are removed, removed nodes restored by their
  parent, stray `<br>`s cleaned up, and the selection restored.
- Ignored: decorator contents and DOM marked with `setDOMUnmanaged()`.

## Test plan

### After

`npx prettier --check packages/lexical-website/docs/intro.md` passes and
`npx docusaurus build` succeeds with broken link and anchor checks set to
throw.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…content export in the intro

## Description

The intro described rendering only through each node's `createDOM()` and
`updateDOM()`, and did not explain how content is exported or imported.

This adds a paragraph on `DOMRenderExtension` overrides (per node class,
composed with `$next()`, shared by rendering and HTML export), mentions it in
the ProseMirror comparison table's Rendering row, and adds an "Exporting and
importing content" section with a JSON / HTML / Markdown / clipboard table
comparing Lexical with ProseMirror.

## Test plan

### After

`npx docusaurus build` in packages/lexical-website exits 0 with no broken
links or anchors (onBrokenLinks and onBrokenAnchors are set to 'throw').

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…thout @lexical/headless

## Description

The intro's "Running without a browser" section pointed to
`@lexical/headless` for running with no DOM. The core already skips
reconciliation and DOM selection when an editor has no root element
(`shouldSkipDOM = editor._headless || rootElement === null` in
LexicalUpdates.ts), so an editor built with `buildEditorFromExtensions()`
that never gets a root element is effectively headless. The section now says
that instead, and keeps `withDOM()` from `@lexical/headless/dom` for the
virtual-DOM case.

## Test plan

### After

`npx docusaurus build` in packages/lexical-website exits 0 with no broken
links or anchors.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
## Description

`@lexical/headless` only offered `createHeadlessEditor()`, which cannot be
used with `buildEditorFromExtensions()`, and it makes
`registerRootListener`, `registerMutationListener` and similar methods throw,
which would break the many extensions that register them.

This adds `HeadlessExtension`. Its `build` step, which runs before any
extension registers, sets `editor._headless` so nested editors inherit it and
DOM-only code such as `registerCodeGutter` skips itself. It also makes
`setRootElement(element)` throw so the editor cannot be attached to the DOM
by mistake. `setRootElement(null)` still works, which `editor.dispose()`
needs, and listener registration keeps working. `createHeadlessEditor()` is
unchanged. The package README and the docs intro describe it.

## Test plan

### Before

`npx vitest run packages/lexical-headless/src/__tests__/unit/HeadlessExtension.test.ts`
without the export:

```
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 4 ⎯⎯⎯⎯⎯⎯⎯
TypeError: Cannot read properties of undefined (reading 'name')
```

### After

```
$ npx vitest run packages/lexical-headless
 Test Files  2 passed (2)
      Tests  12 passed (12)
$ npx vitest run scripts/__tests__/unit/treeShakingSource.test.ts
      Tests  339 passed (339)
$ pnpm run flow
Found 0 errors
```

`pnpm run tsc`, ESLint and Prettier on the changed files, and
`npx docusaurus build` also pass.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ncept pages and split the Concepts sidebar

## Description

The rewritten intro had grown to about 400 lines, holding explanations that
belong with the concepts they describe, and the Concepts sidebar category had
20 entries.

This keeps the intro to an overview (what Lexical is, what you can build, the
package diagram and extension example, and one short paragraph per core idea
with a link), keeping every original anchor. The detail moves to:

- a new Document Model page (the DOM-like tree, the ProseMirror comparison,
  and DOMRenderExtension);
- Editor State (the example tree diagram, what `toJSON()` includes, the `$`
  function convention, node keys, and the read modes, replacing the older
  update example and double-buffering description);
- Updates, now `updates.mdx` (the lifecycle diagram, the interactive
  stepper, and how outside DOM changes are kept or reverted, ahead of the
  existing update tags content);
- a new Running Without a Browser page (HeadlessExtension, withDOM, and a
  JSON-to-HTML server example);
- Serialization (a "Formats at a glance" section with the Lexical vs
  ProseMirror table).

The sidebar splits Concepts into Concepts, Nodes, and Browser and
Environment. Doc ids and URLs are unchanged.

## Test plan

### After

`npx docusaurus build` exits 0 with no broken links or anchors; its only
HTML minifier diagnostics also appear when building the base commit. Served
the build in Chromium with Playwright: the intro, Editor State, Document
Model, Updates, Running Without a Browser, and Serialization pages load with
no page errors and no horizontal scroll at 390px, the Mermaid diagrams render
on the intro, Editor State, and Updates pages, the stepper works on Updates,
and the sidebar shows the three new categories. The server example on
Running Without a Browser was run as a Vitest test in a Node environment.
Firefox and WebKit were not checked.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…Lexical to the intro

## Description

The intro listed Ghost, Payload CMS, Proton Docs, Sveltia CMS, and Dify. This
adds Supabase, MDXEditor, RAGFlow, DeepSeek Harness, and Paperclip, each
linked to its homepage.

## Test plan

### After

`npx docusaurus build` in packages/lexical-website exits 0.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…al users in the intro

## Description

The intro named Meta's web products as a large deployment of Lexical. This
adds Bloomberg alongside it, linked to its homepage.

## Test plan

### After

`npx docusaurus build` in packages/lexical-website exits 0.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… list of projects

## Description

Ghost uses an old version of Lexical, so the intro no longer lists it among
the projects built on Lexical.

## Test plan

### After

`npx docusaurus build` in packages/lexical-website exits 0.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…tRootElement check

## Description

HeadlessExtension threw a plain `Error` when `setRootElement` was given an
element. It now uses `invariant` from `@lexical/internal/invariant`, like the
rest of the codebase, so the message is minified to an error code in
production builds. The message is prefixed with `HeadlessExtension:`.

## Test plan

### After

```
$ npx vitest run packages/lexical-headless
 Test Files  2 passed (2)
      Tests  12 passed (12)
$ npx vitest run scripts/__tests__/unit/treeShakingSource.test.ts
      Tests  339 passed (339)
```

`pnpm run tsc` and ESLint on the package pass.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… unsupported methods

## Description

`createHeadlessEditor()` replaced 8 DOM-only methods with stubs that threw a
plain `Error`. They now use `invariant` from `@lexical/internal/invariant`, so
production builds get a minified error code. Development builds keep the
same message (`<method> is not supported in headless mode`), and a new test
checks it.

## Test plan

### Before

The new test passes against the old `throw new Error` implementation too,
confirming the development message is unchanged:

```
$ npx vitest run packages/lexical-headless
      Tests  13 passed (13)
```

### After

```
$ npx vitest run packages/lexical-headless
      Tests  13 passed (13)
$ npx vitest run scripts/__tests__/unit/treeShakingSource.test.ts
      Tests  339 passed (339)
```

`pnpm run tsc`, ESLint, and Prettier on the package pass.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…e examples

## Description

Several concept pages still set up editors with `createEditor()`,
`registerRichText()`, `createHeadlessEditor()`, or `LexicalComposer`
`initialConfig`, and pointed to React plugins where an extension now exists.

- Editor State: the load/save example uses `buildEditorFromExtensions` with
  `$initialEditorState`, and the React example uses
  `LexicalExtensionComposer`; the accepted values describe
  `$initialEditorState` (noting where legacy `initialConfig.editorState`
  differs).
- Read-only: sets `editable` on the app extension and mentions
  `WatchEditableExtension`.
- DOM Events: the root listener examples are extensions (with a null root
  check), and NodeEventPlugin is shown inside `LexicalExtensionComposer`.
- Commands: registers a command from an extension's `register` instead of a
  React `useEffect`, and links RichTextExtension, PlainTextExtension,
  ListExtension, and TabIndentationExtension.
- Node Replacement and Serialization's ExtendedTextNode recipe declare
  replacements in an extension's `nodes`.
- Serialization's headless HTML import uses HeadlessExtension and `withDOM()`
  instead of `createHeadlessEditor()` and JSDOM.
- Smaller wording fixes in Transforms, Nodes, Selection, and Shadow DOM.

## Test plan

### After

`npx docusaurus build` in packages/lexical-website exits 0 (the two HTML
minifier diagnostics are also present on the base commit). The Serialization
headless import example was run as a Vitest test in a Node environment and
imported the heading and paragraph text.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…hot and the state updates blog link with docs text

## Description

The Editor State page showed the flat Lexical node tree as a PNG screenshot of
the tree view, which screen readers cannot read and which is hard to keep up to
date. It is now a text code block with the same tree, generated by
`generateContent()` from `@lexical/devtools-core` for the example content, plus
a sentence explaining what it shows. The unused PNG is deleted.

Editor State and Serialization also linked to an external blog post about state
updates. Its content (the update lifecycle, batching, discrete updates, and the
`$` function convention) is already covered in Editor State and Updates, except
for why `$` functions only work inside a callback and the read-only error. This
adds a paragraph on both to "The `$` function convention", links the
`@lexical/rules-of-lexical` ESLint rule, and points the Serialization tip at the
discrete updates section instead of the blog post.

## Test plan

### After

`npx docusaurus build` in packages/lexical-website exits 0 with no broken links
or anchors, and the built Editor State page no longer references
`state-formatting-lexical.png`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…nd gather ProseMirror comparisons on one page

## Description

The Document Model page described the tree in prose only, and comparisons
with ProseMirror were spread across Document Model, Serialization, History
and the intro.

This adds a Mermaid diagram of a small document tree to Document Model,
showing ordinary children and a card with a named `title` slot, and moves
every ProseMirror comparison to a new Concepts page, "Compared with
ProseMirror", with Document model, Serialization and History sections. The
other pages keep their Lexical-only content and link to the new page.

## Test plan

### Before

The Document Model page had no diagram, and `grep -ril prosemirror docs`
matched document-model.md, serialization.md, history.md and intro.md.

### After

```
$ npx docusaurus build --out-dir /tmp/claude-0/dm-build
[SUCCESS] Generated static files in "../../../../../tmp/claude-0/dm-build".
```

The diagram renders in Chromium with no Mermaid syntax error. Outside the new
page, ProseMirror is mentioned only in testing.md (a list of editors, not a
comparison), the generated API docs, and the links to the new page.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… config on StackBlitz

## Description

extension-vanilla-tailwind and extension-vanilla-react-plugin-host set a
`stackblitz.startCommand` of `npm i && npm run monorepo:dev`. StackBlitz
opens only the example's directory, so `vite.config.monorepo.ts` could not
resolve `../../scripts/vite/lexicalMonorepoPlugin.ts` and the dev server
never started. Both examples now drop the override, like every other
example, so StackBlitz runs `npm install` and the standalone `dev` script
against the published packages.

## Test plan

### Before

Reported when opening the pinned StackBlitz URL:

```
> @lexical/[email protected] monorepo:dev
> vite -c vite.config.monorepo.ts

✘ [ERROR] Could not resolve "../../scripts/vite/lexicalMonorepoPlugin.ts"
```

### After

Each example extracted on its own (as StackBlitz sees it), then
`npm i && npx vite`: the dev server starts, serves the page, and the
generated CSS includes the `@lexical/tailwind` theme classes (for example
`list-[upper-alpha]`):

```
added 58 packages in 11s
  ➜  Local:   http://localhost:4190/
```

StackBlitz itself was not exercised from this environment.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
## Description

The examples that display the editor state as JSON wrote the legacy form
(`editorState.toJSON()`), which repeats every default and the deprecated
`version` property. They now use the compact form available since 0.51.0,
`editorState.toJSON(true)`:

- extension-vanilla-tailwind: the "Editor state" panel
- vanilla-js-iframe: the state textarea
- node-state-style: the Shiki JSON view
- extension-sveltekit-ssr-hydration: the export JSON view
- shadow-dom-web-component: the element's `value` and its form value (both
  read back with `parseEditorState`, which accepts either form)

vanilla-js and vanilla-js-plugin are left alone: meta#9237
rewrites both and already switches them to `toJSON(true)`, so changing them
here would only conflict.

While checking the SvelteKit example, `svelte-check` failed on its Vitest
config (`provider: 'playwright'` is not accepted by Vitest 4). It now uses
`playwright()` from `@vitest/browser-playwright`, added as a dev dependency.

## Test plan

### Before

```
$ pnpm run check   # extension-sveltekit-ssr-hydration
vite.config.ts:33:7
Error: No overload matches this call.
svelte-check found 1 error and 0 warnings in 1 file
```

### After

Each changed example extracted on its own, installed against the published
0.51.0 packages and built (`✓ built in ...` for all five).

```
$ pnpm run check   # extension-sveltekit-ssr-hydration
COMPLETED 954 FILES 0 ERRORS 0 WARNINGS 0 FILES_WITH_PROBLEMS
$ playwright test   # extension-sveltekit-ssr-hydration
  2 passed (9.9s)
$ playwright test   # shadow-dom-web-component
  35 passed (17.3s)
```

In Chromium, the extension-vanilla-tailwind state panel shows the compact
form (each node leads with `type`, no `version` properties).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
## Description

The form demo printed each submitted value as indented JSON with its
newlines replaced by spaces and cut at 300 characters, so the output ran
together with irregular gaps. Now that the value is the compact form, it is
printed as normal two-space indented JSON in the `pre-wrap` output box, in
full.

## Test plan

### Before

```
notes: {  "root": {   "type": "root",   "children": [    {     "type": "paragraph", ...
```

### After

```
notes: {
  "root": {
    "type": "root",
    "children": [
      {
        "type": "paragraph",
```

`playwright test` in the example (standalone, published 0.51.0): 35 passed.
`tsc -p .` reports no errors.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…lder pnpm setups

## Description

`extension-sveltekit-ssr-hydration` could not be installed in a fresh
environment such as StackBlitz:

- With pnpm 8, install failed with `ERR_PNPM_UNSUPPORTED_ENGINE`: every
  `svelte-eslint-parser` release from 1.4 on (pulled in by
  `eslint-plugin-svelte`) declares an exact `engines.pnpm`, which pnpm 8
  enforces for dependencies. pnpm 9 and 10 install it fine.
- With npm, install failed with `ERESOLVE`: `vitest-browser-svelte@^0.1.0`
  peers on `@vitest/browser` 2 or 3, while the example uses Vitest 4.

Changes:
- `"packageManager": "[email protected]"`, so corepack runs a pnpm that installs it.
- `vitest-browser-svelte` ^3.1.0, which peers on Vitest 4.
- vitest-setup-client.ts references `@vitest/browser-playwright` types, the
  Vitest 4 home of the Playwright provider.

## Test plan

### Before

```
$ pnpm install   # pnpm 8.15.6
 ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)
$ npm i
npm error code ERESOLVE
npm error peer @vitest/browser@"^2.1.0 || ^3.0.0-0" from [email protected]
```

### After

The example extracted on its own:

```
$ npm i && npm run check
added 244 packages in 18s
COMPLETED 962 FILES 0 ERRORS 0 WARNINGS 0 FILES_WITH_PROBLEMS
$ corepack pnpm install && corepack pnpm run lint && corepack pnpm exec playwright test
Done in 5.5s using pnpm v10.33.0
All matched files use Prettier code style!
  2 passed (10.0s)
```

pnpm 8 run directly (without corepack) still hits the upstream
`engines.pnpm` pin. StackBlitz itself was not exercised from this
environment.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
## Description

`extension-sveltekit-ssr-hydration` shipped the SvelteKit template's
`.npmrc` with `engine-strict=true`. Every `svelte-eslint-parser` release
from 1.4 on (a dependency of `eslint-plugin-svelte`) declares an exact
`engines.pnpm`, so with engine-strict any other pnpm, such as StackBlitz's
8.15.6, fails with `ERR_PNPM_UNSUPPORTED_ENGINE`. Without engine-strict it
is only a warning.

This removes the `.npmrc`, and with it the `"packageManager"` pin added in
the previous commit, which StackBlitz ignores and which is not needed once
the install is not strict.

## Test plan

### Before

```
$ pnpm install   # pnpm 8.15.6, with the example's .npmrc
 ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)
```

### After

The example extracted on its own, fresh install each time:

```
pnpm 8.15.6: Done in 5.7s
pnpm 10.34.5: Done in 4.8s using pnpm v10.34.5
pnpm 11.28.0: Done in 8.3s using pnpm v11.28.0
npm: added 244 packages in 22s
```

With pnpm 8.15.6: `pnpm run check` reports 0 errors, `eslint .` passes,
`pnpm run dev` serves the page, and `playwright test` passes 2 tests.
StackBlitz itself was not exercised from this environment.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@etrepum
etrepum added this pull request to the merge queue Sep 27, 2026
Merged via the queue into meta:main with commit 9aaa7d7 Sep 27, 2026
46 checks passed
@etrepum etrepum mentioned this pull request Sep 28, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 377cf72d Deployed Sep 27, 2026 by vercel[bot]
Preview – lexical-playground — 377cf72d Deployed Sep 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants