@pixldocs/canvas-renderer 0.5.380 → 0.5.382

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.
@@ -11733,13 +11733,17 @@ const PageCanvas = forwardRef(
11733
11733
  const sameMembers = activeMembers.length === members.length && members.every((member) => activeMembers.includes(member));
11734
11734
  const sameGroup = activeBeforeRestore.__pixldocsGroupSelection === groupId;
11735
11735
  const alreadyAligned = activeBeforeRestore.__pixldocsAlignedAngle != null;
11736
- if (sameMembers && sameGroup && alreadyAligned) return;
11736
+ if (sameMembers && sameGroup && alreadyAligned) {
11737
+ ensureCanvaControlRenders(activeBeforeRestore);
11738
+ return;
11739
+ }
11737
11740
  }
11738
11741
  isSyncingSelectionToFabricRef.current = true;
11739
11742
  try {
11740
11743
  const active = activeBeforeRestore;
11741
11744
  const selection = active instanceof fabric.ActiveSelection && members.every((member) => active.getObjects().includes(member)) ? active : new fabric.ActiveSelection(members, { canvas: fc });
11742
11745
  applyLogicalGroupSelectionVisualState(selection, groupId);
11746
+ ensureCanvaControlRenders(selection);
11743
11747
  fc.setActiveObject(selection);
11744
11748
  try {
11745
11749
  members.forEach((m) => m.setCoords());
@@ -13363,7 +13367,10 @@ const PageCanvas = forwardRef(
13363
13367
  const sameMembers = activeIds.length === snapshot.memberIds.length && snapshot.memberIds.every((id) => activeIds.includes(id));
13364
13368
  const sameGroup = active.__pixldocsGroupSelection === snapshot.groupSelectionId;
13365
13369
  const alreadyAligned = active.__pixldocsAlignedAngle != null;
13366
- if (sameMembers && sameGroup && alreadyAligned) return;
13370
+ if (sameMembers && sameGroup && alreadyAligned) {
13371
+ ensureCanvaControlRenders(active);
13372
+ return;
13373
+ }
13367
13374
  }
13368
13375
  restoreGroupSelectionSnapshot(snapshot);
13369
13376
  }, 0);
@@ -14292,6 +14299,75 @@ const PageCanvas = forwardRef(
14292
14299
  continue;
14293
14300
  }
14294
14301
  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
+ }
14295
14371
  if (isXSide) {
14296
14372
  if (child.__asLiveOrigW == null) {
14297
14373
  child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
@@ -14708,6 +14784,7 @@ const PageCanvas = forwardRef(
14708
14784
  for (const child of t.getObjects()) {
14709
14785
  delete child.__asLiveOrigW;
14710
14786
  delete child.__asLiveOrigH;
14787
+ delete child.__asLiveRotSnap;
14711
14788
  }
14712
14789
  }
14713
14790
  } catch {
@@ -16089,6 +16166,10 @@ const PageCanvas = forwardRef(
16089
16166
  const sameMembers = !!prevAS && prevMembers.length === freshMembers.length && prevMembers.every((m) => freshMembers.includes(m));
16090
16167
  const alreadyAligned = sameMembers && prevAS.__pixldocsAlignedAngle != null;
16091
16168
  if (sameMembers && alreadyAligned) {
16169
+ try {
16170
+ ensureCanvaControlRenders(prevAS);
16171
+ } catch {
16172
+ }
16092
16173
  fc.setActiveObject(prevAS);
16093
16174
  prevAS.setCoords();
16094
16175
  fc.requestRenderAll();
@@ -17196,6 +17277,7 @@ const PageCanvas = forwardRef(
17196
17277
  });
17197
17278
  if (isPureSingleGroupSelection) applyWarpAwareSelectionBorders(selection);
17198
17279
  }
17280
+ ensureCanvaControlRenders(selection);
17199
17281
  fc.setActiveObject(selection);
17200
17282
  if (!isFlatGroupSelection) {
17201
17283
  selection.setCoords();
@@ -24803,9 +24885,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24803
24885
  }
24804
24886
  return svgString;
24805
24887
  }
24806
- const resolvedPackageVersion = "0.5.380";
24888
+ const resolvedPackageVersion = "0.5.382";
24807
24889
  const PACKAGE_VERSION = resolvedPackageVersion;
24808
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.380";
24890
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.382";
24809
24891
  const roundParityValue = (value) => {
24810
24892
  if (typeof value !== "number") return value;
24811
24893
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25619,7 +25701,7 @@ class PixldocsRenderer {
25619
25701
  await this.waitForCanvasScene(container, cloned, i);
25620
25702
  }
25621
25703
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25622
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DR72C-Lv.js");
25704
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-C6nEEZs9.js");
25623
25705
  const prepared = preparePagesForExport(
25624
25706
  cloned.pages,
25625
25707
  canvasWidth,
@@ -27939,7 +28021,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27939
28021
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27940
28022
  sanitizeSvgTreeForPdf(svgToDraw);
27941
28023
  try {
27942
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DR72C-Lv.js");
28024
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-C6nEEZs9.js");
27943
28025
  try {
27944
28026
  await logTextMeasurementDiagnostic(svgToDraw);
27945
28027
  } catch {
@@ -28339,4 +28421,4 @@ export {
28339
28421
  buildTeaserBlurFlatKeys as y,
28340
28422
  collectFontDescriptorsFromConfig as z
28341
28423
  };
28342
- //# sourceMappingURL=index-8XP6VUfk.js.map
28424
+ //# sourceMappingURL=index-DJ64kXcr.js.map