@pixldocs/canvas-renderer 0.5.35 → 0.5.36

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.cjs CHANGED
@@ -12741,40 +12741,30 @@ class PixldocsRenderer {
12741
12741
  const fabricInstance = this.getFabricCanvasFromContainer(container);
12742
12742
  if (!(fabricInstance == null ? void 0 : fabricInstance.getObjects)) return;
12743
12743
  const waitForPaint = () => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r())));
12744
- const clearTextMetricCaches = () => {
12745
- clearFabricCharCache();
12746
- clearMeasurementCache();
12747
- };
12748
- const resyncTextboxWidths = (obj) => {
12744
+ const primeCharBounds = (obj) => {
12749
12745
  if (obj instanceof fabric__namespace.Textbox) {
12750
- const savedWidth = Math.max(1, obj.width ?? 0);
12751
- const savedScaleX = obj.scaleX ?? 1;
12752
- const savedScaleY = obj.scaleY ?? 1;
12753
- obj.initDimensions();
12754
- if (Math.abs((obj.width ?? 0) - savedWidth) > 0.01) {
12755
- obj.width = savedWidth;
12756
- }
12757
- if (Math.abs((obj.scaleX ?? 1) - savedScaleX) > 0.01) {
12758
- obj.scaleX = savedScaleX;
12759
- }
12760
- if (Math.abs((obj.scaleY ?? 1) - savedScaleY) > 0.01) {
12761
- obj.scaleY = savedScaleY;
12746
+ const lines = obj._textLines;
12747
+ if (Array.isArray(lines)) {
12748
+ for (let i = 0; i < lines.length; i++) {
12749
+ try {
12750
+ obj.getLineWidth(i);
12751
+ } catch {
12752
+ }
12753
+ }
12762
12754
  }
12763
- obj.setCoords();
12764
12755
  obj.dirty = true;
12765
12756
  return;
12766
12757
  }
12767
12758
  if (obj instanceof fabric__namespace.Group) {
12768
- obj.getObjects().forEach(resyncTextboxWidths);
12759
+ obj.getObjects().forEach(primeCharBounds);
12769
12760
  obj.dirty = true;
12770
12761
  }
12771
12762
  };
12772
- clearTextMetricCaches();
12773
- await waitForPaint();
12774
- fabricInstance.getObjects().forEach(resyncTextboxWidths);
12763
+ fabricInstance.getObjects().forEach(primeCharBounds);
12775
12764
  (_a = fabricInstance.calcOffset) == null ? void 0 : _a.call(fabricInstance);
12776
12765
  (_b = fabricInstance.renderAll) == null ? void 0 : _b.call(fabricInstance);
12777
- (_c = fabricInstance.requestRenderAll) == null ? void 0 : _c.call(fabricInstance);
12766
+ await waitForPaint();
12767
+ (_c = fabricInstance.renderAll) == null ? void 0 : _c.call(fabricInstance);
12778
12768
  await waitForPaint();
12779
12769
  }
12780
12770
  }