@leapfrog/interactive-canvas 1.14.2 → 1.14.4

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.
@@ -280,6 +280,10 @@ export declare abstract class AbstractInteractiveCanvas implements IInteractiveC
280
280
  * deletes all circles on canvas load.
281
281
  */
282
282
  private removePersistedBullets;
283
+ /**
284
+ * Remove any slave objects persisted to the canvas; their master objects will recreate them.
285
+ */
286
+ private removeSlaveObjects;
283
287
  /**
284
288
  * @override
285
289
  * @inheritDoc
@@ -410,6 +410,7 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
410
410
  var footerObjects = objects[0];
411
411
  var bodyObjects = objects[1];
412
412
  var bodyWidth = canvasDimensions.widthPx - canvasMargin.right - canvasMargin.left;
413
+ canvas.redraw();
413
414
  //Make one pass and set the widths of all elements. This will force objects with dynamic heights (like text) to take on their necessary height before trying to lay them out.
414
415
  this.applyWidths(allObjects, bodyWidth);
415
416
  var bodyRows = this.getRows(bodyObjects);
@@ -2483,7 +2484,7 @@ var Text = /** @class */ (function (_super) {
2483
2484
  }
2484
2485
  else {
2485
2486
  // Create new marker for this line
2486
- activeMarkers_1[lineIndex] = new fabric.Textbox(lineIndex + ".", {
2487
+ var textbox = new fabric.Textbox(lineIndex + ".", {
2487
2488
  left: 0,
2488
2489
  top: 0,
2489
2490
  fill: fabricText.fill,
@@ -2493,9 +2494,10 @@ var Text = /** @class */ (function (_super) {
2493
2494
  lockMovementX: true,
2494
2495
  lockMovementY: true,
2495
2496
  hasControls: false,
2496
- selectable: false,
2497
- excludeFromExport: true
2497
+ selectable: false
2498
2498
  });
2499
+ textbox._isSlaveObject = true;
2500
+ activeMarkers_1[lineIndex] = textbox;
2499
2501
  }
2500
2502
  }
2501
2503
  }
@@ -3483,7 +3485,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
3483
3485
  var objects = _(this.objects$.value)
3484
3486
  .map(function (x) { return x.persist(); })
3485
3487
  .value();
3486
- var includedProperties = ["id", "_isOrderedList", "_orderedListStart"];
3488
+ var includedProperties = ["id", "_isSlaveObject", "_isOrderedList", "_orderedListStart"];
3487
3489
  var json = this.fabricCanvas.toJSON(includedProperties);
3488
3490
  return {
3489
3491
  dimensions: this.dimensions$.value,
@@ -3518,6 +3520,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
3518
3520
  this.backgroundColor$.next(this.fabricCanvas.backgroundColor);
3519
3521
  this.bindFields(canvasState.objects);
3520
3522
  this.removePersistedBullets();
3523
+ this.removeSlaveObjects();
3521
3524
  this.layoutManager$.value.onInit();
3522
3525
  return [2 /*return*/];
3523
3526
  }
@@ -3537,6 +3540,17 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
3537
3540
  _this.removeFabricObject(object);
3538
3541
  });
3539
3542
  };
