@pixldocs/canvas-renderer 0.5.384 → 0.5.386

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;
@@ -14346,39 +14317,54 @@ const PageCanvas = react.forwardRef(
14346
14317
  continue;
14347
14318
  }
14348
14319
  if (!(child instanceof fabric__namespace.Textbox)) continue;
14320
+ const childAngleDeg = child.angle ?? 0;
14321
+ const asSx = isXSide ? sAxis : 1;
14322
+ const asSy = isXSide ? 1 : sAxis;
14323
+ const theta = fabric__namespace.util.degreesToRadians(childAngleDeg);
14324
+ const cosT = Math.cos(theta);
14325
+ const sinT = Math.sin(theta);
14349
14326
  if (isXSide) {
14350
14327
  if (child.__asLiveOrigW == null) {
14351
14328
  child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
14352
14329
  }
14353
14330
  const origW = child.__asLiveOrigW;
14354
- const newW = Math.max(20, origW * sAxis);
14355
- if (Math.abs((child.width ?? 0) - newW) > 0.5) {
14356
- child._set("width", newW);
14357
- child._set("scaleX", 1 / sAxis);
14358
- try {
14359
- child.initDimensions();
14360
- } catch {
14361
- }
14362
- child.setCoords();
14363
- child.dirty = true;
14364
- didReflowTextChild = true;
14365
- }
14331
+ const sLocalX = asSx * cosT * cosT + sinT * sinT;
14332
+ const newW = Math.max(20, origW * sLocalX);
14333
+ child._set("width", newW);
14366
14334
  } else {
14367
14335
  if (child.__asLiveOrigH == null) {
14368
14336
  child.__asLiveOrigH = (child.height ?? 0) * (child.scaleY ?? 1);
14369
14337
  }
14370
14338
  const origH = child.__asLiveOrigH;
14371
- const newH = Math.max(20, origH * sAxis);
14339
+ const sLocalY = asSy * cosT * cosT + sinT * sinT;
14340
+ const newH = Math.max(20, origH * sLocalY);
14372
14341
  child.minBoxHeight = newH;
14373
- child._set("scaleY", 1 / sAxis);
14374
- try {
14375
- child.initDimensions();
14376
- } catch {
14377
- }
14378
- child.setCoords();
14379
- child.dirty = true;
14380
- didReflowTextChild = true;
14381
14342
  }
14343
+ try {
14344
+ const inv = [1 / asSx, 0, 0, 1 / asSy, 0, 0];
14345
+ const Rtheta = fabric__namespace.util.composeMatrix({
14346
+ angle: childAngleDeg,
14347
+ scaleX: 1,
14348
+ scaleY: 1,
14349
+ translateX: 0,
14350
+ translateY: 0
14351
+ });
14352
+ const M = fabric__namespace.util.multiplyTransformMatrices(inv, Rtheta);
14353
+ const dec = fabric__namespace.util.qrDecompose(M);
14354
+ child._set("angle", dec.angle);
14355
+ child._set("scaleX", dec.scaleX);
14356
+ child._set("scaleY", dec.scaleY);
14357
+ child._set("skewX", dec.skewX);
14358
+ child._set("skewY", dec.skewY);
14359
+ } catch {
14360
+ }
14361
+ try {
14362
+ child.initDimensions();
14363
+ } catch {
14364
+ }
14365
+ child.setCoords();
14366
+ child.dirty = true;
14367
+ didReflowTextChild = true;
14382
14368
  }
14383
14369
  if (isXSide && ((_g = groupShiftReflowSnapshotRef.current) == null ? void 0 : _g.selection) === obj) {
14384
14370
  const snap = groupShiftReflowSnapshotRef.current;
@@ -14763,7 +14749,6 @@ const PageCanvas = react.forwardRef(
14763
14749
  delete child.__asLiveOrigW;
14764
14750
  delete child.__asLiveOrigH;
14765
14751
  delete child.__asLiveRotSnap;
14766
- delete child.__asRotChildSnap;
14767
14752
  }
14768
14753
  }
14769
14754
  } catch {
@@ -15449,6 +15434,14 @@ const PageCanvas = react.forwardRef(
15449
15434
  finalHeight = 0;
15450
15435
  finalScaleX = 1;
15451
15436
  finalScaleY = 1;
15437
+ } 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(
15438
+ ((sourceElement.angle ?? obj.angle ?? 0) % 360 + 360) % 360,
15439
+ 360 - ((sourceElement.angle ?? obj.angle ?? 0) % 360 + 360) % 360
15440
+ ) > 0.5) {
15441
+ finalWidth = Math.max(1, intrinsicWidth);
15442
+ finalHeight = Math.max(1, intrinsicHeight);
15443
+ finalScaleX = 1;
15444
+ finalScaleY = 1;
15452
15445
  } 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
15446
  const sx = Math.abs(decomposed.scaleX || 1);
