import { Canvas } from '../interfaces/canvas'; import { Point } from '../util/canvas-util'; import { DagaConnection, DagaNode } from './converters/daga-model'; import { DiagramConnectionType } from './model/diagram-connection'; import { DiagramNodeGeometry, DiagramNodeType } from './model/diagram-node'; /** * A stack of recent actions taken by the user. * @private */ export declare class ActionStack { #private; /** * Maximum number of actions that can be recorded simultaneously. * When new actions are added past this limit, older actions are removed. * @private */ maximum: number; /** * List of recorded actions, from oldest to newest. * @private */ history: DiagramAction[]; /** * Index of the last action not counting undone actions. One-indexed. Zero if all actions are undone. * @private */ index: number; constructor(canvas: Canvas, maximum: number); /** * Adds an action to the history. * @private */ add(action: DiagramAction): void; /** * Undoes the last action in the history, not counting undone actions. * @private */ undo(): void; /** * Redoes the last undone action in the history. * @private */ redo(): void; } /** * The different methods of an action. * @private */ export declare enum DiagramActionMethod { Do = 0, Undo = 1, Redo = 2 } /** * An action taken by the user that can be undone and redone and implies a change to the diagram's model. * Contrast with {@link DiagramEvent} which doesn't have an impact on the diagram's model. * @private */ export interface DiagramAction { /** * Perform this action on the diagram for the first time. * Performing the same action with the same parameters on a diagram with the same state should always result in the same changes to the state of the diagram. * * @returns `true` if doing the action had an effect on non-removed elements of the model, `false` otherwise. */ do(): boolean; /** * Undo the changes in the diagram caused by this action. * After having called `do()` followed by `undo()`, calling `redo()` followed by `undo()` any number of times should always result in no net changes to the state of the diagram. * * @returns `true` if undoing the action had an effect on non-removed elements of the model, `false` otherwise. */ undo(): boolean; /** * Redo the changes in the diagram caused by this action. * After having called `do()`, calling `undo()` followed by `redo()` any number of times should always result in no net changes to the state of the diagram. * `redo()` is usually equivalent to `do()`, but not always. * * @returns `true` if redoing the action had an effect on non-removed elements of the model, `false` otherwise. */ redo(): boolean; } /** * Enum listing the actions that can be taken by the user. * The actions can correspond to a DiagramAction that can be recorded in the action stack of a diagram or they may not correspond to any DiagramAction implementations. * @public */ export declare enum DiagramActions { /** * Action that corresponds to the addition of a connection. * @public * @see AddConnectionAction */ AddConnection = "add-connection", /** * Action that corresponds to the addition of a node. * @public * @see AddNodeAction */ AddNode = "add-node", /** * Action that corresponds to the addition or removal of sections in a node. * @public * @see AddSectionAction */ AddSectionAction = "add-section", /** * Action that corresponds to applying a layout which changes the location of several nodes. * @public * @see ApplyLayoutAction */ ApplyLayout = "apply-layout", /** * Action that corresponds to copying diagram elements to the clipboard. * @public */ Clipboard = "clipboard", /** * Action that corresponds to opening the context menu. * @public */ ContextMenu = "context-menu", /** * Action that corresponds to the edition of a field's text content. * @public * @see EditFieldAction */ EditField = "edit-field", /** * Action that corresponds to moving a node. * @public * @see MoveAction * @see SetGeometryAction */ MoveNode = "move-node", /** * Action that corresponds to pasting diagram elements from the clipboard. * @public * @see PasteAction */ Paste = "paste", /** * Action that corresponds to removing elements. * @public * @see RemoveAction */ Remove = "remove", /** * Action that corresponds to altering a node's dimensions. * @public * @see SetGeometryAction */ StretchNode = "stretch-node", /** * Action that corresponds to altering a sections's dimensions. * @public * @see SetGeometryAction */ StretchSection = "stretch-section", /** * Action that corresponds to changing the values of a value set. * @public * @see UpdateValuesAction */ UpdateValues = "update-values", /** * Action that corresponds to changing the view point of a diagram by zooming or panning. * @public */ Zoom = "zoom" } /** * Action which consists of adding a node. * @private * @see DiagramNode */ export declare class AddNodeAction implements DiagramAction { readonly canvas: Canvas; type: DiagramNodeType; coords: Point; parentId?: string; ancestorId?: string | undefined; fromAncestorGeometry?: DiagramNodeGeometry | undefined; toAncestorGeometry?: DiagramNodeGeometry | undefined; label?: string; values?: { [key: string]: unknown; }; id: string; constructor(canvas: Canvas, type: DiagramNodeType, coords: Point, parentId?: string, ancestorId?: string | undefined, fromAncestorGeometry?: DiagramNodeGeometry | undefined, toAncestorGeometry?: DiagramNodeGeometry | undefined, label?: string, values?: { [key: string]: unknown; }); do(): boolean; undo(): boolean; redo(): boolean; } /** * Action which consists of adding or removing sections in a node. * @private * @see DiagramSection */ export declare class AddSectionAction implements DiagramAction { readonly canvas: Canvas; nodeId: string; copyColumnIndex: number | undefined; copyRowIndex: number | undefined; removeColumnIndex: number | undefined; removeRowIndex: number | undefined; constructor(canvas: Canvas, nodeId: string, copyColumnIndex: number | undefined, copyRowIndex: number | undefined, removeColumnIndex: number | undefined, removeRowIndex: number | undefined); do(): boolean; undo(): boolean; redo(): boolean; } /** * Action which consists of applying a layout to the diagram which can change the location of several nodes. * @private */ export declare class ApplyLayoutAction implements DiagramAction { readonly canvas: Canvas; from: { [key: string]: Point; }; to: { [key: string]: Point; }; constructor(canvas: Canvas, from: { [key: string]: Point; }, to: { [key: string]: Point; }); do(): boolean; undo(): boolean; redo(): boolean; } /** * Action which consists of changing the coordinates of diagram elements by a fixed amount. * @private */ export declare class MoveAction implements DiagramAction { readonly canvas: Canvas; nodeIds: string[]; delta: Point; constructor(canvas: Canvas, nodeIds: string[], delta: Point); do(): boolean; undo(): boolean; redo(): boolean; } /** * Action which consists of changing a node's geometry: moving, stretching, or stretching sections. * @private * @see DiagramNode */ export declare class SetGeometryAction implements DiagramAction { readonly canvas: Canvas; intent: DiagramActions.MoveNode | DiagramActions.StretchNode | DiagramActions.StretchSection; nodeId: string; from: DiagramNodeGeometry; to: DiagramNodeGeometry; ancestorId: string | undefined; fromAncestorGeometry: DiagramNodeGeometry | undefined; toAncestorGeometry: DiagramNodeGeometry | undefined; constructor(canvas: Canvas, intent: DiagramActions.MoveNode | DiagramActions.StretchNode | DiagramActions.StretchSection, nodeId: string, from: DiagramNodeGeometry, to: DiagramNodeGeometry, ancestorId?: string | undefined, fromAncestorGeometry?: DiagramNodeGeometry | undefined, toAncestorGeometry?: DiagramNodeGeometry | undefined); do(): boolean; undo(): boolean; redo(): boolean; } /** * Action which consists of setting a node's parent. * @private */ export declare class SetParentAction implements DiagramAction { readonly canvas: Canvas; childId: string; fromParentId: string | undefined; toParentId: string | undefined; fromChildGeometry: DiagramNodeGeometry; toChildGeometry: DiagramNodeGeometry; ancestorId: string | undefined; fromAncestorGeometry: DiagramNodeGeometry | undefined; toAncestorGeometry: DiagramNodeGeometry | undefined; constructor(canvas: Canvas, childId: string, fromParentId: string | undefined, toParentId: string | undefined, fromChildGeometry: DiagramNodeGeometry, toChildGeometry: DiagramNodeGeometry, ancestorId: string | undefined, fromAncestorGeometry: DiagramNodeGeometry | undefined, toAncestorGeometry: DiagramNodeGeometry | undefined); do(): boolean; undo(): boolean; redo(): boolean; } /** * Action which consists of adding a connection. * @private * @see DiagramConnection */ export declare class AddConnectionAction implements DiagramAction { readonly canvas: Canvas; type: DiagramConnectionType; startId: string; endId: string; id: string; constructor(canvas: Canvas, type: DiagramConnectionType, startId: string, endId: string); do(): boolean; undo(): boolean; redo(): boolean; } /** * Action which consists of editing the text of a field. * @private * @see DiagramField */ export declare class EditFieldAction implements DiagramAction { readonly canvas: Canvas; fieldId: string; from: string; to: string; constructor(canvas: Canvas, fieldId: string, from: string, to: string); do(): boolean; undo(): boolean; redo(): boolean; } /** * Action which consists of editing the values of a value set. * @private * @see ValueSet */ export declare class UpdateValuesAction implements DiagramAction { readonly canvas: Canvas; id: string | undefined; from: { [key: string]: unknown; }; to: { [key: string]: unknown; }; constructor(canvas: Canvas, id: string | undefined, from: { [key: string]: unknown; }, to: { [key: string]: unknown; }); do(): boolean; undo(): boolean; redo(): boolean; } /** * Action which consists of removing elements from a diagram. * * You should only include an element in this action if the element itself is explicitly removed. * Elements removed as a consequence of a removing another element * (e.g., removing a node removes all of its sections) * will be handled automatically, in a way that converges in the case * of concurrent collaborative actions. * * @private */ export declare class RemoveAction implements DiagramAction { readonly canvas: Canvas; nodeIds: string[]; sectionIds: string[]; portIds: string[]; connectionIds: string[]; fieldIds: string[]; constructor(canvas: Canvas, nodeIds: string[], sectionIds: string[], portIds: string[], connectionIds: string[], fieldIds: string[]); do(): boolean; undo(): boolean; redo(): boolean; } /** * Action which consists of pasting elements from an external source into a diagram. * * @private */ export declare class PasteAction implements DiagramAction { readonly canvas: Canvas; nodes: DagaNode[]; connections: DagaConnection[]; coords?: Point; constructor(canvas: Canvas, nodes: DagaNode[], connections: DagaConnection[], coords?: Point); do(): boolean; undo(): boolean; redo(): boolean; }