@pixldocs/canvas-renderer 0.5.229 → 0.5.231
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-UL0ZxmJo.cjs → index-BbgFuxwu.cjs} +93 -53
- package/dist/index-BbgFuxwu.cjs.map +1 -0
- package/dist/{index-BGRbJpAB.js → index-YHIa8GZv.js} +93 -53
- package/dist/index-YHIa8GZv.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-B-RoR9U6.js → vectorPdfExport-ByHidrM_.js} +4 -4
- package/dist/{vectorPdfExport-B-RoR9U6.js.map → vectorPdfExport-ByHidrM_.js.map} +1 -1
- package/dist/{vectorPdfExport-Cfic2O5h.cjs → vectorPdfExport-Dwv5vpcI.cjs} +4 -4
- package/dist/{vectorPdfExport-Cfic2O5h.cjs.map → vectorPdfExport-Dwv5vpcI.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/index-BGRbJpAB.js.map +0 -1
- package/dist/index-UL0ZxmJo.cjs.map +0 -1
|
@@ -9609,6 +9609,63 @@ function renderSmartElementToDataUri(type, props, width, height) {
|
|
|
9609
9609
|
if (!svg) return null;
|
|
9610
9610
|
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
|
|
9611
9611
|
}
|
|
9612
|
+
function runFontReloadAndReflow(opts) {
|
|
9613
|
+
const { canvas, pageTree, pageBoundsOptions, preserveGlobalFontCache, persistTextboxSize, preResnapSync } = opts;
|
|
9614
|
+
if (!canvas) return;
|
|
9615
|
+
try {
|
|
9616
|
+
clearFontCacheAndRerender(canvas, { clearGlobalCharCache: !preserveGlobalFontCache });
|
|
9617
|
+
} catch {
|
|
9618
|
+
}
|
|
9619
|
+
try {
|
|
9620
|
+
clearMeasurementCache();
|
|
9621
|
+
} catch {
|
|
9622
|
+
}
|
|
9623
|
+
if (!preserveGlobalFontCache) {
|
|
9624
|
+
try {
|
|
9625
|
+
clearFabricCharCache();
|
|
9626
|
+
} catch {
|
|
9627
|
+
}
|
|
9628
|
+
}
|
|
9629
|
+
if (persistTextboxSize && pageTree.length) {
|
|
9630
|
+
const elements = flattenChildren(pageTree);
|
|
9631
|
+
canvas.getObjects().forEach((obj) => {
|
|
9632
|
+
if (!(obj instanceof fabric.Textbox)) return;
|
|
9633
|
+
const id = getObjectId(obj);
|
|
9634
|
+
if (!id) return;
|
|
9635
|
+
const el = elements.find((e) => e.id === id);
|
|
9636
|
+
if (!el) return;
|
|
9637
|
+
persistTextboxSize(id, { width: obj.width ?? 0, height: obj.height ?? 0 }, el);
|
|
9638
|
+
});
|
|
9639
|
+
}
|
|
9640
|
+
if (preResnapSync) {
|
|
9641
|
+
try {
|
|
9642
|
+
preResnapSync();
|
|
9643
|
+
} catch (e) {
|
|
9644
|
+
console.warn("[canvasReflow] preResnapSync failed:", e);
|
|
9645
|
+
}
|
|
9646
|
+
}
|
|
9647
|
+
if (!pageTree.length) return;
|
|
9648
|
+
try {
|
|
9649
|
+
canvas.getObjects().forEach((obj) => {
|
|
9650
|
+
const id = getObjectId(obj);
|
|
9651
|
+
if (!id) return;
|
|
9652
|
+
const node = findNodeById(pageTree, id);
|
|
9653
|
+
if (!node) return;
|
|
9654
|
+
const abs = getAbsoluteBounds(node, pageTree, pageBoundsOptions);
|
|
9655
|
+
const targetLeft = obj.originX === "center" ? abs.left + abs.width / 2 : obj.originX === "right" ? abs.left + abs.width : abs.left;
|
|
9656
|
+
const targetTop = obj.originY === "center" ? abs.top + abs.height / 2 : obj.originY === "bottom" ? abs.top + abs.height : abs.top;
|
|
9657
|
+
const curLeft = obj.left ?? 0;
|
|
9658
|
+
const curTop = obj.top ?? 0;
|
|
9659
|
+
if (Math.abs(curLeft - targetLeft) > 0.1 || Math.abs(curTop - targetTop) > 0.1) {
|
|
9660
|
+
obj.set({ left: targetLeft, top: targetTop });
|
|
9661
|
+
obj.setCoords();
|
|
9662
|
+
}
|
|
9663
|
+
});
|
|
9664
|
+
canvas.requestRenderAll();
|
|
9665
|
+
} catch (e) {
|
|
9666
|
+
console.warn("[canvasReflow] resnap failed:", e);
|
|
9667
|
+
}
|
|
9668
|
+
}
|
|
9612
9669
|
const EVT_SHOW_ORIG_TEXT_BOUNDS = "pixldocs:showOriginalTextBoundsChanged";
|
|
9613
9670
|
function subscribeShowOriginalTextBounds(cb) {
|
|
9614
9671
|
const handler = (e) => cb(!!e.detail);
|
|
@@ -9800,6 +9857,7 @@ const PageCanvas = forwardRef(
|
|
|
9800
9857
|
});
|
|
9801
9858
|
const isEditorMode = mode === "editor";
|
|
9802
9859
|
const isPreviewMode = mode === "preview";
|
|
9860
|
+
const isExportMode = mode === "export";
|
|
9803
9861
|
const allowEditing = isEditorMode;
|
|
9804
9862
|
const allowSelection = isEditorMode;
|
|
9805
9863
|
const allowDynamicFieldClick = isPreviewMode && dynamicFieldIds.length > 0;
|
|
@@ -13391,56 +13449,38 @@ const PageCanvas = forwardRef(
|
|
|
13391
13449
|
var _a2;
|
|
13392
13450
|
const fc = fabricRef.current;
|
|
13393
13451
|
if (!fc || cancelled) return;
|
|
13394
|
-
clearFontCacheAndRerender(fc, { clearGlobalCharCache: !preserveGlobalFontCache });
|
|
13395
13452
|
const state = useEditorStore.getState();
|
|
13396
|
-
const
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
if (!shouldKeepFixedSize && w > 0 && typeof storeW === "number" && Math.abs(w - storeW) > 0.1) updates.width = w;
|
|
13412
|
-
if (shouldKeepFixedSize) {
|
|
13413
|
-
if (h > 0 && typeof storeH === "number" && h < storeH - 0.5) updates.height = h;
|
|
13414
|
-
} else {
|
|
13415
|
-
if (h > 0 && (typeof storeH !== "number" || Math.abs(h - storeH) > 0.1)) updates.height = h;
|
|
13416
|
-
}
|
|
13417
|
-
if (Object.keys(updates).length > 0) {
|
|
13418
|
-
state.updateElement(id, updates, { recordHistory: false, skipLayoutRecalc: true });
|
|
13419
|
-
}
|
|
13453
|
+
const repositionTree = isPreviewMode && (pageChildren == null ? void 0 : pageChildren.length) ? pageChildren ?? [] : ((_a2 = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _a2.children) ?? [];
|
|
13454
|
+
runFontReloadAndReflow({
|
|
13455
|
+
canvas: fc,
|
|
13456
|
+
pageTree: repositionTree,
|
|
13457
|
+
pageBoundsOptions,
|
|
13458
|
+
preserveGlobalFontCache,
|
|
13459
|
+
// Persist measured Textbox sizes back to the editor store. The
|
|
13460
|
+
// headless path passes no callback (it has no store to persist into).
|
|
13461
|
+
persistTextboxSize: (id, measured, el) => {
|
|
13462
|
+
const storeW = el.width ?? 0;
|
|
13463
|
+
const storeH = el.height ?? 0;
|
|
13464
|
+
const shouldKeepFixedSize = el.overflowPolicy === "auto-shrink";
|
|
13465
|
+
const updates = {};
|
|
13466
|
+
if (!shouldKeepFixedSize && measured.width > 0 && typeof storeW === "number" && Math.abs(measured.width - storeW) > 0.1) {
|
|
13467
|
+
updates.width = measured.width;
|
|
13420
13468
|
}
|
|
13421
|
-
|
|
13422
|
-
|
|
13423
|
-
|
|
13424
|
-
|
|
13425
|
-
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13429
|
-
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
obj.setCoords();
|
|
13437
|
-
}
|
|
13438
|
-
});
|
|
13439
|
-
fc.requestRenderAll();
|
|
13440
|
-
}
|
|
13441
|
-
} catch (e) {
|
|
13442
|
-
console.warn("[PageCanvas] post-ready reposition failed:", e);
|
|
13443
|
-
}
|
|
13469
|
+
if (shouldKeepFixedSize) {
|
|
13470
|
+
if (measured.height > 0 && typeof storeH === "number" && measured.height < storeH - 0.5) updates.height = measured.height;
|
|
13471
|
+
} else {
|
|
13472
|
+
if (measured.height > 0 && (typeof storeH !== "number" || Math.abs(measured.height - storeH) > 0.1)) updates.height = measured.height;
|
|
13473
|
+
}
|
|
13474
|
+
if (Object.keys(updates).length > 0) {
|
|
13475
|
+
state.updateElement(id, updates, { recordHistory: false, skipLayoutRecalc: true });
|
|
13476
|
+
}
|
|
13477
|
+
},
|
|
13478
|
+
// Rebuild section/background groups before resnapping top-level objects.
|
|
13479
|
+
preResnapSync: (isPreviewMode || isExportMode) && doSyncRef.current ? () => {
|
|
13480
|
+
var _a3;
|
|
13481
|
+
return (_a3 = doSyncRef.current) == null ? void 0 : _a3.call(doSyncRef);
|
|
13482
|
+
} : void 0
|
|
13483
|
+
});
|
|
13444
13484
|
};
|
|
13445
13485
|
const raf1 = requestAnimationFrame(() => {
|
|
13446
13486
|
requestAnimationFrame(() => {
|
|
@@ -20998,9 +21038,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
20998
21038
|
}
|
|
20999
21039
|
return svgString;
|
|
21000
21040
|
}
|
|
21001
|
-
const resolvedPackageVersion = "0.5.
|
|
21041
|
+
const resolvedPackageVersion = "0.5.231";
|
|
21002
21042
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
21003
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
21043
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.231";
|
|
21004
21044
|
const roundParityValue = (value) => {
|
|
21005
21045
|
if (typeof value !== "number") return value;
|
|
21006
21046
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -21744,7 +21784,7 @@ class PixldocsRenderer {
|
|
|
21744
21784
|
await this.waitForCanvasScene(container, cloned, i);
|
|
21745
21785
|
}
|
|
21746
21786
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
21747
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-
|
|
21787
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-ByHidrM_.js");
|
|
21748
21788
|
const prepared = preparePagesForExport(
|
|
21749
21789
|
cloned.pages,
|
|
21750
21790
|
canvasWidth,
|
|
@@ -24064,7 +24104,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
24064
24104
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
24065
24105
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
24066
24106
|
try {
|
|
24067
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-
|
|
24107
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-ByHidrM_.js");
|
|
24068
24108
|
try {
|
|
24069
24109
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
24070
24110
|
} catch {
|
|
@@ -24463,4 +24503,4 @@ export {
|
|
|
24463
24503
|
buildTeaserBlurFlatKeys as y,
|
|
24464
24504
|
collectFontDescriptorsFromConfig as z
|
|
24465
24505
|
};
|
|
24466
|
-
//# sourceMappingURL=index-
|
|
24506
|
+
//# sourceMappingURL=index-YHIa8GZv.js.map
|