@pixldocs/canvas-renderer 0.5.270 → 0.5.272
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-CLq3CdA3.cjs → index-BYfp_ae9.cjs} +79 -19
- package/dist/index-BYfp_ae9.cjs.map +1 -0
- package/dist/{index-RDXGR8QW.js → index-CHIScvwH.js} +79 -19
- package/dist/index-CHIScvwH.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport--X5puWU1.js → vectorPdfExport-BySFN17q.js} +4 -4
- package/dist/{vectorPdfExport--X5puWU1.js.map → vectorPdfExport-BySFN17q.js.map} +1 -1
- package/dist/{vectorPdfExport-BpHyRyQS.cjs → vectorPdfExport-CdiLpR0-.cjs} +4 -4
- package/dist/{vectorPdfExport-BpHyRyQS.cjs.map → vectorPdfExport-CdiLpR0-.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/index-CLq3CdA3.cjs.map +0 -1
- package/dist/index-RDXGR8QW.js.map +0 -1
|
@@ -12704,7 +12704,9 @@ const PageCanvas = forwardRef(
|
|
|
12704
12704
|
const selection = new fabric.ActiveSelection(members, { canvas: fc });
|
|
12705
12705
|
restoreGroupSelectionVisualState(selection, groupId);
|
|
12706
12706
|
fc.setActiveObject(selection);
|
|
12707
|
-
selection.
|
|
12707
|
+
if (!selection.getObjects().every((obj) => !(obj instanceof fabric.Group))) {
|
|
12708
|
+
selection.setCoords();
|
|
12709
|
+
}
|
|
12708
12710
|
fc.requestRenderAll();
|
|
12709
12711
|
} finally {
|
|
12710
12712
|
requestAnimationFrame(() => {
|
|
@@ -13888,7 +13890,7 @@ const PageCanvas = forwardRef(
|
|
|
13888
13890
|
});
|
|
13889
13891
|
let cropGroupSaveTimer = null;
|
|
13890
13892
|
fabricCanvas.on("object:modified", (e) => {
|
|
13891
|
-
var _a2, _b2, _c, _d, _e, _f, _g;
|
|
13893
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h;
|
|
13892
13894
|
try {
|
|
13893
13895
|
dragStarted = false;
|
|
13894
13896
|
setGuides([]);
|
|
@@ -14304,6 +14306,7 @@ const PageCanvas = forwardRef(
|
|
|
14304
14306
|
drilledGroupIdRef.current = null;
|
|
14305
14307
|
const groupSelectionId = (isActiveSelection && activeObj instanceof fabric.ActiveSelection ? activeObj.__pixldocsGroupSelection : void 0) ?? groupToMove.id;
|
|
14306
14308
|
const targetObjects = isActiveSelection && activeObj instanceof fabric.ActiveSelection ? activeObj.getObjects() : activeObjects;
|
|
14309
|
+
let preservedGroupMemberIds = targetObjects.map((obj) => getObjectId(obj)).filter((id) => !!id && id !== "__background__");
|
|
14307
14310
|
if (groupSelectionId && activeObj instanceof fabric.ActiveSelection) {
|
|
14308
14311
|
try {
|
|
14309
14312
|
skipSelectionClearOnDiscardRef.current = true;
|
|
@@ -14316,15 +14319,35 @@ const PageCanvas = forwardRef(
|
|
|
14316
14319
|
}
|
|
14317
14320
|
} catch {
|
|
14318
14321
|
}
|
|
14319
|
-
const
|
|
14322
|
+
const pageAfterMove = ((_g = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _g.children) ?? [];
|
|
14323
|
+
const groupAfterMove = findNodeById(pageAfterMove, groupToMove.id);
|
|
14324
|
+
const memberIdsAfterMove = groupAfterMove && isGroup(groupAfterMove) ? getAllElementIds(groupAfterMove.children ?? []) : targetObjects.map((obj) => getObjectId(obj)).filter((id) => !!id && id !== "__background__");
|
|
14325
|
+
preservedGroupMemberIds = memberIdsAfterMove;
|
|
14326
|
+
const reselectionObjects = memberIdsAfterMove.map((id) => targetObjects.find((obj) => getObjectId(obj) === id) ?? fabricCanvas.getObjects().find((obj) => getObjectId(obj) === id)).filter((obj) => !!obj);
|
|
14327
|
+
for (const obj of reselectionObjects) {
|
|
14328
|
+
const id = getObjectId(obj);
|
|
14329
|
+
const node = id ? findNodeById(pageAfterMove, id) : null;
|
|
14330
|
+
if (!node) continue;
|
|
14331
|
+
const abs = getAbsoluteBounds(node, pageAfterMove, pageBoundsOptions);
|
|
14332
|
+
const bounds = getNodeBounds(node, pageAfterMove, pageBoundsOptions);
|
|
14333
|
+
if (obj instanceof fabric.Group && obj.__cropGroup || obj instanceof fabric.FabricImage && (obj.originX === "center" || obj.originY === "center")) {
|
|
14334
|
+
obj.set({ left: abs.left + Math.max(1, bounds.width) / 2, top: abs.top + Math.max(1, bounds.height) / 2 });
|
|
14335
|
+
} else {
|
|
14336
|
+
obj.set({ left: abs.left, top: abs.top });
|
|
14337
|
+
}
|
|
14338
|
+
obj.setCoords();
|
|
14339
|
+
}
|
|
14340
|
+
const bakedSelection = reselectionObjects.length > 1 ? new fabric.ActiveSelection(reselectionObjects, { canvas: fabricCanvas }) : activeObj;
|
|
14320
14341
|
restoreGroupSelectionVisualState(bakedSelection, groupSelectionId);
|
|
14321
14342
|
fabricCanvas.setActiveObject(bakedSelection);
|
|
14322
|
-
bakedSelection.
|
|
14343
|
+
if (!(bakedSelection instanceof fabric.ActiveSelection && bakedSelection.getObjects().every((obj) => !(obj instanceof fabric.Group)))) {
|
|
14344
|
+
bakedSelection.setCoords();
|
|
14345
|
+
}
|
|
14323
14346
|
}
|
|
14324
14347
|
selectElements([groupSelectionId], false, false);
|
|
14325
14348
|
fabricCanvas.requestRenderAll();
|
|
14326
14349
|
elementsRef.current = getCurrentElements();
|
|
14327
|
-
for (const obj of targetObjects) {
|
|
14350
|
+
for (const obj of targetObjects.length ? targetObjects : activeObjects) {
|
|
14328
14351
|
const objId = getObjectId(obj);
|
|
14329
14352
|
if (objId && objId !== "__background__") {
|
|
14330
14353
|
justModifiedIdsRef.current.add(objId);
|
|
@@ -14334,7 +14357,7 @@ const PageCanvas = forwardRef(
|
|
|
14334
14357
|
setTimeout(() => modifiedIdsThisRound.forEach((id) => justModifiedIdsRef.current.delete(id)), 150);
|
|
14335
14358
|
groupSelectionTransformStartRef.current = null;
|
|
14336
14359
|
restorePreservedGroupSelectionSoon({
|
|
14337
|
-
memberIds:
|
|
14360
|
+
memberIds: preservedGroupMemberIds,
|
|
14338
14361
|
groupSelectionId
|
|
14339
14362
|
});
|
|
14340
14363
|
unlockEditsSoon();
|
|
@@ -14598,7 +14621,7 @@ const PageCanvas = forwardRef(
|
|
|
14598
14621
|
updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
|
|
14599
14622
|
obj.setCoords();
|
|
14600
14623
|
}
|
|
14601
|
-
const pageChildrenForReflow = ((
|
|
14624
|
+
const pageChildrenForReflow = ((_h = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _h.children) ?? [];
|
|
14602
14625
|
const stackGroupsToReflow = /* @__PURE__ */ new Set();
|
|
14603
14626
|
for (const id of modifiedIdsThisRound) {
|
|
14604
14627
|
const parent = findParentGroup(pageChildrenForReflow, id);
|
|
@@ -15101,9 +15124,42 @@ const PageCanvas = forwardRef(
|
|
|
15101
15124
|
};
|
|
15102
15125
|
fc.add(sectionGroup);
|
|
15103
15126
|
}
|
|
15127
|
+
const getActiveSelectionContainingObject = (obj) => {
|
|
15128
|
+
const active = fc.getActiveObject();
|
|
15129
|
+
return active instanceof fabric.ActiveSelection && active.getObjects().includes(obj) ? active : null;
|
|
15130
|
+
};
|
|
15131
|
+
const shouldPreserveActiveSelectionMemberPosition = (obj) => {
|
|
15132
|
+
if (syncTriggeredByPanelRef.current) return false;
|
|
15133
|
+
const activeSelection = getActiveSelectionContainingObject(obj);
|
|
15134
|
+
if (!activeSelection) return false;
|
|
15135
|
+
const logicalActiveSelection = activeSelection;
|
|
15136
|
+
const logicalGroupId = logicalActiveSelection.__pixldocsGroupSelection;
|
|
15137
|
+
const logicalGroupIds = logicalActiveSelection.__pixldocsLogicalGroupIds;
|
|
15138
|
+
if (logicalGroupId || Array.isArray(logicalGroupIds)) return true;
|
|
15139
|
+
const id = getObjectId(obj);
|
|
15140
|
+
const preserved = preserveActiveSelectionAfterTransformRef.current;
|
|
15141
|
+
return !!(id && (preserved == null ? void 0 : preserved.memberIds.includes(id)) && (!preserved.expiresAt || preserved.expiresAt > Date.now()));
|
|
15142
|
+
};
|
|
15143
|
+
const getObjectSyncComparePosition = (obj) => {
|
|
15144
|
+
const activeSelection = getActiveSelectionContainingObject(obj);
|
|
15145
|
+
if (!activeSelection) return { left: obj.left ?? 0, top: obj.top ?? 0 };
|
|
15146
|
+
const point = fabric.util.transformPoint({ x: obj.left ?? 0, y: obj.top ?? 0 }, activeSelection.calcTransformMatrix());
|
|
15147
|
+
let left = point.x;
|
|
15148
|
+
let top = point.y;
|
|
15149
|
+
const cropObj = obj;
|
|
15150
|
+
if (obj instanceof fabric.Group && cropObj.__cropGroup) {
|
|
15151
|
+
const ct = cropObj.__cropData;
|
|
15152
|
+
left -= ((ct == null ? void 0 : ct.frameW) ?? obj.width ?? 0) * Math.abs(obj.scaleX ?? 1) / 2;
|
|
15153
|
+
top -= ((ct == null ? void 0 : ct.frameH) ?? obj.height ?? 0) * Math.abs(obj.scaleY ?? 1) / 2;
|
|
15154
|
+
} else if (obj instanceof fabric.FabricImage && (obj.originX === "center" || obj.originY === "center")) {
|
|
15155
|
+
left -= (obj.width ?? 0) * Math.abs(obj.scaleX ?? 1) / 2;
|
|
15156
|
+
top -= (obj.height ?? 0) * Math.abs(obj.scaleY ?? 1) / 2;
|
|
15157
|
+
}
|
|
15158
|
+
return { left, top };
|
|
15159
|
+
};
|
|
15104
15160
|
for (const element of elementsToSync) {
|
|
15105
15161
|
if (sectionDescendantIds.has(element.id)) continue;
|
|
15106
|
-
|
|
15162
|
+
const existingObj = currentFabricObjects.get(element.id);
|
|
15107
15163
|
const isHidden = !element.visible;
|
|
15108
15164
|
if (existingObj) {
|
|
15109
15165
|
const isBeingTransformed = transformingIdsRef.current.has(element.id);
|
|
@@ -15397,7 +15453,9 @@ const PageCanvas = forwardRef(
|
|
|
15397
15453
|
const node = findNodeById(pageTree, element.id);
|
|
15398
15454
|
return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
|
|
15399
15455
|
})() : { left: element.left ?? 0, top: element.top ?? 0 };
|
|
15400
|
-
const
|
|
15456
|
+
const comparePosForImg = getObjectSyncComparePosition(existingObj);
|
|
15457
|
+
const preserveSelectionMemberPosition = shouldPreserveActiveSelectionMemberPosition(existingObj);
|
|
15458
|
+
const positionChanged = !preserveSelectionMemberPosition && (Math.abs(comparePosForImg.left - storePosForImg.left) > 0.1 || Math.abs(comparePosForImg.top - storePosForImg.top) > 0.1);
|
|
15401
15459
|
if (visibilityChanged && !positionChanged || visibilityUpdateInProgressRef.current) {
|
|
15402
15460
|
const isDynamicField = dynamicFieldIds.includes(element.id);
|
|
15403
15461
|
const canBeEvented = isEditorMode || isPreviewMode && isDynamicField;
|
|
@@ -15412,7 +15470,7 @@ const PageCanvas = forwardRef(
|
|
|
15412
15470
|
previousVisibilityRef.current.set(element.id, currentVisible);
|
|
15413
15471
|
} else {
|
|
15414
15472
|
if (!visibilityUpdateInProgressRef.current) {
|
|
15415
|
-
updateFabricObject(existingObj, element, wasJustModified);
|
|
15473
|
+
updateFabricObject(existingObj, element, wasJustModified || preserveSelectionMemberPosition);
|
|
15416
15474
|
}
|
|
15417
15475
|
const isDynamicField = dynamicFieldIds.includes(element.id);
|
|
15418
15476
|
const canBeEvented = isEditorMode || isPreviewMode && isDynamicField;
|
|
@@ -15434,8 +15492,9 @@ const PageCanvas = forwardRef(
|
|
|
15434
15492
|
if (!isBeingTransformed && !isBeingTextEdited && !shouldSkipUpdates2) {
|
|
15435
15493
|
previousVisibilityRef.current.get(element.id) ?? true;
|
|
15436
15494
|
const currentVisible = element.visible !== false;
|
|
15437
|
-
const
|
|
15438
|
-
const
|
|
15495
|
+
const comparePos = getObjectSyncComparePosition(existingObj);
|
|
15496
|
+
const fabricLeft = comparePos.left;
|
|
15497
|
+
const fabricTop = comparePos.top;
|
|
15439
15498
|
const storePos = pageTree.length ? (() => {
|
|
15440
15499
|
const node = findNodeById(pageTree, element.id);
|
|
15441
15500
|
return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
|
|
@@ -15444,7 +15503,8 @@ const PageCanvas = forwardRef(
|
|
|
15444
15503
|
const storeTop = storePos.top;
|
|
15445
15504
|
const deltaX = Math.abs(fabricLeft - storeLeft);
|
|
15446
15505
|
const deltaY = Math.abs(fabricTop - storeTop);
|
|
15447
|
-
|
|
15506
|
+
const preserveSelectionMemberPosition = shouldPreserveActiveSelectionMemberPosition(existingObj);
|
|
15507
|
+
let positionChanged = !preserveSelectionMemberPosition && (deltaX > 0.1 || deltaY > 0.1);
|
|
15448
15508
|
const activeObj = fc.getActiveObject();
|
|
15449
15509
|
const isInActiveSelection = activeObj && (activeObj instanceof fabric.ActiveSelection ? activeObj.getObjects().includes(existingObj) : activeObj === existingObj);
|
|
15450
15510
|
const isInSelectedIds = selectedIdsFromStore.has(element.id);
|
|
@@ -15496,7 +15556,7 @@ const PageCanvas = forwardRef(
|
|
|
15496
15556
|
});
|
|
15497
15557
|
previousVisibilityRef.current.set(element.id, currentVisible);
|
|
15498
15558
|
} else {
|
|
15499
|
-
const skipPositionBecauseSelection = isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
|
|
15559
|
+
const skipPositionBecauseSelection = preserveSelectionMemberPosition || isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
|
|
15500
15560
|
const anyChange = positionChanged || otherPropsChanged || forceApplyFromPanel;
|
|
15501
15561
|
if (!visibilityUpdateInProgressRef.current) {
|
|
15502
15562
|
if (anyChange && !skipPositionBecauseSelection) {
|
|
@@ -23678,9 +23738,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
23678
23738
|
}
|
|
23679
23739
|
return svgString;
|
|
23680
23740
|
}
|
|
23681
|
-
const resolvedPackageVersion = "0.5.
|
|
23741
|
+
const resolvedPackageVersion = "0.5.272";
|
|
23682
23742
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
23683
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
23743
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.272";
|
|
23684
23744
|
const roundParityValue = (value) => {
|
|
23685
23745
|
if (typeof value !== "number") return value;
|
|
23686
23746
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -24494,7 +24554,7 @@ class PixldocsRenderer {
|
|
|
24494
24554
|
await this.waitForCanvasScene(container, cloned, i);
|
|
24495
24555
|
}
|
|
24496
24556
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
24497
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport
|
|
24557
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BySFN17q.js");
|
|
24498
24558
|
const prepared = preparePagesForExport(
|
|
24499
24559
|
cloned.pages,
|
|
24500
24560
|
canvasWidth,
|
|
@@ -26814,7 +26874,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
26814
26874
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
26815
26875
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
26816
26876
|
try {
|
|
26817
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport
|
|
26877
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BySFN17q.js");
|
|
26818
26878
|
try {
|
|
26819
26879
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
26820
26880
|
} catch {
|
|
@@ -27214,4 +27274,4 @@ export {
|
|
|
27214
27274
|
buildTeaserBlurFlatKeys as y,
|
|
27215
27275
|
collectFontDescriptorsFromConfig as z
|
|
27216
27276
|
};
|
|
27217
|
-
//# sourceMappingURL=index-
|
|
27277
|
+
//# sourceMappingURL=index-CHIScvwH.js.map
|