@pixldocs/canvas-renderer 0.5.277 → 0.5.279

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.
@@ -13903,14 +13903,24 @@ const PageCanvas = forwardRef(
13903
13903
  }
13904
13904
  });
13905
13905
  let cropGroupSaveTimer = null;
13906
+ let objectModifiedInFlight = false;
13906
13907
  fabricCanvas.on("object:modified", (e) => {
13907
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
13908
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
13909
+ if (objectModifiedInFlight) {
13910
+ if (shouldLogGroupMove()) {
13911
+ console.log("[GRP-MOVE] object:modified re-entry skipped", {
13912
+ targetType: (_b2 = (_a2 = e.target) == null ? void 0 : _a2.constructor) == null ? void 0 : _b2.name
13913
+ });
13914
+ }
13915
+ return;
13916
+ }
13917
+ objectModifiedInFlight = true;
13908
13918
  try {
13909
13919
  dragStarted = false;
13910
13920
  if (shouldLogGroupMove()) {
13911
13921
  const t = e.target;
13912
13922
  console.log("[GRP-MOVE] object:modified fired", {
13913
- targetType: (_a2 = t == null ? void 0 : t.constructor) == null ? void 0 : _a2.name,
13923
+ targetType: (_c = t == null ? void 0 : t.constructor) == null ? void 0 : _c.name,
13914
13924
  isActiveSelection: t instanceof fabric.ActiveSelection,
13915
13925
  groupSelectionId: t ? t.__pixldocsGroupSelection : null,
13916
13926
  memberIds: t instanceof fabric.ActiveSelection ? t.getObjects().map((o) => getObjectId(o)) : [getObjectId(t)],
@@ -13962,7 +13972,7 @@ const PageCanvas = forwardRef(
13962
13972
  const active = fabricCanvas.getActiveObject();
13963
13973
  const activeId = active ? getObjectId(active) : null;
13964
13974
  if (active && activeId && activeId !== "__background__" && !(active instanceof fabric.Group)) {
13965
- const pageChildrenForParent = ((_b2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _b2.children) ?? [];
13975
+ const pageChildrenForParent = ((_d = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
13966
13976
  const parentGroup = findParentGroup(pageChildrenForParent, activeId);
13967
13977
  if (parentGroup && isGroup(parentGroup) && parentGroup.backgroundColor) {
13968
13978
  let fabricSectionGroup = active.group && active.group instanceof fabric.Group ? active.group : null;
@@ -14044,7 +14054,7 @@ const PageCanvas = forwardRef(
14044
14054
  useEditorStore.getState().reflowStackGroupInPage(pageId, groupId);
14045
14055
  }
14046
14056
  const stateAfter = useEditorStore.getState();
14047
- const pageAfter = ((_c = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _c.children) ?? [];
14057
+ const pageAfter = ((_e = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _e.children) ?? [];
14048
14058
  const groupNodeAfter = findNodeById(pageAfter, groupId);
14049
14059
  if (groupNodeAfter) {
14050
14060
  const abs = getAbsoluteBounds(groupNodeAfter, pageAfter);
@@ -14106,7 +14116,7 @@ const PageCanvas = forwardRef(
14106
14116
  }
14107
14117
  if (active && active instanceof fabric.Group && active.__docuforgeSectionGroup && getObjectId(active)) {
14108
14118
  const groupId = getObjectId(active);
14109
- const pageChildrenSec = ((_d = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
14119
+ const pageChildrenSec = ((_f = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _f.children) ?? [];
14110
14120
  const modifiedTarget2 = e == null ? void 0 : e.target;
14111
14121
  const resizeScaleTarget = lastResizeScaleTargetRef.current;
14112
14122
  lastResizeScaleTargetRef.current = null;
@@ -14137,7 +14147,7 @@ const PageCanvas = forwardRef(
14137
14147
  const node = findNodeById(pageChildrenSec, groupId);
14138
14148
  if (isChildModified && node && !groupMoved) {
14139
14149
  const stateAfter = useEditorStore.getState();
14140
- const pageAfter = ((_e = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _e.children) ?? [];
14150
+ const pageAfter = ((_g = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _g.children) ?? [];
14141
14151
  const groupNodeAfter = findNodeById(pageAfter, groupId);
14142
14152
  if (groupNodeAfter) {
14143
14153
  const abs = getAbsoluteBounds(groupNodeAfter, pageAfter);
@@ -14153,7 +14163,7 @@ const PageCanvas = forwardRef(
14153
14163
  }
14154
14164
  if (active && active instanceof fabric.Group && !(active instanceof fabric.ActiveSelection) && getObjectId(active)) {
14155
14165
  const groupId = getObjectId(active);
14156
- const pageChildren3 = ((_f = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _f.children) ?? [];
14166
+ const pageChildren3 = ((_h = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _h.children) ?? [];
14157
14167
  const w = (active.width ?? 0) * (active.scaleX ?? 1);
14158
14168
  const h = (active.height ?? 0) * (active.scaleY ?? 1);
14159
14169
  const centerX = active.left ?? 0;
@@ -14175,7 +14185,7 @@ const PageCanvas = forwardRef(
14175
14185
  }
14176
14186
  const activeObj = fabricCanvas.getActiveObject();
14177
14187
  let activeObjects = fabricCanvas.getActiveObjects();
14178
- const activeSelectionMoveStart = activeObj instanceof fabric.ActiveSelection && ((_g = activeSelectionMoveStartRef.current) == null ? void 0 : _g.selection) === activeObj ? activeSelectionMoveStartRef.current : null;
14188
+ const activeSelectionMoveStart = activeObj instanceof fabric.ActiveSelection && ((_i = activeSelectionMoveStartRef.current) == null ? void 0 : _i.selection) === activeObj ? activeSelectionMoveStartRef.current : null;
14179
14189
  const activeSelectionDelta = activeObj instanceof fabric.ActiveSelection && activeSelectionMoveStart ? (() => {
14180
14190
  const rect = activeObj.getBoundingRect();
14181
14191
  return {
@@ -14375,7 +14385,7 @@ const PageCanvas = forwardRef(
14375
14385
  }
14376
14386
  } catch {
14377
14387
  }
14378
- const pageAfterMove = ((_h = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _h.children) ?? [];
14388
+ const pageAfterMove = ((_j = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _j.children) ?? [];
14379
14389
  const groupAfterMove = findNodeById(pageAfterMove, groupToMove.id);
14380
14390
  const memberIdsAfterMove = groupAfterMove && isGroup(groupAfterMove) ? getAllElementIds(groupAfterMove.children ?? []) : targetObjects.map((obj) => getObjectId(obj)).filter((id) => !!id && id !== "__background__");
14381
14391
  preservedGroupMemberIds = memberIdsAfterMove;
@@ -14388,10 +14398,15 @@ const PageCanvas = forwardRef(
14388
14398
  const bounds = getNodeBounds(node, pageAfterMove, pageBoundsOptions);
14389
14399
  const __prevLeft = obj.left;
14390
14400
  const __prevTop = obj.top;
14391
- if (obj instanceof fabric.Group && obj.__cropGroup || obj instanceof fabric.FabricImage && (obj.originX === "center" || obj.originY === "center")) {
14392
- obj.set({ left: abs.left + Math.max(1, bounds.width) / 2, top: abs.top + Math.max(1, bounds.height) / 2 });
14401
+ const useCenterAnchor = obj instanceof fabric.Group && obj.__cropGroup || obj instanceof fabric.FabricImage && (obj.originX === "center" || obj.originY === "center");
14402
+ const nextPoint = new fabric.Point(
14403
+ useCenterAnchor ? abs.left + Math.max(1, bounds.width) / 2 : abs.left,
14404
+ useCenterAnchor ? abs.top + Math.max(1, bounds.height) / 2 : abs.top
14405
+ );
14406
+ if (typeof obj.setXY === "function") {
14407
+ obj.setXY(nextPoint, useCenterAnchor ? "center" : "left", useCenterAnchor ? "center" : "top");
14393
14408
  } else {
14394
- obj.set({ left: abs.left, top: abs.top });
14409
+ obj.set({ left: nextPoint.x, top: nextPoint.y });
14395
14410
  }
14396
14411
  obj.setCoords();
14397
14412
  if (shouldLogGroupMove()) {
@@ -14690,7 +14705,7 @@ const PageCanvas = forwardRef(
14690
14705
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
14691
14706
  obj.setCoords();
14692
14707
  }
14693
- const pageChildrenForReflow = ((_i = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _i.children) ?? [];
14708
+ const pageChildrenForReflow = ((_k = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _k.children) ?? [];
14694
14709
  const stackGroupsToReflow = /* @__PURE__ */ new Set();
14695
14710
  for (const id of modifiedIdsThisRound) {
14696
14711
  const parent = findParentGroup(pageChildrenForReflow, id);
@@ -14759,6 +14774,8 @@ const PageCanvas = forwardRef(
14759
14774
  } catch (e2) {
14760
14775
  lastResizeScaleCornerRef.current = null;
14761
14776
  unlockEditsSoon();
14777
+ } finally {
14778
+ objectModifiedInFlight = false;
14762
14779
  }
14763
14780
  });
14764
14781
  fabricCanvas.on("before:selection:cleared", (e) => {
@@ -15070,6 +15087,7 @@ const PageCanvas = forwardRef(
15070
15087
  skipSelectionClearOnDiscardRef.current = false;
15071
15088
  }
15072
15089
  }
15090
+ activeSelectionSnapshot.memberIds.forEach((id) => justModifiedIdsRef.current.delete(id));
15073
15091
  }
15074
15092
  const currentFabricObjects = /* @__PURE__ */ new Map();
15075
15093
  fc.getObjects().forEach((obj) => {
@@ -23851,9 +23869,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23851
23869
  }
23852
23870
  return svgString;
23853
23871
  }
23854
- const resolvedPackageVersion = "0.5.277";
23872
+ const resolvedPackageVersion = "0.5.279";
23855
23873
  const PACKAGE_VERSION = resolvedPackageVersion;
23856
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.277";
23874
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.279";
23857
23875
  const roundParityValue = (value) => {
23858
23876
  if (typeof value !== "number") return value;
23859
23877
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24667,7 +24685,7 @@ class PixldocsRenderer {
24667
24685
  await this.waitForCanvasScene(container, cloned, i);
24668
24686
  }
24669
24687
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24670
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CateNrsD.js");
24688
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Bp8RGRa1.js");
24671
24689
  const prepared = preparePagesForExport(
24672
24690
  cloned.pages,
24673
24691
  canvasWidth,
@@ -26987,7 +27005,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26987
27005
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26988
27006
  sanitizeSvgTreeForPdf(svgToDraw);
26989
27007
  try {
26990
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CateNrsD.js");
27008
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Bp8RGRa1.js");
26991
27009
  try {
26992
27010
  await logTextMeasurementDiagnostic(svgToDraw);
26993
27011
  } catch {
@@ -27387,4 +27405,4 @@ export {
27387
27405
  buildTeaserBlurFlatKeys as y,
27388
27406
  collectFontDescriptorsFromConfig as z
27389
27407
  };
27390
- //# sourceMappingURL=index-uuizjIPx.js.map
27408
+ //# sourceMappingURL=index-mvcNnW-5.js.map