@@ -31,6 +31,7 @@ For E2E testing workflow:
3131
3232### Code Quality
3333- ` pnpm run lint ` - Run ESLint on all files
34+ - ` pnpm run lint:fix ` - Auto-fix lint issues
3435- ` pnpm run prettier ` - Check code formatting
3536- ` pnpm run prettier:fix ` - Auto-fix formatting issues
3637- ` pnpm run flow ` - Run Flow type checker
@@ -78,6 +79,7 @@ This is a monorepo with packages in `packages/`:
7879** Feature Packages** (extend core with nodes/commands/utilities):
7980- ` @lexical/rich-text ` - Rich text editing (headings, quotes, etc.)
8081- ` @lexical/plain-text ` - Plain text editing
82+ - ` @lexical/extension ` - Extend editor functionality
8183- ` @lexical/list ` - List nodes (ordered/unordered/checklist)
8284- ` @lexical/table ` - Table support
8385- ` @lexical/code ` - Code block with syntax highlighting
@@ -94,7 +96,38 @@ This is a monorepo with packages in `packages/`:
9496
9597### Key Architectural Patterns
9698
97- ** Plugin System (React)** - Plugins are React components that hook into the editor lifecycle:
99+ ** Extensions** - Extensions should be used to add features and configuration
100+ to an editor. The set of extensions in an editor must be determined when the
101+ editor is created with ` buildEditorFromExtensions ` . Extensions with
102+ functionality that can be toggled on or off typically have a ` disabled `
103+ configuration property and output signal that defaults to ` false ` . See the
104+ lexical-extension package and the supporting code in lexical for
105+ more examples and implementation details.
106+
107+ ``` tsx
108+ export interface MyConfig {
109+ disabled: boolean ;
110+ }
111+ export const MyExtension = defineExtension ({
112+ build : (_editor , config , _state ) => namedSignals (config ),
113+ config: safeCast <MyConfig >({ disabled: false }),
114+ name: ' @lexical/docs/My' ,
115+ nodes : () => [MyNode ],
116+ register : (editor , _config , state ) => {
117+ const {disabled} = state .getOutput ();
118+ return effect (() => {
119+ if (! disabled .value ) {
120+ return editor .registerUpdateListener (({editorState }) => {
121+ // React to updates
122+ });
123+ }
124+ })
125+ },
126+ })
127+ ```
128+
129+ ** Plugin System (React)** - Plugins are a legacy pattern for React components
130+ to hook into the editor lifecycle, extensions should be preferred for new code:
98131``` jsx
99132function MyPlugin () {
100133 const [editor ] = useLexicalComposerContext ();
@@ -149,10 +182,9 @@ Always access node properties/methods within read/update context. Nodes automati
149182### Custom Nodes
150183When creating custom nodes:
1511841 . Extend a base node class (TextNode, ElementNode, DecoratorNode)
152- 2 . Implement required static methods: ` getType() ` , ` clone() ` , ` importJSON() `
153- 3 . Implement instance methods: ` createDOM() ` , ` updateDOM() ` , ` exportJSON() `
154- 4 . Register with editor config: ` nodes: [YourCustomNode] `
155- 5 . Export a ` $createYourNode() ` factory function (follows $ convention)
185+ 2 . Implement instance methods: ` $config() ` , ` createDOM() ` , ` updateDOM() `
186+ 3 . Register with extension or editor config: ` nodes: [YourCustomNode] `
187+ 4 . Export a ` $createYourNode() ` factory function (follows $ convention)
156188
157189### Build System
158190- Uses Rollup for bundling
0 commit comments