docs/research/sources/editor-architecture/lexical-read-update-extension-runtime.md
Compile the Lexical evidence that matters to Slate v2's final read/update runtime architecture.
editor.update(...) the normal way to mutate editor state.editor.read(...) and editorState.read(...) the coherent
read boundary.Direct local source refresh against /Users/zbeyens/git/lexical adds sharper
API evidence for the Slate v2 API review:
LexicalEditor partitions listeners by update, editable, decorator, text
content, root, command, mutation, and node transform.LexicalUpdateTags.ts gives named lifecycle metadata for history, paste,
collaboration, scroll, DOM selection, focus, and composition.LexicalUpdates.ts enforces synchronous active read/update contexts and
applies transforms before DOM reconciliation.init, build, register, and
afterRegistration, with dependencies, peer dependencies, conflicts, merged
config, output, and an abort signal for cleanup.NodeState adds schema-like, parse-backed, JSON-serializable ad-hoc node
state with default elision and equality hooks.DecoratorNode exposes a runtime-owned isolated/rendered node lane with
inline, isolated, and keyboard-selectable policy hooks.Takeaway: the next Slate v2 steal pass should focus less on Lexical's public
command examples and more on listener partitioning, extension lifecycle,
typed lifecycle tags, dirty transform scheduling, decorator/atom isolation, and
extension-local reactive state. The Slate answer should stay state / tx
and plain JSON nodes; Lexical's class nodes, $ helpers, and dispatch-command
app API remain wrong for raw Slate.
editor.update is a better public name than withTransaction or command for
the write boundary. editor.read is the matching read boundary.
Slate v2 should use:
editor.read((state) => {
state.selection.get()
})
editor.update((tx) => {
tx.nodes.set({ type: 'heading-one' })
})
Lexical makes helper functions depend on active read/update context. Slate v2
should not copy $ naming, but it should copy the rule:
editor.readeditor.updateSlate v2 should adopt update tags as commit metadata:
history-pushhistory-mergepastecollaborationskip-dom-selectionskip-scrollcomposition-startcomposition-endTags should inform history, collaboration, React runtime, and DOM repair. They should not be normal app-command policy objects.
Lexical tracks dirty leaves and elements below rendering. Slate v2 should adapt that to:
React should consume this commit data instead of rediscovering it from full snapshots.
Lexical Extensions exist because configuration and registration often need to travel together. Slate v2 should steal that concept for Plate/Yjs migration:
$function naming.The final Slate v2 public runtime should be:
editor.read
editor.update
state groups inside read
tx groups inside update
commit metadata after update
React runtime consumes live reads and dirty commits
tx.resolveTarget() remains useful internally, but the public architecture is
read/update lifecycle discipline.