Repository navigation
[lexical-website] Documentation Update: correct four claims in the extension lifecycle guide - #9208
Merged
Conversation
…tension lifecycle guide
## Description
Four statements in `extensions/defining-extensions.md` do not match
`@lexical/extension`:
1. **`state.getInit()`** — no such method. The state object exposes
`getInitResult()`. (`state.getOutput()`, named in the same sentence, is
correct.)
2. **"The build phase happens just before the editor is constructed"** — it
runs *after* `createEditor`, which is why it receives a `LexicalEditor`.
The type's own doc comment says "Perform any tasks that require a
LexicalEditor instance, but before registration has taken place".
3. **"the graph between `peerDependencies` are not restricted. Loops are
allowed."** — peer edges are added to the same edge map as `dependencies`
and walked by the same topological sort, which asserts on cycles. Two
extensions that peer-depend on each other and are both present throw at
build time (repro below). This also contradicts `peer-dependencies.md`,
which states the DAG requirement.
4. The `PlainTextExtension` excerpt shows `dependencies: [DragonExtension]`;
it has three.
## Test plan
Documentation-only change (markdown is excluded from prettier via
`.prettierignore`), so the check is that each statement matches source. Claim 3
is the one that is not obvious by reading, so it is verified by running it.
### Before
```
$ grep -n "state.getInit()" packages/lexical-website/docs/extensions/defining-extensions.md
264:the result of `init` or `build` via `state.getInit()` and `state.getOutput()`
$ grep -n "getInitResult\|getOutput" packages/lexical/src/extension-core/types.ts
124: getInitResult: () => Init;
140: getOutput: () => Output;
$ grep -n "build phase happens" packages/lexical-website/docs/extensions/defining-extensions.md
222:The build phase happens just before the editor is constructed but after
$ grep -n "Loops are allowed" packages/lexical-website/docs/extensions/defining-extensions.md
134:are not restricted. Loops are allowed.
$ grep -n "dependencies: \[DragonExtension\]" packages/lexical-website/docs/extensions/defining-extensions.md
151: dependencies: [DragonExtension],
```
A scratch unit test building two extensions that peer-depend on each other,
both present in the editor — what the current text says is allowed:
```ts
const A = defineExtension({name: 'A', peerDependencies: [declarePeerDependency('B')]});
const B = defineExtension({name: 'B', peerDependencies: [declarePeerDependency('A')]});
buildEditorFromExtensions(defineExtension({dependencies: [A, B], name: '[root]'}));
```
```
$ npx vitest run packages/lexical-extension/src/__tests__/unit/ScratchPeerLoop.test.ts
ACTUAL ERROR: LexicalBuilder: Circular dependency detected for Extension A from B
```
(The scratch test was for this verification only and is not part of the diff.)
### After
```
$ grep -n "getInitResult()" packages/lexical-website/docs/extensions/defining-extensions.md
264:the result of `init` or `build` via `state.getInitResult()` and
$ sed -n '222,223p' packages/lexical-website/docs/extensions/defining-extensions.md
The build phase happens after the editor is constructed — it receives the
`LexicalEditor` — but before [register](#register), and after
$ sed -n '133,136p' packages/lexical-website/docs/extensions/defining-extensions.md
Since these are optional and by name, an extension may declare a peer it does
not import. The graph must still be acyclic: peer edges take part in the same
topological sort as `dependencies`, so two extensions that peer-depend on each
other and are both present will fail to build.
$ sed -n '151,155p' packages/lexical-website/docs/extensions/defining-extensions.md
dependencies: [
DragonExtension,
NormalizeInlineElementsExtension,
NormalizeTripleClickSelectionExtension,
],
```
Sources: `packages/lexical/src/extension-core/types.ts:124` and `:247-251`
(the `build` doc comment); `packages/lexical-extension/src/LexicalBuilder.ts:185-205`
(`createEditor(...)` then `extensionRep.build(editor)` per extension),
`:327` (peer edges via the same `addEdge`) and `:341-356` (the
"Circular dependency detected" invariant in the topological sort);
`packages/lexical-plain-text/src/index.ts:454-463`.
potatowagon
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7 and
zurfyx
as code owners
September 23, 2026 17:46
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
approved these changes
Sep 23, 2026
Merged
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.
Description
Four statements in
extensions/defining-extensions.mddo not match@lexical/extension:state.getInit()— no such method. The state object exposesgetInitResult(). (state.getOutput(), named in the same sentence, iscorrect.)
runs after
createEditor, which is why it receives aLexicalEditor.The type's own doc comment says "Perform any tasks that require a
LexicalEditor instance, but before registration has taken place".
peerDependenciesare not restricted. Loops areallowed." — peer edges are added to the same edge map as
dependenciesand walked by the same topological sort, which asserts on cycles. Two
extensions that peer-depend on each other and are both present throw at
build time (repro below). This also contradicts
peer-dependencies.md,which states the DAG requirement.
PlainTextExtensionexcerpt showsdependencies: [DragonExtension];it has three.
Test plan
Documentation-only change (markdown is excluded from prettier via
.prettierignore), so the check is that each statement matches source. Claim 3is the one that is not obvious by reading, so it is verified by running it.
Before
A scratch unit test building two extensions that peer-depend on each other,
both present in the editor — what the current text says is allowed:
(The scratch test was for this verification only and is not part of the diff.)
After
Sources:
packages/lexical/src/extension-core/types.ts:124and:247-251(the
builddoc comment);packages/lexical-extension/src/LexicalBuilder.ts:185-205(
createEditor(...)thenextensionRep.build(editor)per extension),:327(peer edges via the sameaddEdge) and:341-356(the"Circular dependency detected" invariant in the topological sort);
packages/lexical-plain-text/src/index.ts:454-463.