Typix LogoTypix
Core

Editor Config

createEditorConfig API reference and configuration options

createEditorConfig creates a Lexical-compatible config object with sensible defaults.

Usage

import { createEditorConfig, defaultExtensionNodes, defaultTheme } from '@typix-editor/react';

const config = createEditorConfig({
  namespace: 'my-editor',
  theme: defaultTheme,
  extensionNodes: defaultExtensionNodes,
});

Pass the config to EditorRoot:

<EditorRoot config={config}>
  <EditorContent />
</EditorRoot>

Options

OptionTypeDefaultDescription
namespacestring"typix-editor"Unique namespace. Important when using multiple editors on the same page.
themeEditorThemeClassesundefinedCSS class mappings for editor elements. See Theming.
extensionNodesReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>[]Nodes to register with the editor.
editablebooleantrueWhether the editor starts in editable mode.
onError(error: Error, editor: LexicalEditor) => voidconsole.errorCustom error handler.
initialStateSerializedEditorStateundefinedInitial content as serialized JSON.
editorStateInitialEditorStateTypeundefinedDirect Lexical editor state (advanced).
htmlHTMLConfigundefinedHTML serialization configuration.

Return value

Returns a Lexical InitialConfigType object suitable for passing to LexicalComposer (or EditorRoot).

defaultExtensionNodes

A pre-configured array of all built-in Lexical nodes:

import { defaultExtensionNodes } from '@typix-editor/react';

Includes: HeadingNode, ParagraphNode, TextNode, QuoteNode, ListNode, ListItemNode, LinkNode, AutoLinkNode, CodeNode, CodeHighlightNode, HashtagNode, OverflowNode, TableNode, TableRowNode, TableCellNode.

Extending with custom nodes

import { defaultExtensionNodes, createEditorConfig } from '@typix-editor/react';
import { MentionNode } from '@typix-editor/extension-mention';

const config = createEditorConfig({
  extensionNodes: [...defaultExtensionNodes, MentionNode],
});

Without EditorRoot config

If you don't pass a config prop to EditorRoot, it automatically calls createEditorConfig with:

createEditorConfig({
  namespace: 'typix-editor',
  extensionNodes: defaultExtensionNodes,
  editable: true,
  editorState: null,
  initialState: content, // from the content prop
  theme: defaultTheme,
});

On this page