@univerjs/docs-drawing-ui 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,1981 +1,2002 @@
1
- var vn = Object.defineProperty;
2
- var In = (i, e, t) => e in i ? vn(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var _e = (i, e, t) => In(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { CommandType as Y, ICommandService as $, IUniverInstanceService as te, TextX as pt, JSONX as X, MemoryCursor as _n, TextXActionType as Z, LocaleService as ot, RxDisposable as Cn, UniverInstanceType as be, toDisposable as ye, FOCUSING_COMMON_DRAWINGS as it, OnLifecycle as at, LifecycleStages as st, IContextService as Bt, PositionedObjectLayoutType as k, BooleanNumber as oe, ObjectRelativeFromH as ee, ObjectRelativeFromV as V, Tools as Pe, WrapTextType as je, Direction as ge, IUndoRedoService as Ft, FOCUSING_UNIVER_EDITOR as Sn, Disposable as qe, UndoCommand as Dn, RedoCommand as En, throttle as Ct, COLORS as Pn, Plugin as On, DependentOn as Tn } from "@univerjs/core";
5
- import { Inject as pe, Injector as kt } from "@wendellhu/redi";
6
- import { ImageCropperObject as Mn, COMPONENT_IMAGE_POPUP_MENU as yn, OpenImageCropOperation as bn, ImageResetSizeOperation as Rn, DrawingCommonPanel as Nn, UniverDrawingUIPlugin as An } from "@univerjs/drawing-ui";
7
- import { IDrawingManagerService as he, DRAWING_IMAGE_ALLOW_IMAGE_LIST as xn, ArrangeTypeEnum as Ye, DRAWING_IMAGE_COUNT_LIMIT as St, ImageUploadStatusType as mt, DRAWING_IMAGE_ALLOW_SIZE as Ln, getImageSize as Un, DrawingTypeEnum as Bn, getDrawingShapeKeyByDrawingSearch as Fn, DRAWING_IMAGE_WIDTH_LIMIT as Dt, DRAWING_IMAGE_HEIGHT_LIMIT as Et, IImageIoService as kn, UniverDrawingPlugin as Hn } from "@univerjs/drawing";
8
- import { IDocDrawingService as Re, UniverDocsDrawingPlugin as Wn } from "@univerjs/docs-drawing";
9
- import { ITextSelectionRenderManager as Ue, IRenderManagerService as se, DocumentEditArea as xe, Liquid as Ht, PageLayoutType as Pt, NodePositionConvertToCursor as Ot, getOneTextSelectionRange as Tt, DocumentSkeletonPageType as Mt, Vector2 as Gn, getAnchorBounding as Vn, Rect as jn, getColor as $n, TEXT_RANGE_LAYER_INDEX as zn } from "@univerjs/engine-render";
10
- import { takeUntil as yt, BehaviorSubject as qn } from "rxjs";
11
- import { DocCanvasPopManagerService as Xn, docDrawingPositionToTransform as Kn } from "@univerjs/docs-ui";
12
- import { RichTextEditingMutation as Q, getRichTextEditPath as $e, DocSkeletonManagerService as ae, TextSelectionManagerService as gt, getRetainAndDeleteFromReplace as Yn, SetDocZoomRatioOperation as Zn, getDocObject as Qn } from "@univerjs/docs";
13
- import { ISidebarService as Jn, MenuItemType as Wt, MenuPosition as ei, MenuGroup as ti, getMenuHiddenObservable as Gt, KeyCode as Le, ComponentManager as ni, IMenuService as ii, IShortcutService as ri, IMessageService as oi, IEditorService as ai } from "@univerjs/ui";
14
- import { useDependency as re } from "@wendellhu/redi/react-bindings";
15
- import d, { forwardRef as Vt, useRef as jt, createElement as $t, useState as ie, useEffect as ht } from "react";
16
- import j from "clsx";
17
- import { RadioGroup as bt, Radio as Ee, InputNumber as Ae, Select as Rt, Checkbox as si, MessageType as Nt } from "@univerjs/design";
18
- const wt = {
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
+ import { CommandType, ICommandService, IUniverInstanceService, TextX, JSONX, MemoryCursor, TextXActionType, LocaleService, RxDisposable, UniverInstanceType, toDisposable, FOCUSING_COMMON_DRAWINGS, OnLifecycle, LifecycleStages, Inject, IContextService, useDependency, PositionedObjectLayoutType, BooleanNumber, ObjectRelativeFromH, ObjectRelativeFromV, Tools, WrapTextType, Direction, IUndoRedoService, FOCUSING_UNIVER_EDITOR, Disposable, Injector, UndoCommand, RedoCommand, throttle, COLORS, Plugin, DependentOn } from "@univerjs/core";
6
+ import { ImageCropperObject, COMPONENT_IMAGE_POPUP_MENU, OpenImageCropOperation, ImageResetSizeOperation, DrawingCommonPanel, UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
7
+ import { IDrawingManagerService, DRAWING_IMAGE_ALLOW_IMAGE_LIST, ArrangeTypeEnum, DRAWING_IMAGE_COUNT_LIMIT, ImageUploadStatusType, DRAWING_IMAGE_ALLOW_SIZE, getImageSize, DrawingTypeEnum, getDrawingShapeKeyByDrawingSearch, DRAWING_IMAGE_WIDTH_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, IImageIoService, UniverDrawingPlugin } from "@univerjs/drawing";
8
+ import { IDocDrawingService, UniverDocsDrawingPlugin } from "@univerjs/docs-drawing";
9
+ import { ITextSelectionRenderManager, IRenderManagerService, DocumentEditArea, Liquid, PageLayoutType, NodePositionConvertToCursor, getOneTextSelectionRange, DocumentSkeletonPageType, Vector2, getAnchorBounding, Rect, getColor, TEXT_RANGE_LAYER_INDEX } from "@univerjs/engine-render";
10
+ import { takeUntil, BehaviorSubject } from "rxjs";
11
+ import { DocCanvasPopManagerService, docDrawingPositionToTransform } from "@univerjs/docs-ui";
12
+ import { RichTextEditingMutation, getRichTextEditPath, DocSkeletonManagerService, TextSelectionManagerService, getRetainAndDeleteFromReplace, SetDocZoomRatioOperation, getDocObject } from "@univerjs/docs";
13
+ import { ISidebarService, MenuItemType, MenuPosition, MenuGroup, getMenuHiddenObservable, KeyCode, ComponentManager, IMenuService, IShortcutService, IMessageService, IEditorService } from "@univerjs/ui";
14
+ import React, { forwardRef, useRef, createElement, useState, useEffect } from "react";
15
+ import clsx from "clsx";
16
+ import { RadioGroup, Radio, InputNumber, Select, Checkbox, MessageType } from "@univerjs/design";
17
+ const RemoveDocDrawingCommand = {
19
18
  id: "doc.command.remove-doc-image",
20
- type: Y.COMMAND,
19
+ type: CommandType.COMMAND,
21
20
  // eslint-disable-next-line max-lines-per-function
22
- handler: (i, e) => {
23
- var C, O, y, T;
24
- const t = i.get($), n = i.get(te), r = i.get(Ue), o = n.getCurrentUniverDocInstance();
25
- if (e == null || o == null)
21
+ handler: /* @__PURE__ */ __name((accessor, params) => {
22
+ var _a8, _b, _c, _d;
23
+ const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), textSelectionRenderManager = accessor.get(ITextSelectionRenderManager), documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
24
+ if (params == null || documentDataModel == null)
26
25
  return !1;
27
- const { drawings: a } = e, s = (C = r.getSegment()) != null ? C : "", l = new pt(), c = X.getInstance(), m = (y = (O = o.getSelfOrHeaderFooterModel(s).getBody()) == null ? void 0 : O.customBlocks) != null ? y : [], u = a.map((N) => m.find((R) => R.blockId === N.drawingId)).filter((N) => !!N).sort((N, R) => N.startIndex > R.startIndex ? 1 : -1), f = a[0].unitId, h = new _n();
28
- h.reset();
29
- const p = u[0].startIndex, w = [
26
+ const { drawings: removeDrawings } = params, segmentId = (_a8 = textSelectionRenderManager.getSegment()) != null ? _a8 : "", textX = new TextX(), jsonX = JSONX.getInstance(), customBlocks = (_c = (_b = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _b.customBlocks) != null ? _c : [], removeCustomBlocks = removeDrawings.map((drawing) => customBlocks.find((customBlock) => customBlock.blockId === drawing.drawingId)).filter((block) => !!block).sort((a, b) => a.startIndex > b.startIndex ? 1 : -1), unitId = removeDrawings[0].unitId, memoryCursor = new MemoryCursor();
27
+ memoryCursor.reset();
28
+ const cursorIndex = removeCustomBlocks[0].startIndex, textRanges = [
30
29
  {
31
- startOffset: p,
32
- endOffset: p
30
+ startOffset: cursorIndex,
31
+ endOffset: cursorIndex
33
32
  }
34
- ], v = {
35
- id: Q.id,
33
+ ], doMutation = {
34
+ id: RichTextEditingMutation.id,
36
35
  params: {
37
- unitId: f,
36
+ unitId,
38
37
  actions: [],
39
- textRanges: w
38
+ textRanges
40
39
  }
41
- }, I = [];
42
- for (const N of u) {
43
- const { startIndex: R } = N;
44
- R > h.cursor && l.push({
45
- t: Z.RETAIN,
46
- len: R - h.cursor,
40
+ }, rawActions = [];
41
+ for (const block of removeCustomBlocks) {
42
+ const { startIndex } = block;
43
+ startIndex > memoryCursor.cursor && textX.push({
44
+ t: TextXActionType.RETAIN,
45
+ len: startIndex - memoryCursor.cursor,
47
46
  segmentId: ""
48
- }), l.push({
49
- t: Z.DELETE,
47
+ }), textX.push({
48
+ t: TextXActionType.DELETE,
50
49
  len: 1,
51
50
  line: 0,
52
51
  segmentId: ""
53
- }), h.moveCursorTo(R + 1);
52
+ }), memoryCursor.moveCursorTo(startIndex + 1);
54
53
  }
55
- const D = $e(o, s);
56
- I.push(c.editOp(l.serialize(), D));
57
- for (const N of u) {
58
- const { blockId: R } = N, E = ((T = o.getDrawings()) != null ? T : {})[R], z = o.getDrawingsOrder().indexOf(R), U = c.removeOp(["drawings", R], E), B = c.removeOp(["drawingsOrder", z], R);
59
- I.push(U), I.push(B);
54
+ const path = getRichTextEditPath(documentDataModel, segmentId);
55
+ rawActions.push(jsonX.editOp(textX.serialize(), path));
56
+ for (const block of removeCustomBlocks) {
57
+ const { blockId } = block, drawing = ((_d = documentDataModel.getDrawings()) != null ? _d : {})[blockId], drawingIndex = documentDataModel.getDrawingsOrder().indexOf(blockId), removeDrawingAction = jsonX.removeOp(["drawings", blockId], drawing), removeDrawingOrderAction = jsonX.removeOp(["drawingsOrder", drawingIndex], blockId);
58
+ rawActions.push(removeDrawingAction), rawActions.push(removeDrawingOrderAction);
60
59
  }
61
- return v.params.actions = I.reduce((N, R) => X.compose(N, R), null), !!t.syncExecuteCommand(v.id, v.params);
62
- }
63
- }, zt = "COMPONENT_DOC_DRAWING_PANEL", qt = {
60
+ return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
61
+ }, "handler")
62
+ }, COMPONENT_DOC_DRAWING_PANEL = "COMPONENT_DOC_DRAWING_PANEL", SidebarDocDrawingOperation = {
64
63
  id: "sidebar.operation.doc-image",
65
- type: Y.COMMAND,
66
- handler: async (i, e) => {
67
- const t = i.get(Jn), n = i.get(ot), r = i.get(he);
68
- switch (e.value) {
64
+ type: CommandType.COMMAND,
65
+ handler: /* @__PURE__ */ __name(async (accessor, params) => {
66
+ const sidebarService = accessor.get(ISidebarService), localeService = accessor.get(LocaleService), drawingManagerService = accessor.get(IDrawingManagerService);
67
+ switch (params.value) {
69
68
  case "open":
70
- t.open({
71
- header: { title: n.t("docImage.panel.title") },
72
- children: { label: zt },
73
- onClose: () => {
74
- r.focusDrawing(null);
75
- },
69
+ sidebarService.open({
70
+ header: { title: localeService.t("docImage.panel.title") },
71
+ children: { label: COMPONENT_DOC_DRAWING_PANEL },
72
+ onClose: /* @__PURE__ */ __name(() => {
73
+ drawingManagerService.focusDrawing(null);
74
+ }, "onClose"),
76
75
  width: 360
77
76
  });
78
77
  break;
79
78
  case "close":
80
79
  default:
81
- t.close();
80
+ sidebarService.close();
82
81
  break;
83
82
  }
84
83
  return !0;
85
- }
86
- }, Xt = {
84
+ }, "handler")
85
+ }, EditDocDrawingOperation = {
87
86
  id: "doc.operation.edit-doc-image",
88
- type: Y.OPERATION,
89
- handler: (i, e) => {
90
- const t = i.get(he), n = i.get($);
91
- return e == null ? !1 : (t.focusDrawing([e]), n.executeCommand(qt.id, { value: "open" }), !0);
92
- }
87
+ type: CommandType.OPERATION,
88
+ handler: /* @__PURE__ */ __name((accessor, params) => {
89
+ const drawingManagerService = accessor.get(IDrawingManagerService), commandService = accessor.get(ICommandService);
90
+ return params == null ? !1 : (drawingManagerService.focusDrawing([params]), commandService.executeCommand(SidebarDocDrawingOperation.id, { value: "open" }), !0);
91
+ }, "handler")
93
92
  };
94
- var ci = Object.defineProperty, li = Object.getOwnPropertyDescriptor, di = (i, e, t, n) => {
95
- for (var r = n > 1 ? void 0 : n ? li(e, t) : e, o = i.length - 1, a; o >= 0; o--)
96
- (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
97
- return n && r && ci(e, t, r), r;
98
- }, ke = (i, e) => (t, n) => e(t, n, i);
99
- let Je = class extends Cn {
100
- constructor(e, t, n, r, o) {
93
+ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
94
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
95
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
96
+ return kind && result && __defProp$6(target, key, result), result;
97
+ }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a;
98
+ let DocDrawingPopupMenuController = (_a = class extends RxDisposable {
99
+ constructor(_drawingManagerService, _canvasPopManagerService, _renderManagerService, _univerInstanceService, _contextService) {
101
100
  super();
102
- _e(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
103
- this._drawingManagerService = e, this._canvasPopManagerService = t, this._renderManagerService = n, this._univerInstanceService = r, this._contextService = o, this._init();
101
+ __publicField(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
102
+ this._drawingManagerService = _drawingManagerService, this._canvasPopManagerService = _canvasPopManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._contextService = _contextService, this._init();
104
103
  }
105
104
  _init() {
106
- this._univerInstanceService.getCurrentTypeOfUnit$(be.UNIVER_DOC).pipe(yt(this.dispose$)).subscribe((e) => this._create(e)), this._univerInstanceService.getTypeOfUnitDisposed$(be.UNIVER_DOC).pipe(yt(this.dispose$)).subscribe((e) => this._dispose(e)), this._univerInstanceService.getAllUnitsForType(be.UNIVER_DOC).forEach((e) => this._create(e));
105
+ this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((documentDataModel) => this._create(documentDataModel)), this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((documentDataModel) => this._dispose(documentDataModel)), this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_DOC).forEach((documentDataModel) => this._create(documentDataModel));
107
106
  }
108
- _dispose(e) {
109
- const t = e.getUnitId();
110
- this._renderManagerService.removeRender(t);
107
+ _dispose(documentDataModel) {
108
+ const unitId = documentDataModel.getUnitId();
109
+ this._renderManagerService.removeRender(unitId);
111
110
  }
112
- _create(e) {
113
- if (!e)
111
+ _create(documentDataModel) {
112
+ if (!documentDataModel)
114
113
  return;
115
- const t = e.getUnitId();
116
- this._renderManagerService.has(t) && !this._initImagePopupMenu.has(t) && (this._popupMenuListener(t), this._initImagePopupMenu.add(t));
114
+ const unitId = documentDataModel.getUnitId();
115
+ this._renderManagerService.has(unitId) && !this._initImagePopupMenu.has(unitId) && (this._popupMenuListener(unitId), this._initImagePopupMenu.add(unitId));
117
116
  }
118
- _hasCropObject(e) {
119
- const t = e.getAllObjects();
120
- for (const n of t)
121
- if (n instanceof Mn)
117
+ _hasCropObject(scene) {
118
+ const objects = scene.getAllObjects();
119
+ for (const object of objects)
120
+ if (object instanceof ImageCropperObject)
122
121
  return !0;
123
122
  return !1;
124
123
  }
125
124
  // eslint-disable-next-line max-lines-per-function
126
- _popupMenuListener(e) {
127
- var o;
128
- const t = (o = this._renderManagerService.getRenderById(e)) == null ? void 0 : o.scene;
129
- if (!t)
125
+ _popupMenuListener(unitId) {
126
+ var _a8;
127
+ const scene = (_a8 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a8.scene;
128
+ if (!scene)
130
129
  return;
131
- const n = t.getTransformerByCreate();
132
- if (!n)
130
+ const transformer = scene.getTransformerByCreate();
131
+ if (!transformer)
133
132
  return;
134
- const r = [];
133
+ const disposePopups = [];
135
134
  this.disposeWithMe(
136
- ye(
137
- n.createControl$.subscribe(() => {
138
- if (this._hasCropObject(t))
135
+ toDisposable(
136
+ transformer.createControl$.subscribe(() => {
137
+ if (this._hasCropObject(scene))
139
138
  return;
140
- const a = n.getSelectedObjectMap();
141
- if (r.forEach((w) => w.dispose()), r.length = 0, a.size > 1)
139
+ const selectedObjects = transformer.getSelectedObjectMap();
140
+ if (disposePopups.forEach((dispose) => dispose.dispose()), disposePopups.length = 0, selectedObjects.size > 1)
142
141
  return;
143
- const s = a.values().next().value;
144
- if (!s)
142
+ const object = selectedObjects.values().next().value;
143
+ if (!object)
145
144
  return;
146
- const l = s.oKey, c = this._drawingManagerService.getDrawingOKey(l);
147
- if (!c)
145
+ const oKey = object.oKey, drawingParam = this._drawingManagerService.getDrawingOKey(oKey);
146
+ if (!drawingParam)
148
147
  return;
149
- const { unitId: m, subUnitId: u, drawingId: f } = c;
150
- r.push(this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s, {
151
- componentKey: yn,
148
+ const { unitId: unitId2, subUnitId, drawingId } = drawingParam;
149
+ disposePopups.push(this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
150
+ componentKey: COMPONENT_IMAGE_POPUP_MENU,
152
151
  direction: "horizontal",
153
152
  offset: [2, 0],
154
153
  extraProps: {
155
- menuItems: this._getImageMenuItems(m, u, f)
154
+ menuItems: this._getImageMenuItems(unitId2, subUnitId, drawingId)
156
155
  }
157
- }))), !this._drawingManagerService.getFocusDrawings().find((w) => w.unitId === m && w.subUnitId === u && w.drawingId === f) && this._drawingManagerService.focusDrawing([{
158
- unitId: m,
159
- subUnitId: u,
160
- drawingId: f
156
+ }))), !this._drawingManagerService.getFocusDrawings().find((drawing) => drawing.unitId === unitId2 && drawing.subUnitId === subUnitId && drawing.drawingId === drawingId) && this._drawingManagerService.focusDrawing([{
157
+ unitId: unitId2,
158
+ subUnitId,
159
+ drawingId
161
160
  }]);
162
161
  })
163
162
  )
164
163
  ), this.disposeWithMe(
165
- ye(
166
- n.clearControl$.subscribe(() => {
167
- r.forEach((a) => a.dispose()), r.length = 0, this._contextService.setContextValue(it, !1), this._drawingManagerService.focusDrawing(null);
164
+ toDisposable(
165
+ transformer.clearControl$.subscribe(() => {
166
+ disposePopups.forEach((dispose) => dispose.dispose()), disposePopups.length = 0, this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1), this._drawingManagerService.focusDrawing(null);
168
167
  })
169
168
  )
170
169
  ), this.disposeWithMe(
171
- ye(
172
- n.changing$.subscribe(() => {
173
- r.forEach((a) => a.dispose()), r.length = 0;
170
+ toDisposable(
171
+ transformer.changing$.subscribe(() => {
172
+ disposePopups.forEach((dispose) => dispose.dispose()), disposePopups.length = 0;
174
173
  })
175
174
  )
176
175
  ), this.disposeWithMe(
177
- ye(
178
- n.changeStart$.subscribe(() => {
179
- r.forEach((a) => a.dispose()), r.length = 0;
176
+ toDisposable(
177
+ transformer.changeStart$.subscribe(() => {
178
+ disposePopups.forEach((dispose) => dispose.dispose()), disposePopups.length = 0;
180
179
  })
181
180
  )
182
181
  );
183
182
  }
184
- _getImageMenuItems(e, t, n) {
183
+ _getImageMenuItems(unitId, subUnitId, drawingId) {
185
184
  return [
186
185
  {
187
186
  label: "image-popup.edit",
188
187
  index: 0,
189
- commandId: Xt.id,
190
- commandParams: { unitId: e, subUnitId: t, drawingId: n },
188
+ commandId: EditDocDrawingOperation.id,
189
+ commandParams: { unitId, subUnitId, drawingId },
191
190
  disable: !1
192
191
  },
193
192
  {
194
193
  label: "image-popup.delete",
195
194
  index: 1,
196
- commandId: wt.id,
197
- commandParams: { unitId: e, drawings: [{ unitId: e, subUnitId: t, drawingId: n }] },
195
+ commandId: RemoveDocDrawingCommand.id,
196
+ commandParams: { unitId, drawings: [{ unitId, subUnitId, drawingId }] },
198
197
  disable: !1
199
198
  },
200
199
  {
201
200
  label: "image-popup.crop",
202
201
  index: 2,
203
- commandId: bn.id,
204
- commandParams: { unitId: e, subUnitId: t, drawingId: n },
202
+ commandId: OpenImageCropOperation.id,
203
+ commandParams: { unitId, subUnitId, drawingId },
205
204
  disable: !0
206
205
  // TODO: @JOCS, feature is not ready.
207
206
  },
208
207
  {
209
208
  label: "image-popup.reset",
210
209
  index: 3,
211
- commandId: Rn.id,
212
- commandParams: [{ unitId: e, subUnitId: t, drawingId: n }],
210
+ commandId: ImageResetSizeOperation.id,
211
+ commandParams: [{ unitId, subUnitId, drawingId }],
213
212
  disable: !0
214
213
  // TODO: @JOCS, feature is not ready.
215
214
  }
216
215
  ];
217
216
  }
218
- };
219
- Je = di([
220
- at(st.Rendered, Je),
221
- ke(0, he),
222
- ke(1, pe(Xn)),
223
- ke(2, se),
224
- ke(3, te),
225
- ke(4, Bt)
226
- ], Je);
227
- var ue = function() {
228
- return ue = Object.assign || function(i) {
229
- for (var e, t = 1, n = arguments.length; t < n; t++) {
230
- e = arguments[t];
231
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (i[r] = e[r]);
217
+ }, __name(_a, "DocDrawingPopupMenuController"), _a);
218
+ DocDrawingPopupMenuController = __decorateClass$6([
219
+ OnLifecycle(LifecycleStages.Rendered, DocDrawingPopupMenuController),
220
+ __decorateParam$6(0, IDrawingManagerService),
221
+ __decorateParam$6(1, Inject(DocCanvasPopManagerService)),
222
+ __decorateParam$6(2, IRenderManagerService),
223
+ __decorateParam$6(3, IUniverInstanceService),
224
+ __decorateParam$6(4, IContextService)
225
+ ], DocDrawingPopupMenuController);
226
+ var __assign = function() {
227
+ return __assign = Object.assign || function(t) {
228
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
229
+ s = arguments[i];
230
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
232
231
  }
233
- return i;
234
- }, ue.apply(this, arguments);
235
- }, mi = function(i, e) {
232
+ return t;
233
+ }, __assign.apply(this, arguments);
234
+ }, __rest = function(s, e) {
236
235
  var t = {};
237
- for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && e.indexOf(n) < 0 && (t[n] = i[n]);
238
- if (i != null && typeof Object.getOwnPropertySymbols == "function")
239
- for (var r = 0, n = Object.getOwnPropertySymbols(i); r < n.length; r++)
240
- e.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(i, n[r]) && (t[n[r]] = i[n[r]]);
236
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
237
+ if (s != null && typeof Object.getOwnPropertySymbols == "function")
238
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
239
+ e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
241
240
  return t;
242
- }, Kt = Vt(function(i, e) {
243
- var t = i.icon, n = i.id, r = i.className, o = i.extend, a = mi(i, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), l = jt("_".concat(fi()));
244
- return Yt(t, "".concat(n), { defIds: t.defIds, idSuffix: l.current }, ue({ ref: e, className: s }, a), o);
241
+ }, IconBase = forwardRef(function(props, ref) {
242
+ var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
243
+ return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
245
244
  });
246
- function Yt(i, e, t, n, r) {
247
- return $t(i.tag, ue(ue({ key: e }, gi(i, t, r)), n), (ui(i, t).children || []).map(function(o, a) {
248
- return Yt(o, "".concat(e, "-").concat(i.tag, "-").concat(a), t, void 0, r);
245
+ function render(node, id, runtimeProps, rootProps, extend) {
246
+ return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
247
+ return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
249
248
  }));
250
249
  }
251
- function gi(i, e, t) {
252
- var n = ue({}, i.attrs);
253
- t != null && t.colorChannel1 && n.fill === "colorChannel1" && (n.fill = t.colorChannel1);
254
- var r = e.defIds;
255
- return !r || r.length === 0 || (i.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(o) {
256
- var a = o[0], s = o[1];
257
- typeof s == "string" && (n[a] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
258
- })), n;
250
+ __name(render, "render");
251
+ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
252
+ var attrs = __assign({}, node.attrs);
253
+ extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
254
+ var defIds = runtimeProps.defIds;
255
+ return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a8) {
256
+ var key = _a8[0], value = _a8[1];
257
+ typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
258
+ })), attrs;
259
259
  }
260
- function ui(i, e) {
261
- var t, n = e.defIds;
262
- return !n || n.length === 0 ? i : i.tag === "defs" && (!((t = i.children) === null || t === void 0) && t.length) ? ue(ue({}, i), { children: i.children.map(function(r) {
263
- return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? ue(ue({}, r), { attrs: ue(ue({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
264
- }) }) : i;
260
+ __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
261
+ function replaceRuntimeIdsInDefs(node, runtimeProps) {
262
+ var _a8, defIds = runtimeProps.defIds;
263
+ return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a8 = node.children) === null || _a8 === void 0) && _a8.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
264
+ return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
265
+ }) }) : node;
265
266
  }
266
- function fi() {
267
+ __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
268
+ function generateShortUuid() {
267
269
  return Math.random().toString(36).substring(2, 8);
268
270
  }
269
- Kt.displayName = "UniverIcon";
270
- var pi = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, Zt = Vt(function(i, e) {
271
- return $t(Kt, Object.assign({}, i, {
271
+ __name(generateShortUuid, "generateShortUuid");
272
+ IconBase.displayName = "UniverIcon";
273
+ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, AddImageSingle = forwardRef(function(props, ref) {
274
+ return createElement(IconBase, Object.assign({}, props, {
272
275
  id: "add-image-single",
273
- ref: e,
274
- icon: pi
276
+ ref,
277
+ icon: element
275
278
  }));
276
279
  });
277
- Zt.displayName = "AddImageSingle";
278
- const vt = {
280
+ AddImageSingle.displayName = "AddImageSingle";
281
+ const InsertDocImageOperation = {
279
282
  id: "doc.operation.insert-float-image",
280
- type: Y.OPERATION,
281
- handler: () => !0
282
- }, hi = "univer-upload-file-menu", wi = "univer-upload-file-menu-input", At = {
283
- uploadFileMenu: hi,
284
- uploadFileMenuInput: wi
285
- }, vi = () => {
286
- const i = re($), e = jt(null), t = () => {
287
- var o;
288
- (o = e.current) == null || o.click();
289
- }, n = xn.map((o) => `.${o.replace("image/", "")}`).join(","), r = (o) => {
290
- const a = o.target.files;
291
- if (a == null)
283
+ type: CommandType.OPERATION,
284
+ handler: /* @__PURE__ */ __name(() => !0, "handler")
285
+ }, uploadFileMenu = "univer-upload-file-menu", uploadFileMenuInput = "univer-upload-file-menu-input", styles$1 = {
286
+ uploadFileMenu,
287
+ uploadFileMenuInput
288
+ }, UploadFileMenu = /* @__PURE__ */ __name(() => {
289
+ const commandService = useDependency(ICommandService), fileInputRef = useRef(null), handleButtonClick = /* @__PURE__ */ __name(() => {
290
+ var _a8;
291
+ (_a8 = fileInputRef.current) == null || _a8.click();
292
+ }, "handleButtonClick"), imageAccept = DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(","), handleFileChange = /* @__PURE__ */ __name((event) => {
293
+ const fileList = event.target.files;
294
+ if (fileList == null)
292
295
  return;
293
- const s = Array.from(a);
294
- i.executeCommand(vt.id, { files: s }), e.current && (e.current.value = "");
295
- };
296
- return /* @__PURE__ */ d.createElement("div", { onClick: t, className: At.uploadFileMenu }, /* @__PURE__ */ d.createElement(
296
+ const files = Array.from(fileList);
297
+ commandService.executeCommand(InsertDocImageOperation.id, { files }), fileInputRef.current && (fileInputRef.current.value = "");
298
+ }, "handleFileChange");
299
+ return /* @__PURE__ */ React.createElement("div", { onClick: handleButtonClick, className: styles$1.uploadFileMenu }, /* @__PURE__ */ React.createElement(
297
300
  "input",
298
301
  {
299
302
  type: "file",
300
- className: At.uploadFileMenuInput,
301
- ref: e,
302
- onChange: r,
303
- accept: n,
303
+ className: styles$1.uploadFileMenuInput,
304
+ ref: fileInputRef,
305
+ onChange: handleFileChange,
306
+ accept: imageAccept,
304
307
  multiple: !0
305
308
  }
306
309
  ));
307
- }, Qt = "COMPONENT_DOC_UPLOAD_FILE_MENU", Jt = "addition-and-subtraction-single", en = "doc.menu.image", Ii = "doc.menu.image.upload.float";
308
- function _i(i) {
310
+ }, "UploadFileMenu"), COMPONENT_DOC_UPLOAD_FILE_MENU = "COMPONENT_DOC_UPLOAD_FILE_MENU", ImageUploadIcon = "addition-and-subtraction-single", IMAGE_MENU_ID = "doc.menu.image", IMAGE_MENU_UPLOAD_FLOAT_ID = "doc.menu.image.upload.float";
311
+ function ImageMenuFactory(accessor) {
309
312
  return {
310
- id: en,
311
- type: Wt.SUBITEMS,
312
- positions: [ei.TOOLBAR_START],
313
- group: ti.TOOLBAR_LAYOUT,
314
- icon: Jt,
313
+ id: IMAGE_MENU_ID,
314
+ type: MenuItemType.SUBITEMS,
315
+ positions: [MenuPosition.TOOLBAR_START],
316
+ group: MenuGroup.TOOLBAR_LAYOUT,
317
+ icon: ImageUploadIcon,
315
318
  tooltip: "docImage.title",
316
- hidden$: Gt(i, be.UNIVER_DOC)
319
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
317
320
  };
318
321
  }
319
- function Ci(i) {
322
+ __name(ImageMenuFactory, "ImageMenuFactory");
323
+ function UploadFloatImageMenuFactory(_accessor) {
320
324
  return {
321
- id: Ii,
325
+ id: IMAGE_MENU_UPLOAD_FLOAT_ID,
322
326
  title: "docImage.upload.float",
323
- type: Wt.SELECTOR,
327
+ type: MenuItemType.SELECTOR,
324
328
  label: {
325
- name: Qt
329
+ name: COMPONENT_DOC_UPLOAD_FILE_MENU
326
330
  },
327
- positions: [en],
328
- hidden$: Gt(i, be.UNIVER_DOC)
331
+ positions: [IMAGE_MENU_ID],
332
+ hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_DOC)
329
333
  };
330
334
  }
331
- const Si = "univer-image-common-panel", Di = "univer-image-common-panel-grid", Ei = "univer-image-common-panel-border", Pi = "univer-image-common-panel-title", Oi = "univer-image-common-panel-subtitle", Ti = "univer-image-common-panel-row", Mi = "univer-image-common-panel-row-vertical", yi = "univer-image-common-panel-column", bi = "univer-image-common-panel-column-center", Ri = "univer-image-common-panel-inline", Ni = "univer-image-common-panel-span2", Ai = "univer-image-common-panel-span3", xi = "univer-image-common-panel-input", Li = "univer-sheet-image-menu", Ui = "univer-sheet-image-menu-input", g = {
332
- imageCommonPanel: Si,
333
- imageCommonPanelGrid: Di,
334
- imageCommonPanelBorder: Ei,
335
- imageCommonPanelTitle: Pi,
336
- imageCommonPanelSubtitle: Oi,
337
- imageCommonPanelRow: Ti,
338
- imageCommonPanelRowVertical: Mi,
339
- imageCommonPanelColumn: yi,
340
- imageCommonPanelColumnCenter: bi,
341
- imageCommonPanelInline: Ri,
342
- imageCommonPanelSpan2: Ni,
343
- imageCommonPanelSpan3: Ai,
344
- imageCommonPanelInput: xi,
345
- sheetImageMenu: Li,
346
- sheetImageMenuInput: Ui
347
- };
348
- class ct {
335
+ __name(UploadFloatImageMenuFactory, "UploadFloatImageMenuFactory");
336
+ const imageCommonPanel = "univer-image-common-panel", imageCommonPanelGrid = "univer-image-common-panel-grid", imageCommonPanelBorder = "univer-image-common-panel-border", imageCommonPanelTitle = "univer-image-common-panel-title", imageCommonPanelSubtitle = "univer-image-common-panel-subtitle", imageCommonPanelRow = "univer-image-common-panel-row", imageCommonPanelRowVertical = "univer-image-common-panel-row-vertical", imageCommonPanelColumn = "univer-image-common-panel-column", imageCommonPanelColumnCenter = "univer-image-common-panel-column-center", imageCommonPanelInline = "univer-image-common-panel-inline", imageCommonPanelSpan2 = "univer-image-common-panel-span2", imageCommonPanelSpan3 = "univer-image-common-panel-span3", imageCommonPanelInput = "univer-image-common-panel-input", sheetImageMenu = "univer-sheet-image-menu", sheetImageMenuInput = "univer-sheet-image-menu-input", styles = {
337
+ imageCommonPanel,
338
+ imageCommonPanelGrid,
339
+ imageCommonPanelBorder,
340
+ imageCommonPanelTitle,
341
+ imageCommonPanelSubtitle,
342
+ imageCommonPanelRow,
343
+ imageCommonPanelRowVertical,
344
+ imageCommonPanelColumn,
345
+ imageCommonPanelColumnCenter,
346
+ imageCommonPanelInline,
347
+ imageCommonPanelSpan2,
348
+ imageCommonPanelSpan3,
349
+ imageCommonPanelInput,
350
+ sheetImageMenu,
351
+ sheetImageMenuInput
352
+ }, _DocRefreshDrawingsService = class _DocRefreshDrawingsService {
349
353
  constructor() {
350
- _e(this, "_refreshDrawings$", new qn(null));
351
- _e(this, "refreshDrawings$", this._refreshDrawings$.asObservable());
354
+ __publicField(this, "_refreshDrawings$", new BehaviorSubject(null));
355
+ __publicField(this, "refreshDrawings$", this._refreshDrawings$.asObservable());
352
356
  }
353
- refreshDrawings(e) {
354
- this._refreshDrawings$.next(e);
357
+ refreshDrawings(skeleton) {
358
+ this._refreshDrawings$.next(skeleton);
355
359
  }
356
- }
357
- var me = /* @__PURE__ */ ((i) => (i.INLINE = "inline", i.BEHIND_TEXT = "behindText", i.IN_FRONT_OF_TEXT = "inFrontOfText", i.WRAP_SQUARE = "wrapSquare", i.WRAP_TOP_AND_BOTTOM = "wrapTopAndBottom", i))(me || {});
358
- const Bi = {
359
- inline: k.INLINE,
360
- wrapSquare: k.WRAP_SQUARE,
361
- wrapTopAndBottom: k.WRAP_TOP_AND_BOTTOM,
362
- inFrontOfText: k.WRAP_NONE,
363
- behindText: k.WRAP_NONE
364
360
  };
365
- function tn(i, e, t, n, r, o, a) {
366
- var h, p;
367
- const s = new pt(), l = X.getInstance(), c = [], m = o.getSelfOrHeaderFooterModel(e).getBody(), u = o.getSelfOrHeaderFooterModel(i).getBody();
368
- if (m == null || u == null)
361
+ __name(_DocRefreshDrawingsService, "DocRefreshDrawingsService");
362
+ let DocRefreshDrawingsService = _DocRefreshDrawingsService;
363
+ var TextWrappingStyle = /* @__PURE__ */ ((TextWrappingStyle2) => (TextWrappingStyle2.INLINE = "inline", TextWrappingStyle2.BEHIND_TEXT = "behindText", TextWrappingStyle2.IN_FRONT_OF_TEXT = "inFrontOfText", TextWrappingStyle2.WRAP_SQUARE = "wrapSquare", TextWrappingStyle2.WRAP_TOP_AND_BOTTOM = "wrapTopAndBottom", TextWrappingStyle2))(TextWrappingStyle || {});
364
+ const WRAPPING_STYLE_TO_LAYOUT_TYPE = {
365
+ inline: PositionedObjectLayoutType.INLINE,
366
+ wrapSquare: PositionedObjectLayoutType.WRAP_SQUARE,
367
+ wrapTopAndBottom: PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM,
368
+ inFrontOfText: PositionedObjectLayoutType.WRAP_NONE,
369
+ behindText: PositionedObjectLayoutType.WRAP_NONE
370
+ };
371
+ function getDeleteAndInsertCustomBlockActions(segmentId, oldSegmentId, segmentPage, offset, drawingId, documentDataModel, textSelectionRenderManager) {
372
+ var _a8, _b;
373
+ const textX = new TextX(), jsonX = JSONX.getInstance(), rawActions = [], oldBody = documentDataModel.getSelfOrHeaderFooterModel(oldSegmentId).getBody(), body = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
374
+ if (oldBody == null || body == null)
369
375
  return;
370
- const f = (p = (h = m.customBlocks) == null ? void 0 : h.find((w) => w.blockId === r)) == null ? void 0 : p.startIndex;
371
- if (f != null) {
372
- if (n = Math.min(u.dataStream.length - 2, n), i === e) {
373
- if (n < f ? (n > 0 && s.push({
374
- t: Z.RETAIN,
375
- len: n,
376
- segmentId: e
377
- }), s.push({
378
- t: Z.INSERT,
376
+ const oldOffset = (_b = (_a8 = oldBody.customBlocks) == null ? void 0 : _a8.find((block) => block.blockId === drawingId)) == null ? void 0 : _b.startIndex;
377
+ if (oldOffset != null) {
378
+ if (offset = Math.min(body.dataStream.length - 2, offset), segmentId === oldSegmentId) {
379
+ if (offset < oldOffset ? (offset > 0 && textX.push({
380
+ t: TextXActionType.RETAIN,
381
+ len: offset,
382
+ segmentId: oldSegmentId
383
+ }), textX.push({
384
+ t: TextXActionType.INSERT,
379
385
  body: {
380
386
  dataStream: "\b",
381
387
  customBlocks: [{
382
388
  startIndex: 0,
383
- blockId: r
389
+ blockId: drawingId
384
390
  }]
385
391
  },
386
392
  len: 1,
387
393
  line: 0,
388
- segmentId: e
389
- }), s.push({
390
- t: Z.RETAIN,
391
- len: f - n,
392
- segmentId: e
393
- }), s.push({
394
- t: Z.DELETE,
394
+ segmentId: oldSegmentId
395
+ }), textX.push({
396
+ t: TextXActionType.RETAIN,
397
+ len: oldOffset - offset,
398
+ segmentId: oldSegmentId
399
+ }), textX.push({
400
+ t: TextXActionType.DELETE,
395
401
  len: 1,
396
402
  line: 0,
397
403
  segmentId: ""
398
- })) : (f > 0 && s.push({
399
- t: Z.RETAIN,
400
- len: f,
401
- segmentId: e
402
- }), s.push({
403
- t: Z.DELETE,
404
+ })) : (oldOffset > 0 && textX.push({
405
+ t: TextXActionType.RETAIN,
406
+ len: oldOffset,
407
+ segmentId: oldSegmentId
408
+ }), textX.push({
409
+ t: TextXActionType.DELETE,
404
410
  len: 1,
405
411
  line: 0,
406
412
  segmentId: ""
407
- }), n - f - 1 > 0 && s.push({
408
- t: Z.RETAIN,
409
- len: n - f - 1,
410
- segmentId: e
411
- }), s.push({
412
- t: Z.INSERT,
413
+ }), offset - oldOffset - 1 > 0 && textX.push({
414
+ t: TextXActionType.RETAIN,
415
+ len: offset - oldOffset - 1,
416
+ segmentId: oldSegmentId
417
+ }), textX.push({
418
+ t: TextXActionType.INSERT,
413
419
  body: {
414
420
  dataStream: "\b",
415
421
  customBlocks: [{
416
422
  startIndex: 0,
417
- blockId: r
423
+ blockId: drawingId
418
424
  }]
419
425
  },
420
426
  len: 1,
421
427
  line: 0,
422
- segmentId: e
423
- })), n !== f) {
424
- const w = $e(o, e), v = l.editOp(s.serialize(), w);
425
- c.push(v);
428
+ segmentId: oldSegmentId
429
+ })), offset !== oldOffset) {
430
+ const path = getRichTextEditPath(documentDataModel, oldSegmentId), action = jsonX.editOp(textX.serialize(), path);
431
+ rawActions.push(action);
426
432
  }
427
433
  } else {
428
- f > 0 && s.push({
429
- t: Z.RETAIN,
430
- len: f,
431
- segmentId: e
432
- }), s.push({
433
- t: Z.DELETE,
434
+ oldOffset > 0 && textX.push({
435
+ t: TextXActionType.RETAIN,
436
+ len: oldOffset,
437
+ segmentId: oldSegmentId
438
+ }), textX.push({
439
+ t: TextXActionType.DELETE,
434
440
  len: 1,
435
441
  line: 0,
436
442
  segmentId: ""
437
443
  });
438
- let w = $e(o, e), v = l.editOp(s.serialize(), w);
439
- c.push(v), s.empty(), n > 0 && s.push({
440
- t: Z.RETAIN,
441
- len: n,
442
- segmentId: i
443
- }), s.push({
444
- t: Z.INSERT,
444
+ let path = getRichTextEditPath(documentDataModel, oldSegmentId), action = jsonX.editOp(textX.serialize(), path);
445
+ rawActions.push(action), textX.empty(), offset > 0 && textX.push({
446
+ t: TextXActionType.RETAIN,
447
+ len: offset,
448
+ segmentId
449
+ }), textX.push({
450
+ t: TextXActionType.INSERT,
445
451
  body: {
446
452
  dataStream: "\b",
447
453
  customBlocks: [{
448
454
  startIndex: 0,
449
- blockId: r
455
+ blockId: drawingId
450
456
  }]
451
457
  },
452
458
  len: 1,
453
459
  line: 0,
454
- segmentId: i
455
- }), w = $e(o, i), v = l.editOp(s.serialize(), w), c.push(v), a.setSegment(i), a.setSegmentPage(t);
460
+ segmentId
461
+ }), path = getRichTextEditPath(documentDataModel, segmentId), action = jsonX.editOp(textX.serialize(), path), rawActions.push(action), textSelectionRenderManager.setSegment(segmentId), textSelectionRenderManager.setSegmentPage(segmentPage);
456
462
  }
457
- return c;
463
+ return rawActions;
458
464
  }
459
465
  }
460
- const nn = {
466
+ __name(getDeleteAndInsertCustomBlockActions, "getDeleteAndInsertCustomBlockActions");
467
+ const UpdateDocDrawingWrappingStyleCommand = {
461
468
  id: "doc.command.update-doc-drawing-wrapping-style",
462
- type: Y.COMMAND,
469
+ type: CommandType.COMMAND,
463
470
  // eslint-disable-next-line max-lines-per-function, complexity
464
- handler: (i, e) => {
465
- var T, N;
466
- if (e == null)
471
+ handler: /* @__PURE__ */ __name((accessor, params) => {
472
+ var _a8, _b;
473
+ if (params == null)
467
474
  return !1;
468
- const { drawings: t, wrappingStyle: n, unitId: r } = e, o = i.get($), a = i.get(te), l = i.get(se).getRenderById(r), c = l == null ? void 0 : l.with(ae).getSkeleton().getSkeletonData(), m = l == null ? void 0 : l.with(ae).getViewModel(), u = l == null ? void 0 : l.scene, f = a.getCurrentUniverDocInstance();
469
- if (f == null || c == null || u == null || m == null)
475
+ const { drawings, wrappingStyle, unitId } = params, commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), renderObject = accessor.get(IRenderManagerService).getRenderById(unitId), skeletonData = renderObject == null ? void 0 : renderObject.with(DocSkeletonManagerService).getSkeleton().getSkeletonData(), viewModel = renderObject == null ? void 0 : renderObject.with(DocSkeletonManagerService).getViewModel(), scene = renderObject == null ? void 0 : renderObject.scene, documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
476
+ if (documentDataModel == null || skeletonData == null || scene == null || viewModel == null)
470
477
  return !1;
471
- const h = m.getEditArea(), p = u.getTransformerByCreate(), { pages: w, skeHeaders: v, skeFooters: I } = c, D = X.getInstance(), _ = [], { drawings: C = {} } = f.getSnapshot();
472
- for (const R of t) {
473
- const { drawingId: E } = R, H = C[E].layoutType, z = Bi[n];
474
- if (H !== z) {
475
- const S = D.replaceOp(["drawings", E, "layoutType"], H, z);
476
- _.push(S);
478
+ const editArea = viewModel.getEditArea(), transformer = scene.getTransformerByCreate(), { pages, skeHeaders, skeFooters } = skeletonData, jsonX = JSONX.getInstance(), rawActions = [], { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
479
+ for (const drawing of drawings) {
480
+ const { drawingId } = drawing, oldLayoutType = oldDrawings[drawingId].layoutType, newLayoutType = WRAPPING_STYLE_TO_LAYOUT_TYPE[wrappingStyle];
481
+ if (oldLayoutType !== newLayoutType) {
482
+ const updateLayoutTypeAction = jsonX.replaceOp(["drawings", drawingId, "layoutType"], oldLayoutType, newLayoutType);
483
+ rawActions.push(updateLayoutTypeAction);
477
484
  }
478
- if (n === "behindText" || n === "inFrontOfText") {
479
- const S = C[E].behindDoc, A = n === "behindText" ? oe.TRUE : oe.FALSE;
480
- if (S !== A) {
481
- const P = D.replaceOp(["drawings", E, "behindDoc"], S, A);
482
- _.push(P);
485
+ if (wrappingStyle === "behindText" || wrappingStyle === "inFrontOfText") {
486
+ const oldBehindDoc = oldDrawings[drawingId].behindDoc, newBehindDoc = wrappingStyle === "behindText" ? BooleanNumber.TRUE : BooleanNumber.FALSE;
487
+ if (oldBehindDoc !== newBehindDoc) {
488
+ const updateBehindDocAction = jsonX.replaceOp(["drawings", drawingId, "behindDoc"], oldBehindDoc, newBehindDoc);
489
+ rawActions.push(updateBehindDocAction);
483
490
  }
484
491
  }
485
- if (n === "inline")
492
+ if (wrappingStyle === "inline")
486
493
  continue;
487
- let U = null, B = 0, b = 0;
488
- for (const S of w) {
489
- const { headerId: A, footerId: P, marginTop: L, marginLeft: x, marginBottom: M, pageWidth: W, pageHeight: G } = S;
490
- switch (h) {
491
- case xe.HEADER: {
492
- const F = (T = v.get(A)) == null ? void 0 : T.get(W);
493
- F != null && F.skeDrawings.has(E) && (U = F.skeDrawings.get(E), B = F.marginTop, b = x);
494
+ let skeDrawing = null, pageMarginTop = 0, pageMarginLeft = 0;
495
+ for (const page of pages) {
496
+ const { headerId, footerId, marginTop, marginLeft, marginBottom, pageWidth, pageHeight } = page;
497
+ switch (editArea) {
498
+ case DocumentEditArea.HEADER: {
499
+ const headerSke = (_a8 = skeHeaders.get(headerId)) == null ? void 0 : _a8.get(pageWidth);
500
+ headerSke != null && headerSke.skeDrawings.has(drawingId) && (skeDrawing = headerSke.skeDrawings.get(drawingId), pageMarginTop = headerSke.marginTop, pageMarginLeft = marginLeft);
494
501
  break;
495
502
  }
496
- case xe.FOOTER: {
497
- const F = (N = I.get(P)) == null ? void 0 : N.get(W);
498
- F != null && F.skeDrawings.has(E) && (U = F.skeDrawings.get(E), B = G - M + F.marginTop, b = x);
503
+ case DocumentEditArea.FOOTER: {
504
+ const footerSke = (_b = skeFooters.get(footerId)) == null ? void 0 : _b.get(pageWidth);
505
+ footerSke != null && footerSke.skeDrawings.has(drawingId) && (skeDrawing = footerSke.skeDrawings.get(drawingId), pageMarginTop = pageHeight - marginBottom + footerSke.marginTop, pageMarginLeft = marginLeft);
499
506
  break;
500
507
  }
501
- case xe.BODY: {
502
- S.skeDrawings.has(E) && (U = S.skeDrawings.get(E), B = L, b = x);
508
+ case DocumentEditArea.BODY: {
509
+ page.skeDrawings.has(drawingId) && (skeDrawing = page.skeDrawings.get(drawingId), pageMarginTop = marginTop, pageMarginLeft = marginLeft);
503
510
  break;
504
511
  }
505
512
  }
506
- if (U != null)
513
+ if (skeDrawing != null)
507
514
  break;
508
515
  }
509
- if (U != null) {
510
- const { aTop: S, aLeft: A } = U, P = C[E].docTransform.positionH;
511
- let L = A;
512
- P.relativeFrom === ee.MARGIN ? L -= b : P.relativeFrom === ee.COLUMN && (L -= U.columnLeft);
513
- const x = {
514
- relativeFrom: P.relativeFrom,
515
- posOffset: L
516
+ if (skeDrawing != null) {
517
+ const { aTop, aLeft } = skeDrawing, oldPositionH = oldDrawings[drawingId].docTransform.positionH;
518
+ let posOffsetH = aLeft;
519
+ oldPositionH.relativeFrom === ObjectRelativeFromH.MARGIN ? posOffsetH -= pageMarginLeft : oldPositionH.relativeFrom === ObjectRelativeFromH.COLUMN && (posOffsetH -= skeDrawing.columnLeft);
520
+ const newPositionH = {
521
+ relativeFrom: oldPositionH.relativeFrom,
522
+ posOffset: posOffsetH
516
523
  };
517
- if (P.posOffset !== x.posOffset) {
518
- const F = D.replaceOp(["drawings", E, "docTransform", "positionH"], P, x);
519
- _.push(F);
524
+ if (oldPositionH.posOffset !== newPositionH.posOffset) {
525
+ const action = jsonX.replaceOp(["drawings", drawingId, "docTransform", "positionH"], oldPositionH, newPositionH);
526
+ rawActions.push(action);
520
527
  }
521
- const M = C[E].docTransform.positionV;
522
- let W = S;
523
- M.relativeFrom === V.PAGE ? W += B : M.relativeFrom === V.LINE ? W -= U.lineTop : M.relativeFrom === V.PARAGRAPH && (W -= U.blockAnchorTop);
524
- const G = {
525
- relativeFrom: M.relativeFrom,
526
- posOffset: W
528
+ const oldPositionV = oldDrawings[drawingId].docTransform.positionV;
529
+ let posOffsetV = aTop;
530
+ oldPositionV.relativeFrom === ObjectRelativeFromV.PAGE ? posOffsetV += pageMarginTop : oldPositionV.relativeFrom === ObjectRelativeFromV.LINE ? posOffsetV -= skeDrawing.lineTop : oldPositionV.relativeFrom === ObjectRelativeFromV.PARAGRAPH && (posOffsetV -= skeDrawing.blockAnchorTop);
531
+ const newPositionV = {
532
+ relativeFrom: oldPositionV.relativeFrom,
533
+ posOffset: posOffsetV
527
534
  };
528
- if (M.posOffset !== G.posOffset) {
529
- const F = D.replaceOp(["drawings", E, "docTransform", "positionV"], M, G);
530
- _.push(F);
535
+ if (oldPositionV.posOffset !== newPositionV.posOffset) {
536
+ const action = jsonX.replaceOp(["drawings", drawingId, "docTransform", "positionV"], oldPositionV, newPositionV);
537
+ rawActions.push(action);
531
538
  }
532
539
  }
533
540
  }
534
- const O = {
535
- id: Q.id,
541
+ const doMutation = {
542
+ id: RichTextEditingMutation.id,
536
543
  params: {
537
- unitId: r,
544
+ unitId,
538
545
  actions: [],
539
546
  textRanges: null
540
547
  }
541
548
  };
542
- O.params.actions = _.reduce((R, E) => X.compose(R, E), null);
543
- const y = o.syncExecuteCommand(O.id, O.params);
544
- return p.refreshControls(), !!y;
545
- }
546
- }, rn = {
549
+ doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null);
550
+ const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
551
+ return transformer.refreshControls(), !!result;
552
+ }, "handler")
553
+ }, UpdateDocDrawingDistanceCommand = {
547
554
  id: "doc.command.update-doc-drawing-distance",
548
- type: Y.COMMAND,
549
- handler: (i, e) => {
550
- if (e == null)
555
+ type: CommandType.COMMAND,
556
+ handler: /* @__PURE__ */ __name((accessor, params) => {
557
+ if (params == null)
551
558
  return !1;
552
- const t = i.get($), r = i.get(te).getCurrentUniverDocInstance();
553
- if (r == null)
559
+ const commandService = accessor.get(ICommandService), documentDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
560
+ if (documentDataModel == null)
554
561
  return !1;
555
- const { drawings: o, dist: a, unitId: s } = e, l = X.getInstance(), c = [], { drawings: m = {} } = r.getSnapshot();
556
- for (const h of o) {
557
- const { drawingId: p } = h;
558
- for (const [w, v] of Object.entries(a)) {
559
- const I = m[p][w];
560
- if (I !== v) {
561
- const D = l.replaceOp(["drawings", p, w], I, v);
562
- c.push(D);
562
+ const { drawings, dist, unitId } = params, jsonX = JSONX.getInstance(), rawActions = [], { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
563
+ for (const drawing of drawings) {
564
+ const { drawingId } = drawing;
565
+ for (const [key, value] of Object.entries(dist)) {
566
+ const oldValue = oldDrawings[drawingId][key];
567
+ if (oldValue !== value) {
568
+ const action = jsonX.replaceOp(["drawings", drawingId, key], oldValue, value);
569
+ rawActions.push(action);
563
570
  }
564
571
  }
565
572
  }
566
- const u = {
567
- id: Q.id,
573
+ const doMutation = {
574
+ id: RichTextEditingMutation.id,
568
575
  params: {
569
- unitId: s,
576
+ unitId,
570
577
  actions: [],
571
578
  textRanges: null
572
579
  }
573
580
  };
574
- return u.params.actions = c.reduce((h, p) => X.compose(h, p), null), !!t.syncExecuteCommand(u.id, u.params);
575
- }
576
- }, on = {
581
+ return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
582
+ }, "handler")
583
+ }, UpdateDocDrawingWrapTextCommand = {
577
584
  id: "doc.command.update-doc-drawing-wrap-text",
578
- type: Y.COMMAND,
579
- handler: (i, e) => {
580
- if (e == null)
585
+ type: CommandType.COMMAND,
586
+ handler: /* @__PURE__ */ __name((accessor, params) => {
587
+ if (params == null)
581
588
  return !1;
582
- const t = i.get($), r = i.get(te).getCurrentUniverDocInstance();
583
- if (r == null)
589
+ const commandService = accessor.get(ICommandService), documentDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
590
+ if (documentDataModel == null)
584
591
  return !1;
585
- const { drawings: o, wrapText: a, unitId: s } = e, l = X.getInstance(), c = [], { drawings: m = {} } = r.getSnapshot();
586
- for (const h of o) {
587
- const { drawingId: p } = h, w = m[p].wrapText;
588
- if (w !== a) {
589
- const v = l.replaceOp(["drawings", p, "wrapText"], w, a);
590
- c.push(v);
592
+ const { drawings, wrapText, unitId } = params, jsonX = JSONX.getInstance(), rawActions = [], { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
593
+ for (const drawing of drawings) {
594
+ const { drawingId } = drawing, oldWrapText = oldDrawings[drawingId].wrapText;
595
+ if (oldWrapText !== wrapText) {
596
+ const action = jsonX.replaceOp(["drawings", drawingId, "wrapText"], oldWrapText, wrapText);
597
+ rawActions.push(action);
591
598
  }
592
599
  }
593
- const u = {
594
- id: Q.id,
600
+ const doMutation = {
601
+ id: RichTextEditingMutation.id,
595
602
  params: {
596
- unitId: s,
603
+ unitId,
597
604
  actions: [],
598
605
  textRanges: null
599
606
  }
600
607
  };
601
- return u.params.actions = c.reduce((h, p) => X.compose(h, p), null), !!t.syncExecuteCommand(u.id, u.params);
602
- }
603
- }, ze = {
608
+ return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
609
+ }, "handler")
610
+ }, UpdateDrawingDocTransformCommand = {
604
611
  id: "doc.command.update-drawing-doc-transform",
605
- type: Y.COMMAND,
606
- handler: (i, e) => {
607
- if (e == null)
612
+ type: CommandType.COMMAND,
613
+ handler: /* @__PURE__ */ __name((accessor, params) => {
614
+ if (params == null)
608
615
  return !1;
609
- const t = i.get($), n = i.get(te), o = i.get(se).getRenderById(e.unitId), a = o == null ? void 0 : o.scene;
610
- if (a == null)
616
+ const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), renderObject = accessor.get(IRenderManagerService).getRenderById(params.unitId), scene = renderObject == null ? void 0 : renderObject.scene;
617
+ if (scene == null)
611
618
  return !1;
612
- const s = a.getTransformerByCreate(), l = n.getCurrentUniverDocInstance();
613
- if (l == null)
619
+ const transformer = scene.getTransformerByCreate(), documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
620
+ if (documentDataModel == null)
614
621
  return !1;
615
- const { drawings: c, unitId: m } = e, u = X.getInstance(), f = [], { drawings: h = {} } = l.getSnapshot();
616
- for (const v of c) {
617
- const { drawingId: I, key: D, value: _ } = v, C = h[I].docTransform[D];
618
- if (!Pe.diffValue(C, _)) {
619
- const O = u.replaceOp(["drawings", I, "docTransform", D], C, _);
620
- f.push(O);
622
+ const { drawings, unitId } = params, jsonX = JSONX.getInstance(), rawActions = [], { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
623
+ for (const drawing of drawings) {
624
+ const { drawingId, key, value } = drawing, oldValue = oldDrawings[drawingId].docTransform[key];
625
+ if (!Tools.diffValue(oldValue, value)) {
626
+ const action = jsonX.replaceOp(["drawings", drawingId, "docTransform", key], oldValue, value);
627
+ rawActions.push(action);
621
628
  }
622
629
  }
623
- const p = {
624
- id: Q.id,
630
+ const doMutation = {
631
+ id: RichTextEditingMutation.id,
625
632
  params: {
626
- unitId: m,
633
+ unitId,
627
634
  actions: [],
628
635
  textRanges: null,
629
636
  debounce: !0
630
637
  }
631
638
  };
632
- p.params.actions = f.reduce((v, I) => X.compose(v, I), null);
633
- const w = t.syncExecuteCommand(p.id, p.params);
634
- return s.refreshControls(), !!w;
635
- }
636
- }, an = {
639
+ doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null);
640
+ const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
641
+ return transformer.refreshControls(), !!result;
642
+ }, "handler")
643
+ }, IMoveInlineDrawingCommand = {
637
644
  id: "doc.command.move-inline-drawing",
638
- type: Y.COMMAND,
639
- handler: (i, e) => {
640
- var T;
641
- if (e == null)
645
+ type: CommandType.COMMAND,
646
+ handler: /* @__PURE__ */ __name((accessor, params) => {
647
+ var _a8;
648
+ if (params == null)
642
649
  return !1;
643
- const t = i.get(se), n = i.get(Ue), r = i.get(ct), o = t.getRenderById(e.unitId), a = o == null ? void 0 : o.scene, s = o == null ? void 0 : o.with(ae).getSkeleton();
644
- if (a == null)
650
+ const renderManagerService = accessor.get(IRenderManagerService), textSelectionRenderManager = accessor.get(ITextSelectionRenderManager), docRefreshDrawingsService = accessor.get(DocRefreshDrawingsService), renderObject = renderManagerService.getRenderById(params.unitId), scene = renderObject == null ? void 0 : renderObject.scene, skeleton = renderObject == null ? void 0 : renderObject.with(DocSkeletonManagerService).getSkeleton();
651
+ if (scene == null)
645
652
  return !1;
646
- const l = a.getTransformerByCreate(), c = i.get($), u = i.get(te).getCurrentUniverDocInstance();
647
- if (u == null)
653
+ const transformer = scene.getTransformerByCreate(), commandService = accessor.get(ICommandService), documentDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
654
+ if (documentDataModel == null)
648
655
  return !1;
649
- const { drawing: f, unitId: h, offset: p, segmentId: w, segmentPage: v } = e, I = [], { drawingId: D } = f, _ = (T = n.getSegment()) != null ? T : "", C = tn(
650
- w,
651
- _,
652
- v,
653
- p,
654
- D,
655
- u,
656
- n
656
+ const { drawing, unitId, offset, segmentId: newSegmentId, segmentPage } = params, rawActions = [], { drawingId } = drawing, segmentId = (_a8 = textSelectionRenderManager.getSegment()) != null ? _a8 : "", actions = getDeleteAndInsertCustomBlockActions(
657
+ newSegmentId,
658
+ segmentId,
659
+ segmentPage,
660
+ offset,
661
+ drawingId,
662
+ documentDataModel,
663
+ textSelectionRenderManager
657
664
  );
658
- if (C == null || C.length === 0)
659
- return r.refreshDrawings(s), l.refreshControls(), !1;
660
- I.push(...C);
661
- const O = {
662
- id: Q.id,
665
+ if (actions == null || actions.length === 0)
666
+ return docRefreshDrawingsService.refreshDrawings(skeleton), transformer.refreshControls(), !1;
667
+ rawActions.push(...actions);
668
+ const doMutation = {
669
+ id: RichTextEditingMutation.id,
663
670
  params: {
664
- unitId: h,
671
+ unitId,
665
672
  actions: [],
666
673
  textRanges: null
667
674
  }
668
675
  };
669
- O.params.actions = I.reduce((N, R) => X.compose(N, R), null);
670
- const y = c.syncExecuteCommand(O.id, O.params);
671
- return l.refreshControls(), !!y;
672
- }
673
- }, sn = {
676
+ doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null);
677
+ const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
678
+ return transformer.refreshControls(), !!result;
679
+ }, "handler")
680
+ }, ITransformNonInlineDrawingCommand = {
674
681
  id: "doc.command.transform-non-inline-drawing",
675
- type: Y.COMMAND,
682
+ type: CommandType.COMMAND,
676
683
  // eslint-disable-next-line max-lines-per-function
677
- handler: (i, e) => {
678
- var U;
679
- if (e == null)
684
+ handler: /* @__PURE__ */ __name((accessor, params) => {
685
+ var _a8;
686
+ if (params == null)
680
687
  return !1;
681
- const t = i.get(Ue), r = i.get(se).getRenderById(e.unitId), o = r == null ? void 0 : r.scene;
682
- if (o == null)
688
+ const textSelectionRenderManager = accessor.get(ITextSelectionRenderManager), renderObject = accessor.get(IRenderManagerService).getRenderById(params.unitId), scene = renderObject == null ? void 0 : renderObject.scene;
689
+ if (scene == null)
683
690
  return !1;
684
- const a = o.getTransformerByCreate(), s = i.get($), c = i.get(te).getCurrentUniverDocInstance();
685
- if (c == null)
691
+ const transformer = scene.getTransformerByCreate(), commandService = accessor.get(ICommandService), documentDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
692
+ if (documentDataModel == null)
686
693
  return !1;
687
- const { drawing: m, unitId: u, offset: f, docTransform: h, segmentId: p, segmentPage: w } = e, v = [], { drawingId: I } = m, D = (U = t.getSegment()) != null ? U : "", _ = tn(
688
- p,
689
- D,
690
- w,
691
- f,
692
- I,
693
- c,
694
- t
694
+ const { drawing, unitId, offset, docTransform, segmentId: newSegmentId, segmentPage } = params, rawActions = [], { drawingId } = drawing, segmentId = (_a8 = textSelectionRenderManager.getSegment()) != null ? _a8 : "", actions = getDeleteAndInsertCustomBlockActions(
695
+ newSegmentId,
696
+ segmentId,
697
+ segmentPage,
698
+ offset,
699
+ drawingId,
700
+ documentDataModel,
701
+ textSelectionRenderManager
695
702
  );
696
- if (_ == null)
703
+ if (actions == null)
697
704
  return !1;
698
- _.length > 0 && v.push(..._);
699
- const C = X.getInstance(), { drawings: O = {} } = c.getSnapshot(), y = O[I].docTransform, { positionH: T, positionV: N, size: R, angle: E } = y;
700
- if (!Pe.diffValue(T, h.positionH)) {
701
- const B = C.replaceOp(["drawings", I, "docTransform", "positionH"], T, h.positionH);
702
- v.push(B);
705
+ actions.length > 0 && rawActions.push(...actions);
706
+ const jsonX = JSONX.getInstance(), { drawings: oldDrawings = {} } = documentDataModel.getSnapshot(), oldDocTransform = oldDrawings[drawingId].docTransform, { positionH: oldPositionH, positionV: oldPositionV, size: oldSize, angle: oldAngle } = oldDocTransform;
707
+ if (!Tools.diffValue(oldPositionH, docTransform.positionH)) {
708
+ const updateAction = jsonX.replaceOp(["drawings", drawingId, "docTransform", "positionH"], oldPositionH, docTransform.positionH);
709
+ rawActions.push(updateAction);
703
710
  }
704
- if (!Pe.diffValue(N, h.positionV)) {
705
- const B = C.replaceOp(["drawings", I, "docTransform", "positionV"], N, h.positionV);
706
- v.push(B);
711
+ if (!Tools.diffValue(oldPositionV, docTransform.positionV)) {
712
+ const updateAction = jsonX.replaceOp(["drawings", drawingId, "docTransform", "positionV"], oldPositionV, docTransform.positionV);
713
+ rawActions.push(updateAction);
707
714
  }
708
- if (!Pe.diffValue(R, h.size)) {
709
- const B = C.replaceOp(["drawings", I, "docTransform", "size"], R, h.size);
710
- v.push(B);
715
+ if (!Tools.diffValue(oldSize, docTransform.size)) {
716
+ const updateAction = jsonX.replaceOp(["drawings", drawingId, "docTransform", "size"], oldSize, docTransform.size);
717
+ rawActions.push(updateAction);
711
718
  }
712
- if (!Pe.diffValue(E, h.angle)) {
713
- const B = C.replaceOp(["drawings", I, "docTransform", "angle"], E, h.angle);
714
- v.push(B);
719
+ if (!Tools.diffValue(oldAngle, docTransform.angle)) {
720
+ const updateAction = jsonX.replaceOp(["drawings", drawingId, "docTransform", "angle"], oldAngle, docTransform.angle);
721
+ rawActions.push(updateAction);
715
722
  }
716
- const H = {
717
- id: Q.id,
723
+ const doMutation = {
724
+ id: RichTextEditingMutation.id,
718
725
  params: {
719
- unitId: u,
726
+ unitId,
720
727
  actions: [],
721
728
  textRanges: null,
722
729
  debounce: !0
723
730
  }
724
731
  };
725
- H.params.actions = v.reduce((B, b) => X.compose(B, b), null);
726
- const z = s.syncExecuteCommand(H.id, H.params);
727
- return a.refreshControls(), !!z;
728
- }
729
- }, Ze = 0, Qe = 100, Fi = (i) => {
730
- const e = re($), t = re(ot), n = re(he), r = re(se), o = re(te), { drawings: a } = i, s = a[0];
731
- if (s == null)
732
+ doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null);
733
+ const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
734
+ return transformer.refreshControls(), !!result;
735
+ }, "handler")
736
+ }, MIN_MARGIN = 0, MAX_MARGIN = 100, DocDrawingTextWrap = /* @__PURE__ */ __name((props) => {
737
+ const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), univerInstanceService = useDependency(IUniverInstanceService), { drawings } = props, drawingParam = drawings[0];
738
+ if (drawingParam == null)
732
739
  return null;
733
- const { unitId: l } = s, c = o.getUniverDocInstance(l), m = r.getRenderById(l);
734
- if ((m == null ? void 0 : m.scene) == null)
740
+ const { unitId } = drawingParam, documentDataModel = univerInstanceService.getUniverDocInstance(unitId), renderObject = renderManagerService.getRenderById(unitId);
741
+ if ((renderObject == null ? void 0 : renderObject.scene) == null)
735
742
  return null;
736
- const [f, h] = ie(!0), [p, w] = ie(!0), [v, I] = ie(!0), [D, _] = ie(me.INLINE), [C, O] = ie(""), [y, T] = ie({
743
+ const [disableWrapText, setDisableWrapText] = useState(!0), [disableDistTB, setDisableDistTB] = useState(!0), [disableDistLR, setDisableDistLR] = useState(!0), [wrappingStyle, setWrappingStyle] = useState(TextWrappingStyle.INLINE), [wrapText, setWrapText] = useState(""), [distToText, setDistToText] = useState({
737
744
  distT: 0,
738
745
  distL: 0,
739
746
  distB: 0,
740
747
  distR: 0
741
- }), [N, R] = ie(!0);
742
- function E(b) {
743
- _(b);
744
- const S = n.getFocusDrawings();
745
- if (S.length === 0)
748
+ }), [showPanel, setShowPanel] = useState(!0);
749
+ function handleWrappingStyleChange(value) {
750
+ setWrappingStyle(value);
751
+ const focusDrawings = drawingManagerService.getFocusDrawings();
752
+ if (focusDrawings.length === 0)
746
753
  return;
747
- const { unitId: A, subUnitId: P } = S[0], L = S.map(({ unitId: x, subUnitId: M, drawingId: W }) => ({
748
- unitId: x,
749
- subUnitId: M,
750
- drawingId: W
754
+ const { unitId: unitId2, subUnitId } = focusDrawings[0], drawings2 = focusDrawings.map(({ unitId: unitId3, subUnitId: subUnitId2, drawingId }) => ({
755
+ unitId: unitId3,
756
+ subUnitId: subUnitId2,
757
+ drawingId
751
758
  }));
752
- e.executeCommand(nn.id, {
753
- unitId: A,
754
- subUnitId: P,
755
- drawings: L,
756
- wrappingStyle: b
759
+ commandService.executeCommand(UpdateDocDrawingWrappingStyleCommand.id, {
760
+ unitId: unitId2,
761
+ subUnitId,
762
+ drawings: drawings2,
763
+ wrappingStyle: value
757
764
  });
758
765
  }
759
- function H(b) {
760
- O(b);
761
- const S = n.getFocusDrawings();
762
- if (S.length === 0)
766
+ __name(handleWrappingStyleChange, "handleWrappingStyleChange");
767
+ function handleWrapTextChange(value) {
768
+ setWrapText(value);
769
+ const focusDrawings = drawingManagerService.getFocusDrawings();
770
+ if (focusDrawings.length === 0)
763
771
  return;
764
- const A = S.map((P) => ({
765
- unitId: P.unitId,
766
- subUnitId: P.subUnitId,
767
- drawingId: P.drawingId
772
+ const drawings2 = focusDrawings.map((drawing) => ({
773
+ unitId: drawing.unitId,
774
+ subUnitId: drawing.subUnitId,
775
+ drawingId: drawing.drawingId
768
776
  }));
769
- e.executeCommand(on.id, {
770
- unitId: S[0].unitId,
771
- subUnitId: S[0].unitId,
772
- drawings: A,
773
- wrapText: b
777
+ commandService.executeCommand(UpdateDocDrawingWrapTextCommand.id, {
778
+ unitId: focusDrawings[0].unitId,
779
+ subUnitId: focusDrawings[0].unitId,
780
+ drawings: drawings2,
781
+ wrapText: value
774
782
  });
775
783
  }
776
- function z(b, S) {
777
- if (b == null)
784
+ __name(handleWrapTextChange, "handleWrapTextChange");
785
+ function handleDistToTextChange(value, direction) {
786
+ if (value == null)
778
787
  return;
779
- const A = { ...y, [S]: b };
780
- T(A);
781
- const P = n.getFocusDrawings();
782
- if (P.length === 0)
788
+ const newDistToText = { ...distToText, [direction]: value };
789
+ setDistToText(newDistToText);
790
+ const focusDrawings = drawingManagerService.getFocusDrawings();
791
+ if (focusDrawings.length === 0)
783
792
  return;
784
- const L = P.map((x) => ({
785
- unitId: x.unitId,
786
- subUnitId: x.subUnitId,
787
- drawingId: x.drawingId
793
+ const drawings2 = focusDrawings.map((drawing) => ({
794
+ unitId: drawing.unitId,
795
+ subUnitId: drawing.subUnitId,
796
+ drawingId: drawing.drawingId
788
797
  }));
789
- e.executeCommand(rn.id, {
790
- unitId: P[0].unitId,
791
- subUnitId: P[0].unitId,
792
- drawings: L,
798
+ commandService.executeCommand(UpdateDocDrawingDistanceCommand.id, {
799
+ unitId: focusDrawings[0].unitId,
800
+ subUnitId: focusDrawings[0].unitId,
801
+ drawings: drawings2,
793
802
  dist: {
794
- [S]: b
803
+ [direction]: value
795
804
  }
796
805
  });
797
806
  }
798
- function U() {
799
- const b = n.getFocusDrawings();
800
- b.length !== 0 && B(b[0]);
807
+ __name(handleDistToTextChange, "handleDistToTextChange");
808
+ function updateFocusDrawingState() {
809
+ const focusDrawings = drawingManagerService.getFocusDrawings();
810
+ focusDrawings.length !== 0 && updateState(focusDrawings[0]);
801
811
  }
802
- function B(b) {
803
- var ce, fe;
804
- const S = (fe = (ce = c == null ? void 0 : c.getSnapshot()) == null ? void 0 : ce.drawings) == null ? void 0 : fe[b.drawingId];
805
- if (S == null)
812
+ __name(updateFocusDrawingState, "updateFocusDrawingState");
813
+ function updateState(drawingParam2) {
814
+ var _a8, _b;
815
+ const drawing = (_b = (_a8 = documentDataModel == null ? void 0 : documentDataModel.getSnapshot()) == null ? void 0 : _a8.drawings) == null ? void 0 : _b[drawingParam2.drawingId];
816
+ if (drawing == null)
806
817
  return;
807
818
  const {
808
- distT: A = 0,
809
- distL: P = 0,
810
- distB: L = 0,
811
- distR: x = 0,
812
- layoutType: M = k.INLINE,
813
- behindDoc: W = oe.FALSE,
814
- wrapText: G = je.BOTH_SIDES
815
- } = S;
816
- if (T({
817
- distT: A,
818
- distL: P,
819
- distB: L,
820
- distR: x
821
- }), O(G), h(M !== k.WRAP_SQUARE), M === k.WRAP_NONE || M === k.INLINE ? w(!0) : w(!1), M === k.WRAP_NONE || M === k.INLINE || M === k.WRAP_TOP_AND_BOTTOM ? I(!0) : I(!1), M === k.WRAP_NONE)
822
- W === oe.TRUE ? _(me.BEHIND_TEXT) : _(me.IN_FRONT_OF_TEXT);
819
+ distT = 0,
820
+ distL = 0,
821
+ distB = 0,
822
+ distR = 0,
823
+ layoutType = PositionedObjectLayoutType.INLINE,
824
+ behindDoc = BooleanNumber.FALSE,
825
+ wrapText: wrapText2 = WrapTextType.BOTH_SIDES
826
+ } = drawing;
827
+ if (setDistToText({
828
+ distT,
829
+ distL,
830
+ distB,
831
+ distR
832
+ }), setWrapText(wrapText2), setDisableWrapText(layoutType !== PositionedObjectLayoutType.WRAP_SQUARE), layoutType === PositionedObjectLayoutType.WRAP_NONE || layoutType === PositionedObjectLayoutType.INLINE ? setDisableDistTB(!0) : setDisableDistTB(!1), layoutType === PositionedObjectLayoutType.WRAP_NONE || layoutType === PositionedObjectLayoutType.INLINE || layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM ? setDisableDistLR(!0) : setDisableDistLR(!1), layoutType === PositionedObjectLayoutType.WRAP_NONE)
833
+ behindDoc === BooleanNumber.TRUE ? setWrappingStyle(TextWrappingStyle.BEHIND_TEXT) : setWrappingStyle(TextWrappingStyle.IN_FRONT_OF_TEXT);
823
834
  else
824
- switch (M) {
825
- case k.INLINE:
826
- _(me.INLINE);
835
+ switch (layoutType) {
836
+ case PositionedObjectLayoutType.INLINE:
837
+ setWrappingStyle(TextWrappingStyle.INLINE);
827
838
  break;
828
- case k.WRAP_SQUARE:
829
- _(me.WRAP_SQUARE);
839
+ case PositionedObjectLayoutType.WRAP_SQUARE:
840
+ setWrappingStyle(TextWrappingStyle.WRAP_SQUARE);
830
841
  break;
831
- case k.WRAP_TOP_AND_BOTTOM:
832
- _(me.WRAP_TOP_AND_BOTTOM);
842
+ case PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM:
843
+ setWrappingStyle(TextWrappingStyle.WRAP_TOP_AND_BOTTOM);
833
844
  break;
834
845
  default:
835
- throw new Error(`Unsupported layout type: ${M}`);
846
+ throw new Error(`Unsupported layout type: ${layoutType}`);
836
847
  }
837
848
  }
838
- return ht(() => {
839
- U();
840
- const b = n.focus$.subscribe((A) => {
841
- if (A.length === 0) {
842
- R(!1);
849
+ return __name(updateState, "updateState"), useEffect(() => {
850
+ updateFocusDrawingState();
851
+ const subscription = drawingManagerService.focus$.subscribe((drawingParams) => {
852
+ if (drawingParams.length === 0) {
853
+ setShowPanel(!1);
843
854
  return;
844
855
  }
845
- R(!0), B(A[0]);
846
- }), S = e.onCommandExecuted(async (A) => {
847
- A.id === Q.id && U();
856
+ setShowPanel(!0), updateState(drawingParams[0]);
857
+ }), mutationListener = commandService.onCommandExecuted(async (command) => {
858
+ command.id === RichTextEditingMutation.id && updateFocusDrawingState();
848
859
  });
849
860
  return () => {
850
- b.unsubscribe(), S.dispose();
861
+ subscription.unsubscribe(), mutationListener.dispose();
851
862
  };
852
- }, []), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: N ? "block" : "none" } }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-text-wrap.title")))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-text-wrap.wrappingStyle")))), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelRow) }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn) }, /* @__PURE__ */ d.createElement(bt, { value: D, onChange: E, direction: "vertical" }, /* @__PURE__ */ d.createElement(Ee, { value: me.INLINE }, t.t("image-text-wrap.inline")), /* @__PURE__ */ d.createElement(Ee, { value: me.WRAP_SQUARE }, t.t("image-text-wrap.square")), /* @__PURE__ */ d.createElement(Ee, { value: me.WRAP_TOP_AND_BOTTOM }, t.t("image-text-wrap.topAndBottom")), /* @__PURE__ */ d.createElement(Ee, { value: me.BEHIND_TEXT }, t.t("image-text-wrap.behindText")), /* @__PURE__ */ d.createElement(Ee, { value: me.IN_FRONT_OF_TEXT }, t.t("image-text-wrap.inFrontText"))))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-text-wrap.wrapText")))), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelRow) }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn) }, /* @__PURE__ */ d.createElement(bt, { disabled: f, value: C, onChange: H, direction: "horizontal" }, /* @__PURE__ */ d.createElement(Ee, { value: je.BOTH_SIDES }, t.t("image-text-wrap.bothSide")), /* @__PURE__ */ d.createElement(Ee, { value: je.LEFT }, t.t("image-text-wrap.leftOnly")), /* @__PURE__ */ d.createElement(Ee, { value: je.RIGHT }, t.t("image-text-wrap.rightOnly"))))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-text-wrap.distanceFromText")))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-text-wrap.top"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
853
- Ae,
863
+ }, []), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelGrid, styles.imageCommonPanelBorder), style: { display: showPanel ? "block" : "none" } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.title")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.wrappingStyle")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelRow) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(RadioGroup, { value: wrappingStyle, onChange: handleWrappingStyleChange, direction: "vertical" }, /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.INLINE }, localeService.t("image-text-wrap.inline")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.WRAP_SQUARE }, localeService.t("image-text-wrap.square")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.WRAP_TOP_AND_BOTTOM }, localeService.t("image-text-wrap.topAndBottom")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.BEHIND_TEXT }, localeService.t("image-text-wrap.behindText")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.IN_FRONT_OF_TEXT }, localeService.t("image-text-wrap.inFrontText"))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.wrapText")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelRow) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(RadioGroup, { disabled: disableWrapText, value: wrapText, onChange: handleWrapTextChange, direction: "horizontal" }, /* @__PURE__ */ React.createElement(Radio, { value: WrapTextType.BOTH_SIDES }, localeService.t("image-text-wrap.bothSide")), /* @__PURE__ */ React.createElement(Radio, { value: WrapTextType.LEFT }, localeService.t("image-text-wrap.leftOnly")), /* @__PURE__ */ React.createElement(Radio, { value: WrapTextType.RIGHT }, localeService.t("image-text-wrap.rightOnly"))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.distanceFromText")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.top"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
864
+ InputNumber,
854
865
  {
855
- min: Ze,
856
- max: Qe,
857
- disabled: p,
866
+ min: MIN_MARGIN,
867
+ max: MAX_MARGIN,
868
+ disabled: disableDistTB,
858
869
  precision: 1,
859
- value: y.distT,
860
- onChange: (b) => {
861
- z(b, "distT");
862
- },
863
- className: g.imageCommonPanelInput
870
+ value: distToText.distT,
871
+ onChange: /* @__PURE__ */ __name((val) => {
872
+ handleDistToTextChange(val, "distT");
873
+ }, "onChange"),
874
+ className: styles.imageCommonPanelInput
864
875
  }
865
- ))))), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-text-wrap.left"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
866
- Ae,
876
+ ))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.left"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
877
+ InputNumber,
867
878
  {
868
- min: Ze,
869
- max: Qe,
870
- disabled: v,
879
+ min: MIN_MARGIN,
880
+ max: MAX_MARGIN,
881
+ disabled: disableDistLR,
871
882
  precision: 1,
872
- value: y.distL,
873
- onChange: (b) => {
874
- z(b, "distL");
875
- },
876
- className: g.imageCommonPanelInput
883
+ value: distToText.distL,
884
+ onChange: /* @__PURE__ */ __name((val) => {
885
+ handleDistToTextChange(val, "distL");
886
+ }, "onChange"),
887
+ className: styles.imageCommonPanelInput
877
888
  }
878
- )))))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-text-wrap.bottom"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
879
- Ae,
889
+ )))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.bottom"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
890
+ InputNumber,
880
891
  {
881
- min: Ze,
882
- max: Qe,
883
- disabled: p,
892
+ min: MIN_MARGIN,
893
+ max: MAX_MARGIN,
894
+ disabled: disableDistTB,
884
895
  precision: 1,
885
- value: y.distB,
886
- onChange: (b) => {
887
- z(b, "distB");
888
- },
889
- className: g.imageCommonPanelInput
896
+ value: distToText.distB,
897
+ onChange: /* @__PURE__ */ __name((val) => {
898
+ handleDistToTextChange(val, "distB");
899
+ }, "onChange"),
900
+ className: styles.imageCommonPanelInput
890
901
  }
891
- ))))), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-text-wrap.right"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
892
- Ae,
902
+ ))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.right"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
903
+ InputNumber,
893
904
  {
894
- min: Ze,
895
- max: Qe,
896
- disabled: v,
905
+ min: MIN_MARGIN,
906
+ max: MAX_MARGIN,
907
+ disabled: disableDistLR,
897
908
  precision: 1,
898
- value: y.distR,
899
- onChange: (b) => {
900
- z(b, "distR");
901
- },
902
- className: g.imageCommonPanelInput
909
+ value: distToText.distR,
910
+ onChange: /* @__PURE__ */ __name((val) => {
911
+ handleDistToTextChange(val, "distR");
912
+ }, "onChange"),
913
+ className: styles.imageCommonPanelInput
903
914
  }
904
915
  )))))));
905
- }, xt = -1e3, Lt = 1e3, ki = (i) => {
906
- const e = re($), t = re(ot), n = re(he), r = re(se), o = re(te), a = re(Ue), { drawings: s } = i, l = s[0];
907
- if (l == null)
916
+ }, "DocDrawingTextWrap"), MIN_OFFSET = -1e3, MAX_OFFSET = 1e3, DocDrawingPosition = /* @__PURE__ */ __name((props) => {
917
+ const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), univerInstanceService = useDependency(IUniverInstanceService), textSelectionRenderService = useDependency(ITextSelectionRenderManager), { drawings } = props, drawingParam = drawings[0];
918
+ if (drawingParam == null)
908
919
  return;
909
- const { unitId: c } = l, m = o.getUniverDocInstance(c), u = r.getRenderById(c), f = u == null ? void 0 : u.scene;
910
- if (f == null)
920
+ const { unitId } = drawingParam, documentDataModel = univerInstanceService.getUniverDocInstance(unitId), renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
921
+ if (scene == null)
911
922
  return;
912
- const h = f.getTransformerByCreate(), p = [{
913
- label: t.t("image-position.column"),
914
- value: String(ee.COLUMN)
923
+ const transformer = scene.getTransformerByCreate(), HORIZONTAL_RELATIVE_FROM = [{
924
+ label: localeService.t("image-position.column"),
925
+ value: String(ObjectRelativeFromH.COLUMN)
915
926
  }, {
916
- label: t.t("image-position.page"),
917
- value: String(ee.PAGE)
927
+ label: localeService.t("image-position.page"),
928
+ value: String(ObjectRelativeFromH.PAGE)
918
929
  }, {
919
- label: t.t("image-position.margin"),
920
- value: String(ee.MARGIN)
921
- }], w = [{
922
- label: t.t("image-position.line"),
923
- value: String(V.LINE)
930
+ label: localeService.t("image-position.margin"),
931
+ value: String(ObjectRelativeFromH.MARGIN)
932
+ }], VERTICAL_RELATIVE_FROM = [{
933
+ label: localeService.t("image-position.line"),
934
+ value: String(ObjectRelativeFromV.LINE)
924
935
  }, {
925
- label: t.t("image-position.page"),
926
- value: String(V.PAGE)
936
+ label: localeService.t("image-position.page"),
937
+ value: String(ObjectRelativeFromV.PAGE)
927
938
  }, {
928
- label: t.t("image-position.margin"),
929
- value: String(V.MARGIN)
939
+ label: localeService.t("image-position.margin"),
940
+ value: String(ObjectRelativeFromV.MARGIN)
930
941
  }, {
931
- label: t.t("image-position.paragraph"),
932
- value: String(V.PARAGRAPH)
933
- }], [v, I] = ie(!0), [D, _] = ie({
934
- relativeFrom: ee.PAGE,
942
+ label: localeService.t("image-position.paragraph"),
943
+ value: String(ObjectRelativeFromV.PARAGRAPH)
944
+ }], [disabled, setDisabled] = useState(!0), [hPosition, setHPosition] = useState({
945
+ relativeFrom: ObjectRelativeFromH.PAGE,
935
946
  posOffset: 0
936
- }), [C, O] = ie({
937
- relativeFrom: V.PAGE,
947
+ }), [vPosition, setVPosition] = useState({
948
+ relativeFrom: ObjectRelativeFromV.PAGE,
938
949
  posOffset: 0
939
- }), [y, T] = ie(!0), [N, R] = ie(!0);
940
- function E(S, A) {
941
- S === "positionH" ? _(A) : O(A);
942
- const P = n.getFocusDrawings();
943
- if (P.length === 0)
950
+ }), [followTextMove, setFollowTextMove] = useState(!0), [showPanel, setShowPanel] = useState(!0);
951
+ function handlePositionChange(direction, value) {
952
+ direction === "positionH" ? setHPosition(value) : setVPosition(value);
953
+ const focusDrawings = drawingManagerService.getFocusDrawings();
954
+ if (focusDrawings.length === 0)
944
955
  return;
945
- const L = P.map((x) => ({
946
- unitId: x.unitId,
947
- subUnitId: x.subUnitId,
948
- drawingId: x.drawingId
956
+ const drawings2 = focusDrawings.map((drawing) => ({
957
+ unitId: drawing.unitId,
958
+ subUnitId: drawing.subUnitId,
959
+ drawingId: drawing.drawingId
949
960
  }));
950
- e.executeCommand(ze.id, {
951
- unitId: P[0].unitId,
952
- subUnitId: P[0].unitId,
953
- drawings: L.map((x) => ({
954
- drawingId: x.drawingId,
955
- key: S,
956
- value: A
961
+ commandService.executeCommand(UpdateDrawingDocTransformCommand.id, {
962
+ unitId: focusDrawings[0].unitId,
963
+ subUnitId: focusDrawings[0].unitId,
964
+ drawings: drawings2.map((drawing) => ({
965
+ drawingId: drawing.drawingId,
966
+ key: direction,
967
+ value
957
968
  }))
958
- }), a.blur(), h.refreshControls();
969
+ }), textSelectionRenderService.blur(), transformer.refreshControls();
959
970
  }
960
- function H(S) {
961
- var we, ve, ne;
962
- const A = D.relativeFrom, P = D.posOffset, L = Number(S);
963
- if (A === L)
971
+ __name(handlePositionChange, "handlePositionChange");
972
+ function handleHorizontalRelativeFromChange(value) {
973
+ var _a8, _b, _c;
974
+ const prevRelativeFrom = hPosition.relativeFrom, prevPosOffset = hPosition.posOffset, relativeFrom = Number(value);
975
+ if (prevRelativeFrom === relativeFrom)
964
976
  return;
965
- const x = n.getFocusDrawings();
966
- if (x.length === 0)
977
+ const focusDrawings = drawingManagerService.getFocusDrawings();
978
+ if (focusDrawings.length === 0)
967
979
  return;
968
- const M = x[0].drawingId, W = x[0].unitId;
969
- let G = null, F = 0;
970
- const ce = (we = r.getRenderById(W)) == null ? void 0 : we.with(ae).getSkeleton(), fe = ce == null ? void 0 : ce.getSkeletonData();
971
- if (fe == null)
980
+ const drawingId = focusDrawings[0].drawingId, unitId2 = focusDrawings[0].unitId;
981
+ let drawing = null, pageMarginLeft = 0;
982
+ const skeleton = (_a8 = renderManagerService.getRenderById(unitId2)) == null ? void 0 : _a8.with(DocSkeletonManagerService).getSkeleton(), skeletonData = skeleton == null ? void 0 : skeleton.getSkeletonData();
983
+ if (skeletonData == null)
972
984
  return;
973
- const { pages: Oe, skeHeaders: Be, skeFooters: Ce } = fe;
974
- for (const Ne of Oe) {
975
- const { marginLeft: Ie, skeDrawings: Se, headerId: Te, footerId: Me, pageWidth: De } = Ne;
976
- if (Se.has(M)) {
977
- G = Se.get(M), F = Ie;
985
+ const { pages, skeHeaders, skeFooters } = skeletonData;
986
+ for (const page of pages) {
987
+ const { marginLeft, skeDrawings, headerId, footerId, pageWidth } = page;
988
+ if (skeDrawings.has(drawingId)) {
989
+ drawing = skeDrawings.get(drawingId), pageMarginLeft = marginLeft;
978
990
  break;
979
991
  }
980
- const J = (ve = Be.get(Te)) == null ? void 0 : ve.get(De);
981
- if (J != null && J.skeDrawings.has(M)) {
982
- G = J == null ? void 0 : J.skeDrawings.get(M), F = Ie;
992
+ const headerPage = (_b = skeHeaders.get(headerId)) == null ? void 0 : _b.get(pageWidth);
993
+ if (headerPage != null && headerPage.skeDrawings.has(drawingId)) {
994
+ drawing = headerPage == null ? void 0 : headerPage.skeDrawings.get(drawingId), pageMarginLeft = marginLeft;
983
995
  break;
984
996
  }
985
- const q = (ne = Ce.get(Me)) == null ? void 0 : ne.get(De);
986
- if (q != null && q.skeDrawings.has(M)) {
987
- G = q == null ? void 0 : q.skeDrawings.get(M), F = Ie;
997
+ const footerPage = (_c = skeFooters.get(footerId)) == null ? void 0 : _c.get(pageWidth);
998
+ if (footerPage != null && footerPage.skeDrawings.has(drawingId)) {
999
+ drawing = footerPage == null ? void 0 : footerPage.skeDrawings.get(drawingId), pageMarginLeft = marginLeft;
988
1000
  break;
989
1001
  }
990
1002
  }
991
- if (G == null)
1003
+ if (drawing == null)
992
1004
  return;
993
- let K = 0;
994
- A === ee.COLUMN ? K -= G.columnLeft : A === ee.MARGIN && (K -= F), L === ee.COLUMN ? K += G.columnLeft : L === ee.MARGIN ? K += F : ee.PAGE;
995
- const le = {
996
- relativeFrom: L,
997
- posOffset: (P != null ? P : 0) - K
1005
+ let delta = 0;
1006
+ prevRelativeFrom === ObjectRelativeFromH.COLUMN ? delta -= drawing.columnLeft : prevRelativeFrom === ObjectRelativeFromH.MARGIN && (delta -= pageMarginLeft), relativeFrom === ObjectRelativeFromH.COLUMN ? delta += drawing.columnLeft : relativeFrom === ObjectRelativeFromH.MARGIN ? delta += pageMarginLeft : ObjectRelativeFromH.PAGE;
1007
+ const newPositionH = {
1008
+ relativeFrom,
1009
+ posOffset: (prevPosOffset != null ? prevPosOffset : 0) - delta
998
1010
  };
999
- E("positionH", le);
1011
+ handlePositionChange("positionH", newPositionH);
1000
1012
  }
1001
- function z(S) {
1002
- var Ie, Se, Te, Me, De;
1003
- const A = C.relativeFrom, P = C.posOffset, L = Number(S);
1004
- if (A === L)
1013
+ __name(handleHorizontalRelativeFromChange, "handleHorizontalRelativeFromChange");
1014
+ function handleVerticalRelativeFromChange(value) {
1015
+ var _a8, _b, _c, _d, _e;
1016
+ const prevRelativeFrom = vPosition.relativeFrom, prevPosOffset = vPosition.posOffset, relativeFrom = Number(value);
1017
+ if (prevRelativeFrom === relativeFrom)
1005
1018
  return;
1006
- const x = n.getFocusDrawings();
1007
- if (x.length === 0)
1019
+ const focusDrawings = drawingManagerService.getFocusDrawings();
1020
+ if (focusDrawings.length === 0)
1008
1021
  return;
1009
- const { drawingId: M, unitId: W } = x[0], G = o.getUniverDocInstance(W), F = (Ie = r.getRenderById(W)) == null ? void 0 : Ie.with(ae).getSkeleton(), ce = a.getSegment(), fe = a.getSegmentPage(), Oe = (Te = (Se = G == null ? void 0 : G.getSelfOrHeaderFooterModel(ce).getBody()) == null ? void 0 : Se.customBlocks) == null ? void 0 : Te.find((J) => J.blockId === M);
1010
- if (Oe == null || F == null)
1022
+ const { drawingId, unitId: unitId2 } = focusDrawings[0], documentDataModel2 = univerInstanceService.getUniverDocInstance(unitId2), skeleton = (_a8 = renderManagerService.getRenderById(unitId2)) == null ? void 0 : _a8.with(DocSkeletonManagerService).getSkeleton(), segmentId = textSelectionRenderService.getSegment(), segmentPage = textSelectionRenderService.getSegmentPage(), drawing = (_c = (_b = documentDataModel2 == null ? void 0 : documentDataModel2.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _b.customBlocks) == null ? void 0 : _c.find((c) => c.blockId === drawingId);
1023
+ if (drawing == null || skeleton == null)
1011
1024
  return;
1012
- const { startIndex: Be } = Oe, Ce = F.findNodeByCharIndex(Be, ce, fe), K = (Me = Ce == null ? void 0 : Ce.parent) == null ? void 0 : Me.parent, le = K == null ? void 0 : K.parent, we = le == null ? void 0 : le.lines.find((J) => J.paragraphIndex === (K == null ? void 0 : K.paragraphIndex) && J.paragraphStart), ve = (De = le == null ? void 0 : le.parent) == null ? void 0 : De.parent;
1013
- if (Ce == null || K == null || we == null || le == null || ve == null)
1025
+ const { startIndex } = drawing, glyph = skeleton.findNodeByCharIndex(startIndex, segmentId, segmentPage), line = (_d = glyph == null ? void 0 : glyph.parent) == null ? void 0 : _d.parent, column = line == null ? void 0 : line.parent, paragraphStartLine = column == null ? void 0 : column.lines.find((l) => l.paragraphIndex === (line == null ? void 0 : line.paragraphIndex) && l.paragraphStart), page = (_e = column == null ? void 0 : column.parent) == null ? void 0 : _e.parent;
1026
+ if (glyph == null || line == null || paragraphStartLine == null || column == null || page == null)
1014
1027
  return;
1015
- let ne = 0;
1016
- A === V.PARAGRAPH ? ne -= we.top : A === V.LINE ? ne -= K.top : A === V.PAGE && (ne += ve.marginTop), L === V.PARAGRAPH ? ne += we.top : L === V.LINE ? ne += K.top : L === V.PAGE && (ne -= ve.marginTop);
1017
- const Ne = {
1018
- relativeFrom: L,
1019
- posOffset: (P != null ? P : 0) - ne
1028
+ let delta = 0;
1029
+ prevRelativeFrom === ObjectRelativeFromV.PARAGRAPH ? delta -= paragraphStartLine.top : prevRelativeFrom === ObjectRelativeFromV.LINE ? delta -= line.top : prevRelativeFrom === ObjectRelativeFromV.PAGE && (delta += page.marginTop), relativeFrom === ObjectRelativeFromV.PARAGRAPH ? delta += paragraphStartLine.top : relativeFrom === ObjectRelativeFromV.LINE ? delta += line.top : relativeFrom === ObjectRelativeFromV.PAGE && (delta -= page.marginTop);
1030
+ const newPositionV = {
1031
+ relativeFrom,
1032
+ posOffset: (prevPosOffset != null ? prevPosOffset : 0) - delta
1020
1033
  };
1021
- E("positionV", Ne);
1034
+ handlePositionChange("positionV", newPositionV);
1022
1035
  }
1023
- function U(S) {
1024
- var W;
1025
- const A = m == null ? void 0 : m.getSnapshot(), P = (W = A == null ? void 0 : A.drawings) == null ? void 0 : W[S.drawingId];
1026
- if (P == null)
1036
+ __name(handleVerticalRelativeFromChange, "handleVerticalRelativeFromChange");
1037
+ function updateState(drawingParam2) {
1038
+ var _a8;
1039
+ const snapshot = documentDataModel == null ? void 0 : documentDataModel.getSnapshot(), drawing = (_a8 = snapshot == null ? void 0 : snapshot.drawings) == null ? void 0 : _a8[drawingParam2.drawingId];
1040
+ if (drawing == null)
1027
1041
  return;
1028
- const { layoutType: L } = P, {
1029
- positionH: x,
1030
- positionV: M
1031
- } = P.docTransform;
1032
- _(x), O(M), I(L === k.INLINE), T(M.relativeFrom === V.PARAGRAPH || M.relativeFrom === V.LINE);
1033
- }
1034
- function B() {
1035
- const S = n.getFocusDrawings();
1036
- S.length !== 0 && U(S[0]);
1037
- }
1038
- function b(S) {
1039
- T(S), z(String(S ? V.PARAGRAPH : V.PAGE));
1040
- }
1041
- return ht(() => {
1042
- B();
1043
- const S = n.focus$.subscribe((P) => {
1044
- if (P.length === 0) {
1045
- R(!1);
1042
+ const { layoutType } = drawing, {
1043
+ positionH,
1044
+ positionV
1045
+ } = drawing.docTransform;
1046
+ setHPosition(positionH), setVPosition(positionV), setDisabled(layoutType === PositionedObjectLayoutType.INLINE), setFollowTextMove(positionV.relativeFrom === ObjectRelativeFromV.PARAGRAPH || positionV.relativeFrom === ObjectRelativeFromV.LINE);
1047
+ }
1048
+ __name(updateState, "updateState");
1049
+ function updateFocusDrawingState() {
1050
+ const focusDrawings = drawingManagerService.getFocusDrawings();
1051
+ focusDrawings.length !== 0 && updateState(focusDrawings[0]);
1052
+ }
1053
+ __name(updateFocusDrawingState, "updateFocusDrawingState");
1054
+ function handleFollowTextMoveCheck(val) {
1055
+ setFollowTextMove(val), handleVerticalRelativeFromChange(String(val ? ObjectRelativeFromV.PARAGRAPH : ObjectRelativeFromV.PAGE));
1056
+ }
1057
+ return __name(handleFollowTextMoveCheck, "handleFollowTextMoveCheck"), useEffect(() => {
1058
+ updateFocusDrawingState();
1059
+ const subscription = drawingManagerService.focus$.subscribe((drawingParams) => {
1060
+ if (drawingParams.length === 0) {
1061
+ setShowPanel(!1);
1046
1062
  return;
1047
1063
  }
1048
- R(!0), U(P[0]);
1049
- }), A = e.onCommandExecuted(async (P) => {
1050
- P.id === Q.id && B();
1064
+ setShowPanel(!0), updateState(drawingParams[0]);
1065
+ }), mutationListener = commandService.onCommandExecuted(async (command) => {
1066
+ command.id === RichTextEditingMutation.id && updateFocusDrawingState();
1051
1067
  });
1052
1068
  return () => {
1053
- S.unsubscribe(), A.dispose();
1069
+ subscription.unsubscribe(), mutationListener.dispose();
1054
1070
  };
1055
- }, []), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: N ? "block" : "none" } }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-position.title")))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-position.horizontal")))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-position.absolutePosition"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
1056
- Ae,
1071
+ }, []), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelGrid, styles.imageCommonPanelBorder), style: { display: showPanel ? "block" : "none" } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-position.title")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-position.horizontal")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-position.absolutePosition"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1072
+ InputNumber,
1057
1073
  {
1058
- min: xt,
1059
- max: Lt,
1074
+ min: MIN_OFFSET,
1075
+ max: MAX_OFFSET,
1060
1076
  precision: 1,
1061
- disabled: v,
1062
- value: D.posOffset,
1063
- onChange: (S) => {
1064
- E("positionH", {
1065
- relativeFrom: D.relativeFrom,
1066
- posOffset: S
1077
+ disabled,
1078
+ value: hPosition.posOffset,
1079
+ onChange: /* @__PURE__ */ __name((val) => {
1080
+ handlePositionChange("positionH", {
1081
+ relativeFrom: hPosition.relativeFrom,
1082
+ posOffset: val
1067
1083
  });
1068
- },
1069
- className: g.imageCommonPanelInput
1084
+ }, "onChange"),
1085
+ className: styles.imageCommonPanelInput
1070
1086
  }
1071
- ))))), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-position.toTheRightOf"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
1072
- Rt,
1087
+ ))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-position.toTheRightOf"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1088
+ Select,
1073
1089
  {
1074
- value: String(D.relativeFrom),
1075
- disabled: v,
1076
- options: p,
1077
- onChange: H
1090
+ value: String(hPosition.relativeFrom),
1091
+ disabled,
1092
+ options: HORIZONTAL_RELATIVE_FROM,
1093
+ onChange: handleHorizontalRelativeFromChange
1078
1094
  }
1079
- )))))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-position.vertical")))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-position.absolutePosition"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
1080
- Ae,
1095
+ )))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-position.vertical")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-position.absolutePosition"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1096
+ InputNumber,
1081
1097
  {
1082
- min: xt,
1083
- max: Lt,
1098
+ min: MIN_OFFSET,
1099
+ max: MAX_OFFSET,
1084
1100
  precision: 1,
1085
- disabled: v,
1086
- value: C.posOffset,
1087
- onChange: (S) => {
1088
- E("positionV", {
1089
- relativeFrom: C.relativeFrom,
1090
- posOffset: S
1101
+ disabled,
1102
+ value: vPosition.posOffset,
1103
+ onChange: /* @__PURE__ */ __name((val) => {
1104
+ handlePositionChange("positionV", {
1105
+ relativeFrom: vPosition.relativeFrom,
1106
+ posOffset: val
1091
1107
  });
1092
- },
1093
- className: g.imageCommonPanelInput
1108
+ }, "onChange"),
1109
+ className: styles.imageCommonPanelInput
1094
1110
  }
1095
- ))))), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-position.bellow"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
1096
- Rt,
1111
+ ))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-position.bellow"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1112
+ Select,
1097
1113
  {
1098
- disabled: v,
1099
- value: String(C.relativeFrom),
1100
- options: w,
1101
- onChange: z
1114
+ disabled,
1115
+ value: String(vPosition.relativeFrom),
1116
+ options: VERTICAL_RELATIVE_FROM,
1117
+ onChange: handleVerticalRelativeFromChange
1102
1118
  }
1103
- )))))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-position.options")))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow, style: { marginBottom: "50px" } }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(si, { disabled: v, checked: y, onChange: b }, t.t("image-position.moveObjectWithText")))));
1104
- }, Hi = () => {
1105
- const i = re(he), e = i.getFocusDrawings(), [t, n] = ie(e);
1106
- return ht(() => {
1107
- const r = i.focus$.subscribe((o) => {
1108
- n(o);
1119
+ )))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-position.options")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow, style: { marginBottom: "50px" } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(Checkbox, { disabled, checked: followTextMove, onChange: handleFollowTextMoveCheck }, localeService.t("image-position.moveObjectWithText")))));
1120
+ }, "DocDrawingPosition"), DocDrawingPanel = /* @__PURE__ */ __name(() => {
1121
+ const drawingManagerService = useDependency(IDrawingManagerService), focusDrawings = drawingManagerService.getFocusDrawings(), [drawings, setDrawings] = useState(focusDrawings);
1122
+ return useEffect(() => {
1123
+ const focusDispose = drawingManagerService.focus$.subscribe((drawings2) => {
1124
+ setDrawings(drawings2);
1109
1125
  });
1110
1126
  return () => {
1111
- r.unsubscribe();
1127
+ focusDispose.unsubscribe();
1112
1128
  };
1113
- }, []), !!(t != null && t.length) && /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanel }, /* @__PURE__ */ d.createElement(Nn, { drawings: t, hasAlign: !1, hasCropper: !1, hasGroup: !1, hasTransform: !1 }), /* @__PURE__ */ d.createElement(Fi, { drawings: t }), /* @__PURE__ */ d.createElement(ki, { drawings: t }));
1114
- }, Wi = {
1129
+ }, []), !!(drawings != null && drawings.length) && /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanel }, /* @__PURE__ */ React.createElement(DrawingCommonPanel, { drawings, hasAlign: !1, hasCropper: !1, hasGroup: !1, hasTransform: !1 }), /* @__PURE__ */ React.createElement(DocDrawingTextWrap, { drawings }), /* @__PURE__ */ React.createElement(DocDrawingPosition, { drawings }));
1130
+ }, "DocDrawingPanel"), ClearDocDrawingTransformerOperation = {
1115
1131
  id: "doc.operation.clear-drawing-transformer",
1116
- type: Y.MUTATION,
1117
- handler: (i, e) => {
1118
- const t = i.get(se);
1119
- return e.forEach((n) => {
1120
- var r, o;
1121
- (o = (r = t.getRenderById(n)) == null ? void 0 : r.scene.getTransformer()) == null || o.debounceRefreshControls();
1132
+ type: CommandType.MUTATION,
1133
+ handler: /* @__PURE__ */ __name((accessor, params) => {
1134
+ const renderManagerService = accessor.get(IRenderManagerService);
1135
+ return params.forEach((unitId) => {
1136
+ var _a8, _b;
1137
+ (_b = (_a8 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a8.scene.getTransformer()) == null || _b.debounceRefreshControls();
1122
1138
  }), !0;
1123
- }
1124
- }, Xe = {
1139
+ }, "handler")
1140
+ }, MoveDocDrawingsCommand = {
1125
1141
  id: "doc.command.move-drawing",
1126
- type: Y.COMMAND,
1127
- handler: (i, e) => {
1128
- const t = i.get($), n = i.get(Re), r = i.get(te), o = i.get(se), { direction: a } = e, s = n.getFocusDrawings();
1129
- if (s.length === 0)
1142
+ type: CommandType.COMMAND,
1143
+ handler: /* @__PURE__ */ __name((accessor, params) => {
1144
+ const commandService = accessor.get(ICommandService), docDrawingService = accessor.get(IDocDrawingService), univerInstanceService = accessor.get(IUniverInstanceService), renderManagerService = accessor.get(IRenderManagerService), { direction } = params, drawings = docDrawingService.getFocusDrawings();
1145
+ if (drawings.length === 0)
1130
1146
  return !1;
1131
- const l = s[0].unitId, c = o.getRenderById(l), m = c == null ? void 0 : c.scene;
1132
- if (m == null)
1147
+ const unitId = drawings[0].unitId, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1148
+ if (scene == null)
1133
1149
  return !1;
1134
- const u = m.getTransformerByCreate(), f = r.getUniverDocInstance(l), h = s.map((w) => {
1135
- var y, T, N, R, E;
1136
- const { drawingId: v } = w, I = (y = f == null ? void 0 : f.getSnapshot().drawings) == null ? void 0 : y[v];
1137
- if (I == null || I.layoutType === k.INLINE)
1150
+ const transformer = scene.getTransformerByCreate(), documentDataModel = univerInstanceService.getUniverDocInstance(unitId), newDrawings = drawings.map((drawing) => {
1151
+ var _a8, _b, _c, _d, _e;
1152
+ const { drawingId } = drawing, drawingData = (_a8 = documentDataModel == null ? void 0 : documentDataModel.getSnapshot().drawings) == null ? void 0 : _a8[drawingId];
1153
+ if (drawingData == null || drawingData.layoutType === PositionedObjectLayoutType.INLINE)
1138
1154
  return null;
1139
- const { positionH: D, positionV: _ } = I.docTransform, C = { ...D }, O = { ..._ };
1140
- return a === ge.UP ? O.posOffset = ((T = O.posOffset) != null ? T : 0) - 2 : a === ge.DOWN ? O.posOffset = ((N = O.posOffset) != null ? N : 0) + 2 : a === ge.LEFT ? C.posOffset = ((R = C.posOffset) != null ? R : 0) - 2 : a === ge.RIGHT && (C.posOffset = ((E = C.posOffset) != null ? E : 0) + 2), {
1141
- drawingId: v,
1142
- key: a === ge.UP || a === ge.DOWN ? "positionV" : "positionH",
1143
- value: a === ge.UP || a === ge.DOWN ? O : C
1155
+ const { positionH, positionV } = drawingData.docTransform, newPositionH = { ...positionH }, newPositionV = { ...positionV };
1156
+ return direction === Direction.UP ? newPositionV.posOffset = ((_b = newPositionV.posOffset) != null ? _b : 0) - 2 : direction === Direction.DOWN ? newPositionV.posOffset = ((_c = newPositionV.posOffset) != null ? _c : 0) + 2 : direction === Direction.LEFT ? newPositionH.posOffset = ((_d = newPositionH.posOffset) != null ? _d : 0) - 2 : direction === Direction.RIGHT && (newPositionH.posOffset = ((_e = newPositionH.posOffset) != null ? _e : 0) + 2), {
1157
+ drawingId,
1158
+ key: direction === Direction.UP || direction === Direction.DOWN ? "positionV" : "positionH",
1159
+ value: direction === Direction.UP || direction === Direction.DOWN ? newPositionV : newPositionH
1144
1160
  };
1145
- }).filter((w) => w != null);
1146
- if (h.length === 0)
1161
+ }).filter((drawing) => drawing != null);
1162
+ if (newDrawings.length === 0)
1147
1163
  return !1;
1148
- const p = t.syncExecuteCommand(ze.id, {
1149
- unitId: l,
1150
- subUnitId: l,
1151
- drawings: h
1164
+ const result = commandService.syncExecuteCommand(UpdateDrawingDocTransformCommand.id, {
1165
+ unitId,
1166
+ subUnitId: unitId,
1167
+ drawings: newDrawings
1152
1168
  });
1153
- return u.refreshControls(), !!p;
1154
- }
1155
- }, cn = {
1169
+ return transformer.refreshControls(), !!result;
1170
+ }, "handler")
1171
+ }, DeleteDocDrawingsCommand = {
1156
1172
  id: "doc.command.delete-drawing",
1157
- type: Y.COMMAND,
1158
- handler: (i) => {
1159
- const e = i.get($), n = i.get(Re).getFocusDrawings();
1160
- if (n.length === 0)
1173
+ type: CommandType.COMMAND,
1174
+ handler: /* @__PURE__ */ __name((accessor) => {
1175
+ const commandService = accessor.get(ICommandService), drawings = accessor.get(IDocDrawingService).getFocusDrawings();
1176
+ if (drawings.length === 0)
1161
1177
  return !1;
1162
- const { unitId: r } = n[0], o = n.map((a) => {
1163
- const { unitId: s, subUnitId: l, drawingId: c, drawingType: m } = a;
1178
+ const { unitId } = drawings[0], newDrawings = drawings.map((drawing) => {
1179
+ const { unitId: unitId2, subUnitId, drawingId, drawingType } = drawing;
1164
1180
  return {
1165
- unitId: s,
1166
- subUnitId: l,
1167
- drawingId: c,
1168
- drawingType: m
1181
+ unitId: unitId2,
1182
+ subUnitId,
1183
+ drawingId,
1184
+ drawingType
1169
1185
  };
1170
1186
  });
1171
- return e.executeCommand(wt.id, {
1172
- unitId: r,
1173
- drawings: o
1187
+ return commandService.executeCommand(RemoveDocDrawingCommand.id, {
1188
+ unitId,
1189
+ drawings: newDrawings
1174
1190
  });
1175
- }
1176
- }, ln = {
1191
+ }, "handler")
1192
+ }, SetDocDrawingArrangeCommand = {
1177
1193
  id: "doc.command.set-drawing-arrange",
1178
- type: Y.COMMAND,
1179
- handler: (i, e) => {
1180
- const t = i.get($), n = i.get(Re);
1181
- if (e == null)
1194
+ type: CommandType.COMMAND,
1195
+ handler: /* @__PURE__ */ __name((accessor, params) => {
1196
+ const commandService = accessor.get(ICommandService), docDrawingService = accessor.get(IDocDrawingService);
1197
+ if (params == null)
1182
1198
  return !1;
1183
- const { unitId: r, subUnitId: o, drawingIds: a, arrangeType: s } = e, l = { unitId: r, subUnitId: o, drawingIds: a };
1184
- let c;
1185
- if (s === Ye.forward ? c = n.getForwardDrawingsOp(l) : s === Ye.backward ? c = n.getBackwardDrawingOp(l) : s === Ye.front ? c = n.getFrontDrawingsOp(l) : s === Ye.back && (c = n.getBackDrawingsOp(l)), c == null)
1199
+ const { unitId, subUnitId, drawingIds, arrangeType } = params, drawingOrderMapParam = { unitId, subUnitId, drawingIds };
1200
+ let jsonOp;
1201
+ if (arrangeType === ArrangeTypeEnum.forward ? jsonOp = docDrawingService.getForwardDrawingsOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.backward ? jsonOp = docDrawingService.getBackwardDrawingOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.front ? jsonOp = docDrawingService.getFrontDrawingsOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.back && (jsonOp = docDrawingService.getBackDrawingsOp(drawingOrderMapParam)), jsonOp == null)
1186
1202
  return !1;
1187
- const { redo: m } = c;
1188
- if (m == null)
1203
+ const { redo } = jsonOp;
1204
+ if (redo == null)
1189
1205
  return !1;
1190
- const u = [];
1191
- let f = Pe.deepClone(m);
1192
- f = f.slice(3), f.unshift("drawingsOrder"), u.push(f);
1193
- const h = {
1194
- id: Q.id,
1206
+ const rawActions = [];
1207
+ let redoCopy = Tools.deepClone(redo);
1208
+ redoCopy = redoCopy.slice(3), redoCopy.unshift("drawingsOrder"), rawActions.push(redoCopy);
1209
+ const doMutation = {
1210
+ id: RichTextEditingMutation.id,
1195
1211
  params: {
1196
- unitId: r,
1212
+ unitId,
1197
1213
  actions: [],
1198
1214
  textRanges: null
1199
1215
  }
1200
1216
  };
1201
- return h.params.actions = u.reduce((w, v) => X.compose(w, v), null), !!t.syncExecuteCommand(h.id, h.params);
1202
- }
1203
- }, dn = {
1217
+ return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
1218
+ }, "handler")
1219
+ }, UngroupDocDrawingCommand = {
1204
1220
  id: "doc.command.ungroup-doc-image",
1205
- type: Y.COMMAND,
1206
- handler: (i, e) => {
1207
- i.get($), i.get(Ft);
1208
- const t = i.get(Re);
1209
- if (!e) return !1;
1210
- const n = [];
1211
- return e.forEach(({ parent: r, children: o }) => {
1212
- n.push(r.unitId), o.forEach((a) => {
1213
- n.push(a.unitId);
1221
+ type: CommandType.COMMAND,
1222
+ handler: /* @__PURE__ */ __name((accessor, params) => {
1223
+ accessor.get(ICommandService), accessor.get(IUndoRedoService);
1224
+ const docDrawingService = accessor.get(IDocDrawingService);
1225
+ if (!params) return !1;
1226
+ const unitIds = [];
1227
+ return params.forEach(({ parent, children }) => {
1228
+ unitIds.push(parent.unitId), children.forEach((child) => {
1229
+ unitIds.push(child.unitId);
1214
1230
  });
1215
- }), t.getUngroupDrawingOp(e), !1;
1216
- }
1217
- }, mn = {
1231
+ }), docDrawingService.getUngroupDrawingOp(params), !1;
1232
+ }, "handler")
1233
+ }, GroupDocDrawingCommand = {
1218
1234
  id: "doc.command.group-doc-image",
1219
- type: Y.COMMAND,
1220
- handler: (i, e) => {
1221
- i.get($), i.get(Ft);
1222
- const t = i.get(Re);
1223
- if (!e) return !1;
1224
- const n = [];
1225
- return e.forEach(({ parent: r, children: o }) => {
1226
- n.push(r.unitId), o.forEach((a) => {
1227
- n.push(a.unitId);
1235
+ type: CommandType.COMMAND,
1236
+ handler: /* @__PURE__ */ __name((accessor, params) => {
1237
+ accessor.get(ICommandService), accessor.get(IUndoRedoService);
1238
+ const docDrawingService = accessor.get(IDocDrawingService);
1239
+ if (!params) return !1;
1240
+ const unitIds = [];
1241
+ return params.forEach(({ parent, children }) => {
1242
+ unitIds.push(parent.unitId), children.forEach((child) => {
1243
+ unitIds.push(child.unitId);
1228
1244
  });
1229
- }), t.getGroupDrawingOp(e), !1;
1230
- }
1231
- }, gn = {
1245
+ }), docDrawingService.getGroupDrawingOp(params), !1;
1246
+ }, "handler")
1247
+ }, InsertDocDrawingCommand = {
1232
1248
  id: "doc.command.insert-doc-image",
1233
- type: Y.COMMAND,
1249
+ type: CommandType.COMMAND,
1234
1250
  // eslint-disable-next-line max-lines-per-function
1235
- handler: (i, e) => {
1236
- var O, y;
1237
- if (e == null)
1251
+ handler: /* @__PURE__ */ __name((accessor, params) => {
1252
+ var _a8, _b;
1253
+ if (params == null)
1238
1254
  return !1;
1239
- const t = i.get($), n = i.get(gt), r = i.get(te), o = n.getActiveRange(), a = r.getCurrentUniverDocInstance();
1240
- if (o == null || a == null)
1255
+ const commandService = accessor.get(ICommandService), textSelectionManagerService = accessor.get(TextSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), activeTextRange = textSelectionManagerService.getActiveRange(), documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
1256
+ if (activeTextRange == null || documentDataModel == null)
1241
1257
  return !1;
1242
- const s = a.getUnitId(), { drawings: l } = e, { collapsed: c, startOffset: m, segmentId: u } = o, f = a.getSelfOrHeaderFooterModel(u).getBody();
1243
- if (f == null)
1258
+ const unitId = documentDataModel.getUnitId(), { drawings } = params, { collapsed, startOffset, segmentId } = activeTextRange, body = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
1259
+ if (body == null)
1244
1260
  return !1;
1245
- const h = new pt(), p = X.getInstance(), w = [], v = (y = (O = a.getSnapshot().drawingsOrder) == null ? void 0 : O.length) != null ? y : 0;
1246
- if (c)
1247
- m > 0 && h.push({
1248
- t: Z.RETAIN,
1249
- len: m,
1250
- segmentId: u
1261
+ const textX = new TextX(), jsonX = JSONX.getInstance(), rawActions = [], drawingOrderLength = (_b = (_a8 = documentDataModel.getSnapshot().drawingsOrder) == null ? void 0 : _a8.length) != null ? _b : 0;
1262
+ if (collapsed)
1263
+ startOffset > 0 && textX.push({
1264
+ t: TextXActionType.RETAIN,
1265
+ len: startOffset,
1266
+ segmentId
1251
1267
  });
1252
1268
  else {
1253
- const { dos: T } = Yn(o, u, 0, f);
1254
- h.push(...T);
1269
+ const { dos } = getRetainAndDeleteFromReplace(activeTextRange, segmentId, 0, body);
1270
+ textX.push(...dos);
1255
1271
  }
1256
- h.push({
1257
- t: Z.INSERT,
1272
+ textX.push({
1273
+ t: TextXActionType.INSERT,
1258
1274
  body: {
1259
- dataStream: "\b".repeat(l.length),
1260
- customBlocks: l.map((T, N) => ({
1261
- startIndex: N,
1262
- blockId: T.drawingId
1275
+ dataStream: "\b".repeat(drawings.length),
1276
+ customBlocks: drawings.map((drawing, i) => ({
1277
+ startIndex: i,
1278
+ blockId: drawing.drawingId
1263
1279
  }))
1264
1280
  },
1265
- len: l.length,
1281
+ len: drawings.length,
1266
1282
  line: 0,
1267
- segmentId: u
1283
+ segmentId
1268
1284
  });
1269
- const I = $e(a, u), D = p.editOp(h.serialize(), I);
1270
- w.push(D);
1271
- for (const T of l) {
1272
- const { drawingId: N } = T, R = p.insertOp(["drawings", N], T), E = p.insertOp(["drawingsOrder", v], N);
1273
- w.push(R), w.push(E);
1285
+ const path = getRichTextEditPath(documentDataModel, segmentId), placeHolderAction = jsonX.editOp(textX.serialize(), path);
1286
+ rawActions.push(placeHolderAction);
1287
+ for (const drawing of drawings) {
1288
+ const { drawingId } = drawing, addDrawingAction = jsonX.insertOp(["drawings", drawingId], drawing), addDrawingOrderAction = jsonX.insertOp(["drawingsOrder", drawingOrderLength], drawingId);
1289
+ rawActions.push(addDrawingAction), rawActions.push(addDrawingOrderAction);
1274
1290
  }
1275
- const _ = {
1276
- id: Q.id,
1291
+ const doMutation = {
1292
+ id: RichTextEditingMutation.id,
1277
1293
  params: {
1278
- unitId: s,
1294
+ unitId,
1279
1295
  actions: [],
1280
1296
  textRanges: []
1281
1297
  }
1282
1298
  };
1283
- return _.params.actions = w.reduce((T, N) => X.compose(T, N), null), !!t.syncExecuteCommand(_.id, _.params);
1284
- }
1299
+ return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
1300
+ }, "handler")
1285
1301
  };
1286
- function Ke(i) {
1287
- return i.getContextValue(Sn) && i.getContextValue(it);
1302
+ function whenDocDrawingFocused(contextService) {
1303
+ return contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && contextService.getContextValue(FOCUSING_COMMON_DRAWINGS);
1288
1304
  }
1289
- const Gi = {
1290
- id: Xe.id,
1305
+ __name(whenDocDrawingFocused, "whenDocDrawingFocused");
1306
+ const MoveDrawingDownShortcutItem = {
1307
+ id: MoveDocDrawingsCommand.id,
1291
1308
  description: "shortcut.doc.drawing-move-down",
1292
1309
  group: "4_doc-drawing-view",
1293
- binding: Le.ARROW_DOWN,
1310
+ binding: KeyCode.ARROW_DOWN,
1294
1311
  priority: 100,
1295
- preconditions: Ke,
1312
+ preconditions: whenDocDrawingFocused,
1296
1313
  staticParameters: {
1297
- direction: ge.DOWN
1314
+ direction: Direction.DOWN
1298
1315
  }
1299
- }, Vi = {
1300
- id: Xe.id,
1316
+ }, MoveDrawingUpShortcutItem = {
1317
+ id: MoveDocDrawingsCommand.id,
1301
1318
  description: "shortcut.doc.drawing-move-up",
1302
1319
  group: "4_doc-drawing-view",
1303
- binding: Le.ARROW_UP,
1320
+ binding: KeyCode.ARROW_UP,
1304
1321
  priority: 100,
1305
- preconditions: Ke,
1322
+ preconditions: whenDocDrawingFocused,
1306
1323
  staticParameters: {
1307
- direction: ge.UP
1324
+ direction: Direction.UP
1308
1325
  }
1309
- }, ji = {
1310
- id: Xe.id,
1326
+ }, MoveDrawingLeftShortcutItem = {
1327
+ id: MoveDocDrawingsCommand.id,
1311
1328
  description: "shortcut.doc.drawing-move-left",
1312
1329
  group: "4_doc-drawing-view",
1313
- binding: Le.ARROW_LEFT,
1330
+ binding: KeyCode.ARROW_LEFT,
1314
1331
  priority: 100,
1315
- preconditions: Ke,
1332
+ preconditions: whenDocDrawingFocused,
1316
1333
  staticParameters: {
1317
- direction: ge.LEFT
1334
+ direction: Direction.LEFT
1318
1335
  }
1319
- }, $i = {
1320
- id: Xe.id,
1336
+ }, MoveDrawingRightShortcutItem = {
1337
+ id: MoveDocDrawingsCommand.id,
1321
1338
  description: "shortcut.doc.drawing-move-right",
1322
1339
  group: "4_doc-drawing-view",
1323
- binding: Le.ARROW_RIGHT,
1340
+ binding: KeyCode.ARROW_RIGHT,
1324
1341
  priority: 100,
1325
- preconditions: Ke,
1342
+ preconditions: whenDocDrawingFocused,
1326
1343
  staticParameters: {
1327
- direction: ge.RIGHT
1344
+ direction: Direction.RIGHT
1328
1345
  }
1329
- }, zi = {
1330
- id: cn.id,
1346
+ }, DeleteDrawingsShortcutItem = {
1347
+ id: DeleteDocDrawingsCommand.id,
1331
1348
  description: "shortcut.doc.drawing-delete",
1332
1349
  group: "4_doc-drawing-view",
1333
1350
  // when focusing on any other input tag do not trigger this shortcut
1334
- preconditions: Ke,
1335
- binding: Le.DELETE,
1336
- mac: Le.BACKSPACE
1351
+ preconditions: whenDocDrawingFocused,
1352
+ binding: KeyCode.DELETE,
1353
+ mac: KeyCode.BACKSPACE
1337
1354
  };
1338
- var qi = Object.defineProperty, Xi = Object.getOwnPropertyDescriptor, Ki = (i, e, t, n) => {
1339
- for (var r = n > 1 ? void 0 : n ? Xi(e, t) : e, o = i.length - 1, a; o >= 0; o--)
1340
- (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
1341
- return n && r && qi(e, t, r), r;
1342
- }, He = (i, e) => (t, n) => e(t, n, i);
1343
- let et = class extends qe {
1344
- constructor(i, e, t, n, r) {
1345
- super(), this._injector = i, this._componentManager = e, this._menuService = t, this._commandService = n, this._shortcutService = r, this._init();
1355
+ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1356
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1357
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1358
+ return kind && result && __defProp$5(target, key, result), result;
1359
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a2;
1360
+ let DocDrawingUIController = (_a2 = class extends Disposable {
1361
+ constructor(_injector, _componentManager, _menuService, _commandService, _shortcutService) {
1362
+ super(), this._injector = _injector, this._componentManager = _componentManager, this._menuService = _menuService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._init();
1346
1363
  }
1347
1364
  _initCustomComponents() {
1348
- const i = this._componentManager;
1349
- this.disposeWithMe(i.register(Jt, Zt)), this.disposeWithMe(i.register(Qt, vi)), this.disposeWithMe(i.register(zt, Hi));
1365
+ const componentManager = this._componentManager;
1366
+ this.disposeWithMe(componentManager.register(ImageUploadIcon, AddImageSingle)), this.disposeWithMe(componentManager.register(COMPONENT_DOC_UPLOAD_FILE_MENU, UploadFileMenu)), this.disposeWithMe(componentManager.register(COMPONENT_DOC_DRAWING_PANEL, DocDrawingPanel));
1350
1367
  }
1351
1368
  _initMenus() {
1352
1369
  [
1353
- _i,
1354
- Ci
1355
- ].forEach((i) => {
1356
- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i), {}));
1370
+ ImageMenuFactory,
1371
+ UploadFloatImageMenuFactory
1372
+ ].forEach((factory) => {
1373
+ this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory), {}));
1357
1374
  });
1358
1375
  }
1359
1376
  _initCommands() {
1360
1377
  [
1361
- vt,
1362
- gn,
1363
- nn,
1364
- rn,
1365
- on,
1366
- ze,
1367
- an,
1368
- sn,
1369
- wt,
1370
- qt,
1371
- Wi,
1372
- Xt,
1373
- mn,
1374
- dn,
1375
- Xe,
1376
- cn,
1377
- ln
1378
- ].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i)));
1378
+ InsertDocImageOperation,
1379
+ InsertDocDrawingCommand,
1380
+ UpdateDocDrawingWrappingStyleCommand,
1381
+ UpdateDocDrawingDistanceCommand,
1382
+ UpdateDocDrawingWrapTextCommand,
1383
+ UpdateDrawingDocTransformCommand,
1384
+ IMoveInlineDrawingCommand,
1385
+ ITransformNonInlineDrawingCommand,
1386
+ RemoveDocDrawingCommand,
1387
+ SidebarDocDrawingOperation,
1388
+ ClearDocDrawingTransformerOperation,
1389
+ EditDocDrawingOperation,
1390
+ GroupDocDrawingCommand,
1391
+ UngroupDocDrawingCommand,
1392
+ MoveDocDrawingsCommand,
1393
+ DeleteDocDrawingsCommand,
1394
+ SetDocDrawingArrangeCommand
1395
+ ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
1379
1396
  }
1380
1397
  _initShortcuts() {
1381
1398
  [
1382
1399
  // sheet drawing shortcuts
1383
- Gi,
1384
- Vi,
1385
- ji,
1386
- $i,
1387
- zi
1388
- ].forEach((i) => {
1389
- this.disposeWithMe(this._shortcutService.registerShortcut(i));
1400
+ MoveDrawingDownShortcutItem,
1401
+ MoveDrawingUpShortcutItem,
1402
+ MoveDrawingLeftShortcutItem,
1403
+ MoveDrawingRightShortcutItem,
1404
+ DeleteDrawingsShortcutItem
1405
+ ].forEach((item) => {
1406
+ this.disposeWithMe(this._shortcutService.registerShortcut(item));
1390
1407
  });
1391
1408
  }
1392
1409
  _init() {
1393
1410
  this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
1394
1411
  }
1395
- };
1396
- et = Ki([
1397
- at(st.Ready, et),
1398
- He(0, pe(kt)),
1399
- He(1, pe(ni)),
1400
- He(2, ii),
1401
- He(3, $),
1402
- He(4, ri)
1403
- ], et);
1404
- var Yi = Object.defineProperty, Zi = Object.getOwnPropertyDescriptor, Qi = (i, e, t, n) => {
1405
- for (var r = n > 1 ? void 0 : n ? Zi(e, t) : e, o = i.length - 1, a; o >= 0; o--)
1406
- (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
1407
- return n && r && Yi(e, t, r), r;
1408
- }, de = (i, e) => (t, n) => e(t, n, i);
1409
- let ut = class extends qe {
1410
- constructor(i, e, t, n, r, o, a, s, l, c, m, u, f) {
1411
- super(), this._context = i, this._commandService = e, this._textSelectionManagerService = t, this._renderManagerSrv = n, this._imageIoService = r, this._docDrawingService = o, this._drawingManagerService = a, this._contextService = s, this._messageService = l, this._localeService = c, this._textSelectionManager = m, this._textSelectionRenderManager = u, this._docRefreshDrawingsService = f, this._initCommandListeners(), this._updateDrawingListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener(), this._editAreaChangeListener();
1412
+ }, __name(_a2, "DocDrawingUIController"), _a2);
1413
+ DocDrawingUIController = __decorateClass$5([
1414
+ OnLifecycle(LifecycleStages.Ready, DocDrawingUIController),
1415
+ __decorateParam$5(0, Inject(Injector)),
1416
+ __decorateParam$5(1, Inject(ComponentManager)),
1417
+ __decorateParam$5(2, IMenuService),
1418
+ __decorateParam$5(3, ICommandService),
1419
+ __decorateParam$5(4, IShortcutService)
1420
+ ], DocDrawingUIController);
1421
+ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1422
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1423
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1424
+ return kind && result && __defProp$4(target, key, result), result;
1425
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a3;
1426
+ let DocDrawingUpdateRenderController = (_a3 = class extends Disposable {
1427
+ constructor(_context, _commandService, _textSelectionManagerService, _renderManagerSrv, _imageIoService, _docDrawingService, _drawingManagerService, _contextService, _messageService, _localeService, _textSelectionManager, _textSelectionRenderManager, _docRefreshDrawingsService) {
1428
+ super(), this._context = _context, this._commandService = _commandService, this._textSelectionManagerService = _textSelectionManagerService, this._renderManagerSrv = _renderManagerSrv, this._imageIoService = _imageIoService, this._docDrawingService = _docDrawingService, this._drawingManagerService = _drawingManagerService, this._contextService = _contextService, this._messageService = _messageService, this._localeService = _localeService, this._textSelectionManager = _textSelectionManager, this._textSelectionRenderManager = _textSelectionRenderManager, this._docRefreshDrawingsService = _docRefreshDrawingsService, this._initCommandListeners(), this._updateDrawingListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener(), this._editAreaChangeListener();
1412
1429
  }
1413
1430
  /**
1414
1431
  * Upload image to cell or float image
1415
1432
  */
1416
1433
  _initCommandListeners() {
1417
1434
  this.disposeWithMe(
1418
- this._commandService.onCommandExecuted(async (i) => {
1419
- if (i.id === vt.id) {
1420
- const e = i.params;
1421
- if (e.files == null)
1435
+ this._commandService.onCommandExecuted(async (command) => {
1436
+ if (command.id === InsertDocImageOperation.id) {
1437
+ const params = command.params;
1438
+ if (params.files == null)
1422
1439
  return;
1423
- const t = e.files.length;
1424
- if (t > St) {
1440
+ const fileLength = params.files.length;
1441
+ if (fileLength > DRAWING_IMAGE_COUNT_LIMIT) {
1425
1442
  this._messageService.show({
1426
- type: Nt.Error,
1427
- content: this._localeService.t("update-status.exceedMaxCount", String(St))
1443
+ type: MessageType.Error,
1444
+ content: this._localeService.t("update-status.exceedMaxCount", String(DRAWING_IMAGE_COUNT_LIMIT))
1428
1445
  });
1429
1446
  return;
1430
1447
  }
1431
- this._imageIoService.setWaitCount(t), await this._insertFloatImages(e.files);
1448
+ this._imageIoService.setWaitCount(fileLength), await this._insertFloatImages(params.files);
1432
1449
  }
1433
1450
  })
1434
1451
  );
1435
1452
  }
1436
1453
  // eslint-disable-next-line max-lines-per-function
1437
- async _insertFloatImages(i) {
1438
- let e = [];
1454
+ async _insertFloatImages(files) {
1455
+ let imageParams = [];
1439
1456
  try {
1440
- e = await Promise.all(i.map((r) => this._imageIoService.saveImage(r)));
1441
- } catch (r) {
1442
- const o = r.message;
1443
- let a = "";
1444
- switch (o) {
1445
- case mt.ERROR_EXCEED_SIZE:
1446
- a = this._localeService.t("update-status.exceedMaxSize", String(Ln / (1024 * 1024)));
1457
+ imageParams = await Promise.all(files.map((file) => this._imageIoService.saveImage(file)));
1458
+ } catch (error) {
1459
+ const type = error.message;
1460
+ let content = "";
1461
+ switch (type) {
1462
+ case ImageUploadStatusType.ERROR_EXCEED_SIZE:
1463
+ content = this._localeService.t("update-status.exceedMaxSize", String(DRAWING_IMAGE_ALLOW_SIZE / (1024 * 1024)));
1447
1464
  break;
1448
- case mt.ERROR_IMAGE_TYPE:
1449
- a = this._localeService.t("update-status.invalidImageType");
1465
+ case ImageUploadStatusType.ERROR_IMAGE_TYPE:
1466
+ content = this._localeService.t("update-status.invalidImageType");
1450
1467
  break;
1451
- case mt.ERROR_IMAGE:
1452
- a = this._localeService.t("update-status.invalidImage");
1468
+ case ImageUploadStatusType.ERROR_IMAGE:
1469
+ content = this._localeService.t("update-status.invalidImage");
1453
1470
  break;
1454
1471
  }
1455
1472
  this._messageService.show({
1456
- type: Nt.Error,
1457
- content: a
1473
+ type: MessageType.Error,
1474
+ content
1458
1475
  });
1459
1476
  }
1460
- if (e.length === 0)
1477
+ if (imageParams.length === 0)
1461
1478
  return;
1462
- const { unitId: t } = this._context, n = [];
1463
- for (const r of e) {
1464
- if (r == null)
1479
+ const { unitId } = this._context, docDrawingParams = [];
1480
+ for (const imageParam of imageParams) {
1481
+ if (imageParam == null)
1465
1482
  continue;
1466
- const { imageId: o, imageSourceType: a, source: s, base64Cache: l } = r, { width: c, height: m, image: u } = await Un(l || "");
1467
- this._imageIoService.addImageSourceCache(o, a, u);
1468
- let f = 1;
1469
- if (c > Dt || m > Et) {
1470
- const v = Dt / c, I = Et / m;
1471
- f = Math.min(v, I);
1483
+ const { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || "");
1484
+ this._imageIoService.addImageSourceCache(imageId, imageSourceType, image);
1485
+ let scale = 1;
1486
+ if (width > DRAWING_IMAGE_WIDTH_LIMIT || height > DRAWING_IMAGE_HEIGHT_LIMIT) {
1487
+ const scaleWidth = DRAWING_IMAGE_WIDTH_LIMIT / width, scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
1488
+ scale = Math.min(scaleWidth, scaleHeight);
1472
1489
  }
1473
- const h = this._getImagePosition(c * f, m * f);
1474
- if (h == null)
1490
+ const docTransform = this._getImagePosition(width * scale, height * scale);
1491
+ if (docTransform == null)
1475
1492
  return;
1476
- const p = {
1477
- unitId: t,
1478
- subUnitId: t,
1479
- drawingId: o,
1480
- drawingType: Bn.DRAWING_IMAGE,
1481
- imageSourceType: a,
1482
- source: s,
1483
- transform: Kn(h),
1484
- docTransform: h,
1485
- behindDoc: oe.FALSE,
1493
+ const docDrawingParam = {
1494
+ unitId,
1495
+ subUnitId: unitId,
1496
+ drawingId: imageId,
1497
+ drawingType: DrawingTypeEnum.DRAWING_IMAGE,
1498
+ imageSourceType,
1499
+ source,
1500
+ transform: docDrawingPositionToTransform(docTransform),
1501
+ docTransform,
1502
+ behindDoc: BooleanNumber.FALSE,
1486
1503
  title: "",
1487
1504
  description: "",
1488
- layoutType: k.INLINE,
1505
+ layoutType: PositionedObjectLayoutType.INLINE,
1489
1506
  // Insert inline drawing by default.
1490
- wrapText: je.BOTH_SIDES,
1507
+ wrapText: WrapTextType.BOTH_SIDES,
1491
1508
  distB: 0,
1492
1509
  distL: 0,
1493
1510
  distR: 0,
1494
1511
  distT: 0
1495
1512
  };
1496
- this._isInsertInHeaderFooter() && (p.isMultiTransform = oe.TRUE, p.transforms = p.transform ? [p.transform] : null), n.push(p);
1513
+ this._isInsertInHeaderFooter() && (docDrawingParam.isMultiTransform = BooleanNumber.TRUE, docDrawingParam.transforms = docDrawingParam.transform ? [docDrawingParam.transform] : null), docDrawingParams.push(docDrawingParam);
1497
1514
  }
1498
- this._commandService.executeCommand(gn.id, {
1499
- unitId: t,
1500
- drawings: n
1515
+ this._commandService.executeCommand(InsertDocDrawingCommand.id, {
1516
+ unitId,
1517
+ drawings: docDrawingParams
1501
1518
  });
1502
1519
  }
1503
1520
  _isInsertInHeaderFooter() {
1504
- var n;
1505
- const { unitId: i } = this._context, e = (n = this._renderManagerSrv.getRenderById(i)) == null ? void 0 : n.with(ae).getViewModel(), t = e == null ? void 0 : e.getEditArea();
1506
- return t === xe.HEADER || t === xe.FOOTER;
1521
+ var _a8;
1522
+ const { unitId } = this._context, viewModel = (_a8 = this._renderManagerSrv.getRenderById(unitId)) == null ? void 0 : _a8.with(DocSkeletonManagerService).getViewModel(), editArea = viewModel == null ? void 0 : viewModel.getEditArea();
1523
+ return editArea === DocumentEditArea.HEADER || editArea === DocumentEditArea.FOOTER;
1507
1524
  }
1508
- _getImagePosition(i, e) {
1509
- const t = this._textSelectionManagerService.getActiveTextRange(), n = (t == null ? void 0 : t.getAbsolutePosition()) || {
1525
+ _getImagePosition(imageWidth, imageHeight) {
1526
+ const activeTextRange = this._textSelectionManagerService.getActiveTextRange(), position = (activeTextRange == null ? void 0 : activeTextRange.getAbsolutePosition()) || {
1510
1527
  left: 0,
1511
1528
  top: 0
1512
1529
  };
1513
1530
  return {
1514
1531
  size: {
1515
- width: i,
1516
- height: e
1532
+ width: imageWidth,
1533
+ height: imageHeight
1517
1534
  },
1518
1535
  positionH: {
1519
- relativeFrom: ee.PAGE,
1520
- posOffset: n.left
1536
+ relativeFrom: ObjectRelativeFromH.PAGE,
1537
+ posOffset: position.left
1521
1538
  },
1522
1539
  positionV: {
1523
- relativeFrom: V.MARGIN,
1524
- posOffset: n.top
1540
+ relativeFrom: ObjectRelativeFromV.MARGIN,
1541
+ posOffset: position.top
1525
1542
  },
1526
1543
  angle: 0
1527
1544
  };
1528
1545
  }
1529
1546
  _updateOrderListener() {
1530
- this._drawingManagerService.featurePluginOrderUpdate$.subscribe((i) => {
1531
- const { unitId: e, subUnitId: t, drawingIds: n, arrangeType: r } = i;
1532
- this._commandService.executeCommand(ln.id, {
1533
- unitId: e,
1534
- subUnitId: t,
1535
- drawingIds: n,
1536
- arrangeType: r
1547
+ this._drawingManagerService.featurePluginOrderUpdate$.subscribe((params) => {
1548
+ const { unitId, subUnitId, drawingIds, arrangeType } = params;
1549
+ this._commandService.executeCommand(SetDocDrawingArrangeCommand.id, {
1550
+ unitId,
1551
+ subUnitId,
1552
+ drawingIds,
1553
+ arrangeType
1537
1554
  });
1538
1555
  });
1539
1556
  }
1540
1557
  _updateDrawingListener() {
1541
- this._drawingManagerService.featurePluginUpdate$.subscribe((i) => {
1558
+ this._drawingManagerService.featurePluginUpdate$.subscribe((params) => {
1542
1559
  });
1543
1560
  }
1544
1561
  _groupDrawingListener() {
1545
- this._drawingManagerService.featurePluginGroupUpdate$.subscribe((i) => {
1546
- this._commandService.executeCommand(mn.id, i);
1547
- }), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((i) => {
1548
- this._commandService.executeCommand(dn.id, i);
1562
+ this._drawingManagerService.featurePluginGroupUpdate$.subscribe((params) => {
1563
+ this._commandService.executeCommand(GroupDocDrawingCommand.id, params);
1564
+ }), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((params) => {
1565
+ this._commandService.executeCommand(UngroupDocDrawingCommand.id, params);
1549
1566
  });
1550
1567
  }
1551
1568
  _getCurrentSceneAndTransformer() {
1552
- const { scene: i, mainComponent: e } = this._context;
1553
- if (i == null || e == null)
1569
+ const { scene, mainComponent } = this._context;
1570
+ if (scene == null || mainComponent == null)
1554
1571
  return;
1555
- const t = i.getTransformerByCreate(), { docsLeft: n, docsTop: r } = e.getOffsetConfig();
1556
- return { scene: i, transformer: t, docsLeft: n, docsTop: r };
1572
+ const transformer = scene.getTransformerByCreate(), { docsLeft, docsTop } = mainComponent.getOffsetConfig();
1573
+ return { scene, transformer, docsLeft, docsTop };
1557
1574
  }
1558
1575
  _focusDrawingListener() {
1559
1576
  this.disposeWithMe(
1560
- this._drawingManagerService.focus$.subscribe((i) => {
1561
- var r;
1562
- const { transformer: e, docsLeft: t, docsTop: n } = (r = this._getCurrentSceneAndTransformer()) != null ? r : {};
1563
- if (i == null || i.length === 0)
1564
- this._contextService.setContextValue(it, !1), this._docDrawingService.focusDrawing([]), e && e.resetProps({
1577
+ this._drawingManagerService.focus$.subscribe((params) => {
1578
+ var _a8;
1579
+ const { transformer, docsLeft, docsTop } = (_a8 = this._getCurrentSceneAndTransformer()) != null ? _a8 : {};
1580
+ if (params == null || params.length === 0)
1581
+ this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1), this._docDrawingService.focusDrawing([]), transformer && transformer.resetProps({
1565
1582
  zeroTop: 0,
1566
1583
  zeroLeft: 0
1567
1584
  });
1568
1585
  else {
1569
- this._contextService.setContextValue(it, !0), this._docDrawingService.focusDrawing(i), this._textSelectionManager.getActiveTextRange() && this._textSelectionManager.replaceTextRanges([]);
1570
- const a = this._textSelectionRenderManager.getSegment(), s = this._findSegmentIdByDrawingId(i[0].drawingId);
1571
- a !== s && this._textSelectionRenderManager.setSegment(s), e && e.resetProps({
1572
- zeroTop: n,
1573
- zeroLeft: t
1586
+ this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !0), this._docDrawingService.focusDrawing(params), this._textSelectionManager.getActiveTextRange() && this._textSelectionManager.replaceTextRanges([]);
1587
+ const prevSegmentId = this._textSelectionRenderManager.getSegment(), segmentId = this._findSegmentIdByDrawingId(params[0].drawingId);
1588
+ prevSegmentId !== segmentId && this._textSelectionRenderManager.setSegment(segmentId), transformer && transformer.resetProps({
1589
+ zeroTop: docsTop,
1590
+ zeroLeft: docsLeft
1574
1591
  });
1575
1592
  }
1576
1593
  })
1577
1594
  );
1578
1595
  }
1579
- _findSegmentIdByDrawingId(i) {
1580
- var a, s, l;
1581
- const { unit: e } = this._context, { body: t, headers: n = {}, footers: r = {} } = e.getSnapshot();
1582
- if (((a = t == null ? void 0 : t.customBlocks) != null ? a : []).some((c) => c.blockId === i))
1596
+ _findSegmentIdByDrawingId(drawingId) {
1597
+ var _a8, _b, _c;
1598
+ const { unit: DocDataModel } = this._context, { body, headers = {}, footers = {} } = DocDataModel.getSnapshot();
1599
+ if (((_a8 = body == null ? void 0 : body.customBlocks) != null ? _a8 : []).some((b) => b.blockId === drawingId))
1583
1600
  return "";
1584
- for (const c of Object.keys(n))
1585
- if ((s = n[c].body.customBlocks) != null && s.some((m) => m.blockId === i))
1586
- return c;
1587
- for (const c of Object.keys(r))
1588
- if ((l = r[c].body.customBlocks) != null && l.some((m) => m.blockId === i))
1589
- return c;
1601
+ for (const headerId of Object.keys(headers))
1602
+ if ((_b = headers[headerId].body.customBlocks) != null && _b.some((b) => b.blockId === drawingId))
1603
+ return headerId;
1604
+ for (const footerId of Object.keys(footers))
1605
+ if ((_c = footers[footerId].body.customBlocks) != null && _c.some((b) => b.blockId === drawingId))
1606
+ return footerId;
1590
1607
  return "";
1591
1608
  }
1592
1609
  // Update drawings edit status and opacity. You can not edit header footer images when you are editing body. and vice verse.
1593
1610
  _updateDrawingsEditStatus() {
1594
- var s;
1595
- const { unit: i, scene: e, unitId: t } = this._context, n = (s = this._renderManagerSrv.getRenderById(t)) == null ? void 0 : s.with(ae).getViewModel();
1596
- if (n == null || i == null)
1611
+ var _a8;
1612
+ const { unit: docDataModel, scene, unitId } = this._context, viewModel = (_a8 = this._renderManagerSrv.getRenderById(unitId)) == null ? void 0 : _a8.with(DocSkeletonManagerService).getViewModel();
1613
+ if (viewModel == null || docDataModel == null)
1597
1614
  return;
1598
- const r = i.getSnapshot(), { drawings: o = {} } = r, a = n.getEditArea() === xe.BODY;
1599
- for (const l of Object.keys(o)) {
1600
- const c = o[l], m = Fn({ unitId: t, drawingId: c.drawingId, subUnitId: t }), u = e.fuzzyMathObjects(m, !0);
1601
- if (u.length)
1602
- for (const f of u)
1603
- e.detachTransformerFrom(f), f.setOpacity(0.5), (a && c.isMultiTransform !== oe.TRUE || !a && c.isMultiTransform === oe.TRUE) && (e.attachTransformerTo(f), f.setOpacity(1));
1615
+ const snapshot = docDataModel.getSnapshot(), { drawings = {} } = snapshot, isEditBody = viewModel.getEditArea() === DocumentEditArea.BODY;
1616
+ for (const key of Object.keys(drawings)) {
1617
+ const drawing = drawings[key], objectKey = getDrawingShapeKeyByDrawingSearch({ unitId, drawingId: drawing.drawingId, subUnitId: unitId }), drawingShapes = scene.fuzzyMathObjects(objectKey, !0);
1618
+ if (drawingShapes.length)
1619
+ for (const shape of drawingShapes)
1620
+ scene.detachTransformerFrom(shape), shape.setOpacity(0.5), (isEditBody && drawing.isMultiTransform !== BooleanNumber.TRUE || !isEditBody && drawing.isMultiTransform === BooleanNumber.TRUE) && (scene.attachTransformerTo(shape), shape.setOpacity(1));
1604
1621
  }
1605
1622
  }
1606
1623
  _editAreaChangeListener() {
1607
- var t;
1608
- const { unitId: i } = this._context, e = (t = this._renderManagerSrv.getRenderById(i)) == null ? void 0 : t.with(ae).getViewModel();
1609
- e != null && (this._updateDrawingsEditStatus(), this.disposeWithMe(
1610
- e.editAreaChange$.subscribe(() => {
1624
+ var _a8;
1625
+ const { unitId } = this._context, viewModel = (_a8 = this._renderManagerSrv.getRenderById(unitId)) == null ? void 0 : _a8.with(DocSkeletonManagerService).getViewModel();
1626
+ viewModel != null && (this._updateDrawingsEditStatus(), this.disposeWithMe(
1627
+ viewModel.editAreaChange$.subscribe(() => {
1611
1628
  this._updateDrawingsEditStatus();
1612
1629
  })
1613
- ), this._docRefreshDrawingsService.refreshDrawings$.subscribe((n) => {
1614
- n != null && queueMicrotask(() => {
1630
+ ), this._docRefreshDrawingsService.refreshDrawings$.subscribe((skeleton) => {
1631
+ skeleton != null && queueMicrotask(() => {
1615
1632
  this._updateDrawingsEditStatus();
1616
1633
  });
1617
1634
  }), this.disposeWithMe(
1618
- this._commandService.onCommandExecuted(async (n) => {
1619
- n.id === Q.id && queueMicrotask(() => {
1635
+ this._commandService.onCommandExecuted(async (command) => {
1636
+ command.id === RichTextEditingMutation.id && queueMicrotask(() => {
1620
1637
  this._updateDrawingsEditStatus();
1621
1638
  });
1622
1639
  })
1623
1640
  ));
1624
1641
  }
1625
- };
1626
- ut = Qi([
1627
- de(1, $),
1628
- de(2, pe(gt)),
1629
- de(3, se),
1630
- de(4, kn),
1631
- de(5, Re),
1632
- de(6, he),
1633
- de(7, Bt),
1634
- de(8, oi),
1635
- de(9, pe(ot)),
1636
- de(10, pe(gt)),
1637
- de(11, Ue),
1638
- de(12, pe(ct))
1639
- ], ut);
1640
- var Ji = Object.defineProperty, er = Object.getOwnPropertyDescriptor, tr = (i, e, t, n) => {
1641
- for (var r = n > 1 ? void 0 : n ? er(e, t) : e, o = i.length - 1, a; o >= 0; o--)
1642
- (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
1643
- return n && r && Ji(e, t, r), r;
1644
- }, We = (i, e) => (t, n) => e(t, n, i);
1645
- let ft = class extends qe {
1646
- constructor(e, t, n, r, o, a) {
1642
+ }, __name(_a3, "DocDrawingUpdateRenderController"), _a3);
1643
+ DocDrawingUpdateRenderController = __decorateClass$4([
1644
+ __decorateParam$4(1, ICommandService),
1645
+ __decorateParam$4(2, Inject(TextSelectionManagerService)),
1646
+ __decorateParam$4(3, IRenderManagerService),
1647
+ __decorateParam$4(4, IImageIoService),
1648
+ __decorateParam$4(5, IDocDrawingService),
1649
+ __decorateParam$4(6, IDrawingManagerService),
1650
+ __decorateParam$4(7, IContextService),
1651
+ __decorateParam$4(8, IMessageService),
1652
+ __decorateParam$4(9, Inject(LocaleService)),
1653
+ __decorateParam$4(10, Inject(TextSelectionManagerService)),
1654
+ __decorateParam$4(11, ITextSelectionRenderManager),
1655
+ __decorateParam$4(12, Inject(DocRefreshDrawingsService))
1656
+ ], DocDrawingUpdateRenderController);
1657
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1658
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1659
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1660
+ return kind && result && __defProp$3(target, key, result), result;
1661
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a4;
1662
+ let DocDrawingTransformUpdateController = (_a4 = class extends Disposable {
1663
+ constructor(_context, _docSkeletonManagerService, _commandService, _editorService, _drawingManagerService, _docRefreshDrawingsService) {
1647
1664
  super();
1648
- _e(this, "_liquid", new Ht());
1649
- this._context = e, this._docSkeletonManagerService = t, this._commandService = n, this._editorService = r, this._drawingManagerService = o, this._docRefreshDrawingsService = a, this._initialize(), this._commandExecutedListener();
1665
+ __publicField(this, "_liquid", new Liquid());
1666
+ this._context = _context, this._docSkeletonManagerService = _docSkeletonManagerService, this._commandService = _commandService, this._editorService = _editorService, this._drawingManagerService = _drawingManagerService, this._docRefreshDrawingsService = _docRefreshDrawingsService, this._initialize(), this._commandExecutedListener();
1650
1667
  }
1651
1668
  _initialize() {
1652
1669
  this._initialRenderRefresh();
1653
1670
  }
1654
1671
  _initialRenderRefresh() {
1655
- this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
1656
- e != null && this._refreshDrawing(e);
1657
- }), this._docRefreshDrawingsService.refreshDrawings$.subscribe((e) => {
1658
- e != null && this._refreshDrawing(e);
1672
+ this._docSkeletonManagerService.currentSkeleton$.subscribe((documentSkeleton) => {
1673
+ documentSkeleton != null && this._refreshDrawing(documentSkeleton);
1674
+ }), this._docRefreshDrawingsService.refreshDrawings$.subscribe((skeleton) => {
1675
+ skeleton != null && this._refreshDrawing(skeleton);
1659
1676
  });
1660
1677
  }
1661
1678
  _commandExecutedListener() {
1662
- const e = [Q.id, Zn.id];
1679
+ const updateCommandList = [RichTextEditingMutation.id, SetDocZoomRatioOperation.id];
1663
1680
  this.disposeWithMe(
1664
- this._commandService.onCommandExecuted((t) => {
1665
- if (e.includes(t.id)) {
1666
- const n = t.params, { unitId: r } = n, { unitId: o, mainComponent: a } = this._context;
1667
- if (r !== o)
1681
+ this._commandService.onCommandExecuted((command) => {
1682
+ if (updateCommandList.includes(command.id)) {
1683
+ const params = command.params, { unitId: commandUnitId } = params, { unitId, mainComponent } = this._context;
1684
+ if (commandUnitId !== unitId)
1668
1685
  return;
1669
- const s = this._docSkeletonManagerService.getSkeleton();
1670
- if (s == null)
1686
+ const skeleton = this._docSkeletonManagerService.getSkeleton();
1687
+ if (skeleton == null)
1671
1688
  return;
1672
- if (this._editorService.isEditor(o)) {
1673
- a == null || a.makeDirty();
1689
+ if (this._editorService.isEditor(unitId)) {
1690
+ mainComponent == null || mainComponent.makeDirty();
1674
1691
  return;
1675
1692
  }
1676
- this._refreshDrawing(s);
1693
+ this._refreshDrawing(skeleton);
1677
1694
  }
1678
1695
  })
1679
1696
  );
1680
1697
  }
1681
- _refreshDrawing(e) {
1682
- var D, _;
1683
- const t = e == null ? void 0 : e.getSkeletonData(), { mainComponent: n, unitId: r } = this._context, o = n;
1684
- if (!t)
1698
+ _refreshDrawing(skeleton) {
1699
+ var _a8, _b;
1700
+ const skeletonData = skeleton == null ? void 0 : skeleton.getSkeletonData(), { mainComponent, unitId } = this._context, documentComponent = mainComponent;
1701
+ if (!skeletonData)
1685
1702
  return;
1686
- const { left: a, top: s, pageLayoutType: l, pageMarginLeft: c, pageMarginTop: m } = o, { pages: u, skeHeaders: f, skeFooters: h } = t, p = {};
1703
+ const { left: docsLeft, top: docsTop, pageLayoutType, pageMarginLeft, pageMarginTop } = documentComponent, { pages, skeHeaders, skeFooters } = skeletonData, updateDrawingMap = {};
1687
1704
  this._liquid.reset();
1688
- for (let C = 0, O = u.length; C < O; C++) {
1689
- const y = u[C], { headerId: T, footerId: N, pageWidth: R } = y;
1690
- if (T) {
1691
- const E = (D = f.get(T)) == null ? void 0 : D.get(R);
1692
- E && this._calculateDrawingPosition(
1693
- r,
1694
- E,
1695
- a,
1696
- s,
1697
- p,
1698
- E.marginTop,
1699
- y.marginLeft
1705
+ for (let i = 0, len = pages.length; i < len; i++) {
1706
+ const page = pages[i], { headerId, footerId, pageWidth } = page;
1707
+ if (headerId) {
1708
+ const headerPage = (_a8 = skeHeaders.get(headerId)) == null ? void 0 : _a8.get(pageWidth);
1709
+ headerPage && this._calculateDrawingPosition(
1710
+ unitId,
1711
+ headerPage,
1712
+ docsLeft,
1713
+ docsTop,
1714
+ updateDrawingMap,
1715
+ headerPage.marginTop,
1716
+ page.marginLeft
1700
1717
  );
1701
1718
  }
1702
- if (N) {
1703
- const E = (_ = h.get(N)) == null ? void 0 : _.get(R);
1704
- E && this._calculateDrawingPosition(
1705
- r,
1706
- E,
1707
- a,
1708
- s,
1709
- p,
1710
- y.pageHeight - y.marginBottom + E.marginTop,
1711
- y.marginLeft
1719
+ if (footerId) {
1720
+ const footerPage = (_b = skeFooters.get(footerId)) == null ? void 0 : _b.get(pageWidth);
1721
+ footerPage && this._calculateDrawingPosition(
1722
+ unitId,
1723
+ footerPage,
1724
+ docsLeft,
1725
+ docsTop,
1726
+ updateDrawingMap,
1727
+ page.pageHeight - page.marginBottom + footerPage.marginTop,
1728
+ page.marginLeft
1712
1729
  );
1713
1730
  }
1714
- this._calculateDrawingPosition(r, y, a, s, p, y.marginTop, y.marginLeft), this._liquid.translatePage(y, l, c, m);
1731
+ this._calculateDrawingPosition(unitId, page, docsLeft, docsTop, updateDrawingMap, page.marginTop, page.marginLeft), this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
1715
1732
  }
1716
- const w = Object.values(p), v = w.filter((C) => !C.isMultiTransform), I = w.filter((C) => C.isMultiTransform);
1717
- v.length > 0 && this._drawingManagerService.refreshTransform(v), I.length > 0 && this._handleMultiDrawingsTransform(I);
1718
- }
1719
- _handleMultiDrawingsTransform(e) {
1720
- const { scene: t, unitId: n } = this._context, r = t.getTransformerByCreate();
1721
- e.forEach((l) => {
1722
- const c = this._drawingManagerService.getDrawingByParam(l);
1723
- c != null && (c.transform = l.transform, c.transforms = l.transforms, c.isMultiTransform = l.isMultiTransform);
1733
+ const updateDrawings = Object.values(updateDrawingMap), nonMultiDrawings = updateDrawings.filter((drawing) => !drawing.isMultiTransform), multiDrawings = updateDrawings.filter((drawing) => drawing.isMultiTransform);
1734
+ nonMultiDrawings.length > 0 && this._drawingManagerService.refreshTransform(nonMultiDrawings), multiDrawings.length > 0 && this._handleMultiDrawingsTransform(multiDrawings);
1735
+ }
1736
+ _handleMultiDrawingsTransform(multiDrawings) {
1737
+ const { scene, unitId } = this._context, transformer = scene.getTransformerByCreate();
1738
+ multiDrawings.forEach((updateParam) => {
1739
+ const param = this._drawingManagerService.getDrawingByParam(updateParam);
1740
+ param != null && (param.transform = updateParam.transform, param.transforms = updateParam.transforms, param.isMultiTransform = updateParam.isMultiTransform);
1724
1741
  });
1725
- const a = [...r.getSelectedObjectMap().keys()], s = Object.values(this._drawingManagerService.getDrawingData(n, n)).filter((l) => l.isMultiTransform === oe.TRUE);
1726
- this._drawingManagerService.removeNotification(s), this._drawingManagerService.addNotification(e);
1727
- for (const l of a) {
1728
- const c = t.getObject(l);
1729
- c && r.setSelectedControl(c);
1742
+ const selectedObjectKeys = [...transformer.getSelectedObjectMap().keys()], allMultiDrawings = Object.values(this._drawingManagerService.getDrawingData(unitId, unitId)).filter((drawing) => drawing.isMultiTransform === BooleanNumber.TRUE);
1743
+ this._drawingManagerService.removeNotification(allMultiDrawings), this._drawingManagerService.addNotification(multiDrawings);
1744
+ for (const key of selectedObjectKeys) {
1745
+ const drawingShape = scene.getObject(key);
1746
+ drawingShape && transformer.setSelectedControl(drawingShape);
1730
1747
  }
1731
1748
  }
1732
- _calculateDrawingPosition(e, t, n, r, o, a, s) {
1733
- const { skeDrawings: l } = t;
1749
+ _calculateDrawingPosition(unitId, page, docsLeft, docsTop, updateDrawingMap, marginTop, marginLeft) {
1750
+ const { skeDrawings } = page;
1734
1751
  this._liquid.translatePagePadding({
1735
- marginTop: a,
1736
- marginLeft: s
1737
- }), l.forEach((c) => {
1738
- const { aLeft: m, aTop: u, height: f, width: h, angle: p, drawingId: w, drawingOrigin: v } = c, I = v.layoutType === k.WRAP_NONE && v.behindDoc === oe.TRUE, { isMultiTransform: D = oe.FALSE } = v, _ = {
1739
- left: m + n + this._liquid.x,
1740
- top: u + r + this._liquid.y,
1741
- width: h,
1742
- height: f,
1743
- angle: p
1752
+ marginTop,
1753
+ marginLeft
1754
+ }), skeDrawings.forEach((drawing) => {
1755
+ const { aLeft, aTop, height, width, angle, drawingId, drawingOrigin } = drawing, behindText = drawingOrigin.layoutType === PositionedObjectLayoutType.WRAP_NONE && drawingOrigin.behindDoc === BooleanNumber.TRUE, { isMultiTransform = BooleanNumber.FALSE } = drawingOrigin, transform = {
1756
+ left: aLeft + docsLeft + this._liquid.x,
1757
+ top: aTop + docsTop + this._liquid.y,
1758
+ width,
1759
+ height,
1760
+ angle
1744
1761
  };
1745
- o[w] == null ? o[w] = {
1746
- unitId: e,
1747
- subUnitId: e,
1748
- drawingId: w,
1749
- behindText: I,
1750
- transform: _,
1751
- transforms: [_],
1752
- isMultiTransform: D
1753
- } : D === oe.TRUE && o[w].transforms.push(_);
1762
+ updateDrawingMap[drawingId] == null ? updateDrawingMap[drawingId] = {
1763
+ unitId,
1764
+ subUnitId: unitId,
1765
+ drawingId,
1766
+ behindText,
1767
+ transform,
1768
+ transforms: [transform],
1769
+ isMultiTransform
1770
+ } : isMultiTransform === BooleanNumber.TRUE && updateDrawingMap[drawingId].transforms.push(transform);
1754
1771
  }), this._liquid.restorePagePadding({
1755
- marginTop: a,
1756
- marginLeft: s
1772
+ marginTop,
1773
+ marginLeft
1757
1774
  });
1758
1775
  }
1759
- };
1760
- ft = tr([
1761
- We(1, pe(ae)),
1762
- We(2, $),
1763
- We(3, ai),
1764
- We(4, he),
1765
- We(5, pe(ct))
1766
- ], ft);
1767
- var nr = Object.defineProperty, ir = Object.getOwnPropertyDescriptor, rr = (i, e, t, n) => {
1768
- for (var r = n > 1 ? void 0 : n ? ir(e, t) : e, o = i.length - 1, a; o >= 0; o--)
1769
- (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
1770
- return n && r && nr(e, t, r), r;
1771
- }, Ge = (i, e) => (t, n) => e(t, n, i);
1772
- function or(i) {
1773
- var n, r, o, a;
1774
- if (X.isNoop(i) || !Array.isArray(i))
1776
+ }, __name(_a4, "DocDrawingTransformUpdateController"), _a4);
1777
+ DocDrawingTransformUpdateController = __decorateClass$3([
1778
+ __decorateParam$3(1, Inject(DocSkeletonManagerService)),
1779
+ __decorateParam$3(2, ICommandService),
1780
+ __decorateParam$3(3, IEditorService),
1781
+ __decorateParam$3(4, IDrawingManagerService),
1782
+ __decorateParam$3(5, Inject(DocRefreshDrawingsService))
1783
+ ], DocDrawingTransformUpdateController);
1784
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1785
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1786
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1787
+ return kind && result && __defProp$2(target, key, result), result;
1788
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2");
1789
+ function getAddOrRemoveDrawings(actions) {
1790
+ var _a8, _b, _c, _d;
1791
+ if (JSONX.isNoop(actions) || !Array.isArray(actions))
1775
1792
  return null;
1776
- const e = i.find((s) => Array.isArray(s) && (s == null ? void 0 : s[0]) === "drawings");
1777
- if (e == null || !Array.isArray(e) || e.length < 3 || typeof e[1] == "string" && typeof e[2] != "object" || Array.isArray(e[1]) && typeof e[1][1] != "object")
1793
+ const drawingsOp = actions.find((action) => Array.isArray(action) && (action == null ? void 0 : action[0]) === "drawings");
1794
+ if (drawingsOp == null || !Array.isArray(drawingsOp) || drawingsOp.length < 3 || typeof drawingsOp[1] == "string" && typeof drawingsOp[2] != "object" || Array.isArray(drawingsOp[1]) && typeof drawingsOp[1][1] != "object")
1778
1795
  return null;
1779
- const t = [];
1780
- if (Array.isArray(e == null ? void 0 : e[1]))
1781
- for (const s of e)
1782
- Array.isArray(s) && t.push({
1783
- type: (n = s == null ? void 0 : s[1]) != null && n.i ? "add" : "remove",
1784
- drawingId: s == null ? void 0 : s[0],
1785
- drawing: (r = s == null ? void 0 : s[1]) == null ? void 0 : r.i
1796
+ const drawings = [];
1797
+ if (Array.isArray(drawingsOp == null ? void 0 : drawingsOp[1]))
1798
+ for (const op of drawingsOp)
1799
+ Array.isArray(op) && drawings.push({
1800
+ type: (_a8 = op == null ? void 0 : op[1]) != null && _a8.i ? "add" : "remove",
1801
+ drawingId: op == null ? void 0 : op[0],
1802
+ drawing: (_b = op == null ? void 0 : op[1]) == null ? void 0 : _b.i
1786
1803
  });
1787
1804
  else
1788
- t.push({
1789
- type: (o = e[2]) != null && o.i ? "add" : "remove",
1790
- drawingId: e[1],
1791
- drawing: (a = e[2]) == null ? void 0 : a.i
1805
+ drawings.push({
1806
+ type: (_c = drawingsOp[2]) != null && _c.i ? "add" : "remove",
1807
+ drawingId: drawingsOp[1],
1808
+ drawing: (_d = drawingsOp[2]) == null ? void 0 : _d.i
1792
1809
  });
1793
- return t;
1810
+ return drawings;
1794
1811
  }
1795
- function ar(i) {
1796
- if (!Array.isArray(i) || i.length < 3 || i[0] !== "drawingsOrder")
1812
+ __name(getAddOrRemoveDrawings, "getAddOrRemoveDrawings");
1813
+ function getReOrderedDrawings(actions) {
1814
+ if (!Array.isArray(actions) || actions.length < 3 || actions[0] !== "drawingsOrder")
1797
1815
  return [];
1798
- const e = [];
1799
- for (let t = 1; t < i.length; t++) {
1800
- const n = i[t];
1801
- if (Array.isArray(n) && typeof n[0] == "number" && typeof n[1] == "object")
1802
- e.push(n[0]);
1816
+ const drawingIndexes = [];
1817
+ for (let i = 1; i < actions.length; i++) {
1818
+ const action = actions[i];
1819
+ if (Array.isArray(action) && typeof action[0] == "number" && typeof action[1] == "object")
1820
+ drawingIndexes.push(action[0]);
1803
1821
  else {
1804
- e.length = 0;
1822
+ drawingIndexes.length = 0;
1805
1823
  break;
1806
1824
  }
1807
1825
  }
1808
- return e;
1826
+ return drawingIndexes;
1809
1827
  }
1810
- let tt = class extends qe {
1811
- constructor(i, e, t, n, r) {
1812
- super(), this._univerInstanceService = i, this._commandService = e, this._drawingManagerService = t, this._docDrawingService = n, this._renderManagerService = r, this._initialize();
1828
+ __name(getReOrderedDrawings, "getReOrderedDrawings");
1829
+ var _a5;
1830
+ let DocDrawingAddRemoveController = (_a5 = class extends Disposable {
1831
+ constructor(_univerInstanceService, _commandService, _drawingManagerService, _docDrawingService, _renderManagerService) {
1832
+ super(), this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._drawingManagerService = _drawingManagerService, this._docDrawingService = _docDrawingService, this._renderManagerService = _renderManagerService, this._initialize();
1813
1833
  }
1814
1834
  _initialize() {
1815
1835
  this._commandExecutedListener();
1816
1836
  }
1817
1837
  _commandExecutedListener() {
1818
1838
  this.disposeWithMe(
1819
- this._commandService.beforeCommandExecuted((i) => {
1820
- if (i.id !== Q.id)
1839
+ this._commandService.beforeCommandExecuted((command) => {
1840
+ if (command.id !== RichTextEditingMutation.id)
1821
1841
  return;
1822
- const e = i.params, { unitId: t, actions: n } = e, r = or(n);
1823
- if (r != null)
1824
- for (const { type: o, drawingId: a, drawing: s } of r)
1825
- o === "add" ? this._addDrawings(t, [s]) : this._removeDrawings(t, [a]);
1842
+ const params = command.params, { unitId, actions } = params, addOrRemoveDrawings = getAddOrRemoveDrawings(actions);
1843
+ if (addOrRemoveDrawings != null)
1844
+ for (const { type, drawingId, drawing } of addOrRemoveDrawings)
1845
+ type === "add" ? this._addDrawings(unitId, [drawing]) : this._removeDrawings(unitId, [drawingId]);
1826
1846
  })
1827
1847
  ), this.disposeWithMe(
1828
- this._commandService.onCommandExecuted((i) => {
1829
- if (i.id !== Q.id)
1848
+ this._commandService.onCommandExecuted((command) => {
1849
+ if (command.id !== RichTextEditingMutation.id)
1830
1850
  return;
1831
- const e = i.params, { unitId: t, actions: n } = e;
1832
- ar(n).length > 0 && this._updateDrawingsOrder(t);
1851
+ const params = command.params, { unitId, actions } = params;
1852
+ getReOrderedDrawings(actions).length > 0 && this._updateDrawingsOrder(unitId);
1833
1853
  })
1834
1854
  ), this.disposeWithMe(
1835
- this._commandService.onCommandExecuted((i) => {
1836
- var a;
1837
- if (i.id !== Dn.id && i.id !== En.id)
1855
+ this._commandService.onCommandExecuted((command) => {
1856
+ var _a8;
1857
+ if (command.id !== UndoCommand.id && command.id !== RedoCommand.id)
1838
1858
  return;
1839
- const e = (a = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : a.getUnitId(), t = this._drawingManagerService.getFocusDrawings();
1840
- if (e == null || t.length === 0)
1859
+ const unitId = (_a8 = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : _a8.getUnitId(), focusedDrawings = this._drawingManagerService.getFocusDrawings();
1860
+ if (unitId == null || focusedDrawings.length === 0)
1841
1861
  return;
1842
- const n = this._renderManagerService.getRenderById(e), r = n == null ? void 0 : n.scene;
1843
- if (r == null)
1862
+ const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1863
+ if (scene == null)
1844
1864
  return !1;
1845
- r.getTransformerByCreate().refreshControls();
1865
+ scene.getTransformerByCreate().refreshControls();
1846
1866
  })
1847
1867
  );
1848
1868
  }
1849
- _addDrawings(i, e) {
1850
- const t = this._drawingManagerService, n = this._docDrawingService, r = this._docDrawingService.getBatchAddOp(e), { subUnitId: o, redo: a, objects: s } = r;
1851
- t.applyJson1(i, o, a), n.applyJson1(i, o, a), t.addNotification(s), n.addNotification(s);
1852
- }
1853
- _removeDrawings(i, e) {
1854
- const t = this._drawingManagerService, n = this._docDrawingService, r = this._docDrawingService.getBatchRemoveOp(e.map((l) => ({
1855
- unitId: i,
1856
- subUnitId: i,
1857
- drawingId: l
1858
- }))), { subUnitId: o, redo: a, objects: s } = r;
1859
- t.applyJson1(i, o, a), n.applyJson1(i, o, a), t.removeNotification(s), n.removeNotification(s);
1860
- }
1861
- _updateDrawingsOrder(i) {
1862
- const e = this._univerInstanceService.getUniverDocInstance(i);
1863
- if (e == null)
1869
+ _addDrawings(unitId, drawings) {
1870
+ const drawingManagerService = this._drawingManagerService, docDrawingService = this._docDrawingService, jsonOp = this._docDrawingService.getBatchAddOp(drawings), { subUnitId, redo: op, objects } = jsonOp;
1871
+ drawingManagerService.applyJson1(unitId, subUnitId, op), docDrawingService.applyJson1(unitId, subUnitId, op), drawingManagerService.addNotification(objects), docDrawingService.addNotification(objects);
1872
+ }
1873
+ _removeDrawings(unitId, drawingIds) {
1874
+ const drawingManagerService = this._drawingManagerService, docDrawingService = this._docDrawingService, jsonOp = this._docDrawingService.getBatchRemoveOp(drawingIds.map((drawingId) => ({
1875
+ unitId,
1876
+ subUnitId: unitId,
1877
+ drawingId
1878
+ }))), { subUnitId, redo: op, objects } = jsonOp;
1879
+ drawingManagerService.applyJson1(unitId, subUnitId, op), docDrawingService.applyJson1(unitId, subUnitId, op), drawingManagerService.removeNotification(objects), docDrawingService.removeNotification(objects);
1880
+ }
1881
+ _updateDrawingsOrder(unitId) {
1882
+ const documentDataModel = this._univerInstanceService.getUniverDocInstance(unitId);
1883
+ if (documentDataModel == null)
1864
1884
  return;
1865
- const t = e.getSnapshot().drawingsOrder;
1866
- if (t == null)
1885
+ const drawingsOrder = documentDataModel.getSnapshot().drawingsOrder;
1886
+ if (drawingsOrder == null)
1867
1887
  return;
1868
- const n = this._drawingManagerService, r = this._docDrawingService;
1869
- n.setDrawingOrder(i, i, t), r.setDrawingOrder(i, i, t);
1870
- const o = {
1871
- unitId: i,
1872
- subUnitId: i,
1873
- drawingIds: t
1888
+ const drawingManagerService = this._drawingManagerService, docDrawingService = this._docDrawingService;
1889
+ drawingManagerService.setDrawingOrder(unitId, unitId, drawingsOrder), docDrawingService.setDrawingOrder(unitId, unitId, drawingsOrder);
1890
+ const objects = {
1891
+ unitId,
1892
+ subUnitId: unitId,
1893
+ drawingIds: drawingsOrder
1874
1894
  };
1875
- n.orderNotification(o), r.orderNotification(o);
1876
- }
1877
- };
1878
- tt = rr([
1879
- at(st.Steady, tt),
1880
- Ge(0, te),
1881
- Ge(1, $),
1882
- Ge(2, he),
1883
- Ge(3, Re),
1884
- Ge(4, se)
1885
- ], tt);
1886
- var sr = Object.defineProperty, cr = Object.getOwnPropertyDescriptor, lr = (i, e, t, n) => {
1887
- for (var r = n > 1 ? void 0 : n ? cr(e, t) : e, o = i.length - 1, a; o >= 0; o--)
1888
- (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
1889
- return n && r && sr(e, t, r), r;
1890
- }, Ve = (i, e) => (t, n) => e(t, n, i);
1891
- const dr = "__InlineDrawingAnchor__";
1892
- let nt = class extends qe {
1893
- constructor(e, t, n, r, o) {
1895
+ drawingManagerService.orderNotification(objects), docDrawingService.orderNotification(objects);
1896
+ }
1897
+ }, __name(_a5, "DocDrawingAddRemoveController"), _a5);
1898
+ DocDrawingAddRemoveController = __decorateClass$2([
1899
+ OnLifecycle(LifecycleStages.Ready, DocDrawingAddRemoveController),
1900
+ __decorateParam$2(0, IUniverInstanceService),
1901
+ __decorateParam$2(1, ICommandService),
1902
+ __decorateParam$2(2, IDrawingManagerService),
1903
+ __decorateParam$2(3, IDocDrawingService),
1904
+ __decorateParam$2(4, IRenderManagerService)
1905
+ ], DocDrawingAddRemoveController);
1906
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1907
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1908
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1909
+ return kind && result && __defProp$1(target, key, result), result;
1910
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
1911
+ const INLINE_DRAWING_ANCHOR_KEY_PREFIX = "__InlineDrawingAnchor__";
1912
+ var _a6;
1913
+ let DocDrawingTransformerController = (_a6 = class extends Disposable {
1914
+ constructor(_commandService, _univerInstanceService, _drawingManagerService, _renderManagerService, _textSelectionRenderManager) {
1894
1915
  super();
1895
- _e(this, "_liquid", new Ht());
1896
- _e(this, "_listenerOnImageMap", /* @__PURE__ */ new Set());
1916
+ __publicField(this, "_liquid", new Liquid());
1917
+ __publicField(this, "_listenerOnImageMap", /* @__PURE__ */ new Set());
1897
1918
  // Use to cache the drawings is under transforming or scaling.
1898
- _e(this, "_transformerCache", /* @__PURE__ */ new Map());
1899
- _e(this, "_anchorShape");
1900
- this._commandService = e, this._univerInstanceService = t, this._drawingManagerService = n, this._renderManagerService = r, this._textSelectionRenderManager = o, this._init();
1919
+ __publicField(this, "_transformerCache", /* @__PURE__ */ new Map());
1920
+ __publicField(this, "_anchorShape");
1921
+ this._commandService = _commandService, this._univerInstanceService = _univerInstanceService, this._drawingManagerService = _drawingManagerService, this._renderManagerService = _renderManagerService, this._textSelectionRenderManager = _textSelectionRenderManager, this._init();
1901
1922
  }
1902
1923
  _init() {
1903
1924
  this._listenDrawingFocus();
1904
1925
  }
1905
1926
  _listenDrawingFocus() {
1906
1927
  this.disposeWithMe(
1907
- this._drawingManagerService.add$.subscribe((e) => {
1908
- if (e.length !== 0)
1909
- for (const t of e) {
1910
- const { unitId: n } = t;
1911
- this._listenerOnImageMap.has(n) || (this._listenTransformerChange(n), this._listenerOnImageMap.add(n));
1928
+ this._drawingManagerService.add$.subscribe((drawingParams) => {
1929
+ if (drawingParams.length !== 0)
1930
+ for (const drawingParam of drawingParams) {
1931
+ const { unitId } = drawingParam;
1932
+ this._listenerOnImageMap.has(unitId) || (this._listenTransformerChange(unitId), this._listenerOnImageMap.add(unitId));
1912
1933
  }
1913
1934
  })
1914
1935
  );
1915
1936
  }
1916
1937
  // Only handle one drawing transformer change.
1917
1938
  // eslint-disable-next-line max-lines-per-function
1918
- _listenTransformerChange(e) {
1919
- var r;
1920
- const t = (r = this._getSceneAndTransformerByDrawingSearch(e)) == null ? void 0 : r.transformer;
1921
- if (t == null)
1939
+ _listenTransformerChange(unitId) {
1940
+ var _a8;
1941
+ const transformer = (_a8 = this._getSceneAndTransformerByDrawingSearch(unitId)) == null ? void 0 : _a8.transformer;
1942
+ if (transformer == null)
1922
1943
  return;
1923
1944
  this.disposeWithMe(
1924
- ye(
1925
- t.changeStart$.subscribe((o) => {
1926
- var s;
1945
+ toDisposable(
1946
+ transformer.changeStart$.subscribe((state) => {
1947
+ var _a9;
1927
1948
  this._transformerCache.clear();
1928
- const { objects: a } = o;
1929
- for (const l of a.values()) {
1930
- const { oKey: c, width: m, height: u, left: f, top: h, angle: p } = l, w = this._drawingManagerService.getDrawingOKey(c);
1931
- if (w == null)
1949
+ const { objects } = state;
1950
+ for (const object of objects.values()) {
1951
+ const { oKey, width, height, left, top, angle } = object, drawing = this._drawingManagerService.getDrawingOKey(oKey);
1952
+ if (drawing == null)
1932
1953
  continue;
1933
- const v = this._univerInstanceService.getUniverDocInstance(w.unitId), I = (s = v == null ? void 0 : v.getSnapshot().drawings) == null ? void 0 : s[w.drawingId];
1934
- (I == null ? void 0 : I.layoutType) === k.INLINE && l.setOpacity(0.2), I != null && this._transformerCache.set(w.drawingId, {
1935
- drawing: I,
1936
- top: h,
1937
- left: f,
1938
- width: m,
1939
- height: u,
1940
- angle: p
1954
+ const documentDataModel = this._univerInstanceService.getUniverDocInstance(drawing.unitId), drawingData = (_a9 = documentDataModel == null ? void 0 : documentDataModel.getSnapshot().drawings) == null ? void 0 : _a9[drawing.drawingId];
1955
+ (drawingData == null ? void 0 : drawingData.layoutType) === PositionedObjectLayoutType.INLINE && object.setOpacity(0.2), drawingData != null && this._transformerCache.set(drawing.drawingId, {
1956
+ drawing: drawingData,
1957
+ top,
1958
+ left,
1959
+ width,
1960
+ height,
1961
+ angle
1941
1962
  });
1942
1963
  }
1943
1964
  })
1944
1965
  )
1945
1966
  );
1946
- const n = Ct(this._updateMultipleDrawingDocTransform.bind(this), 50);
1947
- Ct(this._nonInlineDrawingTransform.bind(this), 50), this.disposeWithMe(
1948
- ye(
1949
- t.changing$.subscribe((o) => {
1950
- const { objects: a, offsetX: s, offsetY: l } = o;
1951
- if (a.size > 1)
1952
- n(a);
1953
- else if (a.size === 1) {
1954
- const c = this._transformerCache.values().next().value, m = a.values().next().value, { width: u, height: f, top: h, left: p, angle: w } = m;
1955
- if (u === c.width && f === c.height && h === c.top && p === c.left && w === c.angle)
1967
+ const throttleMultipleDrawingUpdate = throttle(this._updateMultipleDrawingDocTransform.bind(this), 50);
1968
+ throttle(this._nonInlineDrawingTransform.bind(this), 50), this.disposeWithMe(
1969
+ toDisposable(
1970
+ transformer.changing$.subscribe((state) => {
1971
+ const { objects, offsetX, offsetY } = state;
1972
+ if (objects.size > 1)
1973
+ throttleMultipleDrawingUpdate(objects);
1974
+ else if (objects.size === 1) {
1975
+ const drawingCache = this._transformerCache.values().next().value, object = objects.values().next().value, { width, height, top, left, angle } = object;
1976
+ if (width === drawingCache.width && height === drawingCache.height && top === drawingCache.top && left === drawingCache.left && angle === drawingCache.angle)
1956
1977
  return;
1957
- c && (c.drawing.layoutType, k.INLINE), c && c.drawing.layoutType === k.INLINE && s != null && l != null && this._updateInlineDrawingAnchor(c.drawing, s, l);
1978
+ drawingCache && (drawingCache.drawing.layoutType, PositionedObjectLayoutType.INLINE), drawingCache && drawingCache.drawing.layoutType === PositionedObjectLayoutType.INLINE && offsetX != null && offsetY != null && this._updateInlineDrawingAnchor(drawingCache.drawing, offsetX, offsetY);
1958
1979
  }
1959
1980
  })
1960
1981
  )
1961
1982
  ), this.disposeWithMe(
1962
- ye(
1963
- t.changeEnd$.subscribe((o) => {
1964
- const { objects: a, offsetX: s, offsetY: l } = o;
1965
- for (const c of a.values()) {
1966
- const m = this._drawingManagerService.getDrawingOKey(c.oKey);
1967
- if (m == null)
1983
+ toDisposable(
1984
+ transformer.changeEnd$.subscribe((state) => {
1985
+ const { objects, offsetX, offsetY } = state;
1986
+ for (const object of objects.values()) {
1987
+ const drawing = this._drawingManagerService.getDrawingOKey(object.oKey);
1988
+ if (drawing == null)
1968
1989
  continue;
1969
- const u = this._transformerCache.get(m == null ? void 0 : m.drawingId);
1970
- (u == null ? void 0 : u.drawing.layoutType) === k.INLINE && c.setOpacity(1);
1990
+ const drawingCache = this._transformerCache.get(drawing == null ? void 0 : drawing.drawingId);
1991
+ (drawingCache == null ? void 0 : drawingCache.drawing.layoutType) === PositionedObjectLayoutType.INLINE && object.setOpacity(1);
1971
1992
  }
1972
- if (this._anchorShape && this._anchorShape.hide(), a.size > 1)
1973
- this._updateMultipleDrawingDocTransform(a);
1974
- else if (a.size === 1) {
1975
- const c = this._transformerCache.values().next().value, m = a.values().next().value, { width: u, height: f, top: h, left: p, angle: w } = m;
1976
- if (u === c.width && f === c.height && h === c.top && p === c.left && w === c.angle)
1993
+ if (this._anchorShape && this._anchorShape.hide(), objects.size > 1)
1994
+ this._updateMultipleDrawingDocTransform(objects);
1995
+ else if (objects.size === 1) {
1996
+ const drawingCache = this._transformerCache.values().next().value, object = objects.values().next().value, { width, height, top, left, angle } = object;
1997
+ if (width === drawingCache.width && height === drawingCache.height && top === drawingCache.top && left === drawingCache.left && angle === drawingCache.angle)
1977
1998
  return;
1978
- c && c.drawing.layoutType === k.INLINE ? u !== c.width || f !== c.height || w !== c.angle ? this._updateDrawingSize(c, m) : s != null && l != null && this._moveInlineDrawing(c.drawing, s, l) : c && this._nonInlineDrawingTransform(c.drawing, m);
1999
+ drawingCache && drawingCache.drawing.layoutType === PositionedObjectLayoutType.INLINE ? width !== drawingCache.width || height !== drawingCache.height || angle !== drawingCache.angle ? this._updateDrawingSize(drawingCache, object) : offsetX != null && offsetY != null && this._moveInlineDrawing(drawingCache.drawing, offsetX, offsetY) : drawingCache && this._nonInlineDrawingTransform(drawingCache.drawing, object);
1979
2000
  }
1980
2001
  this._transformerCache.clear();
1981
2002
  })
@@ -1983,171 +2004,171 @@ let nt = class extends qe {
1983
2004
  );
1984
2005
  }
1985
2006
  // eslint-disable-next-line max-lines-per-function
1986
- _updateMultipleDrawingDocTransform(e) {
1987
- if (e.size < 1)
2007
+ _updateMultipleDrawingDocTransform(objects) {
2008
+ if (objects.size < 1)
1988
2009
  return;
1989
- const t = [];
1990
- let n, r;
1991
- for (const o of e.values()) {
1992
- const { oKey: a, left: s, top: l, angle: c } = o;
1993
- let { width: m, height: u } = o;
1994
- const f = this._drawingManagerService.getDrawingOKey(a);
1995
- if (f == null)
2010
+ const drawings = [];
2011
+ let unitId, subUnitId;
2012
+ for (const object of objects.values()) {
2013
+ const { oKey, left, top, angle } = object;
2014
+ let { width, height } = object;
2015
+ const drawing = this._drawingManagerService.getDrawingOKey(oKey);
2016
+ if (drawing == null)
1996
2017
  continue;
1997
- n == null && (n = f.unitId), r == null && (r = f.subUnitId);
1998
- const h = this._transformerCache.get(f.drawingId);
1999
- if (h == null)
2018
+ unitId == null && (unitId = drawing.unitId), subUnitId == null && (subUnitId = drawing.subUnitId);
2019
+ const drawingCache = this._transformerCache.get(drawing.drawingId);
2020
+ if (drawingCache == null)
2000
2021
  continue;
2001
- const { drawing: p, top: w, left: v, width: I, height: D, angle: _ } = h, { width: C, height: O } = this._getPageContentSize(p);
2002
- if (m = Math.min(m, C), u = Math.min(u, O), (I !== m || D !== u) && t.push({
2003
- drawingId: f.drawingId,
2022
+ const { drawing: drawingData, top: oldTop, left: oldLeft, width: oldWidth, height: oldHeight, angle: oldAngle } = drawingCache, { width: maxWidth, height: maxHeight } = this._getPageContentSize(drawingData);
2023
+ if (width = Math.min(width, maxWidth), height = Math.min(height, maxHeight), (oldWidth !== width || oldHeight !== height) && drawings.push({
2024
+ drawingId: drawing.drawingId,
2004
2025
  key: "size",
2005
2026
  value: {
2006
- width: m,
2007
- height: u
2027
+ width,
2028
+ height
2008
2029
  }
2009
- }), _ !== c && t.push({
2010
- drawingId: f.drawingId,
2030
+ }), oldAngle !== angle && drawings.push({
2031
+ drawingId: drawing.drawingId,
2011
2032
  key: "angle",
2012
- value: c
2013
- }), w !== l || v !== s) {
2014
- const y = l - w, T = s - v;
2015
- y !== 0 && t.push({
2016
- drawingId: f.drawingId,
2033
+ value: angle
2034
+ }), oldTop !== top || oldLeft !== left) {
2035
+ const verticalDelta = top - oldTop, horizontalDelta = left - oldLeft;
2036
+ verticalDelta !== 0 && drawings.push({
2037
+ drawingId: drawing.drawingId,
2017
2038
  key: "positionV",
2018
2039
  value: {
2019
- relativeFrom: p.docTransform.positionV.relativeFrom,
2020
- posOffset: p.docTransform.positionV.posOffset + y
2040
+ relativeFrom: drawingData.docTransform.positionV.relativeFrom,
2041
+ posOffset: drawingData.docTransform.positionV.posOffset + verticalDelta
2021
2042
  }
2022
- }), T !== 0 && t.push({
2023
- drawingId: f.drawingId,
2043
+ }), horizontalDelta !== 0 && drawings.push({
2044
+ drawingId: drawing.drawingId,
2024
2045
  key: "positionH",
2025
2046
  value: {
2026
- relativeFrom: p.docTransform.positionH.relativeFrom,
2027
- posOffset: p.docTransform.positionH.posOffset + T
2047
+ relativeFrom: drawingData.docTransform.positionH.relativeFrom,
2048
+ posOffset: drawingData.docTransform.positionH.posOffset + horizontalDelta
2028
2049
  }
2029
2050
  });
2030
2051
  }
2031
2052
  }
2032
- t.length > 0 && n && r && this._commandService.executeCommand(ze.id, {
2033
- unitId: n,
2034
- subUnitId: r,
2035
- drawings: t
2053
+ drawings.length > 0 && unitId && subUnitId && this._commandService.executeCommand(UpdateDrawingDocTransformCommand.id, {
2054
+ unitId,
2055
+ subUnitId,
2056
+ drawings
2036
2057
  });
2037
2058
  }
2038
2059
  // TODO: @JOCS, Use to draw and update the drawing anchor.
2039
- _updateDrawingAnchor(e) {
2060
+ _updateDrawingAnchor(objects) {
2040
2061
  if (this._transformerCache.size !== 1)
2041
2062
  return;
2042
- const t = this._transformerCache.values().next().value, n = e.values().next().value;
2043
- this._getDrawingAnchor(t.drawing, n);
2063
+ const drawingCache = this._transformerCache.values().next().value, object = objects.values().next().value;
2064
+ this._getDrawingAnchor(drawingCache.drawing, object);
2044
2065
  }
2045
- _updateInlineDrawingAnchor(e, t, n) {
2046
- var o;
2066
+ _updateInlineDrawingAnchor(drawing, offsetX, offsetY) {
2067
+ var _a8;
2047
2068
  if (this._transformerCache.size !== 1)
2048
2069
  return;
2049
- const { contentBoxPointGroup: r } = (o = this._getInlineDrawingAnchor(e, t, n)) != null ? o : {};
2050
- r != null && this._createOrUpdateInlineAnchor(e.unitId, r);
2070
+ const { contentBoxPointGroup } = (_a8 = this._getInlineDrawingAnchor(drawing, offsetX, offsetY)) != null ? _a8 : {};
2071
+ contentBoxPointGroup != null && this._createOrUpdateInlineAnchor(drawing.unitId, contentBoxPointGroup);
2051
2072
  }
2052
- _getInlineDrawingAnchor(e, t, n) {
2053
- var z;
2054
- const r = this._renderManagerService.getRenderById(e.unitId), o = r == null ? void 0 : r.with(ae).getSkeleton();
2055
- if (r == null)
2073
+ _getInlineDrawingAnchor(drawing, offsetX, offsetY) {
2074
+ var _a8;
2075
+ const currentRender = this._renderManagerService.getRenderById(drawing.unitId), skeleton = currentRender == null ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton();
2076
+ if (currentRender == null)
2056
2077
  return;
2057
- const { mainComponent: a, scene: s } = r, l = a, c = s.getViewports()[0], {
2058
- pageLayoutType: m = Pt.VERTICAL,
2059
- pageMarginLeft: u,
2060
- pageMarginTop: f
2061
- } = l.getOffsetConfig();
2062
- let h = null, p = !1, w = -1, v = "";
2063
- const I = 0.5, D = this._getTransformCoordForDocumentOffset(l, c, t, n);
2064
- if (D == null)
2078
+ const { mainComponent, scene } = currentRender, documentComponent = mainComponent, activeViewport = scene.getViewports()[0], {
2079
+ pageLayoutType = PageLayoutType.VERTICAL,
2080
+ pageMarginLeft,
2081
+ pageMarginTop
2082
+ } = documentComponent.getOffsetConfig();
2083
+ let glyphAnchor = null, isBack = !1, segmentPageIndex = -1, segmentId = "";
2084
+ const HALF = 0.5, coord = this._getTransformCoordForDocumentOffset(documentComponent, activeViewport, offsetX, offsetY);
2085
+ if (coord == null)
2065
2086
  return;
2066
- const _ = o == null ? void 0 : o.findNodeByCoord(
2067
- D,
2068
- m,
2069
- u,
2070
- f,
2087
+ const nodeInfo = skeleton == null ? void 0 : skeleton.findNodeByCoord(
2088
+ coord,
2089
+ pageLayoutType,
2090
+ pageMarginLeft,
2091
+ pageMarginTop,
2071
2092
  {
2072
2093
  strict: !1,
2073
2094
  segmentId: this._textSelectionRenderManager.getSegment(),
2074
2095
  segmentPage: this._textSelectionRenderManager.getSegmentPage()
2075
2096
  }
2076
2097
  );
2077
- if (_) {
2078
- const { node: U, ratioX: B, segmentPage: b, segmentId: S } = _;
2079
- p = B < I, h = U, w = b, v = S;
2098
+ if (nodeInfo) {
2099
+ const { node, ratioX, segmentPage, segmentId: nodeSegmentId } = nodeInfo;
2100
+ isBack = ratioX < HALF, glyphAnchor = node, segmentPageIndex = segmentPage, segmentId = nodeSegmentId;
2080
2101
  }
2081
- if (h == null)
2102
+ if (glyphAnchor == null)
2082
2103
  return;
2083
- const C = o == null ? void 0 : o.findPositionByGlyph(h, w), O = this._getDocObject();
2084
- if (C == null || o == null || O == null)
2104
+ const nodePosition = skeleton == null ? void 0 : skeleton.findPositionByGlyph(glyphAnchor, segmentPageIndex), docObject = this._getDocObject();
2105
+ if (nodePosition == null || skeleton == null || docObject == null)
2085
2106
  return;
2086
- const y = {
2087
- ...C,
2088
- isBack: p
2089
- }, T = O.document.getOffsetConfig(), N = new Ot(T, o), { cursorList: R, contentBoxPointGroup: E } = N.getRangePointData(y, y), { startOffset: H } = (z = Tt(R)) != null ? z : {};
2090
- if (H != null)
2091
- return { offset: H, contentBoxPointGroup: E, segmentId: v, segmentPage: w };
2107
+ const positionWithIsBack = {
2108
+ ...nodePosition,
2109
+ isBack
2110
+ }, documentOffsetConfig = docObject.document.getOffsetConfig(), convertor = new NodePositionConvertToCursor(documentOffsetConfig, skeleton), { cursorList, contentBoxPointGroup } = convertor.getRangePointData(positionWithIsBack, positionWithIsBack), { startOffset } = (_a8 = getOneTextSelectionRange(cursorList)) != null ? _a8 : {};
2111
+ if (startOffset != null)
2112
+ return { offset: startOffset, contentBoxPointGroup, segmentId, segmentPage: segmentPageIndex };
2092
2113
  }
2093
2114
  // eslint-disable-next-line max-lines-per-function, complexity
2094
- _getDrawingAnchor(e, t) {
2095
- var we, ve, ne, Ne, Ie, Se, Te, Me, De, J;
2096
- const n = this._renderManagerService.getRenderById(e.unitId), r = n == null ? void 0 : n.with(ae).getSkeleton(), o = r == null ? void 0 : r.getSkeletonData();
2097
- if (o == null || n == null)
2115
+ _getDrawingAnchor(drawing, object) {
2116
+ var _a8, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2117
+ const currentRender = this._renderManagerService.getRenderById(drawing.unitId), skeleton = currentRender == null ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton(), skeletonData = skeleton == null ? void 0 : skeleton.getSkeletonData();
2118
+ if (skeletonData == null || currentRender == null)
2098
2119
  return;
2099
- const { pages: a, skeHeaders: s, skeFooters: l } = o, { mainComponent: c, scene: m } = n, u = c, f = m.getViewports()[0], { pageLayoutType: h = Pt.VERTICAL, pageMarginLeft: p, pageMarginTop: w, docsLeft: v, docsTop: I } = u.getOffsetConfig(), { left: D, top: _, angle: C } = t;
2100
- let { width: O, height: y } = t;
2101
- const { positionV: T, positionH: N } = e.docTransform, { width: R, height: E } = this._getPageContentSize(e);
2102
- O = Math.min(O, R), y = Math.min(y, E);
2103
- let H = null, z = "", U = -1;
2104
- const B = !1, b = {
2105
- ...e.docTransform,
2120
+ const { pages, skeHeaders, skeFooters } = skeletonData, { mainComponent, scene } = currentRender, documentComponent = mainComponent, activeViewport = scene.getViewports()[0], { pageLayoutType = PageLayoutType.VERTICAL, pageMarginLeft, pageMarginTop, docsLeft, docsTop } = documentComponent.getOffsetConfig(), { left, top, angle } = object;
2121
+ let { width, height } = object;
2122
+ const { positionV, positionH } = drawing.docTransform, { width: maxWidth, height: maxHeight } = this._getPageContentSize(drawing);
2123
+ width = Math.min(width, maxWidth), height = Math.min(height, maxHeight);
2124
+ let glyphAnchor = null, segmentId = "", segmentPage = -1;
2125
+ const isBack = !1, docTransform = {
2126
+ ...drawing.docTransform,
2106
2127
  size: {
2107
- width: O,
2108
- height: y
2128
+ width,
2129
+ height
2109
2130
  },
2110
- angle: C
2111
- }, { x: S, y: A } = m.getViewportScrollXY(f), P = this._getTransformCoordForDocumentOffset(u, f, D - S, _ - A);
2112
- if (P == null)
2131
+ angle
2132
+ }, { x, y } = scene.getViewportScrollXY(activeViewport), coord = this._getTransformCoordForDocumentOffset(documentComponent, activeViewport, left - x, top - y);
2133
+ if (coord == null)
2113
2134
  return;
2114
- const L = r == null ? void 0 : r.findNodeByCoord(P, h, p, w, {
2135
+ const nodeInfo = skeleton == null ? void 0 : skeleton.findNodeByCoord(coord, pageLayoutType, pageMarginLeft, pageMarginTop, {
2115
2136
  strict: !1,
2116
2137
  segmentId: this._textSelectionRenderManager.getSegment(),
2117
2138
  segmentPage: this._textSelectionRenderManager.getSegmentPage()
2118
2139
  });
2119
- if (L) {
2120
- const { node: q, segmentPage: lt, segmentId: dt } = L;
2121
- H = q, U = lt, z = dt;
2140
+ if (nodeInfo) {
2141
+ const { node, segmentPage: segmentPageIndex, segmentId: nodeSegmentId } = nodeInfo;
2142
+ glyphAnchor = node, segmentPage = segmentPageIndex, segmentId = nodeSegmentId;
2122
2143
  }
2123
- if (H == null)
2144
+ if (glyphAnchor == null)
2124
2145
  return;
2125
- const x = (we = H.parent) == null ? void 0 : we.parent, M = x == null ? void 0 : x.parent, W = (ve = M == null ? void 0 : M.lines.find((q) => q.paragraphIndex === (x == null ? void 0 : x.paragraphIndex) && q.paragraphStart)) != null ? ve : M == null ? void 0 : M.lines[0], G = (ne = M == null ? void 0 : M.parent) == null ? void 0 : ne.parent;
2126
- if (x == null || M == null || W == null || G == null)
2146
+ const line = (_a8 = glyphAnchor.parent) == null ? void 0 : _a8.parent, column = line == null ? void 0 : line.parent, paragraphStartLine = (_b = column == null ? void 0 : column.lines.find((l) => l.paragraphIndex === (line == null ? void 0 : line.paragraphIndex) && l.paragraphStart)) != null ? _b : column == null ? void 0 : column.lines[0], page = (_c = column == null ? void 0 : column.parent) == null ? void 0 : _c.parent;
2147
+ if (line == null || column == null || paragraphStartLine == null || page == null)
2127
2148
  return;
2128
2149
  this._liquid.reset();
2129
- const F = G.type;
2130
- for (const q of a) {
2131
- const { headerId: lt, footerId: dt, pageHeight: pn, pageWidth: It, marginLeft: _t, marginBottom: hn } = q, wn = a.indexOf(q);
2132
- if (U > -1 && wn === U) {
2133
- switch (F) {
2134
- case Mt.HEADER: {
2135
- const Fe = (Ne = s.get(lt)) == null ? void 0 : Ne.get(It);
2136
- if (Fe)
2150
+ const pageType = page.type;
2151
+ for (const p of pages) {
2152
+ const { headerId, footerId, pageHeight, pageWidth, marginLeft, marginBottom } = p, pIndex = pages.indexOf(p);
2153
+ if (segmentPage > -1 && pIndex === segmentPage) {
2154
+ switch (pageType) {
2155
+ case DocumentSkeletonPageType.HEADER: {
2156
+ const headerSke = (_d = skeHeaders.get(headerId)) == null ? void 0 : _d.get(pageWidth);
2157
+ if (headerSke)
2137
2158
  this._liquid.translatePagePadding({
2138
- marginTop: Fe.marginTop,
2139
- marginLeft: _t
2159
+ marginTop: headerSke.marginTop,
2160
+ marginLeft
2140
2161
  });
2141
2162
  else
2142
2163
  throw new Error("header skeleton not found");
2143
2164
  break;
2144
2165
  }
2145
- case Mt.FOOTER: {
2146
- const Fe = (Ie = l.get(dt)) == null ? void 0 : Ie.get(It);
2147
- if (Fe)
2166
+ case DocumentSkeletonPageType.FOOTER: {
2167
+ const footerSke = (_e = skeFooters.get(footerId)) == null ? void 0 : _e.get(pageWidth);
2168
+ if (footerSke)
2148
2169
  this._liquid.translatePagePadding({
2149
- marginTop: pn - hn + Fe.marginTop,
2150
- marginLeft: _t
2170
+ marginTop: pageHeight - marginBottom + footerSke.marginTop,
2171
+ marginLeft
2151
2172
  });
2152
2173
  else
2153
2174
  throw new Error("footer skeleton not found");
@@ -2156,260 +2177,261 @@ let nt = class extends qe {
2156
2177
  }
2157
2178
  break;
2158
2179
  }
2159
- if (this._liquid.translatePagePadding(q), q === G)
2180
+ if (this._liquid.translatePagePadding(p), p === page)
2160
2181
  break;
2161
- this._liquid.restorePagePadding(q), this._liquid.translatePage(q, h, p, w);
2182
+ this._liquid.restorePagePadding(p), this._liquid.translatePage(p, pageLayoutType, pageMarginLeft, pageMarginTop);
2162
2183
  }
2163
- switch (T.relativeFrom === V.LINE ? H = x.divides[0].glyphGroup[0] : H = (De = (Me = (Te = (Se = W.divides) == null ? void 0 : Se[0]) == null ? void 0 : Te.glyphGroup) == null ? void 0 : Me[0]) != null ? De : H, b.positionH = {
2164
- relativeFrom: N.relativeFrom,
2165
- posOffset: D - this._liquid.x - v
2166
- }, N.relativeFrom) {
2167
- case ee.MARGIN: {
2168
- b.positionH.posOffset = D - this._liquid.x - v - G.marginLeft;
2184
+ switch (positionV.relativeFrom === ObjectRelativeFromV.LINE ? glyphAnchor = line.divides[0].glyphGroup[0] : glyphAnchor = (_i = (_h = (_g = (_f = paragraphStartLine.divides) == null ? void 0 : _f[0]) == null ? void 0 : _g.glyphGroup) == null ? void 0 : _h[0]) != null ? _i : glyphAnchor, docTransform.positionH = {
2185
+ relativeFrom: positionH.relativeFrom,
2186
+ posOffset: left - this._liquid.x - docsLeft
2187
+ }, positionH.relativeFrom) {
2188
+ case ObjectRelativeFromH.MARGIN: {
2189
+ docTransform.positionH.posOffset = left - this._liquid.x - docsLeft - page.marginLeft;
2169
2190
  break;
2170
2191
  }
2171
- case ee.COLUMN: {
2172
- b.positionH.posOffset = D - this._liquid.x - v - M.left;
2192
+ case ObjectRelativeFromH.COLUMN: {
2193
+ docTransform.positionH.posOffset = left - this._liquid.x - docsLeft - column.left;
2173
2194
  break;
2174
2195
  }
2175
2196
  }
2176
- switch (b.positionV = {
2177
- relativeFrom: T.relativeFrom,
2178
- posOffset: _ - this._liquid.y - I
2179
- }, T.relativeFrom) {
2180
- case V.PAGE: {
2181
- b.positionV.posOffset = _ - this._liquid.y - I - G.marginTop;
2197
+ switch (docTransform.positionV = {
2198
+ relativeFrom: positionV.relativeFrom,
2199
+ posOffset: top - this._liquid.y - docsTop
2200
+ }, positionV.relativeFrom) {
2201
+ case ObjectRelativeFromV.PAGE: {
2202
+ docTransform.positionV.posOffset = top - this._liquid.y - docsTop - page.marginTop;
2182
2203
  break;
2183
2204
  }
2184
- case V.LINE: {
2185
- b.positionV.posOffset = _ - this._liquid.y - I - x.top;
2205
+ case ObjectRelativeFromV.LINE: {
2206
+ docTransform.positionV.posOffset = top - this._liquid.y - docsTop - line.top;
2186
2207
  break;
2187
2208
  }
2188
- case V.PARAGRAPH: {
2189
- b.positionV.posOffset = _ - this._liquid.y - I - W.top;
2209
+ case ObjectRelativeFromV.PARAGRAPH: {
2210
+ docTransform.positionV.posOffset = top - this._liquid.y - docsTop - paragraphStartLine.top;
2190
2211
  break;
2191
2212
  }
2192
2213
  }
2193
- if (H == null)
2214
+ if (glyphAnchor == null)
2194
2215
  return;
2195
- const ce = r == null ? void 0 : r.findPositionByGlyph(H, U), fe = this._getDocObject();
2196
- if (ce == null || r == null || fe == null)
2216
+ const nodePosition = skeleton == null ? void 0 : skeleton.findPositionByGlyph(glyphAnchor, segmentPage), docObject = this._getDocObject();
2217
+ if (nodePosition == null || skeleton == null || docObject == null)
2197
2218
  return;
2198
- const Oe = {
2199
- ...ce,
2200
- isBack: B
2201
- }, Be = fe.document.getOffsetConfig(), Ce = new Ot(Be, r), { cursorList: K } = Ce.getRangePointData(Oe, Oe), { startOffset: le } = (J = Tt(K)) != null ? J : {};
2202
- if (le != null)
2203
- return { offset: le, docTransform: b, segmentId: z, segmentPage: U };
2219
+ const positionWithIsBack = {
2220
+ ...nodePosition,
2221
+ isBack
2222
+ }, documentOffsetConfig = docObject.document.getOffsetConfig(), convertor = new NodePositionConvertToCursor(documentOffsetConfig, skeleton), { cursorList } = convertor.getRangePointData(positionWithIsBack, positionWithIsBack), { startOffset } = (_j = getOneTextSelectionRange(cursorList)) != null ? _j : {};
2223
+ if (startOffset != null)
2224
+ return { offset: startOffset, docTransform, segmentId, segmentPage };
2204
2225
  }
2205
2226
  // Update drawing when use transformer to resize it.
2206
- _updateDrawingSize(e, t) {
2207
- const n = [], { drawing: r, width: o, height: a, angle: s } = e, { unitId: l, subUnitId: c } = r;
2208
- let { width: m, height: u, angle: f } = t;
2209
- const { width: h, height: p } = this._getPageContentSize(r);
2210
- m = Math.min(h, m), u = Math.min(p, u), (m !== o || u !== a) && n.push({
2211
- drawingId: r.drawingId,
2227
+ _updateDrawingSize(drawingCache, object) {
2228
+ const drawings = [], { drawing, width: oldWidth, height: oldHeight, angle: oldAngle } = drawingCache, { unitId, subUnitId } = drawing;
2229
+ let { width, height, angle } = object;
2230
+ const { width: maxWidth, height: maxHeight } = this._getPageContentSize(drawing);
2231
+ width = Math.min(maxWidth, width), height = Math.min(maxHeight, height), (width !== oldWidth || height !== oldHeight) && drawings.push({
2232
+ drawingId: drawing.drawingId,
2212
2233
  key: "size",
2213
2234
  value: {
2214
- width: m,
2215
- height: u
2235
+ width,
2236
+ height
2216
2237
  }
2217
- }), f !== s && n.push({
2218
- drawingId: r.drawingId,
2238
+ }), angle !== oldAngle && drawings.push({
2239
+ drawingId: drawing.drawingId,
2219
2240
  key: "angle",
2220
- value: f
2221
- }), n.length > 0 && l && c && this._commandService.executeCommand(ze.id, {
2222
- unitId: l,
2223
- subUnitId: c,
2224
- drawings: n
2241
+ value: angle
2242
+ }), drawings.length > 0 && unitId && subUnitId && this._commandService.executeCommand(UpdateDrawingDocTransformCommand.id, {
2243
+ unitId,
2244
+ subUnitId,
2245
+ drawings
2225
2246
  });
2226
2247
  }
2227
2248
  // Update inline drawing when use transformer to move it.
2228
- _moveInlineDrawing(e, t, n) {
2229
- const r = this._getInlineDrawingAnchor(e, t, n), { offset: o, segmentId: a, segmentPage: s } = r != null ? r : {};
2230
- if (o != null)
2231
- return this._commandService.executeCommand(an.id, {
2232
- unitId: e.unitId,
2233
- subUnitId: e.unitId,
2234
- drawing: e,
2235
- offset: o,
2236
- segmentId: a,
2237
- segmentPage: s
2249
+ _moveInlineDrawing(drawing, offsetX, offsetY) {
2250
+ const anchor = this._getInlineDrawingAnchor(drawing, offsetX, offsetY), { offset, segmentId, segmentPage } = anchor != null ? anchor : {};
2251
+ if (offset != null)
2252
+ return this._commandService.executeCommand(IMoveInlineDrawingCommand.id, {
2253
+ unitId: drawing.unitId,
2254
+ subUnitId: drawing.unitId,
2255
+ drawing,
2256
+ offset,
2257
+ segmentId,
2258
+ segmentPage
2238
2259
  });
2239
2260
  }
2240
2261
  // Limit the drawing to the page area, mainly in the vertical direction,
2241
2262
  // and the upper and lower limits cannot exceed the page margin area.
2242
- _limitDrawingInPage(e, t) {
2243
- const n = this._renderManagerService.getRenderById(e.unitId), { left: r, top: o, width: a, height: s, angle: l } = t, c = n == null ? void 0 : n.with(ae).getSkeleton(), m = c == null ? void 0 : c.getSkeletonData(), { pages: u } = m != null ? m : {};
2244
- if (m == null || n == null || u == null)
2263
+ _limitDrawingInPage(drawing, object) {
2264
+ const currentRender = this._renderManagerService.getRenderById(drawing.unitId), { left, top, width, height, angle } = object, skeleton = currentRender == null ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton(), skeletonData = skeleton == null ? void 0 : skeleton.getSkeletonData(), { pages } = skeletonData != null ? skeletonData : {};
2265
+ if (skeletonData == null || currentRender == null || pages == null)
2245
2266
  return {
2246
- left: r,
2247
- top: o,
2248
- width: a,
2249
- height: s,
2250
- angle: l
2267
+ left,
2268
+ top,
2269
+ width,
2270
+ height,
2271
+ angle
2251
2272
  };
2252
- const { mainComponent: f } = n, h = f, { top: p, pageLayoutType: w, pageMarginLeft: v, pageMarginTop: I } = h;
2253
- let D = o;
2273
+ const { mainComponent } = currentRender, documentComponent = mainComponent, { top: docsTop, pageLayoutType, pageMarginLeft, pageMarginTop } = documentComponent;
2274
+ let newTop = top;
2254
2275
  this._liquid.reset();
2255
- for (const _ of u) {
2256
- const { marginBottom: C, pageHeight: O } = _, y = u.indexOf(_), T = u[y + 1];
2257
- if (T == null)
2276
+ for (const page of pages) {
2277
+ const { marginBottom, pageHeight } = page, index = pages.indexOf(page), nextPage = pages[index + 1];
2278
+ if (nextPage == null)
2258
2279
  continue;
2259
- if (Pe.hasIntersectionBetweenTwoRanges(
2260
- o,
2261
- o + s,
2262
- this._liquid.y + p + O - C,
2263
- this._liquid.y + p + O + I + T.marginTop
2280
+ if (Tools.hasIntersectionBetweenTwoRanges(
2281
+ top,
2282
+ top + height,
2283
+ this._liquid.y + docsTop + pageHeight - marginBottom,
2284
+ this._liquid.y + docsTop + pageHeight + pageMarginTop + nextPage.marginTop
2264
2285
  )) {
2265
- const R = o + s / 2, E = this._liquid.y + p + O + I / 2;
2266
- R < E ? D = Math.min(o, this._liquid.y + p + O - C - s) : D = Math.max(o, this._liquid.y + p + O + I + T.marginTop);
2286
+ const drawingVMiddle = top + height / 2, pagesMiddle = this._liquid.y + docsTop + pageHeight + pageMarginTop / 2;
2287
+ drawingVMiddle < pagesMiddle ? newTop = Math.min(top, this._liquid.y + docsTop + pageHeight - marginBottom - height) : newTop = Math.max(top, this._liquid.y + docsTop + pageHeight + pageMarginTop + nextPage.marginTop);
2267
2288
  }
2268
- this._liquid.translatePage(_, w, v, I);
2289
+ this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
2269
2290
  }
2270
2291
  return {
2271
- left: r,
2272
- top: D,
2273
- width: a,
2274
- height: s,
2275
- angle: l
2292
+ left,
2293
+ top: newTop,
2294
+ width,
2295
+ height,
2296
+ angle
2276
2297
  };
2277
2298
  }
2278
- _nonInlineDrawingTransform(e, t, n = !1) {
2279
- const r = e.isMultiTransform === oe.TRUE ? t : this._limitDrawingInPage(e, t);
2280
- if (n && r.top !== t.top)
2299
+ _nonInlineDrawingTransform(drawing, object, isMoving = !1) {
2300
+ const objectPosition = drawing.isMultiTransform === BooleanNumber.TRUE ? object : this._limitDrawingInPage(drawing, object);
2301
+ if (isMoving && objectPosition.top !== object.top)
2281
2302
  return;
2282
- const o = this._getDrawingAnchor(e, r), { offset: a, docTransform: s, segmentId: l, segmentPage: c } = o != null ? o : {};
2283
- return a == null || s == null ? this._updateMultipleDrawingDocTransform(/* @__PURE__ */ new Map([[e.drawingId, t]])) : this._commandService.executeCommand(sn.id, {
2284
- unitId: e.unitId,
2285
- subUnitId: e.unitId,
2286
- drawing: e,
2287
- offset: a,
2288
- docTransform: s,
2289
- segmentId: l,
2290
- segmentPage: c
2303
+ const anchor = this._getDrawingAnchor(drawing, objectPosition), { offset, docTransform, segmentId, segmentPage } = anchor != null ? anchor : {};
2304
+ return offset == null || docTransform == null ? this._updateMultipleDrawingDocTransform(/* @__PURE__ */ new Map([[drawing.drawingId, object]])) : this._commandService.executeCommand(ITransformNonInlineDrawingCommand.id, {
2305
+ unitId: drawing.unitId,
2306
+ subUnitId: drawing.unitId,
2307
+ drawing,
2308
+ offset,
2309
+ docTransform,
2310
+ segmentId,
2311
+ segmentPage
2291
2312
  });
2292
2313
  }
2293
- _getSceneAndTransformerByDrawingSearch(e) {
2294
- if (e == null)
2314
+ _getSceneAndTransformerByDrawingSearch(unitId) {
2315
+ if (unitId == null)
2295
2316
  return;
2296
- const t = this._renderManagerService.getRenderById(e), n = t == null ? void 0 : t.scene;
2297
- if (n == null)
2317
+ const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
2318
+ if (scene == null)
2298
2319
  return;
2299
- const r = n.getTransformerByCreate();
2300
- return { scene: n, transformer: r };
2320
+ const transformer = scene.getTransformerByCreate();
2321
+ return { scene, transformer };
2301
2322
  }
2302
- _getTransformCoordForDocumentOffset(e, t, n, r) {
2303
- const { documentTransform: o } = e.getOffsetConfig(), a = t.transformVector2SceneCoord(Gn.FromArray([n, r]));
2304
- if (a)
2305
- return o.clone().invert().applyPoint(a);
2323
+ _getTransformCoordForDocumentOffset(document, viewport, evtOffsetX, evtOffsetY) {
2324
+ const { documentTransform } = document.getOffsetConfig(), originCoord = viewport.transformVector2SceneCoord(Vector2.FromArray([evtOffsetX, evtOffsetY]));
2325
+ if (originCoord)
2326
+ return documentTransform.clone().invert().applyPoint(originCoord);
2306
2327
  }
2307
- _createOrUpdateInlineAnchor(e, t) {
2308
- const n = this._renderManagerService.getRenderById(e);
2309
- if (n == null)
2328
+ _createOrUpdateInlineAnchor(unitId, pointsGroup) {
2329
+ const currentRender = this._renderManagerService.getRenderById(unitId);
2330
+ if (currentRender == null)
2310
2331
  return;
2311
- const { mainComponent: r, scene: o } = n, a = r, {
2312
- docsLeft: s,
2313
- docsTop: l
2314
- } = a.getOffsetConfig(), c = Vn(t), { left: m, top: u, height: f } = c, h = m + s, p = u + l;
2332
+ const { mainComponent, scene } = currentRender, documentComponent = mainComponent, {
2333
+ docsLeft,
2334
+ docsTop
2335
+ } = documentComponent.getOffsetConfig(), bounding = getAnchorBounding(pointsGroup), { left: boundingLeft, top: boundingTop, height } = bounding, left = boundingLeft + docsLeft, top = boundingTop + docsTop;
2315
2336
  if (this._anchorShape) {
2316
- this._anchorShape.transformByState({ left: h, top: p, height: f }), this._anchorShape.show();
2337
+ this._anchorShape.transformByState({ left, top, height }), this._anchorShape.show();
2317
2338
  return;
2318
2339
  }
2319
- const w = 6, v = new jn(dr + Pe.generateRandomId(w), {
2320
- left: h,
2321
- top: p,
2322
- height: f,
2340
+ const ID_LENGTH = 6, anchor = new Rect(INLINE_DRAWING_ANCHOR_KEY_PREFIX + Tools.generateRandomId(ID_LENGTH), {
2341
+ left,
2342
+ top,
2343
+ height,
2323
2344
  strokeWidth: 2,
2324
- stroke: $n(Pn.darkGray, 1),
2345
+ stroke: getColor(COLORS.darkGray, 1),
2325
2346
  evented: !1
2326
2347
  });
2327
- this._anchorShape = v, o.addObject(v, zn);
2348
+ this._anchorShape = anchor, scene.addObject(anchor, TEXT_RANGE_LAYER_INDEX);
2328
2349
  }
2329
2350
  _getDocObject() {
2330
- return Qn(this._univerInstanceService, this._renderManagerService);
2351
+ return getDocObject(this._univerInstanceService, this._renderManagerService);
2331
2352
  }
2332
- _getPageContentSize(e) {
2333
- const t = this._renderManagerService.getRenderById(e.unitId), n = t == null ? void 0 : t.with(ae).getSkeleton(), r = 500, o = 500, a = n == null ? void 0 : n.getSkeletonData();
2334
- if (a == null || t == null)
2353
+ _getPageContentSize(drawing) {
2354
+ const currentRender = this._renderManagerService.getRenderById(drawing.unitId), skeleton = currentRender == null ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton(), MAX_WIDTH = 500, MAX_HEIGHT = 500, skeletonData = skeleton == null ? void 0 : skeleton.getSkeletonData();
2355
+ if (skeletonData == null || currentRender == null)
2335
2356
  return {
2336
- width: r,
2337
- height: o
2357
+ width: MAX_WIDTH,
2358
+ height: MAX_HEIGHT
2338
2359
  };
2339
- const { pages: s } = a;
2340
- let l = null;
2341
- for (const c of s) {
2342
- const { skeDrawings: m } = c;
2343
- if (m.has(e.drawingId)) {
2344
- l = c;
2360
+ const { pages } = skeletonData;
2361
+ let page = null;
2362
+ for (const p of pages) {
2363
+ const { skeDrawings } = p;
2364
+ if (skeDrawings.has(drawing.drawingId)) {
2365
+ page = p;
2345
2366
  break;
2346
2367
  }
2347
2368
  }
2348
- if (l) {
2349
- const { pageWidth: c, pageHeight: m, marginLeft: u, marginBottom: f, marginRight: h, marginTop: p } = l;
2369
+ if (page) {
2370
+ const { pageWidth, pageHeight, marginLeft, marginBottom, marginRight, marginTop } = page;
2350
2371
  return {
2351
- width: Math.max(r, c - u - h),
2352
- height: Math.max(o, m - p - f)
2372
+ width: Math.max(MAX_WIDTH, pageWidth - marginLeft - marginRight),
2373
+ height: Math.max(MAX_HEIGHT, pageHeight - marginTop - marginBottom)
2353
2374
  };
2354
2375
  } else
2355
2376
  return {
2356
- width: r,
2357
- height: o
2377
+ width: MAX_WIDTH,
2378
+ height: MAX_HEIGHT
2358
2379
  };
2359
2380
  }
2360
- };
2361
- nt = lr([
2362
- at(st.Rendered, nt),
2363
- Ve(0, $),
2364
- Ve(1, te),
2365
- Ve(2, he),
2366
- Ve(3, se),
2367
- Ve(4, Ue)
2368
- ], nt);
2369
- var un = Object.defineProperty, mr = Object.getOwnPropertyDescriptor, gr = (i, e, t) => e in i ? un(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, ur = (i, e, t, n) => {
2370
- for (var r = n > 1 ? void 0 : n ? mr(e, t) : e, o = i.length - 1, a; o >= 0; o--)
2371
- (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
2372
- return n && r && un(e, t, r), r;
2373
- }, Ut = (i, e) => (t, n) => e(t, n, i), fn = (i, e, t) => gr(i, typeof e != "symbol" ? e + "" : e, t);
2374
- const fr = "DOCS_DRAWING_UI_PLUGIN";
2375
- let rt = class extends On {
2376
- constructor(i, e, t) {
2377
- super(), this._injector = e, this._renderManagerSrv = t;
2378
- }
2379
- onStarting(i) {
2381
+ }, __name(_a6, "DocDrawingTransformerController"), _a6);
2382
+ DocDrawingTransformerController = __decorateClass$1([
2383
+ OnLifecycle(LifecycleStages.Rendered, DocDrawingTransformerController),
2384
+ __decorateParam$1(0, ICommandService),
2385
+ __decorateParam$1(1, IUniverInstanceService),
2386
+ __decorateParam$1(2, IDrawingManagerService),
2387
+ __decorateParam$1(3, IRenderManagerService),
2388
+ __decorateParam$1(4, ITextSelectionRenderManager)
2389
+ ], DocDrawingTransformerController);
2390
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2391
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2392
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2393
+ return kind && result && __defProp2(target, key, result), result;
2394
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField");
2395
+ const PLUGIN_NAME = "DOCS_DRAWING_UI_PLUGIN";
2396
+ var _a7;
2397
+ let UniverDocsDrawingUIPlugin = (_a7 = class extends Plugin {
2398
+ constructor(_config, _injector, _renderManagerSrv) {
2399
+ super(), this._injector = _injector, this._renderManagerSrv = _renderManagerSrv;
2400
+ }
2401
+ onStarting() {
2380
2402
  [
2381
- [et],
2382
- [Je],
2383
- [nt],
2384
- [tt],
2385
- [ct]
2386
- ].forEach((t) => i.add(t));
2403
+ [DocDrawingUIController],
2404
+ [DocDrawingPopupMenuController],
2405
+ [DocDrawingTransformerController],
2406
+ [DocDrawingAddRemoveController],
2407
+ [DocRefreshDrawingsService]
2408
+ ].forEach((dependency) => this._injector.add(dependency));
2387
2409
  }
2388
2410
  onReady() {
2389
2411
  [
2390
- [ut],
2391
- [ft]
2392
- ].forEach((i) => this._renderManagerSrv.registerRenderModule(be.UNIVER_DOC, i));
2393
- }
2394
- };
2395
- fn(rt, "type", be.UNIVER_DOC);
2396
- fn(rt, "pluginName", fr);
2397
- rt = ur([
2398
- Tn(An, Hn, Wn),
2399
- Ut(1, pe(kt)),
2400
- Ut(2, se)
2401
- ], rt);
2412
+ [DocDrawingUpdateRenderController],
2413
+ [DocDrawingTransformUpdateController]
2414
+ ].forEach((m) => this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, m));
2415
+ }
2416
+ }, __name(_a7, "UniverDocsDrawingUIPlugin"), _a7);
2417
+ __publicField2(UniverDocsDrawingUIPlugin, "type", UniverInstanceType.UNIVER_DOC);
2418
+ __publicField2(UniverDocsDrawingUIPlugin, "pluginName", PLUGIN_NAME);
2419
+ UniverDocsDrawingUIPlugin = __decorateClass([
2420
+ DependentOn(UniverDrawingUIPlugin, UniverDrawingPlugin, UniverDocsDrawingPlugin),
2421
+ __decorateParam(1, Inject(Injector)),
2422
+ __decorateParam(2, IRenderManagerService)
2423
+ ], UniverDocsDrawingUIPlugin);
2402
2424
  export {
2403
- Wi as ClearDocDrawingTransformerOperation,
2404
- cn as DeleteDocDrawingsCommand,
2405
- Xt as EditDocDrawingOperation,
2406
- mn as GroupDocDrawingCommand,
2407
- gn as InsertDocDrawingCommand,
2408
- vt as InsertDocImageOperation,
2409
- Xe as MoveDocDrawingsCommand,
2410
- wt as RemoveDocDrawingCommand,
2411
- ln as SetDocDrawingArrangeCommand,
2412
- qt as SidebarDocDrawingOperation,
2413
- dn as UngroupDocDrawingCommand,
2414
- rt as UniverDocsDrawingUIPlugin
2425
+ ClearDocDrawingTransformerOperation,
2426
+ DeleteDocDrawingsCommand,
2427
+ EditDocDrawingOperation,
2428
+ GroupDocDrawingCommand,
2429
+ InsertDocDrawingCommand,
2430
+ InsertDocImageOperation,
2431
+ MoveDocDrawingsCommand,
2432
+ RemoveDocDrawingCommand,
2433
+ SetDocDrawingArrangeCommand,
2434
+ SidebarDocDrawingOperation,
2435
+ UngroupDocDrawingCommand,
2436
+ UniverDocsDrawingUIPlugin
2415
2437
  };