/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type { LexicalNode, NodeKey } from '../LexicalNode.js'; import type { ElementNode } from '../nodes/LexicalElementNode.js'; import type { CaretDirection, NodeCaret, SiblingCaret } from './LexicalCaret.js'; import { type PointType, type RangeSelection } from '../LexicalSelection.js'; /** Insert into a gap, repairing both boundaries. All nodes must be writable. */ export declare function $insertNodeBetween(writableParent: ElementNode, writableNode: LexicalNode, writablePrevious: LexicalNode | null, writableNext: LexicalNode | null): void; /** * Unlink a writable child without selection bookkeeping. Detached nodes are * not modified. Callers obtain getWritable once before entering this layer. */ export declare function $detachNode(writableNode: LexicalNode): void; /** * Detach a contiguous child range, repairing its outer boundaries once. * Resolve all writable nodes before changing links so clone hooks see a * consistent tree. The caller handles selection repair. */ export declare function $detachSiblingRange(writableParent: ElementNode, first: LexicalNode | null, count: number, before: LexicalNode | null): NodeKey[]; /** * Detach a writable child and repair element offsets in the old parent. Return * points that followed it before repair, so insertAfter can move them (#6031). */ export declare function $detachNodeWithSelection(node: LexicalNode, selection: RangeSelection | null): PointType[] | null; /** * Shared insertion in a sibling caret direction, without allocating a caret * in the base node methods. Public carets still dispatch through those methods * so subclass overrides run. */ export declare function $insertSibling(origin: LexicalNode, direction: CaretDirection, node: LexicalNode, restoreSelection: boolean): LexicalNode; /** * Select the sibling at this caret, preserving the node methods' placement * rules for text, elements, decorators and slot roots. * @internal */ export declare function $selectAdjacentNode(caret: SiblingCaret, anchorOffset?: number, focusOffset?: number): RangeSelection; /** * Get the adjacent nodes to initialCaret in the given direction. * * @example * ```ts * expect($getAdjacentNodes($getChildCaret(parent, 'next'))).toEqual(parent.getChildren()); * expect($getAdjacentNodes($getChildCaret(parent, 'previous'))).toEqual(parent.getChildren().reverse()); * expect($getAdjacentNodes($getSiblingCaret(node, 'next'))).toEqual(node.getNextSiblings()); * expect($getAdjacentNodes($getSiblingCaret(node, 'previous'))).toEqual(node.getPreviousSiblings().reverse()); * ``` * * @param initialCaret The caret to start at (the origin will not be included) * @returns An array of siblings. */ export declare function $getAdjacentNodes(initialCaret: NodeCaret): LexicalNode[]; /** Collect siblings including start, without allocating intermediate carets. */ export declare function $collectSiblingNodes(start: LexicalNode | null, direction: CaretDirection): LexicalNode[];