@pixldocs/canvas-renderer 0.5.329 → 0.5.330

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.
@@ -13740,7 +13740,7 @@ const PageCanvas = forwardRef(
13740
13740
  const a = ((c.angle ?? 0) % 180 + 180) % 180;
13741
13741
  return !(a < 0.5 || a > 179.5);
13742
13742
  });
13743
- if (isXSide && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13743
+ if ((isXSide || hasRotatedChild) && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13744
13744
  groupShiftReflowSnapshotRef.current = null;
13745
13745
  const logicalGroupId = obj.__pixldocsGroupSelection;
13746
13746
  if (logicalGroupId) {
@@ -13752,7 +13752,9 @@ const PageCanvas = forwardRef(
13752
13752
  const entries = obj.getObjects().map((c) => ({
13753
13753
  obj: c,
13754
13754
  id: getObjectId(c) ?? "",
13755
+ left0: c.left ?? 0,
13755
13756
  top0: c.top ?? 0,
13757
+ width0: (c.width ?? 0) * Math.abs(c.scaleX ?? 1),
13756
13758
  height0: (c.height ?? 0) * Math.abs(c.scaleY ?? 1)
13757
13759
  })).filter((e2) => e2.id).sort((a, b) => a.top0 - b.top0);
13758
13760
  if (entries.length > 1) {
@@ -13785,6 +13787,33 @@ const PageCanvas = forwardRef(
13785
13787
  }
13786
13788
  }
13787
13789
  const childCounterScale = hasRotatedChild ? 1 : 1 / sAxis;
13790
+ const restoreNonTextChildren = (pins) => {
13791
+ var _a3, _b3;
13792
+ if (!hasRotatedChild || ((_a3 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _a3.selection) !== obj) return;
13793
+ for (const entry of groupShiftReflowSnapshotRef.current.children) {
13794
+ const child = entry.obj;
13795
+ if (child instanceof fabric.Textbox) continue;
13796
+ if (child instanceof fabric.FabricImage || child instanceof fabric.Group && (child.__cropGroup || ((_b3 = child._ct) == null ? void 0 : _b3.isCropGroup))) {
13797
+ const pin = pins == null ? void 0 : pins.get(child);
13798
+ const targetLeft = (pin == null ? void 0 : pin.left) ?? (isXSide ? entry.left0 * sAxis : entry.left0);
13799
+ const targetTop = (pin == null ? void 0 : pin.top) ?? (isXSide ? entry.top0 : entry.top0 * sAxis);
13800
+ if (Math.abs((child.left ?? 0) - targetLeft) > 0.01) child._set("left", targetLeft);
13801
+ if (Math.abs((child.top ?? 0) - targetTop) > 0.01) child._set("top", targetTop);
13802
+ if (isXSide) child._set("scaleX", childCounterScale);
13803
+ else child._set("scaleY", childCounterScale);
13804
+ child.setCoords();
13805
+ child.dirty = true;
13806
+ }
13807
+ }
13808
+ };
13809
+ const projectRotatedTextPosition = (child) => {
13810
+ var _a3;
13811
+ if (!hasRotatedChild || ((_a3 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _a3.selection) !== obj) return;
13812
+ const entry = groupShiftReflowSnapshotRef.current.children.find((candidate) => candidate.obj === child);
13813
+ if (!entry) return;
13814
+ if (isXSide) child._set("left", entry.left0 * sAxis);
13815
+ else child._set("top", entry.top0 * sAxis);
13816
+ };
13788
13817
  for (const child of obj.getObjects()) {
13789
13818
  if (child instanceof fabric.Group && (child.__cropGroup || ((_d = child._ct) == null ? void 0 : _d.isCropGroup))) {
13790
13819
  if (isXSide) child._set("scaleX", childCounterScale);
@@ -13801,6 +13830,7 @@ const PageCanvas = forwardRef(
13801
13830
  continue;
13802
13831
  }
13803
13832
  if (!(child instanceof fabric.Textbox)) continue;
13833
+ projectRotatedTextPosition(child);
13804
13834
  if (isXSide) {
13805
13835
  if (child.__asLiveOrigW == null) {
13806
13836
  child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
@@ -13868,10 +13898,12 @@ const PageCanvas = forwardRef(
13868
13898
  if (cornersBefore) {
13869
13899
  fixedMidBefore = corner === "ml" ? { x: (cornersBefore.tr.x + cornersBefore.br.x) / 2, y: (cornersBefore.tr.y + cornersBefore.br.y) / 2 } : { x: (cornersBefore.tl.x + cornersBefore.bl.x) / 2, y: (cornersBefore.tl.y + cornersBefore.bl.y) / 2 };
13870
13900
  }
13901
+ const nonTextPinsBeforeLayout = hasRotatedChild ? new Map(obj.getObjects().map((child) => [child, { left: child.left ?? 0, top: child.top ?? 0 }])) : void 0;
13871
13902
  try {
13872
13903
  obj.triggerLayout();
13873
13904
  } catch {
13874
13905
  }
13906
+ restoreNonTextChildren(nonTextPinsBeforeLayout);
13875
13907
  obj._set("width", asW0);
13876
13908
  obj._set("scaleX", asSx0);
13877
13909
  obj._set("scaleY", asSy0);
@@ -13897,6 +13929,7 @@ const PageCanvas = forwardRef(
13897
13929
  obj._set("left", asLeft0);
13898
13930
  obj._set("top", asTop0);
13899
13931
  }
13932
+ restoreNonTextChildren();
13900
13933
  obj._set("width", asW0);
13901
13934
  obj._set("scaleX", asSx0);
13902
13935
  obj._set("scaleY", asSy0);
@@ -14537,6 +14570,7 @@ const PageCanvas = forwardRef(
14537
14570
  return;
14538
14571
  }
14539
14572
  }
14573
+ const isActiveSelectionSideResize = isActiveSelection && (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb");
14540
14574
  if (selectedElementIds.length > 0 && !anyCropGroup) {
14541
14575
  const firstObj = activeObjects[0];
14542
14576
  const firstId = getObjectId(firstObj);
@@ -14598,7 +14632,8 @@ const PageCanvas = forwardRef(
14598
14632
  }
14599
14633
  const deltaX = movedGroupLeft - groupAbs.left;
14600
14634
  const deltaY = movedGroupTop - groupAbs.top;
14601
- const hadScale = isActiveSelection && activeObj && (Math.abs((activeObj.scaleX ?? 1) - 1) > 0.01 || Math.abs((activeObj.scaleY ?? 1) - 1) > 0.01);
14635
+ const hadResizeHandle = isActiveSelection && !!activeSelectionResizeHandle;
14636
+ const hadScale = isActiveSelection && activeObj && (hadResizeHandle || Math.abs((activeObj.scaleX ?? 1) - 1) > 0.01 || Math.abs((activeObj.scaleY ?? 1) - 1) > 0.01);
14602
14637
  const startSelAngle = (((transformStart == null ? void 0 : transformStart.selectionAngle) ?? 0) % 360 + 360) % 360;
14603
14638
  const currentSelAngle = isActiveSelection && activeObj ? ((activeObj.angle ?? 0) % 360 + 360) % 360 : 0;
14604
14639
  const angleDelta = Math.min(
@@ -14606,7 +14641,7 @@ const PageCanvas = forwardRef(
14606
14641
  360 - Math.abs(currentSelAngle - startSelAngle)
14607
14642
  );
14608
14643
  const hadRotation = isActiveSelection && activeObj && angleDelta > 0.01;
14609
- if (!hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
14644
+ if (!isActiveSelectionSideResize && !hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
14610
14645
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14611
14646
  const newLeft = (groupToMove.left ?? 0) + deltaX;
14612
14647
  const newTop = (groupToMove.top ?? 0) + deltaY;
@@ -24212,9 +24247,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24212
24247
  }
24213
24248
  return svgString;
24214
24249
  }
24215
- const resolvedPackageVersion = "0.5.329";
24250
+ const resolvedPackageVersion = "0.5.330";
24216
24251
  const PACKAGE_VERSION = resolvedPackageVersion;
24217
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.329";
24252
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.330";
24218
24253
  const roundParityValue = (value) => {
24219
24254
  if (typeof value !== "number") return value;
24220
24255
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25028,7 +25063,7 @@ class PixldocsRenderer {
25028
25063
  await this.waitForCanvasScene(container, cloned, i);
25029
25064
  }
25030
25065
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25031
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BhmhaCT1.js");
25066
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BIkOnJF2.js");
25032
25067
  const prepared = preparePagesForExport(
25033
25068
  cloned.pages,
25034
25069
  canvasWidth,
@@ -27348,7 +27383,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27348
27383
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27349
27384
  sanitizeSvgTreeForPdf(svgToDraw);
27350
27385
  try {
27351
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BhmhaCT1.js");
27386
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BIkOnJF2.js");
27352
27387
  try {
27353
27388
  await logTextMeasurementDiagnostic(svgToDraw);
27354
27389
  } catch {
@@ -27748,4 +27783,4 @@ export {
27748
27783
  buildTeaserBlurFlatKeys as y,
27749
27784
  collectFontDescriptorsFromConfig as z
27750
27785
  };
27751
- //# sourceMappingURL=index-K53gPk1O.js.map
27786
+ //# sourceMappingURL=index-B6Ucv-_d.js.map