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