@pixldocs/canvas-renderer 0.5.268 → 0.5.270

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.
@@ -11013,9 +11013,9 @@ const scaleUpdateNumber = (updates, source, key, factor) => {
11013
11013
  const value = Number(source == null ? void 0 : source[key]);
11014
11014
  if (Number.isFinite(value)) updates[key] = value * factor;
11015
11015
  };
11016
- const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
11017
- const sx = Math.abs(obj.scaleX ?? 1) || 1;
11018
- const sy = Math.abs(obj.scaleY ?? 1) || 1;
11016
+ const bakeTextboxScaleIntoTypography = (obj, sourceElement, scaleOverride) => {
11017
+ const sx = Math.abs((scaleOverride == null ? void 0 : scaleOverride.scaleX) ?? obj.scaleX ?? 1) || 1;
11018
+ const sy = Math.abs((scaleOverride == null ? void 0 : scaleOverride.scaleY) ?? obj.scaleY ?? 1) || 1;
11019
11019
  if (Math.abs(sx - 1) < 1e-3 && Math.abs(sy - 1) < 1e-3) return null;
11020
11020
  const isUniform = Math.abs(sx - sy) < 0.01;
11021
11021
  const fontScale = isUniform ? (sx + sy) / 2 : Math.abs(sy - 1) > 1e-3 ? sy : 1;
@@ -11231,6 +11231,7 @@ const PageCanvas = react.forwardRef(
11231
11231
  react.useRef(null);
11232
11232
  const lastTextEditDimensionsRef = react.useRef(null);
11233
11233
  const lastResizeScaleTargetRef = react.useRef(null);
11234
+ const lastResizeScaleCornerRef = react.useRef(null);
11234
11235
  const preserveSelectionAfterTransformIdRef = react.useRef(null);
11235
11236
  const groupSelectionTransformStartRef = react.useRef(null);
11236
11237
  const activeSelectionMoveStartRef = react.useRef(null);
@@ -11558,6 +11559,7 @@ const PageCanvas = react.forwardRef(
11558
11559
  fc.__isUserTransforming = true;
11559
11560
  didTransformRef.current = true;
11560
11561
  lastResizeScaleTargetRef.current = target;
11562
+ lastResizeScaleCornerRef.current = corner;
11561
11563
  const targetId = getObjectId(target);
11562
11564
  if (targetId && targetId !== "__background__") {
11563
11565
  preserveSelectionAfterTransformIdRef.current = targetId;
@@ -13385,10 +13387,11 @@ const PageCanvas = react.forwardRef(
13385
13387
  fabricCanvas.on("selection:cleared", () => {
13386
13388
  });
13387
13389
  fabricCanvas.on("object:scaling", (e) => {
13388
- var _a2;
13390
+ var _a2, _b2;
13389
13391
  if (!isActiveRef.current) return;
13390
13392
  const t = e.target;
13391
13393
  if (t) lastResizeScaleTargetRef.current = t;
13394
+ lastResizeScaleCornerRef.current = ((_a2 = e.transform) == null ? void 0 : _a2.corner) ?? null;
13392
13395
  prepareGroupSelectionTransformStart(t);
13393
13396
  markTransforming(t);
13394
13397
  didTransformRef.current = true;
@@ -13706,16 +13709,17 @@ const PageCanvas = react.forwardRef(
13706
13709
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
13707
13710
  if (drilledGroupIdRef.current) {
13708
13711
  try {
13709
- (_a2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _a2.call(fabricCanvas);
13712
+ (_b2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _b2.call(fabricCanvas);
13710
13713
  } catch {
13711
13714
  }
13712
13715
  }
13713
13716
  });
13714
13717
  fabricCanvas.on("object:resizing", (e) => {
13715
- var _a2;
13718
+ var _a2, _b2;
13716
13719
  if (!isActiveRef.current) return;
13717
13720
  const t = e.target;
13718
13721
  if (t) lastResizeScaleTargetRef.current = t;
13722
+ lastResizeScaleCornerRef.current = ((_a2 = e.transform) == null ? void 0 : _a2.corner) ?? null;
13719
13723
  markTransforming(t);
13720
13724
  didTransformRef.current = true;
13721
13725
  const transformTargetId = t ? getObjectId(t) : null;
@@ -13791,7 +13795,7 @@ const PageCanvas = react.forwardRef(
13791
13795
  setGuides(gridGuidesForTextResize.length ? [...scaleGuides, ...gridGuidesForTextResize] : scaleGuides);
13792
13796
  if (drilledGroupIdRef.current) {
13793
13797
  try {
13794
- (_a2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _a2.call(fabricCanvas);
13798
+ (_b2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _b2.call(fabricCanvas);
13795
13799
  } catch {
13796
13800
  }
13797
13801
  }
@@ -14319,9 +14323,21 @@ const PageCanvas = react.forwardRef(
14319
14323
  const groupSelectionId = (isActiveSelection && activeObj instanceof fabric__namespace.ActiveSelection ? activeObj.__pixldocsGroupSelection : void 0) ?? groupToMove.id;
14320
14324
  const targetObjects = isActiveSelection && activeObj instanceof fabric__namespace.ActiveSelection ? activeObj.getObjects() : activeObjects;
14321
14325
  if (groupSelectionId && activeObj instanceof fabric__namespace.ActiveSelection) {
14322
- restoreGroupSelectionVisualState(activeObj, groupSelectionId);
14323
- fabricCanvas.setActiveObject(activeObj);
14324
- activeObj.setCoords();
14326
+ try {
14327
+ skipSelectionClearOnDiscardRef.current = true;
14328
+ skipActiveSelectionBakeOnClearRef.current = true;
14329
+ try {
14330
+ fabricCanvas.discardActiveObject();
14331
+ } finally {
14332
+ skipActiveSelectionBakeOnClearRef.current = false;
14333
+ skipSelectionClearOnDiscardRef.current = false;
14334
+ }
14335
+ } catch {
14336
+ }
14337
+ const bakedSelection = targetObjects.length > 1 ? new fabric__namespace.ActiveSelection(targetObjects, { canvas: fabricCanvas }) : activeObj;
14338
+ restoreGroupSelectionVisualState(bakedSelection, groupSelectionId);
14339
+ fabricCanvas.setActiveObject(bakedSelection);
14340
+ bakedSelection.setCoords();
14325
14341
  }
14326
14342
  selectElements([groupSelectionId], false, false);
14327
14343
  fabricCanvas.requestRenderAll();
@@ -14506,6 +14522,8 @@ const PageCanvas = react.forwardRef(
14506
14522
  } else if (obj instanceof fabric__namespace.Textbox && isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
14507
14523
  const sx = Math.abs(decomposed.scaleX || 1);
14508
14524
  const sy = Math.abs(decomposed.scaleY || 1);
14525
+ const lastCorner = lastResizeScaleCornerRef.current ?? "";
14526
+ const isCornerGroupScale = lastCorner === "tl" || lastCorner === "tr" || lastCorner === "bl" || lastCorner === "br";
14509
14527
  const bakedWidth = Math.max(20, intrinsicWidth * sx);
14510
14528
  const bakedHeight = Math.max(1, intrinsicHeight * sy);
14511
14529
  finalWidth = bakedWidth;
@@ -14513,8 +14531,13 @@ const PageCanvas = react.forwardRef(
14513
14531
  finalScaleX = 1;
14514
14532
  finalScaleY = 1;
14515
14533
  try {
14516
- obj.set({ width: bakedWidth, scaleX: 1, scaleY: 1 });
14517
- obj.initDimensions();
14534
+ if (isCornerGroupScale) {
14535
+ bakeTextboxScaleIntoTypography(obj, sourceElement, { scaleX: sx, scaleY: sy });
14536
+ } else {
14537
+ obj.set({ width: bakedWidth, scaleX: 1, scaleY: 1 });
14538
+ obj.minBoxHeight = bakedHeight;
14539
+ obj.initDimensions();
14540
+ }
14518
14541
  obj.setCoords();
14519
14542
  } catch {
14520
14543
  }
@@ -14655,10 +14678,12 @@ const PageCanvas = react.forwardRef(
14655
14678
  }
14656
14679
  groupSelectionTransformStartRef.current = null;
14657
14680
  activeSelectionMoveStartRef.current = null;
14681
+ lastResizeScaleCornerRef.current = null;
14658
14682
  setTimeout(() => modifiedIdsThisRound.forEach((id) => justModifiedIdsRef.current.delete(id)), 150);
14659
14683
  commitHistory();
14660
14684
  unlockEditsSoon();
14661
14685
  } catch (e2) {
14686
+ lastResizeScaleCornerRef.current = null;
14662
14687
  unlockEditsSoon();
14663
14688
  }
14664
14689
  });
@@ -14917,13 +14942,14 @@ const PageCanvas = react.forwardRef(
14917
14942
  visibilityUpdateInProgressRef.current = false;
14918
14943
  }
14919
14944
  doSyncRef.current = () => {
14920
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
14945
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
14921
14946
  const shouldSkipUpdates2 = syncLockedRef.current || editLockRef.current;
14922
14947
  const state = useEditorStore.getState();
14923
- const elementsToSync = elements;
14948
+ const storePage = state.canvas.pages.find((p) => p.id === pageId);
14949
+ const pageTree = isPreviewMode && (pageChildren == null ? void 0 : pageChildren.length) ? pageChildren ?? [] : (storePage == null ? void 0 : storePage.children) ?? [];
14950
+ const elementsToSync = isPreviewMode ? elements : pageTree.length ? flattenChildren(pageTree) : elements;
14924
14951
  elementsRef.current = elementsToSync;
14925
- const pageTree = isPreviewMode && (pageChildren == null ? void 0 : pageChildren.length) ? pageChildren ?? [] : ((_a2 = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _a2.children) ?? [];
14926
- const selectedIdsFromStore = new Set(((_b2 = state.canvas) == null ? void 0 : _b2.selectedIds) ?? []);
14952
+ const selectedIdsFromStore = new Set(((_a2 = state.canvas) == null ? void 0 : _a2.selectedIds) ?? []);
14927
14953
  isRebuildingRef.current = true;
14928
14954
  const allElementIds = new Set(elementsToSync.map((el) => el.id));
14929
14955
  const sectionGroups = pageTree.filter(
@@ -14951,7 +14977,7 @@ const PageCanvas = react.forwardRef(
14951
14977
  const activeObjId = activeObj ? getObjectId(activeObj) : null;
14952
14978
  const isTextBeingEdited = activeObjId && editingTextIdRef.current === activeObjId;
14953
14979
  const isMultiSelect = activeObj instanceof fabric__namespace.ActiveSelection;
14954
- if (activeObj && isMultiSelect && !(((_c = activeObj._ct) == null ? void 0 : _c.isCropGroup) || activeObj.__cropGroup) && !isTextBeingEdited) {
14980
+ if (activeObj && isMultiSelect && !(((_b2 = activeObj._ct) == null ? void 0 : _b2.isCropGroup) || activeObj.__cropGroup) && !isTextBeingEdited) {
14955
14981
  fc.discardActiveObject();
14956
14982
  }
14957
14983
  }
@@ -14988,7 +15014,7 @@ const PageCanvas = react.forwardRef(
14988
15014
  fc.requestRenderAll();
14989
15015
  }
14990
15016
  } else if (!skipRestoreSelection && restoreTarget && !isActiveTextBeingEdited) {
14991
- const isCropGroup2 = ((_d = restoreTarget._ct) == null ? void 0 : _d.isCropGroup) || restoreTarget.__cropGroup;
15017
+ const isCropGroup2 = ((_c = restoreTarget._ct) == null ? void 0 : _c.isCropGroup) || restoreTarget.__cropGroup;
14992
15018
  const isSectionGroup = activeId && sectionGroupIds.has(activeId);
14993
15019
  if ((isCropGroup2 || !shouldSkipUpdates2) && !isSectionGroup) {
14994
15020
  fc.setActiveObject(restoreTarget);
@@ -15116,7 +15142,7 @@ const PageCanvas = react.forwardRef(
15116
15142
  const sourceUrlChanged = currentUrlNormalized !== storedUrlNormalized;
15117
15143
  const newFadeKey = edgeFadeKey(element);
15118
15144
  const oldFadeKey = isCropGroup2 ? existingObj.__edgeFadeInputKey || "" : existingObj.__edgeFadeKey || "";
15119
- const innerImg = (_e = existingObj == null ? void 0 : existingObj.__cropData) == null ? void 0 : _e._img;
15145
+ const innerImg = (_d = existingObj == null ? void 0 : existingObj.__cropData) == null ? void 0 : _d._img;
15120
15146
  const innerOldKey = isCropGroup2 ? oldFadeKey : innerImg ? innerImg.__edgeFadeKey || "" : oldFadeKey;
15121
15147
  const cropFadeRendererMissing = isCropGroup2 && Boolean(newFadeKey) && !existingObj.__edgeFadeRenderConfig;
15122
15148
  const fadeKeyChanged = newFadeKey !== oldFadeKey || newFadeKey !== innerOldKey || cropFadeRendererMissing;
@@ -15124,14 +15150,14 @@ const PageCanvas = react.forwardRef(
15124
15150
  const needsCropGroupFadeUpdate = isCropGroup2 && fadeKeyChanged;
15125
15151
  const hadUrlBefore = storedImageUrl && String(storedImageUrl).trim() !== "";
15126
15152
  if (!hasUrl && hadUrlBefore) {
15127
- const resolvedSizeImg = (pageChildren == null ? void 0 : pageChildren.length) ? getNodeBounds(element, pageChildren) : { width: typeof element.width === "number" ? element.width : 200, height: typeof element.height === "number" ? element.height : 50 };
15153
+ const resolvedSizeImg = pageTree.length ? getNodeBounds(element, pageTree) : { width: typeof element.width === "number" ? element.width : 200, height: typeof element.height === "number" ? element.height : 50 };
15128
15154
  const hasExplicitSize = typeof element.width === "number" && Number.isFinite(element.width) && element.width > 0 && typeof element.height === "number" && Number.isFinite(element.height) && element.height > 0;
15129
15155
  const minVisiblePlaceholder = hasExplicitSize ? 1 : 20;
15130
15156
  const nextWidth = Math.max(minVisiblePlaceholder, Number(resolvedSizeImg.width) || 200);
15131
15157
  const nextHeight = Math.max(minVisiblePlaceholder, Number(resolvedSizeImg.height) || 50);
15132
- const storePosImg = pageChildren ? (() => {
15133
- const node = findNodeById(pageChildren, element.id);
15134
- return node ? getAbsoluteBounds(node, pageChildren) : { left: element.left ?? 0, top: element.top ?? 0 };
15158
+ const storePosImg = pageTree.length ? (() => {
15159
+ const node = findNodeById(pageTree, element.id);
15160
+ return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
15135
15161
  })() : { left: element.left ?? 0, top: element.top ?? 0 };
15136
15162
  const elementForPlaceholder = { ...element, width: nextWidth, height: nextHeight };
15137
15163
  const placeholder = isCropGroup2 ? createImagePlaceholderForGroup(elementForPlaceholder) : createImagePlaceholder(elementForPlaceholder);
@@ -15154,8 +15180,8 @@ const PageCanvas = react.forwardRef(
15154
15180
  fc.requestRenderAll();
15155
15181
  continue;
15156
15182
  }
15157
- const imageFitForReplace = element.imageFit || ((_f = element.style) == null ? void 0 : _f.imageFit) || "cover";
15158
- const clipShapeForReplace = element.clipShape ?? ((_g = element.style) == null ? void 0 : _g.imageFrameShape) ?? (isPreviewMode ? "rectangle" : "none");
15183
+ const imageFitForReplace = element.imageFit || ((_e = element.style) == null ? void 0 : _e.imageFit) || "cover";
15184
+ const clipShapeForReplace = element.clipShape ?? ((_f = element.style) == null ? void 0 : _f.imageFrameShape) ?? (isPreviewMode ? "rectangle" : "none");
15159
15185
  const needCropGroupForElement = imageFitForReplace !== "fill" || clipShapeForReplace && clipShapeForReplace !== "none";
15160
15186
  const plainImageNeedsCropGroup = hasUrl && !isCropGroup2 && existingObj instanceof fabric__namespace.FabricImage && needCropGroupForElement;
15161
15187
  if (hasUrl && (needsReload || isPlaceholder || plainImageNeedsCropGroup || needsCropGroupFadeUpdate)) {
@@ -15192,9 +15218,9 @@ const PageCanvas = react.forwardRef(
15192
15218
  }
15193
15219
  ct.rx = rxRatio;
15194
15220
  }
15195
- const cropPos = pageChildren ? (() => {
15196
- const node = findNodeById(pageChildren, element.id);
15197
- return node ? getAbsoluteBounds(node, pageChildren) : { left: element.left ?? 0, top: element.top ?? 0 };
15221
+ const cropPos = pageTree.length ? (() => {
15222
+ const node = findNodeById(pageTree, element.id);
15223
+ return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
15198
15224
  })() : { left: element.left ?? 0, top: element.top ?? 0 };
15199
15225
  const cropCenterX = cropPos.left + (ct.frameW ?? 0) / 2;
15200
15226
  const cropCenterY = cropPos.top + (ct.frameH ?? 0) / 2;
@@ -15291,7 +15317,7 @@ const PageCanvas = react.forwardRef(
15291
15317
  continue;
15292
15318
  }
15293
15319
  } else if (!hasUrl && !isPlaceholder) {
15294
- const resolvedSizeImg = (pageChildren == null ? void 0 : pageChildren.length) ? getNodeBounds(element, pageChildren) : { width: typeof element.width === "number" ? element.width : 200, height: typeof element.height === "number" ? element.height : 50 };
15320
+ const resolvedSizeImg = pageTree.length ? getNodeBounds(element, pageTree) : { width: typeof element.width === "number" ? element.width : 200, height: typeof element.height === "number" ? element.height : 50 };
15295
15321
  const hasExplicitSize = typeof element.width === "number" && Number.isFinite(element.width) && element.width > 0 && typeof element.height === "number" && Number.isFinite(element.height) && element.height > 0;
15296
15322
  const minVisiblePlaceholder = hasExplicitSize ? 1 : 20;
15297
15323
  const elementForPlaceholder = {
@@ -15321,11 +15347,11 @@ const PageCanvas = react.forwardRef(
15321
15347
  placeholder.__imageSrc = void 0;
15322
15348
  } else if (!isBeingTransformed && !isBeingTextEdited && !shouldSkipUpdates2) {
15323
15349
  if (isPlaceholderGroup) {
15324
- const storePosImg = pageChildren ? (() => {
15325
- const node = findNodeById(pageChildren, element.id);
15326
- return node ? getAbsoluteBounds(node, pageChildren) : { left: element.left ?? 0, top: element.top ?? 0 };
15350
+ const storePosImg = pageTree.length ? (() => {
15351
+ const node = findNodeById(pageTree, element.id);
15352
+ return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
15327
15353
  })() : { left: element.left ?? 0, top: element.top ?? 0 };
15328
- const resolvedSizeImg = (pageChildren == null ? void 0 : pageChildren.length) ? getNodeBounds(element, pageChildren) : { width: typeof element.width === "number" ? element.width : 200, height: typeof element.height === "number" ? element.height : 50 };
15354
+ const resolvedSizeImg = pageTree.length ? getNodeBounds(element, pageTree) : { width: typeof element.width === "number" ? element.width : 200, height: typeof element.height === "number" ? element.height : 50 };
15329
15355
  const hasExplicitSize = typeof element.width === "number" && Number.isFinite(element.width) && element.width > 0 && typeof element.height === "number" && Number.isFinite(element.height) && element.height > 0;
15330
15356
  const minVisiblePlaceholder = hasExplicitSize ? 1 : 20;
15331
15357
  const nextWidth = Math.max(minVisiblePlaceholder, Number(resolvedSizeImg.width) || 200);
@@ -15385,9 +15411,9 @@ const PageCanvas = react.forwardRef(
15385
15411
  const previousVisible = previousVisibilityRef.current.get(element.id) ?? true;
15386
15412
  const currentVisible = element.visible !== false;
15387
15413
  const visibilityChanged = previousVisible !== currentVisible;
15388
- const storePosForImg = pageChildren ? (() => {
15389
- const node = findNodeById(pageChildren, element.id);
15390
- return node ? getAbsoluteBounds(node, pageChildren) : { left: element.left ?? 0, top: element.top ?? 0 };
15414
+ const storePosForImg = pageTree.length ? (() => {
15415
+ const node = findNodeById(pageTree, element.id);
15416
+ return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
15391
15417
  })() : { left: element.left ?? 0, top: element.top ?? 0 };
15392
15418
  const positionChanged = Math.abs((existingObj.left ?? 0) - storePosForImg.left) > 0.1 || Math.abs((existingObj.top ?? 0) - storePosForImg.top) > 0.1;
15393
15419
  if (visibilityChanged && !positionChanged || visibilityUpdateInProgressRef.current) {
@@ -15585,7 +15611,7 @@ const PageCanvas = react.forwardRef(
15585
15611
  fc.add(placeholder);
15586
15612
  fc.bringObjectToFront(placeholder);
15587
15613
  const activeObj = fc.getActiveObject();
15588
- if (activeObj && (((_h = activeObj._ct) == null ? void 0 : _h.isCropGroup) || activeObj.__cropGroup)) {
15614
+ if (activeObj && (((_g = activeObj._ct) == null ? void 0 : _g.isCropGroup) || activeObj.__cropGroup)) {
15589
15615
  fc.setActiveObject(activeObj);
15590
15616
  }
15591
15617
  placeholder.dirty = true;
@@ -15625,7 +15651,7 @@ const PageCanvas = react.forwardRef(
15625
15651
  fc.add(obj);
15626
15652
  fc.bringObjectToFront(obj);
15627
15653
  const activeObj = fc.getActiveObject();
15628
- if (activeObj && (((_i = activeObj._ct) == null ? void 0 : _i.isCropGroup) || activeObj.__cropGroup)) {
15654
+ if (activeObj && (((_h = activeObj._ct) == null ? void 0 : _h.isCropGroup) || activeObj.__cropGroup)) {
15629
15655
  fc.setActiveObject(activeObj);
15630
15656
  }
15631
15657
  obj.dirty = true;
@@ -15655,10 +15681,18 @@ const PageCanvas = react.forwardRef(
15655
15681
  });
15656
15682
  allFabricObjects.forEach((obj) => fc.bringObjectToFront(obj));
15657
15683
  }
15684
+ const activeAfterObjectSync = fc.getActiveObject();
15685
+ if (activeAfterObjectSync instanceof fabric__namespace.ActiveSelection) {
15686
+ const groupSelectionId = activeAfterObjectSync.__pixldocsGroupSelection;
15687
+ if (groupSelectionId) {
15688
+ applyLogicalGroupSelectionVisualState(activeAfterObjectSync, groupSelectionId);
15689
+ activeAfterObjectSync.setCoords();
15690
+ }
15691
+ }
15658
15692
  isRebuildingRef.current = false;
15659
15693
  fc.requestRenderAll();
15660
15694
  if (activeBeforeSync && fc.getObjects().includes(activeBeforeSync)) {
15661
- const isCropGroup2 = ((_j = activeBeforeSync._ct) == null ? void 0 : _j.isCropGroup) || activeBeforeSync.__cropGroup;
15695
+ const isCropGroup2 = ((_i = activeBeforeSync._ct) == null ? void 0 : _i.isCropGroup) || activeBeforeSync.__cropGroup;
15662
15696
  if (isCropGroup2) {
15663
15697
  fc.setActiveObject(activeBeforeSync);
15664
15698
  fc.requestRenderAll();
@@ -17152,7 +17186,7 @@ const PageCanvas = react.forwardRef(
17152
17186
  if (imageFit === "fill" && !needCropGroup2) {
17153
17187
  const finalScaleX = baseScaleX * (element.scaleX ?? 1);
17154
17188
  const finalScaleY = baseScaleY * (element.scaleY ?? 1);
17155
- const pageTreeForCreate = ((pageChildren == null ? void 0 : pageChildren.length) ? pageChildren : (_f = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _f.children) ?? [];
17189
+ const pageTreeForCreate = ((isPreviewMode || isExportMode) && (pageChildren == null ? void 0 : pageChildren.length) ? pageChildren : (_f = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _f.children) ?? [];
17156
17190
  const createPos = pageTreeForCreate.length > 0 ? (() => {
17157
17191
  const node = findNodeById(pageTreeForCreate, element.id);
17158
17192
  return node ? getAbsoluteBounds(node, pageTreeForCreate) : { left: element.left ?? 0, top: element.top ?? 0 };
@@ -17202,7 +17236,7 @@ const PageCanvas = react.forwardRef(
17202
17236
  const needCropGroup = imageFitFinal !== "fill" || clipShapeFinal && clipShapeFinal !== "none";
17203
17237
  let finalObject = img;
17204
17238
  if (needCropGroup) {
17205
- const pageTreeForCropResolve = ((pageChildren == null ? void 0 : pageChildren.length) ? pageChildren : (_i = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _i.children) ?? [];
17239
+ const pageTreeForCropResolve = ((isPreviewMode || isExportMode) && (pageChildren == null ? void 0 : pageChildren.length) ? pageChildren : (_i = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _i.children) ?? [];
17206
17240
  const nodeForSize = pageTreeForCropResolve.length ? findNodeById(pageTreeForCropResolve, element.id) : null;
17207
17241
  const w = nodeForSize && isElement(nodeForSize) ? nodeForSize.width : element.width;
17208
17242
  const h = nodeForSize && isElement(nodeForSize) ? nodeForSize.height : element.height;
@@ -17246,7 +17280,7 @@ const PageCanvas = react.forwardRef(
17246
17280
  }
17247
17281
  const isDynamicField = dynamicFieldIds.includes(element.id);
17248
17282
  const canBeEvented = isEditorMode || isPreviewMode && isDynamicField;
17249
- const pageTreeForCrop = ((pageChildren == null ? void 0 : pageChildren.length) ? pageChildren : (_n = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _n.children) ?? [];
17283
+ const pageTreeForCrop = ((isPreviewMode || isExportMode) && (pageChildren == null ? void 0 : pageChildren.length) ? pageChildren : (_n = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _n.children) ?? [];
17250
17284
  const createPosForCrop = pageTreeForCrop.length > 0 ? (() => {
17251
17285
  const node = findNodeById(pageTreeForCrop, element.id);
17252
17286
  return node ? getAbsoluteBounds(node, pageTreeForCrop) : { left: element.left ?? 0, top: element.top ?? 0 };
@@ -23662,9 +23696,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23662
23696
  }
23663
23697
  return svgString;
23664
23698
  }
23665
- const resolvedPackageVersion = "0.5.268";
23699
+ const resolvedPackageVersion = "0.5.270";
23666
23700
  const PACKAGE_VERSION = resolvedPackageVersion;
23667
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.268";
23701
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.270";
23668
23702
  const roundParityValue = (value) => {
23669
23703
  if (typeof value !== "number") return value;
23670
23704
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24478,7 +24512,7 @@ class PixldocsRenderer {
24478
24512
  await this.waitForCanvasScene(container, cloned, i);
24479
24513
  }
24480
24514
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24481
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-D2g8-LcJ.cjs"));
24515
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BpHyRyQS.cjs"));
24482
24516
  const prepared = preparePagesForExport(
24483
24517
  cloned.pages,
24484
24518
  canvasWidth,
@@ -26798,7 +26832,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26798
26832
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26799
26833
  sanitizeSvgTreeForPdf(svgToDraw);
26800
26834
  try {
26801
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-D2g8-LcJ.cjs"));
26835
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BpHyRyQS.cjs"));
26802
26836
  try {
26803
26837
  await logTextMeasurementDiagnostic(svgToDraw);
26804
26838
  } catch {
@@ -27195,4 +27229,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27195
27229
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27196
27230
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27197
27231
  exports.warmTemplateFromForm = warmTemplateFromForm;
27198
- //# sourceMappingURL=index-DNGRsx4X.cjs.map
27232
+ //# sourceMappingURL=index-CLq3CdA3.cjs.map