weasel API - v0.8.0
    Preparing search index...

    Interface InsertAdapter<TNode>

    Narrow adapter for useInsert and useClipboardOps. The kit knows nothing about what tool is active or what shape to construct; it asks the adapter to produce node(s) given gesture or paste inputs.

    Drag-rectangle path: commitInsert(bounds) returns one new node or null. Clipboard paste path: commitPaste(clipboard, offset) returns the array of newly-materialized nodes (in order). Both empty array and array of length N are valid; the kit wraps each entry in an InsertOp.

    snapshotSelection(ids) builds the payload that paste later consumes. getPasteOffset is optional; the kit defaults to a fixed grid-cell offset supplied by the consumer (passed to useClipboardOps options if needed; see the hook for resolution order).

    interface InsertAdapter<TNode extends { id: string }> {
        applyOps?(ops: Op[], label: string): void;
        commitInsert?(
            bounds: { height: number; width: number; x: number; y: number },
        ): TNode | null;
        commitPaste?(
            clipboard: ClipboardSnapshot,
            offset: { dx: number; dy: number },
            ctx?: { dropPoint?: { worldX: number; worldY: number } },
        ): TNode[];
        getPasteOffset?(clipboard: ClipboardSnapshot): { dx: number; dy: number };
        getSelection(): string[];
        insertNode(node: TNode): void;
        setSelection(ids: string[]): void;
        snapshotSelection?(ids: string[]): ClipboardSnapshot;
    }

    Type Parameters

    • TNode extends { id: string }

    Hierarchy (View Summary)

    Index

    Methods

    • Materialize a new node from drag-rect bounds (drag-to-insert tools). Optional — hooks that don't drive insertion (e.g. useClone, read-only clipboard) won't call it, and sceneToAdapter only fills it in when options.commitInsert is supplied. Hooks that do call it (insert tools) document the requirement at their own surface.

      Parameters

      • bounds: { height: number; width: number; x: number; y: number }

      Returns TNode | null

    • Materialize one or more new nodes from a clipboard snapshot. Optional — required by useClipboard.paste, ignored by other consumers.

      Parameters

      • clipboard: ClipboardSnapshot
      • offset: { dx: number; dy: number }
      • Optionalctx: { dropPoint?: { worldX: number; worldY: number } }

      Returns TNode[]