@pixldocs/canvas-renderer 0.5.382 → 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.
@@ -14246,6 +14246,35 @@ 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
+ }
14249
14278
  if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_f = child._ct) == null ? void 0 : _f.isCropGroup))) {
14250
14279
  const ct = child.__cropData;
14251
14280
  if (!ct) continue;
@@ -14317,75 +14346,6 @@ const PageCanvas = react.forwardRef(
14317
14346
  continue;
14318
14347
  }
14319
14348
  if (!(child instanceof fabric__namespace.Textbox)) continue;
14320
- const childAngle = child.angle ?? 0;
14321
- const normalizedAng = (childAngle % 180 + 180) % 180;
14322
- const distFromAxis = Math.min(
14323
- normalizedAng,
14324
- Math.abs(normalizedAng - 90),
14325
- Math.abs(normalizedAng - 180)
14326
- );
14327
- const isRotatedChild = distFromAxis > 0.5;
14328
- if (isRotatedChild) {
14329
- if (child.__asLiveRotSnap == null) {
14330
- const selMatrix0 = obj.calcTransformMatrix();
14331
- const localCenter0 = child.getCenterPoint();
14332
- const worldCenter0 = fabric__namespace.util.transformPoint(localCenter0, selMatrix0);
14333
- const origMinBoxH = Number(child.minBoxHeight);
14334
- child.__asLiveRotSnap = {
14335
- worldCenter: { x: worldCenter0.x, y: worldCenter0.y },
14336
- worldAngle: (obj.angle ?? 0) + childAngle,
14337
- origW: (child.width ?? 0) * Math.abs(child.scaleX ?? 1),
14338
- origH: (child.height ?? 0) * Math.abs(child.scaleY ?? 1),
14339
- origMinBoxH: Number.isFinite(origMinBoxH) ? origMinBoxH : 0
14340
- };
14341
- }
14342
- const snap = child.__asLiveRotSnap;
14343
- const θ = (snap.worldAngle - (obj.angle ?? 0)) * Math.PI / 180;
14344
- const c = Math.cos(θ);
14345
- const s = Math.sin(θ);
14346
- const cos2 = c * c;
14347
- const sin2 = s * s;
14348
- if (isXSide) {
14349
- const sLocal = Math.max(0.01, sin2 + sAxis * cos2);
14350
- const newW = Math.max(20, snap.origW * sLocal);
14351
- child._set("width", newW);
14352
- } else {
14353
- const sLocal = Math.max(0.01, cos2 + sAxis * sin2);
14354
- const newH = Math.max(20, (snap.origMinBoxH || snap.origH) * sLocal);
14355
- child.minBoxHeight = newH;
14356
- }
14357
- const asAngleRad = (obj.angle ?? 0) * Math.PI / 180;
14358
- const ca = Math.cos(asAngleRad), sa = Math.sin(asAngleRad);
14359
- const asSx = obj.scaleX || 1;
14360
- const asSy = obj.scaleY || 1;
14361
- const wa = snap.worldAngle * Math.PI / 180;
14362
- const cw = Math.cos(wa), sw = Math.sin(wa);
14363
- const i00 = ca / asSx, i01 = sa / asSx;
14364
- const i10 = -sa / asSy, i11 = ca / asSy;
14365
- const m00 = i00 * cw + i01 * sw;
14366
- const m01 = i00 * -sw + i01 * cw;
14367
- const m10 = i10 * cw + i11 * sw;
14368
- const m11 = i10 * -sw + i11 * cw;
14369
- const decomp = fabric__namespace.util.qrDecompose([m00, m10, m01, m11, 0, 0]);
14370
- child._set("angle", decomp.angle);
14371
- child._set("scaleX", decomp.scaleX);
14372
- child._set("scaleY", decomp.scaleY);
14373
- child._set("skewX", decomp.skewX || 0);
14374
- child._set("skewY", decomp.skewY || 0);
14375
- try {
14376
- child.initDimensions();
14377
- } catch {
14378
- }
14379
- const selMatrixNow = obj.calcTransformMatrix();
14380
- const invSelNow = fabric__namespace.util.invertTransform(selMatrixNow);
14381
- const wcPoint = new fabric__namespace.Point(snap.worldCenter.x, snap.worldCenter.y);
14382
- const localCenterNow = fabric__namespace.util.transformPoint(wcPoint, invSelNow);
14383
- child.setPositionByOrigin(localCenterNow, "center", "center");
14384
- child.setCoords();
14385
- child.dirty = true;
14386
- didReflowTextChild = true;
14387
- continue;
14388
- }
14389
14349
  if (isXSide) {
14390
14350
  if (child.__asLiveOrigW == null) {
14391
14351
  child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
@@ -14803,6 +14763,7 @@ const PageCanvas = react.forwardRef(
14803
14763
  delete child.__asLiveOrigW;
14804
14764
  delete child.__asLiveOrigH;
14805
14765
  delete child.__asLiveRotSnap;
14766
+ delete child.__asRotChildSnap;
14806
14767
  }
14807
14768
  }
14808
14769
  } catch {
@@ -15722,6 +15683,45 @@ const PageCanvas = react.forwardRef(
15722
15683
  elementUpdate
15723
15684
  });
15724
15685
  }
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
15725
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
15726
15726
  obj.setCoords();
15727
15727
  }
@@ -24903,9 +24903,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24903
24903
  }
24904
24904
  return svgString;
24905
24905
  }
24906
- const resolvedPackageVersion = "0.5.382";
24906
+ const resolvedPackageVersion = "0.5.384";
24907
24907
  const PACKAGE_VERSION = resolvedPackageVersion;
24908
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.382";
24908
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.384";
24909
24909
  const roundParityValue = (value) => {
24910
24910
  if (typeof value !== "number") return value;
24911
24911
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25719,7 +25719,7 @@ class PixldocsRenderer {
25719
25719
  await this.waitForCanvasScene(container, cloned, i);
25720
25720
  }
25721
25721
  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-BI3et0Ux.cjs"));
25722
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CwGVLCXD.cjs"));
25723
25723
  const prepared = preparePagesForExport(
25724
25724
  cloned.pages,
25725
25725
  canvasWidth,
@@ -28039,7 +28039,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28039
28039
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28040
28040
  sanitizeSvgTreeForPdf(svgToDraw);
28041
28041
  try {
28042
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BI3et0Ux.cjs"));
28042
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CwGVLCXD.cjs"));
28043
28043
  try {
28044
28044
  await logTextMeasurementDiagnostic(svgToDraw);
28045
28045
  } catch {
@@ -28436,4 +28436,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28436
28436
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28437
28437
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28438
28438
  exports.warmTemplateFromForm = warmTemplateFromForm;
28439
- //# sourceMappingURL=index-BpiWTXuI.cjs.map
28439
+ //# sourceMappingURL=index-CIEk2Lju.cjs.map