@apollo-office/drawing-ui 1.0.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.
Files changed (135) hide show
  1. package/LICENSE +176 -0
  2. package/MODIFICATIONS.md +26 -0
  3. package/NOTICE +14 -0
  4. package/README.md +42 -0
  5. package/lib/cjs/index.js +3146 -0
  6. package/lib/cjs/locale/ar-SA.js +74 -0
  7. package/lib/cjs/locale/ca-ES.js +74 -0
  8. package/lib/cjs/locale/de-DE.js +74 -0
  9. package/lib/cjs/locale/en-US.js +89 -0
  10. package/lib/cjs/locale/es-ES.js +74 -0
  11. package/lib/cjs/locale/fa-IR.js +74 -0
  12. package/lib/cjs/locale/fr-FR.js +74 -0
  13. package/lib/cjs/locale/id-ID.js +74 -0
  14. package/lib/cjs/locale/it-IT.js +74 -0
  15. package/lib/cjs/locale/ja-JP.js +74 -0
  16. package/lib/cjs/locale/ko-KR.js +74 -0
  17. package/lib/cjs/locale/pl-PL.js +74 -0
  18. package/lib/cjs/locale/pt-BR.js +74 -0
  19. package/lib/cjs/locale/ru-RU.js +74 -0
  20. package/lib/cjs/locale/sk-SK.js +74 -0
  21. package/lib/cjs/locale/vi-VN.js +74 -0
  22. package/lib/cjs/locale/zh-CN.js +74 -0
  23. package/lib/cjs/locale/zh-HK.js +74 -0
  24. package/lib/cjs/locale/zh-TW.js +74 -0
  25. package/lib/es/index.js +3116 -0
  26. package/lib/es/locale/ar-SA.js +73 -0
  27. package/lib/es/locale/ca-ES.js +73 -0
  28. package/lib/es/locale/de-DE.js +73 -0
  29. package/lib/es/locale/en-US.js +88 -0
  30. package/lib/es/locale/es-ES.js +73 -0
  31. package/lib/es/locale/fa-IR.js +73 -0
  32. package/lib/es/locale/fr-FR.js +73 -0
  33. package/lib/es/locale/id-ID.js +73 -0
  34. package/lib/es/locale/it-IT.js +73 -0
  35. package/lib/es/locale/ja-JP.js +73 -0
  36. package/lib/es/locale/ko-KR.js +73 -0
  37. package/lib/es/locale/pl-PL.js +73 -0
  38. package/lib/es/locale/pt-BR.js +73 -0
  39. package/lib/es/locale/ru-RU.js +73 -0
  40. package/lib/es/locale/sk-SK.js +73 -0
  41. package/lib/es/locale/vi-VN.js +73 -0
  42. package/lib/es/locale/zh-CN.js +73 -0
  43. package/lib/es/locale/zh-HK.js +73 -0
  44. package/lib/es/locale/zh-TW.js +73 -0
  45. package/lib/index.css +311 -0
  46. package/lib/index.js +3116 -0
  47. package/lib/locale/ar-SA.js +73 -0
  48. package/lib/locale/ca-ES.js +73 -0
  49. package/lib/locale/de-DE.js +73 -0
  50. package/lib/locale/en-US.js +88 -0
  51. package/lib/locale/es-ES.js +73 -0
  52. package/lib/locale/fa-IR.js +73 -0
  53. package/lib/locale/fr-FR.js +73 -0
  54. package/lib/locale/id-ID.js +73 -0
  55. package/lib/locale/it-IT.js +73 -0
  56. package/lib/locale/ja-JP.js +73 -0
  57. package/lib/locale/ko-KR.js +73 -0
  58. package/lib/locale/pl-PL.js +73 -0
  59. package/lib/locale/pt-BR.js +73 -0
  60. package/lib/locale/ru-RU.js +73 -0
  61. package/lib/locale/sk-SK.js +73 -0
  62. package/lib/locale/vi-VN.js +73 -0
  63. package/lib/locale/zh-CN.js +73 -0
  64. package/lib/locale/zh-HK.js +73 -0
  65. package/lib/locale/zh-TW.js +73 -0
  66. package/lib/types/commands/operations/drawing-align.operation.d.ts +43 -0
  67. package/lib/types/commands/operations/drawing-arrange.operation.d.ts +29 -0
  68. package/lib/types/commands/operations/drawing-group.operation.d.ts +35 -0
  69. package/lib/types/commands/operations/image-crop.operation.d.ts +36 -0
  70. package/lib/types/commands/operations/image-reset-size.operation.d.ts +17 -0
  71. package/lib/types/config/config.d.ts +22 -0
  72. package/lib/types/controllers/drawing-ui.controller.d.ts +27 -0
  73. package/lib/types/controllers/drawing-update.controller.d.ts +49 -0
  74. package/lib/types/controllers/image-cropper.controller.d.ts +41 -0
  75. package/lib/types/controllers/image-update.controller.d.ts +40 -0
  76. package/lib/types/controllers/utils.d.ts +25 -0
  77. package/lib/types/index.d.ts +32 -0
  78. package/lib/types/locale/ar-SA.d.ts +18 -0
  79. package/lib/types/locale/ca-ES.d.ts +18 -0
  80. package/lib/types/locale/de-DE.d.ts +18 -0
  81. package/lib/types/locale/en-US.d.ts +89 -0
  82. package/lib/types/locale/es-ES.d.ts +18 -0
  83. package/lib/types/locale/fa-IR.d.ts +18 -0
  84. package/lib/types/locale/fr-FR.d.ts +18 -0
  85. package/lib/types/locale/id-ID.d.ts +18 -0
  86. package/lib/types/locale/it-IT.d.ts +18 -0
  87. package/lib/types/locale/ja-JP.d.ts +18 -0
  88. package/lib/types/locale/ko-KR.d.ts +18 -0
  89. package/lib/types/locale/pl-PL.d.ts +18 -0
  90. package/lib/types/locale/pt-BR.d.ts +18 -0
  91. package/lib/types/locale/ru-RU.d.ts +18 -0
  92. package/lib/types/locale/sk-SK.d.ts +18 -0
  93. package/lib/types/locale/vi-VN.d.ts +18 -0
  94. package/lib/types/locale/zh-CN.d.ts +18 -0
  95. package/lib/types/locale/zh-HK.d.ts +18 -0
  96. package/lib/types/locale/zh-TW.d.ts +18 -0
  97. package/lib/types/menu/align.menu.d.ts +27 -0
  98. package/lib/types/menu/arrange.menu.d.ts +22 -0
  99. package/lib/types/menu/group.menu.d.ts +21 -0
  100. package/lib/types/menu/schema.d.ts +17 -0
  101. package/lib/types/plugin.d.ts +29 -0
  102. package/lib/types/services/drawing-image-clip.service.d.ts +48 -0
  103. package/lib/types/services/drawing-render.service.d.ts +38 -0
  104. package/lib/types/utils/config.d.ts +18 -0
  105. package/lib/types/utils/get-update-params.d.ts +19 -0
  106. package/lib/types/views/crop/image-cropper-object.d.ts +49 -0
  107. package/lib/types/views/image-popup-menu/ImagePopupMenu.d.ts +35 -0
  108. package/lib/types/views/image-popup-menu/component-name.d.ts +16 -0
  109. package/lib/types/views/panel/DrawingAlign.d.ts +21 -0
  110. package/lib/types/views/panel/DrawingArrange.d.ts +21 -0
  111. package/lib/types/views/panel/DrawingCommonPanel.d.ts +25 -0
  112. package/lib/types/views/panel/DrawingGroup.d.ts +21 -0
  113. package/lib/types/views/panel/DrawingTransform.d.ts +21 -0
  114. package/lib/types/views/panel/ImageCropper.d.ts +21 -0
  115. package/lib/umd/index.js +4 -0
  116. package/lib/umd/locale/ar-SA.js +1 -0
  117. package/lib/umd/locale/ca-ES.js +1 -0
  118. package/lib/umd/locale/de-DE.js +1 -0
  119. package/lib/umd/locale/en-US.js +1 -0
  120. package/lib/umd/locale/es-ES.js +1 -0
  121. package/lib/umd/locale/fa-IR.js +1 -0
  122. package/lib/umd/locale/fr-FR.js +1 -0
  123. package/lib/umd/locale/id-ID.js +1 -0
  124. package/lib/umd/locale/it-IT.js +1 -0
  125. package/lib/umd/locale/ja-JP.js +1 -0
  126. package/lib/umd/locale/ko-KR.js +1 -0
  127. package/lib/umd/locale/pl-PL.js +1 -0
  128. package/lib/umd/locale/pt-BR.js +1 -0
  129. package/lib/umd/locale/ru-RU.js +1 -0
  130. package/lib/umd/locale/sk-SK.js +1 -0
  131. package/lib/umd/locale/vi-VN.js +1 -0
  132. package/lib/umd/locale/zh-CN.js +1 -0
  133. package/lib/umd/locale/zh-HK.js +1 -0
  134. package/lib/umd/locale/zh-TW.js +1 -0
  135. package/package.json +74 -0
