@pixldocs/canvas-renderer 0.5.345 → 0.5.347

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.
@@ -11216,6 +11216,7 @@ function applyWarpAwareSelectionBorders(selection) {
11216
11216
  }
11217
11217
  selection.hasBorders = true;
11218
11218
  selection.hasControls = true;
11219
+ if (selection.__pixldocsGroupSelection) return;
11219
11220
  try {
11220
11221
  if (selection.__pixldocsAlignedAngle == null) {
11221
11222
  const kids = selection.getObjects();
@@ -12327,6 +12328,7 @@ const PageCanvas = forwardRef(
12327
12328
  selectionLeft: rect.left,
12328
12329
  selectionTop: rect.top
12329
12330
  };
12331
+ prepareGroupSelectionTransformStart(active);
12330
12332
  }
12331
12333
  if (fabricCanvas._currentTransform) {
12332
12334
  fabricCanvas.__isUserTransforming = true;
@@ -14462,7 +14464,7 @@ const PageCanvas = forwardRef(
14462
14464
  });
14463
14465
  let cropGroupSaveTimer = null;
14464
14466
  fabricCanvas.on("object:modified", (e) => {
14465
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
14467
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
14466
14468
  try {
14467
14469
  dragStarted = false;
14468
14470
  setGuides([]);
@@ -14970,9 +14972,8 @@ const PageCanvas = forwardRef(
14970
14972
  }
14971
14973
  if (!isActiveSelectionSideResize && !hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
14972
14974
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14973
- const newLeft = (groupToMove.left ?? 0) + deltaX;
14974
- const newTop = (groupToMove.top ?? 0) + deltaY;
14975
- updateNodeStore(groupToMove.id, { left: newLeft, top: newTop }, { recordHistory: false, skipLayoutRecalc: true });
14975
+ const storePos = absoluteToStorePosition(movedGroupLeft, movedGroupTop, groupToMove.id, pageChildren2);
14976
+ updateNodeStore(groupToMove.id, { left: storePos.left, top: storePos.top }, { recordHistory: false, skipLayoutRecalc: true });
14976
14977
  commitHistoryStore();
14977
14978
  pendingGroupDrillInRef.current = null;
14978
14979
  fabricCanvas.__activeEditingGroupId = null;
@@ -15014,7 +15015,35 @@ const PageCanvas = forwardRef(
15014
15015
  const pendingCropGroupFrameBakes = [];
15015
15016
  const logicalGroupSelectionId = activeObj instanceof fabric.ActiveSelection ? activeObj.__pixldocsGroupSelection : void 0;
15016
15017
  const isLogicalGroupAS = !!logicalGroupSelectionId && !(activeObj == null ? void 0 : activeObj.__cropGroup) && !(activeObj == null ? void 0 : activeObj.__docuforgeSectionGroup);
15017
- const asAngleForBake = isLogicalGroupAS && activeObj ? normalizeAngle(activeObj.angle ?? 0) : 0;
15018
+ const logicalGroupNodeForBake = logicalGroupSelectionId ? findNodeById(pageChildren2, logicalGroupSelectionId) : null;
15019
+ const asAngleForBake = isLogicalGroupAS && activeObj ? normalizeAngle(Number((logicalGroupNodeForBake == null ? void 0 : logicalGroupNodeForBake.angle) ?? activeObj.angle ?? 0)) : 0;
15020
+ const logicalGroupFinalFrame = (() => {
15021
+ var _a3;
15022
+ if (!isLogicalGroupAS || !logicalGroupSelectionId || !(activeObj instanceof fabric.ActiveSelection)) return null;
15023
+ const baseline = ((_a3 = groupSelectionTransformStartRef.current) == null ? void 0 : _a3.groupId) === logicalGroupSelectionId ? groupSelectionTransformStartRef.current : null;
15024
+ const localWidth = Math.max(1, (activeObj.width ?? (baseline == null ? void 0 : baseline.groupWidth) ?? 1) * Math.abs(activeObj.scaleX ?? 1));
15025
+ const localHeight = Math.max(1, (activeObj.height ?? (baseline == null ? void 0 : baseline.groupHeight) ?? 1) * Math.abs(activeObj.scaleY ?? 1));
15026
+ const center = activeObj.getCenterPoint();
15027
+ return {
15028
+ groupId: logicalGroupSelectionId,
15029
+ left: center.x - localWidth / 2,
15030
+ top: center.y - localHeight / 2,
15031
+ width: localWidth,
15032
+ height: localHeight,
15033
+ centerX: center.x,
15034
+ centerY: center.y,
15035
+ angle: asAngleForBake,
15036
+ matrix: fabric.util.composeMatrix({
15037
+ translateX: center.x,
15038
+ translateY: center.y,
15039
+ angle: asAngleForBake,
15040
+ scaleX: 1,
15041
+ scaleY: 1,
15042
+ skewX: 0,
15043
+ skewY: 0
15044
+ })
15045
+ };
15046
+ })();
15018
15047
  for (const obj of activeObjects) {
15019
15048
  const objId = getObjectId(obj);
15020
15049
  if (!objId || objId === "__background__") continue;
@@ -15458,7 +15487,18 @@ const PageCanvas = forwardRef(
15458
15487
  const state = useEditorStore.getState();
15459
15488
  const page = state.canvas.pages.find((p) => p.id === pageId);
15460
15489
  const pageChildrenForSave = (page == null ? void 0 : page.children) ?? [];
15461
- const storePos = absoluteToStorePosition(absoluteLeft, absoluteTop, objId, pageChildrenForSave);
15490
+ const storePos = (logicalGroupFinalFrame == null ? void 0 : logicalGroupFinalFrame.groupId) === logicalGroupSelectionId ? (() => {
15491
+ const localCenter = fabric.util.transformPoint(
15492
+ new fabric.Point(decomposed.translateX ?? 0, decomposed.translateY ?? 0),
15493
+ fabric.util.invertTransform(logicalGroupFinalFrame.matrix)
15494
+ );
15495
+ const localAngle = finalAngleFromDecomposed ? ((Number(finalAngle ?? 0) - asAngleForBake) % 360 + 540) % 360 - 180 : Number(finalAngle ?? 0);
15496
+ const localAngleRad = localAngle * Math.PI / 180;
15497
+ return {
15498
+ left: localCenter.x - finalWidth / 2 * Math.cos(localAngleRad) + finalHeight / 2 * Math.sin(localAngleRad) + logicalGroupFinalFrame.width / 2,
15499
+ top: localCenter.y - finalWidth / 2 * Math.sin(localAngleRad) - finalHeight / 2 * Math.cos(localAngleRad) + logicalGroupFinalFrame.height / 2
15500
+ };
15501
+ })() : absoluteToStorePosition(absoluteLeft, absoluteTop, objId, pageChildrenForSave);
15462
15502
  if (isLogicalGroupAS && finalAngleFromDecomposed && typeof finalAngle === "number") {
15463
15503
  finalAngle = ((finalAngle - asAngleForBake) % 360 + 540) % 360 - 180;
15464
15504
  }
@@ -15527,28 +15567,21 @@ const PageCanvas = forwardRef(
15527
15567
  try {
15528
15568
  const pageChildrenForGroup = ((_j = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _j.children) ?? [];
15529
15569
  const groupNode = findNodeById(pageChildrenForGroup, logicalGroupSelectionId);
15530
- if (groupNode) {
15531
- const baseline = ((_k = groupSelectionTransformStartRef.current) == null ? void 0 : _k.groupId) === logicalGroupSelectionId ? groupSelectionTransformStartRef.current : null;
15532
- const center = activeObj.getCenterPoint();
15533
- const prevAbs = getAbsoluteBounds(groupNode, pageChildrenForGroup, pageBoundsOptions);
15534
- const baseCenterX = (baseline == null ? void 0 : baseline.selectionCenterX) ?? prevAbs.left + prevAbs.width / 2;
15535
- const baseCenterY = (baseline == null ? void 0 : baseline.selectionCenterY) ?? prevAbs.top + prevAbs.height / 2;
15536
- const baseLeft = (baseline == null ? void 0 : baseline.groupLeft) ?? prevAbs.left;
15537
- const baseTop = (baseline == null ? void 0 : baseline.groupTop) ?? prevAbs.top;
15538
- const newAbsLeft = baseLeft + (center.x - baseCenterX);
15539
- const newAbsTop = baseTop + (center.y - baseCenterY);
15540
- const storePosGroup = absoluteToStorePosition(newAbsLeft, newAbsTop, logicalGroupSelectionId, pageChildrenForGroup);
15570
+ if (groupNode && logicalGroupFinalFrame) {
15571
+ const storePosGroup = absoluteToStorePosition(logicalGroupFinalFrame.left, logicalGroupFinalFrame.top, logicalGroupSelectionId, pageChildrenForGroup);
15541
15572
  useEditorStore.getState().updateNode(logicalGroupSelectionId, {
15542
15573
  left: storePosGroup.left,
15543
15574
  top: storePosGroup.top,
15544
- angle: asAngleForBake
15575
+ width: logicalGroupFinalFrame.width,
15576
+ height: logicalGroupFinalFrame.height,
15577
+ angle: logicalGroupFinalFrame.angle
15545
15578
  }, { recordHistory: false, skipLayoutRecalc: true });
15546
15579
  }
15547
15580
  } catch (err) {
15548
15581
  console.warn("[Pixldocs] logical-group envelope persist failed", err);
15549
15582
  }
15550
15583
  }
15551
- const pageChildrenForReflow = ((_l = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _l.children) ?? [];
15584
+ const pageChildrenForReflow = ((_k = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _k.children) ?? [];
15552
15585
  const stackGroupsToReflow = /* @__PURE__ */ new Set();
15553
15586
  for (const id of modifiedIdsThisRound) {
15554
15587
  const parent = findParentGroup(pageChildrenForReflow, id);
@@ -17011,9 +17044,7 @@ const PageCanvas = forwardRef(
17011
17044
  if (sameSelection && isFlatGroupSelection) {
17012
17045
  if (selectedGroupSelectionId && active instanceof fabric.ActiveSelection) {
17013
17046
  if (isPureSingleGroupSelection) {
17014
- active.__pixldocsGroupSelection = selectedGroupSelectionId;
17015
- delete active.__pixldocsLogicalGroupIds;
17016
- suppressGroupMemberBordersRef.current = active.getObjects();
17047
+ applyLogicalGroupSelectionVisualState(active, selectedGroupSelectionId);
17017
17048
  } else {
17018
17049
  delete active.__pixldocsGroupSelection;
17019
17050
  active.__pixldocsLogicalGroupIds = selectedGroupIds;
@@ -17053,8 +17084,7 @@ const PageCanvas = forwardRef(
17053
17084
  const selection = new fabric.ActiveSelection(toSelect, { canvas: fc });
17054
17085
  if (selectedGroupSelectionId) {
17055
17086
  if (isPureSingleGroupSelection) {
17056
- selection.__pixldocsGroupSelection = selectedGroupSelectionId;
17057
- suppressGroupMemberBordersRef.current = toSelect;
17087
+ applyLogicalGroupSelectionVisualState(selection, selectedGroupSelectionId);
17058
17088
  } else {
17059
17089
  selection.__pixldocsLogicalGroupIds = selectedGroupIds;
17060
17090
  selection.hasBorders = true;
@@ -24689,9 +24719,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24689
24719
  }
24690
24720
  return svgString;
24691
24721
  }
24692
- const resolvedPackageVersion = "0.5.345";
24722
+ const resolvedPackageVersion = "0.5.347";
24693
24723
  const PACKAGE_VERSION = resolvedPackageVersion;
24694
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.345";
24724
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.347";
24695
24725
  const roundParityValue = (value) => {
24696
24726
  if (typeof value !== "number") return value;
24697
24727
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25505,7 +25535,7 @@ class PixldocsRenderer {
25505
25535
  await this.waitForCanvasScene(container, cloned, i);
25506
25536
  }
25507
25537
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25508
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-rFbeCudV.js");
25538
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DVIaYc4_.js");
25509
25539
  const prepared = preparePagesForExport(
25510
25540
  cloned.pages,
25511
25541
  canvasWidth,
@@ -27825,7 +27855,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27825
27855
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27826
27856
  sanitizeSvgTreeForPdf(svgToDraw);
27827
27857
  try {
27828
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-rFbeCudV.js");
27858
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DVIaYc4_.js");
27829
27859
  try {
27830
27860
  await logTextMeasurementDiagnostic(svgToDraw);
27831
27861
  } catch {
@@ -28225,4 +28255,4 @@ export {
28225
28255
  buildTeaserBlurFlatKeys as y,
28226
28256
  collectFontDescriptorsFromConfig as z
28227
28257
  };
28228
- //# sourceMappingURL=index-wiw1EUl-.js.map
28258
+ //# sourceMappingURL=index-BV35-LzJ.js.map