@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.
@@ -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;
@@ -14299,75 +14328,6 @@ const PageCanvas = forwardRef(
14299
14328
  continue;
14300
14329
  }
14301
14330
  if (!(child instanceof fabric.Textbox)) continue;
14302
- const childAngle = child.angle ?? 0;
14303
- const normalizedAng = (childAngle % 180 + 180) % 180;
14304
- const distFromAxis = Math.min(
14305
- normalizedAng,
14306
- Math.abs(normalizedAng - 90),
14307
- Math.abs(normalizedAng - 180)
14308
- );
14309
- const isRotatedChild = distFromAxis > 0.5;
14310
- if (isRotatedChild) {
14311
- if (child.__asLiveRotSnap == null) {
14312
- const selMatrix0 = obj.calcTransformMatrix();
14313
- const localCenter0 = child.getCenterPoint();
14314
- const worldCenter0 = fabric.util.transformPoint(localCenter0, selMatrix0);
14315
- const origMinBoxH = Number(child.minBoxHeight);
14316
- child.__asLiveRotSnap = {
14317
- worldCenter: { x: worldCenter0.x, y: worldCenter0.y },
14318
- worldAngle: (obj.angle ?? 0) + childAngle,
14319
- origW: (child.width ?? 0) * Math.abs(child.scaleX ?? 1),
14320
- origH: (child.height ?? 0) * Math.abs(child.scaleY ?? 1),
14321
- origMinBoxH: Number.isFinite(origMinBoxH) ? origMinBoxH : 0
14322
- };
14323
- }
14324
- const snap = child.__asLiveRotSnap;
14325
- const θ = (snap.worldAngle - (obj.angle ?? 0)) * Math.PI / 180;
14326
- const c = Math.cos(θ);
14327
- const s = Math.sin(θ);
14328
- const cos2 = c * c;
14329
- const sin2 = s * s;
14330
- if (isXSide) {
14331
- const sLocal = Math.max(0.01, sin2 + sAxis * cos2);
14332
- const newW = Math.max(20, snap.origW * sLocal);
14333
- child._set("width", newW);
14334
- } else {
14335
- const sLocal = Math.max(0.01, cos2 + sAxis * sin2);
14336
- const newH = Math.max(20, (snap.origMinBoxH || snap.origH) * sLocal);
14337
- child.minBoxHeight = newH;
14338
- }
14339
- const asAngleRad = (obj.angle ?? 0) * Math.PI / 180;
14340
- const ca = Math.cos(asAngleRad), sa = Math.sin(asAngleRad);
14341
- const asSx = obj.scaleX || 1;
14342
- const asSy = obj.scaleY || 1;
14343
- const wa = snap.worldAngle * Math.PI / 180;
14344
- const cw = Math.cos(wa), sw = Math.sin(wa);
14345
- const i00 = ca / asSx, i01 = sa / asSx;
14346
- const i10 = -sa / asSy, i11 = ca / asSy;
14347
- const m00 = i00 * cw + i01 * sw;
14348
- const m01 = i00 * -sw + i01 * cw;
14349
- const m10 = i10 * cw + i11 * sw;
14350
- const m11 = i10 * -sw + i11 * cw;
14351
- const decomp = fabric.util.qrDecompose([m00, m10, m01, m11, 0, 0]);
14352
- child._set("angle", decomp.angle);
14353
- child._set("scaleX", decomp.scaleX);
14354
- child._set("scaleY", decomp.scaleY);
14355
- child._set("skewX", decomp.skewX || 0);
14356
- child._set("skewY", decomp.skewY || 0);
14357
- try {
14358
- child.initDimensions();
14359
- } catch {
14360
- }
14361
- const selMatrixNow = obj.calcTransformMatrix();
14362
- const invSelNow = fabric.util.invertTransform(selMatrixNow);
14363
- const wcPoint = new fabric.Point(snap.worldCenter.x, snap.worldCenter.y);
14364
- const localCenterNow = fabric.util.transformPoint(wcPoint, invSelNow);
14365
- child.setPositionByOrigin(localCenterNow, "center", "center");
14366
- child.setCoords();
14367
- child.dirty = true;
14368
- didReflowTextChild = true;
14369
- continue;
14370
- }
14371
14331
  if (isXSide) {
14372
14332
  if (child.__asLiveOrigW == null) {
14373
14333
  child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
@@ -14785,6 +14745,7 @@ const PageCanvas = forwardRef(
14785
14745
  delete child.__asLiveOrigW;
14786
14746
  delete child.__asLiveOrigH;
14787
14747
  delete child.__asLiveRotSnap;
14748
+ delete child.__asRotChildSnap;
14788
14749
  }
14789
14750
  }
14790
14751
  } catch {
@@ -15704,6 +15665,45 @@ const PageCanvas = forwardRef(
15704
15665
  elementUpdate
15705
15666
  });
15706
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
+ }
15707
15707
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
15708
15708
  obj.setCoords();
15709
15709
  }
@@ -24885,9 +24885,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24885
24885
  }
24886
24886
  return svgString;
24887
24887
  }
24888
- const resolvedPackageVersion = "0.5.382";
24888
+ const resolvedPackageVersion = "0.5.384";
24889
24889
  const PACKAGE_VERSION = resolvedPackageVersion;
24890
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.382";
24890
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.384";
24891
24891
  const roundParityValue = (value) => {
24892
24892
  if (typeof value !== "number") return value;
24893
24893
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25701,7 +25701,7 @@ class PixldocsRenderer {
25701
25701
  await this.waitForCanvasScene(container, cloned, i);
25702
25702
  }
25703
25703
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25704
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-C6nEEZs9.js");
25704
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BL8RuhWq.js");
25705
25705
  const prepared = preparePagesForExport(
25706
25706
  cloned.pages,
25707
25707
  canvasWidth,
@@ -28021,7 +28021,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28021
28021
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28022
28022
  sanitizeSvgTreeForPdf(svgToDraw);
28023
28023
  try {
28024
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-C6nEEZs9.js");
28024
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BL8RuhWq.js");
28025
28025
  try {
28026
28026
  await logTextMeasurementDiagnostic(svgToDraw);
28027
28027
  } catch {
@@ -28421,4 +28421,4 @@ export {
28421
28421
  buildTeaserBlurFlatKeys as y,
28422
28422
  collectFontDescriptorsFromConfig as z
28423
28423
  };
28424
- //# sourceMappingURL=index-DJ64kXcr.js.map
28424
+ //# sourceMappingURL=index-ZQVav-Zq.js.map