Skip to content

[lexical-website] Documentation Update: clone is synthesized for $config nodes, and fix a setSomeData typo - #9202

Merged
etrepum merged 1 commit into
meta:mainfrom
potatowagon:docs-node-cloning
Sep 23, 2026
Merged

etrepum merged 1 commit into
meta:mainfrom
potatowagon:docs-node-cloning

Conversation

@potatowagon

Copy link
Copy Markdown
Contributor

Description

Two corrections in concepts/node-cloning.md:

  1. The page opens by calling clone "a static method required by all Lexical
    nodes". It is not required of a node that declares $config(): Lexical
    synthesizes one when the class has no own static clone. nodes.mdx
    already lists static clone among the methods $config provides, so the
    two pages contradict each other today.
  2. The "Node Mutations" example defines setData and then calls
    node.setSomeData("new data"). Every other call on the page — seven of
    them — uses setData.

Test plan

Documentation-only change (markdown is excluded from prettier via
.prettierignore), so the check is that the claim matches the synthesis code
and the example calls the method it defines.

Before

$ sed -n '17p' packages/lexical-website/docs/concepts/node-cloning.md
The `clone` method is a static method required by all Lexical nodes that creates the next version of a node. However, it's important to understand that this is an **internal API** used by Lexical's state management system.

$ grep -n "setData\|setSomeData" packages/lexical-website/docs/concepts/node-cloning.md
39:     setData(data: string): this {
46:   node.setSomeData("new data");
90:  setData(data: string): this {
...

The example calls a method that its own class does not define, and the
"required by all nodes" claim contradicts nodes.mdx:341.

After

$ sed -n '17p' packages/lexical-website/docs/concepts/node-cloning.md
The `clone` method is a static method that creates the next version of a node. A node that declares [`$config()`](./nodes.mdx) has one synthesized for it and need not implement it — a hand-written `clone` is only required for a node that does not use `$config()`, or whose constructor has required arguments. Either way, it's important to understand that this is an **internal API** used by Lexical's state management system.

$ grep -n "setSomeData" packages/lexical-website/docs/concepts/node-cloning.md
$ sed -n '46p' packages/lexical-website/docs/concepts/node-cloning.md
   node.setData("new data");

The synthesis is at packages/lexical/src/LexicalUtils.ts:4956
(if (!hasOwnStaticMethod(klass, 'clone'))), and the required-arguments caveat
is the invariant at :4961-4969.

…fig nodes, and fix a setSomeData typo

## Description

Two corrections in `concepts/node-cloning.md`:

1. The page opens by calling `clone` "a static method required by all Lexical
   nodes". It is not required of a node that declares `$config()`: Lexical
   synthesizes one when the class has no own static `clone`. `nodes.mdx`
   already lists `static clone` among the methods `$config` provides, so the
   two pages contradict each other today.
2. The "Node Mutations" example defines `setData` and then calls
   `node.setSomeData("new data")`. Every other call on the page — seven of
   them — uses `setData`.

## Test plan

Documentation-only change (markdown is excluded from prettier via
`.prettierignore`), so the check is that the claim matches the synthesis code
and the example calls the method it defines.

### Before

```
$ sed -n '17p' packages/lexical-website/docs/concepts/node-cloning.md
The `clone` method is a static method required by all Lexical nodes that creates the next version of a node. However, it's important to understand that this is an **internal API** used by Lexical's state management system.

$ grep -n "setData\|setSomeData" packages/lexical-website/docs/concepts/node-cloning.md
39:     setData(data: string): this {
46:   node.setSomeData("new data");
90:  setData(data: string): this {
...
```

The example calls a method that its own class does not define, and the
"required by all nodes" claim contradicts `nodes.mdx:341`.

### After

```
$ sed -n '17p' packages/lexical-website/docs/concepts/node-cloning.md
The `clone` method is a static method that creates the next version of a node. A node that declares [`$config()`](./nodes.mdx) has one synthesized for it and need not implement it — a hand-written `clone` is only required for a node that does not use `$config()`, or whose constructor has required arguments. Either way, it's important to understand that this is an **internal API** used by Lexical's state management system.

$ grep -n "setSomeData" packages/lexical-website/docs/concepts/node-cloning.md
$ sed -n '46p' packages/lexical-website/docs/concepts/node-cloning.md
   node.setData("new data");
```

The synthesis is at `packages/lexical/src/LexicalUtils.ts:4956`
(`if (!hasOwnStaticMethod(klass, 'clone'))`), and the required-arguments caveat
is the `invariant` at `:4961-4969`.
@vercel

vercel Bot commented Sep 23, 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 23, 2026 6:33am UTC
lexical-playground Ready Ready Preview Sep 23, 2026 6:33am 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 23, 2026
@etrepum
etrepum added this pull request to the merge queue Sep 23, 2026
Merged via the queue into meta:main with commit 5cefa1c Sep 23, 2026
42 checks passed
@etrepum etrepum mentioned this pull request Sep 28, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 6c249163 Deployed Sep 23, 2026 by vercel[bot]
Preview – lexical-playground — 6c249163 Deployed Sep 23, 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