@univerjs/docs-drawing-ui 0.5.5-nightly.202501241606 → 0.6.0-alpha.0

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