@pixldocs/canvas-renderer 0.5.431 → 0.5.433

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.
@@ -11958,6 +11958,7 @@ const PageCanvas = forwardRef(
11958
11958
  const preserveEditingScopeOnSelectionClearRef = useRef(false);
11959
11959
  const preserveActiveSelectionAfterTransformRef = useRef(null);
11960
11960
  const recentGroupSelectionRestoreRef = useRef(null);
11961
+ const intentionalGroupDeselectRef = useRef(null);
11961
11962
  const pendingGroupPromotionRef = useRef(null);
11962
11963
  const pendingGroupDrillInRef = useRef(null);
11963
11964
  const imageReloadRequestSeqRef = useRef(/* @__PURE__ */ new Map());
@@ -13489,6 +13490,14 @@ const PageCanvas = forwardRef(
13489
13490
  setDrilledGroupBounds(null);
13490
13491
  drilledGroupIdRef.current = null;
13491
13492
  }
13493
+ const explicitGroupDeselect = intentionalGroupDeselectRef.current;
13494
+ if (explicitGroupDeselect) {
13495
+ preserveActiveSelectionAfterTransformRef.current = null;
13496
+ recentGroupSelectionRestoreRef.current = null;
13497
+ preserveSelectionAfterTransformIdRef.current = null;
13498
+ editLockRef.current = false;
13499
+ syncLockedRef.current = false;
13500
+ }
13492
13501
  const preservedGroupSelection = preserveActiveSelectionAfterTransformRef.current;
13493
13502
  const shouldRestoreGroupSelection = !!((preservedGroupSelection == null ? void 0 : preservedGroupSelection.groupSelectionId) && (!preservedGroupSelection.expiresAt || preservedGroupSelection.expiresAt > Date.now()));
13494
13503
  if (skipSelectionClearOnDiscardRef.current) {
@@ -13497,11 +13506,12 @@ const PageCanvas = forwardRef(
13497
13506
  }
13498
13507
  const recentGroupSelectionRestore = recentGroupSelectionRestoreRef.current;
13499
13508
  const shouldReassertRecentGroupSelection = !!((recentGroupSelectionRestore == null ? void 0 : recentGroupSelectionRestore.groupSelectionId) && recentGroupSelectionRestore.expiresAt > Date.now());
13500
- if (editLockRef.current || syncLockedRef.current || didTransformRef.current || preserveSelectionAfterTransformIdRef.current || shouldRestoreGroupSelection || shouldReassertRecentGroupSelection) {
13509
+ if (!explicitGroupDeselect && (editLockRef.current || syncLockedRef.current || didTransformRef.current || preserveSelectionAfterTransformIdRef.current || shouldRestoreGroupSelection || shouldReassertRecentGroupSelection)) {
13501
13510
  if (shouldRestoreGroupSelection) restorePreservedGroupSelectionSoon(preservedGroupSelection);
13502
13511
  else if (shouldReassertRecentGroupSelection) restorePreservedGroupSelectionSoon(recentGroupSelectionRestore);
13503
13512
  return;
13504
13513
  }
13514
+ intentionalGroupDeselectRef.current = null;
13505
13515
  restoreSuppressedGroupBorders();
13506
13516
  editLockRef.current = false;
13507
13517
  syncLockedRef.current = false;
@@ -13969,10 +13979,32 @@ const PageCanvas = forwardRef(
13969
13979
  if (!isGroup(node)) continue;
13970
13980
  if (node.backgroundColor) continue;
13971
13981
  if (activeEditingGroupId && node.id === activeEditingGroupId) continue;
13972
- const b = groupFabricUnionBBox(node);
13973
- if (!b) continue;
13974
- if (px < b.left || py < b.top || px > b.right || py > b.bottom) continue;
13975
- const area = Math.max(1, (b.right - b.left) * (b.bottom - b.top));
13982
+ const oriented = groupFabricOrientedBBox(node);
13983
+ let inside = false;
13984
+ let area = 0;
13985
+ if (oriented && Math.abs(oriented.angle) > 0.01) {
13986
+ const rad = -oriented.angle * Math.PI / 180;
13987
+ const cos = Math.cos(rad), sin = Math.sin(rad);
13988
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
13989
+ for (const p of oriented.corners) {
13990
+ const xr2 = p.x * cos - p.y * sin;
13991
+ const yr2 = p.x * sin + p.y * cos;
13992
+ if (xr2 < minX) minX = xr2;
13993
+ if (yr2 < minY) minY = yr2;
13994
+ if (xr2 > maxX) maxX = xr2;
13995
+ if (yr2 > maxY) maxY = yr2;
13996
+ }
13997
+ const xr = px * cos - py * sin;
13998
+ const yr = px * sin + py * cos;
13999
+ inside = xr >= minX && xr <= maxX && yr >= minY && yr <= maxY;
14000
+ area = Math.max(1, (maxX - minX) * (maxY - minY));
14001
+ } else {
14002
+ const b = groupFabricUnionBBox(node);
14003
+ if (!b) continue;
14004
+ inside = !(px < b.left || py < b.top || px > b.right || py > b.bottom);
14005
+ area = Math.max(1, (b.right - b.left) * (b.bottom - b.top));
14006
+ }
14007
+ if (!inside) continue;
13976
14008
  if (!pick || area < pick.area) pick = { group: node, area };
13977
14009
  }
13978
14010
  return pick;
@@ -14126,7 +14158,7 @@ const PageCanvas = forwardRef(
14126
14158
  suppressTextEditForClick(effectiveTarget);
14127
14159
  }
14128
14160
  }
14129
- } else if (!target || targetId === "__background__") {
14161
+ } else if (!target || !targetId || targetId === "__background__") {
14130
14162
  const isMultiSelectKey = !!(((_j = opt.e) == null ? void 0 : _j.shiftKey) || ((_k = opt.e) == null ? void 0 : _k.metaKey) || ((_l = opt.e) == null ? void 0 : _l.ctrlKey));
14131
14163
  if (isMultiSelectKey) return;
14132
14164
  if ((_m = opt.e) == null ? void 0 : _m.altKey) return;
@@ -14135,6 +14167,26 @@ const PageCanvas = forwardRef(
14135
14167
  const px = pointer.x;
14136
14168
  const py = pointer.y;
14137
14169
  const pick = pickGroupAtPointer(px, py, childrenNow, activeEditingGroupId);
14170
+ if (!pick) {
14171
+ const activeNow = fabricCanvas.getActiveObject();
14172
+ const groupSelectionId = activeNow instanceof fabric.ActiveSelection ? activeNow.__pixldocsGroupSelection : activeNow == null ? void 0 : activeNow.__pixldocsGroupSelection;
14173
+ if (groupSelectionId) {
14174
+ intentionalGroupDeselectRef.current = groupSelectionId;
14175
+ preserveActiveSelectionAfterTransformRef.current = null;
14176
+ recentGroupSelectionRestoreRef.current = null;
14177
+ preserveSelectionAfterTransformIdRef.current = null;
14178
+ pendingGroupPromotionRef.current = null;
14179
+ pendingGroupDrillInRef.current = null;
14180
+ editLockRef.current = false;
14181
+ syncLockedRef.current = false;
14182
+ fabricCanvas._target = void 0;
14183
+ fabricCanvas._currentTransform = null;
14184
+ opt.target = void 0;
14185
+ fabricCanvas.discardActiveObject();
14186
+ fabricCanvas.requestRenderAll();
14187
+ }
14188
+ return;
14189
+ }
14138
14190
  if (pick) {
14139
14191
  const parent = pick.group;
14140
14192
  if (activeEditingGroupId !== parent.id) {
@@ -25740,9 +25792,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25740
25792
  }
25741
25793
  return svgString;
25742
25794
  }
25743
- const resolvedPackageVersion = "0.5.431";
25795
+ const resolvedPackageVersion = "0.5.433";
25744
25796
  const PACKAGE_VERSION = resolvedPackageVersion;
25745
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.431";
25797
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.433";
25746
25798
  const roundParityValue = (value) => {
25747
25799
  if (typeof value !== "number") return value;
25748
25800
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26556,7 +26608,7 @@ class PixldocsRenderer {
26556
26608
  await this.waitForCanvasScene(container, cloned, i);
26557
26609
  }
26558
26610
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26559
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BbcJdy23.js");
26611
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-6d2YhE8F.js");
26560
26612
  const prepared = preparePagesForExport(
26561
26613
  cloned.pages,
26562
26614
  canvasWidth,
@@ -28876,7 +28928,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28876
28928
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28877
28929
  sanitizeSvgTreeForPdf(svgToDraw);
28878
28930
  try {
28879
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BbcJdy23.js");
28931
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-6d2YhE8F.js");
28880
28932
  try {
28881
28933
  await logTextMeasurementDiagnostic(svgToDraw);
28882
28934
  } catch {
@@ -29276,4 +29328,4 @@ export {
29276
29328
  buildTeaserBlurFlatKeys as y,
29277
29329
  collectFontDescriptorsFromConfig as z
29278
29330
  };
29279
- //# sourceMappingURL=index-BKeBl1Ev.js.map
29331
+ //# sourceMappingURL=index-XUxKXZ1L.js.map