@nextcloud/image-editor
    Preparing search index...

    Interface UseHistory<T>

    SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors SPDX-License-Identifier: AGPL-3.0-or-later

    interface UseHistory<T> {
        canRedo: ComputedRef<boolean>;
        canUndo: ComputedRef<boolean>;
        current: ComputedRef<T | undefined>;
        entries: ComputedRef<readonly HistoryEntry<T>[]>;
        index: ComputedRef<number>;
        clear(): void;
        jumpTo(target: number): T | undefined;
        push(snapshot: T, label?: string): void;
        redo(): T | undefined;
        undo(): T | undefined;
    }

    Type Parameters

    • T
    Index
    canRedo: ComputedRef<boolean>

    Whether a newer snapshot is available

    canUndo: ComputedRef<boolean>

    Whether an older snapshot is available

    current: ComputedRef<T | undefined>

    The active snapshot, undefined while the history is empty

    entries: ComputedRef<readonly HistoryEntry<T>[]>

    Every recorded step, oldest first

    index: ComputedRef<number>

    Position of the active step in entries, -1 while empty

    • Move to an arbitrary step and return its snapshot, or undefined where there is no such step or it is the active one already.

      Parameters

      • target: number

        position in entries

      Returns T | undefined

    • Append a snapshot after the active one, discarding any redoable entries.

      Parameters

      • snapshot: T

        the state to record

      • Optionallabel: string

        what the user did, for a history list

      Returns void

    • Move forward one snapshot and return it, or undefined at the newest entry

      Returns T | undefined

    • Move back one snapshot and return it, or undefined at the oldest entry

      Returns T | undefined