@pixldocs/canvas-renderer 0.5.306 → 0.5.307

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.
@@ -11241,10 +11241,31 @@ const PageCanvas = forwardRef(
11241
11241
  const [ready, setReady] = useState(false);
11242
11242
  const [unlockRequestId, setUnlockRequestId] = useState(0);
11243
11243
  const applyLogicalGroupSelectionVisualState = useCallback((selection, groupId) => {
11244
- var _a2;
11244
+ var _a2, _b2;
11245
11245
  selection.__pixldocsGroupSelection = groupId;
11246
11246
  delete selection.__pixldocsLogicalGroupIds;
11247
11247
  selection.hasBorders = true;
11248
+ try {
11249
+ const state = useEditorStore.getState();
11250
+ const pages = ((_a2 = state.canvas) == null ? void 0 : _a2.pages) ?? [];
11251
+ let groupNode = null;
11252
+ for (const page of pages) {
11253
+ const found = findNodeById(page.children ?? [], groupId);
11254
+ if (found && isGroup(found)) {
11255
+ groupNode = found;
11256
+ break;
11257
+ }
11258
+ }
11259
+ if (groupNode && !isStackLayoutMode(groupNode.layoutMode) && typeof groupNode.angle === "number" && Math.abs(groupNode.angle) > 0.01) {
11260
+ const currentAngle = ((selection.angle ?? 0) % 360 + 360) % 360;
11261
+ const targetAngle = ((groupNode.angle ?? 0) % 360 + 360) % 360;
11262
+ if (Math.abs(currentAngle - targetAngle) > 0.01) {
11263
+ selection.rotate(targetAngle);
11264
+ selection.setCoords();
11265
+ }
11266
+ }
11267
+ } catch {
11268
+ }
11248
11269
  const members = selection.getObjects();
11249
11270
  for (const prev of suppressGroupMemberBordersRef.current) {
11250
11271
  if (members.includes(prev)) continue;
@@ -11268,7 +11289,7 @@ const PageCanvas = forwardRef(
11268
11289
  if (m.__pixldocsOrigHasControls === void 0) m.__pixldocsOrigHasControls = m.hasControls;
11269
11290
  m.hasBorders = false;
11270
11291
  m.hasControls = false;
11271
- if (m.__cropGroup || ((_a2 = m._ct) == null ? void 0 : _a2.isCropGroup)) {
11292
+ if (m.__cropGroup || ((_b2 = m._ct) == null ? void 0 : _b2.isCropGroup)) {
11272
11293
  if (m.__pixldocsOrigLockScalingX === void 0) {
11273
11294
  m.__pixldocsOrigLockScalingX = m.lockScalingX;
11274
11295
  m.__pixldocsOrigLockScalingY = m.lockScalingY;
@@ -13851,6 +13872,12 @@ const PageCanvas = forwardRef(
13851
13872
  if (didShift) didReflowTextChild = true;
13852
13873
  }
13853
13874
  if (isXSide && didReflowTextChild && typeof obj.triggerLayout === "function") {
13875
+ obj.setCoords();
13876
+ const cornersBefore = obj.aCoords;
13877
+ let fixedMidBefore = null;
13878
+ if (cornersBefore) {
13879
+ 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 };
13880
+ }
13854
13881
  try {
13855
13882
  obj.triggerLayout();
13856
13883
  } catch {
@@ -13859,11 +13886,22 @@ const PageCanvas = forwardRef(
13859
13886
  obj._set("scaleX", asSx0);
13860
13887
  obj._set("scaleY", asSy0);
13861
13888
  obj.setCoords();
13862
- const afterRect = obj.getBoundingRect();
13863
- const fixedLeft = asRect0.left;
13864
- const fixedRight = asRect0.left + asRect0.width;
13865
- const nextLeft = corner === "ml" ? (obj.left ?? 0) + (fixedRight - (afterRect.left + afterRect.width)) : (obj.left ?? 0) + (fixedLeft - afterRect.left);
13866
- obj._set("left", nextLeft);
13889
+ const cornersAfter = obj.aCoords;
13890
+ if (fixedMidBefore && cornersAfter) {
13891
+ const fixedMidAfter = corner === "ml" ? { x: (cornersAfter.tr.x + cornersAfter.br.x) / 2, y: (cornersAfter.tr.y + cornersAfter.br.y) / 2 } : { x: (cornersAfter.tl.x + cornersAfter.bl.x) / 2, y: (cornersAfter.tl.y + cornersAfter.bl.y) / 2 };
13892
+ const dx = fixedMidBefore.x - fixedMidAfter.x;
13893
+ const dy = fixedMidBefore.y - fixedMidAfter.y;
13894
+ if (Math.abs(dx) > 0.01 || Math.abs(dy) > 0.01) {
13895
+ obj._set("left", (obj.left ?? 0) + dx);
13896
+ obj._set("top", (obj.top ?? 0) + dy);
13897
+ }
13898
+ } else {
13899
+ const afterRect = obj.getBoundingRect();
13900
+ const fixedLeft = asRect0.left;
13901
+ const fixedRight = asRect0.left + asRect0.width;
13902
+ const nextLeft = corner === "ml" ? (obj.left ?? 0) + (fixedRight - (afterRect.left + afterRect.width)) : (obj.left ?? 0) + (fixedLeft - afterRect.left);
13903
+ obj._set("left", nextLeft);
13904
+ }
13867
13905
  } else {
13868
13906
  obj._set("height", asH0);
13869
13907
  obj._set("left", asLeft0);
@@ -14608,6 +14646,47 @@ const PageCanvas = forwardRef(
14608
14646
  unlockEditsSoon();
14609
14647
  return;
14610
14648
  }
14649
+ if (hadRotation && !hadScale && isActiveSelection && activeObj instanceof fabric.ActiveSelection && !isStackLayoutMode(groupToMove.layoutMode)) {
14650
+ const groupSelectionId = activeObj.__pixldocsGroupSelection ?? groupToMove.id;
14651
+ const newAngle = ((activeObj.angle ?? 0) % 360 + 360) % 360;
14652
+ const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14653
+ const rotPatch = { angle: newAngle === 0 ? void 0 : newAngle };
14654
+ if (Math.abs(deltaX) > 0.1) rotPatch.left = (groupToMove.left ?? 0) + deltaX;
14655
+ if (Math.abs(deltaY) > 0.1) rotPatch.top = (groupToMove.top ?? 0) + deltaY;
14656
+ updateNodeStore(groupToMove.id, rotPatch, { recordHistory: false, skipLayoutRecalc: true });
14657
+ commitHistoryStore();
14658
+ pendingGroupDrillInRef.current = null;
14659
+ fabricCanvas.__activeEditingGroupId = null;
14660
+ setDrilledGroupBounds(null);
14661
+ drilledGroupIdRef.current = null;
14662
+ if (groupSelectionId) {
14663
+ restoreGroupSelectionVisualState(activeObj, groupSelectionId);
14664
+ fabricCanvas.setActiveObject(activeObj);
14665
+ activeObj.setCoords();
14666
+ }
14667
+ selectElements([groupSelectionId], false, false);
14668
+ fabricCanvas.requestRenderAll();
14669
+ elementsRef.current = getCurrentElements();
14670
+ const rotTargets = activeObj.getObjects();
14671
+ for (const o of rotTargets) {
14672
+ const oid = getObjectId(o);
14673
+ if (oid && oid !== "__background__") {
14674
+ justModifiedIdsRef.current.add(oid);
14675
+ modifiedIdsThisRound.add(oid);
14676
+ }
14677
+ }
14678
+ setTimeout(() => modifiedIdsThisRound.forEach((id) => justModifiedIdsRef.current.delete(id)), 150);
14679
+ groupSelectionTransformStartRef.current = null;
14680
+ const rotSnapshot = {
14681
+ memberIds: rotTargets.map((o) => getObjectId(o)).filter((id) => !!id && id !== "__background__"),
14682
+ groupSelectionId,
14683
+ expiresAt: Date.now() + 1200
14684
+ };
14685
+ recentGroupSelectionRestoreRef.current = rotSnapshot;
14686
+ restorePreservedGroupSelectionSoon(rotSnapshot);
14687
+ unlockEditsSoon();
14688
+ return;
14689
+ }
14611
14690
  }
14612
14691
  }
14613
14692
  const pendingCropGroupFrameBakes = [];
@@ -24193,9 +24272,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24193
24272
  }
24194
24273
  return svgString;
24195
24274
  }
24196
- const resolvedPackageVersion = "0.5.306";
24275
+ const resolvedPackageVersion = "0.5.307";
24197
24276
  const PACKAGE_VERSION = resolvedPackageVersion;
24198
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.306";
24277
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.307";
24199
24278
  const roundParityValue = (value) => {
24200
24279
  if (typeof value !== "number") return value;
24201
24280
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25009,7 +25088,7 @@ class PixldocsRenderer {
25009
25088
  await this.waitForCanvasScene(container, cloned, i);
25010
25089
  }
25011
25090
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25012
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CBKunRKb.js");
25091
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-B6HX4s-I.js");
25013
25092
  const prepared = preparePagesForExport(
25014
25093
  cloned.pages,
25015
25094
  canvasWidth,
@@ -27329,7 +27408,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27329
27408
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27330
27409
  sanitizeSvgTreeForPdf(svgToDraw);
27331
27410
  try {
27332
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CBKunRKb.js");
27411
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-B6HX4s-I.js");
27333
27412
  try {
27334
27413
  await logTextMeasurementDiagnostic(svgToDraw);
27335
27414
  } catch {
@@ -27729,4 +27808,4 @@ export {
27729
27808
  buildTeaserBlurFlatKeys as y,
27730
27809
  collectFontDescriptorsFromConfig as z
27731
27810
  };
27732
- //# sourceMappingURL=index-DG1oNkJx.js.map
27811
+ //# sourceMappingURL=index-D4p1jWxS.js.map