@leapfrog/interactive-canvas 1.11.2 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abstract-interactive-canvas.d.ts +5 -0
- package/dist/interactive-canvas.d.ts +5 -0
- package/dist/interactive-canvas.es.js +181 -121
- package/dist/interactive-canvas.interface.d.ts +4 -0
- package/dist/interactive-canvas.js +181 -121
- package/dist/undo-stack.d.ts +9 -4
- package/package.json +1 -1
|
@@ -304,6 +304,11 @@ export declare abstract class AbstractInteractiveCanvas implements IInteractiveC
|
|
|
304
304
|
* @inheritDoc
|
|
305
305
|
*/
|
|
306
306
|
undo(): Promise<void>;
|
|
307
|
+
/**
|
|
308
|
+
* @override
|
|
309
|
+
* @inheritDoc
|
|
310
|
+
*/
|
|
311
|
+
redo(): Promise<void>;
|
|
307
312
|
/**
|
|
308
313
|
* Redraw the canvas.
|
|
309
314
|
*/
|
|
@@ -13,6 +13,11 @@ export declare class InteractiveCanvas extends AbstractInteractiveCanvas {
|
|
|
13
13
|
* @inheritDoc
|
|
14
14
|
*/
|
|
15
15
|
undo(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* @override
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
redo(): Promise<void>;
|
|
16
21
|
private onFabricSelectionChanged;
|
|
17
22
|
private enterTextSelectionModeIfRequired;
|
|
18
23
|
private onTextEditing;
|
|
@@ -284,63 +284,6 @@ var RedrawAllLayoutFunction = /** @class */ (function () {
|
|
|
284
284
|
return RedrawAllLayoutFunction;
|
|
285
285
|
}());
|
|
286
286
|
|
|
287
|
-
var RepositionCutoffsLayoutFunction = /** @class */ (function () {
|
|
288
|
-
function RepositionCutoffsLayoutFunction() {
|
|
289
|
-
}
|
|
290
|
-
RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
|
|
291
|
-
canvas.getObjectsByTypeInternal(ObjectType.CUTOFF)
|
|
292
|
-
.forEach(function (cutoff) { return cutoff.updatePosition(); });
|
|
293
|
-
};
|
|
294
|
-
return RepositionCutoffsLayoutFunction;
|
|
295
|
-
}());
|
|
296
|
-
|
|
297
|
-
var RepositionBordersLayoutFunction = /** @class */ (function () {
|
|
298
|
-
function RepositionBordersLayoutFunction() {
|
|
299
|
-
}
|
|
300
|
-
RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
|
|
301
|
-
canvas.getObjectsByTypeInternal(ObjectType.BORDER)
|
|
302
|
-
.forEach(function (border) { return border.updatePosition(); });
|
|
303
|
-
};
|
|
304
|
-
return RepositionBordersLayoutFunction;
|
|
305
|
-
}());
|
|
306
|
-
|
|
307
|
-
var PinToBottomLayoutFunction = /** @class */ (function () {
|
|
308
|
-
function PinToBottomLayoutFunction() {
|
|
309
|
-
}
|
|
310
|
-
PinToBottomLayoutFunction.prototype.execute = function (canvas) {
|
|
311
|
-
canvas.getObjectsInternal()
|
|
312
|
-
.forEach(function (object) { return object.moveToPinnedPosition(); });
|
|
313
|
-
};
|
|
314
|
-
return PinToBottomLayoutFunction;
|
|
315
|
-
}());
|
|
316
|
-
|
|
317
|
-
var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
318
|
-
function ResizeCanvasLayoutFunction() {
|
|
319
|
-
}
|
|
320
|
-
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
321
|
-
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
322
|
-
return;
|
|
323
|
-
if (oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
324
|
-
return;
|
|
325
|
-
var currentDimensions = canvas.getDimensions();
|
|
326
|
-
var baseDimensions = canvas.getBaseDimensions();
|
|
327
|
-
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(ObjectType.TEXT))
|
|
328
|
-
.filter(function (text) { return text.isResizeCanvas(); })
|
|
329
|
-
.reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
|
|
330
|
-
var increase = baseDimensions.withSize(currentDimensions.width, 0);
|
|
331
|
-
while (increase.heightPx < textHeightIncreasePx) {
|
|
332
|
-
increase = increase.withSize(increase.width, increase.height + 1);
|
|
333
|
-
}
|
|
334
|
-
var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
|
|
335
|
-
if (currentDimensions.height !== targetHeight.height) {
|
|
336
|
-
canvas.setDimensions(targetHeight);
|
|
337
|
-
}
|
|
338
|
-
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
339
|
-
canvas.redraw();
|
|
340
|
-
};
|
|
341
|
-
return ResizeCanvasLayoutFunction;
|
|
342
|
-
}());
|
|
343
|
-
|
|
344
287
|
var LayoutManager;
|
|
345
288
|
(function (LayoutManager) {
|
|
346
289
|
LayoutManager["LEGACY"] = "LEGACY";
|
|
@@ -348,45 +291,6 @@ var LayoutManager;
|
|
|
348
291
|
LayoutManager["ADVANCED"] = "ADVANCED";
|
|
349
292
|
})(LayoutManager || (LayoutManager = {}));
|
|
350
293
|
|
|
351
|
-
var RepositionBackgroundsLayoutFunction = /** @class */ (function () {
|
|
352
|
-
function RepositionBackgroundsLayoutFunction() {
|
|
353
|
-
}
|
|
354
|
-
RepositionBackgroundsLayoutFunction.prototype.execute = function (canvas) {
|
|
355
|
-
canvas.getObjectsByTypeInternal(ObjectType.BACKGROUND_IMAGE)
|
|
356
|
-
.forEach(function (border) { return border.updatePosition(); });
|
|
357
|
-
};
|
|
358
|
-
return RepositionBackgroundsLayoutFunction;
|
|
359
|
-
}());
|
|
360
|
-
|
|
361
|
-
var AdvancedLayoutManager = /** @class */ (function (_super) {
|
|
362
|
-
__extends(AdvancedLayoutManager, _super);
|
|
363
|
-
function AdvancedLayoutManager(canvas) {
|
|
364
|
-
var _this = _super.call(this, canvas) || this;
|
|
365
|
-
_this.key = LayoutManager.ADVANCED;
|
|
366
|
-
_this.pinToBottom = new PinToBottomLayoutFunction();
|
|
367
|
-
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
368
|
-
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
369
|
-
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
370
|
-
_this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
|
|
371
|
-
_this.resizeCanvas = new ResizeCanvasLayoutFunction();
|
|
372
|
-
return _this;
|
|
373
|
-
}
|
|
374
|
-
AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
375
|
-
this.pinToBottom.execute(this.canvas);
|
|
376
|
-
this.repositionCutoffs.execute(this.canvas);
|
|
377
|
-
this.repositionBorders.execute(this.canvas);
|
|
378
|
-
this.repositionBackgrounds.execute(this.canvas);
|
|
379
|
-
this.redrawAll.execute(this.canvas);
|
|
380
|
-
};
|
|
381
|
-
AdvancedLayoutManager.prototype.onTextChange = function () {
|
|
382
|
-
this.resizeCanvas.execute(this.canvas);
|
|
383
|
-
};
|
|
384
|
-
AdvancedLayoutManager.prototype.onObjectListChange = function () {
|
|
385
|
-
this.redrawAll.execute(this.canvas);
|
|
386
|
-
};
|
|
387
|
-
return AdvancedLayoutManager;
|
|
388
|
-
}(AbstractLayoutManager));
|
|
389
|
-
|
|
390
294
|
var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
|
|
391
295
|
function UpdateObjectDimensionsLayoutFunction() {
|
|
392
296
|
}
|
|
@@ -550,6 +454,26 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
550
454
|
return StackObjectsLayoutFunction;
|
|
551
455
|
}());
|
|
552
456
|
|
|
457
|
+
var RepositionBordersLayoutFunction = /** @class */ (function () {
|
|
458
|
+
function RepositionBordersLayoutFunction() {
|
|
459
|
+
}
|
|
460
|
+
RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
|
|
461
|
+
canvas.getObjectsByTypeInternal(ObjectType.BORDER)
|
|
462
|
+
.forEach(function (border) { return border.updatePosition(); });
|
|
463
|
+
};
|
|
464
|
+
return RepositionBordersLayoutFunction;
|
|
465
|
+
}());
|
|
466
|
+
|
|
467
|
+
var RepositionBackgroundsLayoutFunction = /** @class */ (function () {
|
|
468
|
+
function RepositionBackgroundsLayoutFunction() {
|
|
469
|
+
}
|
|
470
|
+
RepositionBackgroundsLayoutFunction.prototype.execute = function (canvas) {
|
|
471
|
+
canvas.getObjectsByTypeInternal(ObjectType.BACKGROUND_IMAGE)
|
|
472
|
+
.forEach(function (border) { return border.updatePosition(); });
|
|
473
|
+
};
|
|
474
|
+
return RepositionBackgroundsLayoutFunction;
|
|
475
|
+
}());
|
|
476
|
+
|
|
553
477
|
var StandardLayoutManager = /** @class */ (function (_super) {
|
|
554
478
|
__extends(StandardLayoutManager, _super);
|
|
555
479
|
function StandardLayoutManager(canvas) {
|
|
@@ -2612,7 +2536,7 @@ var DefaultCanvasProfile = /** @class */ (function () {
|
|
|
2612
2536
|
this.allowRotate = false;
|
|
2613
2537
|
this.allowScale = false;
|
|
2614
2538
|
this.defaultFont = "Lato";
|
|
2615
|
-
this.defaultFontSize =
|
|
2539
|
+
this.defaultFontSize = 9;
|
|
2616
2540
|
this.defaultFontColor = "#000000";
|
|
2617
2541
|
this.defaultLineHeight = 1.8;
|
|
2618
2542
|
this.defaultCharacterSpacing = 0;
|
|
@@ -3428,6 +3352,13 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3428
3352
|
AbstractInteractiveCanvas.prototype.undo = function () {
|
|
3429
3353
|
throw Error("Undo not supported on this canvas type");
|
|
3430
3354
|
};
|
|
3355
|
+
/**
|
|
3356
|
+
* @override
|
|
3357
|
+
* @inheritDoc
|
|
3358
|
+
*/
|
|
3359
|
+
AbstractInteractiveCanvas.prototype.redo = function () {
|
|
3360
|
+
throw Error("Redo not supported on this canvas type");
|
|
3361
|
+
};
|
|
3431
3362
|
/**
|
|
3432
3363
|
* Redraw the canvas.
|
|
3433
3364
|
*/
|
|
@@ -3643,20 +3574,68 @@ var HeadlessInteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3643
3574
|
}(AbstractInteractiveCanvas));
|
|
3644
3575
|
|
|
3645
3576
|
var UndoStack = /** @class */ (function () {
|
|
3646
|
-
function UndoStack(size) {
|
|
3647
|
-
|
|
3577
|
+
function UndoStack(canvas, size) {
|
|
3578
|
+
if (size === void 0) { size = 100; }
|
|
3579
|
+
this.canvas = canvas;
|
|
3580
|
+
this.undoStates = [];
|
|
3581
|
+
this.redoStates = [];
|
|
3582
|
+
this.lastUndo = null;
|
|
3648
3583
|
this.size = size;
|
|
3649
3584
|
}
|
|
3650
|
-
UndoStack.prototype.
|
|
3651
|
-
var
|
|
3652
|
-
|
|
3585
|
+
UndoStack.prototype.save = function (state) {
|
|
3586
|
+
var currentState = this.canvas.save();
|
|
3587
|
+
var undoState = this.undoStates[this.undoStates.length - 1];
|
|
3588
|
+
if (isEqual(undoState, state))
|
|
3653
3589
|
return;
|
|
3654
|
-
this.
|
|
3655
|
-
if (this.
|
|
3656
|
-
this.
|
|
3590
|
+
this.undoStates.push(state);
|
|
3591
|
+
if (this.undoStates.length > this.size)
|
|
3592
|
+
this.undoStates.splice(0, 1);
|
|
3593
|
+
if (!isEqual(this.lastUndo, currentState))
|
|
3594
|
+
this.redoStates = [];
|
|
3657
3595
|
};
|
|
3658
|
-
UndoStack.prototype.
|
|
3659
|
-
return this
|
|
3596
|
+
UndoStack.prototype.undo = function () {
|
|
3597
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3598
|
+
var undoState, currentState;
|
|
3599
|
+
return __generator(this, function (_a) {
|
|
3600
|
+
switch (_a.label) {
|
|
3601
|
+
case 0:
|
|
3602
|
+
undoState = this.undoStates.pop();
|
|
3603
|
+
if (!undoState)
|
|
3604
|
+
return [2 /*return*/];
|
|
3605
|
+
currentState = this.canvas.save();
|
|
3606
|
+
if (isEqual(undoState, currentState)) {
|
|
3607
|
+
undoState = this.undoStates.pop();
|
|
3608
|
+
if (!undoState)
|
|
3609
|
+
return [2 /*return*/];
|
|
3610
|
+
}
|
|
3611
|
+
this.lastUndo = undoState;
|
|
3612
|
+
this.redoStates.push(currentState);
|
|
3613
|
+
return [4 /*yield*/, this.canvas.load(undoState)];
|
|
3614
|
+
case 1:
|
|
3615
|
+
_a.sent();
|
|
3616
|
+
return [2 /*return*/];
|
|
3617
|
+
}
|
|
3618
|
+
});
|
|
3619
|
+
});
|
|
3620
|
+
};
|
|
3621
|
+
UndoStack.prototype.redo = function () {
|
|
3622
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3623
|
+
var state, currentState;
|
|
3624
|
+
return __generator(this, function (_a) {
|
|
3625
|
+
switch (_a.label) {
|
|
3626
|
+
case 0:
|
|
3627
|
+
state = this.redoStates.pop();
|
|
3628
|
+
if (!state)
|
|
3629
|
+
return [2 /*return*/];
|
|
3630
|
+
currentState = this.canvas.save();
|
|
3631
|
+
this.undoStates.push(currentState);
|
|
3632
|
+
return [4 /*yield*/, this.canvas.load(state)];
|
|
3633
|
+
case 1:
|
|
3634
|
+
_a.sent();
|
|
3635
|
+
return [2 /*return*/];
|
|
3636
|
+
}
|
|
3637
|
+
});
|
|
3638
|
+
});
|
|
3660
3639
|
};
|
|
3661
3640
|
return UndoStack;
|
|
3662
3641
|
}());
|
|
@@ -3666,7 +3645,7 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3666
3645
|
function InteractiveCanvas(elementId, devicePixelRatio) {
|
|
3667
3646
|
var _this = _super.call(this, window['fabric'], new window['fabric'].Canvas(elementId), devicePixelRatio) || this;
|
|
3668
3647
|
_this.devicePixelRatio = devicePixelRatio;
|
|
3669
|
-
_this.undoStack = new UndoStack(
|
|
3648
|
+
_this.undoStack = new UndoStack(_this);
|
|
3670
3649
|
//Initialize watchers
|
|
3671
3650
|
_this.fabricCanvas.on("selection:updated", function () { return _this.onFabricSelectionChanged(); });
|
|
3672
3651
|
_this.fabricCanvas.on("selection:created", function () { return _this.onFabricSelectionChanged(); });
|
|
@@ -3681,7 +3660,7 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3681
3660
|
* @inheritDoc
|
|
3682
3661
|
*/
|
|
3683
3662
|
InteractiveCanvas.prototype.registerUndoState = function () {
|
|
3684
|
-
this.undoStack.
|
|
3663
|
+
this.undoStack.save(this.save());
|
|
3685
3664
|
};
|
|
3686
3665
|
/**
|
|
3687
3666
|
* @override
|
|
@@ -3689,20 +3668,25 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3689
3668
|
*/
|
|
3690
3669
|
InteractiveCanvas.prototype.undo = function () {
|
|
3691
3670
|
return __awaiter(this, void 0, void 0, function () {
|
|
3692
|
-
var state;
|
|
3693
3671
|
return __generator(this, function (_a) {
|
|
3694
3672
|
switch (_a.label) {
|
|
3695
|
-
case 0:
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3673
|
+
case 0: return [4 /*yield*/, this.undoStack.undo()];
|
|
3674
|
+
case 1:
|
|
3675
|
+
_a.sent();
|
|
3676
|
+
return [2 /*return*/];
|
|
3677
|
+
}
|
|
3678
|
+
});
|
|
3679
|
+
});
|
|
3680
|
+
};
|
|
3681
|
+
/**
|
|
3682
|
+
* @override
|
|
3683
|
+
* @inheritDoc
|
|
3684
|
+
*/
|
|
3685
|
+
InteractiveCanvas.prototype.redo = function () {
|
|
3686
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3687
|
+
return __generator(this, function (_a) {
|
|
3688
|
+
switch (_a.label) {
|
|
3689
|
+
case 0: return [4 /*yield*/, this.undoStack.redo()];
|
|
3706
3690
|
case 1:
|
|
3707
3691
|
_a.sent();
|
|
3708
3692
|
return [2 /*return*/];
|
|
@@ -3731,4 +3715,80 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3731
3715
|
return InteractiveCanvas;
|
|
3732
3716
|
}(AbstractInteractiveCanvas));
|
|
3733
3717
|
|
|
3718
|
+
var RepositionCutoffsLayoutFunction = /** @class */ (function () {
|
|
3719
|
+
function RepositionCutoffsLayoutFunction() {
|
|
3720
|
+
}
|
|
3721
|
+
RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
|
|
3722
|
+
canvas.getObjectsByTypeInternal(ObjectType.CUTOFF)
|
|
3723
|
+
.forEach(function (cutoff) { return cutoff.updatePosition(); });
|
|
3724
|
+
};
|
|
3725
|
+
return RepositionCutoffsLayoutFunction;
|
|
3726
|
+
}());
|
|
3727
|
+
|
|
3728
|
+
var PinToBottomLayoutFunction = /** @class */ (function () {
|
|
3729
|
+
function PinToBottomLayoutFunction() {
|
|
3730
|
+
}
|
|
3731
|
+
PinToBottomLayoutFunction.prototype.execute = function (canvas) {
|
|
3732
|
+
canvas.getObjectsInternal()
|
|
3733
|
+
.forEach(function (object) { return object.moveToPinnedPosition(); });
|
|
3734
|
+
};
|
|
3735
|
+
return PinToBottomLayoutFunction;
|
|
3736
|
+
}());
|
|
3737
|
+
|
|
3738
|
+
var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
3739
|
+
function ResizeCanvasLayoutFunction() {
|
|
3740
|
+
}
|
|
3741
|
+
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
3742
|
+
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
3743
|
+
return;
|
|
3744
|
+
if (oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
3745
|
+
return;
|
|
3746
|
+
var currentDimensions = canvas.getDimensions();
|
|
3747
|
+
var baseDimensions = canvas.getBaseDimensions();
|
|
3748
|
+
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(ObjectType.TEXT))
|
|
3749
|
+
.filter(function (text) { return text.isResizeCanvas(); })
|
|
3750
|
+
.reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
|
|
3751
|
+
var increase = baseDimensions.withSize(currentDimensions.width, 0);
|
|
3752
|
+
while (increase.heightPx < textHeightIncreasePx) {
|
|
3753
|
+
increase = increase.withSize(increase.width, increase.height + 1);
|
|
3754
|
+
}
|
|
3755
|
+
var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
|
|
3756
|
+
if (currentDimensions.height !== targetHeight.height) {
|
|
3757
|
+
canvas.setDimensions(targetHeight);
|
|
3758
|
+
}
|
|
3759
|
+
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
3760
|
+
canvas.redraw();
|
|
3761
|
+
};
|
|
3762
|
+
return ResizeCanvasLayoutFunction;
|
|
3763
|
+
}());
|
|
3764
|
+
|
|
3765
|
+
var AdvancedLayoutManager = /** @class */ (function (_super) {
|
|
3766
|
+
__extends(AdvancedLayoutManager, _super);
|
|
3767
|
+
function AdvancedLayoutManager(canvas) {
|
|
3768
|
+
var _this = _super.call(this, canvas) || this;
|
|
3769
|
+
_this.key = LayoutManager.ADVANCED;
|
|
3770
|
+
_this.pinToBottom = new PinToBottomLayoutFunction();
|
|
3771
|
+
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
3772
|
+
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
3773
|
+
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
3774
|
+
_this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
|
|
3775
|
+
_this.resizeCanvas = new ResizeCanvasLayoutFunction();
|
|
3776
|
+
return _this;
|
|
3777
|
+
}
|
|
3778
|
+
AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
3779
|
+
this.pinToBottom.execute(this.canvas);
|
|
3780
|
+
this.repositionCutoffs.execute(this.canvas);
|
|
3781
|
+
this.repositionBorders.execute(this.canvas);
|
|
3782
|
+
this.repositionBackgrounds.execute(this.canvas);
|
|
3783
|
+
this.redrawAll.execute(this.canvas);
|
|
3784
|
+
};
|
|
3785
|
+
AdvancedLayoutManager.prototype.onTextChange = function () {
|
|
3786
|
+
this.resizeCanvas.execute(this.canvas);
|
|
3787
|
+
};
|
|
3788
|
+
AdvancedLayoutManager.prototype.onObjectListChange = function () {
|
|
3789
|
+
this.redrawAll.execute(this.canvas);
|
|
3790
|
+
};
|
|
3791
|
+
return AdvancedLayoutManager;
|
|
3792
|
+
}(AbstractLayoutManager));
|
|
3793
|
+
|
|
3734
3794
|
export { AbstractCanvasObject, AbstractInteractiveCanvas, AbstractLayoutManager, AdvancedLayoutManager, BackgroundImage, Border, CanvasObjectData, Cutoff, DefaultCanvasProfile, Font, FontLibrary, HeadlessInteractiveCanvas, HorizontalRule, Image, ImageType, InteractiveCanvas, LayoutManager, MillimeterDimensions, ObjectType, PixelCanvasDimensions, Print6ColCanvasDimensions, Print8ColCanvasDimensions, Rectangle, RichText, SelectionData, StandardLayoutManager, Text, UNKNOWN_FONT, UnknownFont, VerticalRule, isMutableBackgroundColor, isMutableColor, isMutableImage, isMutablePosition, isMutableStroke, isMutableText, isMutableTextStyle };
|
|
@@ -287,108 +287,12 @@ var RedrawAllLayoutFunction = /** @class */ (function () {
|
|
|
287
287
|
return RedrawAllLayoutFunction;
|
|
288
288
|
}());
|
|
289
289
|
|
|
290
|
-
var RepositionCutoffsLayoutFunction = /** @class */ (function () {
|
|
291
|
-
function RepositionCutoffsLayoutFunction() {
|
|
292
|
-
}
|
|
293
|
-
RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
|
|
294
|
-
canvas.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
|
|
295
|
-
.forEach(function (cutoff) { return cutoff.updatePosition(); });
|
|
296
|
-
};
|
|
297
|
-
return RepositionCutoffsLayoutFunction;
|
|
298
|
-
}());
|
|
299
|
-
|
|
300
|
-
var RepositionBordersLayoutFunction = /** @class */ (function () {
|
|
301
|
-
function RepositionBordersLayoutFunction() {
|
|
302
|
-
}
|
|
303
|
-
RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
|
|
304
|
-
canvas.getObjectsByTypeInternal(exports.ObjectType.BORDER)
|
|
305
|
-
.forEach(function (border) { return border.updatePosition(); });
|
|
306
|
-
};
|
|
307
|
-
return RepositionBordersLayoutFunction;
|
|
308
|
-
}());
|
|
309
|
-
|
|
310
|
-
var PinToBottomLayoutFunction = /** @class */ (function () {
|
|
311
|
-
function PinToBottomLayoutFunction() {
|
|
312
|
-
}
|
|
313
|
-
PinToBottomLayoutFunction.prototype.execute = function (canvas) {
|
|
314
|
-
canvas.getObjectsInternal()
|
|
315
|
-
.forEach(function (object) { return object.moveToPinnedPosition(); });
|
|
316
|
-
};
|
|
317
|
-
return PinToBottomLayoutFunction;
|
|
318
|
-
}());
|
|
319
|
-
|
|
320
|
-
var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
321
|
-
function ResizeCanvasLayoutFunction() {
|
|
322
|
-
}
|
|
323
|
-
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
324
|
-
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
325
|
-
return;
|
|
326
|
-
if (tsOptchain.oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
327
|
-
return;
|
|
328
|
-
var currentDimensions = canvas.getDimensions();
|
|
329
|
-
var baseDimensions = canvas.getBaseDimensions();
|
|
330
|
-
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
|
|
331
|
-
.filter(function (text) { return text.isResizeCanvas(); })
|
|
332
|
-
.reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
|
|
333
|
-
var increase = baseDimensions.withSize(currentDimensions.width, 0);
|
|
334
|
-
while (increase.heightPx < textHeightIncreasePx) {
|
|
335
|
-
increase = increase.withSize(increase.width, increase.height + 1);
|
|
336
|
-
}
|
|
337
|
-
var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
|
|
338
|
-
if (currentDimensions.height !== targetHeight.height) {
|
|
339
|
-
canvas.setDimensions(targetHeight);
|
|
340
|
-
}
|
|
341
|
-
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
342
|
-
canvas.redraw();
|
|
343
|
-
};
|
|
344
|
-
return ResizeCanvasLayoutFunction;
|
|
345
|
-
}());
|
|
346
|
-
|
|
347
290
|
(function (LayoutManager) {
|
|
348
291
|
LayoutManager["LEGACY"] = "LEGACY";
|
|
349
292
|
LayoutManager["STANDARD"] = "STANDARD";
|
|
350
293
|
LayoutManager["ADVANCED"] = "ADVANCED";
|
|
351
294
|
})(exports.LayoutManager || (exports.LayoutManager = {}));
|
|
352
295
|
|
|
353
|
-
var RepositionBackgroundsLayoutFunction = /** @class */ (function () {
|
|
354
|
-
function RepositionBackgroundsLayoutFunction() {
|
|
355
|
-
}
|
|
356
|
-
RepositionBackgroundsLayoutFunction.prototype.execute = function (canvas) {
|
|
357
|
-
canvas.getObjectsByTypeInternal(exports.ObjectType.BACKGROUND_IMAGE)
|
|
358
|
-
.forEach(function (border) { return border.updatePosition(); });
|
|
359
|
-
};
|
|
360
|
-
return RepositionBackgroundsLayoutFunction;
|
|
361
|
-
}());
|
|
362
|
-
|
|
363
|
-
var AdvancedLayoutManager = /** @class */ (function (_super) {
|
|
364
|
-
__extends(AdvancedLayoutManager, _super);
|
|
365
|
-
function AdvancedLayoutManager(canvas) {
|
|
366
|
-
var _this = _super.call(this, canvas) || this;
|
|
367
|
-
_this.key = exports.LayoutManager.ADVANCED;
|
|
368
|
-
_this.pinToBottom = new PinToBottomLayoutFunction();
|
|
369
|
-
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
370
|
-
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
371
|
-
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
372
|
-
_this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
|
|
373
|
-
_this.resizeCanvas = new ResizeCanvasLayoutFunction();
|
|
374
|
-
return _this;
|
|
375
|
-
}
|
|
376
|
-
AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
377
|
-
this.pinToBottom.execute(this.canvas);
|
|
378
|
-
this.repositionCutoffs.execute(this.canvas);
|
|
379
|
-
this.repositionBorders.execute(this.canvas);
|
|
380
|
-
this.repositionBackgrounds.execute(this.canvas);
|
|
381
|
-
this.redrawAll.execute(this.canvas);
|
|
382
|
-
};
|
|
383
|
-
AdvancedLayoutManager.prototype.onTextChange = function () {
|
|
384
|
-
this.resizeCanvas.execute(this.canvas);
|
|
385
|
-
};
|
|
386
|
-
AdvancedLayoutManager.prototype.onObjectListChange = function () {
|
|
387
|
-
this.redrawAll.execute(this.canvas);
|
|
388
|
-
};
|
|
389
|
-
return AdvancedLayoutManager;
|
|
390
|
-
}(AbstractLayoutManager));
|
|
391
|
-
|
|
392
296
|
var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
|
|
393
297
|
function UpdateObjectDimensionsLayoutFunction() {
|
|
394
298
|
}
|
|
@@ -552,6 +456,26 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
552
456
|
return StackObjectsLayoutFunction;
|
|
553
457
|
}());
|
|
554
458
|
|
|
459
|
+
var RepositionBordersLayoutFunction = /** @class */ (function () {
|
|
460
|
+
function RepositionBordersLayoutFunction() {
|
|
461
|
+
}
|
|
462
|
+
RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
|
|
463
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.BORDER)
|
|
464
|
+
.forEach(function (border) { return border.updatePosition(); });
|
|
465
|
+
};
|
|
466
|
+
return RepositionBordersLayoutFunction;
|
|
467
|
+
}());
|
|
468
|
+
|
|
469
|
+
var RepositionBackgroundsLayoutFunction = /** @class */ (function () {
|
|
470
|
+
function RepositionBackgroundsLayoutFunction() {
|
|
471
|
+
}
|
|
472
|
+
RepositionBackgroundsLayoutFunction.prototype.execute = function (canvas) {
|
|
473
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.BACKGROUND_IMAGE)
|
|
474
|
+
.forEach(function (border) { return border.updatePosition(); });
|
|
475
|
+
};
|
|
476
|
+
return RepositionBackgroundsLayoutFunction;
|
|
477
|
+
}());
|
|
478
|
+
|
|
555
479
|
var StandardLayoutManager = /** @class */ (function (_super) {
|
|
556
480
|
__extends(StandardLayoutManager, _super);
|
|
557
481
|
function StandardLayoutManager(canvas) {
|
|
@@ -2614,7 +2538,7 @@ var DefaultCanvasProfile = /** @class */ (function () {
|
|
|
2614
2538
|
this.allowRotate = false;
|
|
2615
2539
|
this.allowScale = false;
|
|
2616
2540
|
this.defaultFont = "Lato";
|
|
2617
|
-
this.defaultFontSize =
|
|
2541
|
+
this.defaultFontSize = 9;
|
|
2618
2542
|
this.defaultFontColor = "#000000";
|
|
2619
2543
|
this.defaultLineHeight = 1.8;
|
|
2620
2544
|
this.defaultCharacterSpacing = 0;
|
|
@@ -3428,6 +3352,13 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3428
3352
|
AbstractInteractiveCanvas.prototype.undo = function () {
|
|
3429
3353
|
throw Error("Undo not supported on this canvas type");
|
|
3430
3354
|
};
|
|
3355
|
+
/**
|
|
3356
|
+
* @override
|
|
3357
|
+
* @inheritDoc
|
|
3358
|
+
*/
|
|
3359
|
+
AbstractInteractiveCanvas.prototype.redo = function () {
|
|
3360
|
+
throw Error("Redo not supported on this canvas type");
|
|
3361
|
+
};
|
|
3431
3362
|
/**
|
|
3432
3363
|
* Redraw the canvas.
|
|
3433
3364
|
*/
|
|
@@ -3643,20 +3574,68 @@ var HeadlessInteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3643
3574
|
}(AbstractInteractiveCanvas));
|
|
3644
3575
|
|
|
3645
3576
|
var UndoStack = /** @class */ (function () {
|
|
3646
|
-
function UndoStack(size) {
|
|
3647
|
-
|
|
3577
|
+
function UndoStack(canvas, size) {
|
|
3578
|
+
if (size === void 0) { size = 100; }
|
|
3579
|
+
this.canvas = canvas;
|
|
3580
|
+
this.undoStates = [];
|
|
3581
|
+
this.redoStates = [];
|
|
3582
|
+
this.lastUndo = null;
|
|
3648
3583
|
this.size = size;
|
|
3649
3584
|
}
|
|
3650
|
-
UndoStack.prototype.
|
|
3651
|
-
var
|
|
3652
|
-
|
|
3585
|
+
UndoStack.prototype.save = function (state) {
|
|
3586
|
+
var currentState = this.canvas.save();
|
|
3587
|
+
var undoState = this.undoStates[this.undoStates.length - 1];
|
|
3588
|
+
if (_.isEqual(undoState, state))
|
|
3653
3589
|
return;
|
|
3654
|
-
this.
|
|
3655
|
-
if (this.
|
|
3656
|
-
this.
|
|
3590
|
+
this.undoStates.push(state);
|
|
3591
|
+
if (this.undoStates.length > this.size)
|
|
3592
|
+
this.undoStates.splice(0, 1);
|
|
3593
|
+
if (!_.isEqual(this.lastUndo, currentState))
|
|
3594
|
+
this.redoStates = [];
|
|
3657
3595
|
};
|
|
3658
|
-
UndoStack.prototype.
|
|
3659
|
-
return this
|
|
3596
|
+
UndoStack.prototype.undo = function () {
|
|
3597
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3598
|
+
var undoState, currentState;
|
|
3599
|
+
return __generator(this, function (_a) {
|
|
3600
|
+
switch (_a.label) {
|
|
3601
|
+
case 0:
|
|
3602
|
+
undoState = this.undoStates.pop();
|
|
3603
|
+
if (!undoState)
|
|
3604
|
+
return [2 /*return*/];
|
|
3605
|
+
currentState = this.canvas.save();
|
|
3606
|
+
if (_.isEqual(undoState, currentState)) {
|
|
3607
|
+
undoState = this.undoStates.pop();
|
|
3608
|
+
if (!undoState)
|
|
3609
|
+
return [2 /*return*/];
|
|
3610
|
+
}
|
|
3611
|
+
this.lastUndo = undoState;
|
|
3612
|
+
this.redoStates.push(currentState);
|
|
3613
|
+
return [4 /*yield*/, this.canvas.load(undoState)];
|
|
3614
|
+
case 1:
|
|
3615
|
+
_a.sent();
|
|
3616
|
+
return [2 /*return*/];
|
|
3617
|
+
}
|
|
3618
|
+
});
|
|
3619
|
+
});
|
|
3620
|
+
};
|
|
3621
|
+
UndoStack.prototype.redo = function () {
|
|
3622
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3623
|
+
var state, currentState;
|
|
3624
|
+
return __generator(this, function (_a) {
|
|
3625
|
+
switch (_a.label) {
|
|
3626
|
+
case 0:
|
|
3627
|
+
state = this.redoStates.pop();
|
|
3628
|
+
if (!state)
|
|
3629
|
+
return [2 /*return*/];
|
|
3630
|
+
currentState = this.canvas.save();
|
|
3631
|
+
this.undoStates.push(currentState);
|
|
3632
|
+
return [4 /*yield*/, this.canvas.load(state)];
|
|
3633
|
+
case 1:
|
|
3634
|
+
_a.sent();
|
|
3635
|
+
return [2 /*return*/];
|
|
3636
|
+
}
|
|
3637
|
+
});
|
|
3638
|
+
});
|
|
3660
3639
|
};
|
|
3661
3640
|
return UndoStack;
|
|
3662
3641
|
}());
|
|
@@ -3666,7 +3645,7 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3666
3645
|
function InteractiveCanvas(elementId, devicePixelRatio) {
|
|
3667
3646
|
var _this = _super.call(this, window['fabric'], new window['fabric'].Canvas(elementId), devicePixelRatio) || this;
|
|
3668
3647
|
_this.devicePixelRatio = devicePixelRatio;
|
|
3669
|
-
_this.undoStack = new UndoStack(
|
|
3648
|
+
_this.undoStack = new UndoStack(_this);
|
|
3670
3649
|
//Initialize watchers
|
|
3671
3650
|
_this.fabricCanvas.on("selection:updated", function () { return _this.onFabricSelectionChanged(); });
|
|
3672
3651
|
_this.fabricCanvas.on("selection:created", function () { return _this.onFabricSelectionChanged(); });
|
|
@@ -3681,7 +3660,7 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3681
3660
|
* @inheritDoc
|
|
3682
3661
|
*/
|
|
3683
3662
|
InteractiveCanvas.prototype.registerUndoState = function () {
|
|
3684
|
-
this.undoStack.
|
|
3663
|
+
this.undoStack.save(this.save());
|
|
3685
3664
|
};
|
|
3686
3665
|
/**
|
|
3687
3666
|
* @override
|
|
@@ -3689,20 +3668,25 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3689
3668
|
*/
|
|
3690
3669
|
InteractiveCanvas.prototype.undo = function () {
|
|
3691
3670
|
return __awaiter(this, void 0, void 0, function () {
|
|
3692
|
-
var state;
|
|
3693
3671
|
return __generator(this, function (_a) {
|
|
3694
3672
|
switch (_a.label) {
|
|
3695
|
-
case 0:
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3673
|
+
case 0: return [4 /*yield*/, this.undoStack.undo()];
|
|
3674
|
+
case 1:
|
|
3675
|
+
_a.sent();
|
|
3676
|
+
return [2 /*return*/];
|
|
3677
|
+
}
|
|
3678
|
+
});
|
|
3679
|
+
});
|
|
3680
|
+
};
|
|
3681
|
+
/**
|
|
3682
|
+
* @override
|
|
3683
|
+
* @inheritDoc
|
|
3684
|
+
*/
|
|
3685
|
+
InteractiveCanvas.prototype.redo = function () {
|
|
3686
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3687
|
+
return __generator(this, function (_a) {
|
|
3688
|
+
switch (_a.label) {
|
|
3689
|
+
case 0: return [4 /*yield*/, this.undoStack.redo()];
|
|
3706
3690
|
case 1:
|
|
3707
3691
|
_a.sent();
|
|
3708
3692
|
return [2 /*return*/];
|
|
@@ -3731,6 +3715,82 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3731
3715
|
return InteractiveCanvas;
|
|
3732
3716
|
}(AbstractInteractiveCanvas));
|
|
3733
3717
|
|
|
3718
|
+
var RepositionCutoffsLayoutFunction = /** @class */ (function () {
|
|
3719
|
+
function RepositionCutoffsLayoutFunction() {
|
|
3720
|
+
}
|
|
3721
|
+
RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
|
|
3722
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
|
|
3723
|
+
.forEach(function (cutoff) { return cutoff.updatePosition(); });
|
|
3724
|
+
};
|
|
3725
|
+
return RepositionCutoffsLayoutFunction;
|
|
3726
|
+
}());
|
|
3727
|
+
|
|
3728
|
+
var PinToBottomLayoutFunction = /** @class */ (function () {
|
|
3729
|
+
function PinToBottomLayoutFunction() {
|
|
3730
|
+
}
|
|
3731
|
+
PinToBottomLayoutFunction.prototype.execute = function (canvas) {
|
|
3732
|
+
canvas.getObjectsInternal()
|
|
3733
|
+
.forEach(function (object) { return object.moveToPinnedPosition(); });
|
|
3734
|
+
};
|
|
3735
|
+
return PinToBottomLayoutFunction;
|
|
3736
|
+
}());
|
|
3737
|
+
|
|
3738
|
+
var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
3739
|
+
function ResizeCanvasLayoutFunction() {
|
|
3740
|
+
}
|
|
3741
|
+
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
3742
|
+
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
3743
|
+
return;
|
|
3744
|
+
if (tsOptchain.oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
3745
|
+
return;
|
|
3746
|
+
var currentDimensions = canvas.getDimensions();
|
|
3747
|
+
var baseDimensions = canvas.getBaseDimensions();
|
|
3748
|
+
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
|
|
3749
|
+
.filter(function (text) { return text.isResizeCanvas(); })
|
|
3750
|
+
.reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
|
|
3751
|
+
var increase = baseDimensions.withSize(currentDimensions.width, 0);
|
|
3752
|
+
while (increase.heightPx < textHeightIncreasePx) {
|
|
3753
|
+
increase = increase.withSize(increase.width, increase.height + 1);
|
|
3754
|
+
}
|
|
3755
|
+
var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
|
|
3756
|
+
if (currentDimensions.height !== targetHeight.height) {
|
|
3757
|
+
canvas.setDimensions(targetHeight);
|
|
3758
|
+
}
|
|
3759
|
+
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
3760
|
+
canvas.redraw();
|
|
3761
|
+
};
|
|
3762
|
+
return ResizeCanvasLayoutFunction;
|
|
3763
|
+
}());
|
|
3764
|
+
|
|
3765
|
+
var AdvancedLayoutManager = /** @class */ (function (_super) {
|
|
3766
|
+
__extends(AdvancedLayoutManager, _super);
|
|
3767
|
+
function AdvancedLayoutManager(canvas) {
|
|
3768
|
+
var _this = _super.call(this, canvas) || this;
|
|
3769
|
+
_this.key = exports.LayoutManager.ADVANCED;
|
|
3770
|
+
_this.pinToBottom = new PinToBottomLayoutFunction();
|
|
3771
|
+
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
3772
|
+
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
3773
|
+
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
3774
|
+
_this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
|
|
3775
|
+
_this.resizeCanvas = new ResizeCanvasLayoutFunction();
|
|
3776
|
+
return _this;
|
|
3777
|
+
}
|
|
3778
|
+
AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
3779
|
+
this.pinToBottom.execute(this.canvas);
|
|
3780
|
+
this.repositionCutoffs.execute(this.canvas);
|
|
3781
|
+
this.repositionBorders.execute(this.canvas);
|
|
3782
|
+
this.repositionBackgrounds.execute(this.canvas);
|
|
3783
|
+
this.redrawAll.execute(this.canvas);
|
|
3784
|
+
};
|
|
3785
|
+
AdvancedLayoutManager.prototype.onTextChange = function () {
|
|
3786
|
+
this.resizeCanvas.execute(this.canvas);
|
|
3787
|
+
};
|
|
3788
|
+
AdvancedLayoutManager.prototype.onObjectListChange = function () {
|
|
3789
|
+
this.redrawAll.execute(this.canvas);
|
|
3790
|
+
};
|
|
3791
|
+
return AdvancedLayoutManager;
|
|
3792
|
+
}(AbstractLayoutManager));
|
|
3793
|
+
|
|
3734
3794
|
exports.AbstractCanvasObject = AbstractCanvasObject;
|
|
3735
3795
|
exports.AbstractInteractiveCanvas = AbstractInteractiveCanvas;
|
|
3736
3796
|
exports.AbstractLayoutManager = AbstractLayoutManager;
|
package/dist/undo-stack.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { ICanvasState } from "./types/canvas-state.interface";
|
|
2
|
+
import { IInteractiveCanvas } from "./interactive-canvas.interface";
|
|
2
3
|
export declare class UndoStack {
|
|
4
|
+
protected canvas: IInteractiveCanvas;
|
|
3
5
|
private readonly size;
|
|
4
|
-
private
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
private undoStates;
|
|
7
|
+
private redoStates;
|
|
8
|
+
private lastUndo;
|
|
9
|
+
constructor(canvas: IInteractiveCanvas, size?: number);
|
|
10
|
+
save(state: ICanvasState): void;
|
|
11
|
+
undo(): Promise<void>;
|
|
12
|
+
redo(): Promise<void>;
|
|
8
13
|
}
|