@pixldocs/canvas-renderer 0.5.34 → 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,15 +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();
12744
+ const primeCharBounds = (obj) => {
12745
+ if (obj instanceof fabric__namespace.Textbox) {
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
+ }
12754
+ }
12755
+ obj.dirty = true;
12756
+ return;
12757
+ }
12758
+ if (obj instanceof fabric__namespace.Group) {
12759
+ obj.getObjects().forEach(primeCharBounds);
12760
+ obj.dirty = true;
12761
+ }
12747
12762
  };
12748
- clearTextMetricCaches();
12749
- await waitForPaint();
12763
+ fabricInstance.getObjects().forEach(primeCharBounds);
12750
12764
  (_a = fabricInstance.calcOffset) == null ? void 0 : _a.call(fabricInstance);
12751
12765
  (_b = fabricInstance.renderAll) == null ? void 0 : _b.call(fabricInstance);
12752
- (_c = fabricInstance.requestRenderAll) == null ? void 0 : _c.call(fabricInstance);
12766
+ await waitForPaint();
12767
+ (_c = fabricInstance.renderAll) == null ? void 0 : _c.call(fabricInstance);
12753
12768
  await waitForPaint();
12754
12769
  }
12755
12770
  }