@pixldocs/canvas-renderer 0.5.331 → 0.5.332

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.
@@ -13761,7 +13761,10 @@ const PageCanvas = react.forwardRef(
13761
13761
  const a = ((c.angle ?? 0) % 180 + 180) % 180;
13762
13762
  return !(a < 0.5 || a > 179.5);
13763
13763
  });
13764
- if ((isXSide || hasRotatedChild) && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13764
+ const selectionAngle = ((obj.angle ?? 0) % 180 + 180) % 180;
13765
+ const isSelectionRotated = !(selectionAngle < 0.5 || selectionAngle > 179.5);
13766
+ const shouldPinNonTextChildren = hasRotatedChild || isSelectionRotated;
13767
+ if ((isXSide || shouldPinNonTextChildren) && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13765
13768
  groupShiftReflowSnapshotRef.current = null;
13766
13769
  const logicalGroupId = obj.__pixldocsGroupSelection;
13767
13770
  if (logicalGroupId) {
@@ -13808,16 +13811,31 @@ const PageCanvas = react.forwardRef(
13808
13811
  }
13809
13812
  }
13810
13813
  const childCounterScale = hasRotatedChild ? 1 : 1 / sAxis;
13814
+ let restoredNonTextAfterLayout = false;
13811
13815
  const restoreNonTextChildren = (pins) => {
13812
13816
  var _a3, _b3;
13813
- if (!hasRotatedChild || ((_a3 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _a3.selection) !== obj) return;
13817
+ if (!shouldPinNonTextChildren || ((_a3 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _a3.selection) !== obj) return;
13814
13818
  for (const entry of groupShiftReflowSnapshotRef.current.children) {
13815
13819
  const child = entry.obj;
13816
13820
  if (child instanceof fabric__namespace.Textbox) continue;
13817
13821
  if (child instanceof fabric__namespace.FabricImage || child instanceof fabric__namespace.Group && (child.__cropGroup || ((_b3 = child._ct) == null ? void 0 : _b3.isCropGroup))) {
13818
13822
  const pin = pins == null ? void 0 : pins.get(child);
13819
- const targetLeft = (pin == null ? void 0 : pin.left) ?? (isXSide ? entry.left0 * sAxis : entry.left0);
13820
- const targetTop = (pin == null ? void 0 : pin.top) ?? (isXSide ? entry.top0 : entry.top0 * sAxis);
13823
+ let targetLeft = hasRotatedChild && isXSide ? entry.left0 * sAxis : entry.left0;
13824
+ let targetTop = hasRotatedChild && !isXSide ? entry.top0 * sAxis : entry.top0;
13825
+ if (pin == null ? void 0 : pin.worldCenter) {
13826
+ try {
13827
+ const invSelectionMatrix = fabric__namespace.util.invertTransform(obj.calcTransformMatrix());
13828
+ const localCenter = fabric__namespace.util.transformPoint(pin.worldCenter, invSelectionMatrix);
13829
+ targetLeft = localCenter.x;
13830
+ targetTop = localCenter.y;
13831
+ } catch {
13832
+ targetLeft = pin.left ?? targetLeft;
13833
+ targetTop = pin.top ?? targetTop;
13834
+ }
13835
+ } else {
13836
+ targetLeft = (pin == null ? void 0 : pin.left) ?? targetLeft;
13837
+ targetTop = (pin == null ? void 0 : pin.top) ?? targetTop;
13838
+ }
13821
13839
  if (Math.abs((child.left ?? 0) - targetLeft) > 0.01) child._set("left", targetLeft);
13822
13840
  if (Math.abs((child.top ?? 0) - targetTop) > 0.01) child._set("top", targetTop);
13823
13841
  if (isXSide) child._set("scaleX", childCounterScale);
@@ -13923,7 +13941,7 @@ const PageCanvas = react.forwardRef(
13923
13941
  didReflowTextChild = true;
13924
13942
  }
13925
13943
  }
13926
- if (isXSide && ((_e = groupShiftReflowSnapshotRef.current) == null ? void 0 : _e.selection) === obj) {
13944
+ if (isXSide && !shouldPinNonTextChildren && ((_e = groupShiftReflowSnapshotRef.current) == null ? void 0 : _e.selection) === obj) {
13927
13945
  const snap = groupShiftReflowSnapshotRef.current;
13928
13946
  const anchorEntry = snap.children[0];
13929
13947
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -13956,12 +13974,17 @@ const PageCanvas = react.forwardRef(
13956
13974
  if (cornersBefore) {
13957
13975
  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 };
13958
13976
  }
13959
- const nonTextPinsBeforeLayout = hasRotatedChild ? new Map(obj.getObjects().map((child) => [child, { left: child.left ?? 0, top: child.top ?? 0 }])) : void 0;
13977
+ const nonTextPinsBeforeLayout = shouldPinNonTextChildren ? new Map(obj.getObjects().map((child) => [child, {
13978
+ left: child.left ?? 0,
13979
+ top: child.top ?? 0,
13980
+ worldCenter: child instanceof fabric__namespace.Textbox ? void 0 : child.getCenterPoint()
13981
+ }])) : void 0;
13960
13982
  try {
13961
13983
  obj.triggerLayout();
13962
13984
  } catch {
13963
13985
  }
13964
13986
  restoreNonTextChildren(nonTextPinsBeforeLayout);
13987
+ restoredNonTextAfterLayout = !!nonTextPinsBeforeLayout;
13965
13988
  obj._set("width", asW0);
13966
13989
  obj._set("scaleX", asSx0);
13967
13990
  obj._set("scaleY", asSy0);
@@ -13987,7 +14010,7 @@ const PageCanvas = react.forwardRef(
13987
14010
  obj._set("left", asLeft0);
13988
14011
  obj._set("top", asTop0);
13989
14012
  }
13990
- restoreNonTextChildren();
14013
+ if (!restoredNonTextAfterLayout) restoreNonTextChildren();
13991
14014
  obj._set("width", asW0);
13992
14015
  obj._set("scaleX", asSx0);
13993
14016
  obj._set("scaleY", asSy0);
@@ -14811,11 +14834,17 @@ const PageCanvas = react.forwardRef(
14811
14834
  absoluteTop = (decomposed.translateY ?? absoluteTop ?? 0) - w / 2 * Math.sin(angleRad) - h / 2 * Math.cos(angleRad);
14812
14835
  }
14813
14836
  } else if (obj instanceof fabric__namespace.FabricImage && (obj.originX === "center" || obj.originY === "center")) {
14814
- const w = (obj.width ?? 0) * (obj.scaleX ?? 1);
14815
- const h = (obj.height ?? 0) * (obj.scaleY ?? 1);
14816
- const angleRad = (decomposed.angle ?? obj.angle ?? 0) * Math.PI / 180;
14817
- absoluteLeft = (decomposed.translateX ?? absoluteLeft ?? 0) - w / 2 * Math.cos(angleRad) + h / 2 * Math.sin(angleRad);
14818
- absoluteTop = (decomposed.translateY ?? absoluteTop ?? 0) - w / 2 * Math.sin(angleRad) - h / 2 * Math.cos(angleRad);
14837
+ if (isActiveSelection && activeObj instanceof fabric__namespace.ActiveSelection) {
14838
+ const frameBounds = getObjectFrameBoundsInSelection(activeObj, obj, obj.width ?? 0, obj.height ?? 0);
14839
+ absoluteLeft = frameBounds.left;
14840
+ absoluteTop = frameBounds.top;
14841
+ } else {
14842
+ const w = (obj.width ?? 0) * (obj.scaleX ?? 1);
14843
+ const h = (obj.height ?? 0) * (obj.scaleY ?? 1);
14844
+ const angleRad = (decomposed.angle ?? obj.angle ?? 0) * Math.PI / 180;
14845
+ absoluteLeft = (decomposed.translateX ?? absoluteLeft ?? 0) - w / 2 * Math.cos(angleRad) + h / 2 * Math.sin(angleRad);
14846
+ absoluteTop = (decomposed.translateY ?? absoluteTop ?? 0) - w / 2 * Math.sin(angleRad) - h / 2 * Math.cos(angleRad);
14847
+ }
14819
14848
  }
14820
14849
  const preserveCornerGeometry = (sourceElement == null ? void 0 : sourceElement.type) === "shape" && (sourceElement.shapeType === "circle" || sourceElement.shapeType === "rounded-rect" || sourceElement.shapeType === "triangle");
14821
14850
  let finalWidth = intrinsicWidth;
@@ -24314,9 +24343,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24314
24343
  }
24315
24344
  return svgString;
24316
24345
  }
24317
- const resolvedPackageVersion = "0.5.331";
24346
+ const resolvedPackageVersion = "0.5.332";
24318
24347
  const PACKAGE_VERSION = resolvedPackageVersion;
24319
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.331";
24348
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.332";
24320
24349
  const roundParityValue = (value) => {
24321
24350
  if (typeof value !== "number") return value;
24322
24351
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25130,7 +25159,7 @@ class PixldocsRenderer {
25130
25159
  await this.waitForCanvasScene(container, cloned, i);
25131
25160
  }
25132
25161
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25133
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-07IeD7w3.cjs"));
25162
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BnF6Lk4i.cjs"));
25134
25163
  const prepared = preparePagesForExport(
25135
25164
  cloned.pages,
25136
25165
  canvasWidth,
@@ -27450,7 +27479,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27450
27479
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27451
27480
  sanitizeSvgTreeForPdf(svgToDraw);
27452
27481
  try {
27453
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-07IeD7w3.cjs"));
27482
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BnF6Lk4i.cjs"));
27454
27483
  try {
27455
27484
  await logTextMeasurementDiagnostic(svgToDraw);
27456
27485
  } catch {
@@ -27847,4 +27876,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27847
27876
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27848
27877
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27849
27878
  exports.warmTemplateFromForm = warmTemplateFromForm;
27850
- //# sourceMappingURL=index-COZR9zOa.cjs.map
27879
+ //# sourceMappingURL=index-B9Lpo1N6.cjs.map