Skip to main content

Crate lexical_ui

Crate lexical_ui 

Source
Expand description

A Rust port of Lexical’s model and headless packages, at parity with the JS implementation: the same documents give the same editor state and the same JSON, byte for byte, in the legacy and compact forms. Parity is checked against the conformance vectors that packages/lexical-conformance records from the JS packages (see rust/PARITY.md).

The internals mirror the upstream sources file by file. JS’s $ functions drop the $ and take snake case: $getRoot() is get_root(), and like JS they only work inside Editor::update, Editor::read or EditorState::read. A node is read and changed through a NodeRef, which resolves the latest version on every call, as JS node methods do. Text offsets are UTF-16 code units, as in JS.

use lexical_ui::{create_editor, get_root, CreateEditorArgs, UpdateOptions};

let editor = create_editor(CreateEditorArgs::default());
let state = editor
    .parse_editor_state(r#"{"root":{"type":"root","children":[{"type":"paragraph","children":[{"type":"text","text":"Hi"}]}]}}"#)
    .unwrap();
assert_eq!(state.read(|| get_root().get_text_content()), "Hi");
assert_eq!(
    state.to_json(true).to_string(),
    r#"{"root":{"type":"root","children":[{"type":"paragraph","children":[{"type":"text","text":"Hi"}]}]}}"#,
);

// An update: split the text and bold the second half.
editor.set_editor_state(&state, None).unwrap();
editor
    .update(
        || {
            let text = get_root().get_first_descendant().unwrap();
            let parts = text.split_text(&[1])?;
            parts[1].toggle_format("bold");
            Ok(())
        },
        UpdateOptions { discrete: true, ..UpdateOptions::default() },
    )
    .unwrap();
assert_eq!(
    editor.get_editor_state().to_json(true).to_string(),
    r#"{"root":{"type":"root","children":[{"type":"paragraph","children":[{"type":"text","text":"H"},{"type":"text","format":1,"text":"i"}]}]}}"#,
);

Re-exports§

pub use headless::create_headless_editor;
pub use nodes::element::Direction;
pub use nodes::element::ElementData;
pub use nodes::paragraph::create_paragraph_node;
pub use nodes::text::TextData;
pub use nodes::text::create_text_node;
pub use nodes::text::toggle_text_format_type;

Modules§

a11y
@lexical/a11y’s announcements (the a11y feature), from packages/lexical-a11y/src/index.ts: the live region an editor announces through (LiveRegion, shown by the app’s LiveRegionHost), AriaLiveRegionExtension, whose output’s announce the other announcers write to, HistoryAnnounceExtension and EditorModeAnnounceExtension. With rich-text, @lexical/rich-text’s HeadingAnnounceExtension is heading_announce_extension, and with link, @lexical/link’s AutoLinkAnnounceExtension is auto_link_announce_extension.
auto_embed
@lexical/react’s auto-embed without React (the auto-embed feature): LexicalAutoEmbedPluginUtils.ts (EmbedMatchResult, EmbedConfig, URL_MATCHER, INSERT_EMBED_COMMAND, AutoEmbedOption) and the logic of LexicalAutoEmbedPlugin.tsx (register_auto_embed): a pasted link that an embed config recognizes (a video, a post) opens a node menu at it that offers to replace it with the embed. React keeps the match in component state and renders LexicalNodeMenuPlugin; here register_auto_embed keeps it and drives a NodeMenu, which the app’s view draws.
clipboard
@lexical/clipboard (the clipboard feature): the model half of packages/lexical-clipboard/src/clipboard.ts, with the default import stack of ClipboardImportExtension.ts that $insertDataTransferForRichText runs.
code
@lexical/code-core (the code feature), from packages/lexical-code-core/src: CodeNode and CodeHighlightNode with their generated JSON (LexicalCodeCoreGeneratedJSON.ts), $exitCodeNodeOnEnter (CodeNode.ts), the line functions of FlatStructureUtils.ts, CodeExtension’s transform (register_code) and registerCodeIndentation’s command handlers, Tab, the arrow keys (escapeWithArrows), MOVE_TO_START and MOVE_TO_END among them (register_code_indentation); with the extension feature, CodeExtension and CodeIndentExtension (code_extension, code_indent_extension).
constants
LexicalConstants.ts: the flags and the tables between their serialized names and stored values. The DOM and platform constants come with the packages that use them.
decorator_block
@lexical/react’s DecoratorBlockNode (the decorator-block feature), from packages/lexical-react/src/LexicalDecoratorBlockNode.ts: the base of block embeds (videos, tweets), a block decorator that keeps an element alignment (format) and is not indentable.
devtools
@lexical/devtools-core (the devtools feature), from packages/lexical-devtools-core/src: generate_content, the text of the playground’s tree view of an editor’s state, its selection and the editor’s settings. Its React parts (TreeView.tsx, useLexicalCommandsLog.ts) aren’t ported; a log of commands is the caller’s to keep (LexicalCommandLogEntry).
dom
A small DOM (the html feature): what a browser, or jsdom in upstream’s unit tests, gives Lexical’s createDOM, exportDOM and HTML import and export. Nothing renders it; it exists so that HTML export and import run the same node methods as JS and write the same bytes, as the Swift port’s DOMDocument does (swift/DESIGN.md, “The DOM is a small model of jsdom’s”).
extension
@lexical/extension’s decorators (the extension feature), from packages/lexical-extension/src: HorizontalRuleNode, a block decorator (HorizontalRuleExtension.ts), and DecoratorTextNode, an inline one that carries a text format (DecoratorTextExtension.ts), with their $create/$is functions. Neither has a schema of its own, so their JSON is LexicalNode’s, with DecoratorTextNode’s format as a flat NodeState.
file
@lexical/file (the file feature), from packages/lexical-file/src: the .lexical document format (serialized_document_from_editor_state, editor_state_from_serialized_document) and importing and exporting files (import_file, export_file), where the app picks and saves the file, as upstream’s DOM file input and download link do.
hashtag
@lexical/hashtag (the hashtag feature), from packages/lexical-hashtag/src: HashtagNode, the text entity a #hashtag becomes, $createHashtagNode, $isHashtagNode, the default matcher (get_hashtag_match) and register_lexical_hashtag, which makes hashtags of the text it matches with register_lexical_text_entity. Its JSON is TextNode’s.
headless
@lexical/headless (packages/lexical-headless/src): an editor for use without a view, such as on a server, which refuses a root element.
history
@lexical/history (packages/lexical-history/src/index.ts): undo and redo. register_history records the editor’s states on an undo stack, merging an update into the entry before it when it continues the same kind of change (typing, deleting) within a delay, and handles UNDO_COMMAND, REDO_COMMAND, CLEAR_HISTORY_COMMAND and CLEAR_EDITOR_COMMAND, dispatching CAN_UNDO_COMMAND and CAN_REDO_COMMAND as the stacks fill and empty.
html
@lexical/html (the html feature): HTML from an editor state (generate_html_from_nodes) and Lexical nodes from a DOM (generate_nodes_from_dom), through the nodes’ exportDOM and importDOM and the editor’s html config. The DOM is crate::dom; parse HTML into it with crate::dom::parse_from_string.
json
JSON as JS reads and writes it: JSON.parse, JSON.stringify with JS’s property order and number formatting, and undefined. Lexical’s serialized documents must be byte-identical to what JS writes, which serde_json doesn’t promise (key order, 1e+21, -0), and the crate has no third-party dependencies (rust/DESIGN.md).
lexical_dom
The DOM side of the core (the html feature): what createDOM, exportDOM and importDOM exchange (DOMExportOutput, DOMConversionMap and the rest, LexicalNode.ts and LexicalEditor.ts), the editor’s default render config (DEFAULT_EDITOR_DOM_CONFIG), the import conversion cache (initializeConversionCache), and the DOM helpers of LexicalUtils.ts, utils/classNames.ts and nodes/LexicalLineBreakNode.ts that nodes and @lexical/html use. The DOM is crate::dom.
link
@lexical/link (the link feature), from packages/lexical-link/src: LinkNode and AutoLinkNode with their generated JSON (LexicalLinkGeneratedJSON.ts), $linkNodeTransform, $toggleLink, TOGGLE_LINK_COMMAND and formatUrl (LexicalLinkNode.ts), and registerLink’s transform and command handlers, with the paste of a URL validateUrl accepts (LexicalLinkExtension.ts); with the autolink feature, registerAutoLink and its matchers (LexicalAutoLinkExtension.ts), whose regular expressions need the regex crate.
list
@lexical/list (the list feature), from packages/lexical-list/src: ListNode and ListItemNode with their generated JSON (LexicalListGeneratedJSON.ts), the model functions of formatList.ts and utils.ts, registerList’s command handlers (Backspace at an item’s start among them) and transforms (register_list), and the model part of registerCheckList (register_check_list).
mark
@lexical/mark (the mark feature), from packages/lexical-mark/src: MarkNode with its generated JSON (MarkNode.ts, LexicalMarkGeneratedJSON.ts), $wrapSelectionInMarkNode, $unwrapMarkNode, $getMarkIDs and MarkExtension (index.ts), and MarkStateExtension.ts, which keeps mark ids as a NodeState of the leaves they cover instead of wrapping them ($addMarkID, $removeMarkID, $getNodeMarkIDs, $getMarkIDsAtSelection, $migrateMarkNodesToMarkState; with the extension feature the mark flavors, their extensions and the inserted-text rule).
markdown
@lexical/markdown (the markdown feature), from packages/lexical-markdown/src: markdown import ($convertFromMarkdownString), export ($convertToMarkdownString, $convertSelectionToMarkdownString), the transformers (MarkdownTransformers.ts) and the markdown shortcuts (registerMarkdownShortcuts).
menu
The typeahead and node menus of @lexical/react without their views (the menu feature): LexicalTypeaheadMenuPluginUtils.ts (PUNCTUATION, basic_typeahead_trigger_match), LexicalMenuOption.ts (MenuOption), and the platform-neutral parts of shared/LexicalMenu.tsx (MenuTextMatch, MenuResolution, get_full_match_offset, split_node_containing_query, the menu’s state and option selection, MenuState), LexicalTypeaheadMenuPlugin.tsx (get_text_up_to_anchor, is_selection_on_entity_boundary, register_typeahead_menu) and LexicalNodeMenuPlugin.tsx (NodeMenu).
nodes
nodes/: the core nodes every editor registers.
overflow
@lexical/overflow (the overflow feature), from packages/lexical-overflow/src/index.ts: OverflowNode, the element @lexical/react’s character limit wraps the text past the limit in, $createOverflowNode and $isOverflowNode. It has no schema of its own, so its JSON is ElementNode’s.
plain_text
@lexical/plain-text (the plain-text feature): registerPlainText’s command handlers that act on the model, from packages/lexical-plain-text/src/index.ts.
rich_text
@lexical/rich-text (the rich-text feature): HeadingNode and QuoteNode, from packages/lexical-rich-text/src/index.ts, with their generated JSON (LexicalRichTextGeneratedJSON.ts).
schema
LexicalSchema.ts: serialization schemas. A SerializationSchema parses an untrusted JSON value into its domain (substituting its default for anything outside it), knows that default, and describes its domain (SerializationSchemaMeta). A node class declares the properties of its JSON as a NodeSchema (nodeSchema) of SchemaFields (withField, withAccessors), which drives its exportJSON in both forms and its updateFromJSON (LexicalUtils.ts’ compiled schema, walk_export_json and walk_update_from_json); a NodeState can be parsed by one (createState(key, {parse: schema}), StateValueConfig::from_schema).
selection
@lexical/selection (the selection feature): what index.ts exports from lexical-node.ts, range-selection.ts and the model part of utils.ts, and what it re-exports from lexical (deprecated upstream).
table
@lexical/table (the table feature), from packages/lexical-table/src: TableNode, TableRowNode and TableCellNode with their generated JSON, TableSelection, the table map utilities of LexicalTableUtils.ts, INSERT_TABLE_COMMAND, and the model parts of the table handlers.
text
@lexical/text (the text feature), from packages/lexical-text/src: register_lexical_text_entity, the transforms that make text entities (such as hashtags) of the text a matcher finds, and turn them back into text when an edit leaves them no match; and the root helpers (root_text_content, is_root_text_content_empty, can_show_placeholder, find_text_intersection_from_characters).
utf16
Text offsets in UTF-16 code units, as JS strings count them, over Rust’s UTF-8 strings. A slice that splits a surrogate pair gives U+FFFD for the half it keeps, the Tier 1 exception for unpaired surrogates (rust/PARITY.md); it is still one unit long, so lengths and offsets agree with JS.
utils
@lexical/utils (the utils feature): the model part of packages/lexical-utils/src/index.ts, and what it re-exports from lexical.

Structs§

AbortController
AbortController: what aborts an AbortSignal.
AbortSignal
AbortSignal, as the builder hands it to register: aborted once, when the editor is disposed. Cloning it shares the signal.
AnyLexicalExtensionArgument
AnyLexicalExtensionArgument: an extension, alone or with config overrides (NormalizedLexicalExtensionArgument, which config_extension makes). Every extension converts into one.
AnyStateConfig
AnyStateConfig: a StateConfig of any value type.
CaretRange
CaretRange: a range selection as a pair of carets in one direction.
ClipboardEvent
A DOM ClipboardEvent: a copy, cut or paste, with its data.
CompiledKeyboardShortcuts
CompiledKeyboardShortcuts (@experimental @internal): a shortcut table indexed by the event’s modifier bits and key (and, for non-Latin layouts, its code), so a look-up costs the same however many shortcuts it holds.
CompositionEvent
A DOM CompositionEvent: an input method composition starts or ends.
CreateEditorArgs
CreateEditorArgs: the node classes (and LexicalNodeReplacements, as NodeClasses) to register besides the core ones, the editor’s namespace (when empty, its parent editor’s, or a random one, createUID()), the initial state, whether it is editable, the theme, the parent editor, onWarn, and (with the html feature) the HTML import and export overrides and the render config. JS’s onError has no counterpart: an update’s error is returned from Editor::update.
DataTransfer
DataTransfer: the data of a clipboard or drag operation, by format (a MIME type), in the order each format was first set, and its files.
DataTransferFile
One file of a DataTransfer, as a web File: its name, type and size are known up front, and its contents are read only when bytes asks for them, as File.bytes() reads a lazy Blob.
DeclaredBy
The class each key of a DeclaredNodeStructure came from, by type.
DeclaredNodeStructure
DeclaredNodeStructure (@experimental node-structure): the structural facts a class declares, each from the nearest class in its config chain that declares it, and the values it declares derived. Keys no class declares are None; a mergeAdjacent: false declaration reads as None too.
Decorators
editor._decorators (Record<NodeKey, unknown>): what each decorator the reconciler rendered returned from decorate, by key, in the order JS’s object lists its keys (Object.entries): array-index keys ascending, which every generated key is, then the others in insertion order. A value is the app’s Rc<dyn Any>, compared by identity (Rc::ptr_eq) as JS compares the object a decorate returns (===).
DragEvent
A DOM DragEvent: a drag or a drop, with its data.
Editor
A Lexical editor. A handle; cloning it shares the same editor. Without a DOM it is what JS calls a headless editor. It is neither Send nor Sync.
EditorConfig
EditorConfig (editor._config): what createDOM reads.
EditorState
An editor state: the node map and the selection. A handle; cloning it shares the same state. Once read-only (committed or parsed), nothing changes it: an update works on a clone whose node map shares the nodes, and a node is copied before its first change (getWritable).
Event
The Event fields handlers use. Every event below holds one and dereferences to it, as the DOM’s event interfaces inherit from Event. Events are shared (Rc), so a handler’s prevent_default() is seen by the code that dispatched the event.
ExtensionBuildState
ExtensionBuildState: what build can ask of the builder; its dependencies are built before it.
ExtensionInitState
ExtensionInitState: what init can ask of the builder about other extensions, whose configs are merged before it runs.
ExtensionRegisterState
ExtensionRegisterState: what register and afterRegistration can ask of the builder.
FocusEvent
A DOM FocusEvent (focus, blur).
InitialEditorConfig
InitialEditorConfig: the editor configuration an extension contributes, and what init may change. Of JS’s fields, the ones the port has: namespace, the node classes and replacements, $initialEditorState, theme, parentEditor, editable, onWarn, and (with the html feature) html and dom. disableEvents has no counterpart (the app dispatches the events it has), nor has onError (an update’s error is returned from Editor::update).
InputEvent
A DOM InputEvent: a beforeinput or input.
InsertClipboardNodesPayload
SELECTION_INSERT_CLIPBOARD_NODES_COMMAND’s payload: the nodes a paste made and the selection to insert them at.
KeyboardEvent
A DOM KeyboardEvent, with the DOM’s key and code values ("Enter", "b", "KeyB", "ArrowLeft"…).
KeyboardEventModifierMask
KeyboardEventModifierMask (with KeyboardEventControlOrOther): the expected state of each modifier; none pressed by default.
KeyboardShortcut
KeyboardShortcut (@experimental): a shortcut as data, the key and modifiers to match and the command to dispatch with the matched event. @lexical/extension’s KeyboardShortcutsExtension (keyboard_shortcuts_extension, the extension feature) dispatches a table of them.
LexicalCommand
A command (createCommand), compared by identity: two commands made with the same name are different commands.
LexicalError
A JS invariant failure (or another error JS throws), carrying the same message. Invariants that only a bug in a node implementation can break panic instead, as RefCell does; the ones a document can break return this.
LexicalExtension
LexicalExtension: a composable, named unit of editor configuration (nodes, the initial state) and of behavior registered once the editor exists. Write one with struct update syntax over LexicalExtension::new, and make it with define_extension.
LexicalExtensionDependency
LexicalExtensionDependency: a built extension’s merged config, its init result and its output (None without init or build, JS’s undefined).
LexicalNodeReplacement
LexicalNodeReplacement: an entry of CreateEditorArgs::nodes (as a NodeClass, through From) that makes $create and the $create* functions of the replace class give what with makes of their node. with_klass, the class with makes (which must extend replace and be registered too), lets transforms and mutation listeners registered for replace reach its nodes.
LexicalWarning
LexicalWarning: a warning with a stable code, passed to the editor’s onWarn (as the LexicalError LexicalError::from_warning makes, whose warning it is) by packages that report recoverable, warn-level conditions. The code is namespaced by the package that reports it ("@example/pkg/some-condition"); a match over codes needs a default arm, since packages may add codes in any release.
MergeAdjacentConfig
MergeAdjacentConfig (@experimental node-structure).
MouseEvent
A DOM MouseEvent (and the PointerEvent fields Lexical reads), with the node the app hit in place of the DOM target.
MutationListenerOptions
MutationListenerOptions.
MutationListenerPayload
A mutation listener’s second argument (MutationListener’s {dirtyLeaves, prevEditorState, updateTags}).
NodeBase
The fields every node has: its key, its links to its parent and siblings (__key, __parent, __prev, __next) and its NodeState (__state), which a clone shares until one of them writes it; and, used by elements and decorators only, the slot fields JS’s ElementNode and DecoratorNode add (__slotHost, __slots). A clone keeps them, as their afterCloneFrom does for the same key; $copyNode drops them.
NodeClass
A node class an editor registers: its type and how it imports JSON (the static importJSON). As an editor’s registration (RegisteredNode) it also holds the class’s node replacement, if any: what LexicalNodeReplacement makes of the class.
NodeClassRef
A node class that a children list names: its type, and how to make a node of it ($create(klass), for the wrapper a list of classes wraps a stray child in).
NodeConfigLink
One class of a config chain (iterStaticNodeConfigChain’s {klass, ownNodeType, ownNodeConfig}).
NodeRef
A node by its key, resolved in the active editor state on every call, so it always reads the latest version, as JS node methods do through getLatest(). Like a JS node reference, it can only be used inside Editor::read or EditorState::read, and panics elsewhere.
NodeSelection
NodeSelection’s fields: the selected keys, in the order added.
NormalizedPeerDependency
NormalizedPeerDependency: [name, config?], from declare_peer_dependency.
Point
PointType: a node key, an offset and a type.
PointCaret
PointCaret: a NodeCaret or a TextPointCaret.
RangeSelection
RangeSelection’s fields.
RefCountedRegistry
RefCountedRegistry<Key, Options>: the first registration of a key runs the activation; what it returned runs once the last registration of that key is released. A handle; cloning it shares the registry.
RequiredNodeStateConfig
RequiredNodeStateConfig: a state a node class declares in its $config’s stateConfigs (LexicalNode::state_configs), which its type knows before any node reads it; a flat one serializes at the top level of the node’s JSON instead of under "$".
RootElementRef
A root element, compared by identity.
SelectionRef
A selection object, shared as JS shares it: $getSelection() returns the one the editor state holds, so a change through it is a change of the state’s selection; clone_selection makes a separate one.
SplitAtPointCaretNextOptions
SplitAtPointCaretNextOptions. $copyElementNode and $splitTextPointCaretNext are always their defaults ($copyNode and split_text_point_caret).
StateConfig
StateConfig: what create_state returns, for get_state and set_state. Clones are the same config: nodes tell configs apart by identity, as JS does.
StateValueConfig
StateValueConfig: how a state’s value parses from JSON (parse, which gives the default for undefined), writes back (unparse) and compares (isEqual), whether $copyNode resets it (resetOnCopyNode), whether the node’s own code recomputes it (derived, @experimental), and the schema parse was given as (StateConfig.schema), when it was one.
StaticNodeConfig
The node-structure keys of one class’s own $config() (StaticNodeConfigValue’s inline, children and mergeAdjacent). What it declares derived comes from its schema (LexicalNode::json_schema_chain) and its NodeState (LexicalNode::state_configs).
StyleObject
A Record<string, string> of CSS properties, as get_style_object_from_css returns it: keys in JS’s property order (array indices first, ascending, then the rest in the order they were first set), so iterating it writes CSS in the order JS does.
TextPointCaretSlice
TextPointCaretSlice: a text point caret and a signed distance from its offset. A negative distance selects the text before the offset, a positive one the text after it, whatever the caret’s direction.
UpdateListenerPayload
What an update listener receives (UpdateListenerPayload). The dirty nodes are in the order they were marked; each dirty element says whether it was marked itself (true) or only because a descendant was.
UpdateOptions
EditorUpdateOptions. event comes with its users.

Enums§

CaretDirection
CaretDirection: 'next' points towards the end of the document, 'previous' towards the beginning.
CaretKind
A caret’s JS type, with the offset a text point caret carries.
ClipboardOrKeyboardEvent
ClipboardEvent | KeyboardEvent, the payload of COPY_COMMAND and CUT_COMMAND (or None, JS’s null).
CommonAncestorAcrossSlotsResult
CommonAncestorAcrossSlotsResult (@experimental): like CommonAncestorResult, except that the common ancestor may be a decorator slot host, and the node on either side below it may be one of its slot values rather than a child.
CommonAncestorResult
CommonAncestorResult: how two nodes relate through their common ancestor.
ControlOrOther
KeyboardEventControlOrOther’s CONTROL_OR_OTHER_KEY: the modifier that stands in for Control on the other platform.
EditorFocusOptions
EditorFocusOptions.
EditorReadMode
EditorReadMode: which state Editor::read_with_mode reads.
InitialEditorStateType
InitialEditorStateType: how InitialStateExtension fills a new editor.
MergeAdjacentDeclaration
A class’s own mergeAdjacent declaration: Off is JS’s false, which turns off a declaration an ancestor made.
MergeAdjacentEntry
One value mergeAdjacent.by names: a schema field of the class (a property of its JSON), or a NodeState.
ModifierExpectation
The expected state of one modifier in a KeyboardEventModifierMask: JS’s true, false (or omitted) and 'any'.
NodeChildEntry
One entry of a children list: 'inline', or a class (which allows its subclasses).
NodeChildrenConfig
NodeChildrenConfig (@experimental node-structure): what an element may hold. Inline is a paragraph’s content, Block a table cell’s, and List only the listed entries.
NodeMutation
NodeMutation: what the reconciler did with a node in a commit.
PasteCommandType
PasteCommandType: ClipboardEvent | InputEvent | KeyboardEvent, the payload of PASTE_COMMAND.
PointType
A point’s type: inside a text node (an offset in UTF-16 code units) or between an element’s children (a child index).
RootMode
RootMode: whether a traversal up the tree stops at the root only ('root'), or at the root and any shadow root ('shadowRoot').
Selection
A selection’s value.
SelectionAlter
'move' or 'extend'.
SelectionGranularity
'character', 'word', 'line' or 'lineboundary'.
SliceMode
The sliceMode of remove_text_from_caret_range.
TextOffset
An offset into a text node: a number of UTF-16 code units, or the end in a direction ('next' is the end, 'previous' the start), as JS’s number | CaretDirection.
Which
Which point of a range selection.

Constants§

BEFORE_INPUT_COMMAND
BEFORE_INPUT_COMMAND: dispatched on a beforeinput event; the core’s handler ($handleBeforeInput) turns it into the command it stands for.
BLUR_COMMAND
BLUR_COMMAND: dispatched when the editor loses the focus.
CAN_REDO_COMMAND
CAN_REDO_COMMAND: dispatched when whether redo is possible changes; the payload is whether it is. JS deprecates it (v0.49.0) for HistoryExtension’s canRedo signal (HistoryExtensionOutput::can_redo).
CAN_UNDO_COMMAND
CAN_UNDO_COMMAND: dispatched when whether undo is possible changes; the payload is whether it is. JS deprecates it (v0.49.0) for HistoryExtension’s canUndo signal (HistoryExtensionOutput::can_undo).
CLEAR_EDITOR_COMMAND
CLEAR_EDITOR_COMMAND: dispatched to clear all editor content.
CLEAR_HISTORY_COMMAND
CLEAR_HISTORY_COMMAND: dispatched to clear the undo and redo stacks.
CLICK_COMMAND
CLICK_COMMAND: dispatched on a click in the editor.
COLLABORATION_TAG
COLLABORATION_TAG (LexicalUpdateTags.ts): the update applies changes that came from another replica.
COMMAND_PRIORITY_BEFORE_CRITICAL
COMMAND_PRIORITY_BEFORE_CRITICAL: the beginning of the critical priority queue.
COMMAND_PRIORITY_BEFORE_EDITOR
COMMAND_PRIORITY_BEFORE_EDITOR: the beginning of the editor priority queue.
COMMAND_PRIORITY_BEFORE_HIGH
COMMAND_PRIORITY_BEFORE_HIGH: the beginning of the high priority queue.
COMMAND_PRIORITY_BEFORE_LOW
COMMAND_PRIORITY_BEFORE_LOW: the beginning of the low priority queue.
COMMAND_PRIORITY_BEFORE_NORMAL
COMMAND_PRIORITY_BEFORE_NORMAL: the beginning of the normal priority queue.
COMMAND_PRIORITY_CRITICAL
COMMAND_PRIORITY_CRITICAL: the end of the critical priority queue.
COMMAND_PRIORITY_EDITOR
COMMAND_PRIORITY_EDITOR: a listener added to the end of the editor priority queue (after critical, high, normal, low).
COMMAND_PRIORITY_HIGH
COMMAND_PRIORITY_HIGH: the end of the high priority queue.
COMMAND_PRIORITY_LOW
COMMAND_PRIORITY_LOW: the end of the low priority queue.
COMMAND_PRIORITY_NORMAL
COMMAND_PRIORITY_NORMAL: the end of the normal priority queue.
COMPOSITION_END_COMMAND
COMPOSITION_END_COMMAND: dispatched when an input method composition ends.
COMPOSITION_END_TAG
COMPOSITION_END_TAG (LexicalUpdateTags.ts): the update ends an input method composition.
COMPOSITION_START_COMMAND
COMPOSITION_START_COMMAND: dispatched when an input method composition starts.
COMPOSITION_START_TAG
COMPOSITION_START_TAG (LexicalUpdateTags.ts): the update starts an input method composition.
CONTROLLED_TEXT_INSERTION_COMMAND
CONTROLLED_TEXT_INSERTION_COMMAND: dispatched to insert text. JS also takes the beforeinput event; without a DOM only the string form is here.
COPY_COMMAND
COPY_COMMAND: dispatched on a copy, with the ClipboardEvent, the KeyboardEvent (⌘C on macOS, Ctrl+C elsewhere), or None (JS null).
CUT_COMMAND
CUT_COMMAND: dispatched on a cut; the payload is as COPY_COMMAND’s.
CUT_TAG
CUT_TAG (LexicalUpdateTags.ts): the update is a cut.
DEFER_COMPOSITION_MERGE_TAG
DEFER_COMPOSITION_MERGE_TAG (LexicalUpdateTags.ts): the update must not merge text into or out of the node being composed.
DELETE_CHARACTER_COMMAND
DELETE_CHARACTER_COMMAND: dispatched to delete a character; the payload is true for a backward deletion (Backspace) and false for a forward one (Delete).
DELETE_LINE_COMMAND
DELETE_LINE_COMMAND: dispatched to delete a line; the payload is true for a backward deletion (Cmd+Delete on macOS).
DELETE_WORD_COMMAND
DELETE_WORD_COMMAND: dispatched to delete a word; the payload is true for a backward deletion (Opt+Delete on macOS).
DRAGEND_COMMAND
DRAGEND_COMMAND: dispatched when a drag ends.
DRAGOVER_COMMAND
DRAGOVER_COMMAND: dispatched when a drag is over the editor.
DRAGSTART_COMMAND
DRAGSTART_COMMAND: dispatched when a drag starts.
DROP_COMMAND
DROP_COMMAND: dispatched on a drop.
FOCUS_COMMAND
FOCUS_COMMAND: dispatched when the editor gets the focus.
FOCUS_TAG
FOCUS_TAG (LexicalUpdateTags.ts): the update is Editor::focus’s.
FORMAT_ELEMENT_COMMAND
FORMAT_ELEMENT_COMMAND: dispatched to set the alignment ("left", "center", …) of the selected blocks.
FORMAT_TEXT_COMMAND
FORMAT_TEXT_COMMAND: dispatched to toggle a text format ("bold", "italic", …) on the selection.
HISTORIC_TAG
HISTORIC_TAG (LexicalUpdateTags.ts): the update applies a state from the undo or redo stack.
HISTORY_MERGE_TAG
HISTORY_MERGE_TAG (LexicalUpdateTags.ts): the update joins the previous history entry.
HISTORY_PUSH_TAG
HISTORY_PUSH_TAG (LexicalUpdateTags.ts): the update starts a new history entry.
INDENT_CONTENT_COMMAND
INDENT_CONTENT_COMMAND: dispatched to indent the selected content.
INPUT_COMMAND
INPUT_COMMAND: dispatched on an input event.
INSERT_LINE_BREAK_COMMAND
INSERT_LINE_BREAK_COMMAND: dispatched to insert a line break. With false the caret moves to the new line (Shift+Enter); with true it stays (Ctrl+O on macOS).
INSERT_PARAGRAPH_COMMAND
INSERT_PARAGRAPH_COMMAND: dispatched to insert a new paragraph (Enter).
INSERT_TAB_COMMAND
INSERT_TAB_COMMAND: dispatched to insert a tab.
KEY_ARROW_DOWN_COMMAND
KEY_ARROW_DOWN_COMMAND: dispatched when ArrowDown is pressed; Shift and Alt may be down.
KEY_ARROW_LEFT_COMMAND
KEY_ARROW_LEFT_COMMAND: dispatched when ArrowLeft is pressed; Shift may be down.
KEY_ARROW_RIGHT_COMMAND
KEY_ARROW_RIGHT_COMMAND: dispatched when ArrowRight is pressed; Shift may be down.
KEY_ARROW_UP_COMMAND
KEY_ARROW_UP_COMMAND: dispatched when ArrowUp is pressed; Shift and Alt may be down.
KEY_BACKSPACE_COMMAND
KEY_BACKSPACE_COMMAND: dispatched when Backspace is pressed; Shift may be down.
KEY_DELETE_COMMAND
KEY_DELETE_COMMAND: dispatched when Delete is pressed (Fn+Delete on macOS), with no modifiers.
KEY_DOWN_COMMAND
KEY_DOWN_COMMAND (named KEYDOWN_COMMAND, as in JS): dispatched when any key is pressed; the core’s handler ($handleKeyDown) dispatches the command the key stands for.
KEY_ENTER_COMMAND
KEY_ENTER_COMMAND: dispatched when Enter is pressed, with the key event, or None (JS null) when the intent is to insert a newline without one. Rich and plain text’s handlers turn it into INSERT_PARAGRAPH_COMMAND or INSERT_LINE_BREAK_COMMAND.
KEY_ESCAPE_COMMAND
KEY_ESCAPE_COMMAND: dispatched when Escape is pressed, with any modifiers.
KEY_MODIFIER_COMMAND
KEY_MODIFIER_COMMAND: dispatched after any key pressed with a modifier. JS deprecates it (v0.31.0) for KEY_DOWN_COMMAND, checking the modifiers.
KEY_SPACE_COMMAND
KEY_SPACE_COMMAND: dispatched when the space key is pressed, with any modifiers.
KEY_TAB_COMMAND
KEY_TAB_COMMAND: dispatched when Tab is pressed; Shift may be down.
MOVE_TO_END
MOVE_TO_END: dispatched on the move to end shortcut (⌘→ on macOS, End elsewhere).
MOVE_TO_START
MOVE_TO_START: dispatched on the move to start shortcut (⌘← on macOS, Home elsewhere).
OUTDENT_CONTENT_COMMAND
OUTDENT_CONTENT_COMMAND: dispatched to outdent the selected content.
PASTE_COMMAND
PASTE_COMMAND: dispatched on a paste, with the ClipboardEvent (or the InputEvent or KeyboardEvent that pasted).
PASTE_TAG
PASTE_TAG (LexicalUpdateTags.ts): the update is a paste.
REDO_COMMAND
REDO_COMMAND: dispatched on redo (⇧⌘Z on macOS, Ctrl+Shift+Z or Ctrl+Y elsewhere).
REMOVE_TEXT_COMMAND
REMOVE_TEXT_COMMAND: dispatched to remove the selected text. JS’s payload is the input event or null, which no handler reads.
SELECTION_CHANGE_COMMAND
SELECTION_CHANGE_COMMAND: dispatched in an update when the selection changes. The core dispatches it from the DOM half of the update cycle, which isn’t ported (rust/PARITY.md), so only an app dispatches it.
SELECTION_INSERT_CLIPBOARD_NODES_COMMAND
SELECTION_INSERT_CLIPBOARD_NODES_COMMAND: dispatched by $insertGeneratedNodes (the clipboard feature) before it inserts the nodes of a paste; a handler that returns true inserts them itself.
SELECT_ALL_COMMAND
SELECT_ALL_COMMAND: dispatched on the select all shortcut (⌘A on macOS, Ctrl+A elsewhere), with the key event.
SET_TEXT_FORMAT_COMMAND
SET_TEXT_FORMAT_COMMAND: dispatched to set (true) or clear (false) text formats on the selection. JS’s payload is an object; its keys’ order is the order here.
SKIP_COLLAB_TAG
SKIP_COLLAB_TAG (LexicalUpdateTags.ts): the update must not be sent to other replicas.
SKIP_DOM_SELECTION_TAG
SKIP_DOM_SELECTION_TAG (LexicalUpdateTags.ts): the update must not change the platform’s selection.
SKIP_SCROLL_INTO_VIEW_TAG
SKIP_SCROLL_INTO_VIEW_TAG (LexicalUpdateTags.ts): the update must not scroll the selection into view.
SKIP_SELECTION_FOCUS_TAG
SKIP_SELECTION_FOCUS_TAG (LexicalUpdateTags.ts): the update must not move the focus to the editor.
UNDO_COMMAND
UNDO_COMMAND: dispatched on undo (⌘Z on macOS, Ctrl+Z elsewhere).
UPSTREAM_VERSION
The upstream Lexical release this port conforms to. The conformance vectors (meta.json) name the same one, so an upstream sync can’t move one without the other.

Traits§

AnyLexicalExtension
AnyLexicalExtension: any LexicalExtension, as the builder sees it. Only LexicalExtension implements it.
ExtensionConfigBase
ExtensionConfigBase: what an extension’s config is. JS configs are objects, their overrides are Partial<Config>, and shallowMergeConfig merges one as {...config, ...overrides}. A Rust config names its overrides’ type and how they apply: Object, the JS form, merges as JS does; () is the config of an extension with none (JS {}).
KeyboardEventModifiers
KeyboardEventModifiers: a KeyboardEvent, or anything with its key, code and modifier fields.
KeyboardShortcutMatch
KeyboardShortcutMatch (@experimental): which keyboard events a shortcut matches, an event.key value (case-insensitive) and a KeyboardEventModifierMask, with the semantics of is_exact_shortcut_match, including the event.code fallback for non-Latin layouts.
LexicalNode
What every node implements. JS’s class hierarchy (LexicalNode, ElementNode, TextNode, …) becomes this trait plus the data each base class adds (ElementData, TextData); a node that extends ElementNode returns its ElementData from element.
ListenerCleanup
What an update, text content, decorator or editable listener returns: nothing (()), or a clean-up function (an Unregister, or an Option of one), which runs before the listener’s next call, or when it is unregistered. JS takes a returned function as the clean-up and ignores any other value (triggerListeners).
NodeClone
The parts of LexicalNode every implementation writes the same way, implemented for any Clone node.
RootElement
The editor’s root element: what JS’s HTMLElement root is to an app without a DOM, the view that shows the document. Setting one (Editor::set_root_element) runs the reconciler’s model half, so mutation listeners hear from the editor. Root elements compare by identity, as JS’s elements do.
SelectionMovement
Where a caret lands when it moves one unit, which only text layout knows (the DOM’s Selection.modify in JS). Called inside an update or read, so it can read nodes.
StateValue
A value a state can hold without saying how it serializes and compares: one that JSON writes as it is (JS’s default unparse), compared with Object.is (JS’s default isEqual).

Functions§

add_update_tag
$addUpdateTag(tag): adds a tag to the running update, which update and mutation listeners and has_update_tag see. Panics in a read, or outside an update, as JS’s errorOnReadOnly and getActiveEditor() throw.
apply_node_replacement
$applyNodeReplacement(node): what the active editor’s replacement of the node’s class ({replace, with, withKlass}) makes of the new node, or the node itself when the class has none. Fails as JS’s invariants do: for a type the editor doesn’t register, or a replacement that isn’t of withKlass (or, without it, of a class extending the node’s), or that kept the node’s key.
caret_from_point
$caretFromPoint(point, direction): the caret at a selection point.
caret_range_from_selection
$caretRangeFromSelection(selection): the carets of a range selection, in the previous direction when the focus is before the anchor.
clamp_range_selection_to_slot_frame
$clampRangeSelectionToSlotFrame(selection) (@experimental): keeps the focus of a range selection in the anchor’s slot frame, at the boundary on the side the focus was, in the default slots-before-children order (compare_point_caret_next_across_slots). Returns whether it moved the focus, which marks the selection dirty.
clone_with_properties
$cloneWithProperties(latestNode): a clone of the node’s latest version with the same key, links and properties, in no editor state. An editor state never sees it unless it is put there, so changing it changes no state.
clone_with_properties_ephemeral
$cloneWithPropertiesEphemeral(latestNode): a clone that can’t join an editor state, for changing in place while serializing a slice. A clone from clone_with_properties is already outside every editor state, so it is the same clone.
compare_point_caret_next
$comparePointCaretNext(a, b): the total order of next carets in which a CaretRange iterates them. For one origin, a child caret and a text point caret come before the sibling caret. Carets whose origins have no common ancestor are an error.
compare_point_caret_next_across_slots
$comparePointCaretNextAcrossSlots(a, b) (@experimental): like compare_point_caret_next, with a host’s slot values, in slot order, after the points before the host and before its children. None when the carets have no common ancestor.
compile_keyboard_shortcuts
compileKeyboardShortcuts(shortcuts) (@experimental @internal).
config_extension
configExtension(extension, ...configs): the extension with config overrides, for another extension’s dependencies or for build_editor_from_extensions. The builder merges them with mergeConfig, or with shallow_merge_config.
control_or_alt
CONTROL_OR_ALT: the secondary shortcut modifier, ⌥ (altKey) on Apple platforms and Ctrl elsewhere, for word-level editing and block formats.
control_or_meta
CONTROL_OR_META: the primary shortcut modifier, ⌘ (metaKey) on Apple platforms and Ctrl elsewhere, for the platform is_apple names.
copy_node
$copyNode(node): a copy of the node with a new key and all its properties, but no parent, siblings or children, after resetOnCopyNodeFrom.
copy_node_with
$copyNode(node, skipReset): copy_node, without resetOnCopyNodeFrom when skip_reset is true, so the copy keeps every property and state of the node.
create
$create(klass): a new node of the class T, with a key, in the active editor state; or, where the editor replaces the class (LexicalNodeReplacement), a node of the class its with_klass chain ends at, or (for a replacement without with_klass) what its with makes of the new node. Where no editor registers T (outside an editor, or while parsing for one without it) the node is T’s, where JS throws.
create_command
createCommand(type).
create_editor
createEditor(config): registers the core nodes (root, text, line break, tab, paragraph, artificial) and args.nodes, in args.namespace, or the parent editor’s when that is empty. (JS’s createEditor() with no config at all takes the active editor as the parent; Rust always takes a config, as Swift does.)
create_node_selection
$createNodeSelection().
create_range_selection
$createRangeSelection(): a selection at the start of the root, not set on the editor state.
create_ref_counted_registry
createRefCountedRegistry(activate).
create_state
createState(key, {parse}): a state with JS’s default unparse and isEqual (StateValue).
create_state_with
createState(key, valueConfig).
declare_peer_dependency
declarePeerDependency(name, config?): a peer dependency on the extension named name, whose config is a C (JS gives the extension’s type as a type argument), optionally with config overrides.
define_extension
defineExtension(extension): the extension, behind the Rc whose identity the builder tells extensions apart by (JS returns the object itself, compared with ===). Define each extension once and share the Rc: two definitions with one name can’t be built together.
export_node_json
$exportNodeJSON(node): one node’s JSON in the active form, checked as every export walk checks it. A failed check is a bug in the node’s implementation, so it panics.
extend_caret_to_range
$extendCaretToRange(anchor): a range from anchor to the end of the document in its direction.
flip_direction
flipDirection(direction).
get_adjacent_child_caret
$getAdjacentChildCaret(caret): the adjacent caret, or its child caret when its origin is an element. With getParentCaret this walks the whole tree depth first.
get_adjacent_node
$getAdjacentNode(focus, isBackward): the node next to the point in the direction, or None at a boundary.
get_adjacent_sibling_or_parent_sibling_caret
$getAdjacentSiblingOrParentSiblingCaret(startCaret, rootMode): the next caret in a depth first walk that doesn’t descend into the start, with the change in depth.
get_cached_type_to_node_map
getCachedTypeToNodeMap(editorState): the nodes of a read-only editor state by type, computed once per state; an empty map for a writable state that is still empty. Panics for any other writable state, as JS’s invariant throws.
get_caret_in_direction
$getCaretInDirection(caret, direction): the caret if it is in direction, otherwise caret.getFlipped().
get_caret_range
$getCaretRange(anchor, focus): a range between carets in the same direction, where the anchor points towards the focus.
get_caret_range_in_direction
$getCaretRangeInDirection(range, direction): the range, or the same part of the document iterated the other way.
get_child_caret
$getChildCaret(origin, direction): a caret pointing to the first (next) or last (previous) child of origin, or None if it isn’t an element.
get_child_caret_at_index
$getChildCaretAtIndex(parent, index, direction): a caret pointing to the child at index, or the last caret in parent past the end.
get_child_caret_or_self
$getChildCaretOrSelf(caret): the caret’s child caret if it has one, otherwise the caret.
get_collapsed_caret_range
$getCollapsedCaretRange(anchor).
get_common_ancestor
$getCommonAncestor(a, b): how a and b relate, or None if they have no common ancestor.
get_common_ancestor_across_slots
$getCommonAncestorAcrossSlots(a, b) (@experimental): like get_common_ancestor, but a slot value’s parent is its host.
get_common_ancestor_result_branch_order
$getCommonAncestorResultBranchOrder(compare): Less if a (a sibling of b) comes first, Greater otherwise.
get_composition_key
$getCompositionKey(): the node an input method is composing in; always none in a read.
get_declared_node_structure
getDeclaredNodeStructure(klass) (@experimental node-structure): the structural declarations of the class of node. Depends on the class only.
get_declared_slots
getDeclaredSlots(klass) (@experimental): the slots a class declares in its $config() (its own, or the nearest ancestor’s), the canonical order of its slots; empty when it declares none.
get_editor
$getEditor(): the editor of the running update or read (or the one parseEditorState parses for). Panics outside them, as JS’s getActiveEditor() throws.
get_node_by_key
$getNodeByKey(key).
get_point_slot_frame
$getPointSlotFrame(point): the slot frame of the point’s node.
get_registered_subtype_map
getRegisteredSubtypeMap(nodes): each type of nodes to itself and the types of the classes of nodes that extend it.
get_root
$getRoot().
get_selection
$getSelection().
get_selection_slot_frame
$getSelectionSlotFrame(selection) (@experimental): the slot frame the selection is in, from a range selection’s anchor or the first node of any other selection, or None outside every slot (or without a selection).
get_sibling_caret
$getSiblingCaret(origin, direction): a caret pointing from origin to its next or previous sibling. JS returns null for a null origin; here that is Option::map.
get_slot
$getSlot(node, name) (@experimental): the node in the named slot, or None when it is empty.
get_slot_frame
$getSlotFrame(node) (@experimental): the slot value (the “slot frame”) whose isolated subtree holds the node, the node itself when it is one, or None outside every slot.
get_slot_host
$getSlotHost(node) (@experimental): the host whose named slot holds the node, or None when it is not slotted. Kept apart from NodeRef::get_parent, so the slot boundary behaves like a shadow root.
get_slot_name_within_host
$getSlotNameWithinHost(slotChild) (@experimental): the name of the slot the node occupies on its host, or None when it is not slotted.
get_slot_names
$getSlotNames(node) (@experimental): the names of the node’s occupied slots, in their canonical order.
get_state
$getState(node, stateConfig): the value of the state on the latest version of the node, or its default. Fails when another config with the same key was used on the node’s type.
get_state_change
$getStateChange(node, prevNode, stateConfig): None when the two versions hold equal values, else (value, prevValue).
get_state_direct
$getState(node, stateConfig, NODE_STATE_DIRECT): the value on this version of the node, which needs no editor state.
get_style_object_from_css
getStyleObjectFromCSS(css): parses inline CSS text into an object that is compatible with CSSStyleDeclaration.setProperty(). Comments are dropped; : and ; inside quotes or parentheses are not delimiters.
get_text_direction
getTextDirection(text): the direction of the first strongly directional UTF-16 code unit in text (RTL_REGEX, then LTR_REGEX: ^[^LTR]*[RTL] and ^[^RTL]*[LTR]), or None when there is none.
get_text_node_offset
$getTextNodeOffset(origin, offset, mode): the numeric offset of offset in origin. Out of bounds it is an error (JS’s development build), or clamped when clamp (mode 'clamp').
get_text_point_caret
$getTextPointCaret(origin, direction, offset): a caret at offset in the text node origin. An offset past the end is an error, as in JS’s development build.
get_text_point_caret_slice
$getTextPointCaretSlice(caret, distance).
get_text_point_caret_slice_for_node
$getTextPointCaretSliceForNode(slices, node): the slice of node among a caret range’s text slices.
has_update_tag
$hasUpdateTag(tag): whether the running update has the tag (one of its options’ tags, or one add_update_tag added). Panics outside an update or a read of an editor, as JS’s getActiveEditor() throws.
insert_node_to_nearest_root_at_caret
$insertNodeToNearestRootAtCaret(node, caret, options): inserts node at the caret, splitting its ancestors up to the nearest block container (the root or a shadow root, with the default root_mode), and returns the caret after it.
insert_nodes
$insertNodes(nodes): inserts nodes at the selection, the previous one if there is none, or else the end of the root.
internal_is_inline_content
INTERNAL_isInlineContent(node): whether the node structure normalization treats node as inline content: text, line breaks, inline elements and decorators, and the character limit’s OverflowNode.
internal_is_node_structure_enforced
INTERNAL_isNodeStructureEnforced(editor) (internal): whether editor enforces declared node structure (NodeStructureExtension or registerNodeStructure is registered on it).
internal_normalize_node_structure
INTERNAL_$normalizeNodeStructure(node) (internal): normalize the subtree rooted at node now, as NodeStructureExtension does, bottom-up (which may split node in its parent), then merge node (or what it was split into) with its equal siblings. For code that applies an update with skip_transforms, which the extension doesn’t normalize.
internal_register_node_structure
INTERNAL_registerNodeStructure(editor) (internal, for NodeStructureExtension and registerNodeStructure): enforce the structure node classes declare on editor, and mark every element and decorator dirty so the current document is normalized too. Registrations are counted: the normalization stops when the last one is disposed.
is_apple
IS_APPLE: whether the keyboard conventions are Apple’s (⌘ for the primary shortcuts, ⌥ for words). JS reads the browser’s platform; here it is true on Apple platforms. with_is_apple overrides it on this thread, as Swift’s withIsApple does, since the vectors are recorded for both.
is_backspace
isBackspace(event).
is_block_container
$isBlockContainer(node) (@experimental node-structure): whether structural commands treat node as a container of blocks: the root, a shadow root, or, in an editor that enforces declared node structure, a block element whose class declares children: 'block'. With no active editor, only the root and shadow roots are containers.
is_block_fully_selected
$isBlockFullySelected(blockNode, selection): whether the selection covers everything in the block. A range in another slot frame never does. is_block_fully_selected_by_caret_range takes a CaretRange, as JS’s also does.
is_block_fully_selected_by_caret_range
$isBlockFullySelected(blockNode, range) with a CaretRange: whether the range, in either direction, covers everything in the block.
is_compact_export
$isCompactExport(): whether the export walk in progress writes the compact form.
is_delete
isDelete(event).
is_escape
isEscape(event).
is_exact_shortcut_match
isExactShortcutMatch(event, expectedKey, mask): whether the event is expected_key (case-insensitive) with exactly the modifiers of mask, falling back to event.code for a single-character key on a non-Latin layout.
is_extendable_text_point_caret
$isExtendableTextPointCaret(caret): a text point caret whose offset can move further in its direction without leaving the node.
is_modifier
isModifier(event): whether any modifier is down.
is_modifier_match
isModifierMatch(event, mask): whether the event’s modifiers are as the mask expects.
is_root_or_shadow_root
$isRootOrShadowRoot(node): whether the node is the root or a shadow root.
is_same_frame
$isSameFrame(a, b).
is_select_all
isSelectAll(event): ⌘A on Apple platforms, Ctrl+A elsewhere.
is_slot_child
$isSlotChild(node) (@experimental): whether the node can be slotted, an element or a decorator (set_slot refuses an inline one).
is_slot_host
$isSlotHost(node) (@experimental): whether the node can host slots, an element or a decorator. What may be slotted is checked by set_slot.
is_token_or_segmented
$isTokenOrSegmented(node): whether a text node is in token or segmented mode.
iter_static_node_config_chain
iterStaticNodeConfigChain(klass): the node’s class and the classes it extends, most derived first (LexicalNode::static_node_config_chain), or the node’s class alone, declaring nothing, for a class that gives no chain.
js_trim
String.prototype.trim: without JS’s whitespace (and line terminators) at either end.
keyboard_event_mask_for_platform
keyboardEventMaskForPlatform(mask, isApple) (@internal): the mask as it is on the platform is_apple names, when it is a control-or-other mask made for the other one.
make_stepwise_iterator
makeStepwiseIterator({initial, hasNext, step, map}): yields map(state) while has_next(state), stepping the state after each.
merge_register
mergeRegister(...func): one clean-up function that calls each of funcs in reverse order, as clean-ups usually need to run in the reverse of the order they were registered.
nodes_of_type
$nodesOfType(klass), by the node type: the nodes of exactly that type in the active editor state, in its node map’s order; in a state still being updated, only those attached to the root.
normalize_caret
$normalizeCaret(initialCaret): the deepest equivalent caret, a text point caret when there is text at the caret.
on_before_input
onBeforeInput(event, editor): an app’s beforeinput. A composition’s own input (insertCompositionText, deleteCompositionText) is left to the composition commands; anything else dispatches BEFORE_INPUT_COMMAND.
on_composition_end
onCompositionEnd(event, editor): dispatches COMPOSITION_END_COMMAND (where JS waits for Firefox’s and Safari’s input event, the model has none to wait for).
on_composition_start
onCompositionStart(event, editor): dispatches COMPOSITION_START_COMMAND.
on_key_down
onKeyDown(event, editor): an app’s key press. It records the key and, unless an input method is composing, dispatches KEY_DOWN_COMMAND, whose default handler dispatches the command the key stands for. Read event.default_prevented() afterwards to know whether the key was taken (the app then skips its own handling of it).
on_selection_change
onSelectionChange(domSelection, editor, isActive), its model half: an app’s view selected anchor to focus (None when the selection left the editor). An editor that isn’t active (is_active false, another editor of the view has the selection) gets no selection, as in JS. Otherwise the points become the selection, with the format and style of the editor state’s (the last committed) selection, as $internalCreateRangeSelection gives a selection read from the DOM; a caret takes the format and style of where it is ($updateCollapsedSelectionFormatStyle) and a range the format all its text has; then the change is announced with SELECTION_CHANGE_COMMAND ($dispatchSelectionChangeCommand).
on_update
$onUpdate(updateFn) (LexicalUtils.ts): runs update_fn once the update that is running commits, after its listeners.
parse_serialized_node
$parseSerializedNode(serializedNode): a node, and its children, from its JSON, created in the active update with the active editor’s node classes.
remove_slot
$removeSlot(host, name) (@experimental): empties the named slot of host, removing the node it held. Nothing happens when it is empty. Returns the host.
remove_text_from_caret_range
$removeTextFromCaretRange(initialRange, sliceMode): removes the text and nodes in the range, merging the rest of the later block into the earlier one when the range spans blocks. Returns the collapsed range where the removal was, in the initial range’s direction.
reset_random_key
resetRandomKey(): restarts the key counter, for deterministic keys in tests.
rewind_sibling_caret
$rewindSiblingCaret(caret): the caret, in the same direction, whose adjacent caret is caret.
safe_cast
safeCast(value): value. JS uses it to give a config its type where inference wouldn’t; Rust infers it from the annotation, so this only keeps ported code close to JS.
select_all
$selectAll(): selects the whole root, with the points moved down to text where they can be, and returns the selection. select_all_in is $selectAll(selection), which scopes an existing selection.
select_all_in
$selectAll(selection): for a range selection, moves its points to the start and end of the root or shadow root that holds its anchor, down to text where they can be, and returns it (in a slot, the contents of the slot value); for a node selection, select_all, which is $selectAll().
set_composition_key
$setCompositionKey(compositionKey): the node an input method is composing in, or none. The previous and the new composition nodes are made writable, so they reconcile.
set_dom_style_from_css
setDOMStyleFromCSS(domStyle, cssText, prevCSSText): sets the properties of css_text and removes those only prev_css_text has.
set_dom_style_object
setDOMStyleObject(domStyle, styleObject): sets each property with a value and removes each one without (null).
set_point_from_caret
$setPointFromCaret(point, caret): sets the point which of a range selection to the caret’s position.
set_selection
$setSelection(selection).
set_selection_from_caret_range
$setSelectionFromCaretRange(caretRange): sets the editor’s range selection (the current one, or a new one) to the range, and returns it.
set_slot
$setSlot(host, name, node) (@experimental): puts node in the named slot of host, replacing (and removing) the node the slot held. The node moves, from a parent or another slot. It must be an element or a decorator that is not inline; the slot link is its shadow boundary. Returns the host.
set_state
$setState(node, stateConfig, value): sets the state on the node (the node is written even when the value is the one it has). Fails when another config with the same key was used on the node’s type.
set_state_with
$setState(node, stateConfig, updater): sets the state to what updater makes of the node’s value, unless that is equal to it, when the node is left as it is.
shallow_merge_config
shallowMergeConfig(config, overrides): the default merge of config overrides, config without them, otherwise ExtensionConfigBase::shallow_merge ({...config, ...overrides}).
split_at_point_caret_next
$splitAtPointCaretNext(pointCaret, options): splits the node at the caret once, and returns the caret where it split, or None where it can’t.
split_node
$splitNode(node, offset): splits the element at its child offset and each ancestor up to the nearest root or shadow root, and returns the top of the left tree (node’s ancestor below the root, which keeps the children before the offset) and of the right tree (a copy, which gets the rest). The child at offset moves into the right tree; its ancestors are copied. An offset past the end splits after the last child. JS’s return type lets the left be null; it never is.
split_text_point_caret
$splitTextPointCaret(textPointCaret): splits the text at the caret, and returns the sibling caret between the two halves (or beside the text, at either end).
update_range_selection_from_caret_range
$updateRangeSelectionFromCaretRange(selection, caretRange).
with_compact_export
$withCompactExport(compact, f): runs f writing the compact form (or, with false, the legacy form) for any export it performs.
with_is_apple
Runs f with is_apple returning is_apple on this thread.
with_warning_handler
Runs f with handler receiving, on this thread, the warnings JS writes with console.warn, and restores the previous handler after, even when f panics.

Type Aliases§

ChildCaret
ChildCaret: a PointCaret whose kind is CaretKind::Child.
ExtensionBuildFn
build (LexicalExtension.build).
ExtensionInitFn
init (LexicalExtension.init).
ExtensionMergeConfigFn
mergeConfig (LexicalExtension.mergeConfig).
ExtensionRegisterFn
register and afterRegistration (LexicalExtension.register): they return the clean-up function.
InitialEditorStateFn
(editor: LexicalEditor) => void, an initial state that updates the editor.
LiftsFromStructure
A holder’s own hook for a child its declared children allow that must still be lifted out (INTERNAL_$liftsFromStructure): the holder, the child, and whether this is INTERNAL_$normalizeNodeStructure’s normalization.
MutatedNodes
MutatedNodes: the nodes a commit mutated by node type, in the order the reconciler first reached one of the type (JS keys its Map by class).
NodeCaret
NodeCaret: a sibling or child caret.
NodeKey
A node’s key in its editor state’s node map. Keys are strings, as in JS, from a per-thread counter (generateRandomKey).
NodeMutations
The nodes of one class a commit mutated, in the order the reconciler reached them (JS’s Map<NodeKey, NodeMutation>).
NodeReplace
A node replacement’s with: given a new node of the replaced class (with a key, in the active editor state), the node to use instead, which must have a key of its own.
ShortcutDisabledFn
A shortcut’s $disabled(selection, editor).
ShortcutDispatchFn
A shortcut’s $dispatch(command, event, $next, editor).
SiblingCaret
SiblingCaret: a PointCaret whose kind is CaretKind::Sibling.
StateIsEqual
A state’s isEqual: whether two of its values are the same value.
TextPointCaret
TextPointCaret: a PointCaret whose kind is CaretKind::Text.
Transform
A node transform (Transform<T>).
TypeToNodeMap
TypeToNodeMap: an editor state’s nodes by type, then by key.
Unregister
Calling it removes what was registered, as the function JS’s register* methods return. Dropping it without calling it keeps the registration.
WarningHandler
ErrorHandler as onWarn takes it: it gets a warning the editor has recovered from, and what it returns is what the call that warned returns (JS’s default throws in development, as the vectors record).