@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.
@@ -11976,6 +11976,7 @@ const PageCanvas = react.forwardRef(
11976
11976
  const preserveEditingScopeOnSelectionClearRef = react.useRef(false);
11977
11977
  const preserveActiveSelectionAfterTransformRef = react.useRef(null);
11978
11978
  const recentGroupSelectionRestoreRef = react.useRef(null);
11979
+ const intentionalGroupDeselectRef = react.useRef(null);
11979
11980
  const pendingGroupPromotionRef = react.useRef(null);
11980
11981
  const pendingGroupDrillInRef = react.useRef(null);
11981
11982
  const imageReloadRequestSeqRef = react.useRef(/* @__PURE__ */ new Map());
@@ -13507,6 +13508,14 @@ const PageCanvas = react.forwardRef(
13507
13508
  setDrilledGroupBounds(null);
13508
13509
  drilledGroupIdRef.current = null;
13509
13510
  }
13511
+ const explicitGroupDeselect = intentionalGroupDeselectRef.current;
13512
+ if (explicitGroupDeselect) {
13513
+ preserveActiveSelectionAfterTransformRef.current = null;
13514
+ recentGroupSelectionRestoreRef.current = null;
13515
+ preserveSelectionAfterTransformIdRef.current = null;
13516
+ editLockRef.current = false;
13517
+ syncLockedRef.current = false;
13518
+ }
13510
13519
  const preservedGroupSelection = preserveActiveSelectionAfterTransformRef.current;
13511
13520
  const shouldRestoreGroupSelection = !!((preservedGroupSelection == null ? void 0 : preservedGroupSelection.groupSelectionId) && (!preservedGroupSelection.expiresAt || preservedGroupSelection.expiresAt > Date.now()));
13512
13521
  if (skipSelectionClearOnDiscardRef.current) {
@@ -13515,11 +13524,12 @@ const PageCanvas = react.forwardRef(
13515
13524
  }
13516
13525
  const recentGroupSelectionRestore = recentGroupSelectionRestoreRef.current;
13517
13526
  const shouldReassertRecentGroupSelection = !!((recentGroupSelectionRestore == null ? void 0 : recentGroupSelectionRestore.groupSelectionId) && recentGroupSelectionRestore.expiresAt > Date.now());
13518
- if (editLockRef.current || syncLockedRef.current || didTransformRef.current || preserveSelectionAfterTransformIdRef.current || shouldRestoreGroupSelection || shouldReassertRecentGroupSelection) {
13527
+ if (!explicitGroupDeselect && (editLockRef.current || syncLockedRef.current || didTransformRef.current || preserveSelectionAfterTransformIdRef.current || shouldRestoreGroupSelection || shouldReassertRecentGroupSelection)) {
13519
13528
  if (shouldRestoreGroupSelection) restorePreservedGroupSelectionSoon(preservedGroupSelection);
13520
13529
  else if (shouldReassertRecentGroupSelection) restorePreservedGroupSelectionSoon(recentGroupSelectionRestore);
13521
13530
  return;
13522
13531
  }
13532
+ intentionalGroupDeselectRef.current = null;
13523
13533
  restoreSuppressedGroupBorders();
13524
13534
  editLockRef.current = false;
13525
13535
  syncLockedRef.current = false;
@@ -13987,10 +13997,32 @@ const PageCanvas = react.forwardRef(
13987
13997
  if (!isGroup(node)) continue;
13988
13998
  if (node.backgroundColor) continue;
13989
13999
  if (activeEditingGroupId && node.id === activeEditingGroupId) continue;
13990
- const b = groupFabricUnionBBox(node);
13991
- if (!b) continue;
13992
- if (px < b.left || py < b.top || px > b.right || py > b.bottom) continue;
13993
- const area = Math.max(1, (b.right - b.left) * (b.bottom - b.top));
14000
+ const oriented = groupFabricOrientedBBox(node);
14001
+ let inside = false;
14002
+ let area = 0;
14003
+ if (oriented && Math.abs(oriented.angle) > 0.01) {
14004
+ const rad = -oriented.angle * Math.PI / 180;
14005
+ const cos = Math.cos(rad), sin = Math.sin(rad);
14006
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
14007
+ for (const p of oriented.corners) {
14008
+ const xr2 = p.x * cos - p.y * sin;
14009
+ const yr2 = p.x * sin + p.y * cos;
14010
+ if (xr2 < minX) minX = xr2;
14011
+ if (yr2 < minY) minY = yr2;
14012
+ if (xr2 > maxX) maxX = xr2;
14013
+ if (yr2 > maxY) maxY = yr2;
14014
+ }
14015
+ const xr = px * cos - py * sin;
14016
+ const yr = px * sin + py * cos;
14017
+ inside = xr >= minX && xr <= maxX && yr >= minY && yr <= maxY;
14018
+ area = Math.max(1, (maxX - minX) * (maxY - minY));
14019
+ } else {
14020
+ const b = groupFabricUnionBBox(node);
14021
+ if (!b) continue;
14022
+ inside = !(px < b.left || py < b.top || px > b.right || py > b.bottom);
14023
+ area = Math.max(1, (b.right - b.left) * (b.bottom - b.top));
14024
+ }
14025
+ if (!inside) continue;
13994
14026
  if (!pick || area < pick.area) pick = { group: node, area };
13995
14027
  }
13996
14028
  return pick;
@@ -14144,7 +14176,7 @@ const PageCanvas = react.forwardRef(
14144
14176
  suppressTextEditForClick(effectiveTarget);
14145
14177
  }
14146
14178
  }
14147
- } else if (!target || targetId === "__background__") {
14179
+ } else if (!target || !targetId || targetId === "__background__") {
14148
14180
  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));
