@pixldocs/canvas-renderer 0.5.383 → 0.5.384

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.
@@ -14228,6 +14228,35 @@ const PageCanvas = forwardRef(
14228
14228
  const asRect0 = obj.getBoundingRect();
14229
14229
  let didReflowTextChild = false;
14230
14230
  for (const child of obj.getObjects()) {
14231
+ if (child instanceof fabric.Textbox && !child.__asRotChildSnap) {
14232
+ const ang = ((child.angle ?? 0) % 360 + 360) % 360;
14233
+ const isRot = Math.min(ang, 360 - ang) > 0.5;
14234
+ if (isRot) {
14235
+ try {
14236
+ const wm = child.calcTransformMatrix();
14237
+ const decomp = fabric.util.qrDecompose(wm);
14238
+ const asMatrix = obj.calcTransformMatrix();
14239
+ const invAS = fabric.util.invertTransform(asMatrix);
14240
+ const localCenter = fabric.util.transformPoint(
14241
+ new fabric.Point(decomp.translateX, decomp.translateY),
14242
+ invAS
14243
+ );
14244
+ child.__asRotChildSnap = {
14245
+ cx0: decomp.translateX,
14246
+ cy0: decomp.translateY,
14247
+ theta0: child.angle ?? 0,
14248
+ w0: child.width ?? 0,
14249
+ h0: child.height ?? 0,
14250
+ localCx: localCenter.x,
14251
+ localCy: localCenter.y
14252
+ };
14253
+ } catch {
14254
+ }
14255
+ }
14256
+ }
14257
+ if (child instanceof fabric.Textbox && child.__asRotChildSnap) {
14258
+ continue;
14259
+ }
14231
14260
  if (child instanceof fabric.Group && (child.__cropGroup || ((_f = child._ct) == null ? void 0 : _f.isCropGroup))) {
14232
14261
  const ct = child.__cropData;
14233
14262
  if (!ct) continue;
@@ -14716,6 +14745,7 @@ const PageCanvas = forwardRef(
14716
14745
  delete child.__asLiveOrigW;
14717
14746
  delete child.__asLiveOrigH;
14718
14747
  delete child.__asLiveRotSnap;
14748
+ delete child.__asRotChildSnap;
14719
14749
  }
14720
14750
  }
14721
14751
  } catch {
@@ -15635,6 +15665,45 @@ const PageCanvas = forwardRef(
15635
15665
  elementUpdate
15636
15666
  });
15637
15667
  }
15668
+ const rotSnap = obj.__asRotChildSnap;
15669
+ if (rotSnap && isActiveSelection && activeObj && obj instanceof fabric.Textbox) {
15670
+ try {
15671
+ const asFinal = activeObj.calcTransformMatrix();
15672
+ const newWorldCenter = fabric.util.transformPoint(
15673
+ new fabric.Point(rotSnap.localCx, rotSnap.localCy),
15674
+ asFinal
15675
+ );
15676
+ const theta = rotSnap.theta0;
15677
+ const w = rotSnap.w0;
15678
+ const h = rotSnap.h0;
15679
+ const rad = theta * Math.PI / 180;
15680
+ const cos = Math.cos(rad);
15681
+ const sin = Math.sin(rad);
15682
+ const ox = newWorldCenter.x - (cos * w / 2 - sin * h / 2);
15683
+ const oy = newWorldCenter.y - (sin * w / 2 + cos * h / 2);
15684
+ const rotStorePos = absoluteToStorePosition(ox, oy, objId, pageChildrenForSave);
15685
+ elementUpdate.left = rotStorePos.left;
15686
+ elementUpdate.top = rotStorePos.top;
15687
+ elementUpdate.width = w;
15688
+ elementUpdate.height = h;
15689
+ elementUpdate.angle = theta;
15690
+ elementUpdate.scaleX = 1;
15691
+ elementUpdate.scaleY = 1;
15692
+ elementUpdate.skewX = 0;
15693
+ elementUpdate.skewY = 0;
15694
+ elementUpdate.transformMatrix = fabric.util.composeMatrix({
15695
+ translateX: newWorldCenter.x,
15696
+ translateY: newWorldCenter.y,
15697
+ angle: theta,
15698
+ scaleX: 1,
15699
+ scaleY: 1,
15700
+ skewX: 0,
15701
+ skewY: 0
15702
+ });
15703
+ } catch {
15704
+ }
15705
+ delete obj.__asRotChildSnap;
15706
+ }
15638
15707
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
15639
15708
  obj.setCoords();
15640
15709
  }
@@ -24816,9 +24885,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24816
24885
  }
24817
24886
  return svgString;
24818
24887
  }
24819
- const resolvedPackageVersion = "0.5.383";
24888
+ const resolvedPackageVersion = "0.5.384";
24820
24889
  const PACKAGE_VERSION = resolvedPackageVersion;
24821
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.383";
24890
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.384";
24822
24891
  const roundParityValue = (value) => {
24823
24892
  if (typeof value !== "number") return value;
24824
24893
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25632,7 +25701,7 @@ class PixldocsRenderer {
25632
25701
  await this.waitForCanvasScene(container, cloned, i);
25633
25702
  }
25634
25703
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25635
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BegTwE0k.js");
25704
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BL8RuhWq.js");
25636
25705
  const prepared = preparePagesForExport(
25637
25706
  cloned.pages,
25638
25707
  canvasWidth,
@@ -27952,7 +28021,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27952
28021
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27953
28022
  sanitizeSvgTreeForPdf(svgToDraw);
27954
28023
  try {
27955
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BegTwE0k.js");
28024
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BL8RuhWq.js");
27956
28025
  try {
27957
28026
  await logTextMeasurementDiagnostic(svgToDraw);
27958
28027
  } catch {
@@ -28352,4 +28421,4 @@ export {
28352
28421
  buildTeaserBlurFlatKeys as y,
28353
28422
  collectFontDescriptorsFromConfig as z
28354
28423
  };
28355
- //# sourceMappingURL=index-BHS16lGJ.js.map
28424
+ //# sourceMappingURL=index-ZQVav-Zq.js.map