@pixldocs/canvas-renderer 0.5.10 → 0.5.11

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/index.js CHANGED
@@ -12549,23 +12549,41 @@ class PixldocsRenderer {
12549
12549
  clearMeasurementCache();
12550
12550
  };
12551
12551
  const reflowTextboxes = () => {
12552
- var _a2, _b;
12552
+ var _a2, _b, _c;
12553
12553
  const walk = (obj) => {
12554
- var _a3, _b2;
12554
+ var _a3, _b2, _c2, _d;
12555
12555
  if (!obj) return;
12556
12556
  const children = Array.isArray(obj._objects) ? obj._objects : Array.isArray(obj.objects) ? obj.objects : [];
12557
12557
  if (children.length) children.forEach(walk);
12558
- if (typeof obj.initDimensions === "function" && (obj.type === "textbox" || obj.isEditing !== void 0)) {
12559
- const savedWidth = obj.width;
12558
+ const isTextObject = typeof obj.text === "string" && typeof obj.initDimensions === "function" && (obj.type === "textbox" || obj.type === "text" || obj.type === "i-text" || obj.isEditing !== void 0);
12559
+ if (isTextObject) {
12560
+ const saved = {
12561
+ width: obj.width,
12562
+ scaleX: obj.scaleX,
12563
+ scaleY: obj.scaleY
12564
+ };
12565
+ (_a3 = obj._clearCache) == null ? void 0 : _a3.call(obj);
12566
+ obj.__charBounds = [];
12567
+ obj.__lineWidths = [];
12568
+ obj.__lineHeights = [];
12569
+ obj._textLines = [];
12570
+ obj.textLines = [];
12560
12571
  obj.dirty = true;
12561
12572
  obj.initDimensions();
12562
- if (savedWidth != null) (_a3 = obj.set) == null ? void 0 : _a3.call(obj, { width: savedWidth });
12563
- (_b2 = obj.setCoords) == null ? void 0 : _b2.call(obj);
12573
+ (_b2 = obj.set) == null ? void 0 : _b2.call(obj, {
12574
+ width: saved.width,
12575
+ scaleX: saved.scaleX,
12576
+ scaleY: saved.scaleY,
12577
+ dirty: true
12578
+ });
12579
+ (_c2 = obj._clearCache) == null ? void 0 : _c2.call(obj);
12580
+ (_d = obj.setCoords) == null ? void 0 : _d.call(obj);
12564
12581
  }
12565
12582
  };
12566
12583
  fabricInstance.getObjects().forEach(walk);
12567
12584
  (_a2 = fabricInstance.calcOffset) == null ? void 0 : _a2.call(fabricInstance);
12568
- (_b = fabricInstance.requestRenderAll) == null ? void 0 : _b.call(fabricInstance);
12585
+ (_b = fabricInstance.renderAll) == null ? void 0 : _b.call(fabricInstance);
12586
+ (_c = fabricInstance.requestRenderAll) == null ? void 0 : _c.call(fabricInstance);
12569
12587
  };
12570
12588
  clearTextMetricCaches();
12571
12589
  await waitForPaint();