@pixldocs/canvas-renderer 0.5.272 → 0.5.274

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.
@@ -14986,6 +14986,22 @@ const PageCanvas = forwardRef(
14986
14986
  fc.discardActiveObject();
14987
14987
  }
14988
14988
  }
14989
+ const forceLogicalGroupStorePositionSyncIds = /* @__PURE__ */ new Set();
14990
+ const needsLooseLogicalGroupPositionSync = !!((activeSelectionSnapshot == null ? void 0 : activeSelectionSnapshot.groupSelectionId) && !syncTriggeredByPanelRef.current && !shouldSkipUpdates2 && !isTransforming2 && activeSelectionSnapshot.memberIds.some((id) => justModifiedIdsRef.current.has(id)));
14991
+ if (needsLooseLogicalGroupPositionSync) {
14992
+ activeSelectionSnapshot.memberIds.forEach((id) => forceLogicalGroupStorePositionSyncIds.add(id));
14993
+ const activeForLooseSync = fc.getActiveObject();
14994
+ if (activeForLooseSync instanceof fabric.ActiveSelection && activeForLooseSync.__pixldocsGroupSelection === activeSelectionSnapshot.groupSelectionId) {
14995
+ try {
14996
+ skipSelectionClearOnDiscardRef.current = true;
14997
+ skipActiveSelectionBakeOnClearRef.current = true;
14998
+ fc.discardActiveObject();
14999
+ } finally {
15000
+ skipActiveSelectionBakeOnClearRef.current = false;
15001
+ skipSelectionClearOnDiscardRef.current = false;
15002
+ }
15003
+ }
15004
+ }
14989
15005
  const currentFabricObjects = /* @__PURE__ */ new Map();
