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

    Interface EditAnchorsDep

    Adapter dep for editAnchorsAction.

    Provides narrow read/write access to the editable polygon for a single node. Consumers register this dep so anchor-edit actions can read/write the polygon WITHOUT knowing whether it lives directly on the node's pose (pose.kind === 'polygon') or on node.data.path (the kit's built-in pen-tool default, also WeaselDraw's shape).

    Note on live previews: in-flight edit state is surfaced through the dispatcher's standard OngoingHandle.previewIds/previewPose/previewData triple (not this dep), so chrome and preview-ghost stay in lock-step via one source of truth.

    interface EditAnchorsDep {
        editingId: string;
        marquee: { height: number; width: number; x: number; y: number } | null;
        selectedAnchors: ReadonlySet<number>;
        applyEdit(id: string, worldPath: unknown, label: string): void;
        getEditablePath(id: string): unknown;
        getNodeShape(id: string): { data: unknown; pose: unknown } | null;
        getStorageKind(id: string): "data" | "pose" | null;
        setEditingId(id: string | null): void;
        setMarquee(
            rect: { height: number; width: number; x: number; y: number } | null,
        ): void;
        setSelectedAnchors(next: Iterable<number>): void;
    }
    Index

    Properties

    editingId: string

    Id of the node currently being edited. Empty string means no node is currently in edit mode — the chrome and gesture both opt out.

    marquee: { height: number; width: number; x: number; y: number } | null

    In-flight anchor-marquee rect in world coords, or null when no marquee drag is active. Written by marqueeAnchorsAction and read by the path-editing overlay — the same "ongoing action owns the preview, chrome just draws it" split the move/resize ghosts use.

    selectedAnchors: ReadonlySet<number>

    Anchors currently selected within the edited path, as flat anchor indices — the same numbering enumerateAnchors produces and the anchor:N affordance kinds carry.

    Selection is transient UI state, deliberately not part of the scene: it is cleared whenever editingId changes, and any edit that renumbers anchors (insert, delete) is responsible for leaving it coherent. Empty means "no anchor selected" — the keyboard actions (nudge, delete) no-op rather than acting on all anchors, matching Illustrator.

    Methods

    • Commit worldPath as the new value for id. Implementation routes to setPose (when pose IS the polygon) or batched setPose+update (when the polygon lives on data.path). Records one history entry labelled label.

      Parameters

      • id: string
      • worldPath: unknown
      • label: string

      Returns void

    • Returns the COMMITTED editable polygon in world coordinates, or null if this node has no editable polygon. Does NOT consult in- flight previews — callers that need live state read the dispatcher's in-flight handles.

      Parameters

      • id: string

      Returns unknown

    • Returns the node's raw pose and data so storage-aware actions can capture origin state at gesture-start and synthesize a matching previewPose / previewData during onMove. Used by editAnchorsAction for the data.path branch (rect pose + data carrying extra fields like fill / stroke that must be preserved through the preview). Returns null when the node is gone.

      Parameters

      • id: string

      Returns { data: unknown; pose: unknown } | null

    • Returns where the polygon is stored — 'pose' when node.pose IS the polygon, 'data' when it lives on node.data.path with a rect pose, or null when the node has no editable polygon. The action uses this to know which preview-ghost axis to populate (previewPose only / previewData + previewPose for data.path).

      Parameters

      • id: string

      Returns "data" | "pose" | null

    • Enter/exit edit mode for a specific node. Pass null (or an empty string) to exit. enterPathEditAction and exitPathEditAction call this; consumers can call it directly to drive edit mode programmatically.

      Parameters

      • id: string | null

      Returns void

    • Set or clear the in-flight marquee rect.

      Parameters

      • rect: { height: number; width: number; x: number; y: number } | null

      Returns void