@univerjs/docs-drawing-ui 0.5.0 → 0.5.1-nightly.202411301606

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