threepipe
Version:
A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.
66 lines • 3.73 kB
TypeScript
import { AViewerPluginSync, ThreeViewer } from '../../viewer';
import { ActionUndoCommand, AnyFunction, JSUndoManager, PrimitiveVal, SetValueUndoCommand, SetValueUndoCommandProps } from 'ts-browser-helpers';
/**
* 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.
*/
export declare class UndoManagerPlugin extends AViewerPluginSync {
static readonly PluginType = "UndoManagerPlugin";
enabled: boolean;
undoManager?: JSUndoManager;
limit: number;
constructor(enabled?: boolean, limit?: number);
protected _refresh(): void;
toJSON: any;
onAdded(viewer: ThreeViewer): void;
onRemove(viewer: ThreeViewer): void;
undoEditingWaitTime: number;
recordUndo(com: SetValueUndoCommand | ActionUndoCommand): JSUndoManager | undefined;
/**
* Performs an action with undo/redo support.
* @param targ - the target object to call the action on
* @param action - a function that returns - 1. an undo function, 2. an object with undo and redo functions (and optional action)
* @param args - the arguments to pass to the action function
* @param uid - unique identifier for the command, not really used in actions
* @param onUndoRedo - optional callback function to be called on undo/redo of the command. Not called on first action execution, only on undo/redo.
*/
performAction<T extends AnyFunction>(targ: any | undefined, action: T, args: Parameters<T>, uid: any, onUndoRedo?: (c: ActionUndoCommand) => void): Promise<void>;
/**
* Sets a value in the target object with undo/redo support.
* @param binding - a tuple of target object and key to set the value on
* @param value - the value to set
* @param props - properties for the undo command, including last, and lastValue(optional)
* @param uid - unique identifier for the command, used to merge commands
* @param forceOnChange
* @param trackUndo - whether to track the undo command or not, defaults to true
* @param onUndoRedo - optional callback function to be called on undo/redo of the command
* @returns 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)
*/
setValue<T extends PrimitiveVal, T1 = any>(binding: [T1, keyof T1], value: T, props: SetValueUndoCommandProps<T>, uid?: any, forceOnChange?: boolean, trackUndo?: boolean, onUndoRedo?: (c: SetValueUndoCommand) => void): boolean;
setValues(bindings: [any, keyof any][], defs: any[], v: any[], props: SetValueUndoCommandProps<any>, uid?: any, forceOnChange?: boolean, trackUndo?: boolean, onUndoRedo?: (c: SetValueUndoCommand) => void): boolean;
readonly undoCommandTypes: {
readonly setValue: "ThreeViewerUM_set";
readonly action: "ThreeViewerUM_action";
};
undoPresets: {
ThreeViewerUM_set: (c: SetValueUndoCommand) => {
undo: () => void;
redo: () => void;
};
ThreeViewerUM_action: (c: ActionUndoCommand) => {
undo: () => Promise<void>;
redo: () => Promise<void>;
};
};
}
/**
* Creates a proxy for an array of bindings, allowing to access and set values in the target objects by editing the value.
* Useful for updating multiple properties in a single undo/redo command when dragging.
* @param bindings
* @param defs
*/
export declare function createBindingsProxy(bindings: [any, keyof any][], defs: any[]): {
p: any[];
value: any[];
};
//# sourceMappingURL=UndoManagerPlugin.d.ts.map