@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.
@@ -14246,35 +14246,6 @@ const PageCanvas = react.forwardRef(
14246
14246
  const asRect0 = obj.getBoundingRect();
14247
14247
  let didReflowTextChild = false;
14248
14248
  for (const child of obj.getObjects()) {
14249
- if (child instanceof fabric__namespace.Textbox && !child.__asRotChildSnap) {
14250
- const ang = ((child.angle ?? 0) % 360 + 360) % 360;
14251
- const isRot = Math.min(ang, 360 - ang) > 0.5;
14252
- if (isRot) {
14253
- try {
14254
- const wm = child.calcTransformMatrix();
14255
- const decomp = fabric__namespace.util.qrDecompose(wm);
14256
- const asMatrix = obj.calcTransformMatrix();
14257
- const invAS = fabric__namespace.util.invertTransform(asMatrix);
14258
- const localCenter = fabric__namespace.util.transformPoint(
14259
- new fabric__namespace.Point(decomp.translateX, decomp.translateY),
14260
- invAS
14261
- );
14262
- child.__asRotChildSnap = {
14263
- cx0: decomp.translateX,
14264
- cy0: decomp.translateY,
14265
- theta0: child.angle ?? 0,
14266
- w0: child.width ?? 0,
14267
- h0: child.height ?? 0,
14268
- localCx: localCenter.x,
14269
- localCy: localCenter.y
14270
- };
14271
- } catch {
14272
- }
14273
- }
14274
- }
14275
- if (child instanceof fabric__namespace.Textbox && child.__asRotChildSnap) {
14276
- continue;
14277
- }
14278
14249
  if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_f = child._ct) == null ? void 0 : _f.isCropGroup))) {
14279
14250
  const ct = child.__cropData;
14280
14251
  if (!ct) continue;
@@ -14763,7 +14734,6 @@ const PageCanvas = react.forwardRef(
14763
14734
  delete child.__asLiveOrigW;
14764
14735
  delete child.__asLiveOrigH;
14765
14736
  delete child.__asLiveRotSnap;
14766
- delete child.__asRotChildSnap;
14767
14737
  }
14768
14738
  }
