@pixldocs/canvas-renderer 0.5.32 → 0.5.34
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 +9 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2750,45 +2750,16 @@ const clearFontCacheAndRerender = (canvas) => {
|
|
|
2750
2750
|
if (beforeMetrics.length > 0) {
|
|
2751
2751
|
logUnderlineDebug("before-rerender", beforeMetrics);
|
|
2752
2752
|
}
|
|
2753
|
-
const
|
|
2754
|
-
var _a
|
|
2753
|
+
const markDirty = (obj) => {
|
|
2754
|
+
var _a;
|
|
2755
2755
|
if (obj instanceof fabric.Textbox) {
|
|
2756
|
-
|
|
2757
|
-
const savedScaleX = obj.scaleX;
|
|
2758
|
-
const savedScaleY = obj.scaleY;
|
|
2759
|
-
obj._forceClearCache = true;
|
|
2760
|
-
obj.initDimensions();
|
|
2761
|
-
if (savedWidth != null) {
|
|
2762
|
-
obj.set({ width: savedWidth, scaleX: savedScaleX, scaleY: savedScaleY });
|
|
2763
|
-
obj._forceClearCache = true;
|
|
2764
|
-
obj.initDimensions();
|
|
2765
|
-
obj.set({ width: savedWidth, scaleX: savedScaleX, scaleY: savedScaleY, dirty: true });
|
|
2766
|
-
}
|
|
2767
|
-
if (obj.underline) {
|
|
2768
|
-
const lineWidths = obj.__lineWidths;
|
|
2769
|
-
logUnderlineDebug("textbox-rerender", {
|
|
2770
|
-
id: getObjectId(obj) ?? null,
|
|
2771
|
-
text: (obj.text || "").slice(0, 120),
|
|
2772
|
-
fontFamily: obj.fontFamily,
|
|
2773
|
-
fontSize: obj.fontSize,
|
|
2774
|
-
savedWidth,
|
|
2775
|
-
finalWidth: obj.width ?? null,
|
|
2776
|
-
finalHeight: obj.height ?? null,
|
|
2777
|
-
scaleX: obj.scaleX,
|
|
2778
|
-
scaleY: obj.scaleY,
|
|
2779
|
-
lineCount: ((_a = obj.textLines) == null ? void 0 : _a.length) ?? 0,
|
|
2780
|
-
maxLineWidth: lineWidths && lineWidths.length > 0 ? Math.max(...lineWidths) : null
|
|
2781
|
-
});
|
|
2782
|
-
}
|
|
2783
|
-
(_b = obj._clearCache) == null ? void 0 : _b.call(obj);
|
|
2784
|
-
obj.setCoords();
|
|
2756
|
+
obj.dirty = true;
|
|
2785
2757
|
} else if (obj instanceof fabric.Group) {
|
|
2786
|
-
(
|
|
2758
|
+
(_a = obj._objects) == null ? void 0 : _a.forEach(markDirty);
|
|
2787
2759
|
obj.dirty = true;
|
|
2788
|
-
obj.setCoords();
|
|
2789
2760
|
}
|
|
2790
2761
|
};
|
|
2791
|
-
canvas.getObjects().forEach(
|
|
2762
|
+
canvas.getObjects().forEach(markDirty);
|
|
2792
2763
|
const afterMetrics = canvas.getObjects().flatMap(collectUnderlineMetrics);
|
|
2793
2764
|
if (afterMetrics.length > 0) {
|
|
2794
2765
|
logUnderlineDebug("after-rerender", afterMetrics);
|
|
@@ -12743,6 +12714,7 @@ class PixldocsRenderer {
|
|
|
12743
12714
|
return null;
|
|
12744
12715
|
}
|
|
12745
12716
|
async waitForStableTextMetrics(container, config) {
|
|
12717
|
+
var _a, _b, _c;
|
|
12746
12718
|
if (typeof document !== "undefined") {
|
|
12747
12719
|
void ensureFontsForResolvedConfig(config);
|
|
12748
12720
|
await this.waitForRelevantFonts(config);
|
|
@@ -12754,21 +12726,11 @@ class PixldocsRenderer {
|
|
|
12754
12726
|
clearFabricCharCache();
|
|
12755
12727
|
clearMeasurementCache();
|
|
12756
12728
|
};
|
|
12757
|
-
const reflowTextboxes = () => {
|
|
12758
|
-
var _a, _b, _c;
|
|
12759
|
-
clearFontCacheAndRerender(fabricInstance);
|
|
12760
|
-
(_a = fabricInstance.calcOffset) == null ? void 0 : _a.call(fabricInstance);
|
|
12761
|
-
(_b = fabricInstance.renderAll) == null ? void 0 : _b.call(fabricInstance);
|
|
12762
|
-
(_c = fabricInstance.requestRenderAll) == null ? void 0 : _c.call(fabricInstance);
|
|
12763
|
-
};
|
|
12764
|
-
clearTextMetricCaches();
|
|
12765
|
-
await waitForPaint();
|
|
12766
|
-
reflowTextboxes();
|
|
12767
|
-
await waitForPaint();
|
|
12768
12729
|
clearTextMetricCaches();
|
|
12769
|
-
reflowTextboxes();
|
|
12770
12730
|
await waitForPaint();
|
|
12771
|
-
|
|
12731
|
+
(_a = fabricInstance.calcOffset) == null ? void 0 : _a.call(fabricInstance);
|
|
12732
|
+
(_b = fabricInstance.renderAll) == null ? void 0 : _b.call(fabricInstance);
|
|
12733
|
+
(_c = fabricInstance.requestRenderAll) == null ? void 0 : _c.call(fabricInstance);
|
|
12772
12734
|
await waitForPaint();
|
|
12773
12735
|
}
|
|
12774
12736
|
}
|