@pixldocs/canvas-renderer 0.5.302 → 0.5.304

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.
@@ -11348,6 +11348,7 @@ const PageCanvas = forwardRef(
11348
11348
  const lastTextEditDimensionsRef = useRef(null);
11349
11349
  const lastResizeScaleTargetRef = useRef(null);
11350
11350
  const activeSelectionResizeHandleRef = useRef(null);
11351
+ const groupShiftReflowSnapshotRef = useRef(null);
11351
11352
  const preserveSelectionAfterTransformIdRef = useRef(null);
11352
11353
  const groupSelectionTransformStartRef = useRef(null);
11353
11354
  const activeSelectionMoveStartRef = useRef(null);
@@ -13505,7 +13506,7 @@ const PageCanvas = forwardRef(
13505
13506
  fabricCanvas.on("selection:cleared", () => {
13506
13507
  });
13507
13508
  fabricCanvas.on("object:scaling", (e) => {
13508
- var _a2, _b2, _c;
13509
+ var _a2, _b2, _c, _d, _e, _f;
13509
13510
  if (!isActiveRef.current) return;
13510
13511
  const t = e.target;
13511
13512
  if (t) lastResizeScaleTargetRef.current = t;
@@ -13682,6 +13683,33 @@ const PageCanvas = forwardRef(
13682
13683
  const isXSide = corner === "ml" || corner === "mr";
13683
13684
  const sAxis = isXSide ? Math.abs(obj.scaleX ?? 1) : Math.abs(obj.scaleY ?? 1);
13684
13685
  if (sAxis > 1e-3) {
13686
+ if (isXSide && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13687
+ groupShiftReflowSnapshotRef.current = null;
13688
+ const logicalGroupId = obj.__pixldocsGroupSelection;
13689
+ if (logicalGroupId) {
13690
+ try {
13691
+ const state = useEditorStore.getState();
13692
+ const pageChildren2 = ((_c = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _c.children) ?? [];
13693
+ const groupNode = findNodeById(pageChildren2, logicalGroupId);
13694
+ if (groupNode && isGroup(groupNode) && !isStackLayoutMode(groupNode.layoutMode)) {
13695
+ const entries = obj.getObjects().map((c) => ({
13696
+ obj: c,
13697
+ id: getObjectId(c) ?? "",
13698
+ top0: c.top ?? 0,
13699
+ height0: (c.height ?? 0) * Math.abs(c.scaleY ?? 1)
13700
+ })).filter((e2) => e2.id).sort((a, b) => a.top0 - b.top0);
13701
+ if (entries.length > 1) {
13702
+ const gaps = [];
13703
+ for (let i = 1; i < entries.length; i++) {
13704
+ gaps.push(Math.max(0, entries[i].top0 - (entries[i - 1].top0 + entries[i - 1].height0)));
13705
+ }
13706
+ groupShiftReflowSnapshotRef.current = { selection: obj, groupId: logicalGroupId, children: entries, gaps };
13707
+ }
13708
+ }
13709
+ } catch {
13710
+ }
13711
+ }
13712
+ }
13685
13713
  const asW0 = obj.width ?? 0;
13686
13714
  const asH0 = obj.height ?? 0;
13687
13715
  const asSx0 = obj.scaleX ?? 1;
@@ -13691,7 +13719,7 @@ const PageCanvas = forwardRef(
13691
13719
  const asRect0 = obj.getBoundingRect();
13692
13720
  let didReflowTextChild = false;
13693
13721
  for (const child of obj.getObjects()) {
13694
- if (child instanceof fabric.Group && (child.__cropGroup || ((_b2 = child._ct) == null ? void 0 : _b2.isCropGroup))) {
13722
+ if (child instanceof fabric.Group && (child.__cropGroup || ((_d = child._ct) == null ? void 0 : _d.isCropGroup))) {
13695
13723
  const ct = child.__cropData;
13696
13724
  if (!ct) continue;
13697
13725
  if (isXSide) {
@@ -13796,6 +13824,34 @@ const PageCanvas = forwardRef(
13796
13824
  didReflowTextChild = true;
13797
13825
  }
13798
13826
  }
13827
+ if (isXSide && ((_e = groupShiftReflowSnapshotRef.current) == null ? void 0 : _e.selection) === obj) {
13828
+ const snap = groupShiftReflowSnapshotRef.current;
13829
+ const anchorEntry = snap.children[0];
13830
+ const anchorTopLive = anchorEntry.obj.top ?? 0;
13831
+ const anchorTop0 = anchorEntry.top0;
13832
+ const liveHeightOf = (entry) => {
13833
+ const c = entry.obj;
13834
+ if (c instanceof fabric.Textbox) return c.height ?? entry.height0;
13835
+ return (c.height ?? entry.height0) * Math.abs(c.scaleY ?? 1);
13836
+ };
13837
+ let prevBottom = anchorTopLive + liveHeightOf(anchorEntry);
13838
+ let didShift = false;
13839
+ for (let i = 1; i < snap.children.length; i++) {
13840
+ const entry = snap.children[i];
13841
+ const c = entry.obj;
13842
+ const naturalTop = anchorTopLive + (entry.top0 - anchorTop0);
13843
+ const minTop = prevBottom + snap.gaps[i - 1];
13844
+ const targetTop = Math.max(naturalTop, minTop);
13845
+ if (Math.abs((c.top ?? 0) - targetTop) > 0.5) {
13846
+ c._set("top", targetTop);
13847
+ c.setCoords();
13848
+ c.dirty = true;
13849
+ didShift = true;
13850
+ }
13851
+ prevBottom = targetTop + liveHeightOf(entry);
13852
+ }
13853
+ if (didShift) didReflowTextChild = true;
13854
+ }
13799
13855
  if (isXSide && didReflowTextChild && typeof obj.triggerLayout === "function") {
13800
13856
  try {
13801
13857
  obj.triggerLayout();
@@ -13909,7 +13965,7 @@ const PageCanvas = forwardRef(
13909
13965
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
13910
13966
  if (drilledGroupIdRef.current) {
13911
13967
  try {
13912
- (_c = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _c.call(fabricCanvas);
13968
+ (_f = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _f.call(fabricCanvas);
13913
13969
  } catch {
13914
13970
  }
13915
13971
  }
@@ -14116,6 +14172,7 @@ const PageCanvas = forwardRef(
14116
14172
  }
14117
14173
  } catch {
14118
14174
  }
14175
+ groupShiftReflowSnapshotRef.current = null;
14119
14176
  lockEdits();
14120
14177
  const modifiedTarget = e.target;
14121
14178
  const modifiedTargetId = modifiedTarget ? getObjectId(modifiedTarget) : null;
@@ -24104,9 +24161,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24104
24161
  }
24105
24162
  return svgString;
24106
24163
  }
24107
- const resolvedPackageVersion = "0.5.302";
24164
+ const resolvedPackageVersion = "0.5.304";
24108
24165
  const PACKAGE_VERSION = resolvedPackageVersion;
24109
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.302";
24166
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.304";
24110
24167
  const roundParityValue = (value) => {
24111
24168
  if (typeof value !== "number") return value;
24112
24169
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24920,7 +24977,7 @@ class PixldocsRenderer {
24920
24977
  await this.waitForCanvasScene(container, cloned, i);
24921
24978
  }
24922
24979
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24923
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Bje676YF.js");
24980
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-M5_Qv3Nm.js");
24924
24981
  const prepared = preparePagesForExport(
24925
24982
  cloned.pages,
24926
24983
  canvasWidth,
@@ -27240,7 +27297,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27240
27297
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27241
27298
  sanitizeSvgTreeForPdf(svgToDraw);
27242
27299
  try {
27243
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Bje676YF.js");
27300
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-M5_Qv3Nm.js");
27244
27301
  try {
27245
27302
  await logTextMeasurementDiagnostic(svgToDraw);
27246
27303
  } catch {
@@ -27640,4 +27697,4 @@ export {
27640
27697
  buildTeaserBlurFlatKeys as y,
27641
27698
  collectFontDescriptorsFromConfig as z
27642
27699
  };
27643
- //# sourceMappingURL=index-ZeWTxoUj.js.map
27700
+ //# sourceMappingURL=index-Cxt1LQoh.js.map