@pixldocs/canvas-renderer 0.5.287 → 0.5.289

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.
@@ -11000,10 +11000,12 @@ const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
11000
11000
  const sy = Math.abs(obj.scaleY ?? 1) || 1;
11001
11001
  if (Math.abs(sx - 1) < 1e-3 && Math.abs(sy - 1) < 1e-3) return null;
11002
11002
  const isUniform = Math.abs(sx - sy) < 0.01;
11003
- const fontScale = isUniform ? (sx + sy) / 2 : Math.abs(sy - 1) > 1e-3 ? sy : 1;
11003
+ const isHeightOnly = !isUniform && Math.abs(sx - 1) < 0.01 && Math.abs(sy - 1) > 1e-3;
11004
+ const fontScale = isUniform ? (sx + sy) / 2 : 1;
11004
11005
  const effectScale = isUniform ? fontScale : Math.max(1e-3, Math.sqrt(sx * sy));
11006
+ const newWidth = isHeightOnly ? obj.width ?? (sourceElement == null ? void 0 : sourceElement.width) ?? 20 : Math.max(20, (obj.width ?? (sourceElement == null ? void 0 : sourceElement.width) ?? 20) * sx);
11005
11007
  const updates = {
11006
- width: Math.max(20, (obj.width ?? (sourceElement == null ? void 0 : sourceElement.width) ?? 20) * sx),
11008
+ width: newWidth,
11007
11009
  scaleX: 1,
11008
11010
  scaleY: 1
11009
11011
  };
@@ -11011,6 +11013,10 @@ const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
11011
11013
  updates.fontSize = Math.max(1, Number(obj.fontSize || (sourceElement == null ? void 0 : sourceElement.fontSize) || 16) * fontScale);
11012
11014
  const minBoxHeight = Number(obj.minBoxHeight ?? (sourceElement == null ? void 0 : sourceElement.minBoxHeight));
11013
11015
  if (Number.isFinite(minBoxHeight) && minBoxHeight > 0) updates.minBoxHeight = minBoxHeight * sy;
11016
+ } else if (isHeightOnly) {
11017
+ const baseMinH = Number(obj.minBoxHeight ?? (sourceElement == null ? void 0 : sourceElement.minBoxHeight));
11018
+ const baselineH = Number.isFinite(baseMinH) && baseMinH > 0 ? baseMinH : obj.height ?? (sourceElement == null ? void 0 : sourceElement.height) ?? 0;
11019
+ if (baselineH > 0) updates.minBoxHeight = Math.max(0, baselineH * sy);
11014
11020
  }
11015
11021
  scaleUpdateNumber(updates, sourceElement ?? void 0, "strokeWidth", effectScale);
11016
11022
  scaleUpdateNumber(updates, sourceElement ?? void 0, "textShadowBlur", effectScale);