14990
15006
  fc.getObjects().forEach((obj) => {
14991
15007
  const id = getObjectId(obj);
@@ -14999,7 +15015,7 @@ const PageCanvas = forwardRef(
14999
15015
  const replacementById = !activeStillOnCanvas && activeId ? fc.getObjects().find((o) => getObjectId(o) === activeId) ?? null : null;
15000
15016
  const restoreTarget = activeStillOnCanvas ? activeBeforeSync : replacementById;
15001
15017
  const isActiveTextBeingEdited = activeId && editingTextIdRef.current === activeId && activeBeforeSync instanceof fabric.Textbox;
15002
- if (!skipRestoreSelection && activeSelectionSnapshot && !isActiveTextBeingEdited && !shouldSkipUpdates2) {
15018
+ if (!skipRestoreSelection && activeSelectionSnapshot && !isActiveTextBeingEdited && !shouldSkipUpdates2 && !needsLooseLogicalGroupPositionSync) {
15003
15019
  const freshMembers = activeSelectionSnapshot.memberIds.map((id) => fc.getObjects().find((o) => getObjectId(o) === id)).filter((o) => !!o);
15004
15020
  if (freshMembers.length > 1) {
15005
15021
  isSyncingSelectionToFabricRef.current = true;
@@ -15009,7 +15025,9 @@ const PageCanvas = forwardRef(
15009
15025
  applyLogicalGroupSelectionVisualState(newSel, activeSelectionSnapshot.groupSelectionId);
15010
15026
  }
15011
15027
  fc.setActiveObject(newSel);
15012
- newSel.setCoords();
15028
+ if (!(activeSelectionSnapshot.groupSelectionId && newSel.getObjects().every((obj) => !(obj instanceof fabric.Group)))) {
15029
+ newSel.setCoords();
15030
+ }
15013
15031
  fc.requestRenderAll();
15014
15032
  } finally {
15015
15033
  isSyncingSelectionToFabricRef.current = false;
@@ -15424,7 +15442,8 @@ const PageCanvas = forwardRef(
15424
15442
  continue;
15425
15443
  }
15426
15444
  if (existingObj instanceof fabric.Group && existingObj.__cropGroup) {
15427
- updateFabricObject(existingObj, element, wasJustModified);
15445
+ const forceStorePositionSync2 = forceLogicalGroupStorePositionSyncIds.has(element.id);
15446
+ updateFabricObject(existingObj, element, wasJustModified && !forceStorePositionSync2);
15428
15447
  existingObj.set({
15429
15448
  flipX: element.flipX ?? false,
15430
15449
  flipY: element.flipY ?? false,
@@ -15435,7 +15454,7 @@ const PageCanvas = forwardRef(
15435
15454
  if (wasJustModified) justModifiedIdsRef.current.delete(element.id);
15436
15455
  continue;
15437
15456
  }
15438
- if (existingObj instanceof fabric.Textbox && wasJustModified && !syncTriggeredByPanelRef.current) {
15457
+ if (existingObj instanceof fabric.Textbox && wasJustModified && !syncTriggeredByPanelRef.current && !forceLogicalGroupStorePositionSyncIds.has(element.id)) {
15439
15458
  justModifiedIdsRef.current.delete(element.id);
15440
15459
  continue;
15441
15460
  }
@@ -15454,7 +15473,8 @@ const PageCanvas = forwardRef(
15454
15473
  return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
15455
15474
  })() : { left: element.left ?? 0, top: element.top ?? 0 };
15456
15475
  const comparePosForImg = getObjectSyncComparePosition(existingObj);
15457
- const preserveSelectionMemberPosition = shouldPreserveActiveSelectionMemberPosition(existingObj);
15476
+ const forceStorePositionSync = forceLogicalGroupStorePositionSyncIds.has(element.id);
15477
+ const preserveSelectionMemberPosition = !forceStorePositionSync && shouldPreserveActiveSelectionMemberPosition(existingObj);
15458
15478
  const positionChanged = !preserveSelectionMemberPosition && (Math.abs(comparePosForImg.left - storePosForImg.left) > 0.1 || Math.abs(comparePosForImg.top - storePosForImg.top) > 0.1);
15459
15479
  if (visibilityChanged && !positionChanged || visibilityUpdateInProgressRef.current) {
15460
15480
  const isDynamicField = dynamicFieldIds.includes(element.id);
@@ -15470,7 +15490,7 @@ const PageCanvas = forwardRef(
15470
15490
  previousVisibilityRef.current.set(element.id, currentVisible);
15471
15491
  } else {
15472
15492
  if (!visibilityUpdateInProgressRef.current) {
15473
- updateFabricObject(existingObj, element, wasJustModified || preserveSelectionMemberPosition);
15493
+ updateFabricObject(existingObj, element, wasJustModified && !forceStorePositionSync || preserveSelectionMemberPosition);
15474
15494
  }
15475
15495
  const isDynamicField = dynamicFieldIds.includes(element.id);
15476
15496
  const canBeEvented = isEditorMode || isPreviewMode && isDynamicField;
@@ -15503,13 +15523,14 @@ const PageCanvas = forwardRef(
15503
15523
  const storeTop = storePos.top;
15504
15524
  const deltaX = Math.abs(fabricLeft - storeLeft);
15505
15525
  const deltaY = Math.abs(fabricTop - storeTop);
15506
- const preserveSelectionMemberPosition = shouldPreserveActiveSelectionMemberPosition(existingObj);
15526
+ const forceStorePositionSync = forceLogicalGroupStorePositionSyncIds.has(element.id);
15527
+ const preserveSelectionMemberPosition = !forceStorePositionSync && shouldPreserveActiveSelectionMemberPosition(existingObj);
15507
15528
  let positionChanged = !preserveSelectionMemberPosition && (deltaX > 0.1 || deltaY > 0.1);
15508
15529
  const activeObj = fc.getActiveObject();
15509
15530
  const isInActiveSelection = activeObj && (activeObj instanceof fabric.ActiveSelection ? activeObj.getObjects().includes(existingObj) : activeObj === existingObj);
15510
15531
  const isInSelectedIds = selectedIdsFromStore.has(element.id);
15511
15532
  const isSelected = isInActiveSelection || isInSelectedIds;
15512
- if (positionChanged && isSelected && (wasJustModified || isBeingTransformed)) {
15533
+ if (positionChanged && isSelected && (wasJustModified || isBeingTransformed) && !forceStorePositionSync) {
15513
15534
  positionChanged = false;
15514
15535
  }
15515
15536
  const resolvedSizeForCompare = pageTree.length ? getNodeBounds(element, pageTree) : { width: typeof element.width === "number" ? element.width : 0, height: typeof element.height === "number" ? element.height : 0 };
@@ -15556,11 +15577,11 @@ const PageCanvas = forwardRef(
15556
15577
  });
15557
15578
  previousVisibilityRef.current.set(element.id, currentVisible);
15558
15579
  } else {
15559
- const skipPositionBecauseSelection = preserveSelectionMemberPosition || isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
15580
+ const skipPositionBecauseSelection = preserveSelectionMemberPosition || !forceStorePositionSync && isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
15560
15581
  const anyChange = positionChanged || otherPropsChanged || forceApplyFromPanel;
15561
15582
  if (!visibilityUpdateInProgressRef.current) {
15562
15583
  if (anyChange && !skipPositionBecauseSelection) {
15563
- updateFabricObject(existingObj, element, wasJustModified);
15584
+ updateFabricObject(existingObj, element, wasJustModified && !forceStorePositionSync);
15564
15585
  if (wasJustModified) justModifiedIdsRef.current.delete(element.id);
15565
15586
  } else if (skipPositionBecauseSelection && anyChange) {
15566
15587
  const savedLeft = existingObj.left;
@@ -15787,7 +15808,9 @@ const PageCanvas = forwardRef(
15787
15808
  applyLogicalGroupSelectionVisualState(newSel, activeSelectionSnapshot.groupSelectionId);
15788
15809
  }
15789
15810
  fc.setActiveObject(newSel);
15790
- newSel.setCoords();
15811
+ if (!(activeSelectionSnapshot.groupSelectionId && newSel.getObjects().every((obj) => !(obj instanceof fabric.Group)))) {
15812
+ newSel.setCoords();
15813
+ }
15791
15814
  fc.requestRenderAll();
15792
15815
  } finally {
15793
15816
  isSyncingSelectionToFabricRef.current = false;
@@ -23738,9 +23761,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23738
23761
  }
23739
23762
  return svgString;
23740
23763
  }
23741
- const resolvedPackageVersion = "0.5.272";
23764
+ const resolvedPackageVersion = "0.5.274";
23742
23765
  const PACKAGE_VERSION = resolvedPackageVersion;
23743
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.272";
23766
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.274";
23744
23767
  const roundParityValue = (value) => {
23745
23768
  if (typeof value !== "number") return value;
23746
23769
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24554,7 +24577,7 @@ class PixldocsRenderer {
24554
24577
  await this.waitForCanvasScene(container, cloned, i);
24555
24578
  }
24556
24579
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24557
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BySFN17q.js");
24580
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-oOUmmqgb.js");
24558
24581
  const prepared = preparePagesForExport(
24559
24582
  cloned.pages,
24560
24583
  canvasWidth,
@@ -26874,7 +26897,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26874
26897
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26875
26898
  sanitizeSvgTreeForPdf(svgToDraw);
26876
26899
  try {
26877
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BySFN17q.js");
26900
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-oOUmmqgb.js");
26878
26901
  try {
26879
26902
  await logTextMeasurementDiagnostic(svgToDraw);
26880
26903
  } catch {
@@ -27274,4 +27297,4 @@ export {
27274
27297
  buildTeaserBlurFlatKeys as y,
27275
27298
  collectFontDescriptorsFromConfig as z
27276
27299
  };
27277
- //# sourceMappingURL=index-CHIScvwH.js.map
27300
+ //# sourceMappingURL=index-C3onaRVR.js.map