@@ -0,0 +1,3146 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _univerjs_core = require("@apollo-office/core");
3
+ let _univerjs_drawing = require("@apollo-office/drawing");
4
+ let _univerjs_engine_render = require("@apollo-office/engine-render");
5
+ let _univerjs_icons = require("@univerjs/icons");
6
+ let _univerjs_ui = require("@apollo-office/ui");
7
+ let rxjs = require("rxjs");
8
+ let _univerjs_design = require("@apollo-office/design");
9
+ let react = require("react");
10
+ let react_jsx_runtime = require("react/jsx-runtime");
11
+
12
+ //#region src/commands/operations/drawing-align.operation.ts
13
+ /**
14
+ * Set drawing align operation, including left, center, right, top, middle, bottom, horizon and vertical align.
15
+ */
16
+ const SetDrawingAlignOperation = {
17
+ id: "sheet.operation.set-image-align",
18
+ type: _univerjs_core.CommandType.OPERATION,
19
+ handler: (accessor, params) => {
20
+ return true;
21
+ }
22
+ };
23
+ const SetDrawingAlignLeftOperation = {
24
+ id: "sheet.operation.set-drawing-align-left",
25
+ type: _univerjs_core.CommandType.OPERATION,
26
+ handler: (accessor) => {
27
+ return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetDrawingAlignOperation.id, { alignType: "1" });
28
+ }
29
+ };
30
+ const SetDrawingAlignCenterOperation = {
31
+ id: "sheet.operation.set-drawing-align-center",
32
+ type: _univerjs_core.CommandType.OPERATION,
33
+ handler: (accessor) => {
34
+ return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetDrawingAlignOperation.id, { alignType: "2" });
35
+ }
36
+ };
37
+ const SetDrawingAlignRightOperation = {
38
+ id: "sheet.operation.set-drawing-align-right",
39
+ type: _univerjs_core.CommandType.OPERATION,
40
+ handler: (accessor) => {
41
+ return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetDrawingAlignOperation.id, { alignType: "3" });
42
+ }
43
+ };
44
+ const SetDrawingAlignTopOperation = {
45
+ id: "sheet.operation.set-drawing-align-top",
46
+ type: _univerjs_core.CommandType.OPERATION,
47
+ handler: (accessor) => {
48
+ return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetDrawingAlignOperation.id, { alignType: "4" });
49
+ }
50
+ };
51
+ const SetDrawingAlignMiddleOperation = {
52
+ id: "sheet.operation.set-drawing-align-middle",
53
+ type: _univerjs_core.CommandType.OPERATION,
54
+ handler: (accessor) => {
55
+ return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetDrawingAlignOperation.id, { alignType: "5" });
56
+ }
57
+ };
58
+ const SetDrawingAlignBottomOperation = {
59
+ id: "sheet.operation.set-drawing-align-bottom",
60
+ type: _univerjs_core.CommandType.OPERATION,
61
+ handler: (accessor) => {
62
+ return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetDrawingAlignOperation.id, { alignType: "6" });
63
+ }
64
+ };
65
+ const SetDrawingAlignHorizonOperation = {
66
+ id: "sheet.operation.set-drawing-align-horizon",
67
+ type: _univerjs_core.CommandType.OPERATION,
68
+ handler: (accessor) => {
69
+ return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetDrawingAlignOperation.id, { alignType: "7" });
70
+ }
71
+ };
72
+ const SetDrawingAlignVerticalOperation = {
73
+ id: "sheet.operation.set-drawing-align-vertical",
74
+ type: _univerjs_core.CommandType.OPERATION,
75
+ handler: (accessor) => {
76
+ return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetDrawingAlignOperation.id, { alignType: "8" });
77
+ }
78
+ };
79
+
80
+ //#endregion
81
+ //#region src/commands/operations/drawing-arrange.operation.ts
82
+ /**
83
+ * Set the layer of the drawing, including forward, backward, front, and back
84
+ */
85
+ const SetDrawingArrangeOperation = {
86
+ id: "drawing.operation.set-drawing-arrange",
87
+ type: _univerjs_core.CommandType.OPERATION,
88
+ handler: (accessor, params) => {
89
+ const drawingManagerService = accessor.get(_univerjs_drawing.IDrawingManagerService);
90
+ const { arrangeType } = params;
91
+ const drawings = params.drawings || drawingManagerService.getFocusDrawings();
92
+ const { unitId, subUnitId } = drawings[0];
93
+ const drawingIds = drawings.map((drawing) => drawing.drawingId);
94
+ drawingManagerService.featurePluginOrderUpdateNotification({
95
+ unitId,
96
+ subUnitId,
97
+ drawingIds,
98
+ arrangeType
99
+ });
100
+ return true;
101
+ }
102
+ };
103
+ const SetDrawingArrangeFrontOperation = {
104
+ id: "drawing.operation.set-drawing-arrange-front",
105
+ type: _univerjs_core.CommandType.OPERATION,
106
+ handler: (accessor) => {
107
+ return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetDrawingArrangeOperation.id, { arrangeType: _univerjs_core.ArrangeTypeEnum.front });
108
+ }
109
+ };
110
+ const SetDrawingArrangeForwardOperation = {
111
+ id: "drawing.operation.set-drawing-arrange-forward",
112
+ type: _univerjs_core.CommandType.OPERATION,
113
+ handler: (accessor) => {
114
+ return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetDrawingArrangeOperation.id, { arrangeType: _univerjs_core.ArrangeTypeEnum.forward });
115
+ }
116
+ };
117
+ const SetDrawingArrangeBackOperation = {
118
+ id: "drawing.operation.set-drawing-arrange-back",
119
+ type: _univerjs_core.CommandType.OPERATION,
120
+ handler: (accessor) => {
121
+ return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetDrawingArrangeOperation.id, { arrangeType: _univerjs_core.ArrangeTypeEnum.back });
122
+ }
123
+ };
124
+ const SetDrawingArrangeBackwardOperation = {
125
+ id: "drawing.operation.set-drawing-arrange-backward",
126
+ type: _univerjs_core.CommandType.OPERATION,
127
+ handler: (accessor) => {
128
+ return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetDrawingArrangeOperation.id, { arrangeType: _univerjs_core.ArrangeTypeEnum.backward });
129
+ }
130
+ };
131
+
132
+ //#endregion
133
+ //#region src/commands/operations/drawing-group.operation.ts
134
+ /**
135
+ * Now only support grouping images, shapes, and groups.
136
+ */
137
+ const DRAWING_GROUP_TYPES = [
138
+ _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE,
139
+ _univerjs_core.DrawingTypeEnum.DRAWING_SHAPE,
140
+ _univerjs_core.DrawingTypeEnum.DRAWING_GROUP
141
+ ];
142
+ /**
143
+ * Group the selected drawings into a new group. The selected drawings must be of type image, shape, or group, and there must be at least 2 drawings selected.
144
+ */
145
+ const SetDrawingGroupOperation = {
146
+ id: "drawing.operation.set-drawing-group",
147
+ type: _univerjs_core.CommandType.OPERATION,
148
+ handler: (accessor, params) => {
149
+ const drawingManagerService = accessor.get(_univerjs_drawing.IDrawingManagerService);
150
+ const drawings = params.drawings || drawingManagerService.getFocusDrawings();
151
+ if (drawings.length < 2) return false;
152
+ if (!drawings.every((drawing) => DRAWING_GROUP_TYPES.includes(drawing.drawingType))) return false;
153
+ const { unitId, subUnitId } = drawings[0];
154
+ const groupId = (0, _univerjs_core.generateRandomId)(10);
155
+ const groupTransform = (0, _univerjs_engine_render.getGroupState)(0, 0, drawings.map((o) => o.transform || {}));
156
+ const groupParam = {
157
+ unitId,
158
+ subUnitId,
159
+ drawingId: groupId,
160
+ drawingType: _univerjs_core.DrawingTypeEnum.DRAWING_GROUP,
161
+ transform: groupTransform,
162
+ groupBaseBound: {
163
+ left: groupTransform.left,
164
+ top: groupTransform.top,
165
+ width: groupTransform.width,
166
+ height: groupTransform.height
167
+ }
168
+ };
169
+ const children = drawings.map((drawing) => {
170
+ const transform = drawing.transform || {
171
+ left: 0,
172
+ top: 0
173
+ };
174
+ const { unitId, subUnitId, drawingId } = drawing;
175
+ return {
176
+ unitId,
177
+ subUnitId,
178
+ drawingId,
179
+ transform: { ...transform },
180
+ groupId
181
+ };
182
+ });
183
+ drawingManagerService.featurePluginGroupUpdateNotification([{
184
+ parent: groupParam,
185
+ children
186
+ }]);
187
+ return true;
188
+ }
189
+ };
190
+ /**
191
+ * Ungroup the selected groups. The selected drawings must be at least 1 group selected.
192
+ */
193
+ const CancelDrawingGroupOperation = {
194
+ id: "drawing.operation.cancel-drawing-group",
195
+ type: _univerjs_core.CommandType.OPERATION,
196
+ handler: (accessor, params) => {
197
+ const drawingManagerService = accessor.get(_univerjs_drawing.IDrawingManagerService);
198
+ const groupParams = (params.drawings || drawingManagerService.getFocusDrawings()).map((drawing) => {
199
+ if (drawing.drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_GROUP) return null;
200
+ const { unitId, subUnitId, drawingId, transform: groupTransform = {
201
+ width: 0,
202
+ height: 0
203
+ }, groupBaseBound } = drawing;
204
+ if (groupTransform === null) return null;
205
+ const objects = drawingManagerService.getDrawingsByGroup({
206
+ unitId,
207
+ subUnitId,
208
+ drawingId
209
+ });
210
+ if (objects.length === 0) return null;
211
+ return {
212
+ parent: drawing,
213
+ children: objects.map((object) => {
214
+ const { transform } = object;
215
+ const { unitId, subUnitId, drawingId } = object;
216
+ const newTransform = (0, _univerjs_engine_render.transformObjectOutOfGroup)(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0, groupBaseBound);
217
+ return {
218
+ unitId,
219
+ subUnitId,
220
+ drawingId,
221
+ transform: {
222
+ ...transform,
223
+ ...newTransform
224
+ },
225
+ groupId: void 0
226
+ };
227
+ })
228
+ };
229
+ }).filter((o) => o !== null);
230
+ if (groupParams.length === 0) return false;
231
+ drawingManagerService.featurePluginUngroupUpdateNotification(groupParams);
232
+ return true;
233
+ }
234
+ };
235
+
236
+ //#endregion
237
+ //#region src/commands/operations/image-crop.operation.ts
238
+ const OpenImageCropOperation = {
239
+ id: "sheet.operation.open-image-crop",
240
+ type: _univerjs_core.CommandType.OPERATION,
241
+ handler: (accessor, params) => {
242
+ return true;
243
+ }
244
+ };
245
+ const CloseImageCropOperation = {
246
+ id: "sheet.operation.close-image-crop",
247
+ type: _univerjs_core.CommandType.OPERATION,
248
+ handler: (accessor, params) => {
249
+ return true;
250
+ }
251
+ };
252
+ const AutoImageCropOperation = {
253
+ id: "sheet.operation.Auto-image-crop",
254
+ type: _univerjs_core.CommandType.OPERATION,
255
+ handler: (accessor, params) => {
256
+ return true;
257
+ }
258
+ };
259
+
260
+ //#endregion
261
+ //#region src/commands/operations/image-reset-size.operation.ts
262
+ const ImageResetSizeOperation = {
263
+ id: "sheet.operation.image-reset-size",
264
+ type: _univerjs_core.CommandType.OPERATION,
265
+ handler: (accessor, params) => {
266
+ return true;
267
+ }
268
+ };
269
+
270
+ //#endregion
271
+ //#region src/controllers/utils.ts
272
+ function insertGroupObject(objectParam, object, scene, drawingManagerService) {
273
+ const groupParam = drawingManagerService.getDrawingByParam(objectParam);
274
+ if (groupParam == null) return;
275
+ const groupKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)(objectParam);
276
+ const groupObject = scene.getObjectIncludeInGroup(groupKey);
277
+ if (groupObject && !(groupObject instanceof _univerjs_engine_render.Group)) return;
278
+ if (groupObject != null) {
279
+ const objects = groupObject.getObjects();
280
+ for (const obj of objects) if (obj.oKey === object.oKey) return;
281
+ groupObject.addObject(object);
282
+ return;
283
+ }
284
+ const group = new _univerjs_engine_render.DrawingGroupObject(groupKey);
285
+ scene.addObject(group, _univerjs_engine_render.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(group);
286
+ group.addObject(object);
287
+ const { transform, groupBaseBound } = groupParam;
288
+ if (groupBaseBound) group.setBaseBound(groupBaseBound);
289
+ if (groupParam.groupId) {
290
+ group.isInGroup = true;
291
+ insertGroupObject({
292
+ drawingId: groupParam.groupId,
293
+ unitId: objectParam.unitId,
294
+ subUnitId: objectParam.subUnitId
295
+ }, group, scene, drawingManagerService);
296
+ }
297
+ transform && group.transformByState({
298
+ left: transform.left,
299
+ top: transform.top,
300
+ angle: transform.angle,
301
+ width: transform.width,
302
+ height: transform.height
303
+ });
304
+ }
305
+ function getCurrentUnitInfo(currentUniverService, propUnitId) {
306
+ const current = propUnitId ? currentUniverService.getUnit(propUnitId) : currentUniverService.getFocusedUnit();
307
+ if (current == null) return;
308
+ const unitId = current.getUnitId();
309
+ let subUnitId;
310
+ if (current.type === _univerjs_core.UniverInstanceType.UNIVER_SHEET) {
311
+ var _getActiveSheet;
312
+ subUnitId = (_getActiveSheet = current.getActiveSheet()) === null || _getActiveSheet === void 0 ? void 0 : _getActiveSheet.getSheetId();
313
+ } else if (current.type === _univerjs_core.UniverInstanceType.UNIVER_DOC) subUnitId = unitId;
314
+ else if (current.type === _univerjs_core.UniverInstanceType.UNIVER_SLIDE) subUnitId = unitId;
315
+ return {
316
+ unitId,
317
+ subUnitId,
318
+ current
319
+ };
320
+ }
321
+
322
+ //#endregion
323
+ //#region package.json
324
+ var name = "@apollo-office/drawing-ui";
325
+ var version = "0.25.1";
326
+
327
+ //#endregion
328
+ //#region src/config/config.ts
329
+ const DRAWING_UI_PLUGIN_CONFIG_KEY = "drawing-ui.config";
330
+ const configSymbol = Symbol(DRAWING_UI_PLUGIN_CONFIG_KEY);
331
+ const defaultPluginConfig = {};
332
+
333
+ //#endregion
334
+ //#region src/menu/align.menu.ts
335
+ const getMenuStateByDrawingFocusChangedObservable$$1 = (accessor) => {
336
+ const drawingManagerService = accessor.get(_univerjs_drawing.IDrawingManagerService);
337
+ return new rxjs.Observable((subscriber) => {
338
+ const update = (drawings) => {
339
+ if (!drawings || drawings.length === 0) return subscriber.next(true);
340
+ if (drawings.length < 2) return subscriber.next(true);
341
+ subscriber.next(false);
342
+ };
343
+ const subscription = drawingManagerService.focus$.subscribe((drawings) => {
344
+ if (!drawings || drawings.length === 0) return subscriber.next(true);
345
+ update(drawings);
346
+ });
347
+ update(drawingManagerService.getFocusDrawings());
348
+ return () => subscription.unsubscribe();
349
+ });
350
+ };
351
+ const DRAWING_ALIGN_CONTEXT_MENU_ID = "contextMenu.drawing-align";
352
+ function DrawingAlignContextMenuItemFactory(accessor) {
353
+ return {
354
+ id: DRAWING_ALIGN_CONTEXT_MENU_ID,
355
+ type: _univerjs_ui.MenuItemType.SUBITEMS,
356
+ icon: "HorizontallyIcon",
357
+ title: "drawing-ui.image-panel.align.title",
358
+ hidden$: getMenuStateByDrawingFocusChangedObservable$$1(accessor)
359
+ };
360
+ }
361
+ function SetDrawingAlignLeftMenuItemFactory() {
362
+ return {
363
+ id: SetDrawingAlignLeftOperation.id,
364
+ type: _univerjs_ui.MenuItemType.BUTTON,
365
+ icon: "LeftJustifyingIcon",
366
+ title: "drawing-ui.image-panel.align.left"
367
+ };
368
+ }
369
+ function SetDrawingAlignCenterMenuItemFactory() {
370
+ return {
371
+ id: SetDrawingAlignCenterOperation.id,
372
+ type: _univerjs_ui.MenuItemType.BUTTON,
373
+ icon: "HorizontallyIcon",
374
+ title: "drawing-ui.image-panel.align.center"
375
+ };
376
+ }
377
+ function SetDrawingAlignRightMenuItemFactory() {
378
+ return {
379
+ id: SetDrawingAlignRightOperation.id,
380
+ type: _univerjs_ui.MenuItemType.BUTTON,
381
+ icon: "RightJustifyingIcon",
382
+ title: "drawing-ui.image-panel.align.right"
383
+ };
384
+ }
385
+ function SetDrawingAlignTopMenuItemFactory() {
386
+ return {
387
+ id: SetDrawingAlignTopOperation.id,
388
+ type: _univerjs_ui.MenuItemType.BUTTON,
389
+ icon: "AlignTopIcon",
390
+ title: "drawing-ui.image-panel.align.top"
391
+ };
392
+ }
393
+ function SetDrawingAlignMiddleMenuItemFactory() {
394
+ return {
395
+ id: SetDrawingAlignMiddleOperation.id,
396
+ type: _univerjs_ui.MenuItemType.BUTTON,
397
+ icon: "VerticalCenterIcon",
398
+ title: "drawing-ui.image-panel.align.middle"
399
+ };
400
+ }
401
+ function SetDrawingAlignBottomMenuItemFactory() {
402
+ return {
403
+ id: SetDrawingAlignBottomOperation.id,
404
+ type: _univerjs_ui.MenuItemType.BUTTON,
405
+ icon: "AlignBottomIcon",
406
+ title: "drawing-ui.image-panel.align.bottom"
407
+ };
408
+ }
409
+ function SetDrawingAlignHorizonMenuItemFactory() {
410
+ return {
411
+ id: SetDrawingAlignHorizonOperation.id,
412
+ type: _univerjs_ui.MenuItemType.BUTTON,
413
+ icon: "HorizontallyIcon",
414
+ title: "drawing-ui.image-panel.align.horizon"
415
+ };
416
+ }
417
+ function SetDrawingAlignVerticalMenuItemFactory() {
418
+ return {
419
+ id: SetDrawingAlignVerticalOperation.id,
420
+ type: _univerjs_ui.MenuItemType.BUTTON,
421
+ icon: "VerticalCenterIcon",
422
+ title: "drawing-ui.image-panel.align.vertical"
423
+ };
424
+ }
425
+
426
+ //#endregion
427
+ //#region src/menu/arrange.menu.ts
428
+ const DRAWING_ARRANGE_CONTEXT_MENU_ID = "contextMenu.drawing-arrange";
429
+ function DrawingArrangeContextMenuItemFactory() {
430
+ return {
431
+ id: DRAWING_ARRANGE_CONTEXT_MENU_ID,
432
+ type: _univerjs_ui.MenuItemType.SUBITEMS,
433
+ icon: "TopmostIcon",
434
+ title: "drawing-ui.image-panel.arrange.title"
435
+ };
436
+ }
437
+ function SetDrawingArrangeFrontMenuItemFactory() {
438
+ return {
439
+ id: SetDrawingArrangeFrontOperation.id,
440
+ type: _univerjs_ui.MenuItemType.BUTTON,
441
+ icon: "TopmostIcon",
442
+ title: "drawing-ui.image-panel.arrange.front"
443
+ };
444
+ }
445
+ function SetDrawingArrangeForwardMenuItemFactory() {
446
+ return {
447
+ id: SetDrawingArrangeForwardOperation.id,
448
+ type: _univerjs_ui.MenuItemType.BUTTON,
449
+ icon: "MoveUpIcon",
450
+ title: "drawing-ui.image-panel.arrange.forward"
451
+ };
452
+ }
453
+ function SetDrawingArrangeBackMenuItemFactory() {
454
+ return {
455
+ id: SetDrawingArrangeBackOperation.id,
456
+ type: _univerjs_ui.MenuItemType.BUTTON,
457
+ icon: "BottomIcon",
458
+ title: "drawing-ui.image-panel.arrange.back"
459
+ };
460
+ }
461
+ function SetDrawingArrangeBackwardMenuItemFactory() {
462
+ return {
463
+ id: SetDrawingArrangeBackwardOperation.id,
464
+ type: _univerjs_ui.MenuItemType.BUTTON,
465
+ icon: "MoveDownIcon",
466
+ title: "drawing-ui.image-panel.arrange.backward"
467
+ };
468
+ }
469
+
470
+ //#endregion
471
+ //#region src/menu/group.menu.ts
472
+ const getMenuStateByDrawingFocusChangedObservable$ = (accessor, type) => {
473
+ const drawingManagerService = accessor.get(_univerjs_drawing.IDrawingManagerService);
474
+ return new rxjs.Observable((subscriber) => {
475
+ const update = (drawings) => {
476
+ if (!drawings || drawings.length === 0) return subscriber.next(true);
477
+ if (type === "group") {
478
+ if (drawings.length < 2) return subscriber.next(true);
479
+ if (!drawings.every((drawing) => DRAWING_GROUP_TYPES.includes(drawing.drawingType))) return subscriber.next(true);
480
+ } else if (type === "unGroup") {
481
+ if (drawings.filter((drawing) => drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_GROUP).length === 0) return subscriber.next(true);
482
+ } else if (!drawings.every((drawing) => DRAWING_GROUP_TYPES.includes(drawing.drawingType))) return subscriber.next(true);
483
+ subscriber.next(false);
484
+ };
485
+ const subscription = drawingManagerService.focus$.subscribe((drawings) => {
486
+ if (!drawings || drawings.length === 0) return subscriber.next(true);
487
+ update(drawings);
488
+ });
489
+ update(drawingManagerService.getFocusDrawings());
490
+ return () => subscription.unsubscribe();
491
+ });
492
+ };
493
+ const DRAWING_GROUP_CONTEXT_MENU_ID = "contextMenu.drawing-group";
494
+ function DrawingGroupContextMenuItemFactory(accessor) {
495
+ return {
496
+ id: DRAWING_GROUP_CONTEXT_MENU_ID,
497
+ type: _univerjs_ui.MenuItemType.SUBITEMS,
498
+ icon: "GroupIcon",
499
+ title: "drawing-ui.image-panel.group.title",
500
+ hidden$: getMenuStateByDrawingFocusChangedObservable$(accessor)
501
+ };
502
+ }
503
+ function SetDrawingGroupMenuItemFactory(accessor) {
504
+ return {
505
+ id: SetDrawingGroupOperation.id,
506
+ type: _univerjs_ui.MenuItemType.BUTTON,
507
+ icon: "GroupIcon",
508
+ title: "drawing-ui.image-panel.group.group",
509
+ disabled$: getMenuStateByDrawingFocusChangedObservable$(accessor, "group")
510
+ };
511
+ }
512
+ function CancelDrawingGroupMenuItemFactory(accessor) {
513
+ return {
514
+ id: CancelDrawingGroupOperation.id,
515
+ type: _univerjs_ui.MenuItemType.BUTTON,
516
+ icon: "UngroupIcon",
517
+ title: "drawing-ui.image-panel.group.unGroup",
518
+ disabled$: getMenuStateByDrawingFocusChangedObservable$(accessor, "unGroup")
519
+ };
520
+ }
521
+
522
+ //#endregion
523
+ //#region src/menu/schema.ts
524
+ const menuSchema = { [_univerjs_ui.ContextMenuPosition.DRAWING]: { [_univerjs_ui.ContextMenuGroup.OTHERS]: {
525
+ [DRAWING_GROUP_CONTEXT_MENU_ID]: {
526
+ order: 1,
527
+ menuItemFactory: DrawingGroupContextMenuItemFactory,
528
+ [SetDrawingGroupOperation.id]: {
529
+ order: 0,
530
+ menuItemFactory: SetDrawingGroupMenuItemFactory
531
+ },
532
+ [CancelDrawingGroupOperation.id]: {
533
+ order: 1,
534
+ menuItemFactory: CancelDrawingGroupMenuItemFactory
535
+ }
536
+ },
537
+ [DRAWING_ARRANGE_CONTEXT_MENU_ID]: {
538
+ order: 2,
539
+ menuItemFactory: DrawingArrangeContextMenuItemFactory,
540
+ [SetDrawingArrangeFrontOperation.id]: {
541
+ order: 0,
542
+ menuItemFactory: SetDrawingArrangeFrontMenuItemFactory
543
+ },
544
+ [SetDrawingArrangeForwardOperation.id]: {
545
+ order: 1,
546
+ menuItemFactory: SetDrawingArrangeForwardMenuItemFactory
547
+ },
548
+ [SetDrawingArrangeBackOperation.id]: {
549
+ order: 2,
550
+ menuItemFactory: SetDrawingArrangeBackMenuItemFactory
551
+ },
552
+ [SetDrawingArrangeBackwardOperation.id]: {
553
+ order: 3,
554
+ menuItemFactory: SetDrawingArrangeBackwardMenuItemFactory
555
+ }
556
+ },
557
+ [DRAWING_ALIGN_CONTEXT_MENU_ID]: {
558
+ order: 3,
559
+ menuItemFactory: DrawingAlignContextMenuItemFactory,
560
+ [SetDrawingAlignLeftOperation.id]: {
561
+ order: 0,
562
+ menuItemFactory: SetDrawingAlignLeftMenuItemFactory
563
+ },
564
+ [SetDrawingAlignCenterOperation.id]: {
565
+ order: 1,
566
+ menuItemFactory: SetDrawingAlignCenterMenuItemFactory
567
+ },
568
+ [SetDrawingAlignRightOperation.id]: {
569
+ order: 2,
570
+ menuItemFactory: SetDrawingAlignRightMenuItemFactory
571
+ },
572
+ [SetDrawingAlignTopOperation.id]: {
573
+ order: 3,
574
+ menuItemFactory: SetDrawingAlignTopMenuItemFactory
575
+ },
576
+ [SetDrawingAlignMiddleOperation.id]: {
577
+ order: 4,
578
+ menuItemFactory: SetDrawingAlignMiddleMenuItemFactory
579
+ },
580
+ [SetDrawingAlignBottomOperation.id]: {
581
+ order: 5,
582
+ menuItemFactory: SetDrawingAlignBottomMenuItemFactory
583
+ },
584
+ [SetDrawingAlignHorizonOperation.id]: {
585
+ order: 6,
586
+ menuItemFactory: SetDrawingAlignHorizonMenuItemFactory
587
+ },
588
+ [SetDrawingAlignVerticalOperation.id]: {
589
+ order: 7,
590
+ menuItemFactory: SetDrawingAlignVerticalMenuItemFactory
591
+ }
592
+ }
593
+ } } };
594
+
595
+ //#endregion
596
+ //#region src/views/image-popup-menu/component-name.ts
597
+ /**
598
+ * Copyright 2023-present DreamNum Co., Ltd.
599
+ *
600
+ * Licensed under the Apache License, Version 2.0 (the "License");
601
+ * you may not use this file except in compliance with the License.
602
+ * You may obtain a copy of the License at
603
+ *
604
+ * http://www.apache.org/licenses/LICENSE-2.0
605
+ *
606
+ * Unless required by applicable law or agreed to in writing, software
607
+ * distributed under the License is distributed on an "AS IS" BASIS,
608
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
609
+ * See the License for the specific language governing permissions and
610
+ * limitations under the License.
611
+ */
612
+ const COMPONENT_IMAGE_POPUP_MENU = "COMPONENT_IMAGE_POPUP_MENU";
613
+
614
+ //#endregion
615
+ //#region src/views/image-popup-menu/ImagePopupMenu.tsx
616
+ function ImagePopupMenu(props) {
617
+ var _popup$extraProps, _popup$extraProps2;
618
+ const { popup } = props;
619
+ const menuItems = popup === null || popup === void 0 || (_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.menuItems;
620
+ if (!menuItems) return null;
621
+ if (((_popup$extraProps2 = popup.extraProps) === null || _popup$extraProps2 === void 0 ? void 0 : _popup$extraProps2.variant) === "doc-floating-toolbar" && popup.extraProps.unitId && popup.extraProps.subUnitId && popup.extraProps.drawingId) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocImageFloatingToolbar, {
622
+ menuItems,
623
+ unitId: popup.extraProps.unitId,
624
+ subUnitId: popup.extraProps.subUnitId,
625
+ drawingId: popup.extraProps.drawingId
626
+ });
627
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
628
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
629
+ const [visible, setVisible] = (0, react.useState)(false);
630
+ const [isHovered, setHovered] = (0, react.useState)(false);
631
+ const handleMouseEnter = () => {
632
+ setHovered(true);
633
+ };
634
+ const handleMouseLeave = () => {
635
+ setHovered(false);
636
+ };
637
+ const onVisibleChange = (visible) => {
638
+ setVisible(visible);
639
+ };
640
+ const handleClick = (item) => {
641
+ commandService.executeCommand(item.commandId, item.commandParams);
642
+ setVisible(false);
643
+ };
644
+ const showMore = visible || isHovered;
645
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
646
+ onMouseEnter: handleMouseEnter,
647
+ onMouseLeave: handleMouseLeave,
648
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
649
+ align: "start",
650
+ items: menuItems.map((item) => ({
651
+ type: "item",
652
+ children: localeService.t(item.label),
653
+ disabled: item.disable,
654
+ onSelect: () => handleClick(item)
655
+ })),
656
+ open: visible,
657
+ onOpenChange: onVisibleChange,
658
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
659
+ className: (0, _univerjs_design.clsx)("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", _univerjs_design.borderClassName, {
660
+ "univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
661
+ "univer-bg-white dark:!univer-bg-gray-900": !visible
662
+ }),
663
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AutofillDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white" }), showMore && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "dark:!univer-text-white" })]
664
+ })
665
+ })
666
+ });
667
+ }
668
+ const UPDATE_DOC_DRAWING_WRAPPING_STYLE_COMMAND_ID = "doc.command.update-doc-drawing-wrapping-style";
669
+ function getWrappingStyle(documentDataModel, drawingId) {
670
+ var _documentDataModel$ge;
671
+ const drawing = documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge = documentDataModel.getSnapshot().drawings) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge[drawingId];
672
+ if (!drawing) return "inline";
673
+ if (drawing.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_NONE) return drawing.behindDoc === _univerjs_core.BooleanNumber.TRUE ? "behindText" : "inFrontOfText";
674
+ if (drawing.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_SQUARE) return "wrapSquare";
675
+ if (drawing.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) return "wrapTopAndBottom";
676
+ return "inline";
677
+ }
678
+ function Divider() {
679
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "\r\n univer-h-5 univer-w-px univer-bg-gray-200\r\n dark:!univer-bg-gray-700\r\n " });
680
+ }
681
+ function ToolbarGroup(props) {
682
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
683
+ className: "univer-flex univer-h-7 univer-items-center univer-gap-1 univer-px-1",
684
+ children: props.children
685
+ });
686
+ }
687
+ function ToolbarButton(props) {
688
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
689
+ title: props.title,
690
+ placement: "bottom",
691
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
692
+ type: "button",
693
+ disabled: props.disabled,
694
+ onClick: props.onClick,
695
+ className: (0, _univerjs_design.clsx)("univer-flex univer-h-6 univer-w-6 univer-items-center univer-justify-center univer-rounded-md univer-border-none univer-bg-transparent univer-p-0 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-40 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700", { "univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300": props.active }),
696
+ children: props.children
697
+ })
698
+ });
699
+ }
700
+ function TextWrapShapeIcon() {
701
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
702
+ viewBox: "0 0 20 20",
703
+ width: "1em",
704
+ height: "1em",
705
+ fill: "none",
706
+ "aria-hidden": "true",
707
+ children: [
708
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
709
+ d: "M2.5 4.5H8.2",
710
+ stroke: "currentColor",
711
+ strokeWidth: "1.4",
712
+ strokeLinecap: "round"
713
+ }),
714
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
715
+ d: "M11.8 4.5H17.5",
716
+ stroke: "currentColor",
717
+ strokeWidth: "1.4",
718
+ strokeLinecap: "round"
719
+ }),
720
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
721
+ d: "M2.5 10H5.7",
722
+ stroke: "currentColor",
723
+ strokeWidth: "1.4",
724
+ strokeLinecap: "round"
725
+ }),
726
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
727
+ d: "M14.3 10H17.5",
728
+ stroke: "currentColor",
729
+ strokeWidth: "1.4",
730
+ strokeLinecap: "round"
731
+ }),
732
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
733
+ d: "M2.5 15.5H8.2",
734
+ stroke: "currentColor",
735
+ strokeWidth: "1.4",
736
+ strokeLinecap: "round"
737
+ }),
738
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
739
+ d: "M11.8 15.5H17.5",
740
+ stroke: "currentColor",
741
+ strokeWidth: "1.4",
742
+ strokeLinecap: "round"
743
+ }),
744
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
745
+ x: "6.8",
746
+ y: "7",
747
+ width: "6.4",
748
+ height: "6",
749
+ rx: "1",
750
+ stroke: "currentColor",
751
+ strokeWidth: "1.4"
752
+ })
753
+ ]
754
+ });
755
+ }
756
+ function CropIcon() {
757
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
758
+ viewBox: "0 0 20 20",
759
+ width: "1em",
760
+ height: "1em",
761
+ fill: "none",
762
+ "aria-hidden": "true",
763
+ children: [
764
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
765
+ d: "M5 2.8V12.5C5 13.9 6.1 15 7.5 15H17.2",
766
+ stroke: "currentColor",
767
+ strokeWidth: "1.5",
768
+ strokeLinecap: "round"
769
+ }),
770
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
771
+ d: "M2.8 5H12.5C13.9 5 15 6.1 15 7.5V17.2",
772
+ stroke: "currentColor",
773
+ strokeWidth: "1.5",
774
+ strokeLinecap: "round"
775
+ }),
776
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
777
+ d: "M8.3 8.3H11.7V11.7H8.3V8.3Z",
778
+ stroke: "currentColor",
779
+ strokeWidth: "1.2"
780
+ })
781
+ ]
782
+ });
783
+ }
784
+ function ToolbarDropdownButton(props) {
785
+ var _props$options$find;
786
+ const [open, setOpen] = (0, react.useState)(false);
787
+ const activeOption = (_props$options$find = props.options.find((option) => option.value === props.value)) !== null && _props$options$find !== void 0 ? _props$options$find : props.options[0];
788
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
789
+ open,
790
+ onOpenChange: setOpen,
791
+ overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
792
+ className: "univer-min-w-32 univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-1 univer-shadow-lg dark:!univer-border-gray-700 dark:!univer-bg-gray-900",
793
+ children: props.options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
794
+ type: "button",
795
+ onClick: () => {
796
+ props.onChange(option.value);
797
+ setOpen(false);
798
+ },
799
+ className: (0, _univerjs_design.clsx)("univer-flex univer-h-8 univer-w-full univer-items-center univer-gap-2 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-800", { "univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-gray-800 dark:!univer-text-primary-300": option.value === props.value }),
800
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
801
+ className: "univer-flex univer-size-4 univer-items-center univer-justify-center",
802
+ children: option.icon
803
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
804
+ className: "univer-flex-1",
805
+ children: option.label
806
+ })]
807
+ }, option.value))
808
+ }),
809
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
810
+ title: props.title,
811
+ placement: "bottom",
812
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
813
+ type: "button",
814
+ className: (0, _univerjs_design.clsx)("univer-flex univer-h-6 univer-min-w-9 univer-items-center univer-justify-center univer-gap-1 univer-rounded-md univer-border-none univer-bg-transparent univer-px-1.5 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700", { "univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300": open }),
815
+ children: [activeOption.icon, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "univer-text-xs" })]
816
+ })
817
+ }) })
818
+ });
819
+ }
820
+ function DocImageFloatingToolbar(props) {
821
+ var _univerInstanceServic, _wrappingStyleOptions, _wrappingStyleOptions2;
822
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
823
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
824
+ const documentDataModel = (_univerInstanceServic = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService).getUnit(props.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC)) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : void 0;
825
+ const [wrappingStyle, setWrappingStyle] = (0, react.useState)(() => getWrappingStyle(documentDataModel, props.drawingId));
826
+ const [hidden, setHidden] = (0, react.useState)(false);
827
+ const getMenuItem = (label) => props.menuItems.find((item) => item.label === label);
828
+ const editItem = getMenuItem("drawing-ui.image-popup.edit");
829
+ const cropItem = getMenuItem("drawing-ui.image-popup.crop");
830
+ const deleteItem = getMenuItem("drawing-ui.image-popup.delete");
831
+ const wrappingStyleOptions = [
832
+ {
833
+ label: localeService.t("drawing-ui.image-text-wrap.inline"),
834
+ value: "inline",
835
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextWrapShapeIcon, {})
836
+ },
837
+ {
838
+ label: localeService.t("drawing-ui.image-text-wrap.square"),
839
+ value: "wrapSquare",
840
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextWrapShapeIcon, {})
841
+ },
842
+ {
843
+ label: localeService.t("drawing-ui.image-text-wrap.topAndBottom"),
844
+ value: "wrapTopAndBottom",
845
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextWrapShapeIcon, {})
846
+ },
847
+ {
848
+ label: localeService.t("drawing-ui.image-text-wrap.behindText"),
849
+ value: "behindText",
850
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextWrapShapeIcon, {})
851
+ },
852
+ {
853
+ label: localeService.t("drawing-ui.image-text-wrap.inFrontText"),
854
+ value: "inFrontOfText",
855
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextWrapShapeIcon, {})
856
+ }
857
+ ];
858
+ const executeMenuItem = (item) => {
859
+ if (!item || item.disable) return;
860
+ commandService.executeCommand(item.commandId, item.commandParams);
861
+ };
862
+ const updateWrappingStyle = (value) => {
863
+ setWrappingStyle(value);
864
+ commandService.executeCommand(UPDATE_DOC_DRAWING_WRAPPING_STYLE_COMMAND_ID, {
865
+ unitId: props.unitId,
866
+ subUnitId: props.subUnitId,
867
+ drawings: [{
868
+ unitId: props.unitId,
869
+ subUnitId: props.subUnitId,
870
+ drawingId: props.drawingId
871
+ }],
872
+ wrappingStyle: value
873
+ });
874
+ };
875
+ if (hidden) return null;
876
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
877
+ "data-u-comp": "doc-image-floating-toolbar",
878
+ onMouseDown: (event) => {
879
+ event.stopPropagation();
880
+ event.preventDefault();
881
+ },
882
+ className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-items-center univer-rounded univer-bg-white univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900", _univerjs_design.borderClassName),
883
+ children: [
884
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarGroup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarDropdownButton, {
885
+ title: (_wrappingStyleOptions = (_wrappingStyleOptions2 = wrappingStyleOptions.find((option) => option.value === wrappingStyle)) === null || _wrappingStyleOptions2 === void 0 ? void 0 : _wrappingStyleOptions2.label) !== null && _wrappingStyleOptions !== void 0 ? _wrappingStyleOptions : localeService.t("drawing-ui.image-text-wrap.inline"),
886
+ value: wrappingStyle,
887
+ options: wrappingStyleOptions,
888
+ onChange: updateWrappingStyle
889
+ }) }),
890
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Divider, {}),
891
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToolbarGroup, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
892
+ title: editItem ? localeService.t(editItem.label) : localeService.t("drawing-ui.image-popup.edit"),
893
+ disabled: !editItem || editItem.disable,
894
+ onClick: () => {
895
+ setHidden(true);
896
+ executeMenuItem(editItem);
897
+ },
898
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DocSettingIcon, {})
899
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
900
+ title: cropItem ? localeService.t(cropItem.label) : localeService.t("drawing-ui.image-popup.crop"),
901
+ disabled: !cropItem || cropItem.disable,
902
+ onClick: () => executeMenuItem(cropItem),
903
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CropIcon, {})
904
+ })] }),
905
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Divider, {}),
906
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarGroup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
907
+ title: deleteItem ? localeService.t(deleteItem.label) : localeService.t("drawing-ui.image-popup.delete"),
908
+ disabled: !deleteItem || deleteItem.disable,
909
+ onClick: () => executeMenuItem(deleteItem),
910
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteIcon, {})
911
+ }) })
912
+ ]
913
+ });
914
+ }
915
+
916
+ //#endregion
917
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
918
+ function __decorateParam(paramIndex, decorator) {
919
+ return function(target, key) {
920
+ decorator(target, key, paramIndex);
921
+ };
922
+ }
923
+
924
+ //#endregion
925
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
926
+ function __decorate(decorators, target, key, desc) {
927
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
928
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
929
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
930
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
931
+ }
932
+
933
+ //#endregion
934
+ //#region src/controllers/drawing-ui.controller.ts
935
+ /**
936
+ * Copyright 2023-present DreamNum Co., Ltd.
937
+ *
938
+ * Licensed under the Apache License, Version 2.0 (the "License");
939
+ * you may not use this file except in compliance with the License.
940
+ * You may obtain a copy of the License at
941
+ *
942
+ * http://www.apache.org/licenses/LICENSE-2.0
943
+ *
944
+ * Unless required by applicable law or agreed to in writing, software
945
+ * distributed under the License is distributed on an "AS IS" BASIS,
946
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
947
+ * See the License for the specific language governing permissions and
948
+ * limitations under the License.
949
+ */
950
+ let DrawingUIController = class DrawingUIController extends _univerjs_core.Disposable {
951
+ constructor(_componentManager, _commandService, _menuManagerService) {
952
+ super();
953
+ this._componentManager = _componentManager;
954
+ this._commandService = _commandService;
955
+ this._menuManagerService = _menuManagerService;
956
+ this._init();
957
+ }
958
+ _init() {
959
+ this._initMenus();
960
+ this._initCommands();
961
+ this._initComponents();
962
+ }
963
+ _initMenus() {
964
+ this._menuManagerService.mergeMenu(menuSchema);
965
+ }
966
+ _initCommands() {
967
+ [
968
+ OpenImageCropOperation,
969
+ CloseImageCropOperation,
970
+ ImageResetSizeOperation,
971
+ SetDrawingAlignOperation,
972
+ SetDrawingAlignLeftOperation,
973
+ SetDrawingAlignCenterOperation,
974
+ SetDrawingAlignRightOperation,
975
+ SetDrawingAlignTopOperation,
976
+ SetDrawingAlignMiddleOperation,
977
+ SetDrawingAlignBottomOperation,
978
+ SetDrawingAlignHorizonOperation,
979
+ SetDrawingAlignVerticalOperation,
980
+ AutoImageCropOperation,
981
+ SetDrawingGroupOperation,
982
+ CancelDrawingGroupOperation,
983
+ SetDrawingArrangeOperation,
984
+ SetDrawingArrangeFrontOperation,
985
+ SetDrawingArrangeForwardOperation,
986
+ SetDrawingArrangeBackOperation,
987
+ SetDrawingArrangeBackwardOperation
988
+ ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
989
+ }
990
+ _initComponents() {
991
+ [
992
+ [COMPONENT_IMAGE_POPUP_MENU, ImagePopupMenu],
993
+ ["BottomIcon", _univerjs_icons.BottomIcon],
994
+ ["GroupIcon", _univerjs_icons.GroupIcon],
995
+ ["MoveDownIcon", _univerjs_icons.MoveDownIcon],
996
+ ["MoveUpIcon", _univerjs_icons.MoveUpIcon],
997
+ ["TopmostIcon", _univerjs_icons.TopmostIcon],
998
+ ["UngroupIcon", _univerjs_icons.UngroupIcon]
999
+ ].forEach(([key, component]) => {
1000
+ this.disposeWithMe(this._componentManager.register(key, component));
1001
+ });
1002
+ }
1003
+ };
1004
+ DrawingUIController = __decorate([
1005
+ __decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
1006
+ __decorateParam(1, _univerjs_core.ICommandService),
1007
+ __decorateParam(2, _univerjs_ui.IMenuManagerService)
1008
+ ], DrawingUIController);
1009
+
1010
+ //#endregion
1011
+ //#region src/utils/get-update-params.ts
1012
+ function getUpdateParams(objects, drawingManagerService) {
1013
+ const params = [];
1014
+ objects.forEach((object) => {
1015
+ const { oKey, left, top, height, width, angle } = object;
1016
+ const searchParam = drawingManagerService.getDrawingOKey(oKey);
1017
+ if (searchParam == null) {
1018
+ params.push(null);
1019
+ return true;
1020
+ }
1021
+ const { unitId, subUnitId, drawingId, drawingType } = searchParam;
1022
+ const param = {
1023
+ unitId,
1024
+ subUnitId,
1025
+ drawingId,
1026
+ drawingType,
1027
+ transform: {
1028
+ left,
1029
+ top,
1030
+ height,
1031
+ width,
1032
+ angle
1033
+ }
1034
+ };
1035
+ if (drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE) param.srcRect = object.srcRect;
1036
+ params.push(param);
1037
+ });
1038
+ return params;
1039
+ }
1040
+
1041
+ //#endregion
1042
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
1043
+ function _typeof(o) {
1044
+ "@babel/helpers - typeof";
1045
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
1046
+ return typeof o;
1047
+ } : function(o) {
1048
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1049
+ }, _typeof(o);
1050
+ }
1051
+
1052
+ //#endregion
1053
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
1054
+ function toPrimitive(t, r) {
1055
+ if ("object" != _typeof(t) || !t) return t;
1056
+ var e = t[Symbol.toPrimitive];
1057
+ if (void 0 !== e) {
1058
+ var i = e.call(t, r || "default");
1059
+ if ("object" != _typeof(i)) return i;
1060
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1061
+ }
1062
+ return ("string" === r ? String : Number)(t);
1063
+ }
1064
+
1065
+ //#endregion
1066
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
1067
+ function toPropertyKey(t) {
1068
+ var i = toPrimitive(t, "string");
1069
+ return "symbol" == _typeof(i) ? i : i + "";
1070
+ }
1071
+
1072
+ //#endregion
1073
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
1074
+ function _defineProperty(e, r, t) {
1075
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1076
+ value: t,
1077
+ enumerable: !0,
1078
+ configurable: !0,
1079
+ writable: !0
1080
+ }) : e[r] = t, e;
1081
+ }
1082
+
1083
+ //#endregion
1084
+ //#region src/controllers/drawing-update.controller.ts
1085
+ let DrawingUpdateController = class DrawingUpdateController extends _univerjs_core.Disposable {
1086
+ constructor(_currentUniverService, _commandService, _renderManagerService, _drawingManagerService) {
1087
+ super();
1088
+ this._currentUniverService = _currentUniverService;
1089
+ this._commandService = _commandService;
1090
+ this._renderManagerService = _renderManagerService;
1091
+ this._drawingManagerService = _drawingManagerService;
1092
+ _defineProperty(this, "_sceneListenerOnDrawingMap", /* @__PURE__ */ new WeakSet());
1093
+ this._initialize();
1094
+ }
1095
+ dispose() {
1096
+ super.dispose();
1097
+ }
1098
+ _initialize() {
1099
+ this._recoveryImages();
1100
+ this._drawingAddListener();
1101
+ this._drawingRemoveListener();
1102
+ this._drawingUpdateListener();
1103
+ this._commandExecutedListener();
1104
+ this._drawingArrangeListener();
1105
+ this._drawingGroupListener();
1106
+ this._drawingRefreshListener();
1107
+ this._drawingVisibleListener();
1108
+ }
1109
+ _recoveryImages() {
1110
+ const drawingList = this._drawingManagerService.drawingManagerData;
1111
+ const info = getCurrentUnitInfo(this._currentUniverService);
1112
+ if (info == null) return;
1113
+ const { unitId: currentUnitId, subUnitId: currentSubUnitId } = info;
1114
+ Object.keys(drawingList).forEach((unitId) => {
1115
+ Object.keys(drawingList[unitId]).forEach((subUnitId) => {
1116
+ const drawingMap = drawingList[unitId][subUnitId].data;
1117
+ if (drawingMap == null || unitId !== currentUnitId || subUnitId !== currentSubUnitId) return;
1118
+ Object.keys(drawingMap).forEach((drawingId) => {
1119
+ if (drawingMap[drawingId]) this._insertDrawing([{
1120
+ unitId,
1121
+ subUnitId,
1122
+ drawingId
1123
+ }]);
1124
+ });
1125
+ });
1126
+ });
1127
+ }
1128
+ _commandExecutedListener() {
1129
+ this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
1130
+ if (command.id === SetDrawingAlignOperation.id) {
1131
+ const params = command.params;
1132
+ if (params == null) return;
1133
+ this._drawingAlign(params);
1134
+ }
1135
+ }));
1136
+ }
1137
+ _drawingGroupListener() {
1138
+ this.disposeWithMe(this._drawingManagerService.group$.subscribe((params) => {
1139
+ this._groupDrawings(params);
1140
+ }));
1141
+ this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe((params) => {
1142
+ this._ungroupDrawings(params);
1143
+ }));
1144
+ }
1145
+ _getSceneAndTransformerByDrawingSearch(unitId) {
1146
+ if (unitId == null) return;
1147
+ const renderObject = this._renderManagerService.getRenderById(unitId);
1148
+ const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1149
+ if (scene == null) return null;
1150
+ return {
1151
+ scene,
1152
+ transformer: scene.getTransformerByCreate()
1153
+ };
1154
+ }
1155
+ _groupDrawings(drawings) {
1156
+ drawings.forEach((drawing) => {
1157
+ this._groupDrawing(drawing);
1158
+ });
1159
+ }
1160
+ _groupDrawing(params) {
1161
+ const { parent, children } = params;
1162
+ const { unitId, subUnitId, drawingId } = parent;
1163
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(parent.unitId);
1164
+ if (renderObject == null) return;
1165
+ const { scene, transformer } = renderObject;
1166
+ this._commandService.syncExecuteCommand(CloseImageCropOperation.id);
1167
+ const objects = [];
1168
+ children.forEach((drawing) => {
1169
+ const drawingShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)(drawing);
1170
+ const object = scene.getObjectIncludeInGroup(drawingShapeKey);
1171
+ if (object == null || objects.includes(object)) return;
1172
+ objects.push(object);
1173
+ const { transform } = drawing;
1174
+ if (transform == null) return;
1175
+ if (object.classType === _univerjs_engine_render.RENDER_CLASS_TYPE.GROUP) object.transformByState({
1176
+ left: transform.left,
1177
+ top: transform.top
1178
+ });
1179
+ else object.transformByState(transform);
1180
+ });
1181
+ if (objects.length === 0) return;
1182
+ const group = new _univerjs_engine_render.DrawingGroupObject((0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
1183
+ unitId,
1184
+ subUnitId,
1185
+ drawingId
1186
+ }));
1187
+ scene.addObject(group, _univerjs_engine_render.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(group);
1188
+ group.addObjects(...objects);
1189
+ if (parent.groupBaseBound) group.setBaseBound(parent.groupBaseBound);
1190
+ if (parent.groupId) {
1191
+ group.isInGroup = true;
1192
+ insertGroupObject({
1193
+ drawingId: parent.groupId,
1194
+ unitId,
1195
+ subUnitId
1196
+ }, group, scene, this._drawingManagerService);
1197
+ }
1198
+ parent.transform && group.transformByState({
1199
+ left: parent.transform.left,
1200
+ top: parent.transform.top,
1201
+ width: parent.transform.width,
1202
+ height: parent.transform.height,
1203
+ angle: parent.transform.angle
1204
+ });
1205
+ transformer.clearSelectedObjects();
1206
+ transformer.setSelectedControl(group);
1207
+ }
1208
+ _ungroupDrawings(drawings) {
1209
+ drawings.forEach((drawing) => {
1210
+ this._ungroupDrawing(drawing);
1211
+ });
1212
+ }
1213
+ _ungroupDrawing(drawing) {
1214
+ const { parent, children } = drawing;
1215
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(parent.unitId);
1216
+ if (renderObject == null) return;
1217
+ const { scene, transformer } = renderObject;
1218
+ children.forEach((drawing) => {
1219
+ const drawingKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)(drawing);
1220
+ const object = scene.getObjectIncludeInGroup(drawingKey);
1221
+ if (object == null) return true;
1222
+ if (object == null) return;
1223
+ const { transform } = drawing;
1224
+ if (transform == null) return;
1225
+ if (object.classType === _univerjs_engine_render.RENDER_CLASS_TYPE.GROUP) object.transformByState({
1226
+ left: transform.left,
1227
+ top: transform.top
1228
+ });
1229
+ else object.transformByState(transform);
1230
+ });
1231
+ const groupKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)(parent);
1232
+ const group = scene.getObject(groupKey);
1233
+ const { width, height } = group;
1234
+ group.getObjects().forEach((object) => {
1235
+ group.removeSelfObjectAndTransform(object.oKey, width, height);
1236
+ });
1237
+ group.dispose();
1238
+ transformer.clearSelectedObjects();
1239
+ }
1240
+ _drawingAlign(params) {
1241
+ const { alignType } = params;
1242
+ const drawings = params.drawings || this._drawingManagerService.getFocusDrawings();
1243
+ if (alignType === "0") return;
1244
+ const drawingTransformCaches = [];
1245
+ let minLeft = Number.POSITIVE_INFINITY;
1246
+ let minTop = Number.POSITIVE_INFINITY;
1247
+ let maxRight = Number.NEGATIVE_INFINITY;
1248
+ let maxBottom = Number.NEGATIVE_INFINITY;
1249
+ let drawingCount = 0;
1250
+ drawings.forEach((drawing) => {
1251
+ const { unitId, subUnitId, drawingId, drawingType } = drawing;
1252
+ const drawingParam = this._drawingManagerService.getDrawingByParam({
1253
+ unitId,
1254
+ subUnitId,
1255
+ drawingId
1256
+ });
1257
+ if (drawingParam == null || drawingParam.transform == null) return;
1258
+ drawingTransformCaches.push({
1259
+ unitId,
1260
+ subUnitId,
1261
+ drawingId,
1262
+ drawingType,
1263
+ transform: drawingParam.transform
1264
+ });
1265
+ const { left = 0, top = 0, width = 0, height = 0 } = drawingParam.transform;
1266
+ minLeft = Math.min(minLeft, left);
1267
+ minTop = Math.min(minTop, top);
1268
+ maxRight = Math.max(maxRight, left + width);
1269
+ maxBottom = Math.max(maxBottom, top + height);
1270
+ drawingCount++;
1271
+ });
1272
+ if (drawingCount === 0) return;
1273
+ this._sortDrawingTransform(drawingTransformCaches, alignType);
1274
+ this._applyAlignType(drawingTransformCaches, alignType, minLeft, minTop, maxRight, maxBottom, drawingCount);
1275
+ }
1276
+ _applyAlignType(drawingTransformCaches, alignType, minLeft, minTop, maxRight, maxBottom, drawingCount) {
1277
+ const averageHorizon = Math.round((maxRight - minLeft) / drawingCount * 10) / 10;
1278
+ const averageVertical = Math.round((maxBottom - minTop) / drawingCount * 10) / 10;
1279
+ const updateParams = [];
1280
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(drawingTransformCaches[0].unitId);
1281
+ if (renderObject == null) return;
1282
+ const { scene, transformer } = renderObject;
1283
+ drawingTransformCaches.forEach((drawingTransformCache, index) => {
1284
+ const { unitId, subUnitId, drawingId, transform, drawingType } = drawingTransformCache;
1285
+ const { left = 0, top = 0, width = 0, height = 0 } = transform;
1286
+ let newLeft = left;
1287
+ let newTop = top;
1288
+ switch (alignType) {
1289
+ case "1":
1290
+ newLeft = minLeft;
1291
+ break;
1292
+ case "2":
1293
+ newLeft = minLeft + (maxRight - minLeft) / 2 - width / 2;
1294
+ break;
1295
+ case "3":
1296
+ newLeft = maxRight - width;
1297
+ break;
1298
+ case "4":
1299
+ newTop = minTop;
1300
+ break;
1301
+ case "5":
1302
+ newTop = minTop + (maxBottom - minTop) / 2 - height / 2;
1303
+ break;
1304
+ case "6":
1305
+ newTop = maxBottom - height;
1306
+ break;
1307
+ case "7":
1308
+ newLeft = minLeft + averageHorizon * index;
1309
+ break;
1310
+ case "8":
1311
+ newTop = minTop + averageVertical * index;
1312
+ break;
1313
+ default: break;
1314
+ }
1315
+ if (newLeft !== left || newTop !== top) updateParams.push({
1316
+ unitId,
1317
+ subUnitId,
1318
+ drawingId,
1319
+ drawingType,
1320
+ transform: {
1321
+ left: newLeft,
1322
+ top: newTop
1323
+ }
1324
+ });
1325
+ });
1326
+ this._drawingManagerService.featurePluginUpdateNotification(updateParams);
1327
+ transformer.refreshControls().changeNotification();
1328
+ }
1329
+ _sortDrawingTransform(drawingTransformCaches, alignType) {
1330
+ drawingTransformCaches.sort((a, b) => {
1331
+ const aTransform = a.transform;
1332
+ const bTransform = b.transform;
1333
+ const { left: aLeft = 0, top: aTop = 0, width: aWidth = 0, height: aHeight = 0 } = aTransform;
1334
+ const { left: bLeft = 0, top: bTop = 0, width: bWidth = 0, height: bHeight = 0 } = bTransform;
1335
+ switch (alignType) {
1336
+ case "1": return aLeft - bLeft;
1337
+ case "2": return aLeft + aWidth / 2 - (bLeft + bWidth / 2);
1338
+ case "3": return aLeft + aWidth - (bLeft + bWidth);
1339
+ case "4": return aTop - bTop;
1340
+ case "5": return aTop + aHeight / 2 - (bTop + bHeight / 2);
1341
+ case "6": return aTop + aHeight - (bTop + bHeight);
1342
+ case "7": return aLeft + aWidth / 2 - (bLeft + bWidth / 2);
1343
+ case "8": return aTop + aHeight / 2 - (bTop + bHeight / 2);
1344
+ default: return 0;
1345
+ }
1346
+ });
1347
+ }
1348
+ _drawingArrangeListener() {
1349
+ this.disposeWithMe(this._drawingManagerService.order$.subscribe((params) => {
1350
+ this._drawingArrange(params);
1351
+ }));
1352
+ }
1353
+ _drawingArrange(params) {
1354
+ const { unitId, subUnitId, drawingIds } = params;
1355
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1356
+ if (renderObject == null) return;
1357
+ const { scene } = renderObject;
1358
+ drawingIds.forEach((drawingId) => {
1359
+ const oKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
1360
+ unitId,
1361
+ subUnitId,
1362
+ drawingId
1363
+ });
1364
+ const drawingShapes = scene.fuzzyMathObjects(oKey, true);
1365
+ if (drawingShapes == null || drawingShapes.length === 0) return;
1366
+ const index = this._drawingManagerService.getDrawingOrder(unitId, subUnitId).indexOf(drawingId);
1367
+ for (const shape of drawingShapes) {
1368
+ shape.setProps({ zIndex: index });
1369
+ shape.makeDirty();
1370
+ }
1371
+ });
1372
+ }
1373
+ _drawingAddListener() {
1374
+ this.disposeWithMe(this._drawingManagerService.add$.subscribe((params) => {
1375
+ this._insertDrawing(params);
1376
+ }));
1377
+ }
1378
+ _insertDrawing(params) {
1379
+ const sceneList = [];
1380
+ params.forEach((param) => {
1381
+ const { unitId } = param;
1382
+ if (this._drawingManagerService.getDrawingByParam(param) == null) return;
1383
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1384
+ if (renderObject == null) return;
1385
+ const { scene } = renderObject;
1386
+ if (!sceneList.includes(scene)) sceneList.push(scene);
1387
+ });
1388
+ sceneList.forEach((scene) => {
1389
+ if (this._sceneListenerOnDrawingMap.has(scene)) return;
1390
+ this._addListenerOnDrawing(scene);
1391
+ this._sceneListenerOnDrawingMap.add(scene);
1392
+ });
1393
+ }
1394
+ _drawingRemoveListener() {
1395
+ this.disposeWithMe(this._drawingManagerService.remove$.subscribe((params) => {
1396
+ params.forEach((param) => {
1397
+ const { unitId, subUnitId, drawingId } = param;
1398
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1399
+ if (renderObject == null) return;
1400
+ const { scene } = renderObject;
1401
+ const drawingShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
1402
+ unitId,
1403
+ subUnitId,
1404
+ drawingId
1405
+ });
1406
+ const drawingShapes = scene.fuzzyMathObjects(drawingShapeKey, true);
1407
+ if (drawingShapes.length > 0) {
1408
+ var _scene$getTransformer;
1409
+ for (const drawingShape of drawingShapes) drawingShape.dispose();
1410
+ (_scene$getTransformer = scene.getTransformer()) === null || _scene$getTransformer === void 0 || _scene$getTransformer.clearSelectedObjects();
1411
+ }
1412
+ });
1413
+ }));
1414
+ }
1415
+ _drawingUpdateListener() {
1416
+ this.disposeWithMe(this._drawingManagerService.update$.subscribe((params) => {
1417
+ params.forEach((param) => {
1418
+ var _scene$getTransformer2;
1419
+ const { unitId, subUnitId, drawingId } = param;
1420
+ const drawingParam = this._drawingManagerService.getDrawingByParam(param);
1421
+ if (drawingParam == null) return;
1422
+ const { transform, drawingType } = drawingParam;
1423
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1424
+ if (renderObject == null) return;
1425
+ const { scene, transformer } = renderObject;
1426
+ if (transform == null) return true;
1427
+ const { left = 0, top = 0, width = 0, height = 0, angle = 0, flipX = false, flipY = false, skewX = 0, skewY = 0 } = transform;
1428
+ const drawingShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
1429
+ unitId,
1430
+ subUnitId,
1431
+ drawingId
1432
+ });
1433
+ const drawingShape = scene.getObject(drawingShapeKey);
1434
+ if (drawingShape == null) return true;
1435
+ drawingShape.transformByState({
1436
+ left,
1437
+ top,
1438
+ width,
1439
+ height,
1440
+ angle,
1441
+ flipX,
1442
+ flipY,
1443
+ skewX,
1444
+ skewY
1445
+ });
1446
+ (_scene$getTransformer2 = scene.getTransformer()) === null || _scene$getTransformer2 === void 0 || _scene$getTransformer2.debounceRefreshControls();
1447
+ });
1448
+ }));
1449
+ }
1450
+ _drawingRefreshListener() {
1451
+ this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe((params) => {
1452
+ params.forEach((param) => {
1453
+ const { unitId, subUnitId, drawingId } = param;
1454
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1455
+ if (renderObject == null) return;
1456
+ const drawingParam = this._drawingManagerService.getDrawingByParam(param);
1457
+ if (drawingParam == null) return;
1458
+ const { transform } = drawingParam;
1459
+ const { scene } = renderObject;
1460
+ const drawingShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
1461
+ unitId,
1462
+ subUnitId,
1463
+ drawingId
1464
+ });
1465
+ const drawingShape = scene.getObject(drawingShapeKey);
1466
+ if (drawingShape == null || transform == null) return true;
1467
+ const { left = 0, top = 0, width = 0, height = 0, angle = 0, flipX = false, flipY = false, skewX = 0, skewY = 0 } = transform;
1468
+ drawingShape.transformByState({
1469
+ left,
1470
+ top,
1471
+ width,
1472
+ height,
1473
+ angle,
1474
+ flipX,
1475
+ flipY,
1476
+ skewX,
1477
+ skewY
1478
+ });
1479
+ });
1480
+ }));
1481
+ }
1482
+ _drawingVisibleListener() {
1483
+ this.disposeWithMe(this._drawingManagerService.visible$.subscribe((params) => {
1484
+ params.forEach((param) => {
1485
+ const { unitId, subUnitId, drawingId, visible } = param;
1486
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1487
+ if (renderObject == null) return;
1488
+ const { scene } = renderObject;
1489
+ const drawingShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
1490
+ unitId,
1491
+ subUnitId,
1492
+ drawingId
1493
+ });
1494
+ const drawingShape = scene.getObject(drawingShapeKey);
1495
+ if (drawingShape == null) return true;
1496
+ if (visible) drawingShape.show();
1497
+ else drawingShape.hide();
1498
+ });
1499
+ }));
1500
+ }
1501
+ _filterUpdateParams(params, startTransforms) {
1502
+ return params.filter((param, index) => {
1503
+ if (param == null) return false;
1504
+ const { transform } = param;
1505
+ return (0, _univerjs_core.checkIfMove)(transform, startTransforms === null || startTransforms === void 0 ? void 0 : startTransforms[index]);
1506
+ });
1507
+ }
1508
+ _addListenerOnDrawing(scene) {
1509
+ const transformer = scene.getTransformerByCreate();
1510
+ let startTransforms = null;
1511
+ this.disposeWithMe((0, _univerjs_core.toDisposable)(transformer.changeStart$.subscribe((state) => {
1512
+ const { objects } = state;
1513
+ const objectArray = Array.from(objects.values());
1514
+ const drawings = [];
1515
+ startTransforms = objectArray.map((object) => {
1516
+ const { left, top, height, width, angle, oKey, isInGroup } = object;
1517
+ const drawing = this._drawingManagerService.getDrawingOKey(oKey);
1518
+ if (isInGroup || object instanceof _univerjs_engine_render.Group) {
1519
+ let group = object.ancestorGroup;
1520
+ if (group == null && object instanceof _univerjs_engine_render.Group) group = object;
1521
+ if (group == null) return null;
1522
+ const groupDrawing = this._drawingManagerService.getDrawingOKey(group.oKey);
1523
+ if (groupDrawing) {
1524
+ const { unitId, subUnitId, drawingId } = groupDrawing;
1525
+ drawings.push({
1526
+ unitId,
1527
+ subUnitId,
1528
+ drawingId
1529
+ });
1530
+ const { left, top, height, width, angle } = group;
1531
+ return {
1532
+ left,
1533
+ top,
1534
+ height,
1535
+ width,
1536
+ angle
1537
+ };
1538
+ }
1539
+ } else if (drawing != null) {
1540
+ const { unitId, subUnitId, drawingId } = drawing;
1541
+ drawings.push({
1542
+ unitId,
1543
+ subUnitId,
1544
+ drawingId
1545
+ });
1546
+ return {
1547
+ left,
1548
+ top,
1549
+ height,
1550
+ width,
1551
+ angle
1552
+ };
1553
+ }
1554
+ return null;
1555
+ }).filter((transform) => transform != null);
1556
+ if (drawings.length > 0) this._commandService.syncExecuteCommand(_univerjs_drawing.SetDrawingSelectedOperation.id, drawings);
1557
+ else this._commandService.syncExecuteCommand(_univerjs_drawing.SetDrawingSelectedOperation.id, []);
1558
+ })));
1559
+ this.disposeWithMe((0, _univerjs_core.toDisposable)(transformer.changeEnd$.subscribe((state) => {
1560
+ const { objects } = state;
1561
+ const params = this._filterUpdateParams(getUpdateParams(objects, this._drawingManagerService), startTransforms);
1562
+ if (params.length > 0) this._drawingManagerService.featurePluginUpdateNotification(params);
1563
+ })));
1564
+ }
1565
+ };
1566
+ DrawingUpdateController = __decorate([
1567
+ __decorateParam(0, _univerjs_core.IUniverInstanceService),
1568
+ __decorateParam(1, _univerjs_core.ICommandService),
1569
+ __decorateParam(2, _univerjs_engine_render.IRenderManagerService),
1570
+ __decorateParam(3, _univerjs_drawing.IDrawingManagerService)
1571
+ ], DrawingUpdateController);
1572
+
1573
+ //#endregion
1574
+ //#region src/views/crop/image-cropper-object.ts
1575
+ var ImageCropperObject = class extends _univerjs_engine_render.Shape {
1576
+ constructor(key, props) {
1577
+ if (props == null) props = {};
1578
+ props.transformerConfig = {
1579
+ keepRatio: false,
1580
+ isCropper: true,
1581
+ anchorFill: "rgb(0, 0, 0)",
1582
+ anchorStroke: "rgb(255, 255, 255)",
1583
+ anchorSize: 24
1584
+ };
1585
+ super(key, props);
1586
+ _defineProperty(this, "_srcRect", void 0);
1587
+ _defineProperty(this, "_prstGeom", void 0);
1588
+ _defineProperty(this, "_applyTransform", void 0);
1589
+ _defineProperty(this, "_dragPadding", 8);
1590
+ _defineProperty(this, "_cacheCanvas", void 0);
1591
+ if (props === null || props === void 0 ? void 0 : props.srcRect) this._srcRect = props.srcRect;
1592
+ if (props === null || props === void 0 ? void 0 : props.prstGeom) this._prstGeom = props.prstGeom;
1593
+ if (props === null || props === void 0 ? void 0 : props.applyTransform) this._applyTransform = props.applyTransform;
1594
+ if (props === null || props === void 0 ? void 0 : props.dragPadding) this._dragPadding = props.dragPadding;
1595
+ this._applyProps();
1596
+ }
1597
+ refreshSrcRect(value, transform) {
1598
+ this._srcRect = value;
1599
+ this._applyTransform = transform;
1600
+ this._applyProps();
1601
+ }
1602
+ get srcRect() {
1603
+ return this._srcRect;
1604
+ }
1605
+ dispose() {
1606
+ var _this$_cacheCanvas;
1607
+ super.dispose();
1608
+ (_this$_cacheCanvas = this._cacheCanvas) === null || _this$_cacheCanvas === void 0 || _this$_cacheCanvas.dispose();
1609
+ this._srcRect = null;
1610
+ }
1611
+ isHit(coord) {
1612
+ const oCoord = this.getInverseCoord(coord);
1613
+ if (oCoord.x >= -this.strokeWidth / 2 && oCoord.x <= this.width + this.strokeWidth / 2 && oCoord.y >= -this.strokeWidth / 2 && oCoord.y <= this.height + this.strokeWidth / 2 && !this._inSurround(oCoord)) return true;
1614
+ return false;
1615
+ }
1616
+ _inSurround(oCoord) {
1617
+ const padding = this._dragPadding;
1618
+ if (oCoord.x >= padding - this.strokeWidth / 2 && oCoord.x <= this.width + this.strokeWidth / 2 - padding && oCoord.y >= padding - this.strokeWidth / 2 && oCoord.y <= this.height + this.strokeWidth / 2 - padding) return true;
1619
+ return false;
1620
+ }
1621
+ render(mainCtx, bounds) {
1622
+ if (!this.visible) {
1623
+ this.makeDirty(false);
1624
+ return this;
1625
+ }
1626
+ mainCtx.save();
1627
+ this._draw(mainCtx);
1628
+ mainCtx.restore();
1629
+ this.makeDirty(false);
1630
+ return this;
1631
+ }
1632
+ _draw(ctx) {
1633
+ var _this$_cacheCanvas2, _this$_cacheCanvas3;
1634
+ const { width: engineWidth, height: engineHeight } = this.getScene().getEngine();
1635
+ this._initialCacheCanvas();
1636
+ (_this$_cacheCanvas2 = this._cacheCanvas) === null || _this$_cacheCanvas2 === void 0 || _this$_cacheCanvas2.clear();
1637
+ const cacheCtx = (_this$_cacheCanvas3 = this._cacheCanvas) === null || _this$_cacheCanvas3 === void 0 ? void 0 : _this$_cacheCanvas3.getContext();
1638
+ if (cacheCtx == null) return;
1639
+ cacheCtx.save();
1640
+ _univerjs_engine_render.Rect.drawWith(cacheCtx, {
1641
+ left: 0,
1642
+ top: 0,
1643
+ width: engineWidth,
1644
+ height: engineHeight,
1645
+ fill: "rgba(0, 0, 0, 0.5)"
1646
+ });
1647
+ cacheCtx.setTransform(ctx.getTransform());
1648
+ this._clipForApplyObject(cacheCtx);
1649
+ this._applyCache(ctx);
1650
+ cacheCtx.restore();
1651
+ }
1652
+ _clipForApplyObject(cacheCtx) {
1653
+ let objectType = 0;
1654
+ if (this._prstGeom != null) objectType = 1;
1655
+ cacheCtx.globalCompositeOperation = "destination-out";
1656
+ cacheCtx.beginPath();
1657
+ if (objectType === 0) {
1658
+ const m = this.transform.getMatrix();
1659
+ cacheCtx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
1660
+ cacheCtx.rect(0, 0, this.width, this.height);
1661
+ cacheCtx.fill();
1662
+ }
1663
+ }
1664
+ _applyProps() {
1665
+ if (this._applyTransform == null) return;
1666
+ let cropLeft = 0;
1667
+ let cropTop = 0;
1668
+ let cropRight = 0;
1669
+ let cropBottom = 0;
1670
+ const { left: applyLeft = 0, top: applyTop = 0, width: applyWidth = 0, height: applyHeight = 0, angle } = this._applyTransform;
1671
+ if (this._srcRect != null) {
1672
+ const { left = 0, top = 0, right = 0, bottom = 0 } = this._srcRect;
1673
+ cropLeft = left;
1674
+ cropTop = top;
1675
+ cropRight = right;
1676
+ cropBottom = bottom;
1677
+ }
1678
+ const left = applyLeft + cropLeft;
1679
+ const top = applyTop + cropTop;
1680
+ this.transformByState({
1681
+ left,
1682
+ top,
1683
+ width: applyLeft + applyWidth - cropRight - left,
1684
+ height: applyTop + applyHeight - cropBottom - top,
1685
+ angle
1686
+ });
1687
+ }
1688
+ _applyCache(ctx) {
1689
+ if (!ctx || this._cacheCanvas == null) return;
1690
+ const cacheCtx = this._cacheCanvas.getContext();
1691
+ cacheCtx.save();
1692
+ ctx.save();
1693
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
1694
+ cacheCtx.setTransform(1, 0, 0, 1, 0, 0);
1695
+ ctx.drawImage(this._cacheCanvas.getCanvasEle(), 0, 0);
1696
+ ctx.restore();
1697
+ cacheCtx.restore();
1698
+ }
1699
+ _initialCacheCanvas() {
1700
+ if (this._cacheCanvas != null) return;
1701
+ const scene = this.getScene();
1702
+ if (scene == null) return;
1703
+ this._cacheCanvas = new _univerjs_engine_render.Canvas();
1704
+ const engine = scene.getEngine();
1705
+ this._cacheCanvas.setSize(engine.width, engine.height);
1706
+ engine.onTransformChange$.subscribeEvent(() => {
1707
+ var _this$_cacheCanvas4;
1708
+ (_this$_cacheCanvas4 = this._cacheCanvas) === null || _this$_cacheCanvas4 === void 0 || _this$_cacheCanvas4.setSize(engine.width, engine.height);
1709
+ this.makeDirty(true);
1710
+ });
1711
+ }
1712
+ };
1713
+
1714
+ //#endregion
1715
+ //#region src/controllers/image-cropper.controller.ts
1716
+ let ImageCropperController = class ImageCropperController extends _univerjs_core.Disposable {
1717
+ constructor(_commandService, _drawingManagerService, _renderManagerService, _univerInstanceService, _messageService, _localeService) {
1718
+ super();
1719
+ this._commandService = _commandService;
1720
+ this._drawingManagerService = _drawingManagerService;
1721
+ this._renderManagerService = _renderManagerService;
1722
+ this._univerInstanceService = _univerInstanceService;
1723
+ this._messageService = _messageService;
1724
+ this._localeService = _localeService;
1725
+ _defineProperty(this, "_sceneListenerOnImageMap", /* @__PURE__ */ new WeakSet());
1726
+ this._init();
1727
+ }
1728
+ _init() {
1729
+ this._initOpenCrop();
1730
+ this._initCloseCrop();
1731
+ this._initAutoCrop();
1732
+ }
1733
+ _initAutoCrop() {
1734
+ this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
1735
+ if (command.id !== AutoImageCropOperation.id) return;
1736
+ const params = command.params;
1737
+ if (params == null) return;
1738
+ const { cropType } = params;
1739
+ const drawingParams = this._drawingManagerService.getFocusDrawings();
1740
+ if (drawingParams.length !== 1) return;
1741
+ const { unitId, subUnitId, drawingId } = drawingParams[0];
1742
+ const renderObject = this._renderManagerService.getRenderById(unitId);
1743
+ const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1744
+ if (scene == null) return true;
1745
+ if (this._searchCropObject(scene) != null) this._commandService.syncExecuteCommand(CloseImageCropOperation.id, { isAuto: true });
1746
+ const imageShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
1747
+ unitId,
1748
+ subUnitId,
1749
+ drawingId
1750
+ });
1751
+ const imageShape = scene.getObject(imageShapeKey);
1752
+ if (!(imageShape instanceof _univerjs_engine_render.Image)) {
1753
+ this._messageService.show({
1754
+ type: _univerjs_design.MessageType.Error,
1755
+ content: this._localeService.t("drawing-ui.image-cropper.error")
1756
+ });
1757
+ return;
1758
+ }
1759
+ if (imageShape == null) return;
1760
+ this._updateCropperObject(cropType, imageShape);
1761
+ this._commandService.executeCommand(OpenImageCropOperation.id, {
1762
+ unitId,
1763
+ subUnitId,
1764
+ drawingId
1765
+ });
1766
+ }));
1767
+ }
1768
+ _calculateSrcRectByRatio(left, top, width, height, numerator, denominator) {
1769
+ const srcRatio = width / height;
1770
+ const ratio = numerator / denominator;
1771
+ let newWidth = width;
1772
+ let newHeight = height;
1773
+ if (srcRatio > ratio) newWidth = height * ratio;
1774
+ else newHeight = width / ratio;
1775
+ const newLeft = (width - newWidth) / 2;
1776
+ const newTop = (height - newHeight) / 2;
1777
+ return {
1778
+ left: (0, _univerjs_engine_render.precisionTo)(newLeft, 1),
1779
+ top: (0, _univerjs_engine_render.precisionTo)(newTop, 1),
1780
+ right: (0, _univerjs_engine_render.precisionTo)(width - (newLeft + newWidth), 1),
1781
+ bottom: (0, _univerjs_engine_render.precisionTo)(height - (newTop + newHeight), 1)
1782
+ };
1783
+ }
1784
+ _updateCropperObject(cropType, imageShape) {
1785
+ const { left, top, width, height } = imageShape.calculateTransformWithSrcRect();
1786
+ let newSrcRect;
1787
+ switch (cropType) {
1788
+ case "1":
1789
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 1, 1);
1790
+ break;
1791
+ case "2":
1792
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 16, 9);
1793
+ break;
1794
+ case "3":
1795
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 9, 16);
1796
+ break;
1797
+ case "4":
1798
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 5, 4);
1799
+ break;
1800
+ case "5":
1801
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 4, 5);
1802
+ break;
1803
+ case "6":
1804
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 4, 3);
1805
+ break;
1806
+ case "7":
1807
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 3, 4);
1808
+ break;
1809
+ case "8":
1810
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 3, 2);
1811
+ break;
1812
+ case "9":
1813
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 2, 3);
1814
+ break;
1815
+ case "0":
1816
+ default: break;
1817
+ }
1818
+ if (newSrcRect == null) return;
1819
+ imageShape.setSrcRect(newSrcRect);
1820
+ const { left: newLeft = 0, top: newTop = 0, bottom: newBottom = 0, right: newRight = 0 } = newSrcRect;
1821
+ imageShape.transformByStateCloseCropper({
1822
+ left: left + newLeft,
1823
+ top: top + newTop,
1824
+ width: width - newRight - newLeft,
1825
+ height: height - newBottom - newTop
1826
+ });
1827
+ }
1828
+ _initOpenCrop() {
1829
+ this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
1830
+ if (command.id !== OpenImageCropOperation.id) return;
1831
+ const params = command.params;
1832
+ if (params == null) return;
1833
+ const { unitId, subUnitId, drawingId } = params;
1834
+ const renderObject = this._renderManagerService.getRenderById(unitId);
1835
+ const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1836
+ if (scene == null) return true;
1837
+ if (!this._sceneListenerOnImageMap.has(scene)) {
1838
+ this._addListenerOnImage(scene);
1839
+ this._sceneListenerOnImageMap.add(scene);
1840
+ }
1841
+ if (this._drawingManagerService.getDrawingByParam({
1842
+ unitId,
1843
+ subUnitId,
1844
+ drawingId
1845
+ }) == null) return;
1846
+ const imageShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
1847
+ unitId,
1848
+ subUnitId,
1849
+ drawingId
1850
+ });
1851
+ const imageShape = scene.getObject(imageShapeKey);
1852
+ if (imageShape == null) return;
1853
+ if (!(imageShape instanceof _univerjs_engine_render.Image)) {
1854
+ this._messageService.show({
1855
+ type: _univerjs_design.MessageType.Error,
1856
+ content: this._localeService.t("drawing-ui.image-cropper.error")
1857
+ });
1858
+ return;
1859
+ }
1860
+ const transformer = scene.getTransformer();
1861
+ transformer === null || transformer === void 0 || transformer.clearControls();
1862
+ const imageCropperObject = new ImageCropperObject(`${imageShapeKey}-crop`, {
1863
+ srcRect: imageShape.srcRect,
1864
+ prstGeom: imageShape.prstGeom,
1865
+ applyTransform: imageShape.calculateTransformWithSrcRect()
1866
+ });
1867
+ scene.addObject(imageCropperObject, imageShape.getLayerIndex() + 1).attachTransformerTo(imageCropperObject);
1868
+ transformer === null || transformer === void 0 || transformer.createControlForCopper(imageCropperObject);
1869
+ this._addHoverForImageCopper(imageCropperObject);
1870
+ imageShape.openRenderByCropper();
1871
+ transformer === null || transformer === void 0 || transformer.refreshControls();
1872
+ imageCropperObject.makeDirty(true);
1873
+ this._commandService.syncExecuteCommand(_univerjs_drawing.SetDrawingSelectedOperation.id, [{
1874
+ unitId,
1875
+ subUnitId,
1876
+ drawingId
1877
+ }]);
1878
+ }));
1879
+ }
1880
+ _searchCropObject(scene) {
1881
+ const objects = scene.getAllObjectsByOrder();
1882
+ for (const object of objects) if (object instanceof ImageCropperObject) return object;
1883
+ }
1884
+ _initCloseCrop() {
1885
+ this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
1886
+ if (command.id !== CloseImageCropOperation.id) return;
1887
+ const currentUnit = this._univerInstanceService.getFocusedUnit();
1888
+ if (currentUnit == null) return;
1889
+ const unitId = currentUnit.getUnitId();
1890
+ const renderObject = this._renderManagerService.getRenderById(unitId);
1891
+ const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1892
+ if (scene == null) return true;
1893
+ const imageCropperObject = this._searchCropObject(scene);
1894
+ if (imageCropperObject == null) return;
1895
+ const imageShape = this._getApplyObjectByCropObject(imageCropperObject);
1896
+ if (imageShape == null) return;
1897
+ const transformer = scene.getTransformerByCreate();
1898
+ transformer.detachFrom(imageCropperObject);
1899
+ transformer.clearCopperControl();
1900
+ const srcRect = this._getSrcRectByTransformState(imageShape, imageCropperObject);
1901
+ const drawingParam = this._drawingManagerService.getDrawingOKey(imageShape.oKey);
1902
+ if (drawingParam != null) {
1903
+ const { left, top, height, width } = imageCropperObject;
1904
+ this._drawingManagerService.featurePluginUpdateNotification([{
1905
+ ...drawingParam,
1906
+ transform: {
1907
+ ...drawingParam.transform,
1908
+ left,
1909
+ top,
1910
+ height,
1911
+ width
1912
+ },
1913
+ srcRect: srcRect.srcRectAngle
1914
+ }]);
1915
+ }
1916
+ imageShape.setSrcRect({ ...srcRect.srcRectAngle });
1917
+ imageShape.closeRenderByCropper();
1918
+ imageShape.makeDirty(true);
1919
+ imageCropperObject === null || imageCropperObject === void 0 || imageCropperObject.dispose();
1920
+ }));
1921
+ const sheetUnit$ = this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => workbook ? workbook.activeSheet$ : (0, rxjs.of)(null)));
1922
+ this.disposeWithMe(sheetUnit$.subscribe(() => {
1923
+ this._commandService.syncExecuteCommand(CloseImageCropOperation.id);
1924
+ }));
1925
+ }
1926
+ _getApplyObjectByCropObject(cropObject) {
1927
+ const cropOKey = cropObject.oKey;
1928
+ const applyOKey = cropOKey.slice(0, cropOKey.length - 5);
1929
+ const scene = cropObject.getScene();
1930
+ if (!scene) return null;
1931
+ const applyObject = scene.getObject(applyOKey);
1932
+ if (applyObject == null) return null;
1933
+ return applyObject;
1934
+ }
1935
+ _addListenerOnImage(scene) {
1936
+ const transformer = scene.getTransformerByCreate();
1937
+ let startTransform = null;
1938
+ this.disposeWithMe(transformer.changeStart$.subscribe((state) => {
1939
+ const { objects } = state;
1940
+ const cropObject = objects.values().next().value;
1941
+ if (cropObject == null || !(cropObject instanceof ImageCropperObject)) return;
1942
+ const { left, top, height, width, angle } = cropObject;
1943
+ startTransform = {
1944
+ left,
1945
+ top,
1946
+ height,
1947
+ width,
1948
+ angle
1949
+ };
1950
+ transformer.clearCopperControl();
1951
+ }));
1952
+ this.disposeWithMe(transformer.changeEnd$.subscribe((state) => {
1953
+ const { objects } = state;
1954
+ const cropObject = objects.values().next().value;
1955
+ if (cropObject == null || !(cropObject instanceof ImageCropperObject)) return;
1956
+ const { left, top, height, width, angle } = cropObject;
1957
+ if (!(0, _univerjs_core.checkIfMove)({
1958
+ left,
1959
+ top,
1960
+ height,
1961
+ width,
1962
+ angle
1963
+ }, startTransform)) return;
1964
+ const applyObject = this._getApplyObjectByCropObject(cropObject);
1965
+ if (applyObject == null) return;
1966
+ const srcRect = this._getSrcRectByTransformState(applyObject, cropObject);
1967
+ cropObject.refreshSrcRect(srcRect.srcRect, applyObject.getState());
1968
+ transformer.createControlForCopper(cropObject);
1969
+ }));
1970
+ this._endCropListener(scene);
1971
+ }
1972
+ _addHoverForImageCopper(o) {
1973
+ this.disposeWithMe(o.onPointerEnter$.subscribeEvent(() => {
1974
+ o.cursor = _univerjs_engine_render.CURSOR_TYPE.MOVE;
1975
+ }));
1976
+ this.disposeWithMe(o.onPointerLeave$.subscribeEvent(() => {
1977
+ o.cursor = _univerjs_engine_render.CURSOR_TYPE.DEFAULT;
1978
+ }));
1979
+ }
1980
+ _endCropListener(scene) {
1981
+ const transformer = scene.getTransformerByCreate();
1982
+ this.disposeWithMe(transformer.clearControl$.subscribe((changeSelf) => {
1983
+ if (changeSelf === true) this._commandService.syncExecuteCommand(CloseImageCropOperation.id);
1984
+ }));
1985
+ }
1986
+ _getSrcRectByTransformState(applyObject, imageCropperObject) {
1987
+ const { left, top, height, width, strokeWidth, angle: copperAngle } = imageCropperObject;
1988
+ const { left: applyLeft, top: applyTop, width: applyWidth, height: applyHeight, angle: applyAngle, strokeWidth: applyStrokeWidth } = applyObject;
1989
+ const newLeft = left - applyLeft;
1990
+ const newTop = top - applyTop;
1991
+ const srcRect = {
1992
+ left: newLeft,
1993
+ top: newTop,
1994
+ right: applyWidth - newLeft - width,
1995
+ bottom: applyHeight - newTop - height
1996
+ };
1997
+ const srcRectAngle = { ...srcRect };
1998
+ if (applyAngle !== 0) {
1999
+ const centerPoint = new _univerjs_engine_render.Vector2(left + width / 2, top + height / 2);
2000
+ const newCenterPoint = new _univerjs_engine_render.Vector2(applyWidth / 2 + applyLeft, applyHeight / 2 + applyTop);
2001
+ const vertexPoint = new _univerjs_engine_render.Vector2(applyLeft, applyTop);
2002
+ vertexPoint.rotateByPoint((0, _univerjs_engine_render.degToRad)(applyAngle), newCenterPoint);
2003
+ const applyFinalPoint = vertexPoint.clone();
2004
+ applyFinalPoint.rotateByPoint((0, _univerjs_engine_render.degToRad)(-applyAngle), centerPoint);
2005
+ const newAngleLeft = left - applyFinalPoint.x;
2006
+ const newAngleTop = top - applyFinalPoint.y;
2007
+ srcRectAngle.left = newAngleLeft;
2008
+ srcRectAngle.top = newAngleTop;
2009
+ srcRectAngle.right = applyWidth - newAngleLeft - width;
2010
+ srcRectAngle.bottom = applyHeight - newAngleTop - height;
2011
+ }
2012
+ return {
2013
+ srcRect,
2014
+ srcRectAngle
2015
+ };
2016
+ }
2017
+ };
2018
+ ImageCropperController = __decorate([
2019
+ __decorateParam(0, _univerjs_core.ICommandService),
2020
+ __decorateParam(1, _univerjs_drawing.IDrawingManagerService),
2021
+ __decorateParam(2, _univerjs_engine_render.IRenderManagerService),
2022
+ __decorateParam(3, _univerjs_core.IUniverInstanceService),
2023
+ __decorateParam(4, _univerjs_ui.IMessageService),
2024
+ __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))
2025
+ ], ImageCropperController);
2026
+
2027
+ //#endregion
2028
+ //#region src/services/drawing-image-clip.service.ts
2029
+ const IMAGE_CLIP_SHAPE_PICKER_COMPONENT = "sheet.image-clip.shape.picker.component";
2030
+ /**
2031
+ * Bridge service that enables shape-based image clipping.
2032
+ * This service lives in the open-source drawing-ui package and delegates
2033
+ * to a registered clip implementation (provided by pro engine-shape package).
2034
+ *
2035
+ * When no delegate is registered, applyShapeClip returns false and images render normally without shape clipping.
2036
+ */
2037
+ var DrawingImageClipService = class extends _univerjs_core.Disposable {
2038
+ constructor() {
2039
+ super();
2040
+ _defineProperty(this, "_clipDelegate", null);
2041
+ _defineProperty(this, "_canUseShapeClip$", new rxjs.BehaviorSubject(false));
2042
+ _defineProperty(this, "canUseShapeClip$", this._canUseShapeClip$.asObservable());
2043
+ }
2044
+ setCanUseShapeClip(canUse) {
2045
+ this._canUseShapeClip$.next(canUse);
2046
+ }
2047
+ /**
2048
+ * Register a clip delegate that knows how to build shape clip paths.
2049
+ * Typically called by the pro-side plugin with a ShapeModel-based implementation.
2050
+ * @returns IDisposable to unregister the delegate
2051
+ */
2052
+ registerClipDelegate(delegate) {
2053
+ this._clipDelegate = delegate;
2054
+ return (0, _univerjs_core.toDisposable)(() => {
2055
+ if (this._clipDelegate === delegate) this._clipDelegate = null;
2056
+ });
2057
+ }
2058
+ applyShapeClip(ctx, prstGeom, width, height, adjustValues) {
2059
+ if (this._clipDelegate) return this._clipDelegate(ctx, prstGeom, width, height, adjustValues);
2060
+ return false;
2061
+ }
2062
+ dispose() {
2063
+ this._clipDelegate = null;
2064
+ this._canUseShapeClip$.complete();
2065
+ super.dispose();
2066
+ }
2067
+ };
2068
+
2069
+ //#endregion
2070
+ //#region src/services/drawing-render.service.ts
2071
+ let DrawingRenderService = class DrawingRenderService {
2072
+ constructor(_drawingManagerService, _imageIoService, _galleryService, _urlImageService, _univerInstanceService, _drawingImageClipService) {
2073
+ this._drawingManagerService = _drawingManagerService;
2074
+ this._imageIoService = _imageIoService;
2075
+ this._galleryService = _galleryService;
2076
+ this._urlImageService = _urlImageService;
2077
+ this._univerInstanceService = _univerInstanceService;
2078
+ this._drawingImageClipService = _drawingImageClipService;
2079
+ }
2080
+ async renderImages(imageParam, scene) {
2081
+ const { transform: singleTransform, drawingType, source, imageSourceType, srcRect, prstGeom, groupId, unitId, subUnitId, drawingId, isMultiTransform, transforms: multiTransforms, adjustValues, hidden } = imageParam;
2082
+ if (drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE) return;
2083
+ if (!this._drawingManagerService.getDrawingVisible()) return;
2084
+ if (this._univerInstanceService.getUnitType(unitId) === _univerjs_core.UniverInstanceType.UNIVER_SHEET && subUnitId !== this._getActiveSheetId()) return;
2085
+ if (singleTransform == null) return;
2086
+ const transforms = isMultiTransform && multiTransforms ? multiTransforms : [singleTransform];
2087
+ const images = [];
2088
+ for (const transform of transforms) {
2089
+ const { left, top, width, height, angle, flipX, flipY, skewX, skewY } = transform;
2090
+ const index = transforms.indexOf(transform);
2091
+ const imageShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
2092
+ unitId,
2093
+ subUnitId,
2094
+ drawingId
2095
+ }, isMultiTransform ? index : void 0);
2096
+ const imageShape = scene.getObject(imageShapeKey);
2097
+ if (imageShape != null) {
2098
+ imageShape.transformByState({
2099
+ left,
2100
+ top,
2101
+ width,
2102
+ height,
2103
+ angle,
2104
+ flipX,
2105
+ flipY,
2106
+ skewX,
2107
+ skewY
2108
+ });
2109
+ continue;
2110
+ }
2111
+ const orders = this._drawingManagerService.getDrawingOrder(unitId, subUnitId);
2112
+ const zIndex = orders.indexOf(drawingId);
2113
+ const imageConfig = {
2114
+ ...transform,
2115
+ zIndex: zIndex === -1 ? orders.length - 1 : zIndex
2116
+ };
2117
+ const imageNativeCache = this._imageIoService.getImageSourceCache(source, imageSourceType);
2118
+ let shouldBeCache = false;
2119
+ if (imageNativeCache != null) imageConfig.image = imageNativeCache;
2120
+ else if (imageSourceType === _univerjs_drawing.ImageSourceType.UUID) try {
2121
+ imageConfig.url = await this._imageIoService.getImage(source);
2122
+ } catch (error) {
2123
+ console.error(error);
2124
+ continue;
2125
+ }
2126
+ else if (imageSourceType === _univerjs_drawing.ImageSourceType.URL) {
2127
+ try {
2128
+ imageConfig.url = await this._urlImageService.getImage(source);
2129
+ } catch (error) {
2130
+ console.error(error);
2131
+ imageConfig.url = source;
2132
+ }
2133
+ shouldBeCache = true;
2134
+ } else {
2135
+ imageConfig.url = source;
2136
+ shouldBeCache = true;
2137
+ }
2138
+ if (hidden) imageConfig.visible = false;
2139
+ if (scene.getObject(imageShapeKey)) continue;
2140
+ imageConfig.printable = true;
2141
+ const image = new _univerjs_engine_render.Image(imageShapeKey, imageConfig);
2142
+ image.setClipService(this._drawingImageClipService);
2143
+ if (shouldBeCache) this._imageIoService.addImageSourceCache(source, imageSourceType, image.getNative());
2144
+ scene.addObject(image, _univerjs_engine_render.DRAWING_OBJECT_LAYER_INDEX);
2145
+ if (this._drawingManagerService.getDrawingEditable()) scene.attachTransformerTo(image);
2146
+ groupId && insertGroupObject({
2147
+ drawingId: groupId,
2148
+ unitId,
2149
+ subUnitId
2150
+ }, image, scene, this._drawingManagerService);
2151
+ if (prstGeom != null) image.setPrstGeom(prstGeom);
2152
+ if (adjustValues != null) image.setPrstGeomAdjValues(adjustValues);
2153
+ if (srcRect != null) image.setSrcRect(srcRect);
2154
+ images.push(image);
2155
+ }
2156
+ return images;
2157
+ }
2158
+ _getActiveSheetId() {
2159
+ var _this$_univerInstance;
2160
+ return (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 || (_this$_univerInstance = _this$_univerInstance.getActiveSheet()) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetId();
2161
+ }
2162
+ renderFloatDom(param, scene) {
2163
+ const { transform: singleTransform, drawingType, groupId, unitId, subUnitId, drawingId, isMultiTransform, transforms: multiTransforms } = param;
2164
+ if (drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_DOM) return;
2165
+ if (!this._drawingManagerService.getDrawingVisible()) return;
2166
+ if (singleTransform == null) return;
2167
+ const transforms = isMultiTransform && multiTransforms ? multiTransforms : [singleTransform];
2168
+ const rects = [];
2169
+ for (const transform of transforms) {
2170
+ const { left, top, width, height, angle, flipX, flipY, skewX, skewY } = transform;
2171
+ const index = transforms.indexOf(transform);
2172
+ const imageShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
2173
+ unitId,
2174
+ subUnitId,
2175
+ drawingId
2176
+ }, isMultiTransform ? index : void 0);
2177
+ const imageShape = scene.getObject(imageShapeKey);
2178
+ if (imageShape != null) {
2179
+ imageShape.transformByState({
2180
+ left,
2181
+ top,
2182
+ width,
2183
+ height,
2184
+ angle,
2185
+ flipX,
2186
+ flipY,
2187
+ skewX,
2188
+ skewY
2189
+ });
2190
+ continue;
2191
+ }
2192
+ const orders = this._drawingManagerService.getDrawingOrder(unitId, subUnitId);
2193
+ const zIndex = orders.indexOf(drawingId);
2194
+ const rectConfig = {
2195
+ ...transform,
2196
+ zIndex: zIndex === -1 ? orders.length - 1 : zIndex
2197
+ };
2198
+ if (scene.getObject(imageShapeKey)) continue;
2199
+ rectConfig.printable = false;
2200
+ const rect = new _univerjs_engine_render.Rect(imageShapeKey, rectConfig);
2201
+ if (!this._drawingManagerService.getDrawingVisible()) continue;
2202
+ scene.addObject(rect, _univerjs_engine_render.DRAWING_OBJECT_LAYER_INDEX);
2203
+ if (this._drawingManagerService.getDrawingEditable() && param.allowTransform !== false) scene.attachTransformerTo(rect);
2204
+ groupId && insertGroupObject({
2205
+ drawingId: groupId,
2206
+ unitId,
2207
+ subUnitId
2208
+ }, rect, scene, this._drawingManagerService);
2209
+ rects.push(rect);
2210
+ }
2211
+ return rects;
2212
+ }
2213
+ renderDrawing(param, scene) {
2214
+ const drawingParam = this._drawingManagerService.getDrawingByParam(param);
2215
+ if (drawingParam == null) return;
2216
+ switch (drawingParam.drawingType) {
2217
+ case _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE: return this.renderImages(drawingParam, scene);
2218
+ default:
2219
+ }
2220
+ }
2221
+ previewImage(key, src, width, height) {
2222
+ this._galleryService.open({
2223
+ images: [src],
2224
+ onOpenChange: (open) => {
2225
+ if (!open) this._galleryService.close();
2226
+ }
2227
+ });
2228
+ }
2229
+ _adjustImageSize(nativeWidth, nativeHeight, screenWidth, screenHeight) {
2230
+ if (nativeWidth <= screenWidth && nativeHeight <= screenHeight) return {
2231
+ width: nativeWidth,
2232
+ height: nativeHeight
2233
+ };
2234
+ const widthRatio = screenWidth / nativeWidth;
2235
+ const heightRatio = screenHeight / nativeHeight;
2236
+ const scale = Math.min(widthRatio, heightRatio);
2237
+ return {
2238
+ width: Math.floor(nativeWidth * scale),
2239
+ height: Math.floor(nativeHeight * scale)
2240
+ };
2241
+ }
2242
+ };
2243
+ DrawingRenderService = __decorate([
2244
+ __decorateParam(0, _univerjs_drawing.IDrawingManagerService),
2245
+ __decorateParam(1, _univerjs_drawing.IImageIoService),
2246
+ __decorateParam(2, _univerjs_ui.IGalleryService),
2247
+ __decorateParam(3, _univerjs_core.IURLImageService),
2248
+ __decorateParam(4, _univerjs_core.IUniverInstanceService),
2249
+ __decorateParam(5, (0, _univerjs_core.Inject)(DrawingImageClipService))
2250
+ ], DrawingRenderService);
2251
+
2252
+ //#endregion
2253
+ //#region src/controllers/image-update.controller.ts
2254
+ let ImageUpdateController = class ImageUpdateController extends _univerjs_core.Disposable {
2255
+ constructor(_commandService, _renderManagerService, _drawingManagerService, _dialogService, _imageIoService, _currentUniverService, _drawingRenderService) {
2256
+ super();
2257
+ this._commandService = _commandService;
2258
+ this._renderManagerService = _renderManagerService;
2259
+ this._drawingManagerService = _drawingManagerService;
2260
+ this._dialogService = _dialogService;
2261
+ this._imageIoService = _imageIoService;
2262
+ this._currentUniverService = _currentUniverService;
2263
+ this._drawingRenderService = _drawingRenderService;
2264
+ this._initialize();
2265
+ }
2266
+ dispose() {
2267
+ super.dispose();
2268
+ }
2269
+ _initialize() {
2270
+ this._drawingAddListener();
2271
+ this._commandExecutedListener();
2272
+ this._imageUpdateListener();
2273
+ }
2274
+ _commandExecutedListener() {
2275
+ this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
2276
+ if (command.id === ImageResetSizeOperation.id) {
2277
+ const params = command.params;
2278
+ if (params == null) return;
2279
+ this._resetImageSize(params);
2280
+ }
2281
+ }));
2282
+ }
2283
+ _getSceneAndTransformerByDrawingSearch(unitId) {
2284
+ if (unitId == null) return;
2285
+ const renderObject = this._renderManagerService.getRenderById(unitId);
2286
+ const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
2287
+ if (scene == null) return null;
2288
+ return {
2289
+ scene,
2290
+ transformer: scene.getTransformerByCreate()
2291
+ };
2292
+ }
2293
+ _resetImageSize(params) {
2294
+ const updateParams = [];
2295
+ const sceneList = [];
2296
+ params.forEach((param) => {
2297
+ const { unitId, subUnitId, drawingId } = param;
2298
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2299
+ if (renderObject == null) return;
2300
+ const { scene } = renderObject;
2301
+ const imageShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
2302
+ unitId,
2303
+ subUnitId,
2304
+ drawingId
2305
+ });
2306
+ const imageShape = scene.getObject(imageShapeKey);
2307
+ if (imageShape == null) return true;
2308
+ const imageData = this._drawingManagerService.getDrawingByParam(param);
2309
+ if (imageData == null) return true;
2310
+ if (imageData.drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE) return;
2311
+ imageShape.resetSize();
2312
+ const { width, height } = imageShape.getNativeSize();
2313
+ if (sceneList.includes(scene) === false) sceneList.push(scene);
2314
+ updateParams.push({
2315
+ ...imageData,
2316
+ transform: {
2317
+ ...imageData.transform,
2318
+ height,
2319
+ width,
2320
+ angle: 0
2321
+ },
2322
+ srcRect: null,
2323
+ prstGeom: null
2324
+ });
2325
+ });
2326
+ this._drawingManagerService.featurePluginUpdateNotification(updateParams);
2327
+ sceneList.forEach((scene) => {
2328
+ scene.getTransformerByCreate().refreshControls().changeNotification();
2329
+ });
2330
+ this._commandService.syncExecuteCommand(_univerjs_drawing.SetDrawingSelectedOperation.id, params);
2331
+ }
2332
+ _drawingAddListener() {
2333
+ this.disposeWithMe(this._drawingManagerService.add$.pipe((0, rxjs.bufferTime)(33), (0, rxjs.filter)((batches) => batches.length > 0), (0, rxjs.map)((batches) => batches.flat()), (0, rxjs.map)((items) => {
2334
+ const map = /* @__PURE__ */ new Map();
2335
+ for (const it of items) map.set(`${it.unitId}|${it.subUnitId}|${it.drawingId}`, it);
2336
+ return [...map.values()];
2337
+ }), (0, rxjs.filter)((items) => items.length > 0)).subscribe((uniqueParams) => {
2338
+ this._insertImages(uniqueParams);
2339
+ }));
2340
+ }
2341
+ _insertImages(params) {
2342
+ params.forEach(async (param) => {
2343
+ var _getCurrentUnitInfo;
2344
+ const { unitId, subUnitId } = param;
2345
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2346
+ const currentSubUnitId = (_getCurrentUnitInfo = getCurrentUnitInfo(this._currentUniverService, unitId)) === null || _getCurrentUnitInfo === void 0 ? void 0 : _getCurrentUnitInfo.subUnitId;
2347
+ if (renderObject == null || currentSubUnitId !== subUnitId) return;
2348
+ const imageParam = this._drawingManagerService.getDrawingByParam(param);
2349
+ if (imageParam == null) return;
2350
+ const images = await this._drawingRenderService.renderImages(imageParam, renderObject.scene);
2351
+ this._drawingManagerService.refreshTransform([imageParam]);
2352
+ if (images == null || images.length === 0) return;
2353
+ for (const image of images) {
2354
+ this._addHoverForImage(image);
2355
+ this._addDialogForImage(image);
2356
+ }
2357
+ });
2358
+ }
2359
+ _imageUpdateListener() {
2360
+ this.disposeWithMe(this._drawingManagerService.update$.subscribe((params) => {
2361
+ params.forEach((param) => {
2362
+ const { unitId, subUnitId, drawingId } = param;
2363
+ const drawingParam = this._drawingManagerService.getDrawingByParam(param);
2364
+ if (drawingParam == null) return;
2365
+ const { transform, drawingType, srcRect, prstGeom, source, imageSourceType } = drawingParam;
2366
+ if (drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE) return;
2367
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2368
+ if (renderObject == null) return;
2369
+ const { scene, transformer } = renderObject;
2370
+ if (transform == null) return true;
2371
+ const drawingShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
2372
+ unitId,
2373
+ subUnitId,
2374
+ drawingId
2375
+ });
2376
+ const imageShape = scene.getObject(drawingShapeKey);
2377
+ if (imageShape == null) return true;
2378
+ imageShape.setSrcRect(srcRect);
2379
+ imageShape.setPrstGeom(prstGeom);
2380
+ if (source != null && source.length > 0 && (imageSourceType === _univerjs_core.ImageSourceType.BASE64 || imageSourceType === _univerjs_core.ImageSourceType.URL)) imageShape.changeSource(source);
2381
+ });
2382
+ }));
2383
+ }
2384
+ _addHoverForImage(o) {
2385
+ this.disposeWithMe((0, _univerjs_core.toDisposable)(o.onPointerEnter$.subscribeEvent(() => {
2386
+ o.cursor = _univerjs_engine_render.CURSOR_TYPE.GRAB;
2387
+ })));
2388
+ this.disposeWithMe((0, _univerjs_core.toDisposable)(o.onPointerLeave$.subscribeEvent(() => {
2389
+ o.cursor = _univerjs_engine_render.CURSOR_TYPE.DEFAULT;
2390
+ })));
2391
+ }
2392
+ _addDialogForImage(o) {
2393
+ this.disposeWithMe((0, _univerjs_core.toDisposable)(o.onDblclick$.subscribeEvent(() => {
2394
+ const dialogId = `${o.oKey}-viewer-dialog`;
2395
+ this._drawingRenderService.previewImage(dialogId, o.getNative().src, o.getNativeSize().width, o.getNativeSize().height);
2396
+ })));
2397
+ }
2398
+ };
2399
+ ImageUpdateController = __decorate([
2400
+ __decorateParam(0, _univerjs_core.ICommandService),
2401
+ __decorateParam(1, _univerjs_engine_render.IRenderManagerService),
2402
+ __decorateParam(2, _univerjs_drawing.IDrawingManagerService),
2403
+ __decorateParam(3, _univerjs_ui.IDialogService),
2404
+ __decorateParam(4, _univerjs_drawing.IImageIoService),
2405
+ __decorateParam(5, _univerjs_core.IUniverInstanceService),
2406
+ __decorateParam(6, (0, _univerjs_core.Inject)(DrawingRenderService))
2407
+ ], ImageUpdateController);
2408
+
2409
+ //#endregion
2410
+ //#region src/plugin.ts
2411
+ let UniverDrawingUIPlugin = class UniverDrawingUIPlugin extends _univerjs_core.Plugin {
2412
+ constructor(_config = defaultPluginConfig, _injector, _configService) {
2413
+ super();
2414
+ this._config = _config;
2415
+ this._injector = _injector;
2416
+ this._configService = _configService;
2417
+ const { menu, ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
2418
+ if (menu) this._configService.setConfig("menu", menu, { merge: true });
2419
+ this._configService.setConfig(DRAWING_UI_PLUGIN_CONFIG_KEY, rest);
2420
+ }
2421
+ onStarting() {
2422
+ this._initDependencies();
2423
+ }
2424
+ onRendered() {
2425
+ this._injector.get(DrawingUpdateController);
2426
+ this._injector.get(DrawingUIController);
2427
+ this._injector.get(ImageCropperController);
2428
+ this._injector.get(ImageUpdateController);
2429
+ }
2430
+ _initDependencies() {
2431
+ [
2432
+ [DrawingImageClipService],
2433
+ [DrawingRenderService],
2434
+ [DrawingUpdateController],
2435
+ [DrawingUIController],
2436
+ [ImageCropperController],
2437
+ [ImageUpdateController]
2438
+ ].forEach((dependency) => this._injector.add(dependency));
2439
+ }
2440
+ };
2441
+ _defineProperty(UniverDrawingUIPlugin, "pluginName", "UNIVER_DRAWING_UI_PLUGIN");
2442
+ _defineProperty(UniverDrawingUIPlugin, "packageName", name);
2443
+ _defineProperty(UniverDrawingUIPlugin, "version", version);
2444
+ UniverDrawingUIPlugin = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(2, _univerjs_core.IConfigService)], UniverDrawingUIPlugin);
2445
+
2446
+ //#endregion
2447
+ //#region src/views/panel/DrawingAlign.tsx
2448
+ const DrawingAlign = (props) => {
2449
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
2450
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
2451
+ const { drawings, alignShow } = props;
2452
+ const [alignValue, setAlignValue] = (0, react.useState)("0");
2453
+ const alignOptions = [
2454
+ {
2455
+ label: localeService.t("drawing-ui.image-panel.align.default"),
2456
+ value: "0"
2457
+ },
2458
+ { options: [
2459
+ {
2460
+ label: localeService.t("drawing-ui.image-panel.align.left"),
2461
+ value: "1"
2462
+ },
2463
+ {
2464
+ label: localeService.t("drawing-ui.image-panel.align.center"),
2465
+ value: "2"
2466
+ },
2467
+ {
2468
+ label: localeService.t("drawing-ui.image-panel.align.right"),
2469
+ value: "3"
2470
+ }
2471
+ ] },
2472
+ { options: [
2473
+ {
2474
+ label: localeService.t("drawing-ui.image-panel.align.top"),
2475
+ value: "4"
2476
+ },
2477
+ {
2478
+ label: localeService.t("drawing-ui.image-panel.align.middle"),
2479
+ value: "5"
2480
+ },
2481
+ {
2482
+ label: localeService.t("drawing-ui.image-panel.align.bottom"),
2483
+ value: "6"
2484
+ }
2485
+ ] },
2486
+ { options: [{
2487
+ label: localeService.t("drawing-ui.image-panel.align.horizon"),
2488
+ value: "7"
2489
+ }, {
2490
+ label: localeService.t("drawing-ui.image-panel.align.vertical"),
2491
+ value: "8"
2492
+ }] }
2493
+ ];
2494
+ function handleAlignChange(value) {
2495
+ setAlignValue(value);
2496
+ commandService.executeCommand(SetDrawingAlignOperation.id, {
2497
+ alignType: value,
2498
+ drawings
2499
+ });
2500
+ }
2501
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2502
+ className: (0, _univerjs_design.clsx)("univer-relative univer-w-full", { "univer-hidden": !alignShow }),
2503
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
2504
+ className: "univer-text-gray-600 dark:!univer-text-gray-200",
2505
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: localeService.t("drawing-ui.image-panel.align.title") })
2506
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2507
+ className: "univer-relative univer-mt-2.5 univer-flex univer-h-full",
2508
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2509
+ className: "univer-w-full univer-text-gray-900 dark:!univer-text-white",
2510
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
2511
+ value: alignValue,
2512
+ options: alignOptions,
2513
+ onChange: handleAlignChange
2514
+ })
2515
+ })
2516
+ })]
2517
+ });
2518
+ };
2519
+
2520
+ //#endregion
2521
+ //#region src/views/panel/DrawingArrange.tsx
2522
+ const DrawingArrange = (props) => {
2523
+ const { arrangeShow, drawings: focusDrawings } = props;
2524
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
2525
+ const drawingManagerService = (0, _univerjs_ui.useDependency)(_univerjs_drawing.IDrawingManagerService);
2526
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
2527
+ const componentManager = (0, _univerjs_ui.useDependency)(_univerjs_ui.ComponentManager);
2528
+ const MoveUpIcon = componentManager.get("MoveUpIcon");
2529
+ const MoveDownIcon = componentManager.get("MoveDownIcon");
2530
+ const TopmostIcon = componentManager.get("TopmostIcon");
2531
+ const BottomIcon = componentManager.get("BottomIcon");
2532
+ const [drawings, setDrawings] = (0, react.useState)(focusDrawings);
2533
+ (0, react.useEffect)(() => {
2534
+ const focusDispose = drawingManagerService.focus$.subscribe((drawings) => {
2535
+ setDrawings(drawings);
2536
+ });
2537
+ return () => {
2538
+ focusDispose.unsubscribe();
2539
+ };
2540
+ }, []);
2541
+ const onArrangeBtnClick = (arrangeType) => {
2542
+ commandService.syncExecuteCommand(SetDrawingArrangeOperation.id, {
2543
+ arrangeType,
2544
+ drawings
2545
+ });
2546
+ };
2547
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2548
+ className: (0, _univerjs_design.clsx)("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", { "univer-hidden": !arrangeShow }),
2549
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
2550
+ className: "univer-text-gray-600 dark:!univer-text-gray-200",
2551
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: localeService.t("drawing-ui.image-panel.arrange.title") })
2552
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2553
+ className: "univer-grid univer-grid-cols-2 univer-gap-2",
2554
+ children: [
2555
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
2556
+ onClick: () => {
2557
+ onArrangeBtnClick(_univerjs_core.ArrangeTypeEnum.forward);
2558
+ },
2559
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MoveUpIcon, {}), localeService.t("drawing-ui.image-panel.arrange.forward")]
2560
+ }),
2561
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
2562
+ onClick: () => {
2563
+ onArrangeBtnClick(_univerjs_core.ArrangeTypeEnum.backward);
2564
+ },
2565
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MoveDownIcon, {}), localeService.t("drawing-ui.image-panel.arrange.backward")]
2566
+ }),
2567
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
2568
+ onClick: () => {
2569
+ onArrangeBtnClick(_univerjs_core.ArrangeTypeEnum.front);
2570
+ },
2571
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TopmostIcon, {}), localeService.t("drawing-ui.image-panel.arrange.front")]
2572
+ }),
2573
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
2574
+ onClick: () => {
2575
+ onArrangeBtnClick(_univerjs_core.ArrangeTypeEnum.back);
2576
+ },
2577
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BottomIcon, {}), localeService.t("drawing-ui.image-panel.arrange.back")]
2578
+ })
2579
+ ]
2580
+ })]
2581
+ });
2582
+ };
2583
+
2584
+ //#endregion
2585
+ //#region src/views/panel/DrawingGroup.tsx
2586
+ const DrawingGroup = (props) => {
2587
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
2588
+ const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
2589
+ const drawingManagerService = (0, _univerjs_ui.useDependency)(_univerjs_drawing.IDrawingManagerService);
2590
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
2591
+ const componentManager = (0, _univerjs_ui.useDependency)(_univerjs_ui.ComponentManager);
2592
+ const { hasGroup, drawings } = props;
2593
+ const GroupIcon = componentManager.get("GroupIcon");
2594
+ const UngroupIcon = componentManager.get("UngroupIcon");
2595
+ const [groupShow, setGroupShow] = (0, react.useState)(false);
2596
+ const [groupBtnShow, setGroupBtnShow] = (0, react.useState)(true);
2597
+ const [ungroupBtnShow, setUngroupBtnShow] = (0, react.useState)(true);
2598
+ const onGroupBtnClick = () => {
2599
+ commandService.syncExecuteCommand(SetDrawingGroupOperation.id, { drawings });
2600
+ };
2601
+ const onUngroupBtnClick = () => {
2602
+ commandService.syncExecuteCommand(CancelDrawingGroupOperation.id, { drawings });
2603
+ };
2604
+ (0, react.useEffect)(() => {
2605
+ const drawingParam = drawings[0];
2606
+ if (drawingParam == null) return;
2607
+ const { unitId } = drawingParam;
2608
+ const renderObject = renderManagerService.getRenderById(unitId);
2609
+ const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
2610
+ if (scene == null) return;
2611
+ const transformer = scene.getTransformerByCreate();
2612
+ const onClearControlObserver = transformer.clearControl$.subscribe((changeSelf) => {
2613
+ if (changeSelf === true) setGroupShow(false);
2614
+ });
2615
+ const onChangeStartObserver = transformer.changeStart$.subscribe((state) => {
2616
+ const { objects } = state;
2617
+ const params = getUpdateParams(objects, drawingManagerService);
2618
+ const groupParams = params.filter((o) => (o === null || o === void 0 ? void 0 : o.drawingType) === _univerjs_core.DrawingTypeEnum.DRAWING_GROUP);
2619
+ let groupBtnShow = false;
2620
+ let ungroupBtnShow = false;
2621
+ if (params.length > 1) groupBtnShow = true;
2622
+ if (groupParams.length > 0) ungroupBtnShow = true;
2623
+ setGroupShow(groupBtnShow || ungroupBtnShow);
2624
+ setGroupBtnShow(groupBtnShow);
2625
+ setUngroupBtnShow(ungroupBtnShow);
2626
+ });
2627
+ return () => {
2628
+ onChangeStartObserver.unsubscribe();
2629
+ onClearControlObserver.unsubscribe();
2630
+ };
2631
+ }, []);
2632
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2633
+ className: (0, _univerjs_design.clsx)("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", { "univer-hidden": hasGroup === true && groupShow === false || hasGroup === false }),
2634
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
2635
+ className: "univer-text-gray-600 dark:!univer-text-gray-200",
2636
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: localeService.t("drawing-ui.image-panel.group.title") })
2637
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2638
+ className: "univer-flex univer-items-center univer-justify-center univer-gap-2",
2639
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
2640
+ className: (0, _univerjs_design.clsx)({ "univer-hidden": !groupBtnShow }),
2641
+ onClick: onGroupBtnClick,
2642
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(GroupIcon, {}), localeService.t("drawing-ui.image-panel.group.group")]
2643
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
2644
+ className: (0, _univerjs_design.clsx)({ "univer-hidden": !ungroupBtnShow }),
2645
+ onClick: onUngroupBtnClick,
2646
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UngroupIcon, {}), localeService.t("drawing-ui.image-panel.group.unGroup")]
2647
+ })]
2648
+ })]
2649
+ });
2650
+ };
2651
+
2652
+ //#endregion
2653
+ //#region src/utils/config.ts
2654
+ const RANGE_DRAWING_ROTATION_LIMIT = [-360, 360];
2655
+
2656
+ //#endregion
2657
+ //#region src/views/panel/DrawingTransform.tsx
2658
+ const INPUT_DEBOUNCE_TIME = 300;
2659
+ const DrawingTransform = (props) => {
2660
+ var _scene$getEngine;
2661
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
2662
+ const drawingManagerService = (0, _univerjs_ui.useDependency)(_univerjs_drawing.IDrawingManagerService);
2663
+ const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
2664
+ const { drawings, transformShow } = props;
2665
+ const drawingParam = drawings[0];
2666
+ if (drawingParam == null) return;
2667
+ const transform = drawingParam.transform;
2668
+ if (transform == null) return;
2669
+ const { unitId, subUnitId, drawingId, drawingType } = drawingParam;
2670
+ const renderObject = renderManagerService.getRenderById(unitId);
2671
+ const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
2672
+ if (scene == null) return;
2673
+ const topScene = (_scene$getEngine = scene.getEngine()) === null || _scene$getEngine === void 0 ? void 0 : _scene$getEngine.activeScene;
2674
+ if (topScene == null) return;
2675
+ const transformer = scene.getTransformerByCreate();
2676
+ const { width: originWidth = 0, height: originHeight = 0, left: originX = 0, top: originY = 0, angle: originRotation = 0 } = transform;
2677
+ const [width, setWidth] = (0, react.useState)(originWidth);
2678
+ const [height, setHeight] = (0, react.useState)(originHeight);
2679
+ const [xPosition, setXPosition] = (0, react.useState)(originX);
2680
+ const [yPosition, setYPosition] = (0, react.useState)(originY);
2681
+ const [rotation, setRotation] = (0, react.useState)(originRotation);
2682
+ const [lockRatio, setLockRatio] = (0, react.useState)(transformer.keepRatio);
2683
+ const checkMoveBoundary = (left, top, width, height) => {
2684
+ const { width: topSceneWidth, height: topSceneHeight } = topScene;
2685
+ const { ancestorLeft, ancestorTop } = scene;
2686
+ let limitLeft = left;
2687
+ let limitTop = top;
2688
+ let limitWidth = width;
2689
+ let limitHeight = height;
2690
+ if (left + ancestorLeft < 0) limitLeft = -ancestorLeft;
2691
+ if (top + ancestorTop < 0) limitTop = -ancestorTop;
2692
+ limitWidth = topSceneWidth - limitLeft - ancestorLeft;
2693
+ if (limitWidth < 20) limitWidth = 20;
2694
+ limitHeight = topSceneHeight - limitTop - ancestorTop;
2695
+ if (limitHeight < 20) limitHeight = 20;
2696
+ if (left + limitWidth + ancestorLeft > topSceneWidth) limitLeft = topSceneWidth - width - ancestorLeft;
2697
+ if (top + limitHeight + ancestorTop > topSceneHeight) limitTop = topSceneHeight - height - ancestorTop;
2698
+ return {
2699
+ limitLeft,
2700
+ limitTop,
2701
+ limitWidth,
2702
+ limitHeight
2703
+ };
2704
+ };
2705
+ const changeObs = (state) => {
2706
+ const { objects } = state;
2707
+ const params = getUpdateParams(objects, drawingManagerService);
2708
+ if (params.length !== 1) return;
2709
+ const drawingParam = params[0];
2710
+ if (drawingParam == null) return;
2711
+ const { transform } = drawingParam;
2712
+ if (transform == null) return;
2713
+ const { width: originWidth, height: originHeight, left: originX, top: originY, angle: originRotation } = transform;
2714
+ if (originWidth != null) setWidth(originWidth);
2715
+ if (originHeight != null) setHeight(originHeight);
2716
+ if (originX != null) setXPosition(originX);
2717
+ if (originY != null) setYPosition(originY);
2718
+ if (originRotation != null) setRotation(originRotation);
2719
+ };
2720
+ (0, react.useEffect)(() => {
2721
+ const subscriptions = [
2722
+ transformer.changeStart$.subscribe((state) => {
2723
+ changeObs(state);
2724
+ }),
2725
+ transformer.changing$.subscribe((state) => {
2726
+ changeObs(state);
2727
+ }),
2728
+ transformer.changeEnd$.subscribe((state) => {
2729
+ changeObs(state);
2730
+ }),
2731
+ drawingManagerService.focus$.subscribe((drawings) => {
2732
+ if (drawings.length !== 1) return;
2733
+ const drawingParam = drawingManagerService.getDrawingByParam(drawings[0]);
2734
+ if (drawingParam == null) return;
2735
+ const transform = drawingParam.transform;
2736
+ if (transform == null) return;
2737
+ const { width: originWidth, height: originHeight, left: originX, top: originY, angle: originRotation } = transform;
2738
+ if (originWidth != null) setWidth(originWidth);
2739
+ if (originHeight != null) setHeight(originHeight);
2740
+ if (originX != null) setXPosition(originX);
2741
+ if (originY != null) setYPosition(originY);
2742
+ if (originRotation != null) setRotation(originRotation);
2743
+ })
2744
+ ];
2745
+ return () => {
2746
+ subscriptions.forEach((sub) => sub.unsubscribe());
2747
+ };
2748
+ }, []);
2749
+ const handleWidthChange = (0, _univerjs_core.debounce)((val) => {
2750
+ if (val == null) return;
2751
+ const { limitWidth, limitHeight } = checkMoveBoundary(xPosition, yPosition, val, height);
2752
+ val = Math.min(val, limitWidth);
2753
+ const updateParam = {
2754
+ unitId,
2755
+ subUnitId,
2756
+ drawingId,
2757
+ drawingType,
2758
+ transform: { width: val }
2759
+ };
2760
+ if (lockRatio) {
2761
+ let heightFix = val / width * height;
2762
+ heightFix = Math.max(heightFix, 20);
2763
+ if (heightFix > limitHeight) return;
2764
+ setHeight(heightFix);
2765
+ updateParam.transform.height = heightFix;
2766
+ }
2767
+ setWidth(val);
2768
+ drawingManagerService.featurePluginUpdateNotification([updateParam]);
2769
+ transformer.refreshControls().changeNotification();
2770
+ }, INPUT_DEBOUNCE_TIME);
2771
+ const handleHeightChange = (0, _univerjs_core.debounce)((val) => {
2772
+ if (val == null) return;
2773
+ const { limitHeight, limitWidth } = checkMoveBoundary(xPosition, yPosition, width, val);
2774
+ val = Math.min(val, limitHeight);
2775
+ const updateParam = {
2776
+ unitId,
2777
+ subUnitId,
2778
+ drawingId,
2779
+ drawingType,
2780
+ transform: { height: val }
2781
+ };
2782
+ if (lockRatio) {
2783
+ let widthFix = val / height * width;
2784
+ widthFix = Math.max(widthFix, 20);
2785
+ if (widthFix > limitWidth) return;
2786
+ setWidth(widthFix);
2787
+ updateParam.transform.width = widthFix;
2788
+ }
2789
+ setHeight(val);
2790
+ drawingManagerService.featurePluginUpdateNotification([updateParam]);
2791
+ transformer.refreshControls().changeNotification();
2792
+ }, INPUT_DEBOUNCE_TIME);
2793
+ const handleXChange = (0, _univerjs_core.debounce)((val) => {
2794
+ if (val == null) return;
2795
+ const { limitLeft } = checkMoveBoundary(val, yPosition, width, height);
2796
+ val = limitLeft;
2797
+ const updateParam = {
2798
+ unitId,
2799
+ subUnitId,
2800
+ drawingId,
2801
+ drawingType,
2802
+ transform: { left: val }
2803
+ };
2804
+ setXPosition(val);
2805
+ drawingManagerService.featurePluginUpdateNotification([updateParam]);
2806
+ transformer.refreshControls().changeNotification();
2807
+ }, INPUT_DEBOUNCE_TIME);
2808
+ const handleYChange = (0, _univerjs_core.debounce)((val) => {
2809
+ if (val == null) return;
2810
+ const { limitTop } = checkMoveBoundary(xPosition, val, width, height);
2811
+ val = limitTop;
2812
+ const updateParam = {
2813
+ unitId,
2814
+ subUnitId,
2815
+ drawingId,
2816
+ drawingType,
2817
+ transform: { top: val }
2818
+ };
2819
+ setYPosition(val);
2820
+ drawingManagerService.featurePluginUpdateNotification([updateParam]);
2821
+ transformer.refreshControls().changeNotification();
2822
+ }, INPUT_DEBOUNCE_TIME);
2823
+ const handleRotationChange = (val) => {
2824
+ if (val == null) return;
2825
+ const updateParam = {
2826
+ unitId,
2827
+ subUnitId,
2828
+ drawingId,
2829
+ drawingType,
2830
+ transform: { angle: val }
2831
+ };
2832
+ setRotation(val);
2833
+ drawingManagerService.featurePluginUpdateNotification([updateParam]);
2834
+ transformer.refreshControls().changeNotification();
2835
+ };
2836
+ const handleLockRatioChange = (val) => {
2837
+ setLockRatio(val);
2838
+ transformer.keepRatio = val;
2839
+ };
2840
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2841
+ className: (0, _univerjs_design.clsx)("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", { "univer-hidden": !transformShow }),
2842
+ children: [
2843
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
2844
+ className: "univer-text-gray-600 dark:!univer-text-gray-200",
2845
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: localeService.t("drawing-ui.image-panel.transform.title") })
2846
+ }),
2847
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2848
+ className: "univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",
2849
+ children: [
2850
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("drawing-ui.image-panel.transform.width") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
2851
+ precision: 1,
2852
+ value: width,
2853
+ min: 20,
2854
+ onChange: (val) => {
2855
+ handleWidthChange(val);
2856
+ }
2857
+ })] }),
2858
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("drawing-ui.image-panel.transform.height") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
2859
+ precision: 1,
2860
+ value: height,
2861
+ min: 20,
2862
+ onChange: (val) => {
2863
+ handleHeightChange(val);
2864
+ }
2865
+ })] }),
2866
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("drawing-ui.image-panel.transform.lock") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2867
+ className: "univer-text-center",
2868
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
2869
+ checked: lockRatio,
2870
+ onChange: handleLockRatioChange
2871
+ })
2872
+ })] })
2873
+ ]
2874
+ }),
2875
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2876
+ className: "univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",
2877
+ children: [
2878
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("drawing-ui.image-panel.transform.x") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
2879
+ precision: 1,
2880
+ value: xPosition,
2881
+ onChange: (val) => {
2882
+ handleXChange(val);
2883
+ }
2884
+ })] }),
2885
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("drawing-ui.image-panel.transform.y") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
2886
+ precision: 1,
2887
+ value: yPosition,
2888
+ onChange: (val) => {
2889
+ handleYChange(val);
2890
+ }
2891
+ })] }),
2892
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("drawing-ui.image-panel.transform.rotate") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
2893
+ precision: 1,
2894
+ value: rotation,
2895
+ min: RANGE_DRAWING_ROTATION_LIMIT[0],
2896
+ max: RANGE_DRAWING_ROTATION_LIMIT[1],
2897
+ onChange: handleRotationChange
2898
+ })] })
2899
+ ]
2900
+ })
2901
+ ]
2902
+ });
2903
+ };
2904
+
2905
+ //#endregion
2906
+ //#region src/views/panel/ImageCropper.tsx
2907
+ const ImageCropper = (props) => {
2908
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
2909
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
2910
+ const clipService = (0, _univerjs_ui.useDependency)(DrawingImageClipService);
2911
+ const componentManager = (0, _univerjs_ui.useDependency)(_univerjs_ui.ComponentManager);
2912
+ const canUseShapeClip = (0, _univerjs_ui.useObservable)(clipService.canUseShapeClip$, false);
2913
+ const { drawings, cropperShow } = props;
2914
+ if (drawings[0] == null) return;
2915
+ const [cropValue, setCropValue] = (0, react.useState)("0");
2916
+ const cropStateRef = (0, react.useRef)(false);
2917
+ const cropOptions = [
2918
+ {
2919
+ label: localeService.t("drawing-ui.image-panel.crop.mode"),
2920
+ value: "0"
2921
+ },
2922
+ {
2923
+ label: "1:1",
2924
+ value: "1"
2925
+ },
2926
+ {
2927
+ label: "16:9",
2928
+ value: "2"
2929
+ },
2930
+ {
2931
+ label: "9:16",
2932
+ value: "3"
2933
+ },
2934
+ {
2935
+ label: "5:4",
2936
+ value: "4"
2937
+ },
2938
+ {
2939
+ label: "4:5",
2940
+ value: "5"
2941
+ },
2942
+ {
2943
+ label: "4:3",
2944
+ value: "6"
2945
+ },
2946
+ {
2947
+ label: "3:4",
2948
+ value: "7"
2949
+ },
2950
+ {
2951
+ label: "3:2",
2952
+ value: "8"
2953
+ },
2954
+ {
2955
+ label: "2:3",
2956
+ value: "9"
2957
+ }
2958
+ ];
2959
+ (0, react.useEffect)(() => {
2960
+ const onChangeStartObserver = commandService.onCommandExecuted((command) => {
2961
+ if (command.id === CloseImageCropOperation.id) {
2962
+ const params = command.params;
2963
+ if (!(params === null || params === void 0 ? void 0 : params.isAuto)) cropStateRef.current = false;
2964
+ }
2965
+ });
2966
+ return () => {
2967
+ onChangeStartObserver === null || onChangeStartObserver === void 0 || onChangeStartObserver.dispose();
2968
+ };
2969
+ }, []);
2970
+ function handleCropChange(value) {
2971
+ setCropValue(value);
2972
+ if (cropStateRef.current) commandService.executeCommand(AutoImageCropOperation.id, { cropType: value });
2973
+ }
2974
+ const onCropperBtnClick = (val) => {
2975
+ commandService.executeCommand(AutoImageCropOperation.id, { cropType: val });
2976
+ cropStateRef.current = true;
2977
+ };
2978
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2979
+ className: (0, _univerjs_design.clsx)("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", { "univer-hidden": !cropperShow }),
2980
+ children: [
2981
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
2982
+ className: "univer-text-gray-600 dark:!univer-text-gray-200",
2983
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: localeService.t("drawing-ui.image-panel.crop.title") })
2984
+ }),
2985
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2986
+ className: "univer-flex univer-items-center univer-justify-center univer-gap-2",
2987
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
2988
+ onClick: () => {
2989
+ onCropperBtnClick(cropValue);
2990
+ },
2991
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CreateCopyIcon, {}), localeService.t("drawing-ui.image-panel.crop.start")]
2992
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
2993
+ value: cropValue,
2994
+ options: cropOptions,
2995
+ onChange: handleCropChange
2996
+ })]
2997
+ }),
2998
+ canUseShapeClip && (() => {
2999
+ const ShapeClipPicker = componentManager.get("sheet.image-clip.shape.picker.component");
3000
+ return ShapeClipPicker ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShapeClipPicker, {}) : null;
3001
+ })()
3002
+ ]
3003
+ });
3004
+ };
3005
+
3006
+ //#endregion
3007
+ //#region src/views/panel/DrawingCommonPanel.tsx
3008
+ const DrawingCommonPanel = (props) => {
3009
+ const drawingManagerService = (0, _univerjs_ui.useDependency)(_univerjs_drawing.IDrawingManagerService);
3010
+ const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
3011
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
3012
+ const { drawings, hasArrange = true, hasTransform = true, hasAlign = true, hasCropper = true, hasGroup = true } = props;
3013
+ const drawingParam = drawings[0];
3014
+ if (drawingParam == null) return;
3015
+ const { unitId } = drawingParam;
3016
+ const renderObject = renderManagerService.getRenderById(unitId);
3017
+ const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
3018
+ if (scene == null) return;
3019
+ const transformer = scene.getTransformerByCreate();
3020
+ const [arrangeShow, setArrangeShow] = (0, react.useState)(true);
3021
+ const [transformShow, setTransformShow] = (0, react.useState)(true);
3022
+ const [alignShow, setAlignShow] = (0, react.useState)(false);
3023
+ const [cropperShow, setCropperShow] = (0, react.useState)(true);
3024
+ const [nullShow, setNullShow] = (0, react.useState)(false);
3025
+ (0, react.useEffect)(() => {
3026
+ const clearControlSub = transformer.clearControl$.subscribe((changeSelf) => {
3027
+ if (changeSelf === true) {
3028
+ setArrangeShow(false);
3029
+ setTransformShow(false);
3030
+ setAlignShow(false);
3031
+ setCropperShow(false);
3032
+ setNullShow(true);
3033
+ }
3034
+ });
3035
+ const changeStartSub = transformer.changeStart$.subscribe((state) => {
3036
+ const { objects } = state;
3037
+ const params = getUpdateParams(objects, drawingManagerService);
3038
+ if (params.length === 0) {
3039
+ setArrangeShow(false);
3040
+ setTransformShow(false);
3041
+ setAlignShow(false);
3042
+ setCropperShow(false);
3043
+ setNullShow(true);
3044
+ } else if (params.length === 1) {
3045
+ setArrangeShow(true);
3046
+ setTransformShow(true);
3047
+ setAlignShow(false);
3048
+ setCropperShow(true);
3049
+ setNullShow(false);
3050
+ } else {
3051
+ setArrangeShow(true);
3052
+ setTransformShow(false);
3053
+ setAlignShow(true);
3054
+ setCropperShow(false);
3055
+ setNullShow(false);
3056
+ }
3057
+ });
3058
+ const focusSub = drawingManagerService.focus$.subscribe((drawings) => {
3059
+ if (drawings.length === 0) {
3060
+ setArrangeShow(false);
3061
+ setTransformShow(false);
3062
+ setAlignShow(false);
3063
+ setCropperShow(false);
3064
+ setNullShow(true);
3065
+ } else if (drawings.length === 1) {
3066
+ setArrangeShow(true);
3067
+ setTransformShow(true);
3068
+ setAlignShow(false);
3069
+ setCropperShow(true);
3070
+ setNullShow(false);
3071
+ } else {
3072
+ setArrangeShow(true);
3073
+ setTransformShow(false);
3074
+ setAlignShow(true);
3075
+ setCropperShow(false);
3076
+ setNullShow(false);
3077
+ }
3078
+ });
3079
+ return () => {
3080
+ changeStartSub.unsubscribe();
3081
+ clearControlSub.unsubscribe();
3082
+ focusSub.unsubscribe();
3083
+ };
3084
+ }, []);
3085
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3086
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3087
+ className: (0, _univerjs_design.clsx)("univer-h-full", { "univer-hidden": !nullShow }),
3088
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3089
+ className: "univer-flex univer-h-full univer-items-center univer-justify-center",
3090
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("drawing-ui.image-panel.null") })
3091
+ })
3092
+ }),
3093
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DrawingArrange, {
3094
+ arrangeShow: hasArrange === true ? arrangeShow : false,
3095
+ drawings
3096
+ }),
3097
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DrawingTransform, {
3098
+ transformShow: hasTransform === true ? transformShow : false,
3099
+ drawings
3100
+ }),
3101
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DrawingAlign, {
3102
+ alignShow: hasAlign === true ? alignShow : false,
3103
+ drawings
3104
+ }),
3105
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageCropper, {
3106
+ cropperShow: hasCropper === true ? cropperShow : false,
3107
+ drawings
3108
+ }),
3109
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DrawingGroup, {
3110
+ hasGroup,
3111
+ drawings
3112
+ })
3113
+ ] });
3114
+ };
3115
+
3116
+ //#endregion
3117
+ exports.AutoImageCropOperation = AutoImageCropOperation;
3118
+ exports.COMPONENT_IMAGE_POPUP_MENU = COMPONENT_IMAGE_POPUP_MENU;
3119
+ exports.CancelDrawingGroupOperation = CancelDrawingGroupOperation;
3120
+ exports.CloseImageCropOperation = CloseImageCropOperation;
3121
+ exports.DRAWING_GROUP_TYPES = DRAWING_GROUP_TYPES;
3122
+ exports.DrawingCommonPanel = DrawingCommonPanel;
3123
+ exports.DrawingImageClipService = DrawingImageClipService;
3124
+ Object.defineProperty(exports, 'DrawingRenderService', {
3125
+ enumerable: true,
3126
+ get: function () {
3127
+ return DrawingRenderService;
3128
+ }
3129
+ });
3130
+ exports.IMAGE_CLIP_SHAPE_PICKER_COMPONENT = IMAGE_CLIP_SHAPE_PICKER_COMPONENT;
3131
+ exports.ImageCropperObject = ImageCropperObject;
3132
+ exports.ImagePopupMenu = ImagePopupMenu;
3133
+ exports.ImageResetSizeOperation = ImageResetSizeOperation;
3134
+ exports.OpenImageCropOperation = OpenImageCropOperation;
3135
+ exports.SetDrawingAlignOperation = SetDrawingAlignOperation;
3136
+ exports.SetDrawingArrangeOperation = SetDrawingArrangeOperation;
3137
+ exports.SetDrawingGroupOperation = SetDrawingGroupOperation;
3138
+ Object.defineProperty(exports, 'UniverDrawingUIPlugin', {
3139
+ enumerable: true,
3140
+ get: function () {
3141
+ return UniverDrawingUIPlugin;
3142
+ }
3143
+ });
3144
+ exports.getCurrentUnitInfo = getCurrentUnitInfo;
3145
+ exports.getUpdateParams = getUpdateParams;
3146
+ exports.insertGroupObject = insertGroupObject;