@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.
@@ -11366,6 +11366,7 @@ const PageCanvas = react.forwardRef(
11366
11366
  const lastTextEditDimensionsRef = react.useRef(null);
11367
11367
  const lastResizeScaleTargetRef = react.useRef(null);
11368
11368
  const activeSelectionResizeHandleRef = react.useRef(null);
11369
+ const groupShiftReflowSnapshotRef = react.useRef(null);
11369
11370
  const preserveSelectionAfterTransformIdRef = react.useRef(null);
11370
11371
  const groupSelectionTransformStartRef = react.useRef(null);
11371
11372
  const activeSelectionMoveStartRef = react.useRef(null);
@@ -13523,7 +13524,7 @@ const PageCanvas = react.forwardRef(
13523
13524
  fabricCanvas.on("selection:cleared", () => {
13524
13525
  });
13525
13526
  fabricCanvas.on("object:scaling", (e) => {
13526
- var _a2, _b2, _c;
13527
+ var _a2, _b2, _c, _d, _e, _f;
13527
13528
  if (!isActiveRef.current) return;
13528
13529
  const t = e.target;
13529
13530
  if (t) lastResizeScaleTargetRef.current = t;
@@ -13700,6 +13701,33 @@ const PageCanvas = react.forwardRef(
13700
13701
  const isXSide = corner === "ml" || corner === "mr";
13701
13702
  const sAxis = isXSide ? Math.abs(obj.scaleX ?? 1) : Math.abs(obj.scaleY ?? 1);
13702
13703
  if (sAxis > 1e-3) {
13704
+ if (isXSide && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13705
+ groupShiftReflowSnapshotRef.current = null;
13706
+ const logicalGroupId = obj.__pixldocsGroupSelection;
13707
+ if (logicalGroupId) {
13708
+ try {
13709
+ const state = useEditorStore.getState();
13710
+ const pageChildren2 = ((_c = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _c.children) ?? [];
13711
+ const groupNode = findNodeById(pageChildren2, logicalGroupId);
13712
+ if (groupNode && isGroup(groupNode) && !isStackLayoutMode(groupNode.layoutMode)) {
13713
+ const entries = obj.getObjects().map((c) => ({
13714
+ obj: c,
13715
+ id: getObjectId(c) ?? "",
13716
+ top0: c.top ?? 0,
13717
+ height0: (c.height ?? 0) * Math.abs(c.scaleY ?? 1)
13718
+ })).filter((e2) => e2.id).sort((a, b) => a.top0 - b.top0);
13719
+ if (entries.length > 1) {
13720
+ const gaps = [];
13721
+ for (let i = 1; i < entries.length; i++) {
13722
+ gaps.push(Math.max(0, entries[i].top0 - (entries[i - 1].top0 + entries[i - 1].height0)));
13723
+ }
13724
+ groupShiftReflowSnapshotRef.current = { selection: obj, groupId: logicalGroupId, children: entries, gaps };
13725
+ }
13726
+ }
13727
+ } catch {
13728
+ }
13729
+ }
13730
+ }
13703
13731
  const asW0 = obj.width ?? 0;
13704
13732
  const asH0 = obj.height ?? 0;
13705
13733
  const asSx0 = obj.scaleX ?? 1;
@@ -13709,7 +13737,7 @@ const PageCanvas = react.forwardRef(
13709
13737
  const asRect0 = obj.getBoundingRect();
13710
13738
  let didReflowTextChild = false;
13711
13739
  for (const child of obj.getObjects()) {
13712
- if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_b2 = child._ct) == null ? void 0 : _b2.isCropGroup))) {
13740
+ if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_d = child._ct) == null ? void 0 : _d.isCropGroup))) {
13713
13741
  const ct = child.__cropData;
13714
13742
  if (!ct) continue;
13715
13743
  if (isXSide) {
@@ -13814,6 +13842,34 @@ const PageCanvas = react.forwardRef(
13814
13842
  didReflowTextChild = true;
13815
13843
  }
13816
13844
  }
13845
+ if (isXSide && ((_e = groupShiftReflowSnapshotRef.current) == null ? void 0 : _e.selection) === obj) {
13846
+ const snap = groupShiftReflowSnapshotRef.current;
13847
+ const anchorEntry = snap.children[0];
13848
+ const anchorTopLive = anchorEntry.obj.top ?? 0;
13849
+ const anchorTop0 = anchorEntry.top0;
13850
+ const liveHeightOf = (entry) => {
13851
+ const c = entry.obj;
13852
+ if (c instanceof fabric__namespace.Textbox) return c.height ?? entry.height0;
13853
+ return (c.height ?? entry.height0) * Math.abs(c.scaleY ?? 1);
13854
+ };
13855
+ let prevBottom = anchorTopLive + liveHeightOf(anchorEntry);
13856
+ let didShift = false;
13857
+ for (let i = 1; i < snap.children.length; i++) {
13858
+ const entry = snap.children[i];
13859
+ const c = entry.obj;
13860
+ const naturalTop = anchorTopLive + (entry.top0 - anchorTop0);
13861
+ const minTop = prevBottom + snap.gaps[i - 1];
13862
+ const targetTop = Math.max(naturalTop, minTop);
13863
+ if (Math.abs((c.top ?? 0) - targetTop) > 0.5) {
13864
+ c._set("top", targetTop);
13865
+ c.setCoords();
13866
+ c.dirty = true;
13867
+ didShift = true;
13868
+ }
13869
+ prevBottom = targetTop + liveHeightOf(entry);
13870
+ }
13871
+ if (didShift) didReflowTextChild = true;
13872
+ }
13817
13873
  if (isXSide && didReflowTextChild && typeof obj.triggerLayout === "function") {
13818
13874
  try {
13819
13875
  obj.triggerLayout();
@@ -13927,7 +13983,7 @@ const PageCanvas = react.forwardRef(
13927
13983
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
13928
13984
  if (drilledGroupIdRef.current) {
13929
13985
  try {
13930
- (_c = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _c.call(fabricCanvas);
13986
+ (_f = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _f.call(fabricCanvas);
13931
13987
  } catch {
13932
13988
  }
13933
13989
  }
@@ -14134,6 +14190,7 @@ const PageCanvas = react.forwardRef(
14134
14190
  }
14135
14191
  } catch {
14136
14192
  }
14193
+ groupShiftReflowSnapshotRef.current = null;
14137
14194
  lockEdits();
14138
14195
  const modifiedTarget = e.target;
14139
14196
  const modifiedTargetId = modifiedTarget ? getObjectId(modifiedTarget) : null;
@@ -24122,9 +24179,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24122
24179
  }
24123
24180
  return svgString;
24124
24181
  }
24125
- const resolvedPackageVersion = "0.5.302";
24182
+ const resolvedPackageVersion = "0.5.304";
24126
24183
  const PACKAGE_VERSION = resolvedPackageVersion;
24127
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.302";
24184
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.304";
24128
24185
  const roundParityValue = (value) => {
24129
24186
  if (typeof value !== "number") return value;
24130
24187
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24938,7 +24995,7 @@ class PixldocsRenderer {
24938
24995
  await this.waitForCanvasScene(container, cloned, i);
24939
24996
  }
24940
24997
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24941
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DXYVw9V2.cjs"));
24998
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BwdX7s-7.cjs"));
24942
24999
  const prepared = preparePagesForExport(
24943
25000
  cloned.pages,
24944
25001
  canvasWidth,
@@ -27258,7 +27315,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27258
27315
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27259
27316
  sanitizeSvgTreeForPdf(svgToDraw);
27260
27317
  try {
27261
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DXYVw9V2.cjs"));
27318
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BwdX7s-7.cjs"));
27262
27319
  try {
27263
27320
  await logTextMeasurementDiagnostic(svgToDraw);
27264
27321
  } catch {
@@ -27655,4 +27712,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27655
27712
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27656
27713
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27657
27714
  exports.warmTemplateFromForm = warmTemplateFromForm;
27658
- //# sourceMappingURL=index-Basn7lBW.cjs.map
27715
+ //# sourceMappingURL=index-C4r2zesf.cjs.map