14149
14181
  if (isMultiSelectKey) return;
14150
14182
  if ((_m = opt.e) == null ? void 0 : _m.altKey) return;
@@ -14153,6 +14185,26 @@ const PageCanvas = react.forwardRef(
14153
14185
  const px = pointer.x;
14154
14186
  const py = pointer.y;
14155
14187
  const pick = pickGroupAtPointer(px, py, childrenNow, activeEditingGroupId);
14188
+ if (!pick) {
14189
+ const activeNow = fabricCanvas.getActiveObject();
14190
+ const groupSelectionId = activeNow instanceof fabric__namespace.ActiveSelection ? activeNow.__pixldocsGroupSelection : activeNow == null ? void 0 : activeNow.__pixldocsGroupSelection;
14191
+ if (groupSelectionId) {
14192
+ intentionalGroupDeselectRef.current = groupSelectionId;
14193
+ preserveActiveSelectionAfterTransformRef.current = null;
14194
+ recentGroupSelectionRestoreRef.current = null;
14195
+ preserveSelectionAfterTransformIdRef.current = null;
14196
+ pendingGroupPromotionRef.current = null;
14197
+ pendingGroupDrillInRef.current = null;
14198
+ editLockRef.current = false;
14199
+ syncLockedRef.current = false;
14200
+ fabricCanvas._target = void 0;
14201
+ fabricCanvas._currentTransform = null;
14202
+ opt.target = void 0;
14203
+ fabricCanvas.discardActiveObject();
14204
+ fabricCanvas.requestRenderAll();
14205
+ }
14206
+ return;
14207
+ }
14156
14208
  if (pick) {
14157
14209
  const parent = pick.group;
14158
14210
  if (activeEditingGroupId !== parent.id) {
@@ -25758,9 +25810,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25758
25810
  }
25759
25811
  return svgString;
25760
25812
  }
25761
- const resolvedPackageVersion = "0.5.431";
25813
+ const resolvedPackageVersion = "0.5.433";
25762
25814
  const PACKAGE_VERSION = resolvedPackageVersion;
25763
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.431";
25815
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.433";
25764
25816
  const roundParityValue = (value) => {
25765
25817
  if (typeof value !== "number") return value;
25766
25818
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26574,7 +26626,7 @@ class PixldocsRenderer {
26574
26626
  await this.waitForCanvasScene(container, cloned, i);
26575
26627
  }
26576
26628
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26577
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-zM3-7B0b.cjs"));
26629
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BXdCe5ek.cjs"));
26578
26630
  const prepared = preparePagesForExport(
26579
26631
  cloned.pages,
26580
26632
  canvasWidth,
@@ -28894,7 +28946,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28894
28946
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28895
28947
  sanitizeSvgTreeForPdf(svgToDraw);
28896
28948
  try {
28897
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-zM3-7B0b.cjs"));
28949
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BXdCe5ek.cjs"));
28898
28950
  try {
28899
28951
  await logTextMeasurementDiagnostic(svgToDraw);
28900
28952
  } catch {
@@ -29291,4 +29343,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29291
29343
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29292
29344
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29293
29345
  exports.warmTemplateFromForm = warmTemplateFromForm;
29294
- //# sourceMappingURL=index-Ce2dA8D0.cjs.map
29346
+ //# sourceMappingURL=index-Dl-ilqW_.cjs.map