@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.
@@ -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;
@@ -15027,7 +15043,9 @@ const PageCanvas = react.forwardRef(
15027
15043
  applyLogicalGroupSelectionVisualState(newSel, activeSelectionSnapshot.groupSelectionId);
15028
15044
  }
15029
15045
  fc.setActiveObject(newSel);
15030
- newSel.setCoords();
15046
+ if (!(activeSelectionSnapshot.groupSelectionId && newSel.getObjects().every((obj) => !(obj instanceof fabric__namespace.Group)))) {
15047
+ newSel.setCoords();
15048
+ }
15031
15049
  fc.requestRenderAll();
15032
15050
  } finally {
15033
15051
  isSyncingSelectionToFabricRef.current = false;
@@ -15442,7 +15460,8 @@ const PageCanvas = react.forwardRef(
15442
15460
  continue;
15443
15461
  }
15444
15462
  if (existingObj instanceof fabric__namespace.Group && existingObj.__cropGroup) {
15445
- updateFabricObject(existingObj, element, wasJustModified);
15463
+ const forceStorePositionSync2 = forceLogicalGroupStorePositionSyncIds.has(element.id);
15464
+ updateFabricObject(existingObj, element, wasJustModified && !forceStorePositionSync2);
15446
15465
  existingObj.set({
15447
15466
  flipX: element.flipX ?? false,
15448
15467
  flipY: element.flipY ?? false,
@@ -15453,7 +15472,7 @@ const PageCanvas = react.forwardRef(
15453
15472
  if (wasJustModified) justModifiedIdsRef.current.delete(element.id);
15454
15473
  continue;
15455
15474
  }
15456
- if (existingObj instanceof fabric__namespace.Textbox && wasJustModified && !syncTriggeredByPanelRef.current) {
15475
+ if (existingObj instanceof fabric__namespace.Textbox && wasJustModified && !syncTriggeredByPanelRef.current && !forceLogicalGroupStorePositionSyncIds.has(element.id)) {
15457
15476
  justModifiedIdsRef.current.delete(element.id);
15458
15477
  continue;
15459
15478
  }
@@ -15472,7 +15491,8 @@ const PageCanvas = react.forwardRef(
15472
15491
  return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
15473
15492
  })() : { left: element.left ?? 0, top: element.top ?? 0 };
15474
15493
  const comparePosForImg = getObjectSyncComparePosition(existingObj);
15475
- const preserveSelectionMemberPosition = shouldPreserveActiveSelectionMemberPosition(existingObj);
15494
+ const forceStorePositionSync = forceLogicalGroupStorePositionSyncIds.has(element.id);
15495
+ const preserveSelectionMemberPosition = !forceStorePositionSync && shouldPreserveActiveSelectionMemberPosition(existingObj);
15476
15496
  const positionChanged = !preserveSelectionMemberPosition && (Math.abs(comparePosForImg.left - storePosForImg.left) > 0.1 || Math.abs(comparePosForImg.top - storePosForImg.top) > 0.1);
15477
15497
  if (visibilityChanged && !positionChanged || visibilityUpdateInProgressRef.current) {
15478
15498
  const isDynamicField = dynamicFieldIds.includes(element.id);
@@ -15488,7 +15508,7 @@ const PageCanvas = react.forwardRef(
15488
15508
  previousVisibilityRef.current.set(element.id, currentVisible);
15489
15509
  } else {
15490
15510
  if (!visibilityUpdateInProgressRef.current) {
15491
- updateFabricObject(existingObj, element, wasJustModified || preserveSelectionMemberPosition);
15511
+ updateFabricObject(existingObj, element, wasJustModified && !forceStorePositionSync || preserveSelectionMemberPosition);
15492
15512
  }
15493
15513
  const isDynamicField = dynamicFieldIds.includes(element.id);
15494
15514
  const canBeEvented = isEditorMode || isPreviewMode && isDynamicField;
@@ -15521,13 +15541,14 @@ const PageCanvas = react.forwardRef(
15521
15541
  const storeTop = storePos.top;
15522
15542
  const deltaX = Math.abs(fabricLeft - storeLeft);
15523
15543
  const deltaY = Math.abs(fabricTop - storeTop);
15524
- const preserveSelectionMemberPosition = shouldPreserveActiveSelectionMemberPosition(existingObj);
15544
+ const forceStorePositionSync = forceLogicalGroupStorePositionSyncIds.has(element.id);
15545
+ const preserveSelectionMemberPosition = !forceStorePositionSync && shouldPreserveActiveSelectionMemberPosition(existingObj);
15525
15546
  let positionChanged = !preserveSelectionMemberPosition && (deltaX > 0.1 || deltaY > 0.1);
15526
15547
  const activeObj = fc.getActiveObject();
15527
15548
  const isInActiveSelection = activeObj && (activeObj instanceof fabric__namespace.ActiveSelection ? activeObj.getObjects().includes(existingObj) : activeObj === existingObj);
15528
15549
  const isInSelectedIds = selectedIdsFromStore.has(element.id);
15529
15550
  const isSelected = isInActiveSelection || isInSelectedIds;
15530
- if (positionChanged && isSelected && (wasJustModified || isBeingTransformed)) {
15551
+ if (positionChanged && isSelected && (wasJustModified || isBeingTransformed) && !forceStorePositionSync) {
15531
15552
  positionChanged = false;
15532
15553
  }
15533
15554
  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 +15595,11 @@ const PageCanvas = react.forwardRef(
15574
15595
  });
15575
15596
  previousVisibilityRef.current.set(element.id, currentVisible);
15576
15597
  } else {
15577
- const skipPositionBecauseSelection = preserveSelectionMemberPosition || isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
15598
+ const skipPositionBecauseSelection = preserveSelectionMemberPosition || !forceStorePositionSync && isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
15578
15599
  const anyChange = positionChanged || otherPropsChanged || forceApplyFromPanel;
15579
15600
  if (!visibilityUpdateInProgressRef.current) {
15580
15601
  if (anyChange && !skipPositionBecauseSelection) {
15581
- updateFabricObject(existingObj, element, wasJustModified);
15602
+ updateFabricObject(existingObj, element, wasJustModified && !forceStorePositionSync);
15582
15603
  if (wasJustModified) justModifiedIdsRef.current.delete(element.id);
15583
15604
  } else if (skipPositionBecauseSelection && anyChange) {
15584
15605
  const savedLeft = existingObj.left;
@@ -15805,7 +15826,9 @@ const PageCanvas = react.forwardRef(
15805
15826
  applyLogicalGroupSelectionVisualState(newSel, activeSelectionSnapshot.groupSelectionId);
15806
15827
  }
15807
15828
  fc.setActiveObject(newSel);
15808
- newSel.setCoords();
15829
+ if (!(activeSelectionSnapshot.groupSelectionId && newSel.getObjects().every((obj) => !(obj instanceof fabric__namespace.Group)))) {
15830
+ newSel.setCoords();
15831
+ }
15809
15832
  fc.requestRenderAll();
15810
15833
  } finally {
15811
15834
  isSyncingSelectionToFabricRef.current = false;
@@ -23756,9 +23779,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23756
23779
  }
23757
23780
  return svgString;
23758
23781
  }
23759
- const resolvedPackageVersion = "0.5.272";
23782
+ const resolvedPackageVersion = "0.5.274";
23760
23783
  const PACKAGE_VERSION = resolvedPackageVersion;
23761
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.272";
23784
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.274";
23762
23785
  const roundParityValue = (value) => {
23763
23786
  if (typeof value !== "number") return value;
23764
23787
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24572,7 +24595,7 @@ class PixldocsRenderer {
24572
24595
  await this.waitForCanvasScene(container, cloned, i);
24573
24596
  }
24574
24597
  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"));
24598
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BECWB93v.cjs"));
24576
24599
  const prepared = preparePagesForExport(
24577
24600
  cloned.pages,
24578
24601
  canvasWidth,
@@ -26892,7 +26915,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26892
26915
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26893
26916
  sanitizeSvgTreeForPdf(svgToDraw);
26894
26917
  try {
26895
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CdiLpR0-.cjs"));
26918
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BECWB93v.cjs"));
26896
26919
  try {
26897
26920
  await logTextMeasurementDiagnostic(svgToDraw);
26898
26921
  } catch {
@@ -27289,4 +27312,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27289
27312
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27290
27313
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27291
27314
  exports.warmTemplateFromForm = warmTemplateFromForm;
27292
- //# sourceMappingURL=index-BYfp_ae9.cjs.map
27315
+ //# sourceMappingURL=index-DvrcUgha.cjs.map