@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.
@@ -13758,7 +13758,7 @@ const PageCanvas = react.forwardRef(
13758
13758
  const a = ((c.angle ?? 0) % 180 + 180) % 180;
13759
13759
  return !(a < 0.5 || a > 179.5);
13760
13760
  });
13761
- if (isXSide && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13761
+ if ((isXSide || hasRotatedChild) && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13762
13762
  groupShiftReflowSnapshotRef.current = null;
13763
13763
  const logicalGroupId = obj.__pixldocsGroupSelection;
13764
13764
  if (logicalGroupId) {
@@ -13770,7 +13770,9 @@ const PageCanvas = react.forwardRef(
13770
13770
  const entries = obj.getObjects().map((c) => ({
13771
13771
  obj: c,
13772
13772
  id: getObjectId(c) ?? "",
13773
+ left0: c.left ?? 0,
13773
13774
  top0: c.top ?? 0,
13775
+ width0: (c.width ?? 0) * Math.abs(c.scaleX ?? 1),
13774
13776
  height0: (c.height ?? 0) * Math.abs(c.scaleY ?? 1)
13775
13777
  })).filter((e2) => e2.id).sort((a, b) => a.top0 - b.top0);
13776
13778
  if (entries.length > 1) {
@@ -13803,6 +13805,33 @@ const PageCanvas = react.forwardRef(
13803
13805
  }
13804
13806
  }
13805
13807
  const childCounterScale = hasRotatedChild ? 1 : 1 / sAxis;
13808
+ const restoreNonTextChildren = (pins) => {
13809
+ var _a3, _b3;
13810
+ if (!hasRotatedChild || ((_a3 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _a3.selection) !== obj) return;
13811
+ for (const entry of groupShiftReflowSnapshotRef.current.children) {
13812
+ const child = entry.obj;
13813
+ if (child instanceof fabric__namespace.Textbox) continue;
13814
+ if (child instanceof fabric__namespace.FabricImage || child instanceof fabric__namespace.Group && (child.__cropGroup || ((_b3 = child._ct) == null ? void 0 : _b3.isCropGroup))) {
13815
+ const pin = pins == null ? void 0 : pins.get(child);
13816
+ const targetLeft = (pin == null ? void 0 : pin.left) ?? (isXSide ? entry.left0 * sAxis : entry.left0);
13817
+ const targetTop = (pin == null ? void 0 : pin.top) ?? (isXSide ? entry.top0 : entry.top0 * sAxis);
13818
+ if (Math.abs((child.left ?? 0) - targetLeft) > 0.01) child._set("left", targetLeft);
13819
+ if (Math.abs((child.top ?? 0) - targetTop) > 0.01) child._set("top", targetTop);
13820
+ if (isXSide) child._set("scaleX", childCounterScale);
13821
+ else child._set("scaleY", childCounterScale);
13822
+ child.setCoords();
13823
+ child.dirty = true;
13824
+ }
13825
+ }
13826
+ };
13827
+ const projectRotatedTextPosition = (child) => {
13828
+ var _a3;
13829
+ if (!hasRotatedChild || ((_a3 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _a3.selection) !== obj) return;
13830
+ const entry = groupShiftReflowSnapshotRef.current.children.find((candidate) => candidate.obj === child);
13831
+ if (!entry) return;
13832
+ if (isXSide) child._set("left", entry.left0 * sAxis);
13833
+ else child._set("top", entry.top0 * sAxis);
13834
+ };
13806
13835
  for (const child of obj.getObjects()) {
13807
13836
  if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_d = child._ct) == null ? void 0 : _d.isCropGroup))) {
13808
13837
  if (isXSide) child._set("scaleX", childCounterScale);
@@ -13819,6 +13848,7 @@ const PageCanvas = react.forwardRef(
13819
13848
  continue;
13820
13849
  }
13821
13850
  if (!(child instanceof fabric__namespace.Textbox)) continue;
13851
+ projectRotatedTextPosition(child);
13822
13852
  if (isXSide) {
13823
13853
  if (child.__asLiveOrigW == null) {
13824
13854
  child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
@@ -13886,10 +13916,12 @@ const PageCanvas = react.forwardRef(
13886
13916
  if (cornersBefore) {
13887
13917
  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 };
13888
13918
  }
13919
+ const nonTextPinsBeforeLayout = hasRotatedChild ? new Map(obj.getObjects().map((child) => [child, { left: child.left ?? 0, top: child.top ?? 0 }])) : void 0;
13889
13920
  try {
13890
13921
  obj.triggerLayout();
13891
13922
  } catch {
13892
13923
  }
13924
+ restoreNonTextChildren(nonTextPinsBeforeLayout);
13893
13925
  obj._set("width", asW0);
13894
13926
  obj._set("scaleX", asSx0);
13895
13927
  obj._set("scaleY", asSy0);
@@ -13915,6 +13947,7 @@ const PageCanvas = react.forwardRef(
13915
13947
  obj._set("left", asLeft0);
13916
13948
  obj._set("top", asTop0);
13917
13949
  }
13950
+ restoreNonTextChildren();
13918
13951
  obj._set("width", asW0);
13919
13952
  obj._set("scaleX", asSx0);
13920
13953
  obj._set("scaleY", asSy0);
@@ -14555,6 +14588,7 @@ const PageCanvas = react.forwardRef(
14555
14588
  return;
14556
14589
  }
14557
14590
  }
14591
+ const isActiveSelectionSideResize = isActiveSelection && (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb");
14558
14592
  if (selectedElementIds.length > 0 && !anyCropGroup) {
14559
14593
  const firstObj = activeObjects[0];
14560
14594
  const firstId = getObjectId(firstObj);
@@ -14616,7 +14650,8 @@ const PageCanvas = react.forwardRef(
14616
14650
  }
14617
14651
  const deltaX = movedGroupLeft - groupAbs.left;
14618
14652
  const deltaY = movedGroupTop - groupAbs.top;
14619
- const hadScale = isActiveSelection && activeObj && (Math.abs((activeObj.scaleX ?? 1) - 1) > 0.01 || Math.abs((activeObj.scaleY ?? 1) - 1) > 0.01);
14653
+ const hadResizeHandle = isActiveSelection && !!activeSelectionResizeHandle;
14654
+ const hadScale = isActiveSelection && activeObj && (hadResizeHandle || Math.abs((activeObj.scaleX ?? 1) - 1) > 0.01 || Math.abs((activeObj.scaleY ?? 1) - 1) > 0.01);
14620
14655
  const startSelAngle = (((transformStart == null ? void 0 : transformStart.selectionAngle) ?? 0) % 360 + 360) % 360;
14621
14656
  const currentSelAngle = isActiveSelection && activeObj ? ((activeObj.angle ?? 0) % 360 + 360) % 360 : 0;
14622
14657
  const angleDelta = Math.min(
@@ -14624,7 +14659,7 @@ const PageCanvas = react.forwardRef(
14624
14659
  360 - Math.abs(currentSelAngle - startSelAngle)
14625
14660
  );
14626
14661
  const hadRotation = isActiveSelection && activeObj && angleDelta > 0.01;
14627
- if (!hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
14662
+ if (!isActiveSelectionSideResize && !hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
14628
14663
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14629
14664
  const newLeft = (groupToMove.left ?? 0) + deltaX;
14630
14665
  const newTop = (groupToMove.top ?? 0) + deltaY;
@@ -24230,9 +24265,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24230
24265
  }
24231
24266
  return svgString;
24232
24267
  }
24233
- const resolvedPackageVersion = "0.5.329";
24268
+ const resolvedPackageVersion = "0.5.330";
24234
24269
  const PACKAGE_VERSION = resolvedPackageVersion;
24235
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.329";
24270
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.330";
24236
24271
  const roundParityValue = (value) => {
24237
24272
  if (typeof value !== "number") return value;
24238
24273
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25046,7 +25081,7 @@ class PixldocsRenderer {
25046
25081
  await this.waitForCanvasScene(container, cloned, i);
25047
25082
  }
25048
25083
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25049
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DNaP0TIk.cjs"));
25084
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CJBVK7bd.cjs"));
25050
25085
  const prepared = preparePagesForExport(
25051
25086
  cloned.pages,
25052
25087
  canvasWidth,
@@ -27366,7 +27401,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27366
27401
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27367
27402
  sanitizeSvgTreeForPdf(svgToDraw);
27368
27403
  try {
27369
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DNaP0TIk.cjs"));
27404
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CJBVK7bd.cjs"));
27370
27405
  try {
27371
27406
  await logTextMeasurementDiagnostic(svgToDraw);
27372
27407
  } catch {
@@ -27763,4 +27798,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27763
27798
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27764
27799
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27765
27800
  exports.warmTemplateFromForm = warmTemplateFromForm;
27766
- //# sourceMappingURL=index-_B1EJq7R.cjs.map
27801
+ //# sourceMappingURL=index-DyarJoo_.cjs.map