15454
15447
  const sy = Math.abs(decomposed.scaleY || 1);
@@ -15648,6 +15641,45 @@ const PageCanvas = react.forwardRef(
15648
15641
  if (sourceElement && sourceElement.opacity !== void 0) {
15649
15642
  elementUpdate.opacity = sourceElement.opacity;
15650
15643
  }
15644
+ const isActiveSelectionSideHandle = activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb";
15645
+ if (isActiveSelection && isActiveSelectionSideHandle && obj instanceof fabric__namespace.Textbox && (sourceElement == null ? void 0 : sourceElement.type) === "text") {
15646
+ const cleanAngle = Number.isFinite(sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? decomposed.angle ?? 0;
15647
+ const normalizedTextAngle = (cleanAngle % 360 + 360) % 360;
15648
+ const isRotatedText = Math.min(normalizedTextAngle, 360 - normalizedTextAngle) > 0.5;
15649
+ if (isRotatedText) {
15650
+ try {
15651
+ const cleanW = Math.max(1, Number(obj.width ?? elementUpdate.width ?? finalWidth));
15652
+ const cleanH = Math.max(1, Number(elementUpdate.height ?? obj.height ?? finalHeight));
15653
+ const cx = decomposed.translateX ?? absoluteLeft + cleanW / 2;
15654
+ const cy = decomposed.translateY ?? absoluteTop + cleanH / 2;
15655
+ const theta = fabric__namespace.util.degreesToRadians(cleanAngle);
15656
+ const cos = Math.cos(theta);
15657
+ const sin = Math.sin(theta);
15658
+ const cleanAbsLeft = cx - (cos * cleanW / 2 - sin * cleanH / 2);
15659
+ const cleanAbsTop = cy - (sin * cleanW / 2 + cos * cleanH / 2);
15660
+ const cleanStorePos = absoluteToStorePosition(cleanAbsLeft, cleanAbsTop, objId, pageChildrenForSave);
15661
+ elementUpdate.left = cleanStorePos.left;
15662
+ elementUpdate.top = cleanStorePos.top;
15663
+ elementUpdate.width = cleanW;
15664
+ elementUpdate.height = cleanH;
15665
+ elementUpdate.angle = cleanAngle;
15666
+ elementUpdate.scaleX = 1;
15667
+ elementUpdate.scaleY = 1;
15668
+ elementUpdate.skewX = 0;
15669
+ elementUpdate.skewY = 0;
15670
+ elementUpdate.transformMatrix = fabric__namespace.util.composeMatrix({
15671
+ translateX: cx,
15672
+ translateY: cy,
15673
+ angle: cleanAngle,
15674
+ scaleX: 1,
15675
+ scaleY: 1,
15676
+ skewX: 0,
15677
+ skewY: 0
15678
+ });
15679
+ } catch {
15680
+ }
15681
+ }
15682
+ }
15651
15683
  if (debugGroupTextCornerResize && obj instanceof fabric__namespace.Textbox) {
15652
15684
  logGroupTextResizeDebug("store-update-text", {
15653
15685
  time: Math.round(performance.now()),
@@ -15683,45 +15715,6 @@ const PageCanvas = react.forwardRef(
15683
15715
  elementUpdate
15684
15716
  });
15685
15717
  }
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
15718
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
15726
15719
  obj.setCoords();
15727
15720
  }
@@ -24903,9 +24896,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24903
24896
  }
24904
24897
  return svgString;
24905
24898
  }
24906
- const resolvedPackageVersion = "0.5.384";
24899
+ const resolvedPackageVersion = "0.5.386";
24907
24900
  const PACKAGE_VERSION = resolvedPackageVersion;
24908
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.384";
24901
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.386";
24909
24902
  const roundParityValue = (value) => {
24910
24903
  if (typeof value !== "number") return value;
24911
24904
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25719,7 +25712,7 @@ class PixldocsRenderer {
25719
25712
  await this.waitForCanvasScene(container, cloned, i);
25720
25713
  }
25721
25714
  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"));
25715
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-Ch4wgY_V.cjs"));
25723
25716
  const prepared = preparePagesForExport(
25724
25717
  cloned.pages,
25725
25718
  canvasWidth,
@@ -28039,7 +28032,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28039
28032
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28040
28033
  sanitizeSvgTreeForPdf(svgToDraw);
28041
28034
  try {
28042
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CwGVLCXD.cjs"));
28035
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Ch4wgY_V.cjs"));
28043
28036
  try {
28044
28037
  await logTextMeasurementDiagnostic(svgToDraw);
28045
28038
  } catch {
@@ -28436,4 +28429,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28436
28429
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28437
28430
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28438
28431
  exports.warmTemplateFromForm = warmTemplateFromForm;
28439
- //# sourceMappingURL=index-CIEk2Lju.cjs.map
28432
+ //# sourceMappingURL=index-DPK4VKN5.cjs.map