14769
14739
  } catch {
@@ -15449,6 +15419,14 @@ const PageCanvas = react.forwardRef(
15449
15419
  finalHeight = 0;
15450
15420
  finalScaleX = 1;
15451
15421
  finalScaleY = 1;
15422
+ } else if (obj instanceof fabric__namespace.Textbox && isActiveSelection && (sourceElement == null ? void 0 : sourceElement.type) === "text" && (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb") && Math.min(
15423
+ ((sourceElement.angle ?? obj.angle ?? 0) % 360 + 360) % 360,
15424
+ 360 - ((sourceElement.angle ?? obj.angle ?? 0) % 360 + 360) % 360
15425
+ ) > 0.5) {
15426
+ finalWidth = Math.max(1, intrinsicWidth);
15427
+ finalHeight = Math.max(1, intrinsicHeight);
15428
+ finalScaleX = 1;
15429
+ finalScaleY = 1;
15452
15430
  } else if (obj instanceof fabric__namespace.Textbox && isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
15453
15431
  const sx = Math.abs(decomposed.scaleX || 1);
15454
15432
  const sy = Math.abs(decomposed.scaleY || 1);
@@ -15648,6 +15626,45 @@ const PageCanvas = react.forwardRef(
15648
15626
  if (sourceElement && sourceElement.opacity !== void 0) {
15649
15627
  elementUpdate.opacity = sourceElement.opacity;
15650
15628
  }
15629
+ const isActiveSelectionSideHandle = activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb";
15630
+ if (isActiveSelection && isActiveSelectionSideHandle && obj instanceof fabric__namespace.Textbox && (sourceElement == null ? void 0 : sourceElement.type) === "text") {
15631
+ const cleanAngle = Number.isFinite(sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? decomposed.angle ?? 0;
15632
+ const normalizedTextAngle = (cleanAngle % 360 + 360) % 360;
15633
+ const isRotatedText = Math.min(normalizedTextAngle, 360 - normalizedTextAngle) > 0.5;
15634
+ if (isRotatedText) {
15635
+ try {
15636
+ const cleanW = Math.max(1, Number(obj.width ?? elementUpdate.width ?? finalWidth));
15637
+ const cleanH = Math.max(1, Number(elementUpdate.height ?? obj.height ?? finalHeight));
15638
+ const cx = decomposed.translateX ?? absoluteLeft + cleanW / 2;
15639
+ const cy = decomposed.translateY ?? absoluteTop + cleanH / 2;
15640
+ const theta = fabric__namespace.util.degreesToRadians(cleanAngle);
15641
+ const cos = Math.cos(theta);
15642
+ const sin = Math.sin(theta);
15643
+ const cleanAbsLeft = cx - (cos * cleanW / 2 - sin * cleanH / 2);
15644
+ const cleanAbsTop = cy - (sin * cleanW / 2 + cos * cleanH / 2);
15645
+ const cleanStorePos = absoluteToStorePosition(cleanAbsLeft, cleanAbsTop, objId, pageChildrenForSave);
15646
+ elementUpdate.left = cleanStorePos.left;
15647
+ elementUpdate.top = cleanStorePos.top;
15648
+ elementUpdate.width = cleanW;
15649
+ elementUpdate.height = cleanH;
15650
+ elementUpdate.angle = cleanAngle;
15651
+ elementUpdate.scaleX = 1;
15652
+ elementUpdate.scaleY = 1;
15653
+ elementUpdate.skewX = 0;
15654
+ elementUpdate.skewY = 0;
15655
+ elementUpdate.transformMatrix = fabric__namespace.util.composeMatrix({
15656
+ translateX: cx,
15657
+ translateY: cy,
15658
+ angle: cleanAngle,
15659
+ scaleX: 1,
15660
+ scaleY: 1,
15661
+ skewX: 0,
15662
+ skewY: 0
15663
+ });
15664
+ } catch {
15665
+ }
15666
+ }
15667
+ }
15651
15668
  if (debugGroupTextCornerResize && obj instanceof fabric__namespace.Textbox) {
15652
15669
  logGroupTextResizeDebug("store-update-text", {
15653
15670
  time: Math.round(performance.now()),
@@ -15683,45 +15700,6 @@ const PageCanvas = react.forwardRef(
15683
15700
  elementUpdate
15684
15701
  });
15685
15702
  }
15686
- const rotSnap = obj.__asRotChildSnap;
15687
- if (rotSnap && isActiveSelection && activeObj && obj instanceof fabric__namespace.Textbox) {
15688
- try {
15689
- const asFinal = activeObj.calcTransformMatrix();
15690
- const newWorldCenter = fabric__namespace.util.transformPoint(
15691
- new fabric__namespace.Point(rotSnap.localCx, rotSnap.localCy),
15692
- asFinal
15693
- );
15694
- const theta = rotSnap.theta0;
15695
- const w = rotSnap.w0;
15696
- const h = rotSnap.h0;
15697
- const rad = theta * Math.PI / 180;
15698
- const cos = Math.cos(rad);
15699
- const sin = Math.sin(rad);
15700
- const ox = newWorldCenter.x - (cos * w / 2 - sin * h / 2);
15701
- const oy = newWorldCenter.y - (sin * w / 2 + cos * h / 2);
15702
- const rotStorePos = absoluteToStorePosition(ox, oy, objId, pageChildrenForSave);
15703
- elementUpdate.left = rotStorePos.left;
15704
- elementUpdate.top = rotStorePos.top;
15705
- elementUpdate.width = w;
15706
- elementUpdate.height = h;
15707
- elementUpdate.angle = theta;
15708
- elementUpdate.scaleX = 1;
15709
- elementUpdate.scaleY = 1;
15710
- elementUpdate.skewX = 0;
15711
- elementUpdate.skewY = 0;
15712
- elementUpdate.transformMatrix = fabric__namespace.util.composeMatrix({
15713
- translateX: newWorldCenter.x,
15714
- translateY: newWorldCenter.y,
15715
- angle: theta,
15716
- scaleX: 1,
15717
- scaleY: 1,
15718
- skewX: 0,
15719
- skewY: 0
15720
- });
15721
- } catch {
15722
- }
15723
- delete obj.__asRotChildSnap;
15724
- }
15725
15703
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
15726
15704
  obj.setCoords();
15727
15705
  }
@@ -24903,9 +24881,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24903
24881
  }
24904
24882
  return svgString;
24905
24883
  }
24906
- const resolvedPackageVersion = "0.5.384";
24884
+ const resolvedPackageVersion = "0.5.385";
24907
24885
  const PACKAGE_VERSION = resolvedPackageVersion;
24908
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.384";
24886
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.385";
24909
24887
  const roundParityValue = (value) => {
24910
24888
  if (typeof value !== "number") return value;
24911
24889
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25719,7 +25697,7 @@ class PixldocsRenderer {
25719
25697
  await this.waitForCanvasScene(container, cloned, i);
25720
25698
  }
25721
25699
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25722
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CwGVLCXD.cjs"));
25700
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-PfyXnorA.cjs"));
25723
25701
  const prepared = preparePagesForExport(
25724
25702
  cloned.pages,
25725
25703
  canvasWidth,
@@ -28039,7 +28017,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28039
28017
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28040
28018
  sanitizeSvgTreeForPdf(svgToDraw);
28041
28019
  try {
28042
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CwGVLCXD.cjs"));
28020
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-PfyXnorA.cjs"));
28043
28021
  try {
28044
28022
  await logTextMeasurementDiagnostic(svgToDraw);
28045
28023
  } catch {
@@ -28436,4 +28414,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28436
28414
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28437
28415
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28438
28416
  exports.warmTemplateFromForm = warmTemplateFromForm;
28439
- //# sourceMappingURL=index-CIEk2Lju.cjs.map
28417
+ //# sourceMappingURL=index-BoNuF4Yx.cjs.map