@pixldocs/canvas-renderer 0.5.325 → 0.5.327

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.
@@ -13754,24 +13754,10 @@ const PageCanvas = react.forwardRef(
13754
13754
  const isXSide = corner === "ml" || corner === "mr";
13755
13755
  const sAxis = isXSide ? Math.abs(obj.scaleX ?? 1) : Math.abs(obj.scaleY ?? 1);
13756
13756
  if (sAxis > 1e-3) {
13757
- const childAnglesNorm = obj.getObjects().map((c) => {
13758
- const a = (c.angle ?? 0) % 360;
13759
- return a < 0 ? a + 360 : a;
13757
+ const hasRotatedChild = obj.getObjects().some((c) => {
13758
+ const a = ((c.angle ?? 0) % 180 + 180) % 180;
13759
+ return !(a < 0.5 || a > 179.5);
13760
13760
  });
13761
- const baseAngle = childAnglesNorm[0] ?? 0;
13762
- const hasMixedRotation = childAnglesNorm.some(
13763
- (a) => Math.abs(a - baseAngle) > 0.5 && Math.abs(Math.abs(a - baseAngle) - 360) > 0.5
13764
- );
13765
- if (hasMixedRotation) {
13766
- if (isXSide) {
13767
- obj._set("scaleY", obj.scaleX ?? 1);
13768
- } else {
13769
- obj._set("scaleX", obj.scaleY ?? 1);
13770
- }
13771
- obj.setCoords();
13772
- obj.dirty = true;
13773
- return;
13774
- }
13775
13761
  if (isXSide && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13776
13762
  groupShiftReflowSnapshotRef.current = null;
13777
13763
  const logicalGroupId = obj.__pixldocsGroupSelection;
@@ -13807,7 +13793,7 @@ const PageCanvas = react.forwardRef(
13807
13793
  const asTop0 = obj.top ?? 0;
13808
13794
  const asRect0 = obj.getBoundingRect();
13809
13795
  let didReflowTextChild = false;
13810
- for (const child of obj.getObjects()) {
13796
+ for (const child of hasRotatedChild ? [] : obj.getObjects()) {
13811
13797
  if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_d = child._ct) == null ? void 0 : _d.isCropGroup))) {
13812
13798
  const ct = child.__cropData;
13813
13799
  if (!ct) continue;
@@ -13978,6 +13964,15 @@ const PageCanvas = react.forwardRef(
13978
13964
  obj._set("width", asW0);
13979
13965
  obj._set("scaleX", asSx0);
13980
13966
  obj._set("scaleY", asSy0);
13967
+ if (hasRotatedChild) {
13968
+ if (isXSide) {
13969
+ obj._set("width", asW0 * sAxis);
13970
+ obj._set("scaleX", 1);
13971
+ } else {
13972
+ obj._set("height", asH0 * sAxis);
13973
+ obj._set("scaleY", 1);
13974
+ }
13975
+ }
13981
13976
  obj.setCoords();
13982
13977
  obj.dirty = true;
13983
13978
  }
@@ -14796,6 +14791,9 @@ const PageCanvas = react.forwardRef(
14796
14791
  let finalScaleX = decomposed.scaleX;
14797
14792
  let finalScaleY = decomposed.scaleY;
14798
14793
  let finalAbsoluteMatrix = absoluteMatrix;
14794
+ let finalAngle = decomposed.angle;
14795
+ let finalSkewX = decomposed.skewX;
14796
+ let finalSkewY = decomposed.skewY;
14799
14797
  if (obj instanceof fabric__namespace.Group && obj.__cropGroup) {
14800
14798
  const ct = obj.__cropData;
14801
14799
  if (ct) {
@@ -14852,6 +14850,11 @@ const PageCanvas = react.forwardRef(
14852
14850
  finalHeight = bakedH;
14853
14851
  finalScaleX = 1;
14854
14852
  finalScaleY = 1;
14853
+ if (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb") {
14854
+ finalAngle = (sourceElement == null ? void 0 : sourceElement.angle) ?? obj.angle ?? decomposed.angle;
14855
+ finalSkewX = (sourceElement == null ? void 0 : sourceElement.skewX) ?? obj.skewX ?? 0;
14856
+ finalSkewY = (sourceElement == null ? void 0 : sourceElement.skewY) ?? obj.skewY ?? 0;
14857
+ }
14855
14858
  obj.set({ scaleX: 1, scaleY: 1 });
14856
14859
  const newSrc = renderSmartElementToDataUri(sourceElement.smartElementType, sourceElement.smartProps, bakedW, bakedH);
14857
14860
  if (newSrc) {
@@ -14902,20 +14905,7 @@ const PageCanvas = react.forwardRef(
14902
14905
  obj.set({ scaleX: localScaleX, scaleY: localScaleY });
14903
14906
  const selectionMatrix = (_g = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _g.call(activeObj);
14904
14907
  const localCenter = selectionMatrix ? fabric__namespace.util.transformPoint(preBakeCenter, fabric__namespace.util.invertTransform(selectionMatrix)) : preBakeCenter;
14905
- const localWidth = bakedW * localScaleX;
14906
- const localHeight = bakedH * localScaleY;
14907
- const isCenterOrigin = obj.originX === "center" || obj.originY === "center";
14908
- if (isCenterOrigin) {
14909
- obj.set({
14910
- left: localCenter.x,
14911
- top: localCenter.y
14912
- });
14913
- } else {
14914
- obj.set({
14915
- left: localCenter.x - localWidth / 2,
14916
- top: localCenter.y - localHeight / 2
14917
- });
14918
- }
14908
+ obj.setPositionByOrigin(localCenter, "center", "center");
14919
14909
  }
14920
14910
  obj.dirty = true;
14921
14911
  if (activeObj) activeObj.dirty = true;
@@ -14926,33 +14916,29 @@ const PageCanvas = react.forwardRef(
14926
14916
  finalHeight = bakedH;
14927
14917
  finalScaleX = 1;
14928
14918
  finalScaleY = 1;
14919
+ if (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb") {
14920
+ finalAngle = (sourceElement == null ? void 0 : sourceElement.angle) ?? obj.angle ?? decomposed.angle;
14921
+ finalSkewX = (sourceElement == null ? void 0 : sourceElement.skewX) ?? obj.skewX ?? 0;
14922
+ finalSkewY = (sourceElement == null ? void 0 : sourceElement.skewY) ?? obj.skewY ?? 0;
14923
+ }
14929
14924
  try {
14930
- const angleRad = (decomposed.angle ?? 0) * Math.PI / 180;
14925
+ const angleRad = (finalAngle ?? 0) * Math.PI / 180;
14931
14926
  const cos = Math.cos(angleRad);
14932
14927
  const sin = Math.sin(angleRad);
14933
14928
  const hw = finalWidth / 2;
14934
14929
  const hh = finalHeight / 2;
14935
- const corners = [
14936
- { x: -hw, y: -hh },
14937
- { x: hw, y: -hh },
14938
- { x: hw, y: hh },
14939
- { x: -hw, y: hh }
14940
- ].map((p) => ({
14941
- x: decomposed.translateX + p.x * cos - p.y * sin,
14942
- y: decomposed.translateY + p.x * sin + p.y * cos
14943
- }));
14944
- absoluteLeft = Math.min(...corners.map((p) => p.x));
14945
- absoluteTop = Math.min(...corners.map((p) => p.y));
14930
+ absoluteLeft = decomposed.translateX - hw * cos + hh * sin;
14931
+ absoluteTop = decomposed.translateY - hw * sin - hh * cos;
14946
14932
  } catch {
14947
14933
  }
14948
14934
  finalAbsoluteMatrix = fabric__namespace.util.composeMatrix({
14949
14935
  translateX: decomposed.translateX,
14950
14936
  translateY: decomposed.translateY,
14951
- angle: decomposed.angle ?? 0,
14937
+ angle: finalAngle ?? 0,
14952
14938
  scaleX: 1,
14953
14939
  scaleY: 1,
14954
- skewX: 0,
14955
- skewY: 0
14940
+ skewX: finalSkewX ?? 0,
14941
+ skewY: finalSkewY ?? 0
14956
14942
  });
14957
14943
  } else {
14958
14944
  finalWidth = intrinsicWidth;
@@ -14963,6 +14949,11 @@ const PageCanvas = react.forwardRef(
14963
14949
  finalHeight = 0;
14964
14950
  finalScaleX = 1;
14965
14951
  finalScaleY = 1;
14952
+ if (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb") {
14953
+ finalAngle = (sourceElement == null ? void 0 : sourceElement.angle) ?? obj.angle ?? decomposed.angle;
14954
+ finalSkewX = (sourceElement == null ? void 0 : sourceElement.skewX) ?? obj.skewX ?? 0;
14955
+ finalSkewY = (sourceElement == null ? void 0 : sourceElement.skewY) ?? obj.skewY ?? 0;
14956
+ }
14966
14957
  } else if (obj instanceof fabric__namespace.Textbox && isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
14967
14958
  const sx = Math.abs(decomposed.scaleX || 1);
14968
14959
  const sy = Math.abs(decomposed.scaleY || 1);
@@ -15033,12 +15024,7 @@ const PageCanvas = react.forwardRef(
15033
15024
  obj.set({ scaleX: localScaleX, scaleY: localScaleY });
15034
15025
  const selectionMatrix = (_h = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _h.call(activeObj);
15035
15026
  const localCenter = selectionMatrix ? fabric__namespace.util.transformPoint(preBakeCenter, fabric__namespace.util.invertTransform(selectionMatrix)) : preBakeCenter;
15036
- const localWidth = bakedWidth * localScaleX;
15037
- const localHeight = (obj.height ?? intrinsicHeight) * localScaleY;
15038
- obj.set({
15039
- left: localCenter.x - localWidth / 2,
15040
- top: localCenter.y - localHeight / 2
15041
- });
15027
+ obj.setPositionByOrigin(localCenter, "center", "center");
15042
15028
  } else {
15043
15029
  obj.setPositionByOrigin(preBakeCenter, "center", "center");
15044
15030
  }
@@ -15051,32 +15037,23 @@ const PageCanvas = react.forwardRef(
15051
15037
  } catch {
15052
15038
  }
15053
15039
  try {
15054
- const angleRad = (decomposed.angle ?? 0) * Math.PI / 180;
15040
+ const angleRad = (finalAngle ?? 0) * Math.PI / 180;
15055
15041
  const cos = Math.cos(angleRad);
15056
15042
  const sin = Math.sin(angleRad);
15057
15043
  const hw = finalWidth / 2;
15058
15044
  const hh = finalHeight / 2;
15059
- const corners = [
15060
- { x: -hw, y: -hh },
15061
- { x: hw, y: -hh },
15062
- { x: hw, y: hh },
15063
- { x: -hw, y: hh }
15064
- ].map((p) => ({
15065
- x: decomposed.translateX + p.x * cos - p.y * sin,
15066
- y: decomposed.translateY + p.x * sin + p.y * cos
15067
- }));
15068
- absoluteLeft = Math.min(...corners.map((p) => p.x));
15069
- absoluteTop = Math.min(...corners.map((p) => p.y));
15045
+ absoluteLeft = decomposed.translateX - hw * cos + hh * sin;
15046
+ absoluteTop = decomposed.translateY - hw * sin - hh * cos;
15070
15047
  } catch {
15071
15048
  }
15072
15049
  finalAbsoluteMatrix = fabric__namespace.util.composeMatrix({
15073
15050
  translateX: decomposed.translateX,
15074
15051
  translateY: decomposed.translateY,
15075
- angle: decomposed.angle ?? 0,
15052
+ angle: finalAngle ?? 0,
15076
15053
  scaleX: 1,
15077
15054
  scaleY: 1,
15078
- skewX: 0,
15079
- skewY: 0
15055
+ skewX: finalSkewX ?? 0,
15056
+ skewY: finalSkewY ?? 0
15080
15057
  });
15081
15058
  if (debugGroupTextCornerResize) {
15082
15059
  logGroupTextResizeDebug("text-bake", {
@@ -15143,9 +15120,9 @@ const PageCanvas = react.forwardRef(
15143
15120
  // so finalWidth already reflects the new width chosen by the user.
15144
15121
  width: finalWidth,
15145
15122
  height: isLineObj ? 0 : isAutoShrinkText ? typeof autoShrinkStoredHeight === "number" ? autoShrinkStoredHeight : finalHeight : finalHeight,
15146
- angle: decomposed.angle,
15147
- skewX: isLineObj ? 0 : decomposed.skewX,
15148
- skewY: isLineObj ? 0 : decomposed.skewY,
15123
+ angle: finalAngle,
15124
+ skewX: isLineObj ? 0 : finalSkewX,
15125
+ skewY: isLineObj ? 0 : finalSkewY,
15149
15126
  scaleX: finalScaleX,
15150
15127
  scaleY: finalScaleY,
15151
15128
  transformMatrix: finalAbsoluteMatrix
@@ -24299,9 +24276,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24299
24276
  }
24300
24277
  return svgString;
24301
24278
  }
24302
- const resolvedPackageVersion = "0.5.325";
24279
+ const resolvedPackageVersion = "0.5.327";
24303
24280
  const PACKAGE_VERSION = resolvedPackageVersion;
24304
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.325";
24281
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.327";
24305
24282
  const roundParityValue = (value) => {
24306
24283
  if (typeof value !== "number") return value;
24307
24284
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25115,7 +25092,7 @@ class PixldocsRenderer {
25115
25092
  await this.waitForCanvasScene(container, cloned, i);
25116
25093
  }
25117
25094
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25118
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DHtj2TRz.cjs"));
25095
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-wr9G37iK.cjs"));
25119
25096
  const prepared = preparePagesForExport(
25120
25097
  cloned.pages,
25121
25098
  canvasWidth,
@@ -27435,7 +27412,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27435
27412
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27436
27413
  sanitizeSvgTreeForPdf(svgToDraw);
27437
27414
  try {
27438
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DHtj2TRz.cjs"));
27415
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-wr9G37iK.cjs"));
27439
27416
  try {
27440
27417
  await logTextMeasurementDiagnostic(svgToDraw);
27441
27418
  } catch {
@@ -27832,4 +27809,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27832
27809
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27833
27810
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27834
27811
  exports.warmTemplateFromForm = warmTemplateFromForm;
27835
- //# sourceMappingURL=index-BeSkXpzz.cjs.map
27812
+ //# sourceMappingURL=index-CAK9gioW.cjs.map