@pixldocs/canvas-renderer 0.5.450 → 0.5.451

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.
@@ -5104,7 +5104,13 @@ function localDeltaToWorld(dx, dy, angleDeg) {
5104
5104
  function getWorldAngleDeg(obj) {
5105
5105
  var _a2;
5106
5106
  try {
5107
- if (typeof obj.getTotalAngle === "function") return obj.getTotalAngle() || 0;
5107
+ let total = 0;
5108
+ let cur = obj;
5109
+ while (cur) {
5110
+ total += Number(cur.angle ?? 0) || 0;
5111
+ cur = cur.group;
5112
+ }
5113
+ if (Number.isFinite(total)) return total;
5108
5114
  const matrix = (_a2 = obj.calcTransformMatrix) == null ? void 0 : _a2.call(obj);
5109
5115
  return matrix ? fabric.util.qrDecompose(matrix).angle || 0 : obj.angle || 0;
5110
5116
  } catch {
@@ -14638,7 +14644,7 @@ const PageCanvas = forwardRef(
14638
14644
  fabricCanvas.on("selection:cleared", () => {
14639
14645
  });
14640
14646
  fabricCanvas.on("object:scaling", (e) => {
14641
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
14647
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
14642
14648
  if (!isActiveRef.current) return;
14643
14649
  const t = e.target;
14644
14650
  if (t) lastResizeScaleTargetRef.current = t;
@@ -14931,9 +14937,12 @@ const PageCanvas = forwardRef(
14931
14937
  const liveGestureKey = `${obj.__pixldocsGroupSelection ?? "selection"}:${corner}:${((_k = groupSelectionTransformStartRef.current) == null ? void 0 : _k.selectionLeft) ?? obj.left ?? 0}:${((_l = groupSelectionTransformStartRef.current) == null ? void 0 : _l.selectionTop) ?? obj.top ?? 0}`;
14932
14938
  if (child.__asLiveGestureKey !== liveGestureKey) {
14933
14939
  child.__asLiveGestureKey = liveGestureKey;
14934
- child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
14940
+ const childIdForAngle = getObjectId(child);
14941
+ const sourceChildForAngle = childIdForAngle ? elementsRef.current.find((el) => el.id === childIdForAngle) : null;
14942
+ const isFlippedImageLikeChild = (child instanceof fabric.FabricImage || child instanceof fabric.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) && !!((sourceChildForAngle == null ? void 0 : sourceChildForAngle.flipX) || (sourceChildForAngle == null ? void 0 : sourceChildForAngle.flipY)) && Number.isFinite(sourceChildForAngle == null ? void 0 : sourceChildForAngle.angle);
14943
+ child.__asLiveOrigAngle = isFlippedImageLikeChild ? sourceChildForAngle.angle ?? 0 : Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
14935
14944
  }
14936
- if (child instanceof fabric.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) {
14945
+ if (child instanceof fabric.Group && (child.__cropGroup || ((_n = child._ct) == null ? void 0 : _n.isCropGroup))) {
14937
14946
  const ct = child.__cropData;
14938
14947
  if (!ct) continue;
14939
14948
  if (child.__asLiveOrigAngle == null) {
@@ -15102,7 +15111,7 @@ const PageCanvas = forwardRef(
15102
15111
  child.dirty = true;
15103
15112
  didReflowTextChild = true;
15104
15113
  }
15105
- if (isXSide && ((_n = groupShiftReflowSnapshotRef.current) == null ? void 0 : _n.selection) === obj) {
15114
+ if (isXSide && ((_o = groupShiftReflowSnapshotRef.current) == null ? void 0 : _o.selection) === obj) {
15106
15115
  const snap = groupShiftReflowSnapshotRef.current;
15107
15116
  const anchorEntry = snap.children[0];
15108
15117
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -15264,7 +15273,7 @@ const PageCanvas = forwardRef(
15264
15273
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
15265
15274
  if (drilledGroupIdRef.current) {
15266
15275
  try {
15267
- (_o = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _o.call(fabricCanvas);
15276
+ (_p = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _p.call(fabricCanvas);
15268
15277
  } catch {
15269
15278
  }
15270
15279
  }
@@ -15671,12 +15680,18 @@ const PageCanvas = forwardRef(
15671
15680
  const absLeft = (active.left ?? 0) - ct.frameW / 2;
15672
15681
  const absTop = (active.top ?? 0) - ct.frameH / 2;
15673
15682
  const storePosCrop = absoluteToStorePosition(absLeft, absTop, objId, pageChildrenCrop);
15683
+ const sourceCropElement = pageChildrenCrop.length ? findNodeById(pageChildrenCrop, objId) : null;
15684
+ const cropAngle = sourceCropElement && isElement(sourceCropElement) && (sourceCropElement.flipX || sourceCropElement.flipY) && Number.isFinite(sourceCropElement.angle) ? sourceCropElement.angle ?? 0 : active.angle ?? 0;
15685
+ if ((sourceCropElement == null ? void 0 : sourceCropElement.flipX) || (sourceCropElement == null ? void 0 : sourceCropElement.flipY)) {
15686
+ active.set({ angle: cropAngle, flipX: sourceCropElement.flipX ?? false, flipY: sourceCropElement.flipY ?? false });
15687
+ active.setCoords();
15688
+ }
15674
15689
  updateElement2(objId, {
15675
15690
  width: ct.frameW,
15676
15691
  height: ct.frameH,
15677
15692
  left: storePosCrop.left,
15678
15693
  top: storePosCrop.top,
15679
- angle: active.angle ?? 0,
15694
+ angle: cropAngle,
15680
15695
  cropPanX: panX,
15681
15696
  cropPanY: panY,
15682
15697
  cropZoom: zoom3
@@ -16175,7 +16190,7 @@ const PageCanvas = forwardRef(
16175
16190
  useEditorStore.getState().updateElement(objId, { src: newSrc }, { recordHistory: false, skipLayoutRecalc: true });
16176
16191
  }
16177
16192
  } else if (isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
16178
- const imgChildLocalAngle = obj.__asLiveOrigAngle != null ? obj.__asLiveOrigAngle : obj.angle ?? 0;
16193
+ const imgChildLocalAngle = obj.__asLiveOrigAngle != null ? obj.__asLiveOrigAngle : ((sourceElement == null ? void 0 : sourceElement.flipX) || (sourceElement == null ? void 0 : sourceElement.flipY)) && Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? 0;
16179
16194
  const imgChildNormAngle = (imgChildLocalAngle % 360 + 360) % 360;
16180
16195
  const imgChildIsRotated = Math.abs(imgChildNormAngle) > 0.5 && Math.abs(imgChildNormAngle - 360) > 0.5;
16181
16196
  const imgHandle = activeSelectionResizeHandle;
@@ -16586,7 +16601,7 @@ const PageCanvas = forwardRef(
16586
16601
  const isCropGroupObj = obj instanceof fabric.Group && obj.__cropGroup;
16587
16602
  const isPlainImageObj = obj instanceof fabric.FabricImage && !obj.__cropGroup && !obj.smartElementType;
16588
16603
  if (isActiveSelection && isActiveSelectionSideHandle && (isCropGroupObj || isPlainImageObj)) {
16589
- const childLocalAngleSrc = obj.__asLiveOrigAngle != null ? obj.__asLiveOrigAngle : Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? 0;
16604
+ const childLocalAngleSrc = obj.__asLiveOrigAngle != null ? obj.__asLiveOrigAngle : ((sourceElement == null ? void 0 : sourceElement.flipX) || (sourceElement == null ? void 0 : sourceElement.flipY)) && Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? sourceElement.angle ?? 0 : Number.isFinite(sourceElement == null ? void 0 : sourceElement.angle) ? sourceElement.angle ?? 0 : obj.angle ?? 0;
16590
16605
  const normAng = (childLocalAngleSrc % 360 + 360) % 360;
16591
16606
  const isRotatedImg = Math.min(normAng, 360 - normAng) > 0.5;
16592
16607
  if (isRotatedImg && activeObj instanceof fabric.ActiveSelection) {
@@ -25928,9 +25943,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25928
25943
  }
25929
25944
  return svgString;
25930
25945
  }
25931
- const resolvedPackageVersion = "0.5.450";
25946
+ const resolvedPackageVersion = "0.5.451";
25932
25947
  const PACKAGE_VERSION = resolvedPackageVersion;
25933
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.450";
25948
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.451";
25934
25949
  const roundParityValue = (value) => {
25935
25950
  if (typeof value !== "number") return value;
25936
25951
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26744,7 +26759,7 @@ class PixldocsRenderer {
26744
26759
  await this.waitForCanvasScene(container, cloned, i);
26745
26760
  }
26746
26761
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26747
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Ds3M_wlL.js");
26762
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-hQLfUhri.js");
26748
26763
  const prepared = preparePagesForExport(
26749
26764
  cloned.pages,
26750
26765
  canvasWidth,
@@ -29064,7 +29079,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29064
29079
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29065
29080
  sanitizeSvgTreeForPdf(svgToDraw);
29066
29081
  try {
29067
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Ds3M_wlL.js");
29082
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-hQLfUhri.js");
29068
29083
  try {
29069
29084
  await logTextMeasurementDiagnostic(svgToDraw);
29070
29085
  } catch {
@@ -29464,4 +29479,4 @@ export {
29464
29479
  buildTeaserBlurFlatKeys as y,
29465
29480
  collectFontDescriptorsFromConfig as z
29466
29481
  };
29467
- //# sourceMappingURL=index-BIyCaEvT.js.map
29482
+ //# sourceMappingURL=index-CmdwL3tr.js.map