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

    Interface SelectionApi

    API returned by useSelection.

    interface SelectionApi {
        adapterMethods: {
            getSelection: () => NodeId[];
            setSelection: (ids: NodeId[]) => void;
        };
        current: readonly NodeId[];
        add(id: NodeId): void;
        applyClick(
            id: NodeId,
            modifiers: { ctrl: boolean; meta: boolean; shift: boolean },
        ): void;
        clear(): void;
        contains(id: NodeId): boolean;
        get(): NodeId[];
        remove(id: NodeId): void;
        set(ids: NodeId[]): void;
        toggle(id: NodeId): void;
    }
    Index

    Properties

    adapterMethods: {
        getSelection: () => NodeId[];
        setSelection: (ids: NodeId[]) => void;
    }

    Pre-built methods for spreading into an adapter that needs them.

    current: readonly NodeId[]

    Current selection. Re-renders trigger when this reference changes.

    Methods

    • Apply a click to the selection per the configured mode/extend key.

      • single: replaces selection with [id], regardless of modifiers.
      • multi: with the extend key held, toggles id in/out of the selection; otherwise replaces with [id].

      Parameters

      • id: NodeId
      • modifiers: { ctrl: boolean; meta: boolean; shift: boolean }

      Returns void