@pixldocs/canvas-renderer 0.5.269 → 0.5.270

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.
@@ -11013,9 +11013,9 @@ const scaleUpdateNumber = (updates, source, key, factor) => {
11013
11013
  const value = Number(source == null ? void 0 : source[key]);
11014
11014
  if (Number.isFinite(value)) updates[key] = value * factor;
11015
11015
  };
11016
- const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
11017
- const sx = Math.abs(obj.scaleX ?? 1) || 1;
11018
- const sy = Math.abs(obj.scaleY ?? 1) || 1;
11016
+ const bakeTextboxScaleIntoTypography = (obj, sourceElement, scaleOverride) => {
11017
+ const sx = Math.abs((scaleOverride == null ? void 0 : scaleOverride.scaleX) ?? obj.scaleX ?? 1) || 1;
11018
+ const sy = Math.abs((scaleOverride == null ? void 0 : scaleOverride.scaleY) ?? obj.scaleY ?? 1) || 1;
11019
11019
  if (Math.abs(sx - 1) < 1e-3 && Math.abs(sy - 1) < 1e-3) return null;
11020
11020
  const isUniform = Math.abs(sx - sy) < 0.01;
11021
11021
  const fontScale = isUniform ? (sx + sy) / 2 : Math.abs(sy - 1) > 1e-3 ? sy : 1;
@@ -11231,6 +11231,7 @@ const PageCanvas = react.forwardRef(
11231
11231
  react.useRef(null);
11232
11232
  const lastTextEditDimensionsRef = react.useRef(null);
11233
11233
  const lastResizeScaleTargetRef = react.useRef(null);
11234
+ const lastResizeScaleCornerRef = react.useRef(null);
11234
11235
  const preserveSelectionAfterTransformIdRef = react.useRef(null);
11235
11236
  const groupSelectionTransformStartRef = react.useRef(null);
11236
11237
  const activeSelectionMoveStartRef = react.useRef(null);
@@ -11558,6 +11559,7 @@ const PageCanvas = react.forwardRef(
11558
11559
  fc.__isUserTransforming = true;
11559
11560
  didTransformRef.current = true;
11560
11561
  lastResizeScaleTargetRef.current = target;
11562
+ lastResizeScaleCornerRef.current = corner;
11561
11563
  const targetId = getObjectId(target);
11562
11564
  if (targetId && targetId !== "__background__") {
11563
11565
  preserveSelectionAfterTransformIdRef.current = targetId;
@@ -13385,10 +13387,11 @@ const PageCanvas = react.forwardRef(
13385
13387
  fabricCanvas.on("selection:cleared", () => {
13386
13388
  });
13387
13389
  fabricCanvas.on("object:scaling", (e) => {
13388
- var _a2;
13390
+ var _a2, _b2;
13389
13391
  if (!isActiveRef.current) return;
13390
13392
  const t = e.target;
13391
13393
  if (t) lastResizeScaleTargetRef.current = t;
13394
+ lastResizeScaleCornerRef.current = ((_a2 = e.transform) == null ? void 0 : _a2.corner) ?? null;
13392
13395
  prepareGroupSelectionTransformStart(t);
13393
13396
  markTransforming(t);
13394
13397
  didTransformRef.current = true;
@@ -13706,16 +13709,17 @@ const PageCanvas = react.forwardRef(
13706
13709
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
13707
13710
  if (drilledGroupIdRef.current) {
13708
13711
  try {
13709
- (_a2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _a2.call(fabricCanvas);
13712
+ (_b2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _b2.call(fabricCanvas);
13710
13713
  } catch {
13711
13714
  }
13712
13715
  }
13713
13716
  });
13714
13717
  fabricCanvas.on("object:resizing", (e) => {
13715
- var _a2;
13718
+ var _a2, _b2;
13716
13719
  if (!isActiveRef.current) return;
13717
13720
  const t = e.target;
13718
13721
  if (t) lastResizeScaleTargetRef.current = t;
13722
+ lastResizeScaleCornerRef.current = ((_a2 = e.transform) == null ? void 0 : _a2.corner) ?? null;
13719
13723
  markTransforming(t);
13720
13724
  didTransformRef.current = true;
13721
13725
  const transformTargetId = t ? getObjectId(t) : null;
@@ -13791,7 +13795,7 @@ const PageCanvas = react.forwardRef(
13791
13795
  setGuides(gridGuidesForTextResize.length ? [...scaleGuides, ...gridGuidesForTextResize] : scaleGuides);
13792
13796
  if (drilledGroupIdRef.current) {
13793
13797
  try {
13794
- (_a2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _a2.call(fabricCanvas);
13798
+ (_b2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _b2.call(fabricCanvas);
13795
13799
  } catch {
13796
13800
  }
13797
13801
  }
@@ -14518,6 +14522,8 @@ const PageCanvas = react.forwardRef(
14518
14522
  } else if (obj instanceof fabric__namespace.Textbox && isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
14519
14523
  const sx = Math.abs(decomposed.scaleX || 1);
14520
14524
  const sy = Math.abs(decomposed.scaleY || 1);
14525
+ const lastCorner = lastResizeScaleCornerRef.current ?? "";
14526
+ const isCornerGroupScale = lastCorner === "tl" || lastCorner === "tr" || lastCorner === "bl" || lastCorner === "br";
14521
14527
  const bakedWidth = Math.max(20, intrinsicWidth * sx);
14522
14528
  const bakedHeight = Math.max(1, intrinsicHeight * sy);
14523
14529
  finalWidth = bakedWidth;
@@ -14525,8 +14531,13 @@ const PageCanvas = react.forwardRef(
14525
14531
  finalScaleX = 1;
14526
14532
  finalScaleY = 1;
14527
14533
  try {
14528
- obj.set({ width: bakedWidth, scaleX: 1, scaleY: 1 });
14529
- obj.initDimensions();
14534
+ if (isCornerGroupScale) {
14535
+ bakeTextboxScaleIntoTypography(obj, sourceElement, { scaleX: sx, scaleY: sy });
14536
+ } else {
14537
+ obj.set({ width: bakedWidth, scaleX: 1, scaleY: 1 });
14538
+ obj.minBoxHeight = bakedHeight;
14539
+ obj.initDimensions();
14540
+ }
14530
14541
  obj.setCoords();
14531
14542
  } catch {
14532
14543
  }
@@ -14667,10 +14678,12 @@ const PageCanvas = react.forwardRef(
14667
14678
  }
14668
14679
  groupSelectionTransformStartRef.current = null;
14669
14680
  activeSelectionMoveStartRef.current = null;
14681
+ lastResizeScaleCornerRef.current = null;
14670
14682
  setTimeout(() => modifiedIdsThisRound.forEach((id) => justModifiedIdsRef.current.delete(id)), 150);
14671
14683
  commitHistory();
14672
14684
  unlockEditsSoon();
14673
14685
  } catch (e2) {
14686
+ lastResizeScaleCornerRef.current = null;
14674
14687
  unlockEditsSoon();
14675
14688
  }
14676
14689
  });
@@ -23683,9 +23696,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23683
23696
  }
23684
23697
  return svgString;
23685
23698
  }
23686
- const resolvedPackageVersion = "0.5.269";
23699
+ const resolvedPackageVersion = "0.5.270";
23687
23700
  const PACKAGE_VERSION = resolvedPackageVersion;
23688
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.269";
23701
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.270";
23689
23702
  const roundParityValue = (value) => {
23690
23703
  if (typeof value !== "number") return value;
23691
23704
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24499,7 +24512,7 @@ class PixldocsRenderer {
24499
24512
  await this.waitForCanvasScene(container, cloned, i);
24500
24513
  }
24501
24514
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24502
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-xlycX5wM.cjs"));
24515
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BpHyRyQS.cjs"));
24503
24516
  const prepared = preparePagesForExport(
24504
24517
  cloned.pages,
24505
24518
  canvasWidth,
@@ -26819,7 +26832,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26819
26832
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26820
26833
  sanitizeSvgTreeForPdf(svgToDraw);
26821
26834
  try {
26822
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-xlycX5wM.cjs"));
26835
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BpHyRyQS.cjs"));
26823
26836
  try {
26824
26837
  await logTextMeasurementDiagnostic(svgToDraw);
26825
26838
  } catch {
@@ -27216,4 +27229,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27216
27229
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27217
27230
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27218
27231
  exports.warmTemplateFromForm = warmTemplateFromForm;
27219
- //# sourceMappingURL=index-V3Oyi5GA.cjs.map
27232
+ //# sourceMappingURL=index-CLq3CdA3.cjs.map