@pixldocs/canvas-renderer 0.5.386 → 0.5.388

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.
@@ -13530,6 +13530,55 @@ const PageCanvas = react.forwardRef(
13530
13530
  if (!found) return null;
13531
13531
  return { left: minX, top: minY, right: maxX, bottom: maxY };
13532
13532
  };
13533
+ const groupFabricOrientedBBox = (g) => {
13534
+ var _a2;
13535
+ const memberIds = new Set(getAllElementIds(g.children ?? []));
13536
+ if (memberIds.size === 0) return null;
13537
+ const members = [];
13538
+ for (const o of fabricCanvas.getObjects()) {
13539
+ const oid = getObjectId(o);
13540
+ if (oid && memberIds.has(oid)) members.push(o);
13541
+ }
13542
+ if (members.length === 0) return null;
13543
+ const a0 = ((members[0].angle ?? 0) % 360 + 360) % 360;
13544
+ const TOL = 0.5;
13545
+ for (const m of members) {
13546
+ const a = ((m.angle ?? 0) % 360 + 360) % 360;
13547
+ const diff = Math.min(Math.abs(a - a0), 360 - Math.abs(a - a0));
13548
+ if (diff > TOL) return null;
13549
+ }
13550
+ const rad = -a0 * Math.PI / 180;
13551
+ const cos = Math.cos(rad), sin = Math.sin(rad);
13552
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
13553
+ let found = false;
13554
+ for (const m of members) {
13555
+ (_a2 = m.setCoords) == null ? void 0 : _a2.call(m);
13556
+ const aC = m.aCoords;
13557
+ if (!aC) continue;
13558
+ for (const k of ["tl", "tr", "br", "bl"]) {
13559
+ const p = aC[k];
13560
+ if (!p) continue;
13561
+ const xr = p.x * cos - p.y * sin;
13562
+ const yr = p.x * sin + p.y * cos;
13563
+ if (xr < minX) minX = xr;
13564
+ if (yr < minY) minY = yr;
13565
+ if (xr > maxX) maxX = xr;
13566
+ if (yr > maxY) maxY = yr;
13567
+ found = true;
13568
+ }
13569
+ }
13570
+ if (!found) return null;
13571
+ const radBack = a0 * Math.PI / 180;
13572
+ const cb = Math.cos(radBack), sb = Math.sin(radBack);
13573
+ const toCanvas = (x, y) => ({ x: x * cb - y * sb, y: x * sb + y * cb });
13574
+ const corners = [
13575
+ toCanvas(minX, minY),
13576
+ toCanvas(maxX, minY),
13577
+ toCanvas(maxX, maxY),
13578
+ toCanvas(minX, maxY)
13579
+ ];
13580
+ return { corners, angle: a0 };
13581
+ };
13533
13582
  const pickGroupAtPointer = (px, py, children, activeEditingGroupId) => {
13534
13583
  let pick = null;
13535
13584
  for (const node of children) {
@@ -13776,6 +13825,21 @@ const PageCanvas = react.forwardRef(
13776
13825
  const activeEditingGroupId = fabricCanvas.__activeEditingGroupId ?? null;
13777
13826
  const groupPick = pickGroupAtPointer(pointer.x, pointer.y, childrenNow, activeEditingGroupId);
13778
13827
  if (groupPick && !activeIds.has(groupPick.group.id)) {
13828
+ const oriented = groupFabricOrientedBBox(groupPick.group);
13829
+ if (oriented) {
13830
+ const pts = oriented.corners.map((p) => `${p.x},${p.y}`).join(" ");
13831
+ const xs = oriented.corners.map((p) => p.x);
13832
+ const ys = oriented.corners.map((p) => p.y);
13833
+ setHoverBounds({
13834
+ left: Math.min(...xs),
13835
+ top: Math.min(...ys),
13836
+ width: Math.max(...xs) - Math.min(...xs),
13837
+ height: Math.max(...ys) - Math.min(...ys),
13838
+ angle: oriented.angle,
13839
+ points: pts
13840
+ });
13841
+ return;
13842
+ }
13779
13843
  const b = groupFabricUnionBBox(groupPick.group);
13780
13844
  if (b) {
13781
13845
  setHoverBounds({
@@ -13791,14 +13855,31 @@ const PageCanvas = react.forwardRef(
13791
13855
  const isHoveringSelected = !!(tid && activeIds.has(tid));
13792
13856
  if (t && tid && tid !== "__background__" && !isHoveringSelected) {
13793
13857
  t.setCoords();
13794
- const br = t.getBoundingRect();
13795
- setHoverBounds({
13796
- left: br.left,
13797
- top: br.top,
13798
- width: br.width,
13799
- height: br.height,
13800
- angle: 0
13801
- });
13858
+ const ang = ((t.angle ?? 0) % 360 + 360) % 360;
13859
+ const aC = t.aCoords;
13860
+ if (ang > 0.5 && (aC == null ? void 0 : aC.tl) && (aC == null ? void 0 : aC.tr) && (aC == null ? void 0 : aC.br) && (aC == null ? void 0 : aC.bl)) {
13861
+ const corners = [aC.tl, aC.tr, aC.br, aC.bl];
13862
+ const pts = corners.map((p) => `${p.x},${p.y}`).join(" ");
13863
+ const xs = corners.map((p) => p.x);
13864
+ const ys = corners.map((p) => p.y);
13865
+ setHoverBounds({
13866
+ left: Math.min(...xs),
13867
+ top: Math.min(...ys),
13868
+ width: Math.max(...xs) - Math.min(...xs),
13869
+ height: Math.max(...ys) - Math.min(...ys),
13870
+ angle: ang,
13871
+ points: pts
13872
+ });
13873
+ } else {
13874
+ const br = t.getBoundingRect();
13875
+ setHoverBounds({
13876
+ left: br.left,
13877
+ top: br.top,
13878
+ width: br.width,
13879
+ height: br.height,
13880
+ angle: 0
13881
+ });
13882
+ }
13802
13883
  } else {
13803
13884
  setHoverBounds(null);
13804
13885
  }
@@ -14317,7 +14398,10 @@ const PageCanvas = react.forwardRef(
14317
14398
  continue;
14318
14399
  }
14319
14400
  if (!(child instanceof fabric__namespace.Textbox)) continue;
14320
- const childAngleDeg = child.angle ?? 0;
14401
+ if (child.__asLiveOrigAngle == null) {
14402
+ child.__asLiveOrigAngle = child.angle ?? 0;
14403
+ }
14404
+ const childAngleDeg = child.__asLiveOrigAngle;
14321
14405
  const asSx = isXSide ? sAxis : 1;
14322
14406
  const asSy = isXSide ? 1 : sAxis;
14323
14407
  const theta = fabric__namespace.util.degreesToRadians(childAngleDeg);
@@ -14749,6 +14833,7 @@ const PageCanvas = react.forwardRef(
14749
14833
  delete child.__asLiveOrigW;
14750
14834
  delete child.__asLiveOrigH;
14751
14835
  delete child.__asLiveRotSnap;
14836
+ delete child.__asLiveOrigAngle;
14752
14837
  }
14753
14838
  }
14754
14839
  } catch {
@@ -18746,7 +18831,18 @@ const PageCanvas = react.forwardRef(
18746
18831
  className: "absolute inset-0 pointer-events-none",
18747
18832
  style: { width: scaledWidth, height: scaledHeight },
18748
18833
  viewBox: `0 0 ${canvasWidth} ${canvasHeight}`,
18749
- children: /* @__PURE__ */ jsxRuntime.jsx(
18834
+ children: hoverBounds.points ? /* @__PURE__ */ jsxRuntime.jsx(
18835
+ "polygon",
18836
+ {
18837
+ points: hoverBounds.points,
18838
+ fill: "none",
18839
+ stroke: SELECTION_PRIMARY,
18840
+ strokeWidth: 2,
18841
+ vectorEffect: "non-scaling-stroke",
18842
+ strokeDasharray: "0",
18843
+ opacity: 1
18844
+ }
18845
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
18750
18846
  "rect",
18751
18847
  {
18752
18848
  x: hoverBounds.left,
@@ -24896,9 +24992,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24896
24992
  }
24897
24993
  return svgString;
24898
24994
  }
24899
- const resolvedPackageVersion = "0.5.386";
24995
+ const resolvedPackageVersion = "0.5.388";
24900
24996
  const PACKAGE_VERSION = resolvedPackageVersion;
24901
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.386";
24997
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.388";
24902
24998
  const roundParityValue = (value) => {
24903
24999
  if (typeof value !== "number") return value;
24904
25000
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25712,7 +25808,7 @@ class PixldocsRenderer {
25712
25808
  await this.waitForCanvasScene(container, cloned, i);
25713
25809
  }
25714
25810
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25715
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-Ch4wgY_V.cjs"));
25811
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BMKSimKF.cjs"));
25716
25812
  const prepared = preparePagesForExport(
25717
25813
  cloned.pages,
25718
25814
  canvasWidth,
@@ -28032,7 +28128,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28032
28128
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28033
28129
  sanitizeSvgTreeForPdf(svgToDraw);
28034
28130
  try {
28035
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Ch4wgY_V.cjs"));
28131
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BMKSimKF.cjs"));
28036
28132
  try {
28037
28133
  await logTextMeasurementDiagnostic(svgToDraw);
28038
28134
  } catch {
@@ -28429,4 +28525,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28429
28525
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28430
28526
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28431
28527
  exports.warmTemplateFromForm = warmTemplateFromForm;
28432
- //# sourceMappingURL=index-DPK4VKN5.cjs.map
28528
+ //# sourceMappingURL=index-CnSzRkFP.cjs.map