@univerjs/docs-drawing-ui 0.5.5-nightly.202501220324 → 0.5.5

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