@pixldocs/canvas-renderer 0.5.447 → 0.5.448
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-g0HVhMPi.js → index-BruY5wZV.js} +95 -22
- package/dist/index-BruY5wZV.js.map +1 -0
- package/dist/{index-D7JnQkpf.cjs → index-CzxefTLk.cjs} +95 -22
- package/dist/index-CzxefTLk.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-BVQkDFXD.cjs → vectorPdfExport-B9AA07qB.cjs} +4 -4
- package/dist/{vectorPdfExport-BVQkDFXD.cjs.map → vectorPdfExport-B9AA07qB.cjs.map} +1 -1
- package/dist/{vectorPdfExport-BdCLPcgH.js → vectorPdfExport-T3FZHnkS.js} +4 -4
- package/dist/{vectorPdfExport-BdCLPcgH.js.map → vectorPdfExport-T3FZHnkS.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-D7JnQkpf.cjs.map +0 -1
- package/dist/index-g0HVhMPi.js.map +0 -1
|
@@ -11668,6 +11668,18 @@ const restorePersistedFlipState = (obj, flipX, flipY, angle) => {
|
|
|
11668
11668
|
obj.setCoords();
|
|
11669
11669
|
obj.dirty = true;
|
|
11670
11670
|
};
|
|
11671
|
+
const isBitmapLikeFabricObject = (obj) => {
|
|
11672
|
+
var _a2;
|
|
11673
|
+
return obj instanceof fabric.FabricImage || obj instanceof fabric.Group && !!(obj.__cropGroup || ((_a2 = obj._ct) == null ? void 0 : _a2.isCropGroup));
|
|
11674
|
+
};
|
|
11675
|
+
const restorePersistedFlipFlagsOnly = (obj, flipX, flipY) => {
|
|
11676
|
+
if (!isBitmapLikeFabricObject(obj)) return;
|
|
11677
|
+
const sx = Math.abs(Number(obj.scaleX ?? 1)) || 1;
|
|
11678
|
+
const sy = Math.abs(Number(obj.scaleY ?? 1)) || 1;
|
|
11679
|
+
obj.set({ scaleX: sx, scaleY: sy, flipX, flipY });
|
|
11680
|
+
obj.setCoords();
|
|
11681
|
+
obj.dirty = true;
|
|
11682
|
+
};
|
|
11671
11683
|
const toggleLogicalFlipInMatrix = (matrix, flipX, flipY) => {
|
|
11672
11684
|
if (!flipX && !flipY) return matrix;
|
|
11673
11685
|
const sx = flipX ? -1 : 1;
|
|
@@ -14637,7 +14649,7 @@ const PageCanvas = forwardRef(
|
|
|
14637
14649
|
fabricCanvas.on("selection:cleared", () => {
|
|
14638
14650
|
});
|
|
14639
14651
|
fabricCanvas.on("object:scaling", (e) => {
|
|
14640
|
-
var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
14652
|
+
var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
14641
14653
|
if (!isActiveRef.current) return;
|
|
14642
14654
|
const t = e.target;
|
|
14643
14655
|
if (t) lastResizeScaleTargetRef.current = t;
|
|
@@ -14868,11 +14880,66 @@ const PageCanvas = forwardRef(
|
|
|
14868
14880
|
};
|
|
14869
14881
|
}
|
|
14870
14882
|
}
|
|
14871
|
-
if (obj instanceof fabric.ActiveSelection && (corner
|
|
14872
|
-
const isXSide = corner === "ml" || corner === "mr";
|
|
14883
|
+
if (obj instanceof fabric.ActiveSelection && isCornerResizeHandle(corner)) {
|
|
14873
14884
|
const _cur = fabricCanvas._currentTransform;
|
|
14874
14885
|
const startSx = Math.abs(Number(((_g = _cur == null ? void 0 : _cur.original) == null ? void 0 : _g.scaleX) ?? 1)) || 1;
|
|
14875
14886
|
const startSy = Math.abs(Number(((_h = _cur == null ? void 0 : _cur.original) == null ? void 0 : _h.scaleY) ?? 1)) || 1;
|
|
14887
|
+
const liveAsSx = Math.abs((obj.scaleX ?? 1) / startSx) || 1;
|
|
14888
|
+
const liveAsSy = Math.abs((obj.scaleY ?? 1) / startSy) || 1;
|
|
14889
|
+
const uniform = Math.max(1e-3, Math.sqrt(liveAsSx * liveAsSy));
|
|
14890
|
+
for (const child of obj.getObjects()) {
|
|
14891
|
+
if (!isBitmapLikeFabricObject(child)) continue;
|
|
14892
|
+
const liveGestureKey = `${obj.__pixldocsGroupSelection ?? "selection"}:${corner}:${((_i = groupSelectionTransformStartRef.current) == null ? void 0 : _i.selectionLeft) ?? obj.left ?? 0}:${((_j = groupSelectionTransformStartRef.current) == null ? void 0 : _j.selectionTop) ?? obj.top ?? 0}`;
|
|
14893
|
+
if (child.__asLiveGestureKey !== liveGestureKey) {
|
|
14894
|
+
child.__asLiveGestureKey = liveGestureKey;
|
|
14895
|
+
child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
|
|
14896
|
+
child.__asLiveOrigFlipX = !!child.flipX;
|
|
14897
|
+
child.__asLiveOrigFlipY = !!child.flipY;
|
|
14898
|
+
child.__asLiveOrigScaleX = Math.abs(Number(child.scaleX ?? 1)) || 1;
|
|
14899
|
+
child.__asLiveOrigScaleY = Math.abs(Number(child.scaleY ?? 1)) || 1;
|
|
14900
|
+
}
|
|
14901
|
+
const childAngleDeg = child.__asLiveOrigAngle ?? (child.angle ?? 0);
|
|
14902
|
+
const origScaleX = child.__asLiveOrigScaleX;
|
|
14903
|
+
const origScaleY = child.__asLiveOrigScaleY;
|
|
14904
|
+
const baseW = Math.max(1, Number(((_k = child.__cropData) == null ? void 0 : _k.frameW) ?? child.width ?? 1));
|
|
14905
|
+
const baseH = Math.max(1, Number(((_l = child.__cropData) == null ? void 0 : _l.frameH) ?? child.height ?? 1));
|
|
14906
|
+
try {
|
|
14907
|
+
const inv = [1 / liveAsSx, 0, 0, 1 / liveAsSy, 0, 0];
|
|
14908
|
+
const Rtheta = fabric.util.composeMatrix({ angle: childAngleDeg, scaleX: 1, scaleY: 1, translateX: 0, translateY: 0 });
|
|
14909
|
+
const Uscale = fabric.util.composeMatrix({ angle: 0, scaleX: origScaleX * uniform, scaleY: origScaleY * uniform, translateX: 0, translateY: 0 });
|
|
14910
|
+
const M = fabric.util.multiplyTransformMatrices(
|
|
14911
|
+
fabric.util.multiplyTransformMatrices(inv, Rtheta),
|
|
14912
|
+
Uscale
|
|
14913
|
+
);
|
|
14914
|
+
const dec = fabric.util.qrDecompose(M);
|
|
14915
|
+
child._set("angle", dec.angle);
|
|
14916
|
+
child._set("scaleX", dec.scaleX);
|
|
14917
|
+
child._set("scaleY", dec.scaleY);
|
|
14918
|
+
child._set("skewX", dec.skewX);
|
|
14919
|
+
child._set("skewY", dec.skewY);
|
|
14920
|
+
child._set("flipX", !!(child.__asLiveOrigFlipX ?? child.flipX));
|
|
14921
|
+
child._set("flipY", !!(child.__asLiveOrigFlipY ?? child.flipY));
|
|
14922
|
+
const worldMatrix = fabric.util.multiplyTransformMatrices(
|
|
14923
|
+
obj.calcTransformMatrix(),
|
|
14924
|
+
child.calcOwnMatrix()
|
|
14925
|
+
);
|
|
14926
|
+
const live = fabric.util.qrDecompose(worldMatrix);
|
|
14927
|
+
child.__asLiveWorldAngle = (obj.angle ?? 0) + childAngleDeg;
|
|
14928
|
+
child.__asLiveWorldCenterX = live.translateX;
|
|
14929
|
+
child.__asLiveWorldCenterY = live.translateY;
|
|
14930
|
+
child.__asLiveFinalW = baseW * origScaleX * uniform;
|
|
14931
|
+
child.__asLiveFinalH = baseH * origScaleY * uniform;
|
|
14932
|
+
} catch {
|
|
14933
|
+
}
|
|
14934
|
+
child.setCoords();
|
|
14935
|
+
child.dirty = true;
|
|
14936
|
+
}
|
|
14937
|
+
}
|
|
14938
|
+
if (obj instanceof fabric.ActiveSelection && (corner === "ml" || corner === "mr" || corner === "mt" || corner === "mb")) {
|
|
14939
|
+
const isXSide = corner === "ml" || corner === "mr";
|
|
14940
|
+
const _cur = fabricCanvas._currentTransform;
|
|
14941
|
+
const startSx = Math.abs(Number(((_m = _cur == null ? void 0 : _cur.original) == null ? void 0 : _m.scaleX) ?? 1)) || 1;
|
|
14942
|
+
const startSy = Math.abs(Number(((_n = _cur == null ? void 0 : _cur.original) == null ? void 0 : _n.scaleY) ?? 1)) || 1;
|
|
14876
14943
|
const sAxis = isXSide ? Math.abs((obj.scaleX ?? 1) / startSx) : Math.abs((obj.scaleY ?? 1) / startSy);
|
|
14877
14944
|
if (sAxis > 1e-3) {
|
|
14878
14945
|
const captureAsLiveWorldSnapshot = (childObj, liveW, liveH) => {
|
|
@@ -14891,13 +14958,13 @@ const PageCanvas = forwardRef(
|
|
|
14891
14958
|
} catch {
|
|
14892
14959
|
}
|
|
14893
14960
|
};
|
|
14894
|
-
if (isXSide && ((
|
|
14961
|
+
if (isXSide && ((_o = groupShiftReflowSnapshotRef.current) == null ? void 0 : _o.selection) !== obj) {
|
|
14895
14962
|
groupShiftReflowSnapshotRef.current = null;
|
|
14896
14963
|
const logicalGroupId = obj.__pixldocsGroupSelection;
|
|
14897
14964
|
if (logicalGroupId) {
|
|
14898
14965
|
try {
|
|
14899
14966
|
const state = useEditorStore.getState();
|
|
14900
|
-
const pageChildren2 = ((
|
|
14967
|
+
const pageChildren2 = ((_p = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _p.children) ?? [];
|
|
14901
14968
|
const groupNode = findNodeById(pageChildren2, logicalGroupId);
|
|
14902
14969
|
if (groupNode && isGroup(groupNode) && !isStackLayoutMode(groupNode.layoutMode)) {
|
|
14903
14970
|
const entries = obj.getObjects().map((c) => ({
|
|
@@ -14927,7 +14994,7 @@ const PageCanvas = forwardRef(
|
|
|
14927
14994
|
const asRect0 = obj.getBoundingRect();
|
|
14928
14995
|
let didReflowTextChild = false;
|
|
14929
14996
|
for (const child of obj.getObjects()) {
|
|
14930
|
-
const liveGestureKey = `${obj.__pixldocsGroupSelection ?? "selection"}:${corner}:${((
|
|
14997
|
+
const liveGestureKey = `${obj.__pixldocsGroupSelection ?? "selection"}:${corner}:${((_q = groupSelectionTransformStartRef.current) == null ? void 0 : _q.selectionLeft) ?? obj.left ?? 0}:${((_r = groupSelectionTransformStartRef.current) == null ? void 0 : _r.selectionTop) ?? obj.top ?? 0}`;
|
|
14931
14998
|
if (child.__asLiveGestureKey !== liveGestureKey) {
|
|
14932
14999
|
child.__asLiveGestureKey = liveGestureKey;
|
|
14933
15000
|
child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
|
|
@@ -14936,7 +15003,7 @@ const PageCanvas = forwardRef(
|
|
|
14936
15003
|
}
|
|
14937
15004
|
const liveAsSx = isXSide ? sAxis : 1;
|
|
14938
15005
|
const liveAsSy = isXSide ? 1 : sAxis;
|
|
14939
|
-
if (child instanceof fabric.Group && (child.__cropGroup || ((
|
|
15006
|
+
if (child instanceof fabric.Group && (child.__cropGroup || ((_s = child._ct) == null ? void 0 : _s.isCropGroup)) || child instanceof fabric.FabricImage && !child.__cropGroup && !child.smartElementType) {
|
|
14940
15007
|
const childAngleDeg2 = child.__asLiveOrigAngle ?? (child.angle ?? 0);
|
|
14941
15008
|
const theta2 = fabric.util.degreesToRadians(childAngleDeg2);
|
|
14942
15009
|
const cosT2 = Math.cos(theta2);
|
|
@@ -14947,8 +15014,8 @@ const PageCanvas = forwardRef(
|
|
|
14947
15014
|
if (child.__asLiveOrigScaleY == null) child.__asLiveOrigScaleY = Math.abs(Number(child.scaleY ?? 1)) || 1;
|
|
14948
15015
|
const origScaleX = child.__asLiveOrigScaleX;
|
|
14949
15016
|
const origScaleY = child.__asLiveOrigScaleY;
|
|
14950
|
-
const baseW = Math.max(1, Number(((
|
|
14951
|
-
const baseH = Math.max(1, Number(((
|
|
15017
|
+
const baseW = Math.max(1, Number(((_t = child.__cropData) == null ? void 0 : _t.frameW) ?? child.width ?? 1));
|
|
15018
|
+
const baseH = Math.max(1, Number(((_u = child.__cropData) == null ? void 0 : _u.frameH) ?? child.height ?? 1));
|
|
14952
15019
|
const liveW = baseW * origScaleX * dX;
|
|
14953
15020
|
const liveH = baseH * origScaleY * dY;
|
|
14954
15021
|
try {
|
|
@@ -15027,7 +15094,7 @@ const PageCanvas = forwardRef(
|
|
|
15027
15094
|
child.dirty = true;
|
|
15028
15095
|
didReflowTextChild = true;
|
|
15029
15096
|
}
|
|
15030
|
-
if (isXSide && ((
|
|
15097
|
+
if (isXSide && ((_v = groupShiftReflowSnapshotRef.current) == null ? void 0 : _v.selection) === obj) {
|
|
15031
15098
|
const snap = groupShiftReflowSnapshotRef.current;
|
|
15032
15099
|
const anchorEntry = snap.children[0];
|
|
15033
15100
|
const anchorTopLive = anchorEntry.obj.top ?? 0;
|
|
@@ -15189,7 +15256,7 @@ const PageCanvas = forwardRef(
|
|
|
15189
15256
|
setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
|
|
15190
15257
|
if (drilledGroupIdRef.current) {
|
|
15191
15258
|
try {
|
|
15192
|
-
(
|
|
15259
|
+
(_w = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _w.call(fabricCanvas);
|
|
15193
15260
|
} catch {
|
|
15194
15261
|
}
|
|
15195
15262
|
}
|
|
@@ -16437,7 +16504,13 @@ const PageCanvas = forwardRef(
|
|
|
16437
16504
|
const cleanTransformMatrix = toggleLogicalFlipInMatrix(normalizedFinalAbsoluteMatrix, persistedFlipX, persistedFlipY);
|
|
16438
16505
|
const persistedDecomposed = fabric.util.qrDecompose(cleanTransformMatrix);
|
|
16439
16506
|
if (isActiveSelection && (obj instanceof fabric.FabricImage || obj instanceof fabric.Group && obj.__cropGroup)) {
|
|
16440
|
-
activeSelectionFlipRestores.push({
|
|
16507
|
+
activeSelectionFlipRestores.push({
|
|
16508
|
+
obj,
|
|
16509
|
+
flipX: persistedFlipX,
|
|
16510
|
+
flipY: persistedFlipY,
|
|
16511
|
+
localAngle: Number.isFinite(obj.angle) ? obj.angle ?? 0 : persistedAngle,
|
|
16512
|
+
worldAngle: persistedAngle
|
|
16513
|
+
});
|
|
16441
16514
|
}
|
|
16442
16515
|
const elementUpdate = {
|
|
16443
16516
|
left: storePos.left,
|
|
@@ -16518,7 +16591,7 @@ const PageCanvas = forwardRef(
|
|
|
16518
16591
|
}
|
|
16519
16592
|
const isCropGroupObj = obj instanceof fabric.Group && obj.__cropGroup;
|
|
16520
16593
|
const isPlainImageObj = obj instanceof fabric.FabricImage && !obj.__cropGroup && !obj.smartElementType;
|
|
16521
|
-
if (isActiveSelection &&
|
|
16594
|
+
if (isActiveSelection && isActiveSelectionResizeGesture && (isCropGroupObj || isPlainImageObj)) {
|
|
16522
16595
|
const childLocalAngleSrc = obj.__asLiveOrigAngle != null ? obj.__asLiveOrigAngle : Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? 0;
|
|
16523
16596
|
const normAng = (childLocalAngleSrc % 360 + 360) % 360;
|
|
16524
16597
|
const isRotatedImg = Math.min(normAng, 360 - normAng) > 0.5;
|
|
@@ -16570,7 +16643,7 @@ const PageCanvas = forwardRef(
|
|
|
16570
16643
|
if (isActiveSelection && (obj instanceof fabric.FabricImage || obj instanceof fabric.Group && obj.__cropGroup)) {
|
|
16571
16644
|
const restore = activeSelectionFlipRestores.find((entry) => entry.obj === obj);
|
|
16572
16645
|
if (restore) {
|
|
16573
|
-
restore.
|
|
16646
|
+
restore.worldAngle = Number.isFinite(elementUpdate.angle) ? elementUpdate.angle : persistedAngle;
|
|
16574
16647
|
}
|
|
16575
16648
|
}
|
|
16576
16649
|
if (isActiveSelection) {
|
|
@@ -16669,14 +16742,14 @@ const PageCanvas = forwardRef(
|
|
|
16669
16742
|
skipActiveSelectionBakeOnClearRef.current = true;
|
|
16670
16743
|
try {
|
|
16671
16744
|
for (const restore of activeSelectionFlipRestores) {
|
|
16672
|
-
|
|
16745
|
+
restorePersistedFlipFlagsOnly(restore.obj, restore.flipX, restore.flipY);
|
|
16673
16746
|
}
|
|
16674
16747
|
fabricCanvas.discardActiveObject();
|
|
16675
16748
|
} finally {
|
|
16676
16749
|
skipActiveSelectionBakeOnClearRef.current = false;
|
|
16677
16750
|
}
|
|
16678
16751
|
for (const restore of activeSelectionFlipRestores) {
|
|
16679
|
-
restorePersistedFlipState(restore.obj, restore.flipX, restore.flipY
|
|
16752
|
+
restorePersistedFlipState(restore.obj, restore.flipX, restore.flipY);
|
|
16680
16753
|
}
|
|
16681
16754
|
for (const bake of pendingCropGroupFrameBakes) {
|
|
16682
16755
|
const ct = bake.obj.__cropData;
|
|
@@ -16698,7 +16771,7 @@ const PageCanvas = forwardRef(
|
|
|
16698
16771
|
bake.obj.setCoords();
|
|
16699
16772
|
}
|
|
16700
16773
|
for (const restore of activeSelectionFlipRestores) {
|
|
16701
|
-
restorePersistedFlipState(restore.obj, restore.flipX, restore.flipY
|
|
16774
|
+
restorePersistedFlipState(restore.obj, restore.flipX, restore.flipY);
|
|
16702
16775
|
}
|
|
16703
16776
|
if (membersToReselect.length > 1) {
|
|
16704
16777
|
const newSel = new fabric.ActiveSelection(membersToReselect, { canvas: fabricCanvas });
|
|
@@ -25871,9 +25944,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
25871
25944
|
}
|
|
25872
25945
|
return svgString;
|
|
25873
25946
|
}
|
|
25874
|
-
const resolvedPackageVersion = "0.5.
|
|
25947
|
+
const resolvedPackageVersion = "0.5.448";
|
|
25875
25948
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
25876
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
25949
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.448";
|
|
25877
25950
|
const roundParityValue = (value) => {
|
|
25878
25951
|
if (typeof value !== "number") return value;
|
|
25879
25952
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -26687,7 +26760,7 @@ class PixldocsRenderer {
|
|
|
26687
26760
|
await this.waitForCanvasScene(container, cloned, i);
|
|
26688
26761
|
}
|
|
26689
26762
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
26690
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-
|
|
26763
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-T3FZHnkS.js");
|
|
26691
26764
|
const prepared = preparePagesForExport(
|
|
26692
26765
|
cloned.pages,
|
|
26693
26766
|
canvasWidth,
|
|
@@ -29007,7 +29080,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
29007
29080
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
29008
29081
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
29009
29082
|
try {
|
|
29010
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-
|
|
29083
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-T3FZHnkS.js");
|
|
29011
29084
|
try {
|
|
29012
29085
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
29013
29086
|
} catch {
|
|
@@ -29407,4 +29480,4 @@ export {
|
|
|
29407
29480
|
buildTeaserBlurFlatKeys as y,
|
|
29408
29481
|
collectFontDescriptorsFromConfig as z
|
|
29409
29482
|
};
|
|
29410
|
-
//# sourceMappingURL=index-
|
|
29483
|
+
//# sourceMappingURL=index-BruY5wZV.js.map
|