@univerjs/docs-drawing-ui 1.0.0-alpha.8 → 1.0.0-beta.0

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.
package/lib/index.js CHANGED
@@ -2,11 +2,11 @@ import { AlignTypeH, AlignTypeV, BooleanNumber, COLORS, CommandType, DOC_DRAWING
2
2
  import { IDocDrawingAdapterService, IDocDrawingService, InsertDocDrawingCommand, RemoveDocDrawingCommand, SetDocDrawingArrangeCommand, TextWrappingStyle, UniverDocsDrawingPlugin, UpdateDocDrawingWrappingStyleCommand, UpdateDrawingDocTransformCommand, getDocDrawingRenderOrder } from "@univerjs/docs-drawing";
3
3
  import { CURSOR_TYPE, DocumentEditArea, DocumentSkeletonPageType, IRenderManagerService, Liquid, PageLayoutType, Rect, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin, Vector2, getColor, getCurrentTypeOfRenderer, getDocsTableRenderViewport, getTableIdAndSliceIndex } from "@univerjs/engine-render";
4
4
  import { Checkbox, InputNumber, MessageType, Radio, RadioGroup, Select, clsx, render, unmount } from "@univerjs/design";
5
- import { DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, UniverDocsPlugin, buildDocTransform, docDrawingPositionToTransform } from "@univerjs/docs";
5
+ import { DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, UniverDocsPlugin, buildDocTransform, docDrawingPositionToTransform, isSheetLikeDocsCustomBlockChildType } from "@univerjs/docs";
6
6
  import { DOC_CONTENT_INSERT_MENU_ID, DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID, DOC_PARAGRAPH_T_INSERT_MENU_ID, DocCanvasPopManagerService, DocPrintInterceptorService, DocSelectionRenderService, EMPTY_PARAGRAPH_MENU_ID, IEditorService, INSERT_BELLOW_MENU_ID, NodePositionConvertToCursor, SetDocZoomRatioOperation, TEXT_RANGE_LAYER_INDEX, UniverDocsUIPlugin, VIEWPORT_KEY, getAnchorBounding, getOneTextSelectionRange, neoGetDocObject } from "@univerjs/docs-ui";
7
7
  import { DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, IDrawingManagerService, UniverDrawingPlugin, getDrawingImageAllowSize, getDrawingShapeKeyByDrawingSearch, getImageSize } from "@univerjs/drawing";
8
- import { CanvasFloatDomService, ComponentManager, ContextMenuGroup, ContextMenuPosition, ILocalFileService, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, KeyCode, MenuItemType, PrintFloatDomSingle, RibbonInsertGroup, UniverUIPlugin, connectInjector, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
9
- import { BehaviorSubject, Observable, debounceTime, filter, map, of, switchMap, takeUntil } from "rxjs";
8
+ import { CanvasFloatDomService, ComponentManager, ContextMenuGroup, ContextMenuPosition, ILocalFileService, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, KeyCode, MenuItemType, PrintFloatDomSingle, RibbonInsertGroup, connectInjector, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
9
+ import { BehaviorSubject, Observable, debounceTime, filter, map, merge as merge$1, of, switchMap, takeUntil } from "rxjs";
10
10
  import { COMPONENT_IMAGE_POPUP_MENU, DrawingCommonPanel, DrawingRenderService, ImageCropperObject, ImageResetSizeOperation, OpenImageCropOperation, UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
11
11
  import { useEffect, useMemo, useState } from "react";
12
12
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -226,7 +226,7 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
226
226
  const scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
227
227
  scale = Math.min(scaleWidth, scaleHeight);
228
228
  }
229
- const imagePosition = insertPosition !== null && insertPosition !== void 0 ? insertPosition : this._getCurrentImageInsertPosition();
229
+ const imagePosition = insertPosition ?? this._getCurrentImageInsertPosition();
230
230
  const docTransform = this._getImagePosition(width * scale, height * scale, imagePosition);
231
231
  if (docTransform == null) return;
232
232
  const transform = docDrawingPositionToTransform(docTransform);
@@ -269,8 +269,7 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
269
269
  return editArea === DocumentEditArea.HEADER || editArea === DocumentEditArea.FOOTER;
270
270
  }
271
271
  _getImagePosition(imageWidth, imageHeight, insertPosition) {
272
- var _ref;
273
- return buildDocTransform(imageWidth, imageHeight, { left: ((_ref = insertPosition !== null && insertPosition !== void 0 ? insertPosition : this._getCurrentImageInsertPosition()) !== null && _ref !== void 0 ? _ref : {
272
+ return buildDocTransform(imageWidth, imageHeight, { left: (insertPosition ?? this._getCurrentImageInsertPosition() ?? {
274
273
  left: 0,
275
274
  top: 0
276
275
  }).left });
@@ -324,8 +323,7 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
324
323
  }
325
324
  _focusDrawingListener() {
326
325
  this.disposeWithMe(this._drawingManagerService.focus$.subscribe((params) => {
327
- var _this$_getCurrentScen;
328
- const { transformer, docsLeft, docsTop } = (_this$_getCurrentScen = this._getCurrentSceneAndTransformer()) !== null && _this$_getCurrentScen !== void 0 ? _this$_getCurrentScen : {};
326
+ const { transformer, docsLeft, docsTop } = this._getCurrentSceneAndTransformer() ?? {};
329
327
  if (params == null || params.length === 0) {
330
328
  this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, false);
331
329
  this._docDrawingService.focusDrawing([]);
@@ -349,10 +347,9 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
349
347
  }));
350
348
  }
351
349
  _findSegmentIdByDrawingId(drawingId) {
352
- var _body$customBlocks;
353
350
  const { unit: DocDataModel } = this._context;
354
351
  const { body, headers = {}, footers = {} } = DocDataModel.getSnapshot();
355
- if (((_body$customBlocks = body === null || body === void 0 ? void 0 : body.customBlocks) !== null && _body$customBlocks !== void 0 ? _body$customBlocks : []).some((b) => b.blockId === drawingId)) return "";
352
+ if (((body === null || body === void 0 ? void 0 : body.customBlocks) ?? []).some((b) => b.blockId === drawingId)) return "";
356
353
  for (const headerId of Object.keys(headers)) {
357
354
  var _headers$headerId$bod;
358
355
  if ((_headers$headerId$bod = headers[headerId].body.customBlocks) === null || _headers$headerId$bod === void 0 ? void 0 : _headers$headerId$bod.some((b) => b.blockId === drawingId)) return headerId;
@@ -426,9 +423,9 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
426
423
  }));
427
424
  }
428
425
  _setDrawingSelections(params) {
429
- var _unit$getSnapshot$bod, _unit$getSnapshot$bod2;
426
+ var _unit$getSnapshot$bod;
430
427
  const { unit } = this._context;
431
- const customBlocks = (_unit$getSnapshot$bod = (_unit$getSnapshot$bod2 = unit.getSnapshot().body) === null || _unit$getSnapshot$bod2 === void 0 ? void 0 : _unit$getSnapshot$bod2.customBlocks) !== null && _unit$getSnapshot$bod !== void 0 ? _unit$getSnapshot$bod : [];
428
+ const customBlocks = ((_unit$getSnapshot$bod = unit.getSnapshot().body) === null || _unit$getSnapshot$bod === void 0 ? void 0 : _unit$getSnapshot$bod.customBlocks) ?? [];
432
429
  const ranges = params.map((item) => {
433
430
  const id = item.drawingId;
434
431
  const block = customBlocks.find((b) => b.blockId === id);
@@ -462,10 +459,10 @@ const InsertDocImageCommand = {
462
459
  id: "doc.command.insert-float-image",
463
460
  type: CommandType.COMMAND,
464
461
  handler: (accessor) => {
465
- var _getCurrentTypeOfRend, _getCurrentTypeOfRend2;
462
+ var _getCurrentTypeOfRend;
466
463
  const univerInstanceService = accessor.get(IUniverInstanceService);
467
464
  const renderManagerService = accessor.get(IRenderManagerService);
468
- return (_getCurrentTypeOfRend = (_getCurrentTypeOfRend2 = getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC, univerInstanceService, renderManagerService)) === null || _getCurrentTypeOfRend2 === void 0 ? void 0 : _getCurrentTypeOfRend2.with(DocDrawingUpdateRenderController).insertDocImage()) !== null && _getCurrentTypeOfRend !== void 0 ? _getCurrentTypeOfRend : false;
465
+ return ((_getCurrentTypeOfRend = getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC, univerInstanceService, renderManagerService)) === null || _getCurrentTypeOfRend === void 0 ? void 0 : _getCurrentTypeOfRend.with(DocDrawingUpdateRenderController).insertDocImage()) ?? false;
469
466
  }
470
467
  };
471
468
 
@@ -542,19 +539,10 @@ const MoveDocDrawingsCommand = {
542
539
  const { positionH, positionV } = drawingData.docTransform;
543
540
  const newPositionH = { ...positionH };
544
541
  const newPositionV = { ...positionV };
545
- if (direction === Direction.UP) {
546
- var _newPositionV$posOffs;
547
- newPositionV.posOffset = ((_newPositionV$posOffs = newPositionV.posOffset) !== null && _newPositionV$posOffs !== void 0 ? _newPositionV$posOffs : 0) - 2;
548
- } else if (direction === Direction.DOWN) {
549
- var _newPositionV$posOffs2;
550
- newPositionV.posOffset = ((_newPositionV$posOffs2 = newPositionV.posOffset) !== null && _newPositionV$posOffs2 !== void 0 ? _newPositionV$posOffs2 : 0) + 2;
551
- } else if (direction === Direction.LEFT) {
552
- var _newPositionH$posOffs;
553
- newPositionH.posOffset = ((_newPositionH$posOffs = newPositionH.posOffset) !== null && _newPositionH$posOffs !== void 0 ? _newPositionH$posOffs : 0) - 2;
554
- } else if (direction === Direction.RIGHT) {
555
- var _newPositionH$posOffs2;
556
- newPositionH.posOffset = ((_newPositionH$posOffs2 = newPositionH.posOffset) !== null && _newPositionH$posOffs2 !== void 0 ? _newPositionH$posOffs2 : 0) + 2;
557
- }
542
+ if (direction === Direction.UP) newPositionV.posOffset = (newPositionV.posOffset ?? 0) - 2;
543
+ else if (direction === Direction.DOWN) newPositionV.posOffset = (newPositionV.posOffset ?? 0) + 2;
544
+ else if (direction === Direction.LEFT) newPositionH.posOffset = (newPositionH.posOffset ?? 0) - 2;
545
+ else if (direction === Direction.RIGHT) newPositionH.posOffset = (newPositionH.posOffset ?? 0) + 2;
558
546
  return {
559
547
  drawingId,
560
548
  key: direction === Direction.UP || direction === Direction.DOWN ? "positionV" : "positionH",
@@ -669,7 +657,7 @@ function calcDocFloatDomPositionByRect(rect, scene, opacity = 1, angle = 0) {
669
657
  left: false,
670
658
  top: false
671
659
  },
672
- opacity: opacity !== null && opacity !== void 0 ? opacity : 1
660
+ opacity: opacity ?? 1
673
661
  };
674
662
  }
675
663
  function calcDocFloatDomPosition(object, renderUnit) {
@@ -696,6 +684,9 @@ function pickValidCustomBlockRenderViewport(viewport) {
696
684
  if (isPositiveNumber(viewport === null || viewport === void 0 ? void 0 : viewport.contentHeight)) result.contentHeight = viewport.contentHeight;
697
685
  if (isPositiveNumber(viewport === null || viewport === void 0 ? void 0 : viewport.contentWidth)) result.contentWidth = viewport.contentWidth;
698
686
  if (isPositiveNumber(viewport === null || viewport === void 0 ? void 0 : viewport.height)) result.height = viewport.height;
687
+ if (isPositiveNumber(viewport === null || viewport === void 0 ? void 0 : viewport.pageContentWidth)) result.pageContentWidth = viewport.pageContentWidth;
688
+ const viewScale = viewport === null || viewport === void 0 ? void 0 : viewport.viewScale;
689
+ if (isPositiveNumber(viewScale)) result.viewScale = viewScale;
699
690
  if (isPositiveNumber(viewport === null || viewport === void 0 ? void 0 : viewport.viewportHeight)) result.viewportHeight = viewport.viewportHeight;
700
691
  return Object.keys(result).length ? result : void 0;
701
692
  }
@@ -782,6 +773,10 @@ let DocFloatDomController = class DocFloatDomController extends Disposable {
782
773
  position$,
783
774
  id: rectParam.drawingId,
784
775
  componentKey: rectParam.componentKey,
776
+ contentBox: isSheetLikeEmbedFloatDomRuntimeParam(runtimeParam) ? {
777
+ contentInset: 0,
778
+ wrapperInset: 0
779
+ } : void 0,
785
780
  eventPassThrough: preserveRuntimeGeometry ? false : void 0,
786
781
  preserveOnFocusChange: preserveRuntimeGeometry,
787
782
  onPointerDown: (evt) => {
@@ -819,7 +814,7 @@ let DocFloatDomController = class DocFloatDomController extends Disposable {
819
814
  params.forEach((param) => {
820
815
  var _this$_canvasFloatDom;
821
816
  const floatDomInfo = this._domLayerInfoMap.get(param.drawingId);
822
- if (!floatDomInfo) return;
817
+ if (!floatDomInfo || floatDomInfo.unitId !== param.unitId) return;
823
818
  const runtimeParam = param;
824
819
  const runtimeViewport = pickValidCustomBlockRenderViewport(runtimeParam.customBlockRenderViewport);
825
820
  if (runtimeViewport) floatDomInfo.runtimeViewport = runtimeViewport;
@@ -876,12 +871,14 @@ let DocFloatDomController = class DocFloatDomController extends Disposable {
876
871
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
877
872
  if (commandInfo.id === SetDocZoomRatioOperation.id) {
878
873
  const { unitId } = commandInfo.params;
879
- updateDoc(unitId);
874
+ globalThis.queueMicrotask(() => {
875
+ if (!this._disposed) updateDoc(unitId);
876
+ });
880
877
  }
881
878
  }));
882
879
  }
883
880
  insertFloatDom(floatDom, opts) {
884
- var _skeleton$getSkeleton, _opts$width, _opts$drawingId;
881
+ var _skeleton$getSkeleton;
885
882
  const currentDoc = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
886
883
  if (!currentDoc) return false;
887
884
  const render = this._getSceneAndTransformerByDrawingSearch(currentDoc.getUnitId());
@@ -892,7 +889,7 @@ let DocFloatDomController = class DocFloatDomController extends Disposable {
892
889
  const width = pageWidth - marginLeft - marginRight;
893
890
  const docTransform = {
894
891
  size: {
895
- width: (_opts$width = opts.width) !== null && _opts$width !== void 0 ? _opts$width : width,
892
+ width: opts.width ?? width,
896
893
  height: opts.height
897
894
  },
898
895
  positionH: {
@@ -905,7 +902,7 @@ let DocFloatDomController = class DocFloatDomController extends Disposable {
905
902
  },
906
903
  angle: 0
907
904
  };
908
- const drawingId = (_opts$drawingId = opts.drawingId) !== null && _opts$drawingId !== void 0 ? _opts$drawingId : generateRandomId();
905
+ const drawingId = opts.drawingId ?? generateRandomId();
909
906
  const params = {
910
907
  unitId: currentDoc.getUnitId(),
911
908
  drawings: [{
@@ -940,20 +937,16 @@ function syncRectWithRuntimeParam(rect, param, fallbackViewport, fallbackTransfo
940
937
  return true;
941
938
  }
942
939
  function getRuntimeTransform(param, rect, fallbackViewport, fallbackTransform, preserveRuntimeGeometry) {
943
- var _param$transform, _param$transforms, _param$customBlockRen, _runtimeViewport$heig2;
944
- const transform = (_param$transform = param.transform) !== null && _param$transform !== void 0 ? _param$transform : (_param$transforms = param.transforms) === null || _param$transforms === void 0 ? void 0 : _param$transforms[0];
945
- const runtimeViewport = (_param$customBlockRen = param.customBlockRenderViewport) !== null && _param$customBlockRen !== void 0 ? _param$customBlockRen : fallbackViewport;
946
- if (!param.customBlockRenderViewport && preserveRuntimeGeometry && fallbackTransform && transform) {
947
- var _fallbackTransform$wi, _fallbackTransform$he;
948
- return {
949
- ...transform,
950
- width: (_fallbackTransform$wi = fallbackTransform.width) !== null && _fallbackTransform$wi !== void 0 ? _fallbackTransform$wi : transform.width,
951
- height: (_fallbackTransform$he = fallbackTransform.height) !== null && _fallbackTransform$he !== void 0 ? _fallbackTransform$he : transform.height
952
- };
953
- }
940
+ var _param$transforms;
941
+ const transform = param.transform ?? ((_param$transforms = param.transforms) === null || _param$transforms === void 0 ? void 0 : _param$transforms[0]);
942
+ const runtimeViewport = param.customBlockRenderViewport ?? fallbackViewport;
943
+ if (!param.customBlockRenderViewport && preserveRuntimeGeometry && fallbackTransform && transform) return {
944
+ ...transform,
945
+ width: fallbackTransform.width ?? transform.width,
946
+ height: fallbackTransform.height ?? transform.height
947
+ };
954
948
  if (!transform) {
955
- var _runtimeViewport$heig;
956
- const height = (_runtimeViewport$heig = runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.height) !== null && _runtimeViewport$heig !== void 0 ? _runtimeViewport$heig : runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.contentHeight;
949
+ const height = (runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.height) ?? (runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.contentHeight);
957
950
  if (!isPositiveNumber(height)) return;
958
951
  return {
959
952
  left: rect.left,
@@ -963,7 +956,7 @@ function getRuntimeTransform(param, rect, fallbackViewport, fallbackTransform, p
963
956
  angle: rect.angle
964
957
  };
965
958
  }
966
- const height = (_runtimeViewport$heig2 = runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.height) !== null && _runtimeViewport$heig2 !== void 0 ? _runtimeViewport$heig2 : runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.contentHeight;
959
+ const height = (runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.height) ?? (runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.contentHeight);
967
960
  if (!isPositiveNumber(height)) return transform;
968
961
  return {
969
962
  ...transform,
@@ -976,6 +969,11 @@ function isEmbedFloatDomRuntimeParam(param) {
976
969
  const candidate = data;
977
970
  return candidate.version === 1 && typeof candidate.embedId === "string" && typeof candidate.hostAnchorId === "string";
978
971
  }
972
+ function isSheetLikeEmbedFloatDomRuntimeParam(param) {
973
+ if (!isEmbedFloatDomRuntimeParam(param)) return false;
974
+ const data = param.data;
975
+ return !!data && typeof data === "object" && "childType" in data && typeof data.childType === "number" && isSheetLikeDocsCustomBlockChildType(data.childType);
976
+ }
979
977
  function createTransformFromRect(rect) {
980
978
  return {
981
979
  angle: rect.angle,
@@ -1196,7 +1194,7 @@ const menuSchema = {
1196
1194
  //#endregion
1197
1195
  //#region package.json
1198
1196
  var name = "@univerjs/docs-drawing-ui";
1199
- var version = "1.0.0-alpha.8";
1197
+ var version = "1.0.0-beta.0";
1200
1198
 
1201
1199
  //#endregion
1202
1200
  //#region src/config/config.ts
@@ -1359,7 +1357,7 @@ function DocDrawingPositionContent(props) {
1359
1357
  else if (relativeFrom === ObjectRelativeFromH.PAGE) {}
1360
1358
  handlePositionChange("positionH", {
1361
1359
  relativeFrom,
1362
- posOffset: (prevPosOffset !== null && prevPosOffset !== void 0 ? prevPosOffset : 0) - delta
1360
+ posOffset: (prevPosOffset ?? 0) - delta
1363
1361
  });
1364
1362
  }
1365
1363
  function handleVerticalRelativeFromChange(value) {
@@ -1394,7 +1392,7 @@ function DocDrawingPositionContent(props) {
1394
1392
  else if (relativeFrom === ObjectRelativeFromV.PAGE) delta -= page.marginTop;
1395
1393
  handlePositionChange("positionV", {
1396
1394
  relativeFrom,
1397
- posOffset: (prevPosOffset !== null && prevPosOffset !== void 0 ? prevPosOffset : 0) - delta
1395
+ posOffset: (prevPosOffset ?? 0) - delta
1398
1396
  });
1399
1397
  }
1400
1398
  function updateState(drawingParam) {
@@ -1706,7 +1704,7 @@ const IMoveInlineDrawingCommand = {
1706
1704
  id: "doc.command.move-inline-drawing",
1707
1705
  type: CommandType.COMMAND,
1708
1706
  handler: (accessor, params) => {
1709
- var _renderManagerService, _docSelectionRenderSe;
1707
+ var _renderManagerService;
1710
1708
  if (params == null) return false;
1711
1709
  const { drawing, unitId, offset, segmentId: newSegmentId, segmentPage, needRefreshDrawings } = params;
1712
1710
  const renderManagerService = accessor.get(IRenderManagerService);
@@ -1727,7 +1725,7 @@ const IMoveInlineDrawingCommand = {
1727
1725
  }
1728
1726
  const rawActions = [];
1729
1727
  const { drawingId } = drawing;
1730
- const actions = getDeleteAndInsertCustomBlockActions(newSegmentId, (_docSelectionRenderSe = docSelectionRenderService.getSegment()) !== null && _docSelectionRenderSe !== void 0 ? _docSelectionRenderSe : "", segmentPage, offset, drawingId, documentDataModel, docSelectionRenderService);
1728
+ const actions = getDeleteAndInsertCustomBlockActions(newSegmentId, docSelectionRenderService.getSegment() ?? "", segmentPage, offset, drawingId, documentDataModel, docSelectionRenderService);
1731
1729
  if (actions == null || actions.length === 0) {
1732
1730
  docRefreshDrawingsService.refreshDrawings(skeleton);
1733
1731
  transformer.refreshControls();
@@ -1757,7 +1755,7 @@ const ITransformNonInlineDrawingCommand = {
1757
1755
  id: "doc.command.transform-non-inline-drawing",
1758
1756
  type: CommandType.COMMAND,
1759
1757
  handler: (accessor, params) => {
1760
- var _renderManagerService2, _docSelectionRenderSe2;
1758
+ var _renderManagerService2;
1761
1759
  if (params == null) return false;
1762
1760
  const { drawing, unitId, offset, docTransform, segmentId: newSegmentId, segmentPage } = params;
1763
1761
  const renderManagerService = accessor.get(IRenderManagerService);
@@ -1771,7 +1769,7 @@ const ITransformNonInlineDrawingCommand = {
1771
1769
  if (documentDataModel == null) return false;
1772
1770
  const rawActions = [];
1773
1771
  const { drawingId } = drawing;
1774
- const actions = getDeleteAndInsertCustomBlockActions(newSegmentId, (_docSelectionRenderSe2 = docSelectionRenderService.getSegment()) !== null && _docSelectionRenderSe2 !== void 0 ? _docSelectionRenderSe2 : "", segmentPage, offset, drawingId, documentDataModel, docSelectionRenderService);
1772
+ const actions = getDeleteAndInsertCustomBlockActions(newSegmentId, docSelectionRenderService.getSegment() ?? "", segmentPage, offset, drawingId, documentDataModel, docSelectionRenderService);
1775
1773
  if (actions == null) return false;
1776
1774
  if (actions.length > 0) rawActions.push(...actions);
1777
1775
  const jsonX = JSONX.getInstance();
@@ -2281,12 +2279,12 @@ let DocDrawingAddRemoveController = class DocDrawingAddRemoveController extends
2281
2279
  if (unitId == null || focusedDrawings.length === 0) return;
2282
2280
  const renderObject = this._renderManagerService.getRenderUnitById(unitId);
2283
2281
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
2284
- if (scene == null) return false;
2282
+ if (renderObject == null || scene == null) return false;
2283
+ this._docRefreshDrawingsService.refreshDrawings(renderObject.with(DocSkeletonManagerService).getSkeleton());
2285
2284
  scene.getTransformerByCreate().refreshControls();
2286
2285
  }));
2287
2286
  }
2288
2287
  _preserveWrappingStylePosition(params) {
2289
- var _documentDataModel$ge;
2290
2288
  if (params.wrappingStyle === TextWrappingStyle.INLINE) return;
2291
2289
  const { unitId } = params;
2292
2290
  const documentDataModel = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
@@ -2297,7 +2295,7 @@ let DocDrawingAddRemoveController = class DocDrawingAddRemoveController extends
2297
2295
  if (!documentDataModel || !skeletonData || !viewModel) return;
2298
2296
  const editArea = viewModel.getEditArea();
2299
2297
  const { pages, skeHeaders, skeFooters } = skeletonData;
2300
- const oldDrawings = (_documentDataModel$ge = documentDataModel.getDrawings()) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : {};
2298
+ const oldDrawings = documentDataModel.getDrawings() ?? {};
2301
2299
  params.drawings = params.drawings.map((drawing) => {
2302
2300
  const oldDrawing = oldDrawings[drawing.drawingId];
2303
2301
  if (!oldDrawing) return drawing;
@@ -2595,8 +2593,7 @@ function getDocsTableCellDrawingOffset(unitId, table, row, cell) {
2595
2593
  };
2596
2594
  }
2597
2595
  function hasHorizontalTableViewport(viewport) {
2598
- var _viewport$leadingInse, _viewport$trailingIns;
2599
- return viewport != null && ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0) + viewport.contentWidth + ((_viewport$trailingIns = viewport.trailingInsetRight) !== null && _viewport$trailingIns !== void 0 ? _viewport$trailingIns : 0) > viewport.viewportWidth;
2596
+ return viewport != null && (viewport.leadingInsetLeft ?? 0) + viewport.contentWidth + (viewport.trailingInsetRight ?? 0) > viewport.viewportWidth;
2600
2597
  }
2601
2598
  let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateController extends Disposable {
2602
2599
  constructor(_context, _docSkeletonManagerService, _commandService, _editorService, _drawingManagerService, _docRefreshDrawingsService, _univerInstanceService, _lifecycleService) {
@@ -2616,7 +2613,7 @@ let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateControl
2616
2613
  _initialize() {
2617
2614
  this._initialRenderRefresh();
2618
2615
  this._drawingInitializeListener();
2619
- this._initResize();
2616
+ this._initTransformRefresh();
2620
2617
  }
2621
2618
  _initialRenderRefresh() {
2622
2619
  this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe((documentSkeleton) => {
@@ -2645,8 +2642,8 @@ let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateControl
2645
2642
  }
2646
2643
  }));
2647
2644
  }
2648
- _initResize() {
2649
- this.disposeWithMe(fromEventSubject(this._context.engine.onTransformChange$).pipe(filter((evt) => evt.type === TRANSFORM_CHANGE_OBSERVABLE_TYPE.resize), debounceTime(16)).subscribe(() => {
2645
+ _initTransformRefresh() {
2646
+ this.disposeWithMe(merge$1(fromEventSubject(this._context.engine.onTransformChange$).pipe(filter((evt) => evt.type === TRANSFORM_CHANGE_OBSERVABLE_TYPE.resize)), fromEventSubject(this._context.scene.onTransformChange$).pipe(filter((evt) => evt.type === TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale))).pipe(debounceTime(16)).subscribe(() => {
2650
2647
  var _scene$getTransformer;
2651
2648
  const skeleton = this._docSkeletonManagerService.getSkeleton();
2652
2649
  const { scene } = this._context;
@@ -2700,21 +2697,17 @@ let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateControl
2700
2697
  this._handleMultiDrawingsTransform(multiDrawings);
2701
2698
  }
2702
2699
  _getStaleNonMultiDrawings(unitId, updateDrawingMap) {
2703
- var _this$_drawingManager;
2704
- const drawingData = (_this$_drawingManager = this._drawingManagerService.getDrawingData(unitId, unitId)) !== null && _this$_drawingManager !== void 0 ? _this$_drawingManager : {};
2705
- return Object.values(drawingData).filter((drawing) => drawing.isMultiTransform !== BooleanNumber.TRUE).filter((drawing) => updateDrawingMap[drawing.drawingId] == null).map((drawing) => {
2706
- var _drawing$transforms, _drawing$isMultiTrans;
2707
- return {
2708
- unitId,
2709
- subUnitId: unitId,
2710
- drawingId: drawing.drawingId,
2711
- behindText: false,
2712
- hidden: true,
2713
- transform: drawing.transform,
2714
- transforms: (_drawing$transforms = drawing.transforms) !== null && _drawing$transforms !== void 0 ? _drawing$transforms : [],
2715
- isMultiTransform: (_drawing$isMultiTrans = drawing.isMultiTransform) !== null && _drawing$isMultiTrans !== void 0 ? _drawing$isMultiTrans : BooleanNumber.FALSE
2716
- };
2717
- });
2700
+ const drawingData = this._drawingManagerService.getDrawingData(unitId, unitId) ?? {};
2701
+ return Object.values(drawingData).filter((drawing) => drawing.isMultiTransform !== BooleanNumber.TRUE).filter((drawing) => updateDrawingMap[drawing.drawingId] == null).map((drawing) => ({
2702
+ unitId,
2703
+ subUnitId: unitId,
2704
+ drawingId: drawing.drawingId,
2705
+ behindText: false,
2706
+ hidden: true,
2707
+ transform: drawing.transform,
2708
+ transforms: drawing.transforms ?? [],
2709
+ isMultiTransform: drawing.isMultiTransform ?? BooleanNumber.FALSE
2710
+ }));
2718
2711
  }
2719
2712
  _handleMultiDrawingsTransform(multiDrawings) {
2720
2713
  const { scene, unitId } = this._context;
@@ -2786,8 +2779,8 @@ let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateControl
2786
2779
  height
2787
2780
  }) : void 0;
2788
2781
  const transform = {
2789
- left: (pageRelativeLeft !== null && pageRelativeLeft !== void 0 ? pageRelativeLeft : aLeft) + docsLeft + (pageRelativeLeft == null ? this._liquid.x : pageOffsetLeft),
2790
- top: (pageRelativeTop !== null && pageRelativeTop !== void 0 ? pageRelativeTop : aTop) + docsTop + (pageRelativeTop == null ? this._liquid.y : pageOffsetTop),
2782
+ left: (pageRelativeLeft ?? aLeft) + docsLeft + (pageRelativeLeft == null ? this._liquid.x : pageOffsetLeft),
2783
+ top: (pageRelativeTop ?? aTop) + docsTop + (pageRelativeTop == null ? this._liquid.y : pageOffsetTop),
2791
2784
  width,
2792
2785
  height,
2793
2786
  angle,
@@ -2868,6 +2861,28 @@ function getDocsTableCellAnchorContext(unitId, cell) {
2868
2861
  table
2869
2862
  };
2870
2863
  }
2864
+ function shouldUseDocsDrawingOuterPageOrigin(config) {
2865
+ const { drawing, height, hostPage, page, width } = config;
2866
+ if (drawing.layoutType !== PositionedObjectLayoutType.WRAP_NONE) return false;
2867
+ return getDocsPageRelativeDrawingAnchorPage({
2868
+ page,
2869
+ clipPage: getDocsDrawingClipPage({
2870
+ drawing: {
2871
+ behindText: getDocsDrawingBehindText({
2872
+ drawingOrigin: drawing,
2873
+ hostPage
2874
+ }),
2875
+ transform: {
2876
+ width,
2877
+ height
2878
+ }
2879
+ },
2880
+ hostPage,
2881
+ page
2882
+ }),
2883
+ hostPage
2884
+ }) != null;
2885
+ }
2871
2886
  let DocDrawingTransformerController = class DocDrawingTransformerController extends Disposable {
2872
2887
  constructor(_commandService, _univerInstanceService, _drawingManagerService, _renderManagerService) {
2873
2888
  super();
@@ -2924,7 +2939,6 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
2924
2939
  }
2925
2940
  })));
2926
2941
  const throttleMultipleDrawingUpdate = throttle(this._updateMultipleDrawingDocTransform.bind(this), 50);
2927
- throttle(this._nonInlineDrawingTransform.bind(this), 50);
2928
2942
  this.disposeWithMe(toDisposable(transformer.changing$.subscribe((state) => {
2929
2943
  const { objects, offsetX, offsetY } = state;
2930
2944
  if (objects.size > 1) throttleMultipleDrawingUpdate(objects);
@@ -2932,7 +2946,6 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
2932
2946
  const drawingCache = this._transformerCache.values().next().value;
2933
2947
  const { width, height, top, left, angle } = objects.values().next().value;
2934
2948
  if (drawingCache && width === drawingCache.width && height === drawingCache.height && top === drawingCache.top && left === drawingCache.left && angle === drawingCache.angle) return;
2935
- if (drawingCache && drawingCache.drawing.layoutType !== PositionedObjectLayoutType.INLINE) {}
2936
2949
  if (drawingCache && drawingCache.drawing.layoutType === PositionedObjectLayoutType.INLINE && offsetX != null && offsetY != null) this._updateInlineDrawingAnchor(drawingCache.drawing, offsetX, offsetY);
2937
2950
  }
2938
2951
  })));
@@ -3026,14 +3039,13 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3026
3039
  this._getDrawingAnchor(drawingCache.drawing, object);
3027
3040
  }
3028
3041
  _updateInlineDrawingAnchor(drawing, offsetX, offsetY) {
3029
- var _this$_getInlineDrawi;
3030
3042
  if (this._transformerCache.size !== 1) return;
3031
- const { contentBoxPointGroup } = (_this$_getInlineDrawi = this._getInlineDrawingAnchor(drawing, offsetX, offsetY)) !== null && _this$_getInlineDrawi !== void 0 ? _this$_getInlineDrawi : {};
3043
+ const { contentBoxPointGroup } = this._getInlineDrawingAnchor(drawing, offsetX, offsetY) ?? {};
3032
3044
  if (contentBoxPointGroup == null) return;
3033
3045
  this._createOrUpdateInlineAnchor(drawing.unitId, contentBoxPointGroup);
3034
3046
  }
3035
3047
  _getInlineDrawingAnchor(drawing, offsetX, offsetY) {
3036
- var _this$_renderManagerS, _getOneTextSelectionR;
3048
+ var _this$_renderManagerS;
3037
3049
  const currentRender = this._renderManagerService.getRenderUnitById(drawing.unitId);
3038
3050
  const skeleton = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton();
3039
3051
  if (currentRender == null) return;
@@ -3071,7 +3083,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3071
3083
  isBack
3072
3084
  };
3073
3085
  const { cursorList, contentBoxPointGroup } = new NodePositionConvertToCursor(docObject.document.getOffsetConfig(), skeleton).getRangePointData(positionWithIsBack, positionWithIsBack);
3074
- const { startOffset } = (_getOneTextSelectionR = getOneTextSelectionRange(cursorList)) !== null && _getOneTextSelectionR !== void 0 ? _getOneTextSelectionR : {};
3086
+ const { startOffset } = getOneTextSelectionRange(cursorList) ?? {};
3075
3087
  if (startOffset == null) return;
3076
3088
  return {
3077
3089
  offset: startOffset,
@@ -3081,7 +3093,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3081
3093
  };
3082
3094
  }
3083
3095
  _getDrawingAnchor(drawing, object) {
3084
- var _this$_renderManagerS2, _glyphAnchor$parent, _column$parent$top, _column$parent, _column$lines$find, _column$parent2, _tableCellContext$hos, _getOneTextSelectionR2;
3096
+ var _this$_renderManagerS2, _glyphAnchor$parent, _column$parent, _column$parent2;
3085
3097
  const currentRender = this._renderManagerService.getRenderUnitById(drawing.unitId);
3086
3098
  const skeleton = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton();
3087
3099
  const skeletonData = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getSkeletonData();
@@ -3128,18 +3140,30 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3128
3140
  if (glyphAnchor == null) return;
3129
3141
  const line = (_glyphAnchor$parent = glyphAnchor.parent) === null || _glyphAnchor$parent === void 0 ? void 0 : _glyphAnchor$parent.parent;
3130
3142
  const column = line === null || line === void 0 ? void 0 : line.parent;
3131
- const sectionTop = (_column$parent$top = column === null || column === void 0 || (_column$parent = column.parent) === null || _column$parent === void 0 ? void 0 : _column$parent.top) !== null && _column$parent$top !== void 0 ? _column$parent$top : 0;
3132
- const paragraphStartLine = (_column$lines$find = column === null || column === void 0 ? void 0 : column.lines.find((l) => l.paragraphIndex === (line === null || line === void 0 ? void 0 : line.paragraphIndex) && l.paragraphStart)) !== null && _column$lines$find !== void 0 ? _column$lines$find : column === null || column === void 0 ? void 0 : column.lines[0];
3143
+ const sectionTop = (column === null || column === void 0 || (_column$parent = column.parent) === null || _column$parent === void 0 ? void 0 : _column$parent.top) ?? 0;
3144
+ const paragraphStartLine = (column === null || column === void 0 ? void 0 : column.lines.find((l) => l.paragraphIndex === (line === null || line === void 0 ? void 0 : line.paragraphIndex) && l.paragraphStart)) ?? (column === null || column === void 0 ? void 0 : column.lines[0]);
3133
3145
  const page = column === null || column === void 0 || (_column$parent2 = column.parent) === null || _column$parent2 === void 0 ? void 0 : _column$parent2.parent;
3134
3146
  if (line == null || column == null || paragraphStartLine == null || page == null) return;
3135
3147
  this._liquid.reset();
3136
3148
  const tableCellContext = page.type === DocumentSkeletonPageType.CELL ? getDocsTableCellAnchorContext(drawing.unitId, page) : null;
3137
- const anchorPage = (_tableCellContext$hos = tableCellContext === null || tableCellContext === void 0 ? void 0 : tableCellContext.hostPage) !== null && _tableCellContext$hos !== void 0 ? _tableCellContext$hos : page;
3149
+ const anchorPage = (tableCellContext === null || tableCellContext === void 0 ? void 0 : tableCellContext.hostPage) ?? page;
3138
3150
  const pageType = anchorPage.type;
3151
+ const drawingHostPage = (page.type === DocumentSkeletonPageType.HEADER || page.type === DocumentSkeletonPageType.FOOTER) && segmentPage > -1 ? pages[segmentPage] : void 0;
3152
+ const useOuterPageOrigin = shouldUseDocsDrawingOuterPageOrigin({
3153
+ drawing,
3154
+ height: object.height,
3155
+ hostPage: drawingHostPage,
3156
+ page,
3157
+ width: object.width
3158
+ });
3159
+ let pageOffsetLeft = this._liquid.x;
3160
+ let pageOffsetTop = this._liquid.y;
3139
3161
  for (const p of pages) {
3140
3162
  const { headerId, footerId, pageHeight, pageWidth, marginLeft, marginBottom } = p;
3141
3163
  const pIndex = pages.indexOf(p);
3142
3164
  if (segmentPage > -1 && pIndex === segmentPage) {
3165
+ pageOffsetLeft = this._liquid.x;
3166
+ pageOffsetTop = this._liquid.y;
3143
3167
  switch (pageType) {
3144
3168
  case DocumentSkeletonPageType.HEADER: {
3145
3169
  var _skeHeaders$get;
@@ -3167,6 +3191,10 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3167
3191
  }
3168
3192
  break;
3169
3193
  }
3194
+ if (p === anchorPage) {
3195
+ pageOffsetLeft = this._liquid.x;
3196
+ pageOffsetTop = this._liquid.y;
3197
+ }
3170
3198
  this._liquid.translatePagePadding(p);
3171
3199
  if (p === anchorPage) break;
3172
3200
  this._liquid.restorePagePadding(p);
@@ -3175,14 +3203,17 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3175
3203
  if (tableCellContext) this._liquid.translate(tableCellContext.offset.left, tableCellContext.offset.top);
3176
3204
  if (positionV.relativeFrom === ObjectRelativeFromV.LINE) glyphAnchor = line.divides[0].glyphGroup[0];
3177
3205
  else {
3178
- var _paragraphStartLine$d, _paragraphStartLine$d2;
3179
- glyphAnchor = (_paragraphStartLine$d = (_paragraphStartLine$d2 = paragraphStartLine.divides) === null || _paragraphStartLine$d2 === void 0 || (_paragraphStartLine$d2 = _paragraphStartLine$d2[0]) === null || _paragraphStartLine$d2 === void 0 || (_paragraphStartLine$d2 = _paragraphStartLine$d2.glyphGroup) === null || _paragraphStartLine$d2 === void 0 ? void 0 : _paragraphStartLine$d2[0]) !== null && _paragraphStartLine$d !== void 0 ? _paragraphStartLine$d : glyphAnchor;
3206
+ var _paragraphStartLine$d;
3207
+ glyphAnchor = ((_paragraphStartLine$d = paragraphStartLine.divides) === null || _paragraphStartLine$d === void 0 || (_paragraphStartLine$d = _paragraphStartLine$d[0]) === null || _paragraphStartLine$d === void 0 || (_paragraphStartLine$d = _paragraphStartLine$d.glyphGroup) === null || _paragraphStartLine$d === void 0 ? void 0 : _paragraphStartLine$d[0]) ?? glyphAnchor;
3180
3208
  }
3181
3209
  docTransform.positionH = {
3182
3210
  relativeFrom: positionH.relativeFrom,
3183
3211
  posOffset: left - this._liquid.x - docsLeft
3184
3212
  };
3185
3213
  switch (positionH.relativeFrom) {
3214
+ case ObjectRelativeFromH.PAGE:
3215
+ if (useOuterPageOrigin) docTransform.positionH.posOffset = left - pageOffsetLeft - docsLeft;
3216
+ break;
3186
3217
  case ObjectRelativeFromH.MARGIN:
3187
3218
  docTransform.positionH.posOffset = left - this._liquid.x - docsLeft - page.marginLeft;
3188
3219
  break;
@@ -3196,7 +3227,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3196
3227
  };
3197
3228
  switch (positionV.relativeFrom) {
3198
3229
  case ObjectRelativeFromV.PAGE:
3199
- docTransform.positionV.posOffset = top - this._liquid.y - docsTop - page.marginTop;
3230
+ docTransform.positionV.posOffset = useOuterPageOrigin ? top - pageOffsetTop - docsTop : top - this._liquid.y - docsTop + page.marginTop;
3200
3231
  break;
3201
3232
  case ObjectRelativeFromV.LINE:
3202
3233
  docTransform.positionV.posOffset = top - this._liquid.y - docsTop - sectionTop - line.top;
@@ -3214,7 +3245,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3214
3245
  isBack
3215
3246
  };
3216
3247
  const { cursorList } = new NodePositionConvertToCursor(docObject.document.getOffsetConfig(), skeleton).getRangePointData(positionWithIsBack, positionWithIsBack);
3217
- const { startOffset } = (_getOneTextSelectionR2 = getOneTextSelectionRange(cursorList)) !== null && _getOneTextSelectionR2 !== void 0 ? _getOneTextSelectionR2 : {};
3248
+ const { startOffset } = getOneTextSelectionRange(cursorList) ?? {};
3218
3249
  if (startOffset == null) return;
3219
3250
  return {
3220
3251
  offset: startOffset,
@@ -3251,8 +3282,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3251
3282
  });
3252
3283
  }
3253
3284
  _moveInlineDrawing(drawing, offsetX, offsetY) {
3254
- const anchor = this._getInlineDrawingAnchor(drawing, offsetX, offsetY);
3255
- const { offset, segmentId, segmentPage } = anchor !== null && anchor !== void 0 ? anchor : {};
3285
+ const { offset, segmentId, segmentPage } = this._getInlineDrawingAnchor(drawing, offsetX, offsetY) ?? {};
3256
3286
  return this._commandService.executeCommand(IMoveInlineDrawingCommand.id, {
3257
3287
  unitId: drawing.unitId,
3258
3288
  subUnitId: drawing.unitId,
@@ -3268,7 +3298,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3268
3298
  const { left, top, width, height, angle } = object;
3269
3299
  const skeleton = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton();
3270
3300
  const skeletonData = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getSkeletonData();
3271
- const { pages } = skeletonData !== null && skeletonData !== void 0 ? skeletonData : {};
3301
+ const { pages } = skeletonData ?? {};
3272
3302
  if (skeletonData == null || currentRender == null || pages == null) return {
3273
3303
  left,
3274
3304
  top,
@@ -3299,8 +3329,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3299
3329
  _nonInlineDrawingTransform(drawing, object, isMoving = false) {
3300
3330
  const objectPosition = drawing.isMultiTransform === BooleanNumber.TRUE ? object : this._limitDrawingInPage(drawing, object);
3301
3331
  if (isMoving && objectPosition.top !== object.top) return;
3302
- const anchor = this._getDrawingAnchor(drawing, objectPosition);
3303
- const { offset, docTransform, segmentId, segmentPage } = anchor !== null && anchor !== void 0 ? anchor : {};
3332
+ const { offset, docTransform, segmentId, segmentPage } = this._getDrawingAnchor(drawing, objectPosition) ?? {};
3304
3333
  if (offset == null || docTransform == null) return this._updateMultipleDrawingDocTransform(/* @__PURE__ */ new Map([[drawing.drawingId, object]]));
3305
3334
  return this._commandService.executeCommand(ITransformNonInlineDrawingCommand.id, {
3306
3335
  unitId: drawing.unitId,
@@ -3660,7 +3689,6 @@ let DocDrawingPopupMenuController = class DocDrawingPopupMenuController extends
3660
3689
  }));
3661
3690
  }
3662
3691
  _getDrawingPopupMenuItems(unitId, subUnitId, drawingId, drawingType) {
3663
- var _editCommandInfo$labe, _editCommandInfo$comm, _editCommandInfo$comm2, _editCommandInfo$disa;
3664
3692
  const drawing = this._drawingManagerService.getDrawingByParam({
3665
3693
  unitId,
3666
3694
  subUnitId,
@@ -3679,15 +3707,15 @@ let DocDrawingPopupMenuController = class DocDrawingPopupMenuController extends
3679
3707
  }) : null;
3680
3708
  return [
3681
3709
  {
3682
- label: (_editCommandInfo$labe = editCommandInfo === null || editCommandInfo === void 0 ? void 0 : editCommandInfo.label) !== null && _editCommandInfo$labe !== void 0 ? _editCommandInfo$labe : "docs-drawing-ui.image-popup.edit",
3710
+ label: (editCommandInfo === null || editCommandInfo === void 0 ? void 0 : editCommandInfo.label) ?? "docs-drawing-ui.image-popup.edit",
3683
3711
  index: 0,
3684
- commandId: (_editCommandInfo$comm = editCommandInfo === null || editCommandInfo === void 0 ? void 0 : editCommandInfo.commandId) !== null && _editCommandInfo$comm !== void 0 ? _editCommandInfo$comm : EditDocDrawingOperation.id,
3685
- commandParams: (_editCommandInfo$comm2 = editCommandInfo === null || editCommandInfo === void 0 ? void 0 : editCommandInfo.commandParams) !== null && _editCommandInfo$comm2 !== void 0 ? _editCommandInfo$comm2 : {
3712
+ commandId: (editCommandInfo === null || editCommandInfo === void 0 ? void 0 : editCommandInfo.commandId) ?? EditDocDrawingOperation.id,
3713
+ commandParams: (editCommandInfo === null || editCommandInfo === void 0 ? void 0 : editCommandInfo.commandParams) ?? {
3686
3714
  unitId,
3687
3715
  subUnitId,
3688
3716
  drawingId
3689
3717
  },
3690
- disable: (_editCommandInfo$disa = editCommandInfo === null || editCommandInfo === void 0 ? void 0 : editCommandInfo.disable) !== null && _editCommandInfo$disa !== void 0 ? _editCommandInfo$disa : drawingType === DrawingTypeEnum.DRAWING_DOM,
3718
+ disable: (editCommandInfo === null || editCommandInfo === void 0 ? void 0 : editCommandInfo.disable) ?? drawingType === DrawingTypeEnum.DRAWING_DOM,
3691
3719
  hideOnClick: true,
3692
3720
  icon: "DrawingEditIcon"
3693
3721
  },
@@ -3786,7 +3814,7 @@ _defineProperty(UniverDocsDrawingUIPlugin, "pluginName", "DOC_DRAWING_UI_PLUGIN"
3786
3814
  _defineProperty(UniverDocsDrawingUIPlugin, "packageName", name);
3787
3815
  _defineProperty(UniverDocsDrawingUIPlugin, "version", version);
3788
3816
  UniverDocsDrawingUIPlugin = __decorate([
3789
- DependentOn(UniverDocsPlugin, UniverDrawingPlugin, UniverRenderEnginePlugin, UniverDocsDrawingPlugin, UniverUIPlugin, UniverDocsUIPlugin, UniverDrawingUIPlugin),
3817
+ DependentOn(UniverDocsPlugin, UniverDrawingPlugin, UniverRenderEnginePlugin, UniverDocsDrawingPlugin, UniverDocsUIPlugin, UniverDrawingUIPlugin),
3790
3818
  __decorateParam(1, Inject(Injector)),
3791
3819
  __decorateParam(2, IRenderManagerService),
3792
3820
  __decorateParam(3, IConfigService)
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { Nullable } from '@univerjs/core';
16
+ import type { IDocDrawingBase, Nullable } from '@univerjs/core';
17
17
  import type { IDocumentSkeletonPage, IDocumentSkeletonRow, IDocumentSkeletonTable } from '@univerjs/engine-render';
18
18
  import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
19
19
  import { IDrawingManagerService } from '@univerjs/drawing';
@@ -29,6 +29,13 @@ export interface IDocsTableCellAnchorContext {
29
29
  table: IDocumentSkeletonTable;
30
30
  }
31
31
  export declare function getDocsTableCellAnchorContext(unitId: string, cell: IDocumentSkeletonPage): Nullable<IDocsTableCellAnchorContext>;
32
+ export declare function shouldUseDocsDrawingOuterPageOrigin(config: {
33
+ drawing: Pick<IDocDrawingBase, 'behindDoc' | 'layoutType'>;
34
+ height: number;
35
+ hostPage?: IDocumentSkeletonPage;
36
+ page: IDocumentSkeletonPage;
37
+ width: number;
38
+ }): boolean;
32
39
  export declare class DocDrawingTransformerController extends Disposable {
33
40
  private readonly _commandService;
34
41
  private readonly _univerInstanceService;