@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.cjs
CHANGED
|
@@ -2769,45 +2769,16 @@ const clearFontCacheAndRerender = (canvas) => {
|
|
|
2769
2769
|
if (beforeMetrics.length > 0) {
|
|
2770
2770
|
logUnderlineDebug("before-rerender", beforeMetrics);
|
|
2771
2771
|
}
|
|
2772
|
-
const
|
|
2773
|
-
var _a
|
|
2772
|
+
const markDirty = (obj) => {
|
|
2773
|
+
var _a;
|
|
2774
2774
|
if (obj instanceof fabric__namespace.Textbox) {
|
|
2775
|
-
|
|
2776
|
-
const savedScaleX = obj.scaleX;
|
|
2777
|
-
const savedScaleY = obj.scaleY;
|
|
2778
|
-
obj._forceClearCache = true;
|
|
2779
|
-
obj.initDimensions();
|
|
2780
|
-
if (savedWidth != null) {
|
|
2781
|
-
obj.set({ width: savedWidth, scaleX: savedScaleX, scaleY: savedScaleY });
|
|
2782
|
-
obj._forceClearCache = true;
|
|
2783
|
-
obj.initDimensions();
|
|
2784
|
-
obj.set({ width: savedWidth, scaleX: savedScaleX, scaleY: savedScaleY, dirty: true });
|
|
2785
|
-
}
|
|
2786
|
-
if (obj.underline) {
|
|
2787
|
-
const lineWidths = obj.__lineWidths;
|
|
2788
|
-
logUnderlineDebug("textbox-rerender", {
|
|
2789
|
-
id: getObjectId(obj) ?? null,
|
|
2790
|
-
text: (obj.text || "").slice(0, 120),
|
|
2791
|
-
fontFamily: obj.fontFamily,
|
|
2792
|
-
fontSize: obj.fontSize,
|
|
2793
|
-
savedWidth,
|
|
2794
|
-
finalWidth: obj.width ?? null,
|
|
2795
|
-
finalHeight: obj.height ?? null,
|
|
2796
|
-
scaleX: obj.scaleX,
|
|
2797
|
-
scaleY: obj.scaleY,
|
|
2798
|
-
lineCount: ((_a = obj.textLines) == null ? void 0 : _a.length) ?? 0,
|
|
2799
|
-
maxLineWidth: lineWidths && lineWidths.length > 0 ? Math.max(...lineWidths) : null
|
|
2800
|
-
});
|
|
2801
|
-
}
|
|
2802
|
-
(_b = obj._clearCache) == null ? void 0 : _b.call(obj);
|
|
2803
|
-
obj.setCoords();
|
|
2775
|
+
obj.dirty = true;
|
|
2804
2776
|
} else if (obj instanceof fabric__namespace.Group) {
|
|
2805
|
-
(
|
|
2777
|
+
(_a = obj._objects) == null ? void 0 : _a.forEach(markDirty);
|
|
2806
2778
|
obj.dirty = true;
|
|
2807
|
-
obj.setCoords();
|
|
2808
2779
|
}
|
|
2809
2780
|
};
|
|
2810
|
-
canvas.getObjects().forEach(
|
|
2781
|
+
canvas.getObjects().forEach(markDirty);
|
|
2811
2782
|
const afterMetrics = canvas.getObjects().flatMap(collectUnderlineMetrics);
|
|
2812
2783
|
if (afterMetrics.length > 0) {
|
|
2813
2784
|
logUnderlineDebug("after-rerender", afterMetrics);
|
|
@@ -12762,6 +12733,7 @@ class PixldocsRenderer {
|
|
|
12762
12733
|
return null;
|
|
12763
12734
|
}
|
|
12764
12735
|
async waitForStableTextMetrics(container, config) {
|
|
12736
|
+
var _a, _b, _c;
|
|
12765
12737
|
if (typeof document !== "undefined") {
|
|
12766
12738
|
void ensureFontsForResolvedConfig(config);
|
|
12767
12739
|
await this.waitForRelevantFonts(config);
|
|
@@ -12773,21 +12745,11 @@ class PixldocsRenderer {
|
|
|
12773
12745
|
clearFabricCharCache();
|
|
12774
12746
|
clearMeasurementCache();
|
|
12775
12747
|
};
|
|
12776
|
-
const reflowTextboxes = () => {
|
|
12777
|
-
var _a, _b, _c;
|
|
12778
|
-
clearFontCacheAndRerender(fabricInstance);
|
|
12779
|
-
(_a = fabricInstance.calcOffset) == null ? void 0 : _a.call(fabricInstance);
|
|
12780
|
-
(_b = fabricInstance.renderAll) == null ? void 0 : _b.call(fabricInstance);
|
|
12781
|
-
(_c = fabricInstance.requestRenderAll) == null ? void 0 : _c.call(fabricInstance);
|
|
12782
|
-
};
|
|
12783
|
-
clearTextMetricCaches();
|
|
12784
|
-
await waitForPaint();
|
|
12785
|
-
reflowTextboxes();
|
|
12786
|
-
await waitForPaint();
|
|
12787
12748
|
clearTextMetricCaches();
|
|
12788
|
-
reflowTextboxes();
|
|
12789
12749
|
await waitForPaint();
|
|
12790
|
-
|
|
12750
|
+
(_a = fabricInstance.calcOffset) == null ? void 0 : _a.call(fabricInstance);
|
|
12751
|
+
(_b = fabricInstance.renderAll) == null ? void 0 : _b.call(fabricInstance);
|
|
12752
|
+
(_c = fabricInstance.requestRenderAll) == null ? void 0 : _c.call(fabricInstance);
|
|
12791
12753
|
await waitForPaint();
|
|
12792
12754
|
}
|
|
12793
12755
|
}
|