@pixldocs/canvas-renderer 0.5.271 → 0.5.273
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-6188mLJ2.cjs → index-CeO7JhXA.cjs} +79 -19
- package/dist/index-CeO7JhXA.cjs.map +1 -0
- package/dist/{index-BpY8sZ_v.js → index-DCqQEnix.js} +79 -19
- package/dist/index-DCqQEnix.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-DjBUHamz.cjs → vectorPdfExport-CATK019f.cjs} +4 -4
- package/dist/{vectorPdfExport-DjBUHamz.cjs.map → vectorPdfExport-CATK019f.cjs.map} +1 -1
- package/dist/{vectorPdfExport-0BizqdiS.js → vectorPdfExport-D4O4QFHJ.js} +4 -4
- package/dist/{vectorPdfExport-0BizqdiS.js.map → vectorPdfExport-D4O4QFHJ.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-6188mLJ2.cjs.map +0 -1
- package/dist/index-BpY8sZ_v.js.map +0 -1
|
@@ -12722,7 +12722,9 @@ const PageCanvas = react.forwardRef(
|
|
|
12722
12722
|
const selection = new fabric__namespace.ActiveSelection(members, { canvas: fc });
|
|
12723
12723
|
restoreGroupSelectionVisualState(selection, groupId);
|
|
12724
12724
|
fc.setActiveObject(selection);
|
|
12725
|
-
selection.
|
|
12725
|
+
if (!selection.getObjects().every((obj) => !(obj instanceof fabric__namespace.Group))) {
|
|
12726
|
+
selection.setCoords();
|
|
12727
|
+
}
|
|
12726
12728
|
fc.requestRenderAll();
|
|
12727
12729
|
} finally {
|
|
12728
12730
|
requestAnimationFrame(() => {
|
|
@@ -14356,7 +14358,9 @@ const PageCanvas = react.forwardRef(
|
|
|
14356
14358
|
const bakedSelection = reselectionObjects.length > 1 ? new fabric__namespace.ActiveSelection(reselectionObjects, { canvas: fabricCanvas }) : activeObj;
|
|
14357
14359
|
restoreGroupSelectionVisualState(bakedSelection, groupSelectionId);
|
|
14358
14360
|
fabricCanvas.setActiveObject(bakedSelection);
|
|
14359
|
-
bakedSelection.
|
|
14361
|
+
if (!(bakedSelection instanceof fabric__namespace.ActiveSelection && bakedSelection.getObjects().every((obj) => !(obj instanceof fabric__namespace.Group)))) {
|
|
14362
|
+
bakedSelection.setCoords();
|
|
14363
|
+
}
|
|
14360
14364
|
}
|
|
14361
14365
|
selectElements([groupSelectionId], false, false);
|
|
14362
14366
|
fabricCanvas.requestRenderAll();
|
|
@@ -15000,6 +15004,22 @@ const PageCanvas = react.forwardRef(
|
|
|
15000
15004
|
fc.discardActiveObject();
|
|
15001
15005
|
}
|
|
15002
15006
|
}
|
|
15007
|
+
const forceLogicalGroupStorePositionSyncIds = /* @__PURE__ */ new Set();
|
|
15008
|
+
const needsLooseLogicalGroupPositionSync = !!((activeSelectionSnapshot == null ? void 0 : activeSelectionSnapshot.groupSelectionId) && !syncTriggeredByPanelRef.current && !shouldSkipUpdates2 && !isTransforming2 && activeSelectionSnapshot.memberIds.some((id) => justModifiedIdsRef.current.has(id)));
|
|
15009
|
+
if (needsLooseLogicalGroupPositionSync) {
|
|
15010
|
+
activeSelectionSnapshot.memberIds.forEach((id) => forceLogicalGroupStorePositionSyncIds.add(id));
|
|
15011
|
+
const activeForLooseSync = fc.getActiveObject();
|
|
15012
|
+
if (activeForLooseSync instanceof fabric__namespace.ActiveSelection && activeForLooseSync.__pixldocsGroupSelection === activeSelectionSnapshot.groupSelectionId) {
|
|
15013
|
+
try {
|
|
15014
|
+
skipSelectionClearOnDiscardRef.current = true;
|
|
15015
|
+
skipActiveSelectionBakeOnClearRef.current = true;
|
|
15016
|
+
fc.discardActiveObject();
|
|
15017
|
+
} finally {
|
|
15018
|
+
skipActiveSelectionBakeOnClearRef.current = false;
|
|
15019
|
+
skipSelectionClearOnDiscardRef.current = false;
|
|
15020
|
+
}
|
|
15021
|
+
}
|
|
15022
|
+
}
|
|
15003
15023
|
const currentFabricObjects = /* @__PURE__ */ new Map();
|
|
15004
15024
|
fc.getObjects().forEach((obj) => {
|
|
15005
15025
|
const id = getObjectId(obj);
|
|
@@ -15013,7 +15033,7 @@ const PageCanvas = react.forwardRef(
|
|
|
15013
15033
|
const replacementById = !activeStillOnCanvas && activeId ? fc.getObjects().find((o) => getObjectId(o) === activeId) ?? null : null;
|
|
15014
15034
|
const restoreTarget = activeStillOnCanvas ? activeBeforeSync : replacementById;
|
|
15015
15035
|
const isActiveTextBeingEdited = activeId && editingTextIdRef.current === activeId && activeBeforeSync instanceof fabric__namespace.Textbox;
|
|
15016
|
-
if (!skipRestoreSelection && activeSelectionSnapshot && !isActiveTextBeingEdited && !shouldSkipUpdates2) {
|
|
15036
|
+
if (!skipRestoreSelection && activeSelectionSnapshot && !isActiveTextBeingEdited && !shouldSkipUpdates2 && !needsLooseLogicalGroupPositionSync) {
|
|
15017
15037
|
const freshMembers = activeSelectionSnapshot.memberIds.map((id) => fc.getObjects().find((o) => getObjectId(o) === id)).filter((o) => !!o);
|
|
15018
15038
|
if (freshMembers.length > 1) {
|
|
15019
15039
|
isSyncingSelectionToFabricRef.current = true;
|
|
@@ -15138,9 +15158,42 @@ const PageCanvas = react.forwardRef(
|
|
|
15138
15158
|
};
|
|
15139
15159
|
fc.add(sectionGroup);
|
|
15140
15160
|
}
|
|
15161
|
+
const getActiveSelectionContainingObject = (obj) => {
|
|
15162
|
+
const active = fc.getActiveObject();
|
|
15163
|
+
return active instanceof fabric__namespace.ActiveSelection && active.getObjects().includes(obj) ? active : null;
|
|
15164
|
+
};
|
|
15165
|
+
const shouldPreserveActiveSelectionMemberPosition = (obj) => {
|
|
15166
|
+
if (syncTriggeredByPanelRef.current) return false;
|
|
15167
|
+
const activeSelection = getActiveSelectionContainingObject(obj);
|
|
15168
|
+
if (!activeSelection) return false;
|
|
15169
|
+
const logicalActiveSelection = activeSelection;
|
|
15170
|
+
const logicalGroupId = logicalActiveSelection.__pixldocsGroupSelection;
|
|
15171
|
+
const logicalGroupIds = logicalActiveSelection.__pixldocsLogicalGroupIds;
|
|
15172
|
+
if (logicalGroupId || Array.isArray(logicalGroupIds)) return true;
|
|
15173
|
+
const id = getObjectId(obj);
|
|
15174
|
+
const preserved = preserveActiveSelectionAfterTransformRef.current;
|
|
15175
|
+
return !!(id && (preserved == null ? void 0 : preserved.memberIds.includes(id)) && (!preserved.expiresAt || preserved.expiresAt > Date.now()));
|
|
15176
|
+
};
|
|
15177
|
+
const getObjectSyncComparePosition = (obj) => {
|
|
15178
|
+
const activeSelection = getActiveSelectionContainingObject(obj);
|
|
15179
|
+
if (!activeSelection) return { left: obj.left ?? 0, top: obj.top ?? 0 };
|
|
15180
|
+
const point = fabric__namespace.util.transformPoint({ x: obj.left ?? 0, y: obj.top ?? 0 }, activeSelection.calcTransformMatrix());
|
|
15181
|
+
let left = point.x;
|
|
15182
|
+
let top = point.y;
|
|
15183
|
+
const cropObj = obj;
|
|
15184
|
+
if (obj instanceof fabric__namespace.Group && cropObj.__cropGroup) {
|
|
15185
|
+
const ct = cropObj.__cropData;
|
|
15186
|
+
left -= ((ct == null ? void 0 : ct.frameW) ?? obj.width ?? 0) * Math.abs(obj.scaleX ?? 1) / 2;
|
|
15187
|
+
top -= ((ct == null ? void 0 : ct.frameH) ?? obj.height ?? 0) * Math.abs(obj.scaleY ?? 1) / 2;
|
|
15188
|
+
} else if (obj instanceof fabric__namespace.FabricImage && (obj.originX === "center" || obj.originY === "center")) {
|
|
15189
|
+
left -= (obj.width ?? 0) * Math.abs(obj.scaleX ?? 1) / 2;
|
|
15190
|
+
top -= (obj.height ?? 0) * Math.abs(obj.scaleY ?? 1) / 2;
|
|
15191
|
+
}
|
|
15192
|
+
return { left, top };
|
|
15193
|
+
};
|
|
15141
15194
|
for (const element of elementsToSync) {
|
|
15142
15195
|
if (sectionDescendantIds.has(element.id)) continue;
|
|
15143
|
-
|
|
15196
|
+
const existingObj = currentFabricObjects.get(element.id);
|
|
15144
15197
|
const isHidden = !element.visible;
|
|
15145
15198
|
if (existingObj) {
|
|
15146
15199
|
const isBeingTransformed = transformingIdsRef.current.has(element.id);
|
|
@@ -15405,7 +15458,8 @@ const PageCanvas = react.forwardRef(
|
|
|
15405
15458
|
continue;
|
|
15406
15459
|
}
|
|
15407
15460
|
if (existingObj instanceof fabric__namespace.Group && existingObj.__cropGroup) {
|
|
15408
|
-
|
|
15461
|
+
const forceStorePositionSync2 = forceLogicalGroupStorePositionSyncIds.has(element.id);
|
|
15462
|
+
updateFabricObject(existingObj, element, wasJustModified && !forceStorePositionSync2);
|
|
15409
15463
|
existingObj.set({
|
|
15410
15464
|
flipX: element.flipX ?? false,
|
|
15411
15465
|
flipY: element.flipY ?? false,
|
|
@@ -15416,7 +15470,7 @@ const PageCanvas = react.forwardRef(
|
|
|
15416
15470
|
if (wasJustModified) justModifiedIdsRef.current.delete(element.id);
|
|
15417
15471
|
continue;
|
|
15418
15472
|
}
|
|
15419
|
-
if (existingObj instanceof fabric__namespace.Textbox && wasJustModified && !syncTriggeredByPanelRef.current) {
|
|
15473
|
+
if (existingObj instanceof fabric__namespace.Textbox && wasJustModified && !syncTriggeredByPanelRef.current && !forceLogicalGroupStorePositionSyncIds.has(element.id)) {
|
|
15420
15474
|
justModifiedIdsRef.current.delete(element.id);
|
|
15421
15475
|
continue;
|
|
15422
15476
|
}
|
|
@@ -15434,7 +15488,10 @@ const PageCanvas = react.forwardRef(
|
|
|
15434
15488
|
const node = findNodeById(pageTree, element.id);
|
|
15435
15489
|
return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
|
|
15436
15490
|
})() : { left: element.left ?? 0, top: element.top ?? 0 };
|
|
15437
|
-
const
|
|
15491
|
+
const comparePosForImg = getObjectSyncComparePosition(existingObj);
|
|
15492
|
+
const forceStorePositionSync = forceLogicalGroupStorePositionSyncIds.has(element.id);
|
|
15493
|
+
const preserveSelectionMemberPosition = !forceStorePositionSync && shouldPreserveActiveSelectionMemberPosition(existingObj);
|
|
15494
|
+
const positionChanged = !preserveSelectionMemberPosition && (Math.abs(comparePosForImg.left - storePosForImg.left) > 0.1 || Math.abs(comparePosForImg.top - storePosForImg.top) > 0.1);
|
|
15438
15495
|
if (visibilityChanged && !positionChanged || visibilityUpdateInProgressRef.current) {
|
|
15439
15496
|
const isDynamicField = dynamicFieldIds.includes(element.id);
|
|
15440
15497
|
const canBeEvented = isEditorMode || isPreviewMode && isDynamicField;
|
|
@@ -15449,7 +15506,7 @@ const PageCanvas = react.forwardRef(
|
|
|
15449
15506
|
previousVisibilityRef.current.set(element.id, currentVisible);
|
|
15450
15507
|
} else {
|
|
15451
15508
|
if (!visibilityUpdateInProgressRef.current) {
|
|
15452
|
-
updateFabricObject(existingObj, element, wasJustModified);
|
|
15509
|
+
updateFabricObject(existingObj, element, wasJustModified && !forceStorePositionSync || preserveSelectionMemberPosition);
|
|
15453
15510
|
}
|
|
15454
15511
|
const isDynamicField = dynamicFieldIds.includes(element.id);
|
|
15455
15512
|
const canBeEvented = isEditorMode || isPreviewMode && isDynamicField;
|
|
@@ -15471,8 +15528,9 @@ const PageCanvas = react.forwardRef(
|
|
|
15471
15528
|
if (!isBeingTransformed && !isBeingTextEdited && !shouldSkipUpdates2) {
|
|
15472
15529
|
previousVisibilityRef.current.get(element.id) ?? true;
|
|
15473
15530
|
const currentVisible = element.visible !== false;
|
|
15474
|
-
const
|
|
15475
|
-
const
|
|
15531
|
+
const comparePos = getObjectSyncComparePosition(existingObj);
|
|
15532
|
+
const fabricLeft = comparePos.left;
|
|
15533
|
+
const fabricTop = comparePos.top;
|
|
15476
15534
|
const storePos = pageTree.length ? (() => {
|
|
15477
15535
|
const node = findNodeById(pageTree, element.id);
|
|
15478
15536
|
return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
|
|
@@ -15481,12 +15539,14 @@ const PageCanvas = react.forwardRef(
|
|
|
15481
15539
|
const storeTop = storePos.top;
|
|
15482
15540
|
const deltaX = Math.abs(fabricLeft - storeLeft);
|
|
15483
15541
|
const deltaY = Math.abs(fabricTop - storeTop);
|
|
15484
|
-
|
|
15542
|
+
const forceStorePositionSync = forceLogicalGroupStorePositionSyncIds.has(element.id);
|
|
15543
|
+
const preserveSelectionMemberPosition = !forceStorePositionSync && shouldPreserveActiveSelectionMemberPosition(existingObj);
|
|
15544
|
+
let positionChanged = !preserveSelectionMemberPosition && (deltaX > 0.1 || deltaY > 0.1);
|
|
15485
15545
|
const activeObj = fc.getActiveObject();
|
|
15486
15546
|
const isInActiveSelection = activeObj && (activeObj instanceof fabric__namespace.ActiveSelection ? activeObj.getObjects().includes(existingObj) : activeObj === existingObj);
|
|
15487
15547
|
const isInSelectedIds = selectedIdsFromStore.has(element.id);
|
|
15488
15548
|
const isSelected = isInActiveSelection || isInSelectedIds;
|
|
15489
|
-
if (positionChanged && isSelected && (wasJustModified || isBeingTransformed)) {
|
|
15549
|
+
if (positionChanged && isSelected && (wasJustModified || isBeingTransformed) && !forceStorePositionSync) {
|
|
15490
15550
|
positionChanged = false;
|
|
15491
15551
|
}
|
|
15492
15552
|
const resolvedSizeForCompare = pageTree.length ? getNodeBounds(element, pageTree) : { width: typeof element.width === "number" ? element.width : 0, height: typeof element.height === "number" ? element.height : 0 };
|
|
@@ -15533,11 +15593,11 @@ const PageCanvas = react.forwardRef(
|
|
|
15533
15593
|
});
|
|
15534
15594
|
previousVisibilityRef.current.set(element.id, currentVisible);
|
|
15535
15595
|
} else {
|
|
15536
|
-
const skipPositionBecauseSelection = isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
|
|
15596
|
+
const skipPositionBecauseSelection = preserveSelectionMemberPosition || !forceStorePositionSync && isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
|
|
15537
15597
|
const anyChange = positionChanged || otherPropsChanged || forceApplyFromPanel;
|
|
15538
15598
|
if (!visibilityUpdateInProgressRef.current) {
|
|
15539
15599
|
if (anyChange && !skipPositionBecauseSelection) {
|
|
15540
|
-
updateFabricObject(existingObj, element, wasJustModified);
|
|
15600
|
+
updateFabricObject(existingObj, element, wasJustModified && !forceStorePositionSync);
|
|
15541
15601
|
if (wasJustModified) justModifiedIdsRef.current.delete(element.id);
|
|
15542
15602
|
} else if (skipPositionBecauseSelection && anyChange) {
|
|
15543
15603
|
const savedLeft = existingObj.left;
|
|
@@ -23715,9 +23775,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
23715
23775
|
}
|
|
23716
23776
|
return svgString;
|
|
23717
23777
|
}
|
|
23718
|
-
const resolvedPackageVersion = "0.5.
|
|
23778
|
+
const resolvedPackageVersion = "0.5.273";
|
|
23719
23779
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
23720
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
23780
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.273";
|
|
23721
23781
|
const roundParityValue = (value) => {
|
|
23722
23782
|
if (typeof value !== "number") return value;
|
|
23723
23783
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -24531,7 +24591,7 @@ class PixldocsRenderer {
|
|
|
24531
24591
|
await this.waitForCanvasScene(container, cloned, i);
|
|
24532
24592
|
}
|
|
24533
24593
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
24534
|
-
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
24594
|
+
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CATK019f.cjs"));
|
|
24535
24595
|
const prepared = preparePagesForExport(
|
|
24536
24596
|
cloned.pages,
|
|
24537
24597
|
canvasWidth,
|
|
@@ -26851,7 +26911,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
26851
26911
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
26852
26912
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
26853
26913
|
try {
|
|
26854
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
26914
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CATK019f.cjs"));
|
|
26855
26915
|
try {
|
|
26856
26916
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
26857
26917
|
} catch {
|
|
@@ -27248,4 +27308,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
|
27248
27308
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
27249
27309
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
27250
27310
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|
|
27251
|
-
//# sourceMappingURL=index-
|
|
27311
|
+
//# sourceMappingURL=index-CeO7JhXA.cjs.map
|