@pixldocs/canvas-renderer 0.5.384 → 0.5.385

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,35 +14228,6 @@ 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
- }
14260
14231
  if (child instanceof fabric.Group && (child.__cropGroup || ((_f = child._ct) == null ? void 0 : _f.isCropGroup))) {
14261
14232
  const ct = child.__cropData;
14262
14233
  if (!ct) continue;
@@ -14745,7 +14716,6 @@ const PageCanvas = forwardRef(
14745
14716
  delete child.__asLiveOrigW;
14746
14717
  delete child.__asLiveOrigH;
14747
14718
  delete child.__asLiveRotSnap;
14748
- delete child.__asRotChildSnap;
14749
14719
  }
14750
14720
  }
14751
14721
  } catch {
@@ -15431,6 +15401,14 @@ const PageCanvas = forwardRef(
15431
15401
  finalHeight = 0;
15432
15402
  finalScaleX = 1;
15433
15403
  finalScaleY = 1;
15404
+ } else if (obj instanceof fabric.Textbox && isActiveSelection && (sourceElement == null ? void 0 : sourceElement.type) === "text" && (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb") && Math.min(
15405
+ ((sourceElement.angle ?? obj.angle ?? 0) % 360 + 360) % 360,
15406
+ 360 - ((sourceElement.angle ?? obj.angle ?? 0) % 360 + 360) % 360
15407
+ ) > 0.5) {
15408
+ finalWidth = Math.max(1, intrinsicWidth);
15409
+ finalHeight = Math.max(1, intrinsicHeight);
15410
+ finalScaleX = 1;
15411
+ finalScaleY = 1;
15434
15412
  } else if (obj instanceof fabric.Textbox && isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
15435
15413
  const sx = Math.abs(decomposed.scaleX || 1);
15436
15414
  const sy = Math.abs(decomposed.scaleY || 1);
@@ -15630,6 +15608,45 @@ const PageCanvas = forwardRef(
15630
15608
  if (sourceElement && sourceElement.opacity !== void 0) {
15631
15609
  elementUpdate.opacity = sourceElement.opacity;
15632
15610
  }
15611
+ const isActiveSelectionSideHandle = activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb";
15612
+ if (isActiveSelection && isActiveSelectionSideHandle && obj instanceof fabric.Textbox && (sourceElement == null ? void 0 : sourceElement.type) === "text") {
15613
+ const cleanAngle = Number.isFinite(sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? decomposed.angle ?? 0;
15614
+ const normalizedTextAngle = (cleanAngle % 360 + 360) % 360;
15615
+ const isRotatedText = Math.min(normalizedTextAngle, 360 - normalizedTextAngle) > 0.5;
15616
+ if (isRotatedText) {
15617
+ try {
15618
+ const cleanW = Math.max(1, Number(obj.width ?? elementUpdate.width ?? finalWidth));
15619
+ const cleanH = Math.max(1, Number(elementUpdate.height ?? obj.height ?? finalHeight));
15620
+ const cx = decomposed.translateX ?? absoluteLeft + cleanW / 2;
15621
+ const cy = decomposed.translateY ?? absoluteTop + cleanH / 2;
15622
+ const theta = fabric.util.degreesToRadians(cleanAngle);
15623
+ const cos = Math.cos(theta);
15624
+ const sin = Math.sin(theta);
15625
+ const cleanAbsLeft = cx - (cos * cleanW / 2 - sin * cleanH / 2);
15626
+ const cleanAbsTop = cy - (sin * cleanW / 2 + cos * cleanH / 2);
15627
+ const cleanStorePos = absoluteToStorePosition(cleanAbsLeft, cleanAbsTop, objId, pageChildrenForSave);
15628
+ elementUpdate.left = cleanStorePos.left;
15629
+ elementUpdate.top = cleanStorePos.top;
15630
+ elementUpdate.width = cleanW;
15631
+ elementUpdate.height = cleanH;
15632
+ elementUpdate.angle = cleanAngle;
15633
+ elementUpdate.scaleX = 1;
15634
+ elementUpdate.scaleY = 1;
15635
+ elementUpdate.skewX = 0;
15636
+ elementUpdate.skewY = 0;
15637
+ elementUpdate.transformMatrix = fabric.util.composeMatrix({
15638
+ translateX: cx,
15639
+ translateY: cy,
15640
+ angle: cleanAngle,
15641
+ scaleX: 1,
15642
+ scaleY: 1,
15643
+ skewX: 0,
15644
+ skewY: 0
15645
+ });
15646
+ } catch {
15647
+ }
15648
+ }
15649
+ }
15633
15650
  if (debugGroupTextCornerResize && obj instanceof fabric.Textbox) {
15634
15651
  logGroupTextResizeDebug("store-update-text", {
15635
15652
  time: Math.round(performance.now()),
@@ -15665,45 +15682,6 @@ const PageCanvas = forwardRef(
15665
15682
  elementUpdate
15666
15683
  });
15667
15684
  }
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
- }
15707
15685
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
15708
15686
  obj.setCoords();
15709
15687
  }
@@ -24885,9 +24863,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24885
24863
  }
24886
24864
  return svgString;
24887
24865
  }
24888
- const resolvedPackageVersion = "0.5.384";
24866
+ const resolvedPackageVersion = "0.5.385";
24889
24867
  const PACKAGE_VERSION = resolvedPackageVersion;
24890
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.384";
24868
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.385";
24891
24869
  const roundParityValue = (value) => {
24892
24870
  if (typeof value !== "number") return value;
24893
24871
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25701,7 +25679,7 @@ class PixldocsRenderer {
25701
25679
  await this.waitForCanvasScene(container, cloned, i);
25702
25680
  }
25703
25681
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25704
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BL8RuhWq.js");
25682
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CqGfBDhF.js");
25705
25683
  const prepared = preparePagesForExport(
25706
25684
  cloned.pages,
25707
25685
  canvasWidth,
@@ -28021,7 +27999,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28021
27999
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28022
28000
  sanitizeSvgTreeForPdf(svgToDraw);
28023
28001
  try {
28024
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BL8RuhWq.js");
28002
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CqGfBDhF.js");
28025
28003
  try {
28026
28004
  await logTextMeasurementDiagnostic(svgToDraw);
28027
28005
  } catch {
@@ -28421,4 +28399,4 @@ export {
28421
28399
  buildTeaserBlurFlatKeys as y,
28422
28400
  collectFontDescriptorsFromConfig as z
28423
28401
  };
28424
- //# sourceMappingURL=index-ZQVav-Zq.js.map
28402
+ //# sourceMappingURL=index-Y4ydIPau.js.map