Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TransactionHandler

Hierarchy

Index

Constructors

constructor

Properties

Private Readonly MAX_HISTORY_SIZE

MAX_HISTORY_SIZE: 30 = 30

active

active: boolean = false

Protected canvas

canvas: FabricCanvas

Private currentObjects

currentObjects: FabricObject[] = []

Protected handler

handler: Handler

Private latestNodeSticky

latestNodeSticky: Map<string, {}> = new Map<string, StickyNodeFields>()

redo

redo: DebouncedFuncLeading<(Anonymous function)> = throttle(() => {const redo = this.redos.pop();if (!redo) return;try {this.undos.push({type: 'undo',json: JSON.stringify(this.currentObjects),});this.replay(redo);} catch (error) {console.error('[TransactionHandler] Redo failed:', error);}}, 100)

Redo transaction

redos

undo

undo: DebouncedFuncLeading<(Anonymous function)> = throttle(() => {const undo = this.undos.pop();if (!undo) return;try {this.redos.push({type: 'redo',json: JSON.stringify(this.currentObjects),});this.replay(undo);} catch (error) {console.error('[TransactionHandler] Undo failed:', error);}}, 100)

Undo transaction

undos

Methods

Private applyLatestStickyToSnapshot

  • applyLatestStickyToSnapshot(objects: FabricObject[]): void

canRedo

  • canRedo(): boolean

canUndo

  • canUndo(): boolean

Private captureLatestStickyFromSnapshot

  • captureLatestStickyFromSnapshot(objects: FabricObject[], nodeId?: string): void
  • Capture sticky fields from a snapshot. If nodeId is provided, capture only that node.

    NOTE: We use "field" in obj to allow clearing values (setting undefined/null) while still being captured/applied consistently.

    Parameters

    Returns void

Private cloneDeep

  • cloneDeep<T>(v: T): T

Protected initialize

  • initialize(): void

Private normalizeObjects

replay

save

  • Save transaction

    Rules:

    • type === 'configuration': update sticky cache (configuration/name/description) and DO NOT push to undos/redos (NOT part of undo/redo), and DO NOT clear redo stack (redo remains possible).
    • other types: normal history behavior (push to undos, clear redos).

    Parameters

    Returns void

setDefaultObjects

Private sortObjects

  • sortObjects(objects: FabricObject[]): (Object & IObjectOptions & { animating?: boolean; animation?: AnimationProperty; anime?: AnimeInstance; class?: string; clickable?: boolean; cloneable?: boolean; dblclick?: boolean; deletable?: boolean; description?: string; editable?: boolean; id?: string; link?: LinkProperty; locked?: boolean; originAngle?: number; originFill?: string | Pattern | Gradient; originLeft?: number; originOpacity?: number; originRotation?: number; originScaleX?: number; originScaleY?: number; originStroke?: string; originTop?: number; parentId?: string; rotation?: number; superType?: string; tooltip?: TooltipProperty })[]
  • Parameters

    Returns (Object & IObjectOptions & { animating?: boolean; animation?: AnimationProperty; anime?: AnimeInstance; class?: string; clickable?: boolean; cloneable?: boolean; dblclick?: boolean; deletable?: boolean; description?: string; editable?: boolean; id?: string; link?: LinkProperty; locked?: boolean; originAngle?: number; originFill?: string | Pattern | Gradient; originLeft?: number; originOpacity?: number; originRotation?: number; originScaleX?: number; originScaleY?: number; originStroke?: string; originTop?: number; parentId?: string; rotation?: number; superType?: string; tooltip?: TooltipProperty })[]

Generated using TypeDoc