@pixldocs/canvas-renderer 0.5.328 → 0.5.330

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.
@@ -13758,7 +13758,7 @@ const PageCanvas = react.forwardRef(
13758
13758
  const a = ((c.angle ?? 0) % 180 + 180) % 180;
13759
13759
  return !(a < 0.5 || a > 179.5);
13760
13760
  });
13761
- if (isXSide && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13761
+ if ((isXSide || hasRotatedChild) && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13762
13762
  groupShiftReflowSnapshotRef.current = null;
13763
13763
  const logicalGroupId = obj.__pixldocsGroupSelection;
13764
13764
  if (logicalGroupId) {
@@ -13770,7 +13770,9 @@ const PageCanvas = react.forwardRef(
13770
13770
  const entries = obj.getObjects().map((c) => ({
13771
13771
  obj: c,
13772
13772
  id: getObjectId(c) ?? "",
13773
+ left0: c.left ?? 0,
13773
13774
  top0: c.top ?? 0,
13775
+ width0: (c.width ?? 0) * Math.abs(c.scaleX ?? 1),
13774
13776
  height0: (c.height ?? 0) * Math.abs(c.scaleY ?? 1)
13775
13777
  })).filter((e2) => e2.id).sort((a, b) => a.top0 - b.top0);
13776
13778
  if (entries.length > 1) {
@@ -13803,78 +13805,50 @@ const PageCanvas = react.forwardRef(
13803
13805
  }
13804
13806
  }
13805
13807
  const childCounterScale = hasRotatedChild ? 1 : 1 / sAxis;
13808
+ const restoreNonTextChildren = (pins) => {
13809
+ var _a3, _b3;
13810
+ if (!hasRotatedChild || ((_a3 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _a3.selection) !== obj) return;
13811
+ for (const entry of groupShiftReflowSnapshotRef.current.children) {
13812
+ const child = entry.obj;
13813
+ if (child instanceof fabric__namespace.Textbox) continue;
13814
+ if (child instanceof fabric__namespace.FabricImage || child instanceof fabric__namespace.Group && (child.__cropGroup || ((_b3 = child._ct) == null ? void 0 : _b3.isCropGroup))) {
13815
+ const pin = pins == null ? void 0 : pins.get(child);
13816
+ const targetLeft = (pin == null ? void 0 : pin.left) ?? (isXSide ? entry.left0 * sAxis : entry.left0);
13817
+ const targetTop = (pin == null ? void 0 : pin.top) ?? (isXSide ? entry.top0 : entry.top0 * sAxis);
13818
+ if (Math.abs((child.left ?? 0) - targetLeft) > 0.01) child._set("left", targetLeft);
13819
+ if (Math.abs((child.top ?? 0) - targetTop) > 0.01) child._set("top", targetTop);
13820
+ if (isXSide) child._set("scaleX", childCounterScale);
13821
+ else child._set("scaleY", childCounterScale);
13822
+ child.setCoords();
13823
+ child.dirty = true;
13824
+ }
13825
+ }
13826
+ };
13827
+ const projectRotatedTextPosition = (child) => {
13828
+ var _a3;
13829
+ if (!hasRotatedChild || ((_a3 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _a3.selection) !== obj) return;
13830
+ const entry = groupShiftReflowSnapshotRef.current.children.find((candidate) => candidate.obj === child);
13831
+ if (!entry) return;
13832
+ if (isXSide) child._set("left", entry.left0 * sAxis);
13833
+ else child._set("top", entry.top0 * sAxis);
13834
+ };
13806
13835
  for (const child of obj.getObjects()) {
13807
13836
  if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_d = child._ct) == null ? void 0 : _d.isCropGroup))) {
13808
- const ct = child.__cropData;
13809
- if (!ct) continue;
13810
- if (isXSide) {
13811
- if (child.__asLiveOrigW == null) {
13812
- const baseW = child.width ?? ct.frameW ?? 0;
13813
- child.__asLiveOrigW = baseW * (child.scaleX ?? 1);
13814
- }
13815
- const origW = child.__asLiveOrigW;
13816
- const newW = Math.max(20, origW * sAxis);
13817
- if (Math.abs((child.width ?? 0) - newW) > 0.5) {
13818
- ct.frameW = newW;
13819
- child._set("width", newW);
13820
- child._set("scaleX", childCounterScale);
13821
- try {
13822
- updateCoverLayout(child);
13823
- } catch {
13824
- }
13825
- child.setCoords();
13826
- child.dirty = true;
13827
- }
13828
- } else {
13829
- if (child.__asLiveOrigH == null) {
13830
- const baseH = child.height ?? ct.frameH ?? 0;
13831
- child.__asLiveOrigH = baseH * (child.scaleY ?? 1);
13832
- }
13833
- const origH = child.__asLiveOrigH;
13834
- const newH = Math.max(20, origH * sAxis);
13835
- if (Math.abs((child.height ?? 0) - newH) > 0.5) {
13836
- ct.frameH = newH;
13837
- child._set("height", newH);
13838
- child._set("scaleY", childCounterScale);
13839
- try {
13840
- updateCoverLayout(child);
13841
- } catch {
13842
- }
13843
- child.setCoords();
13844
- child.dirty = true;
13845
- }
13846
- }
13837
+ if (isXSide) child._set("scaleX", childCounterScale);
13838
+ else child._set("scaleY", childCounterScale);
13839
+ child.setCoords();
13840
+ child.dirty = true;
13847
13841
  continue;
13848
13842
  }
13849
13843
  if (child instanceof fabric__namespace.FabricImage && !child.__cropGroup && !child.smartElementType) {
13850
- if (isXSide) {
13851
- if (child.__asLiveOrigW == null) {
13852
- child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
13853
- }
13854
- const origW = child.__asLiveOrigW;
13855
- const newW = Math.max(1, origW * sAxis);
13856
- if (Math.abs((child.width ?? 0) - newW) > 0.5) {
13857
- child._set("width", newW);
13858
- child._set("scaleX", childCounterScale);
13859
- child.setCoords();
13860
- child.dirty = true;
13861
- }
13862
- } else {
13863
- if (child.__asLiveOrigH == null) {
13864
- child.__asLiveOrigH = (child.height ?? 0) * (child.scaleY ?? 1);
13865
- }
13866
- const origH = child.__asLiveOrigH;
13867
- const newH = Math.max(1, origH * sAxis);
13868
- if (Math.abs((child.height ?? 0) - newH) > 0.5) {
13869
- child._set("height", newH);
13870
- child._set("scaleY", childCounterScale);
13871
- child.setCoords();
13872
- child.dirty = true;
13873
- }
13874
- }
13844
+ if (isXSide) child._set("scaleX", childCounterScale);
13845
+ else child._set("scaleY", childCounterScale);
13846
+ child.setCoords();
13847
+ child.dirty = true;
13875
13848
  continue;
13876
13849
  }
13877
13850
  if (!(child instanceof fabric__namespace.Textbox)) continue;
13851
+ projectRotatedTextPosition(child);
13878
13852
  if (isXSide) {
13879
13853
  if (child.__asLiveOrigW == null) {
13880
13854
  child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
@@ -13942,10 +13916,12 @@ const PageCanvas = react.forwardRef(
13942
13916
  if (cornersBefore) {
13943
13917
  fixedMidBefore = corner === "ml" ? { x: (cornersBefore.tr.x + cornersBefore.br.x) / 2, y: (cornersBefore.tr.y + cornersBefore.br.y) / 2 } : { x: (cornersBefore.tl.x + cornersBefore.bl.x) / 2, y: (cornersBefore.tl.y + cornersBefore.bl.y) / 2 };
13944
13918
  }
13919
+ const nonTextPinsBeforeLayout = hasRotatedChild ? new Map(obj.getObjects().map((child) => [child, { left: child.left ?? 0, top: child.top ?? 0 }])) : void 0;
13945
13920
  try {
13946
13921
  obj.triggerLayout();
13947
13922
  } catch {
13948
13923
  }
13924
+ restoreNonTextChildren(nonTextPinsBeforeLayout);
13949
13925
  obj._set("width", asW0);
13950
13926
  obj._set("scaleX", asSx0);
13951
13927
  obj._set("scaleY", asSy0);
@@ -13971,6 +13947,7 @@ const PageCanvas = react.forwardRef(
13971
13947
  obj._set("left", asLeft0);
13972
13948
  obj._set("top", asTop0);
13973
13949
  }
13950
+ restoreNonTextChildren();
13974
13951
  obj._set("width", asW0);
13975
13952
  obj._set("scaleX", asSx0);
13976
13953
  obj._set("scaleY", asSy0);
@@ -14611,6 +14588,7 @@ const PageCanvas = react.forwardRef(
14611
14588
  return;
14612
14589
  }
14613
14590
  }
14591
+ const isActiveSelectionSideResize = isActiveSelection && (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb");
14614
14592
  if (selectedElementIds.length > 0 && !anyCropGroup) {
14615
14593
  const firstObj = activeObjects[0];
14616
14594
  const firstId = getObjectId(firstObj);
@@ -14672,7 +14650,8 @@ const PageCanvas = react.forwardRef(
14672
14650
  }
14673
14651
  const deltaX = movedGroupLeft - groupAbs.left;
14674
14652
  const deltaY = movedGroupTop - groupAbs.top;
14675
- const hadScale = isActiveSelection && activeObj && (Math.abs((activeObj.scaleX ?? 1) - 1) > 0.01 || Math.abs((activeObj.scaleY ?? 1) - 1) > 0.01);
14653
+ const hadResizeHandle = isActiveSelection && !!activeSelectionResizeHandle;
14654
+ const hadScale = isActiveSelection && activeObj && (hadResizeHandle || Math.abs((activeObj.scaleX ?? 1) - 1) > 0.01 || Math.abs((activeObj.scaleY ?? 1) - 1) > 0.01);
14676
14655
  const startSelAngle = (((transformStart == null ? void 0 : transformStart.selectionAngle) ?? 0) % 360 + 360) % 360;
14677
14656
  const currentSelAngle = isActiveSelection && activeObj ? ((activeObj.angle ?? 0) % 360 + 360) % 360 : 0;
14678
14657
  const angleDelta = Math.min(
@@ -14680,7 +14659,7 @@ const PageCanvas = react.forwardRef(
14680
14659
  360 - Math.abs(currentSelAngle - startSelAngle)
14681
14660
  );
14682
14661
  const hadRotation = isActiveSelection && activeObj && angleDelta > 0.01;
14683
- if (!hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
14662
+ if (!isActiveSelectionSideResize && !hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
14684
14663
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14685
14664
  const newLeft = (groupToMove.left ?? 0) + deltaX;
14686
14665
  const newTop = (groupToMove.top ?? 0) + deltaY;
@@ -24286,9 +24265,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24286
24265
  }
24287
24266
  return svgString;
24288
24267
  }
24289
- const resolvedPackageVersion = "0.5.328";
24268
+ const resolvedPackageVersion = "0.5.330";
24290
24269
  const PACKAGE_VERSION = resolvedPackageVersion;
24291
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.328";
24270
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.330";
24292
24271
  const roundParityValue = (value) => {
24293
24272
  if (typeof value !== "number") return value;
24294
24273
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25102,7 +25081,7 @@ class PixldocsRenderer {
25102
25081
  await this.waitForCanvasScene(container, cloned, i);
25103
25082
  }
25104
25083
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25105
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-B4Vpz8di.cjs"));
25084
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CJBVK7bd.cjs"));
25106
25085
  const prepared = preparePagesForExport(
25107
25086
  cloned.pages,
25108
25087
  canvasWidth,
@@ -27422,7 +27401,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27422
27401
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27423
27402
  sanitizeSvgTreeForPdf(svgToDraw);
27424
27403
  try {
27425
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-B4Vpz8di.cjs"));
27404
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CJBVK7bd.cjs"));
27426
27405
  try {
27427
27406
  await logTextMeasurementDiagnostic(svgToDraw);
27428
27407
  } catch {
@@ -27819,4 +27798,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27819
27798
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27820
27799
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27821
27800
  exports.warmTemplateFromForm = warmTemplateFromForm;
27822
- //# sourceMappingURL=index-DhowYy-T.cjs.map
27801
+ //# sourceMappingURL=index-DyarJoo_.cjs.map