createEditorSystem
Type-safe editor system factory
The core factory function that creates a fully typed editor system based on your extensions. Provides compile-time safety and intelligent autocomplete for your editor components.
What It Does
createEditorSystem is the heart of LexKit's type system. It analyzes your extensions and generates a perfectly typed Provider component and useEditor hook.
Analyzes your extension array and extracts command types, state queries, and configuration options at compile time.
Creates a runtime system that manages extension registration, command aggregation, and state synchronization.
Provides intelligent autocomplete, compile-time error checking, and a clean API for building editor components.
Basic Usage
Get started with createEditorSystem in three simple steps.
Create a const array of extensions for type safety.
Define extensions array
Use createEditorSystem with your extensions to generate typed components.
Create typed editor system
Wrap your editor components with the Provider and use the hook.
Use the typed system
Type Safety Benefits
createEditorSystem provides compile-time guarantees about your editor's capabilities.
Only available commands and states are suggested
Configuration
Customize your editor system with configuration options.
| Prop | Type | Description |
|---|---|---|
| extensions | Extension[] | Required. Array of extensions to include in the editor. |
| config | EditorConfig | Optional. Configuration object with theme and other settings. |
| children | ReactNode | Required. Your editor components. |
Configure theme and other options
Advanced Usage
Take advantage of createEditorSystem's advanced features.
Create different editor systems for different use cases in the same app.
Different editors for different purposes
Access export/import utilities, state queries, and the raw editor instance.
Full access to editor capabilities
API Reference
Complete reference for the createEditorSystem API.
Provider<Exts>React component that provides editor context. Wraps your editor components.
extensions: ExtsRequired. Your extension array.
config?: EditorConfigOptional. Editor configuration.
commandsAll available commands from your extensions.
activeStatesCurrent state of all formatters and selections.
editorRaw Lexical editor instance for advanced use.
export / importUtilities for content serialization.
Best Practices
Tips for getting the most out of createEditorSystem.
Always use as const with your extension arrays to enable full type inference.
Create separate editor systems for different use cases rather than one system with all possible extensions.
Use typeof extensions when calling createEditorSystem to maintain type safety.
Build complex editors by composing simpler ones rather than configuring a single complex system.