Skip to content

[lexical-website] Documentation Update: correct DOMExportOutput, DOMConversion priority, and the HeadingNode examples - #9223

Merged
etrepum merged 1 commit into
meta:mainfrom
potatowagon:docs-serialization-fixes
Sep 24, 2026
Merged

etrepum merged 1 commit into
meta:mainfrom
potatowagon:docs-serialization-fixes

Conversation

@potatowagon

Copy link
Copy Markdown
Contributor

Description

Three corrections in serialization/serialization.md:

  1. DOMExportOutput is reproduced with Flow syntax and the wrong types —
    element is shown as optional and HTMLElement-only, and after uses
    Flow's ?T. In source element is required and both it and after accept
    HTMLElement | DocumentFragment | Text | null.
  2. DOMConversion.priority is shown as required — it is optional.
  3. The exportJSON / importJSON / updateFromJSON bodies are introduced
    as "an example ... for the HeadingNode"
    — the shipped HeadingNode
    implements none of them. It declares only overload signatures and
    serializes through $config's json: headingNodeSchema. The snippets
    themselves are still valid, supported code, so they stay; they are
    reworded as illustration and a note points at the declarative-schema
    section the node actually uses.

Test plan

Documentation-only change (markdown is excluded from prettier via
.prettierignore), so the check is that the reproduced types and the
attribution match source.

Before

$ sed -n '45,48p' packages/lexical-website/docs/serialization/serialization.md
export type DOMExportOutput = {
  after?: (generatedElement: ?HTMLElement) => ?HTMLElement,
  element?: HTMLElement | null,
};

$ sed -n '138,141p' packages/lexical-website/docs/serialization/serialization.md
type DOMConversion = {
  conversion: DOMConversionFn;
  priority: 0 | 1 | 2 | 3 | 4;
};

$ grep -n "example of .exportJSON.\|example of .importJSON." packages/lexical-website/docs/serialization/serialization.md
409:Here's an example of `exportJSON` for the `HeadingNode`:
444:Here's an example of `importJSON` for the `HeadingNode`:

$ grep -n "^  exportJSON(\|^  static importJSON(\|^  updateFromJSON(" packages/lexical-rich-text/src/index.ts
352:  exportJSON(compact?: false): SerializedHeadingNode;
353:  exportJSON(compact: boolean): SerializedPartial<SerializedHeadingNode>;
354:  updateFromJSON(serializedNode: LexicalParseJSON<SerializedHeadingNode>): this;

Those three lines are declaration-merging overload signatures in an
interface, not implementations — HeadingNode's class body has none.

After

$ sed -n '45,51p' packages/lexical-website/docs/serialization/serialization.md
export interface DOMExportOutput {
  after?: (
    generatedElement: HTMLElement | DocumentFragment | Text | null | undefined,
  ) => HTMLElement | DocumentFragment | Text | null | undefined;
  element: HTMLElement | DocumentFragment | Text | null;
}

$ sed -n '141,144p' packages/lexical-website/docs/serialization/serialization.md
type DOMConversion = {
  conversion: DOMConversionFn;
  priority?: 0 | 1 | 2 | 3 | 4;
};

$ grep -n "no longer writes" packages/lexical-website/docs/serialization/serialization.md
412:(the shipped `HeadingNode` no longer writes this by hand — see the note below):
464:The shipped `HeadingNode` no longer writes any of these three methods by

Sources: packages/lexical/src/LexicalNode.ts:885-900 (DOMExportOutput) and
:854-857 (DOMConversion); packages/lexical-rich-text/src/index.ts:341-347
(headingNodeSchema) and :400 (json: headingNodeSchema in $config).

…onversion priority, and the HeadingNode examples

## Description

Three corrections in `serialization/serialization.md`:

1. **`DOMExportOutput` is reproduced with Flow syntax and the wrong types** —
   `element` is shown as optional and `HTMLElement`-only, and `after` uses
   Flow's `?T`. In source `element` is required and both it and `after` accept
   `HTMLElement | DocumentFragment | Text | null`.
2. **`DOMConversion.priority` is shown as required** — it is optional.
3. **The `exportJSON` / `importJSON` / `updateFromJSON` bodies are introduced
   as "an example ... for the `HeadingNode`"** — the shipped `HeadingNode`
   implements none of them. It declares only overload signatures and
   serializes through `$config`'s `json: headingNodeSchema`. The snippets
   themselves are still valid, supported code, so they stay; they are
   reworded as illustration and a note points at the declarative-schema
   section the node actually uses.

## Test plan

Documentation-only change (markdown is excluded from prettier via
`.prettierignore`), so the check is that the reproduced types and the
attribution match source.

### Before

```
$ sed -n '45,48p' packages/lexical-website/docs/serialization/serialization.md
export type DOMExportOutput = {
  after?: (generatedElement: ?HTMLElement) => ?HTMLElement,
  element?: HTMLElement | null,
};

$ sed -n '138,141p' packages/lexical-website/docs/serialization/serialization.md
type DOMConversion = {
  conversion: DOMConversionFn;
  priority: 0 | 1 | 2 | 3 | 4;
};

$ grep -n "example of .exportJSON.\|example of .importJSON." packages/lexical-website/docs/serialization/serialization.md
409:Here's an example of `exportJSON` for the `HeadingNode`:
444:Here's an example of `importJSON` for the `HeadingNode`:

$ grep -n "^  exportJSON(\|^  static importJSON(\|^  updateFromJSON(" packages/lexical-rich-text/src/index.ts
352:  exportJSON(compact?: false): SerializedHeadingNode;
353:  exportJSON(compact: boolean): SerializedPartial<SerializedHeadingNode>;
354:  updateFromJSON(serializedNode: LexicalParseJSON<SerializedHeadingNode>): this;
```

Those three lines are declaration-merging overload signatures in an
`interface`, not implementations — `HeadingNode`'s class body has none.

### After

```
$ sed -n '45,51p' packages/lexical-website/docs/serialization/serialization.md
export interface DOMExportOutput {
  after?: (
    generatedElement: HTMLElement | DocumentFragment | Text | null | undefined,
  ) => HTMLElement | DocumentFragment | Text | null | undefined;
  element: HTMLElement | DocumentFragment | Text | null;
}

$ sed -n '141,144p' packages/lexical-website/docs/serialization/serialization.md
type DOMConversion = {
  conversion: DOMConversionFn;
  priority?: 0 | 1 | 2 | 3 | 4;
};

$ grep -n "no longer writes" packages/lexical-website/docs/serialization/serialization.md
412:(the shipped `HeadingNode` no longer writes this by hand — see the note below):
464:The shipped `HeadingNode` no longer writes any of these three methods by
```

Sources: `packages/lexical/src/LexicalNode.ts:885-900` (`DOMExportOutput`) and
`:854-857` (`DOMConversion`); `packages/lexical-rich-text/src/index.ts:341-347`
(`headingNodeSchema`) and `:400` (`json: headingNodeSchema` in `$config`).
@vercel

vercel Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lexical Ready Ready Preview Sep 24, 2026 4:48pm UTC
lexical-playground Ready Ready Preview Sep 24, 2026 4:48pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 24, 2026
@etrepum
etrepum added this pull request to the merge queue Sep 24, 2026
Merged via the queue into meta:main with commit 9d174a8 Sep 24, 2026
42 checks passed
@etrepum etrepum mentioned this pull request Sep 28, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 10ca9c95 Deployed Sep 24, 2026 by vercel[bot]
Preview – lexical-playground — 10ca9c95 Deployed Sep 24, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants