import { Descendant } from '../../slate/index.ts'; import { Key } from '../utils/key'; export interface ChunkTree { type: "root"; children: ChunkDescendant[]; /** * The keys of any Slate nodes that have been moved using move_node since the * last render * * Detecting when a node has been moved to a different position in the * children array is impossible to do efficiently while reconciling the chunk * tree. This interferes with the reconciliation logic since it is treated as * if the intermediate nodes were inserted and removed, causing them to be * re-chunked unnecessarily. * * This set is used to detect when a node has been moved so that this case * can be handled correctly and efficiently. */ movedNodeKeys: Set; } export interface Chunk { type: "chunk"; key: Key; parent: ChunkAncestor; children: ChunkDescendant[]; } export interface ChunkLeaf { type: "leaf"; key: Key; node: Descendant; index: number; } export type ChunkAncestor = ChunkTree | Chunk; export type ChunkDescendant = Chunk | ChunkLeaf; export type ChunkNode = ChunkTree | Chunk | ChunkLeaf;