@pixldocs/canvas-renderer 0.5.297 → 0.5.299

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.
@@ -13600,6 +13600,34 @@ const PageCanvas = forwardRef(
13600
13600
  const asRect0 = obj.getBoundingRect();
13601
13601
  let didReflowTextChild = false;
13602
13602
  for (const child of obj.getObjects()) {
13603
+ if (child instanceof fabric.FabricImage && !child.__cropGroup && !child.smartElementType) {
13604
+ if (isXSide) {
13605
+ if (child.__asLiveOrigW == null) {
13606
+ child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
13607
+ }
13608
+ const origW = child.__asLiveOrigW;
13609
+ const newW = Math.max(1, origW * sAxis);
13610
+ if (Math.abs((child.width ?? 0) - newW) > 0.5) {
13611
+ child._set("width", newW);
13612
+ child._set("scaleX", 1 / sAxis);
13613
+ child.setCoords();
13614
+ child.dirty = true;
13615
+ }
13616
+ } else {
13617
+ if (child.__asLiveOrigH == null) {
13618
+ child.__asLiveOrigH = (child.height ?? 0) * (child.scaleY ?? 1);
13619
+ }
13620
+ const origH = child.__asLiveOrigH;
13621
+ const newH = Math.max(1, origH * sAxis);
13622
+ if (Math.abs((child.height ?? 0) - newH) > 0.5) {
13623
+ child._set("height", newH);
13624
+ child._set("scaleY", 1 / sAxis);
13625
+ child.setCoords();
13626
+ child.dirty = true;
13627
+ }
13628
+ }
13629
+ continue;
13630
+ }
13603
13631
  if (!(child instanceof fabric.Textbox)) continue;
13604
13632
  if (isXSide) {
13605
13633
  if (child.__asLiveOrigW == null) {
@@ -13937,7 +13965,7 @@ const PageCanvas = forwardRef(
13937
13965
  });
13938
13966
  let cropGroupSaveTimer = null;
13939
13967
  fabricCanvas.on("object:modified", (e) => {
13940
- var _a2, _b2, _c, _d, _e, _f, _g, _h;
13968
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
13941
13969
  try {
13942
13970
  dragStarted = false;
13943
13971
  setGuides([]);
@@ -14544,6 +14572,94 @@ const PageCanvas = forwardRef(
14544
14572
  };
14545
14573
  useEditorStore.getState().updateElement(objId, { src: newSrc }, { recordHistory: false, skipLayoutRecalc: true });
14546
14574
  }
14575
+ } else if (isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
14576
+ const sx = Math.abs(decomposed.scaleX || 1);
14577
+ const sy = Math.abs(decomposed.scaleY || 1);
14578
+ const handle = activeSelectionResizeHandle;
14579
+ const isCornerHandle = handle === "tl" || handle === "tr" || handle === "bl" || handle === "br" || // Fallback: if handle ref is missing and sx≈sy with non-1 magnitude,
14580
+ // treat as a uniform corner drag.
14581
+ !handle && Math.abs(sx - sy) < 0.01 && Math.abs(sx - 1) > 1e-3;
14582
+ let fx;
14583
+ let fy;
14584
+ if (isCornerHandle) {
14585
+ const u = Math.max(1e-3, Math.sqrt(sx * sy));
14586
+ fx = u;
14587
+ fy = u;
14588
+ } else {
14589
+ fx = sx;
14590
+ fy = sy;
14591
+ }
14592
+ const bakedW = Math.max(1, intrinsicWidth * fx);
14593
+ const bakedH = Math.max(1, intrinsicHeight * fy);
14594
+ try {
14595
+ const preBakeCenter = obj.getCenterPoint();
14596
+ const prevObjCaching = obj.objectCaching;
14597
+ obj.set({
14598
+ width: bakedW,
14599
+ height: bakedH,
14600
+ scaleX: 1,
14601
+ scaleY: 1,
14602
+ objectCaching: false
14603
+ });
14604
+ obj.objectCaching = prevObjCaching;
14605
+ if (sx > 0 && sy > 0) {
14606
+ const localScaleX = 1 / sx;
14607
+ const localScaleY = 1 / sy;
14608
+ obj.set({ scaleX: localScaleX, scaleY: localScaleY });
14609
+ const selectionMatrix = (_g = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _g.call(activeObj);
14610
+ const localCenter = selectionMatrix ? fabric.util.transformPoint(preBakeCenter, fabric.util.invertTransform(selectionMatrix)) : preBakeCenter;
14611
+ const localWidth = bakedW * localScaleX;
14612
+ const localHeight = bakedH * localScaleY;
14613
+ const isCenterOrigin = obj.originX === "center" || obj.originY === "center";
14614
+ if (isCenterOrigin) {
14615
+ obj.set({
14616
+ left: localCenter.x,
14617
+ top: localCenter.y
14618
+ });
14619
+ } else {
14620
+ obj.set({
14621
+ left: localCenter.x - localWidth / 2,
14622
+ top: localCenter.y - localHeight / 2
14623
+ });
14624
+ }
14625
+ }
14626
+ obj.dirty = true;
14627
+ if (activeObj) activeObj.dirty = true;
14628
+ obj.setCoords();
14629
+ } catch {
14630
+ }
14631
+ finalWidth = bakedW;
14632
+ finalHeight = bakedH;
14633
+ finalScaleX = 1;
14634
+ finalScaleY = 1;
14635
+ try {
14636
+ const angleRad = (decomposed.angle ?? 0) * Math.PI / 180;
14637
+ const cos = Math.cos(angleRad);
14638
+ const sin = Math.sin(angleRad);
14639
+ const hw = finalWidth / 2;
14640
+ const hh = finalHeight / 2;
14641
+ const corners = [
14642
+ { x: -hw, y: -hh },
14643
+ { x: hw, y: -hh },
14644
+ { x: hw, y: hh },
14645
+ { x: -hw, y: hh }
14646
+ ].map((p) => ({
14647
+ x: decomposed.translateX + p.x * cos - p.y * sin,
14648
+ y: decomposed.translateY + p.x * sin + p.y * cos
14649
+ }));
14650
+ absoluteLeft = Math.min(...corners.map((p) => p.x));
14651
+ absoluteTop = Math.min(...corners.map((p) => p.y));
14652
+ } catch {
14653
+ }
14654
+ finalAbsoluteMatrix = fabric.util.composeMatrix({
14655
+ translateX: decomposed.translateX,
14656
+ translateY: decomposed.translateY,
14657
+ angle: decomposed.angle ?? 0,
14658
+ scaleX: 1,
14659
+ scaleY: 1,
14660
+ skewX: 0,
14661
+ skewY: 0
14662
+ });
14547
14663
  } else {
14548
14664
  finalWidth = intrinsicWidth;
14549
14665
  finalHeight = intrinsicHeight;
@@ -14587,7 +14703,7 @@ const PageCanvas = forwardRef(
14587
14703
  const localScaleX = 1 / sx;
14588
14704
  const localScaleY = 1 / sy;
14589
14705
  obj.set({ scaleX: localScaleX, scaleY: localScaleY });
14590
- const selectionMatrix = (_g = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _g.call(activeObj);
14706
+ const selectionMatrix = (_h = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _h.call(activeObj);
14591
14707
  const localCenter = selectionMatrix ? fabric.util.transformPoint(preBakeCenter, fabric.util.invertTransform(selectionMatrix)) : preBakeCenter;
14592
14708
  const localWidth = bakedWidth * localScaleX;
14593
14709
  const localHeight = (obj.height ?? intrinsicHeight) * localScaleY;
@@ -14739,7 +14855,7 @@ const PageCanvas = forwardRef(
14739
14855
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
14740
14856
  obj.setCoords();
14741
14857
  }
14742
- const pageChildrenForReflow = ((_h = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _h.children) ?? [];
14858
+ const pageChildrenForReflow = ((_i = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _i.children) ?? [];
14743
14859
  const stackGroupsToReflow = /* @__PURE__ */ new Set();
14744
14860
  for (const id of modifiedIdsThisRound) {
14745
14861
  const parent = findParentGroup(pageChildrenForReflow, id);
@@ -23839,9 +23955,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23839
23955
  }
23840
23956
  return svgString;
23841
23957
  }
23842
- const resolvedPackageVersion = "0.5.297";
23958
+ const resolvedPackageVersion = "0.5.299";
23843
23959
  const PACKAGE_VERSION = resolvedPackageVersion;
23844
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.297";
23960
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.299";
23845
23961
  const roundParityValue = (value) => {
23846
23962
  if (typeof value !== "number") return value;
23847
23963
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24655,7 +24771,7 @@ class PixldocsRenderer {
24655
24771
  await this.waitForCanvasScene(container, cloned, i);
24656
24772
  }
24657
24773
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24658
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DOAlZclW.js");
24774
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-C1obEkji.js");
24659
24775
  const prepared = preparePagesForExport(
24660
24776
  cloned.pages,
24661
24777
  canvasWidth,
@@ -26975,7 +27091,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26975
27091
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26976
27092
  sanitizeSvgTreeForPdf(svgToDraw);
26977
27093
  try {
26978
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DOAlZclW.js");
27094
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-C1obEkji.js");
26979
27095
  try {
26980
27096
  await logTextMeasurementDiagnostic(svgToDraw);
26981
27097
  } catch {
@@ -27375,4 +27491,4 @@ export {
27375
27491
  buildTeaserBlurFlatKeys as y,
27376
27492
  collectFontDescriptorsFromConfig as z
27377
27493
  };
27378
- //# sourceMappingURL=index-BDVGR-oo.js.map
27494
+ //# sourceMappingURL=index-Ddn4TvlA.js.map