@pixldocs/canvas-renderer 0.5.367 → 0.5.369

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.
@@ -11553,6 +11553,7 @@ const PageCanvas = react.forwardRef(
11553
11553
  const skipSelectionClearOnDiscardRef = react.useRef(false);
11554
11554
  const skipActiveSelectionBakeOnClearRef = react.useRef(false);
11555
11555
  const suppressObjectModifiedDuringInternalReselectRef = react.useRef(false);
11556
+ const suppressSelectionEventsUntilRef = react.useRef(0);
11556
11557
  const preserveEditingScopeOnSelectionClearRef = react.useRef(false);
11557
11558
  const preserveActiveSelectionAfterTransformRef = react.useRef(null);
11558
11559
  const recentGroupSelectionRestoreRef = react.useRef(null);
@@ -11601,9 +11602,17 @@ const PageCanvas = react.forwardRef(
11601
11602
  if (!fc || !groupId || snapshot.memberIds.length < 2 || editingTextIdRef.current) return;
11602
11603
  const members = snapshot.memberIds.map((id) => fc.getObjects().find((o) => getObjectId(o) === id)).filter((o) => !!o);
11603
11604
  if (members.length < 2) return;
11605
+ const activeBeforeRestore = fc.getActiveObject();
11606
+ if (activeBeforeRestore instanceof fabric__namespace.ActiveSelection) {
11607
+ const activeMembers = activeBeforeRestore.getObjects();
11608
+ const sameMembers = activeMembers.length === members.length && members.every((member) => activeMembers.includes(member));
11609
+ const sameGroup = activeBeforeRestore.__pixldocsGroupSelection === groupId;
11610
+ const alreadyAligned = activeBeforeRestore.__pixldocsAlignedAngle != null;
11611
+ if (sameMembers && sameGroup && alreadyAligned) return;
11612
+ }
11604
11613
  isSyncingSelectionToFabricRef.current = true;
11605
11614
  try {
11606
- const active = fc.getActiveObject();
11615
+ const active = activeBeforeRestore;
11607
11616
  const selection = active instanceof fabric__namespace.ActiveSelection && members.every((member) => active.getObjects().includes(member)) ? active : new fabric__namespace.ActiveSelection(members, { canvas: fc });
11608
11617
  applyLogicalGroupSelectionVisualState(selection, groupId);
11609
11618
  fc.setActiveObject(selection);
@@ -12840,7 +12849,7 @@ const PageCanvas = react.forwardRef(
12840
12849
  };
12841
12850
  fabricCanvas.on("selection:created", () => {
12842
12851
  var _a2;
12843
- if (suppressObjectModifiedDuringInternalReselectRef.current) return;
12852
+ if (suppressObjectModifiedDuringInternalReselectRef.current || performance.now() < suppressSelectionEventsUntilRef.current) return;
12844
12853
  syncSelectionToStore();
12845
12854
  const activeObj = fabricCanvas.getActiveObject();
12846
12855
  if (activeObj instanceof fabric__namespace.ActiveSelection) applyWarpAwareSelectionBorders(activeObj);
@@ -12853,7 +12862,7 @@ const PageCanvas = react.forwardRef(
12853
12862
  });
12854
12863
  fabricCanvas.on("selection:updated", () => {
12855
12864
  var _a2;
12856
- if (suppressObjectModifiedDuringInternalReselectRef.current) return;
12865
+ if (suppressObjectModifiedDuringInternalReselectRef.current || performance.now() < suppressSelectionEventsUntilRef.current) return;
12857
12866
  const next = fabricCanvas.getActiveObject();
12858
12867
  const isLogicalGroupSel = next instanceof fabric__namespace.ActiveSelection && (next.__pixldocsGroupSelection || Array.isArray(next.__pixldocsLogicalGroupIds));
12859
12868
  if (!isLogicalGroupSel) restoreSuppressedGroupBorders();
@@ -13215,6 +13224,14 @@ const PageCanvas = react.forwardRef(
13215
13224
  requestAnimationFrame(() => {
13216
13225
  setTimeout(() => {
13217
13226
  if (!isActiveRef.current) return;
13227
+ const active = fabricCanvas.getActiveObject();
13228
+ if (active instanceof fabric__namespace.ActiveSelection) {
13229
+ const activeIds = active.getObjects().map((obj) => getObjectId(obj)).filter((id) => !!id && id !== "__background__");
13230
+ const sameMembers = activeIds.length === snapshot.memberIds.length && snapshot.memberIds.every((id) => activeIds.includes(id));
13231
+ const sameGroup = active.__pixldocsGroupSelection === snapshot.groupSelectionId;
13232
+ const alreadyAligned = active.__pixldocsAlignedAngle != null;
13233
+ if (sameMembers && sameGroup && alreadyAligned) return;
13234
+ }
13218
13235
  restoreGroupSelectionSnapshot(snapshot);
13219
13236
  }, 0);
13220
13237
  });
@@ -14245,12 +14262,16 @@ const PageCanvas = react.forwardRef(
14245
14262
  obj.dirty = true;
14246
14263
  }
14247
14264
  }
14248
- snapDuringScaleCallback(obj, corner);
14249
- const scaleGuides = calculateScaleSnapGuidesCallback(obj, corner);
14265
+ const normalizedScaleAngle = ((obj.angle ?? 0) % 360 + 360) % 360;
14266
+ const isRotatedActiveSelectionCorner = obj instanceof fabric__namespace.ActiveSelection && isCornerResizeHandle(corner) && Math.min(normalizedScaleAngle, 360 - normalizedScaleAngle) > 0.5;
14267
+ if (!isRotatedActiveSelectionCorner) {
14268
+ snapDuringScaleCallback(obj, corner);
14269
+ }
14270
+ const scaleGuides = isRotatedActiveSelectionCorner ? [] : calculateScaleSnapGuidesCallback(obj, corner);
14250
14271
  const gridGuidesForScale = [];
14251
14272
  try {
14252
14273
  const psGrid = projectSettingsRef.current;
14253
- const canApplyGridSnap = psGrid.snapToGrid && corner && !obj.__cropGroup && !obj.__resizeSnapHandler;
14274
+ const canApplyGridSnap = psGrid.snapToGrid && corner && !isRotatedActiveSelectionCorner && !obj.__cropGroup && !obj.__resizeSnapHandler;
14254
14275
  if (canApplyGridSnap) {
14255
14276
  const gridX = psGrid.gridSizeX ?? psGrid.gridSize ?? 0;
14256
14277
  const gridY = psGrid.gridSizeY ?? psGrid.gridSize ?? 0;
@@ -15519,6 +15540,7 @@ const PageCanvas = react.forwardRef(
15519
15540
  const prevRenderOnAddRemove = fabricCanvas.renderOnAddRemove;
15520
15541
  fabricCanvas.renderOnAddRemove = false;
15521
15542
  suppressObjectModifiedDuringInternalReselectRef.current = true;
15543
+ suppressSelectionEventsUntilRef.current = performance.now() + 80;
15522
15544
  skipSelectionClearOnDiscardRef.current = true;
15523
15545
  skipActiveSelectionBakeOnClearRef.current = true;
15524
15546
  try {
@@ -15590,6 +15612,7 @@ const PageCanvas = react.forwardRef(
15590
15612
  unlockEditsSoon();
15591
15613
  } catch (e2) {
15592
15614
  suppressObjectModifiedDuringInternalReselectRef.current = false;
15615
+ suppressSelectionEventsUntilRef.current = 0;
15593
15616
  skipSelectionClearOnDiscardRef.current = false;
15594
15617
  skipActiveSelectionBakeOnClearRef.current = false;
15595
15618
  unlockEditsSoon();
@@ -24627,9 +24650,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24627
24650
  }
24628
24651
  return svgString;
24629
24652
  }
24630
- const resolvedPackageVersion = "0.5.367";
24653
+ const resolvedPackageVersion = "0.5.369";
24631
24654
  const PACKAGE_VERSION = resolvedPackageVersion;
24632
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.367";
24655
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.369";
24633
24656
  const roundParityValue = (value) => {
24634
24657
  if (typeof value !== "number") return value;
24635
24658
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25443,7 +25466,7 @@ class PixldocsRenderer {
25443
25466
  await this.waitForCanvasScene(container, cloned, i);
25444
25467
  }
25445
25468
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25446
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-IZ_tpeyw.cjs"));
25469
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CEv3yhbN.cjs"));
25447
25470
  const prepared = preparePagesForExport(
25448
25471
  cloned.pages,
25449
25472
  canvasWidth,
@@ -27763,7 +27786,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27763
27786
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27764
27787
  sanitizeSvgTreeForPdf(svgToDraw);
27765
27788
  try {
27766
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-IZ_tpeyw.cjs"));
27789
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CEv3yhbN.cjs"));
27767
27790
  try {
27768
27791
  await logTextMeasurementDiagnostic(svgToDraw);
27769
27792
  } catch {
@@ -28160,4 +28183,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28160
28183
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28161
28184
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28162
28185
  exports.warmTemplateFromForm = warmTemplateFromForm;
28163
- //# sourceMappingURL=index-CG1dGppw.cjs.map
28186
+ //# sourceMappingURL=index-DSq50Plv.cjs.map