Skip to main content

@lexical/extension/IMEExtension

Variables

IMEExtension

const IMEExtension: LexicalExtension<ExtensionConfigBase, "@lexical/extension/IME", { composingTextNode: Signal<TextNode | null>; compositionKey: Signal<string | null>; }, unknown>

Defined in: packages/lexical-extension/src/IMEExtension.ts:52

Centralizes IME composition state so extensions that react to composition lifecycle don't each re-implement the COMPOSITION_START_COMMAND + compositionend listener dance.

Exposes two signals (both always-active for the editor's lifetime — listeners are wired up by register, not lazily on subscription, so consumers can read .value from anywhere without holding a subscription themselves):

  • compositionKey is the raw mirror — the value Lexical's own $handleCompositionStart writes to its internal _compositionKey, i.e. the selection.anchor.key at the moment composition starts. This can be a non-TextNode key when composition begins on an element-anchor selection (e.g. empty paragraph). Cleared on compositionend.

  • composingTextNode is the resolved view — the actual TextNode being composed on, or null while there is no TextNode-level composition. For an element-anchor start it stays null until the COMPOSITION_START_TAG-tagged update fires with the post-ZWSP-heuristic selection, at which point it updates to the new TextNode.