@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.
@@ -13736,24 +13736,10 @@ const PageCanvas = forwardRef(
13736
13736
  const isXSide = corner === "ml" || corner === "mr";
13737
13737
  const sAxis = isXSide ? Math.abs(obj.scaleX ?? 1) : Math.abs(obj.scaleY ?? 1);
13738
13738
  if (sAxis > 1e-3) {
13739
- const childAnglesNorm = obj.getObjects().map((c) => {
13740
- const a = (c.angle ?? 0) % 360;
13741
- return a < 0 ? a + 360 : a;
13739
+ const hasRotatedChild = obj.getObjects().some((c) => {
13740
+ const a = ((c.angle ?? 0) % 180 + 180) % 180;
13741
+ return !(a < 0.5 || a > 179.5);
13742
13742
  });
13743
- const baseAngle = childAnglesNorm[0] ?? 0;
13744
- const hasMixedRotation = childAnglesNorm.some(
13745
- (a) => Math.abs(a - baseAngle) > 0.5 && Math.abs(Math.abs(a - baseAngle) - 360) > 0.5
13746
- );
13747
- if (hasMixedRotation) {
13748
- if (isXSide) {
13749
- obj._set("scaleY", obj.scaleX ?? 1);
13750
- } else {
13751
- obj._set("scaleX", obj.scaleY ?? 1);
13752
- }
13753
- obj.setCoords();
13754
- obj.dirty = true;
13755
- return;
13756
- }
13757
13743
  if (isXSide && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13758
13744
  groupShiftReflowSnapshotRef.current = null;
13759
13745
  const logicalGroupId = obj.__pixldocsGroupSelection;
@@ -13789,7 +13775,7 @@ const PageCanvas = forwardRef(
13789
13775
  const asTop0 = obj.top ?? 0;
13790
13776
  const asRect0 = obj.getBoundingRect();
13791
13777
  let didReflowTextChild = false;
13792
- for (const child of obj.getObjects()) {
13778
+ for (const child of hasRotatedChild ? [] : obj.getObjects()) {
13793
13779
  if (child instanceof fabric.Group && (child.__cropGroup || ((_d = child._ct) == null ? void 0 : _d.isCropGroup))) {
13794
13780
  const ct = child.__cropData;
13795
13781
  if (!ct) continue;
@@ -13960,6 +13946,15 @@ const PageCanvas = forwardRef(
13960
13946
  obj._set("width", asW0);
13961
13947
  obj._set("scaleX", asSx0);
13962
13948
  obj._set("scaleY", asSy0);
13949
+ if (hasRotatedChild) {
13950
+ if (isXSide) {
13951
+ obj._set("width", asW0 * sAxis);
13952
+ obj._set("scaleX", 1);
13953
+ } else {
13954
+ obj._set("height", asH0 * sAxis);
13955
+ obj._set("scaleY", 1);
13956
+ }
13957
+ }
13963
13958
  obj.setCoords();
13964
13959
  obj.dirty = true;
13965
13960
  }
@@ -14778,6 +14773,9 @@ const PageCanvas = forwardRef(
14778
14773
  let finalScaleX = decomposed.scaleX;
14779
14774
  let finalScaleY = decomposed.scaleY;
14780
14775
  let finalAbsoluteMatrix = absoluteMatrix;
14776
+ let finalAngle = decomposed.angle;
14777
+ let finalSkewX = decomposed.skewX;
14778
+ let finalSkewY = decomposed.skewY;
14781
14779
  if (obj instanceof fabric.Group && obj.__cropGroup) {
14782
14780
  const ct = obj.__cropData;
14783
14781
  if (ct) {
@@ -14834,6 +14832,11 @@ const PageCanvas = forwardRef(
14834
14832
  finalHeight = bakedH;
14835
14833
  finalScaleX = 1;
14836
14834
  finalScaleY = 1;
14835
+ if (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb") {
14836
+ finalAngle = (sourceElement == null ? void 0 : sourceElement.angle) ?? obj.angle ?? decomposed.angle;
14837
+ finalSkewX = (sourceElement == null ? void 0 : sourceElement.skewX) ?? obj.skewX ?? 0;
14838
+ finalSkewY = (sourceElement == null ? void 0 : sourceElement.skewY) ?? obj.skewY ?? 0;
14839
+ }
14837
14840
  obj.set({ scaleX: 1, scaleY: 1 });
14838
14841
  const newSrc = renderSmartElementToDataUri(sourceElement.smartElementType, sourceElement.smartProps, bakedW, bakedH);
14839
14842
  if (newSrc) {
@@ -14884,20 +14887,7 @@ const PageCanvas = forwardRef(
14884
14887
  obj.set({ scaleX: localScaleX, scaleY: localScaleY });
14885
14888
  const selectionMatrix = (_g = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _g.call(activeObj);
14886
14889
  const localCenter = selectionMatrix ? fabric.util.transformPoint(preBakeCenter, fabric.util.invertTransform(selectionMatrix)) : preBakeCenter;
14887
- const localWidth = bakedW * localScaleX;
14888
- const localHeight = bakedH * localScaleY;
14889
- const isCenterOrigin = obj.originX === "center" || obj.originY === "center";
14890
- if (isCenterOrigin) {
14891
- obj.set({
14892
- left: localCenter.x,
14893
- top: localCenter.y
14894
- });
14895
- } else {
14896
- obj.set({
14897
- left: localCenter.x - localWidth / 2,
14898
- top: localCenter.y - localHeight / 2
14899
- });
14900
- }
14890
+ obj.setPositionByOrigin(localCenter, "center", "center");
14901
14891
  }
14902
14892
  obj.dirty = true;
14903
14893
  if (activeObj) activeObj.dirty = true;
@@ -14908,33 +14898,29 @@ const PageCanvas = forwardRef(
14908
14898
  finalHeight = bakedH;
14909
14899
  finalScaleX = 1;
14910
14900
  finalScaleY = 1;
14901
+ if (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb") {
14902
+ finalAngle = (sourceElement == null ? void 0 : sourceElement.angle) ?? obj.angle ?? decomposed.angle;
14903
+ finalSkewX = (sourceElement == null ? void 0 : sourceElement.skewX) ?? obj.skewX ?? 0;
14904
+ finalSkewY = (sourceElement == null ? void 0 : sourceElement.skewY) ?? obj.skewY ?? 0;
14905
+ }
14911
14906
  try {
14912
- const angleRad = (decomposed.angle ?? 0) * Math.PI / 180;
14907
+ const angleRad = (finalAngle ?? 0) * Math.PI / 180;
14913
14908
  const cos = Math.cos(angleRad);
14914
14909
  const sin = Math.sin(angleRad);
14915
14910
  const hw = finalWidth / 2;
14916
14911
  const hh = finalHeight / 2;
14917
- const corners = [
14918
- { x: -hw, y: -hh },
14919
- { x: hw, y: -hh },
14920
- { x: hw, y: hh },
14921
- { x: -hw, y: hh }
14922
- ].map((p) => ({
14923
- x: decomposed.translateX + p.x * cos - p.y * sin,
14924
- y: decomposed.translateY + p.x * sin + p.y * cos
14925
- }));
14926
- absoluteLeft = Math.min(...corners.map((p) => p.x));
14927
- absoluteTop = Math.min(...corners.map((p) => p.y));
14912
+ absoluteLeft = decomposed.translateX - hw * cos + hh * sin;
14913
+ absoluteTop = decomposed.translateY - hw * sin - hh * cos;
14928
14914
  } catch {
14929
14915
  }
14930
14916
  finalAbsoluteMatrix = fabric.util.composeMatrix({
14931
14917
  translateX: decomposed.translateX,
14932
14918
  translateY: decomposed.translateY,
14933
- angle: decomposed.angle ?? 0,
14919
+ angle: finalAngle ?? 0,
14934
14920
  scaleX: 1,
14935
14921
  scaleY: 1,
14936
- skewX: 0,
14937
- skewY: 0
14922
+ skewX: finalSkewX ?? 0,
14923
+ skewY: finalSkewY ?? 0
14938
14924
  });
14939
14925
  } else {
14940
14926
  finalWidth = intrinsicWidth;
@@ -14945,6 +14931,11 @@ const PageCanvas = forwardRef(
14945
14931
  finalHeight = 0;
14946
14932
  finalScaleX = 1;
14947
14933
  finalScaleY = 1;
14934
+ if (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb") {
14935
+ finalAngle = (sourceElement == null ? void 0 : sourceElement.angle) ?? obj.angle ?? decomposed.angle;
14936
+ finalSkewX = (sourceElement == null ? void 0 : sourceElement.skewX) ?? obj.skewX ?? 0;
14937
+ finalSkewY = (sourceElement == null ? void 0 : sourceElement.skewY) ?? obj.skewY ?? 0;
14938
+ }
14948
14939
  } else if (obj instanceof fabric.Textbox && isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
14949
14940
  const sx = Math.abs(decomposed.scaleX || 1);
14950
14941
  const sy = Math.abs(decomposed.scaleY || 1);
@@ -15015,12 +15006,7 @@ const PageCanvas = forwardRef(
15015
15006
  obj.set({ scaleX: localScaleX, scaleY: localScaleY });
15016
15007
  const selectionMatrix = (_h = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _h.call(activeObj);
15017
15008
  const localCenter = selectionMatrix ? fabric.util.transformPoint(preBakeCenter, fabric.util.invertTransform(selectionMatrix)) : preBakeCenter;
15018
- const localWidth = bakedWidth * localScaleX;
15019
- const localHeight = (obj.height ?? intrinsicHeight) * localScaleY;
15020
- obj.set({
15021
- left: localCenter.x - localWidth / 2,
15022
- top: localCenter.y - localHeight / 2
15023
- });
15009
+ obj.setPositionByOrigin(localCenter, "center", "center");
15024
15010
  } else {
15025
15011
  obj.setPositionByOrigin(preBakeCenter, "center", "center");
15026
15012
  }
@@ -15033,32 +15019,23 @@ const PageCanvas = forwardRef(
15033
15019
  } catch {
15034
15020
  }
15035
15021
  try {
15036
- const angleRad = (decomposed.angle ?? 0) * Math.PI / 180;
15022
+ const angleRad = (finalAngle ?? 0) * Math.PI / 180;
15037
15023
  const cos = Math.cos(angleRad);
15038
15024
  const sin = Math.sin(angleRad);
15039
15025
  const hw = finalWidth / 2;
15040
15026
  const hh = finalHeight / 2;
15041
- const corners = [
15042
- { x: -hw, y: -hh },
15043
- { x: hw, y: -hh },
15044
- { x: hw, y: hh },
15045
- { x: -hw, y: hh }
15046
- ].map((p) => ({
15047
- x: decomposed.translateX + p.x * cos - p.y * sin,
15048
- y: decomposed.translateY + p.x * sin + p.y * cos
15049
- }));
15050
- absoluteLeft = Math.min(...corners.map((p) => p.x));
15051
- absoluteTop = Math.min(...corners.map((p) => p.y));
15027
+ absoluteLeft = decomposed.translateX - hw * cos + hh * sin;
15028
+ absoluteTop = decomposed.translateY - hw * sin - hh * cos;
15052
15029
  } catch {
15053
15030
  }
15054
15031
  finalAbsoluteMatrix = fabric.util.composeMatrix({
15055
15032
  translateX: decomposed.translateX,
15056
15033
  translateY: decomposed.translateY,
15057
- angle: decomposed.angle ?? 0,
15034
+ angle: finalAngle ?? 0,
15058
15035
  scaleX: 1,
15059
15036
  scaleY: 1,
15060
- skewX: 0,
15061
- skewY: 0
15037
+ skewX: finalSkewX ?? 0,
15038
+ skewY: finalSkewY ?? 0
15062
15039
  });
15063
15040
  if (debugGroupTextCornerResize) {
15064
15041
  logGroupTextResizeDebug("text-bake", {
@@ -15125,9 +15102,9 @@ const PageCanvas = forwardRef(
15125
15102
  // so finalWidth already reflects the new width chosen by the user.
15126
15103
  width: finalWidth,
15127
15104
  height: isLineObj ? 0 : isAutoShrinkText ? typeof autoShrinkStoredHeight === "number" ? autoShrinkStoredHeight : finalHeight : finalHeight,
15128
- angle: decomposed.angle,
15129
- skewX: isLineObj ? 0 : decomposed.skewX,
15130
- skewY: isLineObj ? 0 : decomposed.skewY,
15105
+ angle: finalAngle,
15106
+ skewX: isLineObj ? 0 : finalSkewX,
15107
+ skewY: isLineObj ? 0 : finalSkewY,
15131
15108
  scaleX: finalScaleX,
15132
15109
  scaleY: finalScaleY,
15133
15110
  transformMatrix: finalAbsoluteMatrix
@@ -24281,9 +24258,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24281
24258
  }
24282
24259
  return svgString;
24283
24260
  }
24284
- const resolvedPackageVersion = "0.5.325";
24261
+ const resolvedPackageVersion = "0.5.327";
24285
24262
  const PACKAGE_VERSION = resolvedPackageVersion;
24286
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.325";
24263
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.327";
24287
24264
  const roundParityValue = (value) => {
24288
24265
  if (typeof value !== "number") return value;
24289
24266
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25097,7 +25074,7 @@ class PixldocsRenderer {
25097
25074
  await this.waitForCanvasScene(container, cloned, i);
25098
25075
  }
25099
25076
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25100
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Mq6tcwR7.js");
25077
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DE3LhODY.js");
25101
25078
  const prepared = preparePagesForExport(
25102
25079
  cloned.pages,
25103
25080
  canvasWidth,
@@ -27417,7 +27394,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27417
27394
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27418
27395
  sanitizeSvgTreeForPdf(svgToDraw);
27419
27396
  try {
27420
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Mq6tcwR7.js");
27397
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DE3LhODY.js");
27421
27398
  try {
27422
27399
  await logTextMeasurementDiagnostic(svgToDraw);
27423
27400
  } catch {
@@ -27817,4 +27794,4 @@ export {
27817
27794
  buildTeaserBlurFlatKeys as y,
27818
27795
  collectFontDescriptorsFromConfig as z
27819
27796
  };
27820
- //# sourceMappingURL=index-CYpr1MY-.js.map
27797
+ //# sourceMappingURL=index-LJNw8NgB.js.map