@leapfrog/interactive-canvas 1.14.1 → 1.14.3

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
package/dist/index.d.ts CHANGED
@@ -51,3 +51,4 @@ export * from "./abstract-interactive-canvas";
51
51
  export * from "./headless-interactive-canvas";
52
52
  export * from "./interactive-canvas";
53
53
  export * from "./interactive-canvas.interface";
54
+ export { ExtendedFabricTextbox } from "./object/impl/extended-fabric-textbox.interface";
@@ -2251,14 +2251,14 @@ var Text = /** @class */ (function (_super) {
2251
2251
  * @inheritDoc
2252
2252
  */
2253
2253
  Text.prototype.getOrderedListMargin = function () {
2254
- var _this_1 = this;
2255
2254
  if (!this.isOrderedList())
2256
2255
  return 0;
2257
- var fontSize = 0;
2258
- each(this.fabricObject._textLines, function (textLine, lineIndex) {
2259
- fontSize = Math.max(fontSize, _this_1.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
2260
- });
2261
- return fontSize * 1.5;
2256
+ var orderedListMarkerEntities = this.fabricObject._orderedListMarkerEntities;
2257
+ var max = _(orderedListMarkerEntities)
2258
+ .filter(function (x) { return !!x; })
2259
+ .map(function (x) { return x.getBoundingRect(true, true).width; })
2260
+ .max();
2261
+ return (max * 1.2) || 0;
2262
2262
  };
2263
2263
  /**
2264
2264
  * @override
@@ -2342,7 +2342,7 @@ var Text = /** @class */ (function (_super) {
2342
2342
  * @inheritDoc
2343
2343
  */
2344
2344
  Text.prototype.isOrderedList = function () {
2345
- return this.fabricObject.orderedList || false;
2345
+ return this.fabricObject._isOrderedList || false;
2346
2346
  };
2347
2347
  /**
2348
2348
  * @override
@@ -2350,8 +2350,8 @@ var Text = /** @class */ (function (_super) {
2350
2350
  */
2351
2351
  Text.prototype.enableOrderedList = function () {
2352
2352
  this.disableBullets();
2353
- this.fabricObject["objectCaching"] = false;
2354
- this.fabricObject.orderedList = true;
2353
+ this.fabricObject.objectCaching = false;
2354
+ this.fabricObject._isOrderedList = true;
2355
2355
  this.notifyCanvasOfTextChanges();
2356
2356
  this.redraw();
2357
2357
  };
@@ -2360,8 +2360,8 @@ var Text = /** @class */ (function (_super) {
2360
2360
  * @inheritDoc
2361
2361
  */
2362
2362
  Text.prototype.disableOrderedList = function () {
2363
- this.removeOrderedList();
2364
- delete this.fabricObject.orderedList;
2363
+ this.removeOrderedListMarkers();
2364
+ delete this.fabricObject._isOrderedList;
2365
2365
  this.notifyCanvasOfTextChanges();
2366
2366
  this.redraw();
2367
2367
  };
@@ -2370,7 +2370,8 @@ var Text = /** @class */ (function (_super) {
2370
2370
  * @inheritDoc
2371
2371
  */
2372
2372
  Text.prototype.setOrderedListStart = function (start) {
2373
- this.fabricObject.orderedListIndex = start;
2373
+ this.fabricObject._orderedListStart = start;
2374
+ this.notifyCanvasOfTextChanges();
2374
2375
  this.redraw();
2375
2376
  };
2376
2377
  /**
@@ -2378,7 +2379,7 @@ var Text = /** @class */ (function (_super) {
2378
2379
  * @inheritDoc
2379
2380
  */
2380
2381
  Text.prototype.getOrderedListStart = function () {
2381
- return this.fabricObject.orderedListIndex || 1;
2382
+ return this.fabricObject._orderedListStart || 1;
2382
2383
  };
2383
2384
  Text.prototype.getSizeIncreaseSinceCreation = function () {
2384
2385
  return Math.max(0, this.fabricObject.height - this.baseComponentHeight);
@@ -2392,12 +2393,12 @@ var Text = /** @class */ (function (_super) {
2392
2393
  this.fabricObject["objectCaching"] = true;
2393
2394
  }
2394
2395
  };
2395
- Text.prototype.removeOrderedList = function () {
2396
+ Text.prototype.removeOrderedListMarkers = function () {
2396
2397
  var _this_1 = this;
2397
- if (this.fabricObject.orderedList) {
2398
- var lineNumbers = this.fabricObject["_currentLineNumbers"];
2399
- delete this.fabricObject["_currentLineNumbers"];
2400
- each(lineNumbers, function (lineNumber) { return _this_1.canvas.removeFabricObject(lineNumber); });
2398
+ if (this.fabricObject._isOrderedList) {
2399
+ var markerEntities = this.fabricObject._orderedListMarkerEntities;
2400
+ delete this.fabricObject._orderedListMarkerEntities;
2401
+ each(markerEntities, function (marker) { return _this_1.canvas.removeFabricObject(marker); });
2401
2402
  this.fabricObject["objectCaching"] = true;
2402
2403
  }
2403
2404
  };
@@ -2405,7 +2406,7 @@ var Text = /** @class */ (function (_super) {
2405
2406
  var _this = this;
2406
2407
  if (this.data.bulleted)
2407
2408
  this.enableBullets();
2408
- if (this.fabricObject.orderedList)
2409
+ if (this.fabricObject._isOrderedList)
2409
2410
  this.enableOrderedList();
2410
2411
  var originalRender = this.fabricObject["_render"];
2411
2412
  var fabric = this.canvas.fabric;
@@ -2468,22 +2469,21 @@ var Text = /** @class */ (function (_super) {
2468
2469
  setTimeout(canvas_1.renderAll.bind(canvas_1));
2469
2470
  }
2470
2471
  }
2471
- if (fabricText["orderedList"]) {
2472
- // Determine list of active bullets
2473
- var currentLineNumbers_1 = fabricText["_currentLineNumbers"] || {};
2474
- var activeLineNumbers_1 = {};
2472
+ if (fabricText._isOrderedList) {
2473
+ var existingMarkers_1 = fabricText._orderedListMarkerEntities || [];
2474
+ var activeMarkers_1 = [];
2475
2475
  each(fabricText._textLines, function (textLine, lineIndex) {
2476
2476
  if (textLine.length) {
2477
2477
  // Start of real lines will have offset 0 in styleMap
2478
2478
  var styleMap = fabricText._styleMap[lineIndex];
2479
2479
  if (styleMap.offset === 0) {
2480
- if (currentLineNumbers_1[lineIndex]) {
2481
- // Reuse existing bullet for this line
2482
- activeLineNumbers_1[lineIndex] = currentLineNumbers_1[lineIndex];
2480
+ if (existingMarkers_1[lineIndex]) {
2481
+ // Reuse existing marker for this line
2482
+ activeMarkers_1[lineIndex] = existingMarkers_1[lineIndex];
2483
2483
  }
2484
2484
  else {
2485
- // Create new bullet for this line
2486
- activeLineNumbers_1[lineIndex] = new fabric.Textbox(lineIndex + ".", {
2485
+ // Create new marker for this line
2486
+ var textbox = new fabric.Textbox(lineIndex + ".", {
2487
2487
  left: 0,
2488
2488
  top: 0,
2489
2489
  fill: fabricText.fill,
@@ -2493,31 +2493,36 @@ var Text = /** @class */ (function (_super) {
2493
2493
  lockMovementX: true,
2494
2494
  lockMovementY: true,
2495
2495
  hasControls: false,
2496
- selectable: false,
2497
- excludeFromExport: true
2496
+ selectable: false
2498
2497
  });
2498
+ textbox._isSlaveObject = true;
2499
+ activeMarkers_1[lineIndex] = textbox;
2499
2500
  }
2500
2501
  }
2501
2502
  }
2502
2503
  });
2503
- // Add/Remove bullets from canvas
2504
+ // Add/Remove markers from canvas
2504
2505
  var canvas_2 = fabricText.canvas;
2505
2506
  var canvasDirty_2 = false;
2506
2507
  canvas_2.renderOnAddRemove = false;
2507
- each(activeLineNumbers_1, function (bullet) {
2508
- if (!canvas_2.contains(bullet)) {
2509
- canvas_2.add(bullet);
2508
+ each(activeMarkers_1, function (marker) {
2509
+ if (!marker)
2510
+ return;
2511
+ if (!canvas_2.contains(marker)) {
2512
+ canvas_2.add(marker);
2510
2513
  canvasDirty_2 = true;
2511
2514
  }
2512
2515
  });
2513
- each(currentLineNumbers_1, function (bullet, key) {
2514
- if (!activeLineNumbers_1[key]) {
2515
- canvas_2.remove(bullet);
2516
+ each(existingMarkers_1, function (marker, key) {
2517
+ if (!marker)
2518
+ return;
2519
+ if (!activeMarkers_1[key]) {
2520
+ canvas_2.remove(marker);
2516
2521
  canvasDirty_2 = true;
2517
2522
  }
2518
2523
  });
2519
2524
  canvas_2.renderOnAddRemove = true;
2520
- fabricText["_currentLineNumbers"] = activeLineNumbers_1;
2525
+ fabricText._orderedListMarkerEntities = activeMarkers_1;
2521
2526
  if (canvasDirty_2) {
2522
2527
  // Fabric doesn't like it when you add new things within render so use a sneaky timeout to delay render
2523
2528
  setTimeout(canvas_2.renderAll.bind(canvas_2));
@@ -2548,24 +2553,25 @@ var Text = /** @class */ (function (_super) {
2548
2553
  top: fabricText.top + yOffset + bulletCenterOffset[1]
2549
2554
  });
2550
2555
  }
2551
- var currentLineNumbers = fabricText._currentLineNumbers;
2552
- if (currentLineNumbers && currentLineNumbers[lineIndex]) {
2553
- var entry = currentLineNumbers[lineIndex];
2556
+ var orderedListMarkerEntities = fabricText._orderedListMarkerEntities;
2557
+ var xShift = -_this.getOrderedListMargin() + 1;
2558
+ if (orderedListMarkerEntities && orderedListMarkerEntities[lineIndex]) {
2559
+ var entry = orderedListMarkerEntities[lineIndex];
2554
2560
  var fontSize = this.getValueOfPropertyAt(lineIndex, 0, "fontSize");
2555
2561
  var fontFamily = this.getValueOfPropertyAt(lineIndex, 0, "fontFamily");
2556
2562
  var color = this.getValueOfPropertyAt(lineIndex, 0, "fill");
2557
2563
  var angle = fabricText.angle;
2558
2564
  var theta = angle * Math.PI / 180;
2559
- var xShift = -fontSize * 1.5;
2560
2565
  var yShift = (fabricText.height / 2) + top - fontSize - 1;
2561
2566
  var xOffset = (xShift * Math.cos(theta)) - (yShift * Math.sin(theta));
2562
2567
  var yOffset = (xShift * Math.sin(theta)) + (yShift * Math.cos(theta));
2563
2568
  var lineNumber = _this.getOrderedListStart();
2564
2569
  for (var i = 0; i < lineIndex; i++) {
2565
- if (currentLineNumbers[i])
2570
+ if (orderedListMarkerEntities[i])
2566
2571
  lineNumber++;
2567
2572
  }
2568
2573
  entry.set({
2574
+ width: 1,
2569
2575
  fontSize: fontSize,
2570
2576
  fontFamily: fontFamily,
2571
2577
  fill: color,
@@ -3478,7 +3484,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
3478
3484
  var objects = _(this.objects$.value)
3479
3485
  .map(function (x) { return x.persist(); })
3480
3486
  .value();
3481
- var includedProperties = ["id", "orderedList", "orderedListIndex"];
3487
+ var includedProperties = ["id", "_isSlaveObject", "_isOrderedList", "_orderedListStart"];
3482
3488
  var json = this.fabricCanvas.toJSON(includedProperties);
3483
3489
  return {
3484
3490
  dimensions: this.dimensions$.value,
@@ -3513,6 +3519,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
3513
3519
  this.backgroundColor$.next(this.fabricCanvas.backgroundColor);
3514
3520
  this.bindFields(canvasState.objects);
3515
3521
  this.removePersistedBullets();
3522
+ this.removeSlaveObjects();
3516
3523
  this.layoutManager$.value.onInit();
3517
3524
  return [2 /*return*/];
3518
3525
  }
@@ -3532,6 +3539,17 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
3532
3539
  _this.removeFabricObject(object);
3533
3540
  });
3534
3541
  };
3542
+ /**
3543
+ * Remove any slave objects persisted to the canvas; their master objects will recreate them.
3544
+ */
3545
+ AbstractInteractiveCanvas.prototype.removeSlaveObjects = function () {
3546
+ var _this = this;
3547
+ var objects = this.fabricCanvas.getObjects();
3548
+ each(objects, function (object) {
3549
+ if (object._isSlaveObject)
3550
+ _this.removeFabricObject(object);
3551
+ });
3552
+ };
3535
3553
  /**
3536
3554
  * @override
3537
3555
  * @inheritDoc
@@ -2253,14 +2253,14 @@ var Text = /** @class */ (function (_super) {
2253
2253
  * @inheritDoc
2254
2254
  */
2255
2255
  Text.prototype.getOrderedListMargin = function () {
2256
- var _this_1 = this;
2257
2256
  if (!this.isOrderedList())
2258
2257
  return 0;
2259
- var fontSize = 0;
2260
- _.each(this.fabricObject._textLines, function (textLine, lineIndex) {
2261
- fontSize = Math.max(fontSize, _this_1.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
2262
- });
2263
- return fontSize * 1.5;
2258
+ var orderedListMarkerEntities = this.fabricObject._orderedListMarkerEntities;
2259
+ var max = _(orderedListMarkerEntities)
2260
+ .filter(function (x) { return !!x; })
2261
+ .map(function (x) { return x.getBoundingRect(true, true).width; })
2262
+ .max();
2263
+ return (max * 1.2) || 0;
2264
2264
  };
2265
2265
  /**
2266
2266
  * @override
@@ -2344,7 +2344,7 @@ var Text = /** @class */ (function (_super) {
2344
2344
  * @inheritDoc
2345
2345
  */
2346
2346
  Text.prototype.isOrderedList = function () {
2347
- return this.fabricObject.orderedList || false;
2347
+ return this.fabricObject._isOrderedList || false;
2348
2348
  };
2349
2349
  /**
2350
2350
  * @override
@@ -2352,8 +2352,8 @@ var Text = /** @class */ (function (_super) {
2352
2352
  */
2353
2353
  Text.prototype.enableOrderedList = function () {
2354
2354
  this.disableBullets();
2355
- this.fabricObject["objectCaching"] = false;
2356
- this.fabricObject.orderedList = true;
2355
+ this.fabricObject.objectCaching = false;
2356
+ this.fabricObject._isOrderedList = true;
2357
2357
  this.notifyCanvasOfTextChanges();
2358
2358
  this.redraw();
2359
2359
  };
@@ -2362,8 +2362,8 @@ var Text = /** @class */ (function (_super) {
2362
2362
  * @inheritDoc
2363
2363
  */
2364
2364
  Text.prototype.disableOrderedList = function () {
2365
- this.removeOrderedList();
2366
- delete this.fabricObject.orderedList;
2365
+ this.removeOrderedListMarkers();
2366
+ delete this.fabricObject._isOrderedList;
2367
2367
  this.notifyCanvasOfTextChanges();
2368
2368
  this.redraw();
2369
2369
  };
@@ -2372,7 +2372,8 @@ var Text = /** @class */ (function (_super) {
2372
2372
  * @inheritDoc
2373
2373
  */
2374
2374
  Text.prototype.setOrderedListStart = function (start) {
2375
- this.fabricObject.orderedListIndex = start;
2375
+ this.fabricObject._orderedListStart = start;
2376
+ this.notifyCanvasOfTextChanges();
2376
2377
  this.redraw();
2377
2378
  };
2378
2379
  /**
@@ -2380,7 +2381,7 @@ var Text = /** @class */ (function (_super) {
2380
2381
  * @inheritDoc
2381
2382
  */
2382
2383
  Text.prototype.getOrderedListStart = function () {
2383
- return this.fabricObject.orderedListIndex || 1;
2384
+ return this.fabricObject._orderedListStart || 1;
2384
2385
  };
2385
2386
  Text.prototype.getSizeIncreaseSinceCreation = function () {
2386
2387
  return Math.max(0, this.fabricObject.height - this.baseComponentHeight);
@@ -2394,12 +2395,12 @@ var Text = /** @class */ (function (_super) {
2394
2395
  this.fabricObject["objectCaching"] = true;
2395
2396
  }
2396
2397
  };
2397
- Text.prototype.removeOrderedList = function () {
2398
+ Text.prototype.removeOrderedListMarkers = function () {
2398
2399
  var _this_1 = this;
2399
- if (this.fabricObject.orderedList) {
2400
- var lineNumbers = this.fabricObject["_currentLineNumbers"];
2401
- delete this.fabricObject["_currentLineNumbers"];
2402
- _.each(lineNumbers, function (lineNumber) { return _this_1.canvas.removeFabricObject(lineNumber); });
2400
+ if (this.fabricObject._isOrderedList) {
2401
+ var markerEntities = this.fabricObject._orderedListMarkerEntities;
2402
+ delete this.fabricObject._orderedListMarkerEntities;
2403
+ _.each(markerEntities, function (marker) { return _this_1.canvas.removeFabricObject(marker); });
2403
2404
  this.fabricObject["objectCaching"] = true;
2404
2405
  }
2405
2406
  };
@@ -2407,7 +2408,7 @@ var Text = /** @class */ (function (_super) {
2407
2408
  var _this = this;
2408
2409
  if (this.data.bulleted)
2409
2410
  this.enableBullets();
2410
- if (this.fabricObject.orderedList)
2411
+ if (this.fabricObject._isOrderedList)
2411
2412
  this.enableOrderedList();
2412
2413
  var originalRender = this.fabricObject["_render"];
2413
2414
  var fabric = this.canvas.fabric;
@@ -2470,22 +2471,21 @@ var Text = /** @class */ (function (_super) {
2470
2471
  setTimeout(canvas_1.renderAll.bind(canvas_1));
2471
2472
  }
2472
2473
  }
2473
- if (fabricText["orderedList"]) {
2474
- // Determine list of active bullets
2475
- var currentLineNumbers_1 = fabricText["_currentLineNumbers"] || {};
2476
- var activeLineNumbers_1 = {};
2474
+ if (fabricText._isOrderedList) {
2475
+ var existingMarkers_1 = fabricText._orderedListMarkerEntities || [];
2476
+ var activeMarkers_1 = [];
2477
2477
  _.each(fabricText._textLines, function (textLine, lineIndex) {
2478
2478
  if (textLine.length) {
2479
2479
  // Start of real lines will have offset 0 in styleMap
2480
2480
  var styleMap = fabricText._styleMap[lineIndex];
2481
2481
  if (styleMap.offset === 0) {
2482
- if (currentLineNumbers_1[lineIndex]) {
2483
- // Reuse existing bullet for this line
2484
- activeLineNumbers_1[lineIndex] = currentLineNumbers_1[lineIndex];
2482
+ if (existingMarkers_1[lineIndex]) {
2483
+ // Reuse existing marker for this line
2484
+ activeMarkers_1[lineIndex] = existingMarkers_1[lineIndex];
2485
2485
  }
2486
2486
  else {
2487
- // Create new bullet for this line
2488
- activeLineNumbers_1[lineIndex] = new fabric.Textbox(lineIndex + ".", {
2487
+ // Create new marker for this line
2488
+ var textbox = new fabric.Textbox(lineIndex + ".", {
2489
2489
  left: 0,
2490
2490
  top: 0,
2491
2491
  fill: fabricText.fill,
@@ -2495,31 +2495,36 @@ var Text = /** @class */ (function (_super) {
2495
2495
  lockMovementX: true,
2496
2496
  lockMovementY: true,
2497
2497
  hasControls: false,
2498
- selectable: false,
2499
- excludeFromExport: true
2498
+ selectable: false
2500
2499
  });
2500
+ textbox._isSlaveObject = true;
2501
+ activeMarkers_1[lineIndex] = textbox;
2501
2502
  }
2502
2503
  }
2503
2504
  }
2504
2505
  });
2505
- // Add/Remove bullets from canvas
2506
+ // Add/Remove markers from canvas
2506
2507
  var canvas_2 = fabricText.canvas;
2507
2508
  var canvasDirty_2 = false;
2508
2509
  canvas_2.renderOnAddRemove = false;
2509
- _.each(activeLineNumbers_1, function (bullet) {
2510
- if (!canvas_2.contains(bullet)) {
2511
- canvas_2.add(bullet);
2510
+ _.each(activeMarkers_1, function (marker) {
2511
+ if (!marker)
2512
+ return;
2513
+ if (!canvas_2.contains(marker)) {
2514
+ canvas_2.add(marker);
2512
2515
  canvasDirty_2 = true;
2513
2516
  }
2514
2517
  });
2515
- _.each(currentLineNumbers_1, function (bullet, key) {
2516
- if (!activeLineNumbers_1[key]) {
2517
- canvas_2.remove(bullet);
2518
+ _.each(existingMarkers_1, function (marker, key) {
2519
+ if (!marker)
2520
+ return;
2521
+ if (!activeMarkers_1[key]) {
2522
+ canvas_2.remove(marker);
2518
2523
  canvasDirty_2 = true;
2519
2524
  }
2520
2525
  });
2521
2526
  canvas_2.renderOnAddRemove = true;
2522
- fabricText["_currentLineNumbers"] = activeLineNumbers_1;
2527
+ fabricText._orderedListMarkerEntities = activeMarkers_1;
2523
2528
  if (canvasDirty_2) {
2524
2529
  // Fabric doesn't like it when you add new things within render so use a sneaky timeout to delay render
2525
2530
  setTimeout(canvas_2.renderAll.bind(canvas_2));
@@ -2550,24 +2555,25 @@ var Text = /** @class */ (function (_super) {
2550
2555
  top: fabricText.top + yOffset + bulletCenterOffset[1]
2551
2556
  });
2552
2557
  }
2553
- var currentLineNumbers = fabricText._currentLineNumbers;
2554
- if (currentLineNumbers && currentLineNumbers[lineIndex]) {
2555
- var entry = currentLineNumbers[lineIndex];
2558
+ var orderedListMarkerEntities = fabricText._orderedListMarkerEntities;
2559
+ var xShift = -_this.getOrderedListMargin() + 1;
2560
+ if (orderedListMarkerEntities && orderedListMarkerEntities[lineIndex]) {
2561
+ var entry = orderedListMarkerEntities[lineIndex];
2556
2562
  var fontSize = this.getValueOfPropertyAt(lineIndex, 0, "fontSize");
2557
2563
  var fontFamily = this.getValueOfPropertyAt(lineIndex, 0, "fontFamily");
2558
2564
  var color = this.getValueOfPropertyAt(lineIndex, 0, "fill");
2559
2565
  var angle = fabricText.angle;
2560
2566
  var theta = angle * Math.PI / 180;
2561
- var xShift = -fontSize * 1.5;
2562
2567
  var yShift = (fabricText.height / 2) + top - fontSize - 1;
2563
2568
  var xOffset = (xShift * Math.cos(theta)) - (yShift * Math.sin(theta));
2564
2569
  var yOffset = (xShift * Math.sin(theta)) + (yShift * Math.cos(theta));
2565
2570
  var lineNumber = _this.getOrderedListStart();
2566
2571
  for (var i = 0; i < lineIndex; i++) {
2567
- if (currentLineNumbers[i])
2572
+ if (orderedListMarkerEntities[i])
2568
2573
  lineNumber++;
2569
2574
  }
2570
2575
  entry.set({
2576
+ width: 1,
2571
2577
  fontSize: fontSize,
2572
2578
  fontFamily: fontFamily,
2573
2579
  fill: color,
@@ -3478,7 +3484,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
3478
3484
  var objects = _(this.objects$.value)
3479
3485
  .map(function (x) { return x.persist(); })
3480
3486
  .value();
3481
- var includedProperties = ["id", "orderedList", "orderedListIndex"];
3487
+ var includedProperties = ["id", "_isSlaveObject", "_isOrderedList", "_orderedListStart"];
3482
3488
  var json = this.fabricCanvas.toJSON(includedProperties);
3483
3489
  return {
3484
3490
  dimensions: this.dimensions$.value,
@@ -3513,6 +3519,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
3513
3519
  this.backgroundColor$.next(this.fabricCanvas.backgroundColor);
3514
3520
  this.bindFields(canvasState.objects);
3515
3521
  this.removePersistedBullets();
3522
+ this.removeSlaveObjects();
3516
3523
  this.layoutManager$.value.onInit();
3517
3524
  return [2 /*return*/];
3518
3525
  }
@@ -3532,6 +3539,17 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
3532
3539
  _this.removeFabricObject(object);
3533
3540
  });
3534
3541
  };
3542
+ /**
3543
+ * Remove any slave objects persisted to the canvas; their master objects will recreate them.
3544
+ */
3545
+ AbstractInteractiveCanvas.prototype.removeSlaveObjects = function () {
3546
+ var _this = this;
3547
+ var objects = this.fabricCanvas.getObjects();
3548
+ _.each(objects, function (object) {
3549
+ if (object._isSlaveObject)
3550
+ _this.removeFabricObject(object);
3551
+ });
3552
+ };
3535
3553
  /**
3536
3554
  * @override
3537
3555
  * @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
+ }
@@ -0,0 +1,7 @@
1
+ import { fabric } from "fabric";
2
+ import { ExtendedFabricObject } from "./extended-fabric-object.interface";
3
+ export interface ExtendedFabricTextbox extends fabric.Textbox, ExtendedFabricObject {
4
+ _isOrderedList?: boolean;
5
+ _orderedListStart?: number;
6
+ _orderedListMarkerEntities?: fabric.Textbox[];
7
+ }
@@ -4,6 +4,7 @@ import { ICanvasObject } from "../canvas-object.interface";
4
4
  import { AbstractCanvasObject } from "../abstract-canvas-object";
5
5
  import { CanvasObjectData } from "../canvas-object-data";
6
6
  import { fabric } from "fabric";
7
+ import { ExtendedFabricTextbox } from "./extended-fabric-textbox.interface";
7
8
  /**
8
9
  * Text field. Displays customizable text.
9
10
  */
@@ -49,7 +50,7 @@ export interface IText extends ICanvasObject, IMutableColor, IMutableText, IMuta
49
50
  */
50
51
  getOrderedListMargin(): number;
51
52
  }
52
- export declare class Text extends AbstractCanvasObject<fabric.Textbox> implements IText {
53
+ export declare class Text extends AbstractCanvasObject<ExtendedFabricTextbox> implements IText {
53
54
  private readonly fontLibrary;
54
55
  private baseComponentHeight;
55
56
  private readonly text$;
@@ -297,7 +298,7 @@ export declare class Text extends AbstractCanvasObject<fabric.Textbox> implement
297
298
  getOrderedListStart(): number;
298
299
  getSizeIncreaseSinceCreation(): number;
299
300
  private removeBullets;
300
- private removeOrderedList;
301
+ private removeOrderedListMarkers;
301
302
  private applyBulletListMonkeyPatches;
302
303
  /**
303
304
  * @override
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leapfrog/interactive-canvas",
3
- "version": "1.14.1",
3
+ "version": "1.14.3",
4
4
  "description": "Leapfrog interactive canvas",
5
5
  "files": [
6
6
  "dist"