@pixldocs/canvas-renderer 0.5.430 → 0.5.432

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.
@@ -13987,10 +13987,32 @@ const PageCanvas = react.forwardRef(
13987
13987
  if (!isGroup(node)) continue;
13988
13988
  if (node.backgroundColor) continue;
13989
13989
  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));
13990
+ const oriented = groupFabricOrientedBBox(node);
13991
+ let inside = false;
13992
+ let area = 0;
13993
+ if (oriented && Math.abs(oriented.angle) > 0.01) {
13994
+ const rad = -oriented.angle * Math.PI / 180;
13995
+ const cos = Math.cos(rad), sin = Math.sin(rad);
13996
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
13997
+ for (const p of oriented.corners) {
13998
+ const xr2 = p.x * cos - p.y * sin;
13999
+ const yr2 = p.x * sin + p.y * cos;
14000
+ if (xr2 < minX) minX = xr2;
14001
+ if (yr2 < minY) minY = yr2;
14002
+ if (xr2 > maxX) maxX = xr2;
14003
+ if (yr2 > maxY) maxY = yr2;
14004
+ }
14005
+ const xr = px * cos - py * sin;
14006
+ const yr = px * sin + py * cos;
14007
+ inside = xr >= minX && xr <= maxX && yr >= minY && yr <= maxY;
14008
+ area = Math.max(1, (maxX - minX) * (maxY - minY));
14009
+ } else {
14010
+ const b = groupFabricUnionBBox(node);
14011
+ if (!b) continue;
14012
+ inside = !(px < b.left || py < b.top || px > b.right || py > b.bottom);
14013
+ area = Math.max(1, (b.right - b.left) * (b.bottom - b.top));
14014
+ }
14015
+ if (!inside) continue;
13994
14016
  if (!pick || area < pick.area) pick = { group: node, area };
13995
14017
  }
13996
14018
  return pick;
@@ -16720,10 +16742,17 @@ const PageCanvas = react.forwardRef(
16720
16742
  const parentForCrop = targetId ? findParentGroup(pageChildrenForCrop, targetId) : null;
16721
16743
  const isInsideGroup = !!parentForCrop;
16722
16744
  if (isInsideGroup) {
16723
- sonner.toast.info("Ungroup to crop this image", {
16724
- description: "Crop mode is disabled for images inside a group. Select the group and ungroup first."
16725
- });
16726
- return;
16745
+ const active = fabricCanvas.getActiveObject();
16746
+ const isIndividuallySelected = active === target;
16747
+ if (!isIndividuallySelected) {
16748
+ try {
16749
+ fabricCanvas.discardActiveObject();
16750
+ fabricCanvas.setActiveObject(target);
16751
+ fabricCanvas.requestRenderAll();
16752
+ } catch {
16753
+ }
16754
+ return;
16755
+ }
16727
16756
  }
16728
16757
  if (innerImg && !isPlaceholder && !isCropGroupInCropMode(target)) {
16729
16758
  enterCropMode(target);
@@ -25751,9 +25780,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25751
25780
  }
25752
25781
  return svgString;
25753
25782
  }
25754
- const resolvedPackageVersion = "0.5.430";
25783
+ const resolvedPackageVersion = "0.5.432";
25755
25784
  const PACKAGE_VERSION = resolvedPackageVersion;
25756
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.430";
25785
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.432";
25757
25786
  const roundParityValue = (value) => {
25758
25787
  if (typeof value !== "number") return value;
25759
25788
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26567,7 +26596,7 @@ class PixldocsRenderer {
26567
26596
  await this.waitForCanvasScene(container, cloned, i);
26568
26597
  }
26569
26598
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26570
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CTWkNuBw.cjs"));
26599
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DgXV6S2u.cjs"));
26571
26600
  const prepared = preparePagesForExport(
26572
26601
  cloned.pages,
26573
26602
  canvasWidth,
@@ -28887,7 +28916,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28887
28916
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28888
28917
  sanitizeSvgTreeForPdf(svgToDraw);
28889
28918
  try {
28890
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CTWkNuBw.cjs"));
28919
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DgXV6S2u.cjs"));
28891
28920
  try {
28892
28921
  await logTextMeasurementDiagnostic(svgToDraw);
28893
28922
  } catch {
@@ -29284,4 +29313,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29284
29313
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29285
29314
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29286
29315
  exports.warmTemplateFromForm = warmTemplateFromForm;
29287
- //# sourceMappingURL=index-lW4vxeRT.cjs.map
29316
+ //# sourceMappingURL=index-CK9heNqN.cjs.map