Skip to main content

$setSlot

function

Places `node` into the named slot of `host`, replacing any existing value under that name. Move semantics, mirroring `ElementNode.append` / `insertBefore`: the value is detached from wherever it currently lives — a child of another element, or a slot on this or another host (a node's two up-links, `__parent` and `__slotHost`, are mutually exclusive, so it holds exactly one) — before linking, so re-slotting never requires an explicit remove first. The replaced value, if any, is detached. A slot value must be a non-inline ElementNode or a non-inline DecoratorNode: the slot link itself acts as a virtual shadow root between the host and the value, so the value does not need to be a shadow root — a plain block (e.g. a ParagraphNode subclass serving as a single-line field) is a valid slot value, and selection, traversal, and editing treat its slot boundary exactly like a shadow-root boundary. `host` is constrained to SlotHostNode so a non-host is rejected at compile time.

function $setSlot<T extends LexicalNode & SlotHostNode>(host: T, name: SlotName<T>, node: LexicalNode): T

Import

import { $setSlot } from '@modular/sdk/editor';