@pixldocs/canvas-renderer 0.5.288 → 0.5.290

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.
@@ -11220,6 +11220,7 @@ const PageCanvas = forwardRef(
11220
11220
  useRef(null);
11221
11221
  const lastTextEditDimensionsRef = useRef(null);
11222
11222
  const lastResizeScaleTargetRef = useRef(null);
11223
+ const activeSelectionResizeHandleRef = useRef(null);
11223
11224
  const preserveSelectionAfterTransformIdRef = useRef(null);
11224
11225
  const groupSelectionTransformStartRef = useRef(null);
11225
11226
  const activeSelectionMoveStartRef = useRef(null);
@@ -12042,6 +12043,7 @@ const PageCanvas = forwardRef(
12042
12043
  fabricCanvas.on("mouse:down", () => {
12043
12044
  groupSelectionTransformStartRef.current = null;
12044
12045
  activeSelectionMoveStartRef.current = null;
12046
+ activeSelectionResizeHandleRef.current = null;
12045
12047
  const active = fabricCanvas.getActiveObject();
12046
12048
  if (active instanceof fabric.ActiveSelection) {
12047
12049
  const rect = active.getBoundingRect();
@@ -13508,6 +13510,9 @@ const PageCanvas = forwardRef(
13508
13510
  }
13509
13511
  const transform = e.transform;
13510
13512
  const corner = (transform == null ? void 0 : transform.corner) || "";
13513
+ if (obj instanceof fabric.ActiveSelection && corner) {
13514
+ activeSelectionResizeHandleRef.current = corner;
13515
+ }
13511
13516
  if (obj instanceof fabric.ActiveSelection && (corner === "ml" || corner === "mr" || corner === "mt" || corner === "mb")) {
13512
13517
  const isXSide = corner === "ml" || corner === "mr";
13513
13518
  const sAxis = isXSide ? Math.abs(obj.scaleX ?? 1) : Math.abs(obj.scaleY ?? 1);
@@ -14130,6 +14135,7 @@ const PageCanvas = forwardRef(
14130
14135
  activeObjects = activeObjects[0].getObjects();
14131
14136
  }
14132
14137
  const isActiveSelection = activeObj instanceof fabric.ActiveSelection || activeObjects.length > 1;
14138
+ const activeSelectionResizeHandle = isActiveSelection ? activeSelectionResizeHandleRef.current : null;
14133
14139
  if (activeObj instanceof fabric.ActiveSelection && activeObjects.length > 1) {
14134
14140
  const memberIds = activeObjects.map((o) => getObjectId(o)).filter((id) => !!id && id !== "__background__");
14135
14141
  if (memberIds.length > 1) {
@@ -14462,15 +14468,38 @@ const PageCanvas = forwardRef(
14462
14468
  } else if (obj instanceof fabric.Textbox && isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
14463
14469
  const sx = Math.abs(decomposed.scaleX || 1);
14464
14470
  const sy = Math.abs(decomposed.scaleY || 1);
14471
+ const isLikelyUniformCorner = !activeSelectionResizeHandle && Math.abs(sx - sy) < 0.01 && Math.abs(sx - 1) > 1e-3;
14472
+ const isCornerHandle = activeSelectionResizeHandle === "tl" || activeSelectionResizeHandle === "tr" || activeSelectionResizeHandle === "bl" || activeSelectionResizeHandle === "br" || isLikelyUniformCorner;
14473
+ const isHeightSideHandle = activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb";
14474
+ const fontScale = isCornerHandle ? Math.max(1e-3, Math.sqrt(sx * sy)) : 1;
14465
14475
  const bakedWidth = Math.max(20, intrinsicWidth * sx);
14466
- const bakedHeight = Math.max(1, intrinsicHeight * sy);
14467
- finalWidth = bakedWidth;
14468
- finalHeight = bakedHeight;
14476
+ const baseMinH = Number(obj.minBoxHeight ?? (sourceElement == null ? void 0 : sourceElement.minBoxHeight));
14477
+ const nextMinH = Number.isFinite(baseMinH) && baseMinH > 0 ? baseMinH * sy : isHeightSideHandle ? Math.max(1, intrinsicHeight * sy) : void 0;
14478
+ const bakedTextScaleUpdates = { width: bakedWidth };
14469
14479
  finalScaleX = 1;
14470
14480
  finalScaleY = 1;
14471
14481
  try {
14472
- obj.set({ width: bakedWidth, scaleX: 1, scaleY: 1 });
14482
+ const preBakeCenter = obj.getCenterPoint();
14483
+ if (isCornerHandle) {
14484
+ const baseFontSize = Number((sourceElement == null ? void 0 : sourceElement.fontSize) ?? obj.fontSize ?? 16);
14485
+ const nextFontSize = Math.max(1, baseFontSize * fontScale);
14486
+ bakedTextScaleUpdates.fontSize = nextFontSize;
14487
+ obj.set({ fontSize: nextFontSize });
14488
+ }
14489
+ if (nextMinH !== void 0) {
14490
+ bakedTextScaleUpdates.minBoxHeight = Math.max(0, nextMinH);
14491
+ obj.minBoxHeight = bakedTextScaleUpdates.minBoxHeight;
14492
+ }
14493
+ const prevObjCaching = obj.objectCaching;
14494
+ obj.set({ width: bakedWidth, scaleX: 1, scaleY: 1, objectCaching: false });
14473
14495
  obj.initDimensions();
14496
+ obj.setPositionByOrigin(preBakeCenter, "center", "center");
14497
+ obj.objectCaching = prevObjCaching;
14498
+ obj.dirty = true;
14499
+ if (activeObj) activeObj.dirty = true;
14500
+ finalWidth = bakedWidth;
14501
+ finalHeight = Math.max(1, obj.height ?? intrinsicHeight * sy);
14502
+ obj.__pixldocsBakedTextScaleUpdates = bakedTextScaleUpdates;
14474
14503
  obj.setCoords();
14475
14504
  } catch {
14476
14505
  }
@@ -14614,6 +14643,7 @@ const PageCanvas = forwardRef(
14614
14643
  }
14615
14644
  groupSelectionTransformStartRef.current = null;
14616
14645
  activeSelectionMoveStartRef.current = null;
14646
+ activeSelectionResizeHandleRef.current = null;
14617
14647
  setTimeout(() => modifiedIdsThisRound.forEach((id) => justModifiedIdsRef.current.delete(id)), 150);
14618
14648
  commitHistory();
14619
14649
  unlockEditsSoon();
@@ -23625,9 +23655,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23625
23655
  }
23626
23656
  return svgString;
23627
23657
  }
23628
- const resolvedPackageVersion = "0.5.288";
23658
+ const resolvedPackageVersion = "0.5.290";
23629
23659
  const PACKAGE_VERSION = resolvedPackageVersion;
23630
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.288";
23660
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.290";
23631
23661
  const roundParityValue = (value) => {
23632
23662
  if (typeof value !== "number") return value;
23633
23663
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24441,7 +24471,7 @@ class PixldocsRenderer {
24441
24471
  await this.waitForCanvasScene(container, cloned, i);
24442
24472
  }
24443
24473
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24444
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BeBLRc4B.js");
24474
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BW4Ihi3j.js");
24445
24475
  const prepared = preparePagesForExport(
24446
24476
  cloned.pages,
24447
24477
  canvasWidth,
@@ -26761,7 +26791,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26761
26791
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26762
26792
  sanitizeSvgTreeForPdf(svgToDraw);
26763
26793
  try {
26764
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BeBLRc4B.js");
26794
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BW4Ihi3j.js");
26765
26795
  try {
26766
26796
  await logTextMeasurementDiagnostic(svgToDraw);
26767
26797
  } catch {
@@ -27161,4 +27191,4 @@ export {
27161
27191
  buildTeaserBlurFlatKeys as y,
27162
27192
  collectFontDescriptorsFromConfig as z
27163
27193
  };
27164
- //# sourceMappingURL=index-Dc3vuyOU.js.map
27194
+ //# sourceMappingURL=index-B6JMRs-J.js.map