@pixldocs/canvas-renderer 0.5.272 → 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.
@@ -15004,6 +15004,22 @@ const PageCanvas = react.forwardRef(
15004
15004
  fc.discardActiveObject();
15005
15005
  }
15006
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
+ }
15007
15023
  const currentFabricObjects = /* @__PURE__ */ new Map();
15008
15024
  fc.getObjects().forEach((obj) => {
15009
15025
  const id = getObjectId(obj);
@@ -15017,7 +15033,7 @@ const PageCanvas = react.forwardRef(
15017
15033
  const replacementById = !activeStillOnCanvas && activeId ? fc.getObjects().find((o) => getObjectId(o) === activeId) ?? null : null;
15018
15034
  const restoreTarget = activeStillOnCanvas ? activeBeforeSync : replacementById;
15019
15035
  const isActiveTextBeingEdited = activeId && editingTextIdRef.current === activeId && activeBeforeSync instanceof fabric__namespace.Textbox;
15020
- if (!skipRestoreSelection && activeSelectionSnapshot && !isActiveTextBeingEdited && !shouldSkipUpdates2) {
15036
+ if (!skipRestoreSelection && activeSelectionSnapshot && !isActiveTextBeingEdited && !shouldSkipUpdates2 && !needsLooseLogicalGroupPositionSync) {
15021
15037
  const freshMembers = activeSelectionSnapshot.memberIds.map((id) => fc.getObjects().find((o) => getObjectId(o) === id)).filter((o) => !!o);
15022
15038
  if (freshMembers.length > 1) {
15023
15039
  isSyncingSelectionToFabricRef.current = true;
@@ -15442,7 +15458,8 @@ const PageCanvas = react.forwardRef(
15442
15458
  continue;
15443
15459
  }
15444
15460
  if (existingObj instanceof fabric__namespace.Group && existingObj.__cropGroup) {
15445
- updateFabricObject(existingObj, element, wasJustModified);
15461
+ const forceStorePositionSync2 = forceLogicalGroupStorePositionSyncIds.has(element.id);
15462
+ updateFabricObject(existingObj, element, wasJustModified && !forceStorePositionSync2);
15446
15463
  existingObj.set({
15447
15464
  flipX: element.flipX ?? false,
15448
15465
  flipY: element.flipY ?? false,
@@ -15453,7 +15470,7 @@ const PageCanvas = react.forwardRef(
15453
15470
  if (wasJustModified) justModifiedIdsRef.current.delete(element.id);
15454
15471
  continue;
15455
15472
  }
15456
- if (existingObj instanceof fabric__namespace.Textbox && wasJustModified && !syncTriggeredByPanelRef.current) {
15473
+ if (existingObj instanceof fabric__namespace.Textbox && wasJustModified && !syncTriggeredByPanelRef.current && !forceLogicalGroupStorePositionSyncIds.has(element.id)) {
15457
15474
  justModifiedIdsRef.current.delete(element.id);
15458
15475
  continue;
15459
15476
  }
@@ -15472,7 +15489,8 @@ const PageCanvas = react.forwardRef(
15472
15489
  return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
15473
15490
  })() : { left: element.left ?? 0, top: element.top ?? 0 };
15474
15491
  const comparePosForImg = getObjectSyncComparePosition(existingObj);
15475
- const preserveSelectionMemberPosition = shouldPreserveActiveSelectionMemberPosition(existingObj);
15492
+ const forceStorePositionSync = forceLogicalGroupStorePositionSyncIds.has(element.id);
15493
+ const preserveSelectionMemberPosition = !forceStorePositionSync && shouldPreserveActiveSelectionMemberPosition(existingObj);
15476
15494
  const positionChanged = !preserveSelectionMemberPosition && (Math.abs(comparePosForImg.left - storePosForImg.left) > 0.1 || Math.abs(comparePosForImg.top - storePosForImg.top) > 0.1);
15477
15495
  if (visibilityChanged && !positionChanged || visibilityUpdateInProgressRef.current) {
15478
15496
  const isDynamicField = dynamicFieldIds.includes(element.id);
@@ -15488,7 +15506,7 @@ const PageCanvas = react.forwardRef(
15488
15506
  previousVisibilityRef.current.set(element.id, currentVisible);
15489
15507
  } else {
15490
15508
  if (!visibilityUpdateInProgressRef.current) {
15491
- updateFabricObject(existingObj, element, wasJustModified || preserveSelectionMemberPosition);
15509
+ updateFabricObject(existingObj, element, wasJustModified && !forceStorePositionSync || preserveSelectionMemberPosition);
15492
15510
  }
15493
15511
  const isDynamicField = dynamicFieldIds.includes(element.id);
15494
15512
  const canBeEvented = isEditorMode || isPreviewMode && isDynamicField;
@@ -15521,13 +15539,14 @@ const PageCanvas = react.forwardRef(
15521
15539
  const storeTop = storePos.top;
15522
15540
  const deltaX = Math.abs(fabricLeft - storeLeft);
15523
15541
  const deltaY = Math.abs(fabricTop - storeTop);
15524
- const preserveSelectionMemberPosition = shouldPreserveActiveSelectionMemberPosition(existingObj);
15542
+ const forceStorePositionSync = forceLogicalGroupStorePositionSyncIds.has(element.id);
15543
+ const preserveSelectionMemberPosition = !forceStorePositionSync && shouldPreserveActiveSelectionMemberPosition(existingObj);
15525
15544
  let positionChanged = !preserveSelectionMemberPosition && (deltaX > 0.1 || deltaY > 0.1);
15526
15545
  const activeObj = fc.getActiveObject();
15527
15546
  const isInActiveSelection = activeObj && (activeObj instanceof fabric__namespace.ActiveSelection ? activeObj.getObjects().includes(existingObj) : activeObj === existingObj);
15528
15547
  const isInSelectedIds = selectedIdsFromStore.has(element.id);
15529
15548
  const isSelected = isInActiveSelection || isInSelectedIds;
15530
- if (positionChanged && isSelected && (wasJustModified || isBeingTransformed)) {
15549
+ if (positionChanged && isSelected && (wasJustModified || isBeingTransformed) && !forceStorePositionSync) {
15531
15550
  positionChanged = false;
15532
15551
  }
15533
15552
  const resolvedSizeForCompare = pageTree.length ? getNodeBounds(element, pageTree) : { width: typeof element.width === "number" ? element.width : 0, height: typeof element.height === "number" ? element.height : 0 };
@@ -15574,11 +15593,11 @@ const PageCanvas = react.forwardRef(
15574
15593
  });
15575
15594
  previousVisibilityRef.current.set(element.id, currentVisible);
15576
15595
  } else {
15577
- const skipPositionBecauseSelection = preserveSelectionMemberPosition || isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
15596
+ const skipPositionBecauseSelection = preserveSelectionMemberPosition || !forceStorePositionSync && isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
15578
15597
  const anyChange = positionChanged || otherPropsChanged || forceApplyFromPanel;
15579
15598
  if (!visibilityUpdateInProgressRef.current) {
15580
15599
  if (anyChange && !skipPositionBecauseSelection) {
15581
- updateFabricObject(existingObj, element, wasJustModified);
15600
+ updateFabricObject(existingObj, element, wasJustModified && !forceStorePositionSync);
15582
15601
  if (wasJustModified) justModifiedIdsRef.current.delete(element.id);
15583
15602
  } else if (skipPositionBecauseSelection && anyChange) {
15584
15603
  const savedLeft = existingObj.left;
@@ -23756,9 +23775,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23756
23775
  }
23757
23776
  return svgString;
23758
23777
  }
23759
- const resolvedPackageVersion = "0.5.272";
23778
+ const resolvedPackageVersion = "0.5.273";
23760
23779
  const PACKAGE_VERSION = resolvedPackageVersion;
23761
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.272";
23780
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.273";
23762
23781
  const roundParityValue = (value) => {
23763
23782
  if (typeof value !== "number") return value;
23764
23783
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24572,7 +24591,7 @@ class PixldocsRenderer {
24572
24591
  await this.waitForCanvasScene(container, cloned, i);
24573
24592
  }
24574
24593
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24575
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CdiLpR0-.cjs"));
24594
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CATK019f.cjs"));
24576
24595
  const prepared = preparePagesForExport(
24577
24596
  cloned.pages,
24578
24597
  canvasWidth,
@@ -26892,7 +26911,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26892
26911
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26893
26912
  sanitizeSvgTreeForPdf(svgToDraw);
26894
26913
  try {
26895
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CdiLpR0-.cjs"));
26914
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CATK019f.cjs"));
26896
26915
  try {
26897
26916
  await logTextMeasurementDiagnostic(svgToDraw);
26898
26917
  } catch {
@@ -27289,4 +27308,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27289
27308
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27290
27309
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27291
27310
  exports.warmTemplateFromForm = warmTemplateFromForm;
27292
- //# sourceMappingURL=index-BYfp_ae9.cjs.map
27311
+ //# sourceMappingURL=index-CeO7JhXA.cjs.map