DOMSlot
classBase class for DOM slots — a pointer to the content-bearing element of a node's DOM, plus optional `before` / `after` boundaries marking where the lexical-managed content sits inside that element. For ElementNode children management see ElementDOMSlot. For non-Element nodes (TextNode, LineBreakNode, DecoratorNode) the slot still supports an internal `before` / `after` so subclasses can prepend or append non-lexical siblings around the content node and the reconciler / `setTextContent` route the actual content through the slot.
Import
import { DOMSlot } from '@modular/sdk/editor';Members10
- after
Node | nullLower boundary: the lexical-managed range starts after this node.
- before
Node | nullUpper boundary: the lexical-managed range ends before this node.
- element
TThe content-bearing element of the node's DOM.
- getFirstChild()
() => ChildNode | nullReturns the first managed child (the first node in `this.element` that is not a non-lexical prelude / decoration), or `null` if there is none. Subclasses may override to also skip reconciler-managed scaffolding such as the managed line break.
- insertChild()
(dom: Node) => thisInsert the given node before `this.before` (if defined) or append it to `this.element` otherwise. Subclasses may override to respect additional boundaries (e.g. `ElementDOMSlot` also keeps the managed line break at the end).
- removeChild()
(dom: Node) => thisRemove the given child from `this.element`. Throws if it was not a child.
- replaceChild()
(dom: Node, prevDom: Node) => thisReplace `prevDom` with `dom`. Throws if `prevDom` is not a child.
- withAfter()
(after: Node | undefined | null) => DOMSlot<T>Return a new slot with `after` updated.
- withBefore()
(before: Node | undefined | null) => DOMSlot<T>Return a new slot with `before` updated.
- withElement()
<ElementType extends HTMLElement>(element: ElementType) => DOMSlot<ElementType>Return a new slot with `element` updated.