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

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/cjs/index.js CHANGED
@@ -24,14 +24,14 @@ const RemoveDocDrawingCommand = {
24
24
  const commandService = accessor.get(_univerjs_core.ICommandService);
25
25
  const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
26
26
  const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
27
- const documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
27
+ const documentDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
28
28
  if (params == null || documentDataModel == null) return false;
29
29
  const docSelectionRenderService = renderManagerService.getRenderById(params.unitId).with(_univerjs_docs_ui.DocSelectionRenderService);
30
30
  const { drawings: removeDrawings } = params;
31
31
  const segmentId = (_docSelectionRenderSe = docSelectionRenderService.getSegment()) !== null && _docSelectionRenderSe !== void 0 ? _docSelectionRenderSe : "";
32
32
  const textX = new _univerjs_core.TextX();
33
33
  const jsonX = _univerjs_core.JSONX.getInstance();
34
- const customBlocks = (_documentDataModel$ge = (_documentDataModel$ge2 = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.customBlocks) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : [];
34
+ const customBlocks = (_documentDataModel$ge = (_documentDataModel$ge2 = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge2 === void 0 || (_documentDataModel$ge2 = _documentDataModel$ge2.getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.customBlocks) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : [];
35
35
  const removeCustomBlocks = removeDrawings.map((drawing) => customBlocks.find((customBlock) => customBlock.blockId === drawing.drawingId)).filter((block) => !!block).sort((a, b) => a.startIndex > b.startIndex ? 1 : -1);
36
36
  const unitId = removeDrawings[0].unitId;
37
37
  const memoryCursor = new _univerjs_core.MemoryCursor();
@@ -130,13 +130,13 @@ const InsertDocDrawingCommand = {
130
130
  id: "doc.command.insert-doc-image",
131
131
  type: _univerjs_core.CommandType.COMMAND,
132
132
  handler: (accessor, params) => {
133
- var _ref, _contentInsertRange$s, _documentDataModel$ge, _documentDataModel$ge2;
133
+ var _ref, _contentInsertRange$s, _documentDataModel$ge, _documentDataModel$ge2, _documentDataModel$ge3;
134
134
  if (params == null) return false;
135
135
  const commandService = accessor.get(_univerjs_core.ICommandService);
136
136
  const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
137
137
  const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
138
138
  const activeTextRange = docSelectionManagerService.getActiveTextRange();
139
- const documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
139
+ const documentDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
140
140
  if (documentDataModel == null) return false;
141
141
  const unitId = documentDataModel.getUnitId();
142
142
  const contentInsertRange = getContentInsertRange(accessor, unitId);
@@ -150,12 +150,12 @@ const InsertDocDrawingCommand = {
150
150
  if (targetTextRange == null) return false;
151
151
  const { drawings } = params;
152
152
  const { collapsed, startOffset, segmentId = "" } = targetTextRange;
153
- const body = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
153
+ const body = (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.getBody();
154
154
  if (body == null) return false;
155
155
  const textX = new _univerjs_core.TextX();
156
156
  const jsonX = _univerjs_core.JSONX.getInstance();
157
157
  const rawActions = [];
158
- const drawingOrderLength = (_documentDataModel$ge = (_documentDataModel$ge2 = documentDataModel.getSnapshot().drawingsOrder) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.length) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : 0;
158
+ const drawingOrderLength = (_documentDataModel$ge2 = (_documentDataModel$ge3 = documentDataModel.getSnapshot().drawingsOrder) === null || _documentDataModel$ge3 === void 0 ? void 0 : _documentDataModel$ge3.length) !== null && _documentDataModel$ge2 !== void 0 ? _documentDataModel$ge2 : 0;
159
159
  let removeDrawingLen = 0;
160
160
  if (collapsed) {
161
161
  if (startOffset > 0) textX.push({
@@ -163,12 +163,12 @@ const InsertDocDrawingCommand = {
163
163
  len: startOffset
164
164
  });
165
165
  } else {
166
- var _documentDataModel$ge3, _documentDataModel$ge4;
166
+ var _documentDataModel$ge4, _documentDataModel$ge5;
167
167
  const dos = _univerjs_core.BuildTextUtils.selection.delete([targetTextRange], body, 0, null, false);
168
168
  textX.push(...dos);
169
169
  const removedCustomBlockIds = (0, _univerjs_docs_ui.getCustomBlockIdsInSelections)(body, [targetTextRange]);
170
- const drawings = (_documentDataModel$ge3 = documentDataModel.getDrawings()) !== null && _documentDataModel$ge3 !== void 0 ? _documentDataModel$ge3 : {};
171
- const drawingOrder = (_documentDataModel$ge4 = documentDataModel.getDrawingsOrder()) !== null && _documentDataModel$ge4 !== void 0 ? _documentDataModel$ge4 : [];
170
+ const drawings = (_documentDataModel$ge4 = documentDataModel.getDrawings()) !== null && _documentDataModel$ge4 !== void 0 ? _documentDataModel$ge4 : {};
171
+ const drawingOrder = (_documentDataModel$ge5 = documentDataModel.getDrawingsOrder()) !== null && _documentDataModel$ge5 !== void 0 ? _documentDataModel$ge5 : [];
172
172
  const sortedRemovedCustomBlockIds = removedCustomBlockIds.sort((a, b) => {
173
173
  if (drawingOrder.indexOf(a) > drawingOrder.indexOf(b)) return -1;
174
174
  else if (drawingOrder.indexOf(a) < drawingOrder.indexOf(b)) return 1;
@@ -801,12 +801,12 @@ function findDrawingAnchorInPage(page, drawingId, pageMarginTop, pageMarginLeft)
801
801
  return null;
802
802
  }
803
803
  function getDeleteAndInsertCustomBlockActions(segmentId, oldSegmentId, segmentPage, offset, drawingId, documentDataModel, docSelectionRenderManager) {
804
- var _oldBody$customBlocks;
804
+ var _documentDataModel$ge, _documentDataModel$ge2, _oldBody$customBlocks;
805
805
  const textX = new _univerjs_core.TextX();
806
806
  const jsonX = _univerjs_core.JSONX.getInstance();
807
807
  const rawActions = [];
808
- const oldBody = documentDataModel.getSelfOrHeaderFooterModel(oldSegmentId).getBody();
809
- const body = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
808
+ const oldBody = (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(oldSegmentId)) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.getBody();
809
+ const body = (_documentDataModel$ge2 = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.getBody();
810
810
  if (oldBody == null || body == null) return;
811
811
  const oldOffset = (_oldBody$customBlocks = oldBody.customBlocks) === null || _oldBody$customBlocks === void 0 || (_oldBody$customBlocks = _oldBody$customBlocks.find((block) => block.blockId === drawingId)) === null || _oldBody$customBlocks === void 0 ? void 0 : _oldBody$customBlocks.startIndex;
812
812
  if (oldOffset == null) return;
@@ -917,7 +917,7 @@ const UpdateDocDrawingWrappingStyleCommand = {
917
917
  const skeletonData = renderObject === null || renderObject === void 0 ? void 0 : renderObject.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton().getSkeletonData();
918
918
  const viewModel = renderObject === null || renderObject === void 0 ? void 0 : renderObject.with(_univerjs_docs.DocSkeletonManagerService).getViewModel();
919
919
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
920
- const documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
920
+ const documentDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
921
921
  if (documentDataModel == null || skeletonData == null || scene == null || viewModel == null) return false;
922
922
  const editArea = viewModel.getEditArea();
923
923
  const transformer = scene.getTransformerByCreate();
@@ -1037,9 +1037,10 @@ const UpdateDocDrawingDistanceCommand = {
1037
1037
  handler: (accessor, params) => {
1038
1038
  if (params == null) return false;
1039
1039
  const commandService = accessor.get(_univerjs_core.ICommandService);
1040
- const documentDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUniverDocInstance();
1041
- if (documentDataModel == null) return false;
1040
+ const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
1042
1041
  const { drawings, dist, unitId } = params;
1042
+ const documentDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
1043
+ if (documentDataModel == null) return false;
1043
1044
  const jsonX = _univerjs_core.JSONX.getInstance();
1044
1045
  const rawActions = [];
1045
1046
  const { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
@@ -1081,9 +1082,10 @@ const UpdateDocDrawingWrapTextCommand = {
1081
1082
  handler: (accessor, params) => {
1082
1083
  if (params == null) return false;
1083
1084
  const commandService = accessor.get(_univerjs_core.ICommandService);
1084
- const documentDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUniverDocInstance();
1085
- if (documentDataModel == null) return false;
1085
+ const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
1086
1086
  const { drawings, wrapText, unitId } = params;
1087
+ const documentDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
1088
+ if (documentDataModel == null) return false;
1087
1089
  const jsonX = _univerjs_core.JSONX.getInstance();
1088
1090
  const rawActions = [];
1089
1091
  const { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
@@ -1124,13 +1126,14 @@ const UpdateDrawingDocTransformCommand = {
1124
1126
  if (params == null) return false;
1125
1127
  const commandService = accessor.get(_univerjs_core.ICommandService);
1126
1128
  const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
1127
- const renderObject = accessor.get(_univerjs_engine_render.IRenderManagerService).getRenderById(params.unitId);
1129
+ const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
1130
+ const { drawings, unitId } = params;
1131
+ const renderObject = renderManagerService.getRenderUnitById(unitId);
1128
1132
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1129
1133
  if (scene == null) return false;
1130
1134
  const transformer = scene.getTransformerByCreate();
1131
- const documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
1135
+ const documentDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
1132
1136
  if (documentDataModel == null) return false;
1133
- const { drawings, unitId } = params;
1134
1137
  const jsonX = _univerjs_core.JSONX.getInstance();
1135
1138
  const rawActions = [];
1136
1139
  const { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
@@ -1173,18 +1176,18 @@ const IMoveInlineDrawingCommand = {
1173
1176
  handler: (accessor, params) => {
1174
1177
  var _renderManagerService, _docSelectionRenderSe;
1175
1178
  if (params == null) return false;
1179
+ const { drawing, unitId, offset, segmentId: newSegmentId, segmentPage, needRefreshDrawings } = params;
1176
1180
  const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
1177
- const docSelectionRenderService = (_renderManagerService = renderManagerService.getRenderById(params.unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs_ui.DocSelectionRenderService);
1181
+ const docSelectionRenderService = (_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs_ui.DocSelectionRenderService);
1178
1182
  const docRefreshDrawingsService = accessor.get(DocRefreshDrawingsService);
1179
- const renderObject = renderManagerService.getRenderById(params.unitId);
1183
+ const renderObject = renderManagerService.getRenderUnitById(unitId);
1180
1184
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1181
1185
  const skeleton = renderObject === null || renderObject === void 0 ? void 0 : renderObject.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
1182
1186
  if (scene == null || docSelectionRenderService == null) return false;
1183
1187
  const transformer = scene.getTransformerByCreate();
1184
1188
  const commandService = accessor.get(_univerjs_core.ICommandService);
1185
- const documentDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUniverDocInstance();
1189
+ const documentDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
1186
1190
  if (documentDataModel == null) return false;
1187
- const { drawing, unitId, offset, segmentId: newSegmentId, segmentPage, needRefreshDrawings } = params;
1188
1191
  if (needRefreshDrawings) {
1189
1192
  docRefreshDrawingsService.refreshDrawings(skeleton);
1190
1193
  transformer.refreshControls();
@@ -1224,16 +1227,16 @@ const ITransformNonInlineDrawingCommand = {
1224
1227
  handler: (accessor, params) => {
1225
1228
  var _renderManagerService2, _docSelectionRenderSe2;
1226
1229
  if (params == null) return false;
1230
+ const { drawing, unitId, offset, docTransform, segmentId: newSegmentId, segmentPage } = params;
1227
1231
  const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
1228
- const docSelectionRenderService = (_renderManagerService2 = renderManagerService.getRenderById(params.unitId)) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.with(_univerjs_docs_ui.DocSelectionRenderService);
1229
- const renderObject = renderManagerService.getRenderById(params.unitId);
1232
+ const docSelectionRenderService = (_renderManagerService2 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.with(_univerjs_docs_ui.DocSelectionRenderService);
1233
+ const renderObject = renderManagerService.getRenderUnitById(unitId);
1230
1234
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1231
1235
  if (scene == null || docSelectionRenderService == null) return false;
1232
1236
  const transformer = scene.getTransformerByCreate();
1233
1237
  const commandService = accessor.get(_univerjs_core.ICommandService);
1234
- const documentDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUniverDocInstance();
1238
+ const documentDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
1235
1239
  if (documentDataModel == null) return false;
1236
- const { drawing, unitId, offset, docTransform, segmentId: newSegmentId, segmentPage } = params;
1237
1240
  const rawActions = [];
1238
1241
  const { drawingId } = drawing;
1239
1242
  const actions = getDeleteAndInsertCustomBlockActions(newSegmentId, (_docSelectionRenderSe2 = docSelectionRenderService.getSegment()) !== null && _docSelectionRenderSe2 !== void 0 ? _docSelectionRenderSe2 : "", segmentPage, offset, drawingId, documentDataModel, docSelectionRenderService);
@@ -1314,7 +1317,7 @@ const MoveDocDrawingsCommand = {
1314
1317
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1315
1318
  if (scene == null) return false;
1316
1319
  const transformer = scene.getTransformerByCreate();
1317
- const documentDataModel = univerInstanceService.getUniverDocInstance(unitId);
1320
+ const documentDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
1318
1321
  const newDrawings = drawings.map((drawing) => {
1319
1322
  var _documentDataModel$ge;
1320
1323
  const { drawingId } = drawing;
@@ -1670,8 +1673,8 @@ const getDisableWhenSelectionInTableObservable = (accessor) => {
1670
1673
  if (activeRange) {
1671
1674
  var _docDataModel$getSelf;
1672
1675
  const { segmentId, startOffset, endOffset } = activeRange;
1673
- const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
1674
- const tables = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.tables;
1676
+ const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
1677
+ const tables = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 || (_docDataModel$getSelf = _docDataModel$getSelf.getBody()) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.tables;
1675
1678
  if (tables && tables.length) {
1676
1679
  if (tables.some((table) => {
1677
1680
  const { startIndex, endIndex } = table;
@@ -1785,7 +1788,7 @@ function InsertEllipseShapeBelowMenuFactory(accessor) {
1785
1788
  //#endregion
1786
1789
  //#region package.json
1787
1790
  var name = "@univerjs/docs-drawing-ui";
1788
- var version = "1.0.0-alpha.0";
1791
+ var version = "1.0.0-alpha.2";
1789
1792
 
1790
1793
  //#endregion
1791
1794
  //#region src/config/config.ts
@@ -1822,7 +1825,7 @@ const DocDrawingPosition = (props) => {
1822
1825
  const drawingParam = drawings[0];
1823
1826
  if (drawingParam == null) return;
1824
1827
  const { unitId } = drawingParam;
1825
- const documentDataModel = univerInstanceService.getUniverDocInstance(unitId);
1828
+ const documentDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
1826
1829
  const documentFlavor = documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getSnapshot().documentStyle.documentFlavor;
1827
1830
  const renderObject = renderManagerService.getRenderById(unitId);
1828
1831
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
@@ -1958,12 +1961,12 @@ const DocDrawingPosition = (props) => {
1958
1961
  const focusDrawings = drawingManagerService.getFocusDrawings();
1959
1962
  if (focusDrawings.length === 0) return;
1960
1963
  const { drawingId, unitId } = focusDrawings[0];
1961
- const documentDataModel = univerInstanceService.getUniverDocInstance(unitId);
1962
- const skeleton = (_renderManagerService3 = renderManagerService.getRenderById(unitId)) === null || _renderManagerService3 === void 0 ? void 0 : _renderManagerService3.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
1963
- const docSelectionRenderService = (_renderManagerService4 = renderManagerService.getRenderById(unitId)) === null || _renderManagerService4 === void 0 ? void 0 : _renderManagerService4.with(_univerjs_docs_ui.DocSelectionRenderService);
1964
+ const documentDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
1965
+ const skeleton = (_renderManagerService3 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService3 === void 0 ? void 0 : _renderManagerService3.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
1966
+ const docSelectionRenderService = (_renderManagerService4 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService4 === void 0 ? void 0 : _renderManagerService4.with(_univerjs_docs_ui.DocSelectionRenderService);
1964
1967
  const segmentId = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.getSegment();
1965
1968
  const segmentPage = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.getSegmentPage();
1966
- const drawing = documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _documentDataModel$ge === void 0 || (_documentDataModel$ge = _documentDataModel$ge.customBlocks) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.find((c) => c.blockId === drawingId);
1969
+ const drawing = documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge === void 0 || (_documentDataModel$ge = _documentDataModel$ge.getBody()) === null || _documentDataModel$ge === void 0 || (_documentDataModel$ge = _documentDataModel$ge.customBlocks) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.find((c) => c.blockId === drawingId);
1967
1970
  if (drawing == null || skeleton == null || docSelectionRenderService == null) return;
1968
1971
  const { startIndex } = drawing;
1969
1972
  const glyph = skeleton.findNodeByCharIndex(startIndex, segmentId, segmentPage);
@@ -2108,8 +2111,8 @@ const DocDrawingTextWrap = (props) => {
2108
2111
  const drawingParam = drawings[0];
2109
2112
  if (drawingParam == null) return null;
2110
2113
  const { unitId } = drawingParam;
2111
- const documentDataModel = univerInstanceService.getUniverDocInstance(unitId);
2112
- const renderObject = renderManagerService.getRenderById(unitId);
2114
+ const documentDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
2115
+ const renderObject = renderManagerService.getRenderUnitById(unitId);
2113
2116
  if ((renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene) == null) return null;
2114
2117
  const [disableWrapText, setDisableWrapText] = (0, react.useState)(true);
2115
2118
  const [disableDistTB, setDisableDistTB] = (0, react.useState)(true);
@@ -2480,10 +2483,10 @@ let DocDrawingAddRemoveController = class DocDrawingAddRemoveController extends
2480
2483
  this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
2481
2484
  var _this$_univerInstance;
2482
2485
  if (command.id !== _univerjs_core.UndoCommand.id && command.id !== _univerjs_core.RedoCommand.id) return;
2483
- const unitId = (_this$_univerInstance = this._univerInstanceService.getCurrentUniverDocInstance()) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
2486
+ const unitId = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
2484
2487
  const focusedDrawings = this._drawingManagerService.getFocusDrawings();
2485
2488
  if (unitId == null || focusedDrawings.length === 0) return;
2486
- const renderObject = this._renderManagerService.getRenderById(unitId);
2489
+ const renderObject = this._renderManagerService.getRenderUnitById(unitId);
2487
2490
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
2488
2491
  if (scene == null) return false;
2489
2492
  scene.getTransformerByCreate().refreshControls();
@@ -2514,7 +2517,7 @@ let DocDrawingAddRemoveController = class DocDrawingAddRemoveController extends
2514
2517
  docDrawingService.removeNotification(objects);
2515
2518
  }
2516
2519
  _updateDrawingsOrder(unitId) {
2517
- const documentDataModel = this._univerInstanceService.getUniverDocInstance(unitId);
2520
+ const documentDataModel = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
2518
2521
  if (documentDataModel == null) return;
2519
2522
  const { drawings, drawingsOrder } = documentDataModel.getSnapshot();
2520
2523
  if (drawingsOrder == null) return;
@@ -2895,7 +2898,7 @@ let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateControl
2895
2898
  clipOffsetTop: clipOffset === null || clipOffset === void 0 ? void 0 : clipOffset.top,
2896
2899
  page: clipPage
2897
2900
  });
2898
- const pageRelativeAnchorPage = getDocsPageRelativeDrawingAnchorPage({
2901
+ const pageRelativeAnchorPage = drawingOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.INLINE ? void 0 : getDocsPageRelativeDrawingAnchorPage({
2899
2902
  page,
2900
2903
  clipPage,
2901
2904
  hostPage
@@ -3030,7 +3033,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3030
3033
  const { oKey, width, height, left, top, angle } = object;
3031
3034
  const drawing = this._drawingManagerService.getDrawingOKey(oKey);
3032
3035
  if (drawing == null) continue;
3033
- const documentDataModel = this._univerInstanceService.getUniverDocInstance(drawing.unitId);
3036
+ const documentDataModel = this._univerInstanceService.getUnit(drawing.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
3034
3037
  const drawingData = documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge = documentDataModel.getSnapshot().drawings) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge[drawing.drawingId];
3035
3038
  if ((drawingData === null || drawingData === void 0 ? void 0 : drawingData.layoutType) === _univerjs_core.PositionedObjectLayoutType.INLINE) try {
3036
3039
  object.setOpacity(.2);
package/lib/es/index.js CHANGED
@@ -23,14 +23,14 @@ const RemoveDocDrawingCommand = {
23
23
  const commandService = accessor.get(ICommandService);
24
24
  const univerInstanceService = accessor.get(IUniverInstanceService);
25
25
  const renderManagerService = accessor.get(IRenderManagerService);
26
- const documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
26
+ const documentDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
27
27
  if (params == null || documentDataModel == null) return false;
28
28
  const docSelectionRenderService = renderManagerService.getRenderById(params.unitId).with(DocSelectionRenderService);
29
29
  const { drawings: removeDrawings } = params;
30
30
  const segmentId = (_docSelectionRenderSe = docSelectionRenderService.getSegment()) !== null && _docSelectionRenderSe !== void 0 ? _docSelectionRenderSe : "";
31
31
  const textX = new TextX();
32
32
  const jsonX = JSONX.getInstance();
33
- const customBlocks = (_documentDataModel$ge = (_documentDataModel$ge2 = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.customBlocks) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : [];
33
+ const customBlocks = (_documentDataModel$ge = (_documentDataModel$ge2 = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge2 === void 0 || (_documentDataModel$ge2 = _documentDataModel$ge2.getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.customBlocks) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : [];
34
34
  const removeCustomBlocks = removeDrawings.map((drawing) => customBlocks.find((customBlock) => customBlock.blockId === drawing.drawingId)).filter((block) => !!block).sort((a, b) => a.startIndex > b.startIndex ? 1 : -1);
35
35
  const unitId = removeDrawings[0].unitId;
36
36
  const memoryCursor = new MemoryCursor();
@@ -129,13 +129,13 @@ const InsertDocDrawingCommand = {
129
129
  id: "doc.command.insert-doc-image",
130
130
  type: CommandType.COMMAND,
131
131
  handler: (accessor, params) => {
132
- var _ref, _contentInsertRange$s, _documentDataModel$ge, _documentDataModel$ge2;
132
+ var _ref, _contentInsertRange$s, _documentDataModel$ge, _documentDataModel$ge2, _documentDataModel$ge3;
133
133
  if (params == null) return false;
134
134
  const commandService = accessor.get(ICommandService);
135
135
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
136
136
  const univerInstanceService = accessor.get(IUniverInstanceService);
137
137
  const activeTextRange = docSelectionManagerService.getActiveTextRange();
138
- const documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
138
+ const documentDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
139
139
  if (documentDataModel == null) return false;
140
140
  const unitId = documentDataModel.getUnitId();
141
141
  const contentInsertRange = getContentInsertRange(accessor, unitId);
@@ -149,12 +149,12 @@ const InsertDocDrawingCommand = {
149
149
  if (targetTextRange == null) return false;
150
150
  const { drawings } = params;
151
151
  const { collapsed, startOffset, segmentId = "" } = targetTextRange;
152
- const body = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
152
+ const body = (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.getBody();
153
153
  if (body == null) return false;
154
154
  const textX = new TextX();
155
155
  const jsonX = JSONX.getInstance();
156
156
  const rawActions = [];
157
- const drawingOrderLength = (_documentDataModel$ge = (_documentDataModel$ge2 = documentDataModel.getSnapshot().drawingsOrder) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.length) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : 0;
157
+ const drawingOrderLength = (_documentDataModel$ge2 = (_documentDataModel$ge3 = documentDataModel.getSnapshot().drawingsOrder) === null || _documentDataModel$ge3 === void 0 ? void 0 : _documentDataModel$ge3.length) !== null && _documentDataModel$ge2 !== void 0 ? _documentDataModel$ge2 : 0;
158
158
  let removeDrawingLen = 0;
159
159
  if (collapsed) {
160
160
  if (startOffset > 0) textX.push({
@@ -162,12 +162,12 @@ const InsertDocDrawingCommand = {
162
162
  len: startOffset
163
163
  });
164
164
  } else {
165
- var _documentDataModel$ge3, _documentDataModel$ge4;
165
+ var _documentDataModel$ge4, _documentDataModel$ge5;
166
166
  const dos = BuildTextUtils.selection.delete([targetTextRange], body, 0, null, false);
167
167
  textX.push(...dos);
168
168
  const removedCustomBlockIds = getCustomBlockIdsInSelections(body, [targetTextRange]);
169
- const drawings = (_documentDataModel$ge3 = documentDataModel.getDrawings()) !== null && _documentDataModel$ge3 !== void 0 ? _documentDataModel$ge3 : {};
170
- const drawingOrder = (_documentDataModel$ge4 = documentDataModel.getDrawingsOrder()) !== null && _documentDataModel$ge4 !== void 0 ? _documentDataModel$ge4 : [];
169
+ const drawings = (_documentDataModel$ge4 = documentDataModel.getDrawings()) !== null && _documentDataModel$ge4 !== void 0 ? _documentDataModel$ge4 : {};
170
+ const drawingOrder = (_documentDataModel$ge5 = documentDataModel.getDrawingsOrder()) !== null && _documentDataModel$ge5 !== void 0 ? _documentDataModel$ge5 : [];
171
171
  const sortedRemovedCustomBlockIds = removedCustomBlockIds.sort((a, b) => {
172
172
  if (drawingOrder.indexOf(a) > drawingOrder.indexOf(b)) return -1;
173
173
  else if (drawingOrder.indexOf(a) < drawingOrder.indexOf(b)) return 1;
@@ -800,12 +800,12 @@ function findDrawingAnchorInPage(page, drawingId, pageMarginTop, pageMarginLeft)
800
800
  return null;
801
801
  }
802
802
  function getDeleteAndInsertCustomBlockActions(segmentId, oldSegmentId, segmentPage, offset, drawingId, documentDataModel, docSelectionRenderManager) {
803
- var _oldBody$customBlocks;
803
+ var _documentDataModel$ge, _documentDataModel$ge2, _oldBody$customBlocks;
804
804
  const textX = new TextX();
805
805
  const jsonX = JSONX.getInstance();
806
806
  const rawActions = [];
807
- const oldBody = documentDataModel.getSelfOrHeaderFooterModel(oldSegmentId).getBody();
808
- const body = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
807
+ const oldBody = (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(oldSegmentId)) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.getBody();
808
+ const body = (_documentDataModel$ge2 = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.getBody();
809
809
  if (oldBody == null || body == null) return;
810
810
  const oldOffset = (_oldBody$customBlocks = oldBody.customBlocks) === null || _oldBody$customBlocks === void 0 || (_oldBody$customBlocks = _oldBody$customBlocks.find((block) => block.blockId === drawingId)) === null || _oldBody$customBlocks === void 0 ? void 0 : _oldBody$customBlocks.startIndex;
811
811
  if (oldOffset == null) return;
@@ -916,7 +916,7 @@ const UpdateDocDrawingWrappingStyleCommand = {
916
916
  const skeletonData = renderObject === null || renderObject === void 0 ? void 0 : renderObject.with(DocSkeletonManagerService).getSkeleton().getSkeletonData();
917
917
  const viewModel = renderObject === null || renderObject === void 0 ? void 0 : renderObject.with(DocSkeletonManagerService).getViewModel();
918
918
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
919
- const documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
919
+ const documentDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
920
920
  if (documentDataModel == null || skeletonData == null || scene == null || viewModel == null) return false;
921
921
  const editArea = viewModel.getEditArea();
922
922
  const transformer = scene.getTransformerByCreate();
@@ -1036,9 +1036,10 @@ const UpdateDocDrawingDistanceCommand = {
1036
1036
  handler: (accessor, params) => {
1037
1037
  if (params == null) return false;
1038
1038
  const commandService = accessor.get(ICommandService);
1039
- const documentDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
1040
- if (documentDataModel == null) return false;
1039
+ const univerInstanceService = accessor.get(IUniverInstanceService);
1041
1040
  const { drawings, dist, unitId } = params;
1041
+ const documentDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
1042
+ if (documentDataModel == null) return false;
1042
1043
  const jsonX = JSONX.getInstance();
1043
1044
  const rawActions = [];
1044
1045
  const { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
@@ -1080,9 +1081,10 @@ const UpdateDocDrawingWrapTextCommand = {
1080
1081
  handler: (accessor, params) => {
1081
1082
  if (params == null) return false;
1082
1083
  const commandService = accessor.get(ICommandService);
1083
- const documentDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
1084
- if (documentDataModel == null) return false;
1084
+ const univerInstanceService = accessor.get(IUniverInstanceService);
1085
1085
  const { drawings, wrapText, unitId } = params;
1086
+ const documentDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
1087
+ if (documentDataModel == null) return false;
1086
1088
  const jsonX = JSONX.getInstance();
1087
1089
  const rawActions = [];
1088
1090
  const { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
@@ -1123,13 +1125,14 @@ const UpdateDrawingDocTransformCommand = {
1123
1125
  if (params == null) return false;
1124
1126
  const commandService = accessor.get(ICommandService);
1125
1127
  const univerInstanceService = accessor.get(IUniverInstanceService);
1126
- const renderObject = accessor.get(IRenderManagerService).getRenderById(params.unitId);
1128
+ const renderManagerService = accessor.get(IRenderManagerService);
1129
+ const { drawings, unitId } = params;
1130
+ const renderObject = renderManagerService.getRenderUnitById(unitId);
1127
1131
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1128
1132
  if (scene == null) return false;
1129
1133
  const transformer = scene.getTransformerByCreate();
1130
- const documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
1134
+ const documentDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
1131
1135
  if (documentDataModel == null) return false;
1132
- const { drawings, unitId } = params;
1133
1136
  const jsonX = JSONX.getInstance();
1134
1137
  const rawActions = [];
1135
1138
  const { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
@@ -1172,18 +1175,18 @@ const IMoveInlineDrawingCommand = {
1172
1175
  handler: (accessor, params) => {
1173
1176
  var _renderManagerService, _docSelectionRenderSe;
1174
1177
  if (params == null) return false;
1178
+ const { drawing, unitId, offset, segmentId: newSegmentId, segmentPage, needRefreshDrawings } = params;
1175
1179
  const renderManagerService = accessor.get(IRenderManagerService);
1176
- const docSelectionRenderService = (_renderManagerService = renderManagerService.getRenderById(params.unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(DocSelectionRenderService);
1180
+ const docSelectionRenderService = (_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(DocSelectionRenderService);
1177
1181
  const docRefreshDrawingsService = accessor.get(DocRefreshDrawingsService);
1178
- const renderObject = renderManagerService.getRenderById(params.unitId);
1182
+ const renderObject = renderManagerService.getRenderUnitById(unitId);
1179
1183
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1180
1184
  const skeleton = renderObject === null || renderObject === void 0 ? void 0 : renderObject.with(DocSkeletonManagerService).getSkeleton();
1181
1185
  if (scene == null || docSelectionRenderService == null) return false;
1182
1186
  const transformer = scene.getTransformerByCreate();
1183
1187
  const commandService = accessor.get(ICommandService);
1184
- const documentDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
1188
+ const documentDataModel = accessor.get(IUniverInstanceService).getUnit(unitId, UniverInstanceType.UNIVER_DOC);
1185
1189
  if (documentDataModel == null) return false;
1186
- const { drawing, unitId, offset, segmentId: newSegmentId, segmentPage, needRefreshDrawings } = params;
1187
1190
  if (needRefreshDrawings) {
1188
1191
  docRefreshDrawingsService.refreshDrawings(skeleton);
1189
1192
  transformer.refreshControls();
@@ -1223,16 +1226,16 @@ const ITransformNonInlineDrawingCommand = {
1223
1226
  handler: (accessor, params) => {
1224
1227
  var _renderManagerService2, _docSelectionRenderSe2;
1225
1228
  if (params == null) return false;
1229
+ const { drawing, unitId, offset, docTransform, segmentId: newSegmentId, segmentPage } = params;
1226
1230
  const renderManagerService = accessor.get(IRenderManagerService);
1227
- const docSelectionRenderService = (_renderManagerService2 = renderManagerService.getRenderById(params.unitId)) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.with(DocSelectionRenderService);
1228
- const renderObject = renderManagerService.getRenderById(params.unitId);
1231
+ const docSelectionRenderService = (_renderManagerService2 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.with(DocSelectionRenderService);
1232
+ const renderObject = renderManagerService.getRenderUnitById(unitId);
1229
1233
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1230
1234
  if (scene == null || docSelectionRenderService == null) return false;
1231
1235
  const transformer = scene.getTransformerByCreate();
1232
1236
  const commandService = accessor.get(ICommandService);
1233
- const documentDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
1237
+ const documentDataModel = accessor.get(IUniverInstanceService).getUnit(unitId, UniverInstanceType.UNIVER_DOC);
1234
1238
  if (documentDataModel == null) return false;
1235
- const { drawing, unitId, offset, docTransform, segmentId: newSegmentId, segmentPage } = params;
1236
1239
  const rawActions = [];
1237
1240
  const { drawingId } = drawing;
1238
1241
  const actions = getDeleteAndInsertCustomBlockActions(newSegmentId, (_docSelectionRenderSe2 = docSelectionRenderService.getSegment()) !== null && _docSelectionRenderSe2 !== void 0 ? _docSelectionRenderSe2 : "", segmentPage, offset, drawingId, documentDataModel, docSelectionRenderService);
@@ -1313,7 +1316,7 @@ const MoveDocDrawingsCommand = {
1313
1316
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1314
1317
  if (scene == null) return false;
1315
1318
  const transformer = scene.getTransformerByCreate();
1316
- const documentDataModel = univerInstanceService.getUniverDocInstance(unitId);
1319
+ const documentDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
1317
1320
  const newDrawings = drawings.map((drawing) => {
1318
1321
  var _documentDataModel$ge;
1319
1322
  const { drawingId } = drawing;
@@ -1669,8 +1672,8 @@ const getDisableWhenSelectionInTableObservable = (accessor) => {
1669
1672
  if (activeRange) {
1670
1673
  var _docDataModel$getSelf;
1671
1674
  const { segmentId, startOffset, endOffset } = activeRange;
1672
- const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
1673
- const tables = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.tables;
1675
+ const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
1676
+ const tables = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 || (_docDataModel$getSelf = _docDataModel$getSelf.getBody()) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.tables;
1674
1677
  if (tables && tables.length) {
1675
1678
  if (tables.some((table) => {
1676
1679
  const { startIndex, endIndex } = table;
@@ -1784,7 +1787,7 @@ function InsertEllipseShapeBelowMenuFactory(accessor) {
1784
1787
  //#endregion
1785
1788
  //#region package.json
1786
1789
  var name = "@univerjs/docs-drawing-ui";
1787
- var version = "1.0.0-alpha.0";
1790
+ var version = "1.0.0-alpha.2";
1788
1791
 
1789
1792
  //#endregion
1790
1793
  //#region src/config/config.ts
@@ -1821,7 +1824,7 @@ const DocDrawingPosition = (props) => {
1821
1824
  const drawingParam = drawings[0];
1822
1825
  if (drawingParam == null) return;
1823
1826
  const { unitId } = drawingParam;
1824
- const documentDataModel = univerInstanceService.getUniverDocInstance(unitId);
1827
+ const documentDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
1825
1828
  const documentFlavor = documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getSnapshot().documentStyle.documentFlavor;
1826
1829
  const renderObject = renderManagerService.getRenderById(unitId);
1827
1830
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
@@ -1957,12 +1960,12 @@ const DocDrawingPosition = (props) => {
1957
1960
  const focusDrawings = drawingManagerService.getFocusDrawings();
1958
1961
  if (focusDrawings.length === 0) return;
1959
1962
  const { drawingId, unitId } = focusDrawings[0];
1960
- const documentDataModel = univerInstanceService.getUniverDocInstance(unitId);
1961
- const skeleton = (_renderManagerService3 = renderManagerService.getRenderById(unitId)) === null || _renderManagerService3 === void 0 ? void 0 : _renderManagerService3.with(DocSkeletonManagerService).getSkeleton();
1962
- const docSelectionRenderService = (_renderManagerService4 = renderManagerService.getRenderById(unitId)) === null || _renderManagerService4 === void 0 ? void 0 : _renderManagerService4.with(DocSelectionRenderService);
1963
+ const documentDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
1964
+ const skeleton = (_renderManagerService3 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService3 === void 0 ? void 0 : _renderManagerService3.with(DocSkeletonManagerService).getSkeleton();
1965
+ const docSelectionRenderService = (_renderManagerService4 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService4 === void 0 ? void 0 : _renderManagerService4.with(DocSelectionRenderService);
1963
1966
  const segmentId = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.getSegment();
1964
1967
  const segmentPage = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.getSegmentPage();
1965
- const drawing = documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _documentDataModel$ge === void 0 || (_documentDataModel$ge = _documentDataModel$ge.customBlocks) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.find((c) => c.blockId === drawingId);
1968
+ const drawing = documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge === void 0 || (_documentDataModel$ge = _documentDataModel$ge.getBody()) === null || _documentDataModel$ge === void 0 || (_documentDataModel$ge = _documentDataModel$ge.customBlocks) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.find((c) => c.blockId === drawingId);
1966
1969
  if (drawing == null || skeleton == null || docSelectionRenderService == null) return;
1967
1970
  const { startIndex } = drawing;
1968
1971
  const glyph = skeleton.findNodeByCharIndex(startIndex, segmentId, segmentPage);
@@ -2107,8 +2110,8 @@ const DocDrawingTextWrap = (props) => {
2107
2110
  const drawingParam = drawings[0];
2108
2111
  if (drawingParam == null) return null;
2109
2112
  const { unitId } = drawingParam;
2110
- const documentDataModel = univerInstanceService.getUniverDocInstance(unitId);
2111
- const renderObject = renderManagerService.getRenderById(unitId);
2113
+ const documentDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
2114
+ const renderObject = renderManagerService.getRenderUnitById(unitId);
2112
2115
  if ((renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene) == null) return null;
2113
2116
  const [disableWrapText, setDisableWrapText] = useState(true);
2114
2117
  const [disableDistTB, setDisableDistTB] = useState(true);
@@ -2479,10 +2482,10 @@ let DocDrawingAddRemoveController = class DocDrawingAddRemoveController extends
2479
2482
  this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
2480
2483
  var _this$_univerInstance;
2481
2484
  if (command.id !== UndoCommand.id && command.id !== RedoCommand.id) return;
2482
- const unitId = (_this$_univerInstance = this._univerInstanceService.getCurrentUniverDocInstance()) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
2485
+ const unitId = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
2483
2486
  const focusedDrawings = this._drawingManagerService.getFocusDrawings();
2484
2487
  if (unitId == null || focusedDrawings.length === 0) return;
2485
- const renderObject = this._renderManagerService.getRenderById(unitId);
2488
+ const renderObject = this._renderManagerService.getRenderUnitById(unitId);
2486
2489
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
2487
2490
  if (scene == null) return false;
2488
2491
  scene.getTransformerByCreate().refreshControls();
@@ -2513,7 +2516,7 @@ let DocDrawingAddRemoveController = class DocDrawingAddRemoveController extends
2513
2516
  docDrawingService.removeNotification(objects);
2514
2517
  }
2515
2518
  _updateDrawingsOrder(unitId) {
2516
- const documentDataModel = this._univerInstanceService.getUniverDocInstance(unitId);
2519
+ const documentDataModel = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
2517
2520
  if (documentDataModel == null) return;
2518
2521
  const { drawings, drawingsOrder } = documentDataModel.getSnapshot();
2519
2522
  if (drawingsOrder == null) return;
@@ -2894,7 +2897,7 @@ let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateControl
2894
2897
  clipOffsetTop: clipOffset === null || clipOffset === void 0 ? void 0 : clipOffset.top,
2895
2898
  page: clipPage
2896
2899
  });
2897
- const pageRelativeAnchorPage = getDocsPageRelativeDrawingAnchorPage({
2900
+ const pageRelativeAnchorPage = drawingOrigin.layoutType === PositionedObjectLayoutType.INLINE ? void 0 : getDocsPageRelativeDrawingAnchorPage({
2898
2901
  page,
2899
2902
  clipPage,
2900
2903
  hostPage
@@ -3029,7 +3032,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
3029
3032
  const { oKey, width, height, left, top, angle } = object;
3030
3033
  const drawing = this._drawingManagerService.getDrawingOKey(oKey);
3031
3034
  if (drawing == null) continue;
3032
- const documentDataModel = this._univerInstanceService.getUniverDocInstance(drawing.unitId);
3035
+ const documentDataModel = this._univerInstanceService.getUnit(drawing.unitId, UniverInstanceType.UNIVER_DOC);
3033
3036
  const drawingData = documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge = documentDataModel.getSnapshot().drawings) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge[drawing.drawingId];
3034
3037
  if ((drawingData === null || drawingData === void 0 ? void 0 : drawingData.layoutType) === PositionedObjectLayoutType.INLINE) try {
3035
3038
  object.setOpacity(.2);