3543
+ /**
3544
+ * Remove any slave objects persisted to the canvas; their master objects will recreate them.
3545
+ */
3546
+ AbstractInteractiveCanvas.prototype.removeSlaveObjects = function () {
3547
+ var _this = this;
3548
+ var objects = this.fabricCanvas.getObjects();
3549
+ each(objects, function (object) {
3550
+ if (object._isSlaveObject)
3551
+ _this.removeFabricObject(object);
3552
+ });
3553
+ };
3540
3554
  /**
3541
3555
  * @override
3542
3556
  * @inheritDoc
@@ -412,6 +412,7 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
412
412
  var footerObjects = objects[0];
413
413
  var bodyObjects = objects[1];
414
414
  var bodyWidth = canvasDimensions.widthPx - canvasMargin.right - canvasMargin.left;
415
+ canvas.redraw();
415
416
  //Make one pass and set the widths of all elements. This will force objects with dynamic heights (like text) to take on their necessary height before trying to lay them out.
416
417
  this.applyWidths(allObjects, bodyWidth);
417
418
  var bodyRows = this.getRows(bodyObjects);
@@ -2485,7 +2486,7 @@ var Text = /** @class */ (function (_super) {
2485
2486
  }
2486
2487
  else {
2487
2488
  // Create new marker for this line
2488
- activeMarkers_1[lineIndex] = new fabric.Textbox(lineIndex + ".", {
2489
+ var textbox = new fabric.Textbox(lineIndex + ".", {
2489
2490
  left: 0,
2490
2491
  top: 0,
2491
2492
  fill: fabricText.fill,
@@ -2495,9 +2496,10 @@ var Text = /** @class */ (function (_super) {
2495
2496
  lockMovementX: true,
2496
2497
  lockMovementY: true,
2497
2498
  hasControls: false,
2498
- selectable: false,
2499
- excludeFromExport: true
2499
+ selectable: false
2500
2500
  });
2501
+ textbox._isSlaveObject = true;
2502
+ activeMarkers_1[lineIndex] = textbox;
2501
2503
  }
2502
2504
  }
2503
2505
  }
@@ -3483,7 +3485,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
3483
3485
  var objects = _(this.objects$.value)
3484
3486
  .map(function (x) { return x.persist(); })
3485
3487
  .value();
3486
- var includedProperties = ["id", "_isOrderedList", "_orderedListStart"];
3488
+ var includedProperties = ["id", "_isSlaveObject", "_isOrderedList", "_orderedListStart"];
3487
3489
  var json = this.fabricCanvas.toJSON(includedProperties);
3488
3490
  return {
3489
3491
  dimensions: this.dimensions$.value,
@@ -3518,6 +3520,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
3518
3520
  this.backgroundColor$.next(this.fabricCanvas.backgroundColor);
3519
3521
  this.bindFields(canvasState.objects);
3520
3522
  this.removePersistedBullets();
3523
+ this.removeSlaveObjects();
3521
3524
  this.layoutManager$.value.onInit();
3522
3525
  return [2 /*return*/];
3523
3526
  }
@@ -3537,6 +3540,17 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
3537
3540
  _this.removeFabricObject(object);
3538
3541
  });
3539
3542
  };
3543
+ /**
3544
+ * Remove any slave objects persisted to the canvas; their master objects will recreate them.
3545
+ */
3546
+ AbstractInteractiveCanvas.prototype.removeSlaveObjects = function () {
3547
+ var _this = this;
3548
+ var objects = this.fabricCanvas.getObjects();
3549
+ _.each(objects, function (object) {
3550
+ if (object._isSlaveObject)
3551
+ _this.removeFabricObject(object);
3552
+ });
3553
+ };
3540
3554
  /**
3541
3555
  * @override
3542
3556
  * @inheritDoc
@@ -0,0 +1,7 @@
1
+ import { fabric } from "fabric";
2
+ export interface ExtendedFabricObject extends fabric.Object {
3
+ /**
4
+ * If true, this object is a slave object controlled by another object and not directly by the user, such as the line markers in an ordered list.
5
+ */
6
+ _isSlaveObject?: boolean;
7
+ }
@@ -1,5 +1,6 @@
1
1
  import { fabric } from "fabric";
2
- export interface ExtendedFabricTextbox extends fabric.Textbox {
2
+ import { ExtendedFabricObject } from "./extended-fabric-object.interface";
3
+ export interface ExtendedFabricTextbox extends fabric.Textbox, ExtendedFabricObject {
3
4
  _isOrderedList?: boolean;
4
5
  _orderedListStart?: number;
5
6
  _orderedListMarkerEntities?: fabric.Textbox[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leapfrog/interactive-canvas",
3
- "version": "1.14.2",
3
+ "version": "1.14.4",
4
4
  "description": "Leapfrog interactive canvas",
5
5
  "files": [
6
6
  "dist"