@leapfrog/interactive-canvas 1.12.0 → 1.12.2

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.
@@ -2612,7 +2612,7 @@ var DefaultCanvasProfile = /** @class */ (function () {
2612
2612
  this.allowRotate = false;
2613
2613
  this.allowScale = false;
2614
2614
  this.defaultFont = "Lato";
2615
- this.defaultFontSize = 8;
2615
+ this.defaultFontSize = 9;
2616
2616
  this.defaultFontColor = "#000000";
2617
2617
  this.defaultLineHeight = 1.8;
2618
2618
  this.defaultCharacterSpacing = 0;
@@ -3655,9 +3655,13 @@ var UndoStack = /** @class */ (function () {
3655
3655
  this.canvas = canvas;
3656
3656
  this.undoStates = [];
3657
3657
  this.redoStates = [];
3658
- this.lastUndo = null;
3658
+ this.lastState = null;
3659
3659
  this.size = size;
3660
3660
  }
3661
+ /**
3662
+ * @override
3663
+ * @inheritDoc
3664
+ */
3661
3665
  UndoStack.prototype.save = function (state) {
3662
3666
  var currentState = this.canvas.save();
3663
3667
  var undoState = this.undoStates[this.undoStates.length - 1];
@@ -3666,9 +3670,12 @@ var UndoStack = /** @class */ (function () {
3666
3670
  this.undoStates.push(state);
3667
3671
  if (this.undoStates.length > this.size)
3668
3672
  this.undoStates.splice(0, 1);
3669
- if (!isEqual(this.lastUndo, currentState))
3670
- this.redoStates = [];
3673
+ this.clearRedoStackIfCanvasChanged(currentState);
3671
3674
  };
3675
+ /**
3676
+ * @override
3677
+ * @inheritDoc
3678
+ */
3672
3679
  UndoStack.prototype.undo = function () {
3673
3680
  return __awaiter(this, void 0, void 0, function () {
3674
3681
  var undoState, currentState;
@@ -3684,7 +3691,7 @@ var UndoStack = /** @class */ (function () {
3684
3691
  if (!undoState)
3685
3692
  return [2 /*return*/];
3686
3693
  }
3687
- this.lastUndo = undoState;
3694
+ this.lastState = undoState;
3688
3695
  this.redoStates.push(currentState);
3689
3696
  return [4 /*yield*/, this.canvas.load(undoState)];
3690
3697
  case 1:
@@ -3694,18 +3701,23 @@ var UndoStack = /** @class */ (function () {
3694
3701
  });
3695
3702
  });
3696
3703
  };
3704
+ /**
3705
+ * @override
3706
+ * @inheritDoc
3707
+ */
3697
3708
  UndoStack.prototype.redo = function () {
3698
3709
  return __awaiter(this, void 0, void 0, function () {
3699
- var state, currentState;
3710
+ var redoState, currentState;
3700
3711
  return __generator(this, function (_a) {
3701
3712
  switch (_a.label) {
3702
3713
  case 0:
3703
- state = this.redoStates.pop();
3704
- if (!state)
3714
+ redoState = this.redoStates.pop();
3715
+ if (!redoState)
3705
3716
  return [2 /*return*/];
3706
3717
  currentState = this.canvas.save();
3718
+ this.lastState = redoState;
3707
3719
  this.undoStates.push(currentState);
3708
- return [4 /*yield*/, this.canvas.load(state)];
3720
+ return [4 /*yield*/, this.canvas.load(redoState)];
3709
3721
  case 1:
3710
3722
  _a.sent();
3711
3723
  return [2 /*return*/];
@@ -3713,6 +3725,11 @@ var UndoStack = /** @class */ (function () {
3713
3725
  });
3714
3726
  });
3715
3727
  };
3728
+ UndoStack.prototype.clearRedoStackIfCanvasChanged = function (currentState) {
3729
+ if (isEqual(this.lastState, currentState))
3730
+ return;
3731
+ this.redoStates = [];
3732
+ };
3716
3733
  return UndoStack;
3717
3734
  }());
3718
3735
 
@@ -2614,7 +2614,7 @@ var DefaultCanvasProfile = /** @class */ (function () {
2614
2614
  this.allowRotate = false;
2615
2615
  this.allowScale = false;
2616
2616
  this.defaultFont = "Lato";
2617
- this.defaultFontSize = 8;
2617
+ this.defaultFontSize = 9;
2618
2618
  this.defaultFontColor = "#000000";
2619
2619
  this.defaultLineHeight = 1.8;
2620
2620
  this.defaultCharacterSpacing = 0;
@@ -3655,9 +3655,13 @@ var UndoStack = /** @class */ (function () {
3655
3655
  this.canvas = canvas;
3656
3656
  this.undoStates = [];
3657
3657
  this.redoStates = [];
3658
- this.lastUndo = null;
3658
+ this.lastState = null;
3659
3659
  this.size = size;
3660
3660
  }
3661
+ /**
3662
+ * @override
3663
+ * @inheritDoc
3664
+ */
3661
3665
  UndoStack.prototype.save = function (state) {
3662
3666
  var currentState = this.canvas.save();
3663
3667
  var undoState = this.undoStates[this.undoStates.length - 1];
@@ -3666,9 +3670,12 @@ var UndoStack = /** @class */ (function () {
3666
3670
  this.undoStates.push(state);
3667
3671
  if (this.undoStates.length > this.size)
3668
3672
  this.undoStates.splice(0, 1);
3669
- if (!_.isEqual(this.lastUndo, currentState))
3670
- this.redoStates = [];
3673
+ this.clearRedoStackIfCanvasChanged(currentState);
3671
3674
  };
3675
+ /**
3676
+ * @override
3677
+ * @inheritDoc
3678
+ */
3672
3679
  UndoStack.prototype.undo = function () {
3673
3680
  return __awaiter(this, void 0, void 0, function () {
3674
3681
  var undoState, currentState;
@@ -3684,7 +3691,7 @@ var UndoStack = /** @class */ (function () {
3684
3691
  if (!undoState)
3685
3692
  return [2 /*return*/];
3686
3693
  }
3687
- this.lastUndo = undoState;
3694
+ this.lastState = undoState;
3688
3695
  this.redoStates.push(currentState);
3689
3696
  return [4 /*yield*/, this.canvas.load(undoState)];
3690
3697
  case 1:
@@ -3694,18 +3701,23 @@ var UndoStack = /** @class */ (function () {
3694
3701
  });
3695
3702
  });
3696
3703
  };
3704
+ /**
3705
+ * @override
3706
+ * @inheritDoc
3707
+ */
3697
3708
  UndoStack.prototype.redo = function () {
3698
3709
  return __awaiter(this, void 0, void 0, function () {
3699
- var state, currentState;
3710
+ var redoState, currentState;
3700
3711
  return __generator(this, function (_a) {
3701
3712
  switch (_a.label) {
3702
3713
  case 0:
3703
- state = this.redoStates.pop();
3704
- if (!state)
3714
+ redoState = this.redoStates.pop();
3715
+ if (!redoState)
3705
3716
  return [2 /*return*/];
3706
3717
  currentState = this.canvas.save();
3718
+ this.lastState = redoState;
3707
3719
  this.undoStates.push(currentState);
3708
- return [4 /*yield*/, this.canvas.load(state)];
3720
+ return [4 /*yield*/, this.canvas.load(redoState)];
3709
3721
  case 1:
3710
3722
  _a.sent();
3711
3723
  return [2 /*return*/];
@@ -3713,6 +3725,11 @@ var UndoStack = /** @class */ (function () {
3713
3725
  });
3714
3726
  });
3715
3727
  };
3728
+ UndoStack.prototype.clearRedoStackIfCanvasChanged = function (currentState) {
3729
+ if (_.isEqual(this.lastState, currentState))
3730
+ return;
3731
+ this.redoStates = [];
3732
+ };
3716
3733
  return UndoStack;
3717
3734
  }());
3718
3735
 
@@ -1,13 +1,27 @@
1
1
  import { ICanvasState } from "./types/canvas-state.interface";
2
2
  import { IInteractiveCanvas } from "./interactive-canvas.interface";
3
- export declare class UndoStack {
3
+ import { IUndoStack } from "./undo-stack.interface";
4
+ export declare class UndoStack implements IUndoStack {
4
5
  protected canvas: IInteractiveCanvas;
5
6
  private readonly size;
6
7
  private undoStates;
7
8
  private redoStates;
8
- private lastUndo;
9
+ private lastState;
9
10
  constructor(canvas: IInteractiveCanvas, size?: number);
11
+ /**
12
+ * @override
13
+ * @inheritDoc
14
+ */
10
15
  save(state: ICanvasState): void;
16
+ /**
17
+ * @override
18
+ * @inheritDoc
19
+ */
11
20
  undo(): Promise<void>;
21
+ /**
22
+ * @override
23
+ * @inheritDoc
24
+ */
12
25
  redo(): Promise<void>;
26
+ private clearRedoStackIfCanvasChanged;
13
27
  }
@@ -0,0 +1,6 @@
1
+ import { ICanvasState } from "./types/canvas-state.interface";
2
+ export interface IUndoStack {
3
+ save(state: ICanvasState): void;
4
+ undo(): Promise<void>;
5
+ redo(): Promise<void>;
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leapfrog/interactive-canvas",
3
- "version": "1.12.0",
3
+ "version": "1.12.2",
4
4
  "description": "Leapfrog interactive canvas",
5
5
  "files": [
6
6
  "dist"