docs/solutions/developer-experience/2026-05-16-slate-transform-middleware-defaults-need-alias-depth-guard.md
Slate v2 needed extension.transforms to cover every public mutating transform
without turning internal implementation aliases into duplicate public hooks.
The dirty version is easy: wrap every transform and call the old implementation.
That is not enough.
EditorTransformMiddlewareMap accepted only deleteBackward and
insertText.deleteBackward -> delete
run a second transform middleware hook during delegation.setNodes middleware args to plain
Node, which weakened custom-value inference for extension authors.EditorTransformMiddlewareMap. That keeps
the same drift failure.Use three layers:
transform:insertNode.The guard makes this distinction explicit:
Editor.deleteBackward(editor)
should invoke transforms.deleteBackward, and its default implementation may
call lower-level delete logic without also invoking transforms.delete.
Public type contracts should assert both directions:
type Missing = Exclude<EditorPublicTransformMiddlewareKey, Accepted>
type Extra = Exclude<Accepted, EditorPublicTransformMiddlewareKey>
type AssertNever<T extends never> = T
Runtime contracts should install middleware for every accepted key and call the
matching Editor.* transform. Keep specific next(overrides) tests for
high-pressure keys like insertNode, and keep double-next() rejection tested
once through the generic bridge.
The public API stays Slate-close: extension authors write
transforms.insertNode({ next, node, options }), not command-string handlers.
The runtime still reuses ordered command storage and cleanup, but the no-handler
fast path preserves no-middleware behavior and command metadata.
The default-depth guard is the important bit. It lets internal implementations compose through existing helpers without making those helper calls observable as second public transform middleware invocations.
docs/solutions/developer-experience/2026-04-09-slate-transform-namespaces-should-stay-thin-sugar-over-the-current-engine.mddocs/solutions/developer-experience/2026-05-03-slate-public-root-hard-cuts-need-internal-imports-and-explicit-type-exports.mddocs/solutions/developer-experience/2026-04-29-slate-v2-hard-cuts-must-run-explicit-contract-files.md