@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.js CHANGED
@@ -12722,40 +12722,30 @@ class PixldocsRenderer {
12722
12722
  const fabricInstance = this.getFabricCanvasFromContainer(container);
12723
12723
  if (!(fabricInstance == null ? void 0 : fabricInstance.getObjects)) return;
12724
12724
  const waitForPaint = () => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r())));
12725
- const clearTextMetricCaches = () => {
12726
- clearFabricCharCache();
12727
- clearMeasurementCache();
12728
- };
12729
- const resyncTextboxWidths = (obj) => {
12725
+ const primeCharBounds = (obj) => {
12730
12726
  if (obj instanceof fabric.Textbox) {
12731
- const savedWidth = Math.max(1, obj.width ?? 0);
12732
- const savedScaleX = obj.scaleX ?? 1;
12733
- const savedScaleY = obj.scaleY ?? 1;
12734
- obj.initDimensions();
12735
- if (Math.abs((obj.width ?? 0) - savedWidth) > 0.01) {
12736
- obj.width = savedWidth;
12737
- }
12738
- if (Math.abs((obj.scaleX ?? 1) - savedScaleX) > 0.01) {
12739
- obj.scaleX = savedScaleX;
12740
- }
12741
- if (Math.abs((obj.scaleY ?? 1) - savedScaleY) > 0.01) {
12742
- obj.scaleY = savedScaleY;
12727
+ const lines = obj._textLines;
12728
+ if (Array.isArray(lines)) {
12729
+ for (let i = 0; i < lines.length; i++) {
12730
+ try {
12731
+ obj.getLineWidth(i);
12732
+ } catch {
12733
+ }
12734
+ }
12743
12735
  }
12744
- obj.setCoords();
12745
12736
  obj.dirty = true;
12746
12737
  return;
12747
12738
  }
12748
12739
  if (obj instanceof fabric.Group) {
12749
- obj.getObjects().forEach(resyncTextboxWidths);
12740
+ obj.getObjects().forEach(primeCharBounds);
12750
12741
  obj.dirty = true;
12751
12742
  }
12752
12743
  };
12753
- clearTextMetricCaches();
12754
- await waitForPaint();
12755
- fabricInstance.getObjects().forEach(resyncTextboxWidths);
12744
+ fabricInstance.getObjects().forEach(primeCharBounds);
12756
12745
  (_a = fabricInstance.calcOffset) == null ? void 0 : _a.call(fabricInstance);
12757
12746
  (_b = fabricInstance.renderAll) == null ? void 0 : _b.call(fabricInstance);
12758
- (_c = fabricInstance.requestRenderAll) == null ? void 0 : _c.call(fabricInstance);
12747
+ await waitForPaint();
12748
+ (_c = fabricInstance.renderAll) == null ? void 0 : _c.call(fabricInstance);
12759
12749
  await waitForPaint();
12760
12750
  }
12761
12751
  }