@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.
@@ -11535,6 +11535,7 @@ const PageCanvas = forwardRef(
11535
11535
  const skipSelectionClearOnDiscardRef = useRef(false);
11536
11536
  const skipActiveSelectionBakeOnClearRef = useRef(false);
11537
11537
  const suppressObjectModifiedDuringInternalReselectRef = useRef(false);
11538
+ const suppressSelectionEventsUntilRef = useRef(0);
11538
11539
  const preserveEditingScopeOnSelectionClearRef = useRef(false);
11539
11540
  const preserveActiveSelectionAfterTransformRef = useRef(null);
11540
11541
  const recentGroupSelectionRestoreRef = useRef(null);
@@ -11583,9 +11584,17 @@ const PageCanvas = forwardRef(
11583
11584
  if (!fc || !groupId || snapshot.memberIds.length < 2 || editingTextIdRef.current) return;
11584
11585
  const members = snapshot.memberIds.map((id) => fc.getObjects().find((o) => getObjectId(o) === id)).filter((o) => !!o);
11585
11586
  if (members.length < 2) return;
11587
+ const activeBeforeRestore = fc.getActiveObject();
11588
+ if (activeBeforeRestore instanceof fabric.ActiveSelection) {
11589
+ const activeMembers = activeBeforeRestore.getObjects();
11590
+ const sameMembers = activeMembers.length === members.length && members.every((member) => activeMembers.includes(member));
11591
+ const sameGroup = activeBeforeRestore.__pixldocsGroupSelection === groupId;
11592
+ const alreadyAligned = activeBeforeRestore.__pixldocsAlignedAngle != null;
11593
+ if (sameMembers && sameGroup && alreadyAligned) return;
11594
+ }
11586
11595
  isSyncingSelectionToFabricRef.current = true;
11587
11596
  try {
11588
- const active = fc.getActiveObject();
11597
+ const active = activeBeforeRestore;
11589
11598
  const selection = active instanceof fabric.ActiveSelection && members.every((member) => active.getObjects().includes(member)) ? active : new fabric.ActiveSelection(members, { canvas: fc });
11590
11599
  applyLogicalGroupSelectionVisualState(selection, groupId);
11591
11600
  fc.setActiveObject(selection);
@@ -12822,7 +12831,7 @@ const PageCanvas = forwardRef(
12822
12831
  };
12823
12832
  fabricCanvas.on("selection:created", () => {
12824
12833
  var _a2;
12825
- if (suppressObjectModifiedDuringInternalReselectRef.current) return;
12834
+ if (suppressObjectModifiedDuringInternalReselectRef.current || performance.now() < suppressSelectionEventsUntilRef.current) return;
12826
12835
  syncSelectionToStore();
12827
12836
  const activeObj = fabricCanvas.getActiveObject();
12828
12837
  if (activeObj instanceof fabric.ActiveSelection) applyWarpAwareSelectionBorders(activeObj);
@@ -12835,7 +12844,7 @@ const PageCanvas = forwardRef(
12835
12844
  });
12836
12845
  fabricCanvas.on("selection:updated", () => {
12837
12846
  var _a2;
12838
- if (suppressObjectModifiedDuringInternalReselectRef.current) return;
12847
+ if (suppressObjectModifiedDuringInternalReselectRef.current || performance.now() < suppressSelectionEventsUntilRef.current) return;
12839
12848
  const next = fabricCanvas.getActiveObject();
12840
12849
  const isLogicalGroupSel = next instanceof fabric.ActiveSelection && (next.__pixldocsGroupSelection || Array.isArray(next.__pixldocsLogicalGroupIds));
12841
12850
  if (!isLogicalGroupSel) restoreSuppressedGroupBorders();
@@ -13197,6 +13206,14 @@ const PageCanvas = forwardRef(
13197
13206
  requestAnimationFrame(() => {
13198
13207
  setTimeout(() => {
13199
13208
  if (!isActiveRef.current) return;
13209
+ const active = fabricCanvas.getActiveObject();
13210
+ if (active instanceof fabric.ActiveSelection) {
13211
+ const activeIds = active.getObjects().map((obj) => getObjectId(obj)).filter((id) => !!id && id !== "__background__");
13212
+ const sameMembers = activeIds.length === snapshot.memberIds.length && snapshot.memberIds.every((id) => activeIds.includes(id));
13213
+ const sameGroup = active.__pixldocsGroupSelection === snapshot.groupSelectionId;
13214
+ const alreadyAligned = active.__pixldocsAlignedAngle != null;
13215
+ if (sameMembers && sameGroup && alreadyAligned) return;
13216
+ }
13200
13217
  restoreGroupSelectionSnapshot(snapshot);
13201
13218
  }, 0);
13202
13219
  });
@@ -14227,12 +14244,16 @@ const PageCanvas = forwardRef(
14227
14244
  obj.dirty = true;
14228
14245
  }
14229
14246
  }
14230
- snapDuringScaleCallback(obj, corner);
14231
- const scaleGuides = calculateScaleSnapGuidesCallback(obj, corner);
14247
+ const normalizedScaleAngle = ((obj.angle ?? 0) % 360 + 360) % 360;
14248
+ const isRotatedActiveSelectionCorner = obj instanceof fabric.ActiveSelection && isCornerResizeHandle(corner) && Math.min(normalizedScaleAngle, 360 - normalizedScaleAngle) > 0.5;
14249
+ if (!isRotatedActiveSelectionCorner) {
14250
+ snapDuringScaleCallback(obj, corner);
14251
+ }
14252
+ const scaleGuides = isRotatedActiveSelectionCorner ? [] : calculateScaleSnapGuidesCallback(obj, corner);
14232
14253
  const gridGuidesForScale = [];
14233
14254
  try {
14234
14255
  const psGrid = projectSettingsRef.current;
14235
- const canApplyGridSnap = psGrid.snapToGrid && corner && !obj.__cropGroup && !obj.__resizeSnapHandler;
14256
+ const canApplyGridSnap = psGrid.snapToGrid && corner && !isRotatedActiveSelectionCorner && !obj.__cropGroup && !obj.__resizeSnapHandler;
14236
14257
  if (canApplyGridSnap) {
14237
14258
  const gridX = psGrid.gridSizeX ?? psGrid.gridSize ?? 0;
14238
14259
  const gridY = psGrid.gridSizeY ?? psGrid.gridSize ?? 0;
@@ -15501,6 +15522,7 @@ const PageCanvas = forwardRef(
15501
15522
  const prevRenderOnAddRemove = fabricCanvas.renderOnAddRemove;
15502
15523
  fabricCanvas.renderOnAddRemove = false;
15503
15524
  suppressObjectModifiedDuringInternalReselectRef.current = true;
15525
+ suppressSelectionEventsUntilRef.current = performance.now() + 80;
15504
15526
  skipSelectionClearOnDiscardRef.current = true;
15505
15527
  skipActiveSelectionBakeOnClearRef.current = true;
15506
15528
  try {
@@ -15572,6 +15594,7 @@ const PageCanvas = forwardRef(
15572
15594
  unlockEditsSoon();
15573
15595
  } catch (e2) {
15574
15596
  suppressObjectModifiedDuringInternalReselectRef.current = false;
15597
+ suppressSelectionEventsUntilRef.current = 0;
15575
15598
  skipSelectionClearOnDiscardRef.current = false;
15576
15599
  skipActiveSelectionBakeOnClearRef.current = false;
15577
15600
  unlockEditsSoon();
@@ -24609,9 +24632,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24609
24632
  }
24610
24633
  return svgString;
24611
24634
  }
24612
- const resolvedPackageVersion = "0.5.367";
24635
+ const resolvedPackageVersion = "0.5.369";
24613
24636
  const PACKAGE_VERSION = resolvedPackageVersion;
24614
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.367";
24637
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.369";
24615
24638
  const roundParityValue = (value) => {
24616
24639
  if (typeof value !== "number") return value;
24617
24640
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25425,7 +25448,7 @@ class PixldocsRenderer {
25425
25448
  await this.waitForCanvasScene(container, cloned, i);
25426
25449
  }
25427
25450
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25428
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DvcAOjPg.js");
25451
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DMnr_S0D.js");
25429
25452
  const prepared = preparePagesForExport(
25430
25453
  cloned.pages,
25431
25454
  canvasWidth,
@@ -27745,7 +27768,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27745
27768
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27746
27769
  sanitizeSvgTreeForPdf(svgToDraw);
27747
27770
  try {
27748
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DvcAOjPg.js");
27771
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DMnr_S0D.js");
27749
27772
  try {
27750
27773
  await logTextMeasurementDiagnostic(svgToDraw);
27751
27774
  } catch {
@@ -28145,4 +28168,4 @@ export {
28145
28168
  buildTeaserBlurFlatKeys as y,
28146
28169
  collectFontDescriptorsFromConfig as z
28147
28170
  };
28148
- //# sourceMappingURL=index-BeQl1M5I.js.map
28171
+ //# sourceMappingURL=index-CBpMMrvY.js.map