@leapfrog/interactive-canvas 2.0.25-beta-12 → 2.0.25-beta-14

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.
@@ -340,7 +340,6 @@ export declare abstract class AbstractInteractiveCanvas implements IInteractiveC
340
340
  * @inheritDoc
341
341
  */
342
342
  cloneObject(sourceObject: FabricObject, objectData: CanvasObjectData): Promise<void>;
343
- private redrawScheduled;
344
343
  /**
345
344
  * Redraw the canvas.
346
345
  */
@@ -232,15 +232,9 @@ class ResizeCanvasLayoutFunction {
232
232
  const targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
233
233
  if (currentDimensions.height !== targetHeight.height) {
234
234
  canvas.setDimensions(targetHeight);
235
- canvas.getObjectsInternal().forEach((object) => {
236
- var _a;
237
- const canvasObj = canvas.getObjectsByTypeInternal(object.type).find(o => o.getId() === object.getId());
238
- if (canvasObj && (((_a = canvasObj.isPinToBottom) === null || _a === void 0 ? void 0 : _a.call(canvasObj)) || object.top > currentDimensions.heightPx * 0.5)) {
239
- object.setCoords();
240
- }
241
- });
242
- canvas.redraw();
243
235
  }
236
+ canvas.getObjectsInternal().forEach((object) => object.setCoords());
237
+ canvas.redraw();
244
238
  }
245
239
  }
246
240
 
@@ -258,46 +252,6 @@ class RepositionBackgroundsLayoutFunction {
258
252
  }
259
253
  }
260
254
 
261
- class AdvancedLayoutManager extends AbstractLayoutManager {
262
- constructor(canvas) {
263
- super(canvas);
264
- this.key = LayoutManager.ADVANCED;
265
- this.pinToBottom = new PinToBottomLayoutFunction();
266
- this.redrawAll = new RedrawAllLayoutFunction();
267
- this.repositionBorders = new RepositionBordersLayoutFunction();
268
- this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
269
- this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
270
- this.resizeCanvas = new ResizeCanvasLayoutFunction();
271
- this.dimensionsLayoutScheduled = false;
272
- }
273
- onCanvasDimensionsChange() {
274
- if (this.dimensionsLayoutScheduled) {
275
- return;
276
- }
277
- this.dimensionsLayoutScheduled = true;
278
- Promise.resolve().then(() => {
279
- this.pinToBottom.execute(this.canvas);
280
- this.repositionCutoffs.execute(this.canvas);
281
- this.repositionBorders.execute(this.canvas);
282
- this.repositionBackgrounds.execute(this.canvas);
283
- this.redrawAll.execute(this.canvas);
284
- this.dimensionsLayoutScheduled = false;
285
- });
286
- }
287
- onTextChange() {
288
- this.resizeCanvas.execute(this.canvas);
289
- }
290
- onObjectListChange() {
291
- this.redrawAll.execute(this.canvas);
292
- }
293
- }
294
-
295
- class UpdateObjectDimensionsLayoutFunction {
296
- execute(canvas) {
297
- canvas.getObjectsInternal().forEach((object) => object.updateDimensions());
298
- }
299
- }
300
-
301
255
  const MIN_MAGNITUDE = 1;
