@pixldocs/canvas-renderer 0.5.352 → 0.5.354

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.
@@ -13312,6 +13312,30 @@ const PageCanvas = react.forwardRef(
13312
13312
  });
13313
13313
  };
13314
13314
  fabricCanvas.__updateDrilledGroupOutline = updateDrilledGroupOutline;
13315
+ const isPointerOnSelectionControl = (selection, event) => {
13316
+ var _a2;
13317
+ try {
13318
+ selection.setCoords();
13319
+ const controls = selection.oCoords ?? ((_a2 = selection.calcOCoords) == null ? void 0 : _a2.call(selection));
13320
+ const el = fabricCanvas.upperCanvasEl ?? fabricCanvas.lowerCanvasEl;
13321
+ const rect = el == null ? void 0 : el.getBoundingClientRect();
13322
+ if (!controls || !rect || !event) return false;
13323
+ const x = Number(event.clientX) - rect.left;
13324
+ const y = Number(event.clientY) - rect.top;
13325
+ return Object.values(controls).some((control) => {
13326
+ const pts = (control == null ? void 0 : control.touchCorner) ?? (control == null ? void 0 : control.corner);
13327
+ const corners = pts ? Object.values(pts) : [];
13328
+ if (!corners.length) return false;
13329
+ const minX = Math.min(...corners.map((p) => p.x)) - 2;
13330
+ const maxX = Math.max(...corners.map((p) => p.x)) + 2;
13331
+ const minY = Math.min(...corners.map((p) => p.y)) - 2;
13332
+ const maxY = Math.max(...corners.map((p) => p.y)) + 2;
13333
+ return x >= minX && x <= maxX && y >= minY && y <= maxY;
13334
+ });
13335
+ } catch {
13336
+ return false;
13337
+ }
13338
+ };
13315
13339
  fabricCanvas.on("mouse:down:before", (opt) => {
13316
13340
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
13317
13341
  const activeBeforeMouseDown = fabricCanvas.getActiveObject();
@@ -13335,7 +13359,8 @@ const PageCanvas = react.forwardRef(
13335
13359
  }
13336
13360
  let target = opt.target;
13337
13361
  let targetId = target ? getObjectId(target) : null;
13338
- if (target instanceof fabric__namespace.ActiveSelection && target.__pixldocsGroupSelection && target === fabricCanvas.getActiveObject()) {
13362
+ const pointerOnActiveSelectionControl = activeBeforeMouseDown instanceof fabric__namespace.ActiveSelection ? isPointerOnSelectionControl(activeBeforeMouseDown, opt.e) : false;
13363
+ if (target instanceof fabric__namespace.ActiveSelection && target.__pixldocsGroupSelection && target === fabricCanvas.getActiveObject() && !target.__corner && !pointerOnActiveSelectionControl) {
13339
13364
  const child = pickChildInActiveSelectionAtPointer(target, opt.e);
13340
13365
  const childId = child ? getObjectId(child) : null;
13341
13366
  if (child && childId) {
@@ -13384,7 +13409,7 @@ const PageCanvas = react.forwardRef(
13384
13409
  let effectiveTargetId = targetId;
13385
13410
  const activeNowEarly = fabricCanvas.getActiveObject();
13386
13411
  const asGroupId = target instanceof fabric__namespace.ActiveSelection ? target.__pixldocsGroupSelection : void 0;
13387
- if (target instanceof fabric__namespace.ActiveSelection && asGroupId && target === activeNowEarly) {
13412
+ if (target instanceof fabric__namespace.ActiveSelection && asGroupId && target === activeNowEarly && !target.__corner && !pointerOnActiveSelectionControl) {
13388
13413
  const child = pickChildInActiveSelectionAtPointer(target, opt.e);
13389
13414
  const childId = child ? getObjectId(child) : null;
13390
13415
  if (child && childId) {
@@ -14187,6 +14212,10 @@ const PageCanvas = react.forwardRef(
14187
14212
  if (child.__asLiveOrigH == null) {
14188
14213
  child.__asLiveOrigH = (child.height ?? 0) * (child.scaleY ?? 1);
14189
14214
  }
14215
+ if (child.__asLiveOrigMinH == null) {
14216
+ const m = Number(child.minBoxHeight);
14217
+ if (Number.isFinite(m) && m > 0) child.__asLiveOrigMinH = m;
14218
+ }
14190
14219
  const origH = child.__asLiveOrigH;
14191
14220
  const newH = Math.max(20, origH * sAxis);
14192
14221
  child.minBoxHeight = newH;
@@ -14474,6 +14503,7 @@ const PageCanvas = react.forwardRef(
14474
14503
  });
14475
14504
  fabricCanvas.on("object:rotating", (e) => {
14476
14505
  var _a2, _b2;
14506
+ prepareGroupSelectionTransformStart(e.target);
14477
14507
  markSimpleTransform(e);
14478
14508
  didTransformRef.current = true;
14479
14509
  const tr = e.target;
@@ -14642,16 +14672,6 @@ const PageCanvas = react.forwardRef(
14642
14672
  unlockEditsSoon();
14643
14673
  return;
14644
14674
  }
14645
- try {
14646
- const t = e.target;
14647
- if (t instanceof fabric__namespace.ActiveSelection) {
14648
- for (const child of t.getObjects()) {
14649
- delete child.__asLiveOrigW;
14650
- delete child.__asLiveOrigH;
14651
- }
14652
- }
14653
- } catch {
14654
- }
14655
14675
  groupShiftReflowSnapshotRef.current = null;
14656
14676
  lockEdits();
14657
14677
  const modifiedTargetId = modifiedTarget ? getObjectId(modifiedTarget) : null;
@@ -15479,16 +15499,27 @@ const PageCanvas = react.forwardRef(
15479
15499
  finalSkewY = (sourceElement == null ? void 0 : sourceElement.skewY) ?? obj.skewY ?? 0;
15480
15500
  if ((sourceElement == null ? void 0 : sourceElement.angle) !== void 0 || obj.angle !== void 0) finalAngleFromDecomposed = false;
15481
15501
  }
15482
- } else if (obj instanceof fabric__namespace.Textbox && isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
15483
- const sx = Math.abs(decomposed.scaleX || 1);
15484
- const sy = Math.abs(decomposed.scaleY || 1);
15502
+ } else if (obj instanceof fabric__namespace.Textbox && isActiveSelection && (activeSelectionResizeHandle != null || obj.__asLiveOrigW != null || obj.__asLiveOrigH != null || Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
15503
+ const liveOrigW = obj.__asLiveOrigW;
15504
+ const liveOrigH = obj.__asLiveOrigH;
15505
+ const decSx = Math.abs(decomposed.scaleX || 1);
15506
+ const decSy = Math.abs(decomposed.scaleY || 1);
15507
+ const sx = Math.abs(decSx - 1) < 1e-3 && liveOrigW && liveOrigW > 0 ? Math.max(1e-3, (obj.width ?? liveOrigW) / liveOrigW) : decSx;
15508
+ const baseHForRecover = Number(
15509
+ obj.minBoxHeight ?? obj.height ?? liveOrigH ?? 1
15510
+ );
15511
+ const sy = Math.abs(decSy - 1) < 1e-3 && liveOrigH && liveOrigH > 0 ? Math.max(1e-3, baseHForRecover / liveOrigH) : decSy;
15485
15512
  const isLikelyUniformCorner = !activeSelectionResizeHandle && Math.abs(sx - sy) < 0.01 && Math.abs(sx - 1) > 1e-3;
15486
15513
  const isCornerHandle = activeSelectionResizeHandle === "tl" || activeSelectionResizeHandle === "tr" || activeSelectionResizeHandle === "bl" || activeSelectionResizeHandle === "br" || isLikelyUniformCorner;
15487
15514
  const isHeightSideHandle = activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb";
15488
15515
  const fontScale = isCornerHandle ? Math.max(1e-3, Math.sqrt(sx * sy)) : 1;
15489
- const bakedWidth = Math.max(20, intrinsicWidth * sx);
15490
- const baseMinH = Number(obj.minBoxHeight ?? (sourceElement == null ? void 0 : sourceElement.minBoxHeight));
15491
- const nextMinH = Number.isFinite(baseMinH) && baseMinH > 0 ? baseMinH * sy : isHeightSideHandle ? Math.max(1, intrinsicHeight * sy) : void 0;
15516
+ const widthBase = liveOrigW && liveOrigW > 0 ? liveOrigW : intrinsicWidth;
15517
+ const heightBase = liveOrigH && liveOrigH > 0 ? liveOrigH : intrinsicHeight;
15518
+ const bakedWidth = Math.max(20, widthBase * sx);
15519
+ const liveMinHOrig = obj.__asLiveOrigMinH;
15520
+ const currentMinH = Number(obj.minBoxHeight ?? (sourceElement == null ? void 0 : sourceElement.minBoxHeight));
15521
+ const minHBase = Number.isFinite(liveMinHOrig) && liveMinHOrig > 0 ? liveMinHOrig : liveOrigH && liveOrigH > 0 ? currentMinH / sy : currentMinH;
15522
+ const nextMinH = Number.isFinite(minHBase) && minHBase > 0 ? minHBase * sy : isHeightSideHandle ? Math.max(1, heightBase * sy) : void 0;
15492
15523
  const bakedTextScaleUpdates = { width: bakedWidth };
15493
15524
  const debugTextBeforeBake = debugGroupTextCornerResize ? summarizeFabricObjectForResizeDebug(obj) : null;
15494
15525
  finalScaleX = 1;
@@ -15712,6 +15743,9 @@ const PageCanvas = react.forwardRef(
15712
15743
  }
15713
15744
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
15714
15745
  obj.setCoords();
15746
+ delete obj.__asLiveOrigW;
15747
+ delete obj.__asLiveOrigH;
15748
+ delete obj.__asLiveOrigMinH;
15715
15749
  }
15716
15750
  if (isLogicalGroupAS && logicalGroupSelectionId && activeObj instanceof fabric__namespace.ActiveSelection) {
15717
15751
  try {
@@ -17294,6 +17328,7 @@ const PageCanvas = react.forwardRef(
17294
17328
  const node = findNodeById(currentPageTree, element.id);
17295
17329
  return node && isElement(node) ? getElementFabricPlacement(node, currentPageTree) : { left: element.left ?? 0, top: element.top ?? 0, angle: element.angle ?? 0 };
17296
17330
  })() : { left: element.left ?? 0, top: element.top ?? 0, angle: element.angle ?? 0 };
17331
+ const fabricAngle = fabricPos.angle ?? element.angle ?? 0;
17297
17332
  const resolvedSize = currentPageTree.length > 0 ? getNodeBounds(element, currentPageTree) : { width: typeof element.width === "number" ? element.width : 200, height: typeof element.height === "number" ? element.height : 50 };
17298
17333
  const shouldPreserveSmallSize = typeof element.width === "number" && Number.isFinite(element.width) && element.width > 0 && typeof element.height === "number" && Number.isFinite(element.height) && element.height > 0;
17299
17334
  const minVisible = shouldPreserveSmallSize ? 1 : 20;
@@ -17550,7 +17585,7 @@ const PageCanvas = react.forwardRef(
17550
17585
  y1: 0,
17551
17586
  x2: lineLen,
17552
17587
  y2: 0,
17553
- angle: element.angle ?? 0,
17588
+ angle: fabricAngle,
17554
17589
  scaleX: 1,
17555
17590
  scaleY: 1,
17556
17591
  skewX: 0,
@@ -17580,7 +17615,7 @@ const PageCanvas = react.forwardRef(
17580
17615
  width: rW,
17581
17616
  scaleX: effectiveScaleX,
17582
17617
  scaleY: effectiveScaleY,
17583
- angle: element.angle ?? 0,
17618
+ angle: fabricAngle,
17584
17619
  skewX: element.skewX ?? 0,
17585
17620
  skewY: appliedSkewY
17586
17621
  });
@@ -17589,7 +17624,7 @@ const PageCanvas = react.forwardRef(
17589
17624
  ...posIfNotSkipped,
17590
17625
  scaleX: effectiveScaleX,
17591
17626
  scaleY: effectiveScaleY,
17592
- angle: element.angle ?? 0,
17627
+ angle: fabricAngle,
17593
17628
  skewX: element.skewX ?? 0,
17594
17629
  skewY: element.skewY ?? 0
17595
17630
  });
@@ -17600,7 +17635,7 @@ const PageCanvas = react.forwardRef(
17600
17635
  obj.set({
17601
17636
  ...posIfNotSkipped,
17602
17637
  width: rW,
17603
- angle: element.angle ?? 0,
17638
+ angle: fabricAngle,
17604
17639
  skewX: element.skewX ?? 0,
17605
17640
  skewY: appliedSkewY,
17606
17641
  scaleX: effectiveScaleX * baseScaleX,
@@ -17609,7 +17644,7 @@ const PageCanvas = react.forwardRef(
17609
17644
  } else {
17610
17645
  obj.set({
17611
17646
  ...posIfNotSkipped,
17612
- angle: element.angle ?? 0,
17647
+ angle: fabricAngle,
17613
17648
  skewX: element.skewX ?? 0,
17614
17649
  skewY: element.skewY ?? 0,
17615
17650
  scaleX: effectiveScaleX * baseScaleX,
@@ -24870,9 +24905,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24870
24905
  }
24871
24906
  return svgString;
24872
24907
  }
24873
- const resolvedPackageVersion = "0.5.352";
24908
+ const resolvedPackageVersion = "0.5.354";
24874
24909
  const PACKAGE_VERSION = resolvedPackageVersion;
24875
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.352";
24910
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.354";
24876
24911
  const roundParityValue = (value) => {
24877
24912
  if (typeof value !== "number") return value;
24878
24913
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25686,7 +25721,7 @@ class PixldocsRenderer {
25686
25721
  await this.waitForCanvasScene(container, cloned, i);
25687
25722
  }
25688
25723
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25689
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DssfP9Fv.cjs"));
25724
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DnoKFr-R.cjs"));
25690
25725
  const prepared = preparePagesForExport(
25691
25726
  cloned.pages,
25692
25727
  canvasWidth,
@@ -28006,7 +28041,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28006
28041
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28007
28042
  sanitizeSvgTreeForPdf(svgToDraw);
28008
28043
  try {
28009
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DssfP9Fv.cjs"));
28044
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DnoKFr-R.cjs"));
28010
28045
  try {
28011
28046
  await logTextMeasurementDiagnostic(svgToDraw);
28012
28047
  } catch {
@@ -28403,4 +28438,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28403
28438
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28404
28439
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28405
28440
  exports.warmTemplateFromForm = warmTemplateFromForm;
28406
- //# sourceMappingURL=index-BBwoWejC.cjs.map
28441
+ //# sourceMappingURL=index-BUYWcO1C.cjs.map