@@ -11214,6 +11220,7 @@ const PageCanvas = forwardRef(
11214
11220
  useRef(null);
11215
11221
  const lastTextEditDimensionsRef = useRef(null);
11216
11222
  const lastResizeScaleTargetRef = useRef(null);
11223
+ const activeSelectionResizeHandleRef = useRef(null);
11217
11224
  const preserveSelectionAfterTransformIdRef = useRef(null);
11218
11225
  const groupSelectionTransformStartRef = useRef(null);
11219
11226
  const activeSelectionMoveStartRef = useRef(null);
@@ -12036,6 +12043,7 @@ const PageCanvas = forwardRef(
12036
12043
  fabricCanvas.on("mouse:down", () => {
12037
12044
  groupSelectionTransformStartRef.current = null;
12038
12045
  activeSelectionMoveStartRef.current = null;
12046
+ activeSelectionResizeHandleRef.current = null;
12039
12047
  const active = fabricCanvas.getActiveObject();
12040
12048
  if (active instanceof fabric.ActiveSelection) {
12041
12049
  const rect = active.getBoundingRect();
@@ -13502,6 +13510,9 @@ const PageCanvas = forwardRef(
13502
13510
  }
13503
13511
  const transform = e.transform;
13504
13512
  const corner = (transform == null ? void 0 : transform.corner) || "";
13513
+ if (obj instanceof fabric.ActiveSelection && corner) {
13514
+ activeSelectionResizeHandleRef.current = corner;
13515
+ }
13505
13516
  if (obj instanceof fabric.ActiveSelection && (corner === "ml" || corner === "mr" || corner === "mt" || corner === "mb")) {
13506
13517
  const isXSide = corner === "ml" || corner === "mr";
13507
13518
  const sAxis = isXSide ? Math.abs(obj.scaleX ?? 1) : Math.abs(obj.scaleY ?? 1);
@@ -14124,6 +14135,7 @@ const PageCanvas = forwardRef(
14124
14135
  activeObjects = activeObjects[0].getObjects();
14125
14136
  }
14126
14137
  const isActiveSelection = activeObj instanceof fabric.ActiveSelection || activeObjects.length > 1;
14138
+ const activeSelectionResizeHandle = isActiveSelection ? activeSelectionResizeHandleRef.current : null;
14127
14139
  if (activeObj instanceof fabric.ActiveSelection && activeObjects.length > 1) {
14128
14140
  const memberIds = activeObjects.map((o) => getObjectId(o)).filter((id) => !!id && id !== "__background__");
14129
14141
  if (memberIds.length > 1) {
@@ -14456,15 +14468,32 @@ const PageCanvas = forwardRef(
14456
14468
  } else if (obj instanceof fabric.Textbox && isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
14457
14469
  const sx = Math.abs(decomposed.scaleX || 1);
14458
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;
14459
14475
  const bakedWidth = Math.max(20, intrinsicWidth * sx);
14460
- const bakedHeight = Math.max(1, intrinsicHeight * sy);
14461
- finalWidth = bakedWidth;
14462
- 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 };
14463
14479
  finalScaleX = 1;
14464
14480
  finalScaleY = 1;
14465
14481
  try {
14482
+ if (isCornerHandle) {
14483
+ const baseFontSize = Number((sourceElement == null ? void 0 : sourceElement.fontSize) ?? obj.fontSize ?? 16);
14484
+ const nextFontSize = Math.max(1, baseFontSize * fontScale);
14485
+ bakedTextScaleUpdates.fontSize = nextFontSize;
14486
+ obj.set({ fontSize: nextFontSize });
14487
+ }
14488
+ if (nextMinH !== void 0) {
14489
+ bakedTextScaleUpdates.minBoxHeight = Math.max(0, nextMinH);
14490
+ obj.minBoxHeight = bakedTextScaleUpdates.minBoxHeight;
14491
+ }
14466
14492
  obj.set({ width: bakedWidth, scaleX: 1, scaleY: 1 });
14467
14493
  obj.initDimensions();
14494
+ finalWidth = bakedWidth;
14495
+ finalHeight = Math.max(1, obj.height ?? intrinsicHeight * sy);
14496
+ obj.__pixldocsBakedTextScaleUpdates = bakedTextScaleUpdates;
14468
14497
  obj.setCoords();
14469
14498
  } catch {
14470
14499
  }
@@ -14608,6 +14637,7 @@ const PageCanvas = forwardRef(
14608
14637
  }
14609
14638
  groupSelectionTransformStartRef.current = null;
14610
14639
  activeSelectionMoveStartRef.current = null;
14640
+ activeSelectionResizeHandleRef.current = null;
14611
14641
  setTimeout(() => modifiedIdsThisRound.forEach((id) => justModifiedIdsRef.current.delete(id)), 150);
14612
14642
  commitHistory();
14613
14643
  unlockEditsSoon();
@@ -23619,9 +23649,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23619
23649
  }
23620
23650
  return svgString;
23621
23651
  }
23622
- const resolvedPackageVersion = "0.5.287";
23652
+ const resolvedPackageVersion = "0.5.289";
23623
23653
  const PACKAGE_VERSION = resolvedPackageVersion;
23624
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.287";
23654
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.289";
23625
23655
  const roundParityValue = (value) => {
23626
23656
  if (typeof value !== "number") return value;
23627
23657
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24435,7 +24465,7 @@ class PixldocsRenderer {
24435
24465
  await this.waitForCanvasScene(container, cloned, i);
24436
24466
  }
24437
24467
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24438
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Cdzd1M4c.js");
24468
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-rGdZJ7ux.js");
24439
24469
  const prepared = preparePagesForExport(
24440
24470
  cloned.pages,
24441
24471
  canvasWidth,
@@ -26755,7 +26785,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26755
26785
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26756
26786
  sanitizeSvgTreeForPdf(svgToDraw);
26757
26787
  try {
26758
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Cdzd1M4c.js");
26788
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-rGdZJ7ux.js");
26759
26789
  try {
26760
26790
  await logTextMeasurementDiagnostic(svgToDraw);
26761
26791
  } catch {
@@ -27155,4 +27185,4 @@ export {
27155
27185
  buildTeaserBlurFlatKeys as y,
27156
27186
  collectFontDescriptorsFromConfig as z
27157
27187
  };
27158
- //# sourceMappingURL=index-SOarDnbw.js.map
27188
+ //# sourceMappingURL=index-8DBd7ACA.js.map