ThreePipe
    Preparing search index...

    Class UndoManagerPlugin

    UndoManagerPlugin is a plugin for ThreeViewer that provides undo/redo functionality. It uses the JSUndoManager(from ts-browser-helpers) library to maintain a common undo/redo history across the viewer and other plugins.

    Hierarchy (View Summary)

    Index
    _dirty: boolean = false
    _viewer?: ThreeViewer
    _viewerListeners: PartialRecord<IViewerEventTypes, (e: IViewerEvent) => void> = {}
    actions: ViewerAction[] = ...

    Undo and Redo as actions (registered in viewer.actions, where a UI lists them and the app changes their keys): Mod+Z undoes, Mod+Shift+Z and Mod+Y redo (Mod: Cmd on a Mac, Ctrl on other platforms). The keys are letters, as in other apps: they follow the printed key on any layout (the Z key of a German keyboard is at the place of Y). A held key repeats them. A key typed in a text field is left to the field, for its own text undo; a checkbox or a button has no text, so the key undoes there. The keys do nothing while the plugin is disabled.

    constructor: typeof AViewerPluginSync & typeof AViewerPlugin
    enabled: boolean = true
    isViewerPluginSync: true = ...
    limit: number = 1000
    toJSON: any = undefined
    uiConfig?: UiObjectConfig<any, string, any> = undefined
    undoCommandTypes: {
        action: "ThreeViewerUM_action";
        setValue: "ThreeViewerUM_set";
    } = ...
    undoEditingWaitTime: number = 2000
    undoManager?: JSUndoManager
    undoPresets: {
        ThreeViewerUM_action: (
            c: ActionUndoCommand,
        ) => { redo: () => Promise<void>; undo: () => Promise<void> };
        ThreeViewerUM_set: (
            c: SetValueUndoCommand,
        ) => { redo: () => void; undo: () => void };
    } = ...
    OldPluginType?: string
    PluginType: "UndoManagerPlugin" = 'UndoManagerPlugin'
    • Performs an action with undo/redo support.

      Type Parameters

      Parameters

      • targ: any

        the target object to call the action on

      • action: T

        a function that returns - 1. an undo function, 2. an object with undo and redo functions (and optional action)

      • args: Parameters<T>

        the arguments to pass to the action function

      • uid: any

        unique identifier for the command, not really used in actions

      • OptionalonUndoRedo: (c: ActionUndoCommand) => void

        optional callback function to be called on undo/redo of the command. Not called on first action execution, only on undo/redo.

      Returns Promise<void>

    • Sets a value in the target object with undo/redo support.

      Type Parameters

      Parameters

      • binding: [T1, keyof T1]

        a tuple of target object and key to set the value on

      • value: T

        the value to set

      • props: SetValueUndoCommandProps<T>

        properties for the undo command, including last, and lastValue(optional)

      • Optionaluid: any

        unique identifier for the command, used to merge commands

      • OptionalforceOnChange: boolean
      • trackUndo: boolean = true

        whether to track the undo command or not, defaults to true

      • OptionalonUndoRedo: (c: SetValueUndoCommand) => void

        optional callback function to be called on undo/redo of the command

      Returns boolean

      true if the value was set and the command was recorded, false if the command was not recorded (e.g. if it was not undoable or forceOnChange was false)