@pixldocs/canvas-renderer 0.5.28 → 0.5.30
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 +16 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2714,6 +2714,13 @@ const clearFabricCharCache = () => {
|
|
|
2714
2714
|
};
|
|
2715
2715
|
const clearFontCacheAndRerender = (canvas) => {
|
|
2716
2716
|
clearFabricCharCache();
|
|
2717
|
+
const logUnderlineDebug = (stage, payload) => {
|
|
2718
|
+
try {
|
|
2719
|
+
console.log(`[canvas-renderer][underline-debug] ${stage} ${JSON.stringify(payload)}`);
|
|
2720
|
+
} catch {
|
|
2721
|
+
console.log("[canvas-renderer][underline-debug]", stage, payload);
|
|
2722
|
+
}
|
|
2723
|
+
};
|
|
2717
2724
|
const collectUnderlineMetrics = (obj) => {
|
|
2718
2725
|
var _a, _b;
|
|
2719
2726
|
if (obj instanceof fabric.Textbox) {
|
|
@@ -2741,7 +2748,7 @@ const clearFontCacheAndRerender = (canvas) => {
|
|
|
2741
2748
|
};
|
|
2742
2749
|
const beforeMetrics = canvas.getObjects().flatMap(collectUnderlineMetrics);
|
|
2743
2750
|
if (beforeMetrics.length > 0) {
|
|
2744
|
-
|
|
2751
|
+
logUnderlineDebug("before-rerender", beforeMetrics);
|
|
2745
2752
|
}
|
|
2746
2753
|
const resetTextboxLayoutInternals = (obj) => {
|
|
2747
2754
|
var _a;
|
|
@@ -2772,7 +2779,7 @@ const clearFontCacheAndRerender = (canvas) => {
|
|
|
2772
2779
|
}
|
|
2773
2780
|
if (obj.underline) {
|
|
2774
2781
|
const lineWidths = obj.__lineWidths;
|
|
2775
|
-
|
|
2782
|
+
logUnderlineDebug("textbox-rerender", {
|
|
2776
2783
|
id: getObjectId(obj) ?? null,
|
|
2777
2784
|
text: (obj.text || "").slice(0, 120),
|
|
2778
2785
|
fontFamily: obj.fontFamily,
|
|
@@ -2797,7 +2804,7 @@ const clearFontCacheAndRerender = (canvas) => {
|
|
|
2797
2804
|
canvas.getObjects().forEach(fixTextbox);
|
|
2798
2805
|
const afterMetrics = canvas.getObjects().flatMap(collectUnderlineMetrics);
|
|
2799
2806
|
if (afterMetrics.length > 0) {
|
|
2800
|
-
|
|
2807
|
+
logUnderlineDebug("after-rerender", afterMetrics);
|
|
2801
2808
|
}
|
|
2802
2809
|
canvas.requestRenderAll();
|
|
2803
2810
|
};
|
|
@@ -12535,6 +12542,8 @@ class PixldocsRenderer {
|
|
|
12535
12542
|
const fabricInstance = this.getFabricCanvasFromContainer(container);
|
|
12536
12543
|
const expectedImageCount = this.getExpectedImageCount(config, pageIndex);
|
|
12537
12544
|
await this.waitForCanvasImages(container, expectedImageCount);
|
|
12545
|
+
await this.waitForStableTextMetrics(container, config);
|
|
12546
|
+
await this.waitForCanvasScene(container, config, pageIndex);
|
|
12538
12547
|
const fabricCanvas = container.querySelector("canvas.upper-canvas, canvas");
|
|
12539
12548
|
const sourceCanvas = (fabricInstance == null ? void 0 : fabricInstance.lowerCanvasEl) || container.querySelector("canvas.lower-canvas") || fabricCanvas;
|
|
12540
12549
|
if (!sourceCanvas) {
|
|
@@ -12573,7 +12582,7 @@ class PixldocsRenderer {
|
|
|
12573
12582
|
pageIndex,
|
|
12574
12583
|
zoom: pixelRatio,
|
|
12575
12584
|
absoluteZoom: true,
|
|
12576
|
-
skipFontReadyWait:
|
|
12585
|
+
skipFontReadyWait: false,
|
|
12577
12586
|
onReady
|
|
12578
12587
|
})
|
|
12579
12588
|
);
|
|
@@ -12622,6 +12631,8 @@ class PixldocsRenderer {
|
|
|
12622
12631
|
}
|
|
12623
12632
|
const expectedImageCount = this.getExpectedImageCount(config, pageIndex);
|
|
12624
12633
|
await this.waitForCanvasImages(container, expectedImageCount);
|
|
12634
|
+
await this.waitForStableTextMetrics(container, config);
|
|
12635
|
+
await this.waitForCanvasScene(container, config, pageIndex);
|
|
12625
12636
|
const prevVPT = fabricInstance.viewportTransform ? [...fabricInstance.viewportTransform] : void 0;
|
|
12626
12637
|
const prevSvgVPT = fabricInstance.svgViewportTransformation;
|
|
12627
12638
|
const prevRetina = fabricInstance.enableRetinaScaling;
|
|
@@ -12672,7 +12683,7 @@ class PixldocsRenderer {
|
|
|
12672
12683
|
zoom: 1,
|
|
12673
12684
|
// 1:1 — no UI scaling for SVG capture
|
|
12674
12685
|
absoluteZoom: true,
|
|
12675
|
-
skipFontReadyWait:
|
|
12686
|
+
skipFontReadyWait: false,
|
|
12676
12687
|
onReady
|
|
12677
12688
|
})
|
|
12678
12689
|
);
|