302
256
  class StackObjectsLayoutFunction {
303
257
  execute(canvas) {
@@ -310,7 +264,7 @@ class StackObjectsLayoutFunction {
310
264
  const footerObjects = objects[0];
311
265
  const bodyObjects = objects[1];
312
266
  const bodyWidth = canvasDimensions.widthPx - canvasMargin.right - canvasMargin.left;
313
- // canvas.redraw();
267
+ canvas.redraw();
314
268
  //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.
315
269
  this.applyWidths(allObjects, bodyWidth);
316
270
  const bodyRows = this.getRows(bodyObjects);
@@ -397,12 +351,7 @@ class StackObjectsLayoutFunction {
397
351
  object.setPosition({
398
352
  width: actualWidth
399
353
  });
400
- //object.updateDimensions();
401
- _(objects).forEach((object) => {
402
- if (object.getType() !== ObjectType.VERTICAL_RULE) {
403
- object.updateDimensions();
404
- }
405
- });
354
+ object.updateDimensions();
406
355
  });
407
356
  }
408
357
  adjustCanvasSize(canvas, requiredHeight) {
@@ -463,6 +412,66 @@ class StackObjectsLayoutFunction {
463
412
  }
464
413
  }
465
414
 
415
+ var ObjectType;
416
+ (function (ObjectType) {
417
+ ObjectType["TEXT"] = "TEXT";
418
+ ObjectType["BORDER"] = "BORDER";
419
+ ObjectType["IMAGE"] = "IMAGE";
420
+ ObjectType["RECTANGLE"] = "RECTANGLE";
421
+ ObjectType["LIBRARY_IMAGE"] = "LIBRARY_IMAGE";
422
+ ObjectType["CUTOFF"] = "CUTOFF";
423
+ ObjectType["VERTICAL_RULE"] = "VERTICAL_RULE";
424
+ ObjectType["HORIZONTAL_RULE"] = "HORIZONTAL_RULE";
425
+ ObjectType["RICH_TEXT"] = "RICH_TEXT";
426
+ ObjectType["BACKGROUND_IMAGE"] = "BACKGROUND_IMAGE";
427
+ })(ObjectType || (ObjectType = {}));
428
+
429
+ class AdvancedLayoutManager extends AbstractLayoutManager {
430
+ constructor(canvas) {
431
+ super(canvas);
432
+ this.key = LayoutManager.ADVANCED;
433
+ this.pinToBottom = new PinToBottomLayoutFunction();
434
+ this.redrawAll = new RedrawAllLayoutFunction();
435
+ this.repositionBorders = new RepositionBordersLayoutFunction();
436
+ this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
437
+ this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
438
+ this.resizeCanvas = new ResizeCanvasLayoutFunction();
439
+ this.stackObjects = new StackObjectsLayoutFunction();
440
+ }
441
+ onCanvasDimensionsChange() {
442
+ this.pinToBottom.execute(this.canvas);
443
+ // this.stackObjects.execute(this.canvas);
444
+ this.dimensionChange();
445
+ this.repositionCutoffs.execute(this.canvas);
446
+ this.repositionBorders.execute(this.canvas);
447
+ this.repositionBackgrounds.execute(this.canvas);
448
+ this.redrawAll.execute(this.canvas);
449
+ }
450
+ onTextChange() {
451
+ this.resizeCanvas.execute(this.canvas);
452
+ }
453
+ onObjectListChange() {
454
+ this.redrawAll.execute(this.canvas);
455
+ }
456
+ dimensionChange() {
457
+ const canvasMargin = this.canvas.getMargin();
458
+ const canvasDimensions = this.canvas.getDimensions();
459
+ const allObjects = this.canvas.getObjectsByTypesInternal(ObjectType.TEXT, ObjectType.RICH_TEXT,
460
+ //ObjectType.IMAGE,
461
+ ObjectType.RECTANGLE, ObjectType.VERTICAL_RULE, ObjectType.HORIZONTAL_RULE);
462
+ const bodyWidth = canvasDimensions.widthPx - canvasMargin.right - canvasMargin.left;
463
+ this.canvas.redraw();
464
+ //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.
465
+ this.stackObjects.applyWidths(allObjects, bodyWidth);
466
+ }
467
+ }
468
+
469
+ class UpdateObjectDimensionsLayoutFunction {
470
+ execute(canvas) {
471
+ canvas.getObjectsInternal().forEach((object) => object.updateDimensions());
472
+ }
473
+ }
474
+
466
475
  class StandardLayoutManager extends AbstractLayoutManager {
467
476
  constructor(canvas) {
468
477
  super(canvas);
@@ -475,7 +484,6 @@ class StandardLayoutManager extends AbstractLayoutManager {
475
484
  this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
476
485
  this.stackObjects = new StackObjectsLayoutFunction();
477
486
  this.updateObjectDimensions = new UpdateObjectDimensionsLayoutFunction();
478
- this.layoutBatchScheduled = false;
479
487
  }
480
488
  /**
481
489
  * @override
@@ -517,19 +525,12 @@ class StandardLayoutManager extends AbstractLayoutManager {
517
525
  this.stackAndRedraw();
518
526
  }
519
527
  stackAndRedraw() {
520
- if (this.layoutBatchScheduled) {
521
- return;
522
- }
523
- this.layoutBatchScheduled = true;
524
- Promise.resolve().then(() => {
525
- this.stackObjects.execute(this.canvas);
526
- this.repositionCutoffs.execute(this.canvas);
527
- this.repositionBorders.execute(this.canvas);
528
- this.repositionBackgrounds.execute(this.canvas);
529
- this.updateObjectDimensions.execute(this.canvas);
530
- this.redrawAll.execute(this.canvas);
531
- this.layoutBatchScheduled = false;
532
- });
528
+ this.stackObjects.execute(this.canvas);
529
+ this.repositionCutoffs.execute(this.canvas);
530
+ this.repositionBorders.execute(this.canvas);
531
+ this.repositionBackgrounds.execute(this.canvas);
532
+ this.updateObjectDimensions.execute(this.canvas);
533
+ this.redrawAll.execute(this.canvas);
533
534
  }
534
535
  }
535
536
 
@@ -1790,60 +1791,18 @@ class RichText extends Image {
1790
1791
  }
1791
1792
  }
1792
1793
 
1793
- var ObjectType;
1794
- (function (ObjectType) {
1795
- ObjectType["TEXT"] = "TEXT";
1796
- ObjectType["BORDER"] = "BORDER";
1797
- ObjectType["IMAGE"] = "IMAGE";
1798
- ObjectType["RECTANGLE"] = "RECTANGLE";
1799
- ObjectType["LIBRARY_IMAGE"] = "LIBRARY_IMAGE";
1800
- ObjectType["CUTOFF"] = "CUTOFF";
1801
- ObjectType["VERTICAL_RULE"] = "VERTICAL_RULE";
1802
- ObjectType["HORIZONTAL_RULE"] = "HORIZONTAL_RULE";
1803
- ObjectType["RICH_TEXT"] = "RICH_TEXT";
1804
- ObjectType["BACKGROUND_IMAGE"] = "BACKGROUND_IMAGE";
1805
- })(ObjectType || (ObjectType = {}));
1806
-
1807
1794
  class Text extends AbstractCanvasObject {
1808
1795
  constructor(canvas, fabricObject, persistedField) {
1809
1796
  super(ObjectType.TEXT, canvas, fabricObject, persistedField);
1810
- this.notifyCanvasTimeout = null;
1811
- this.NOTIFY_DELAY_MS = 150;
1812
1797
  this.canvas = canvas;
1813
1798
  this.fontLibrary = canvas.getFontLibrary();
1814
1799
  this.baseComponentHeight = this.fabricObject.height;
1815
1800
  this.text$ = new BehaviorSubject(this.fabricObject.text);
1816
1801
  this.data.userText = this.fabricObject.text;
1817
1802
  this.textSelection$ = new BehaviorSubject(new TextSelection(this.fabricObject, this.fontLibrary));
1818
- //this.fabricObject.set({strokeWidth: 0});
1819
- this.fabricObject.set({
1820
- strokeWidth: 0,
1821
- perPixelTargetFind: false // Disable per-pixel detection for this object
1822
- });
1803
+ this.fabricObject.set({ strokeWidth: 0 });
1823
1804
  this.fabricObject.on("changed", () => this.onTextChange());
1824
1805
  this.fabricObject.on("selection:changed", () => this.onSelectionChange());
1825
- this.fabricObject.containsPoint.bind(this.fabricObject);
1826
- this.fabricObject.containsPoint = function (point) {
1827
- const coords = this.getCoords();
1828
- if (coords.length !== 4)
1829
- return false;
1830
- let inside = false;
1831
- for (let i = 0, j = coords.length - 1; i < coords.length; j = i++) {
1832
- const xi = coords[i].x, yi = coords[i].y;
1833
- const xj = coords[j].x, yj = coords[j].y;
1834
- const intersect = ((yi > point.y) !== (yj > point.y))
1835
- && (point.x < (xj - xi) * (point.y - yi) / (yj - yi) + xi);
1836
- if (intersect)
1837
- inside = !inside;
1838
- }
1839
- return inside;
1840
- };
1841
- this.fabricObject.on("mousedown", (e) => {
1842
- var _a;
1843
- if (!this.fabricObject.isEditing) {
1844
- (_a = e.e) === null || _a === void 0 ? void 0 : _a.preventDefault();
1845
- }
1846
- });
1847
1806
  this.applyBulletListMonkeyPatches();
1848
1807
  }
1849
1808
  /**
@@ -2192,87 +2151,27 @@ class Text extends AbstractCanvasObject {
2192
2151
  * @override
2193
2152
  * @inheritDoc
2194
2153
  */
2195
- /*public getBulletMargin(): number {
2196
- if (!this.isBulleted()) return 0;
2197
-
2154
+ getBulletMargin() {
2155
+ if (!this.isBulleted())
2156
+ return 0;
2198
2157
  let fontSize = 0;
2199
- each(this.fabricObject._textLines, (textLine: string[], lineIndex: number) => {
2158
+ each(this.fabricObject._textLines, (textLine, lineIndex) => {
2200
2159
  fontSize = Math.max(fontSize, this.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
2201
2160
  });
2202
-
2203
2161
  return fontSize * 0.6;
2204
- }*/
2205
- getBulletMargin() {
2206
- if (!this.isBulleted())
2207
- return 0;
2208
- try {
2209
- let fontSize = 0;
2210
- each(this.fabricObject._textLines, (textLine, lineIndex) => {
2211
- const size = this.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize");
2212
- // Sanity check fontSize
2213
- if (isFinite(size) && size > 0 && size < 1000) {
2214
- fontSize = Math.max(fontSize, size);
2215
- }
2216
- });
2217
- // Additional safety check
2218
- if (!isFinite(fontSize) || fontSize < 0 || fontSize > 1000) {
2219
- return 0;
2220
- }
2221
- return fontSize * 0.6;
2222
- }
2223
- catch (e) {
2224
- console.warn('Error calculating bullet margin:', e);
2225
- return 0;
2226
- }
2227
2162
  }
2228
2163
  /**
2229
2164
  * @override
2230
2165
  * @inheritDoc
2231
2166
  */
2232
- /*public getOrderedListMargin(): number {
2233
- if (!this.isOrderedList()) return 0;
2234
-
2235
- const orderedListMarkerEntities = this.fabricObject._orderedListMarkerEntities;
2236
- let maxValue = max(
2237
- (orderedListMarkerEntities ?? [])
2238
- .filter((x: Textbox) => !!x)
2239
- .map((x: fabric.Textbox) => x.getBoundingRect().width)
2240
- );
2241
- return maxValue ? (maxValue * 1.2) : 0;
2242
- }*/
2243
2167
  getOrderedListMargin() {
2244
2168
  if (!this.isOrderedList())
2245
2169
  return 0;
2246
2170
  const orderedListMarkerEntities = this.fabricObject._orderedListMarkerEntities;
2247
- try {
2248
- const widths = (orderedListMarkerEntities !== null && orderedListMarkerEntities !== void 0 ? orderedListMarkerEntities : [])
2249
- .filter((x) => !!x)
2250
- .map((x) => {
2251
- var _a;
2252
- try {
2253
- const rect = x.getBoundingRect();
2254
- const width = (_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0;
2255
- // Sanity check: if width is invalid, return 0
2256
- if (!isFinite(width) || width < 0 || width > 1000) {
2257
- return 0;
2258
- }
2259
- return width;
2260
- }
2261
- catch (e) {
2262
- return 0;
2263
- }
2264
- });
2265
- const maxValue = max(widths);
2266
- // Additional safety: ensure maxValue is a valid number
2267
- if (!maxValue || !isFinite(maxValue) || maxValue < 0 || maxValue > 1000) {
2268
- return 0;
2269
- }
2270
- return maxValue * 1.2;
2271
- }
2272
- catch (e) {
2273
- console.warn('Error calculating ordered list margin:', e);
2274
- return 0;
2275
- }
2171
+ let maxValue = max((orderedListMarkerEntities !== null && orderedListMarkerEntities !== void 0 ? orderedListMarkerEntities : [])
2172
+ .filter((x) => !!x)
2173
+ .map((x) => x.getBoundingRect().width));
2174
+ return maxValue ? (maxValue * 1.2) : 0;
2276
2175
  }
2277
2176
  /**
2278
2177
  * @override
@@ -2607,10 +2506,7 @@ class Text extends AbstractCanvasObject {
2607
2506
  text: `${lineNumber}.`
2608
2507
  });
2609
2508
  }
2610
- /* if (method === "fillText" && this.fabricObject.left <= 3) {
2611
- left = left + this.getOrderedListMargin();
2612
- }*/
2613
- if (method === "fillText" && this.isOrderedList() && this.fabricObject.left <= 3) {
2509
+ if (method === "fillText" && this.fabricObject.left <= 3) {
2614
2510
  left = left + this.getOrderedListMargin();
2615
2511
  }
2616
2512
  this.fabricObject.dirty = true;
@@ -2626,16 +2522,9 @@ class Text extends AbstractCanvasObject {
2626
2522
  const profile = this.canvas.getProfile();
2627
2523
  const allowManualPositioning = !this.canvas.getLayoutManager().isEnforcedPositioning;
2628
2524
  this.fabricObject.set({
2629
- lockMovementX: false,
2630
- lockMovementY: false,
2631
2525
  lockScalingY: true,
2632
2526
  lockScalingX: this.isPinToBottom(),
2633
- lockScalingFlip: true,
2634
- lockRotation: true,
2635
- selectable: true,
2636
- editable: false, // Only enable on double-click
2637
- hoverCursor: "move", // Show move cursor by default
2638
- moveCursor: "move",
2527
+ lockScalingFlip: true
2639
2528
  });
2640
2529
  this.fabricObject.setControlsVisibility({
2641
2530
  tl: false,
@@ -2645,49 +2534,35 @@ class Text extends AbstractCanvasObject {
2645
2534
  ml: allowManualPositioning && profile.allowScale && !this.isPinToBottom(),
2646
2535
  mt: false,
2647
2536
  mr: allowManualPositioning && profile.allowScale && !this.isPinToBottom(),
2648
- mb: false,
2649
- mtr: false
2537
+ mb: false
2650
2538
  });
2651
2539
  this.redraw();
2652
2540
  }
2653
2541
  onTextChange() {
2654
2542
  this.data.userText = this.fabricObject.text;
2655
2543
  this.text$.next(this.fabricObject.text);
2656
- const currentLeft = this.fabricObject.left || 0;
2657
- const canvasWidth = this.canvas.getDimensions().widthPx;
2658
- // Skip expensive getBoundingBox if object is clearly within bounds
2659
- if (currentLeft + (this.fabricObject.width || 0) > canvasWidth * 0.9) {
2660
- if (this.getBoundingBox().width > canvasWidth) {
2661
- this.fabricObject.set({ left: 0, width: canvasWidth });
2662
- this.redraw();
2663
- }
2544
+ if (this.getBoundingBox().width > this.canvas.getDimensions().widthPx) {
2545
+ this.fabricObject.set({ left: 0, width: this.canvas.getDimensions().widthPx });
2546
+ this.redraw();
2664
2547
  }
2665
2548
  }
2666
2549
  onDelete() {
2667
2550
  this.removeBullets();
2668
2551
  }
2669
2552
  onSelectionChange() {
2670
- this.updateTextSelection(false);
2553
+ this.updateTextSelection();
2671
2554
  }
2672
2555
  hasTextSelection() {
2673
2556
  return this.canvas.getSelection().isText && this.textSelection$.value.length > 0;
2674
2557
  }
2675
- updateTextSelection(notifyCanvas = true) {
2558
+ updateTextSelection() {
2676
2559
  if (this.canvas.headless)
2677
2560
  return;
2678
2561
  this.textSelection$.next(new TextSelection(this.fabricObject, this.fontLibrary));
2679
- if (notifyCanvas) {
2680
- this.notifyCanvasOfTextChanges();
2681
- }
2562
+ this.notifyCanvasOfTextChanges();
2682
2563
  }
2683
2564
  notifyCanvasOfTextChanges() {
2684
- if (this.notifyCanvasTimeout) {
2685
- clearTimeout(this.notifyCanvasTimeout);
2686
- }
2687
- this.notifyCanvasTimeout = setTimeout(() => {
2688
- this.canvas.notifyTextChanged();
2689
- this.notifyCanvasTimeout = null;
2690
- }, this.NOTIFY_DELAY_MS);
2565
+ this.canvas.notifyTextChanged();
2691
2566
  }
2692
2567
  }
2693
2568
  Text.NEW_LINE = "\n";
@@ -2853,7 +2728,6 @@ class AbstractInteractiveCanvas {
2853
2728
  this.devicePixelRatio = devicePixelRatio;
2854
2729
  this.fontLibrary = new FontLibrary();
2855
2730
  this.dimensionChangeRejections$ = new Subject();
2856
- this.redrawScheduled = false;
2857
2731
  this.IMAGE_CAPTURE_COEFFICIENT = this.calculateImageCaptureCoefficient();
2858
2732
  /**
2859
2733
  * Fabric defaults to only 2 decimal places when saving, which causes havoc on the scaling of large images.
@@ -3272,7 +3146,6 @@ class AbstractInteractiveCanvas {
3272
3146
  targetFindTolerance: 4,
3273
3147
  splitByGrapheme: true,
3274
3148
  editable: false, // Only enable on double-click
3275
- editingBorderColor: '#2196F3',
3276
3149
  padding: 0,
3277
3150
  cornerSize: 8,
3278
3151
  touchCornerSize: 12
@@ -3724,14 +3597,7 @@ class AbstractInteractiveCanvas {
3724
3597
  * Redraw the canvas.
3725
3598
  */
3726
3599
  redraw() {
3727
- if (this.redrawScheduled) {
3728
- return;
3729
- }
3730
- this.redrawScheduled = true;
3731
- requestAnimationFrame(() => {
3732
- this.fabricCanvas.requestRenderAll();
3733
- this.redrawScheduled = false;
3734
- });
3600
+ this.fabricCanvas.requestRenderAll();
3735
3601
  }
3736
3602
  syncObjectList() {
3737
3603
  const newObjectList = _(this.fabricCanvas.getObjects())
@@ -3857,7 +3723,7 @@ class AbstractInteractiveCanvas {
3857
3723
  * Update the actual dimensions of the canvas by multiplying the requested dimensions by the current zoom factor.
3858
3724
  */
3859
3725
  updateCanvasDimensions(dims, zoom) {
3860
- const oldWidth = this.fabricCanvas.getWidth();
3726
+ //const oldWidth = this.fabricCanvas.getWidth();
3861
3727
  const width = dims.widthPx * zoom;
3862
3728
  const height = dims.heightPx * zoom;
3863
3729
  this.fabricCanvas.setZoom(zoom);
@@ -3865,34 +3731,39 @@ class AbstractInteractiveCanvas {
3865
3731
  width,
3866
3732
  height
3867
3733
  });
3868
- const scaleFactor = width / oldWidth;
3869
- const objects = this.fabricCanvas.getObjects();
3870
- objects.forEach((obj) => {
3871
- obj.set({
3872
- left: obj.left * scaleFactor,
3873
- });
3874
- if (obj.type === "textbox" || obj.type === "text") {
3875
- obj.set({
3876
- scaleX: 1,
3877
- scaleY: 1,
3878
- width: obj.width * scaleFactor,
3879
- });
3880
- }
3881
- else if (obj.type === "border" || obj.type === "rect") {
3882
- obj.set({
3883
- width: obj.width * scaleFactor,
3884
- scaleX: 1,
3885
- strokeUniform: true,
3886
- });
3887
- }
3888
- else {
3889
- obj.set({
3890
- scaleX: obj.scaleX * scaleFactor,
3734
+ /*if (this.layoutManager$.value instanceof AdvancedLayoutManager) {
3735
+ const scaleFactor = width / oldWidth;
3736
+ //this.fabricCanvas.calcOffset();
3737
+ const objects = this.fabricCanvas.getObjects();
3738
+ objects.forEach((obj: any) => {
3739
+ obj.set({ ₹
3740
+ left: obj.left * scaleFactor,
3891
3741
  });
3892
- }
3893
- obj.setCoords();
3894
- });
3895
- this.fabricCanvas.requestRenderAll();
3742
+ if (obj.type === "textbox" || obj.type === "text") {
3743
+ obj.set({
3744
+ scaleX: 1,
3745
+ scaleY: 1,
3746
+ // scaleX: obj.scaleX * scaleFactor,
3747
+ // scaleY: obj.scaleY * scaleFactor,
3748
+ width: obj.width * scaleFactor,
3749
+ });
3750
+ // obj.initDimensions();
3751
+ } else if (obj.type === "border" || obj.type === "rect") {
3752
+ obj.set({
3753
+ width: obj.width * scaleFactor,
3754
+ scaleX: 1,
3755
+ strokeUniform: true,
3756
+ // strokeAlign: "inner",
3757
+ });
3758
+ } else {
3759
+ obj.set({
3760
+ scaleX: obj.scaleX * scaleFactor,
3761
+ });
3762
+ }
3763
+ obj.setCoords();
3764
+ });
3765
+ this.fabricCanvas.requestRenderAll();
3766
+ }*/
3896
3767
  }
3897
3768
  onProfileChanged(profile) {
3898
3769
  this.setMultiSelect(profile.allowMultiSelect);
@@ -4047,7 +3918,7 @@ class InteractiveCanvas extends AbstractInteractiveCanvas {
4047
3918
  this.fabricCanvas.on("selection:created", (event) => this.onFabricSelectionChanged(event));
4048
3919
  this.fabricCanvas.on("selection:cleared", (event) => this.onFabricSelectionChanged(event));
4049
3920
  this.fabricCanvas.on("text:editing:entered", () => this.onTextEditing());
4050
- //this.fabricCanvas.on("text:editing:exited", () => this.onTextEditing());
3921
+ this.fabricCanvas.on("text:editing:exited", () => this.onTextEditing());
4051
3922
  this.fabricCanvas.on("text:editing:exited", (event) => {
4052
3923
  this.onTextEditing();
4053
3924
  const target = event.target;
@@ -253,15 +253,9 @@ class ResizeCanvasLayoutFunction {
253
253
  const targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
254
254
  if (currentDimensions.height !== targetHeight.height) {
255
255
  canvas.setDimensions(targetHeight);
256
- canvas.getObjectsInternal().forEach((object) => {
257
- var _a;
258
- const canvasObj = canvas.getObjectsByTypeInternal(object.type).find(o => o.getId() === object.getId());
259
- if (canvasObj && (((_a = canvasObj.isPinToBottom) === null || _a === void 0 ? void 0 : _a.call(canvasObj)) || object.top > currentDimensions.heightPx * 0.5)) {
260
- object.setCoords();
261
- }
262
- });
263
- canvas.redraw();
264
256
  }
257
+ canvas.getObjectsInternal().forEach((object) => object.setCoords());
258
+ canvas.redraw();
265
259
  }
266
260
  }
267
261
 
@@ -279,46 +273,6 @@ class RepositionBackgroundsLayoutFunction {
279
273
  }
280
274
  }
281
275
 
282
- class AdvancedLayoutManager extends AbstractLayoutManager {
283
- constructor(canvas) {
284
- super(canvas);
285
- this.key = exports.LayoutManager.ADVANCED;
286
- this.pinToBottom = new PinToBottomLayoutFunction();
287
- this.redrawAll = new RedrawAllLayoutFunction();
288
- this.repositionBorders = new RepositionBordersLayoutFunction();
289
- this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
290
- this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
291
- this.resizeCanvas = new ResizeCanvasLayoutFunction();
292
- this.dimensionsLayoutScheduled = false;
293
- }
294
- onCanvasDimensionsChange() {
295
- if (this.dimensionsLayoutScheduled) {
296
- return;
297
- }
298
- this.dimensionsLayoutScheduled = true;
299
- Promise.resolve().then(() => {
300
- this.pinToBottom.execute(this.canvas);
301
- this.repositionCutoffs.execute(this.canvas);
302
- this.repositionBorders.execute(this.canvas);
303
- this.repositionBackgrounds.execute(this.canvas);
304
- this.redrawAll.execute(this.canvas);
305
- this.dimensionsLayoutScheduled = false;
306
- });
307
- }
308
- onTextChange() {
309
- this.resizeCanvas.execute(this.canvas);
310
- }
311
- onObjectListChange() {
312
- this.redrawAll.execute(this.canvas);
313
- }
314
- }
315
-
316
- class UpdateObjectDimensionsLayoutFunction {
317
- execute(canvas) {
318
- canvas.getObjectsInternal().forEach((object) => object.updateDimensions());
319
- }
320
- }
321
-
322
276
  const MIN_MAGNITUDE = 1;
323
277
  class StackObjectsLayoutFunction {
324
278
  execute(canvas) {
@@ -331,7 +285,7 @@ class StackObjectsLayoutFunction {
331
285
  const footerObjects = objects[0];
332
286
  const bodyObjects = objects[1];
333
287
  const bodyWidth = canvasDimensions.widthPx - canvasMargin.right - canvasMargin.left;
334
- // canvas.redraw();
288
+ canvas.redraw();
335
289
  //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.
336
290
  this.applyWidths(allObjects, bodyWidth);
337
291
  const bodyRows = this.getRows(bodyObjects);
@@ -418,12 +372,7 @@ class StackObjectsLayoutFunction {
418
372
  object.setPosition({
419
373
  width: actualWidth
420
374
  });
421
- //object.updateDimensions();
422
- _(objects).forEach((object) => {
423
- if (object.getType() !== exports.ObjectType.VERTICAL_RULE) {
424
- object.updateDimensions();
425
- }
426
- });
375
+ object.updateDimensions();
427
376
  });
428
377
  }
429
378
  adjustCanvasSize(canvas, requiredHeight) {
@@ -484,6 +433,66 @@ class StackObjectsLayoutFunction {
484
433
  }
485
434
  }
486
435
 
436
+ exports.ObjectType = void 0;
437
+ (function (ObjectType) {
438
+ ObjectType["TEXT"] = "TEXT";
439
+ ObjectType["BORDER"] = "BORDER";
440
+ ObjectType["IMAGE"] = "IMAGE";
441
+ ObjectType["RECTANGLE"] = "RECTANGLE";
442
+ ObjectType["LIBRARY_IMAGE"] = "LIBRARY_IMAGE";
443
+ ObjectType["CUTOFF"] = "CUTOFF";
444
+ ObjectType["VERTICAL_RULE"] = "VERTICAL_RULE";
445
+ ObjectType["HORIZONTAL_RULE"] = "HORIZONTAL_RULE";
446
+ ObjectType["RICH_TEXT"] = "RICH_TEXT";
447
+ ObjectType["BACKGROUND_IMAGE"] = "BACKGROUND_IMAGE";
448
+ })(exports.ObjectType || (exports.ObjectType = {}));
449
+
450
+ class AdvancedLayoutManager extends AbstractLayoutManager {
451
+ constructor(canvas) {
452
+ super(canvas);
453
+ this.key = exports.LayoutManager.ADVANCED;
454
+ this.pinToBottom = new PinToBottomLayoutFunction();
455
+ this.redrawAll = new RedrawAllLayoutFunction();
456
+ this.repositionBorders = new RepositionBordersLayoutFunction();
457
+ this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
458
+ this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
459
+ this.resizeCanvas = new ResizeCanvasLayoutFunction();
460
+ this.stackObjects = new StackObjectsLayoutFunction();
461
+ }
462
+ onCanvasDimensionsChange() {
463
+ this.pinToBottom.execute(this.canvas);
464
+ // this.stackObjects.execute(this.canvas);
465
+ this.dimensionChange();
466
+ this.repositionCutoffs.execute(this.canvas);
467
+ this.repositionBorders.execute(this.canvas);
468
+ this.repositionBackgrounds.execute(this.canvas);
469
+ this.redrawAll.execute(this.canvas);
470
+ }
471
+ onTextChange() {
472
+ this.resizeCanvas.execute(this.canvas);
473
+ }
474
+ onObjectListChange() {
475
+ this.redrawAll.execute(this.canvas);
476
+ }
477
+ dimensionChange() {
478
+ const canvasMargin = this.canvas.getMargin();
479
+ const canvasDimensions = this.canvas.getDimensions();
480
+ const allObjects = this.canvas.getObjectsByTypesInternal(exports.ObjectType.TEXT, exports.ObjectType.RICH_TEXT,
481
+ //ObjectType.IMAGE,
482
+ exports.ObjectType.RECTANGLE, exports.ObjectType.VERTICAL_RULE, exports.ObjectType.HORIZONTAL_RULE);
483
+ const bodyWidth = canvasDimensions.widthPx - canvasMargin.right - canvasMargin.left;
484
+ this.canvas.redraw();
485
+ //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.
486
+ this.stackObjects.applyWidths(allObjects, bodyWidth);
487
+ }
488
+ }
489
+
490
+ class UpdateObjectDimensionsLayoutFunction {
491
+ execute(canvas) {
492
+ canvas.getObjectsInternal().forEach((object) => object.updateDimensions());
493
+ }
494
+ }
495
+
487
496
  class StandardLayoutManager extends AbstractLayoutManager {
488
497
  constructor(canvas) {
489
498
  super(canvas);
@@ -496,7 +505,6 @@ class StandardLayoutManager extends AbstractLayoutManager {
496
505
  this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
497
506
  this.stackObjects = new StackObjectsLayoutFunction();
498
507
  this.updateObjectDimensions = new UpdateObjectDimensionsLayoutFunction();
499
- this.layoutBatchScheduled = false;
500
508
  }
501
509
  /**
502
510
  * @override
@@ -538,19 +546,12 @@ class StandardLayoutManager extends AbstractLayoutManager {
538
546
  this.stackAndRedraw();
539
547
  }
540
548
  stackAndRedraw() {
541
- if (this.layoutBatchScheduled) {
542
- return;
543
- }
544
- this.layoutBatchScheduled = true;
545
- Promise.resolve().then(() => {
546
- this.stackObjects.execute(this.canvas);
547
- this.repositionCutoffs.execute(this.canvas);
548
- this.repositionBorders.execute(this.canvas);
549
- this.repositionBackgrounds.execute(this.canvas);
550
- this.updateObjectDimensions.execute(this.canvas);
551
- this.redrawAll.execute(this.canvas);
552
- this.layoutBatchScheduled = false;
553
- });
549
+ this.stackObjects.execute(this.canvas);
550
+ this.repositionCutoffs.execute(this.canvas);
551
+ this.repositionBorders.execute(this.canvas);
552
+ this.repositionBackgrounds.execute(this.canvas);
553
+ this.updateObjectDimensions.execute(this.canvas);
554
+ this.redrawAll.execute(this.canvas);
554
555
  }
555
556
  }
556
557
 
@@ -1811,60 +1812,18 @@ class RichText extends Image {
1811
1812
  }
1812
1813
  }
1813
1814
 
1814
- exports.ObjectType = void 0;
1815
- (function (ObjectType) {
1816
- ObjectType["TEXT"] = "TEXT";
1817
- ObjectType["BORDER"] = "BORDER";
1818
- ObjectType["IMAGE"] = "IMAGE";
1819
- ObjectType["RECTANGLE"] = "RECTANGLE";
1820
- ObjectType["LIBRARY_IMAGE"] = "LIBRARY_IMAGE";
1821
- ObjectType["CUTOFF"] = "CUTOFF";
1822
- ObjectType["VERTICAL_RULE"] = "VERTICAL_RULE";
1823
- ObjectType["HORIZONTAL_RULE"] = "HORIZONTAL_RULE";
1824
- ObjectType["RICH_TEXT"] = "RICH_TEXT";
1825
- ObjectType["BACKGROUND_IMAGE"] = "BACKGROUND_IMAGE";
1826
- })(exports.ObjectType || (exports.ObjectType = {}));
1827
-
1828
1815
  class Text extends AbstractCanvasObject {
1829
1816
  constructor(canvas, fabricObject, persistedField) {
1830
1817
  super(exports.ObjectType.TEXT, canvas, fabricObject, persistedField);
1831
- this.notifyCanvasTimeout = null;
1832
- this.NOTIFY_DELAY_MS = 150;
1833
1818
  this.canvas = canvas;
1834
1819
  this.fontLibrary = canvas.getFontLibrary();
1835
1820
  this.baseComponentHeight = this.fabricObject.height;
1836
1821
  this.text$ = new rxjs.BehaviorSubject(this.fabricObject.text);
1837
1822
  this.data.userText = this.fabricObject.text;
1838
1823
  this.textSelection$ = new rxjs.BehaviorSubject(new TextSelection(this.fabricObject, this.fontLibrary));
1839
- //this.fabricObject.set({strokeWidth: 0});
1840
- this.fabricObject.set({
1841
- strokeWidth: 0,
1842
- perPixelTargetFind: false // Disable per-pixel detection for this object
1843
- });
1824
+ this.fabricObject.set({ strokeWidth: 0 });
1844
1825
  this.fabricObject.on("changed", () => this.onTextChange());
1845
1826
  this.fabricObject.on("selection:changed", () => this.onSelectionChange());
1846
- this.fabricObject.containsPoint.bind(this.fabricObject);
1847
- this.fabricObject.containsPoint = function (point) {
1848
- const coords = this.getCoords();
1849
- if (coords.length !== 4)
1850
- return false;
1851
- let inside = false;
1852
- for (let i = 0, j = coords.length - 1; i < coords.length; j = i++) {
1853
- const xi = coords[i].x, yi = coords[i].y;
1854
- const xj = coords[j].x, yj = coords[j].y;
1855
- const intersect = ((yi > point.y) !== (yj > point.y))
1856
- && (point.x < (xj - xi) * (point.y - yi) / (yj - yi) + xi);
1857
- if (intersect)
1858
- inside = !inside;
1859
- }
1860
- return inside;
1861
- };
1862
- this.fabricObject.on("mousedown", (e) => {
1863
- var _a;
1864
- if (!this.fabricObject.isEditing) {
1865
- (_a = e.e) === null || _a === void 0 ? void 0 : _a.preventDefault();
1866
- }
1867
- });
1868
1827
  this.applyBulletListMonkeyPatches();
1869
1828
  }
1870
1829
  /**
@@ -2213,87 +2172,27 @@ class Text extends AbstractCanvasObject {
2213
2172
  * @override
2214
2173
  * @inheritDoc
2215
2174
  */
2216
- /*public getBulletMargin(): number {
2217
- if (!this.isBulleted()) return 0;
2218
-
2175
+ getBulletMargin() {
2176
+ if (!this.isBulleted())
2177
+ return 0;
2219
2178
  let fontSize = 0;
2220
- each(this.fabricObject._textLines, (textLine: string[], lineIndex: number) => {
2179
+ _.each(this.fabricObject._textLines, (textLine, lineIndex) => {
2221
2180
  fontSize = Math.max(fontSize, this.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
2222
2181
  });
2223
-
2224
2182
  return fontSize * 0.6;
2225
- }*/
2226
- getBulletMargin() {
2227
- if (!this.isBulleted())
2228
- return 0;
2229
- try {
2230
- let fontSize = 0;
2231
- _.each(this.fabricObject._textLines, (textLine, lineIndex) => {
2232
- const size = this.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize");
2233
- // Sanity check fontSize
2234
- if (isFinite(size) && size > 0 && size < 1000) {
2235
- fontSize = Math.max(fontSize, size);
2236
- }
2237
- });
2238
- // Additional safety check
2239
- if (!isFinite(fontSize) || fontSize < 0 || fontSize > 1000) {
2240
- return 0;
2241
- }
2242
- return fontSize * 0.6;
2243
- }
2244
- catch (e) {
2245
- console.warn('Error calculating bullet margin:', e);
2246
- return 0;
2247
- }
2248
2183
  }
2249
2184
  /**
2250
2185
  * @override
2251
2186
  * @inheritDoc
2252
2187
  */
2253
- /*public getOrderedListMargin(): number {
2254
- if (!this.isOrderedList()) return 0;
2255
-
2256
- const orderedListMarkerEntities = this.fabricObject._orderedListMarkerEntities;
2257
- let maxValue = max(
2258
- (orderedListMarkerEntities ?? [])
2259
- .filter((x: Textbox) => !!x)
2260
- .map((x: fabric.Textbox) => x.getBoundingRect().width)
2261
- );
2262
- return maxValue ? (maxValue * 1.2) : 0;
2263
- }*/
2264
2188
  getOrderedListMargin() {
2265
2189
  if (!this.isOrderedList())
2266
2190
  return 0;
2267
2191
  const orderedListMarkerEntities = this.fabricObject._orderedListMarkerEntities;
2268
- try {
2269
- const widths = (orderedListMarkerEntities !== null && orderedListMarkerEntities !== void 0 ? orderedListMarkerEntities : [])
2270
- .filter((x) => !!x)
2271
- .map((x) => {
2272
- var _a;
2273
- try {
2274
- const rect = x.getBoundingRect();
2275
- const width = (_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0;
2276
- // Sanity check: if width is invalid, return 0
2277
- if (!isFinite(width) || width < 0 || width > 1000) {
2278
- return 0;
2279
- }
2280
- return width;
2281
- }
2282
- catch (e) {
2283
- return 0;
2284
- }
2285
- });
2286
- const maxValue = _.max(widths);
2287
- // Additional safety: ensure maxValue is a valid number
2288
- if (!maxValue || !isFinite(maxValue) || maxValue < 0 || maxValue > 1000) {
2289
- return 0;
2290
- }
2291
- return maxValue * 1.2;
2292
- }
2293
- catch (e) {
2294
- console.warn('Error calculating ordered list margin:', e);
2295
- return 0;
2296
- }
2192
+ let maxValue = _.max((orderedListMarkerEntities !== null && orderedListMarkerEntities !== void 0 ? orderedListMarkerEntities : [])
2193
+ .filter((x) => !!x)
2194
+ .map((x) => x.getBoundingRect().width));
2195
+ return maxValue ? (maxValue * 1.2) : 0;
2297
2196
  }
2298
2197
  /**
2299
2198
  * @override
@@ -2628,10 +2527,7 @@ class Text extends AbstractCanvasObject {
2628
2527
  text: `${lineNumber}.`
2629
2528
  });
2630
2529
  }
2631
- /* if (method === "fillText" && this.fabricObject.left <= 3) {
2632
- left = left + this.getOrderedListMargin();
2633
- }*/
2634
- if (method === "fillText" && this.isOrderedList() && this.fabricObject.left <= 3) {
2530
+ if (method === "fillText" && this.fabricObject.left <= 3) {
2635
2531
  left = left + this.getOrderedListMargin();
2636
2532
  }
2637
2533
  this.fabricObject.dirty = true;
@@ -2647,16 +2543,9 @@ class Text extends AbstractCanvasObject {
2647
2543
  const profile = this.canvas.getProfile();
2648
2544
  const allowManualPositioning = !this.canvas.getLayoutManager().isEnforcedPositioning;
2649
2545
  this.fabricObject.set({
2650
- lockMovementX: false,
2651
- lockMovementY: false,
2652
2546
  lockScalingY: true,
2653
2547
  lockScalingX: this.isPinToBottom(),
2654
- lockScalingFlip: true,
2655
- lockRotation: true,
2656
- selectable: true,
2657
- editable: false, // Only enable on double-click
2658
- hoverCursor: "move", // Show move cursor by default
2659
- moveCursor: "move",
2548
+ lockScalingFlip: true
2660
2549
  });
2661
2550
  this.fabricObject.setControlsVisibility({
2662
2551
  tl: false,
@@ -2666,49 +2555,35 @@ class Text extends AbstractCanvasObject {
2666
2555
  ml: allowManualPositioning && profile.allowScale && !this.isPinToBottom(),
2667
2556
  mt: false,
2668
2557
  mr: allowManualPositioning && profile.allowScale && !this.isPinToBottom(),
2669
- mb: false,
2670
- mtr: false
2558
+ mb: false
2671
2559
  });
2672
2560
  this.redraw();
2673
2561
  }
2674
2562
  onTextChange() {
2675
2563
  this.data.userText = this.fabricObject.text;
2676
2564
  this.text$.next(this.fabricObject.text);
2677
- const currentLeft = this.fabricObject.left || 0;
2678
- const canvasWidth = this.canvas.getDimensions().widthPx;
2679
- // Skip expensive getBoundingBox if object is clearly within bounds
2680
- if (currentLeft + (this.fabricObject.width || 0) > canvasWidth * 0.9) {
2681
- if (this.getBoundingBox().width > canvasWidth) {
2682
- this.fabricObject.set({ left: 0, width: canvasWidth });
2683
- this.redraw();
2684
- }
2565
+ if (this.getBoundingBox().width > this.canvas.getDimensions().widthPx) {
2566
+ this.fabricObject.set({ left: 0, width: this.canvas.getDimensions().widthPx });
2567
+ this.redraw();
2685
2568
  }
2686
2569
  }
2687
2570
  onDelete() {
2688
2571
  this.removeBullets();
2689
2572
  }
2690
2573
  onSelectionChange() {
2691
- this.updateTextSelection(false);
2574
+ this.updateTextSelection();
2692
2575
  }
2693
2576
  hasTextSelection() {
2694
2577
  return this.canvas.getSelection().isText && this.textSelection$.value.length > 0;
2695
2578
  }
2696
- updateTextSelection(notifyCanvas = true) {
2579
+ updateTextSelection() {
2697
2580
  if (this.canvas.headless)
2698
2581
  return;
2699
2582
  this.textSelection$.next(new TextSelection(this.fabricObject, this.fontLibrary));
2700
- if (notifyCanvas) {
2701
- this.notifyCanvasOfTextChanges();
2702
- }
2583
+ this.notifyCanvasOfTextChanges();
2703
2584
  }
2704
2585
  notifyCanvasOfTextChanges() {
2705
- if (this.notifyCanvasTimeout) {
2706
- clearTimeout(this.notifyCanvasTimeout);
2707
- }
2708
- this.notifyCanvasTimeout = setTimeout(() => {
2709
- this.canvas.notifyTextChanged();
2710
- this.notifyCanvasTimeout = null;
2711
- }, this.NOTIFY_DELAY_MS);
2586
+ this.canvas.notifyTextChanged();
2712
2587
  }
2713
2588
  }
2714
2589
  Text.NEW_LINE = "\n";
@@ -2874,7 +2749,6 @@ class AbstractInteractiveCanvas {
2874
2749
  this.devicePixelRatio = devicePixelRatio;
2875
2750
  this.fontLibrary = new FontLibrary();
2876
2751
  this.dimensionChangeRejections$ = new rxjs.Subject();
2877
- this.redrawScheduled = false;
2878
2752
  this.IMAGE_CAPTURE_COEFFICIENT = this.calculateImageCaptureCoefficient();
2879
2753
  /**
2880
2754
  * Fabric defaults to only 2 decimal places when saving, which causes havoc on the scaling of large images.
@@ -3293,7 +3167,6 @@ class AbstractInteractiveCanvas {
3293
3167
  targetFindTolerance: 4,
3294
3168
  splitByGrapheme: true,
3295
3169
  editable: false, // Only enable on double-click
3296
- editingBorderColor: '#2196F3',
3297
3170
  padding: 0,
3298
3171
  cornerSize: 8,
3299
3172
  touchCornerSize: 12
@@ -3745,14 +3618,7 @@ class AbstractInteractiveCanvas {
3745
3618
  * Redraw the canvas.
3746
3619
  */
3747
3620
  redraw() {
3748
- if (this.redrawScheduled) {
3749
- return;
3750
- }
3751
- this.redrawScheduled = true;
3752
- requestAnimationFrame(() => {
3753
- this.fabricCanvas.requestRenderAll();
3754
- this.redrawScheduled = false;
3755
- });
3621
+ this.fabricCanvas.requestRenderAll();
3756
3622
  }
3757
3623
  syncObjectList() {
3758
3624
  const newObjectList = _(this.fabricCanvas.getObjects())
@@ -3878,7 +3744,7 @@ class AbstractInteractiveCanvas {
3878
3744
  * Update the actual dimensions of the canvas by multiplying the requested dimensions by the current zoom factor.
3879
3745
  */
3880
3746
  updateCanvasDimensions(dims, zoom) {
3881
- const oldWidth = this.fabricCanvas.getWidth();
3747
+ //const oldWidth = this.fabricCanvas.getWidth();
3882
3748
  const width = dims.widthPx * zoom;
3883
3749
  const height = dims.heightPx * zoom;
3884
3750
  this.fabricCanvas.setZoom(zoom);
@@ -3886,34 +3752,39 @@ class AbstractInteractiveCanvas {
3886
3752
  width,
3887
3753
  height
3888
3754
  });
3889
- const scaleFactor = width / oldWidth;
3890
- const objects = this.fabricCanvas.getObjects();
3891
- objects.forEach((obj) => {
3892
- obj.set({
3893
- left: obj.left * scaleFactor,
3894
- });
3895
- if (obj.type === "textbox" || obj.type === "text") {
3896
- obj.set({
3897
- scaleX: 1,
3898
- scaleY: 1,
3899
- width: obj.width * scaleFactor,
3900
- });
3901
- }
3902
- else if (obj.type === "border" || obj.type === "rect") {
3903
- obj.set({
3904
- width: obj.width * scaleFactor,
3905
- scaleX: 1,
3906
- strokeUniform: true,
3907
- });
3908
- }
3909
- else {
3910
- obj.set({
3911
- scaleX: obj.scaleX * scaleFactor,
3755
+ /*if (this.layoutManager$.value instanceof AdvancedLayoutManager) {
3756
+ const scaleFactor = width / oldWidth;
3757
+ //this.fabricCanvas.calcOffset();
3758
+ const objects = this.fabricCanvas.getObjects();
3759
+ objects.forEach((obj: any) => {
3760
+ obj.set({ ₹
3761
+ left: obj.left * scaleFactor,
3912
3762
  });
3913
- }
3914
- obj.setCoords();
3915
- });
3916
- this.fabricCanvas.requestRenderAll();
3763
+ if (obj.type === "textbox" || obj.type === "text") {
3764
+ obj.set({
3765
+ scaleX: 1,
3766
+ scaleY: 1,
3767
+ // scaleX: obj.scaleX * scaleFactor,
3768
+ // scaleY: obj.scaleY * scaleFactor,
3769
+ width: obj.width * scaleFactor,
3770
+ });
3771
+ // obj.initDimensions();
3772
+ } else if (obj.type === "border" || obj.type === "rect") {
3773
+ obj.set({
3774
+ width: obj.width * scaleFactor,
3775
+ scaleX: 1,
3776
+ strokeUniform: true,
3777
+ // strokeAlign: "inner",
3778
+ });
3779
+ } else {
3780
+ obj.set({
3781
+ scaleX: obj.scaleX * scaleFactor,
3782
+ });
3783
+ }
3784
+ obj.setCoords();
3785
+ });
3786
+ this.fabricCanvas.requestRenderAll();
3787
+ }*/
3917
3788
  }
3918
3789
  onProfileChanged(profile) {
3919
3790
  this.setMultiSelect(profile.allowMultiSelect);
@@ -4068,7 +3939,7 @@ class InteractiveCanvas extends AbstractInteractiveCanvas {
4068
3939
  this.fabricCanvas.on("selection:created", (event) => this.onFabricSelectionChanged(event));
4069
3940
  this.fabricCanvas.on("selection:cleared", (event) => this.onFabricSelectionChanged(event));
4070
3941
  this.fabricCanvas.on("text:editing:entered", () => this.onTextEditing());
4071
- //this.fabricCanvas.on("text:editing:exited", () => this.onTextEditing());
3942
+ this.fabricCanvas.on("text:editing:exited", () => this.onTextEditing());
4072
3943
  this.fabricCanvas.on("text:editing:exited", (event) => {
4073
3944
  this.onTextEditing();
4074
3945
  const target = event.target;
@@ -9,9 +9,10 @@ export declare class AdvancedLayoutManager extends AbstractLayoutManager {
9
9
  private repositionCutoffs;
10
10
  private repositionBackgrounds;
11
11
  private resizeCanvas;
12
- private dimensionsLayoutScheduled;
12
+ private stackObjects;
13
13
  constructor(canvas: IInteractiveCanvas);
14
14
  onCanvasDimensionsChange(): void;
15
15
  onTextChange(): void;
16
16
  onObjectListChange(): void;
17
+ private dimensionChange;
17
18
  }
@@ -1,9 +1,10 @@
1
+ import { AbstractCanvasObject } from "../..";
1
2
  import { IInteractiveCanvas } from "../../interactive-canvas.interface";
2
3
  export declare class StackObjectsLayoutFunction {
3
4
  execute(canvas: IInteractiveCanvas): void;
4
5
  private layoutFooter;
5
6
  private layoutBody;
6
- private applyWidths;
7
+ applyWidths(objects: Array<AbstractCanvasObject<any>>, layoutWidth: number): void;
7
8
  private adjustCanvasSize;
8
9
  private getRows;
9
10
  private getObjectHeight;
@@ -36,6 +36,5 @@ export declare class StandardLayoutManager extends AbstractLayoutManager {
36
36
  * @override
37
37
  */
38
38
  onMarginChange(): void;
39
- private layoutBatchScheduled;
40
39
  private stackAndRedraw;
41
40
  }
@@ -63,8 +63,6 @@ export declare class Text extends AbstractCanvasObject<ExtendedFabricTextbox> im
63
63
  private readonly text$;
64
64
  private readonly textSelection$;
65
65
  static readonly NEW_LINE: string;
66
- private notifyCanvasTimeout;
67
- private readonly NOTIFY_DELAY_MS;
68
66
  constructor(canvas: IInteractiveCanvas, fabricObject: fabric.Textbox, persistedField?: CanvasObjectData);
69
67
  /**
70
68
  * @override
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leapfrog/interactive-canvas",
3
- "version": "2.0.25-beta-12",
3
+ "version": "2.0.25-beta-14",
4
4
  "description": "Leapfrog interactive canvas",
5
5
  "files": [
6
6
  "dist"
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "canvas": "^3.2.3",
22
- "fabric": "7.4.0",
22
+ "fabric": "^7.2.0",
23
23
  "lodash": "^4.18.1",
24
24
  "rollup": "^4.60.3",
25
25
  "rollup-plugin-typescript2": "^0.37.0",