@univerjs/docs-drawing-ui 0.16.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1408 -1416
- package/lib/index.js +1408 -1416
- package/lib/types/index.d.ts +2 -2
- package/lib/types/plugin.d.ts +3 -1
- package/lib/umd/index.js +1 -1
- package/package.json +12 -12
- /package/lib/types/{controllers/config.schema.d.ts → config/config.d.ts} +0 -0
- /package/lib/types/{controllers → menu}/drawing-popup-menu.controller.d.ts +0 -0
- /package/lib/types/{views/menu → menu}/image.menu.d.ts +0 -0
- /package/lib/types/{controllers/menu.schema.d.ts → menu/schema.d.ts} +0 -0
package/lib/index.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
var Pn = Object.defineProperty;
|
|
2
2
|
var xn = (r, e, t) => e in r ? Pn(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var me = (r, e, t) => xn(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { CommandType as q, ICommandService as
|
|
5
|
-
import { IDocDrawingService as
|
|
6
|
-
import { RichTextEditingMutation as ee, DocSelectionManagerService as
|
|
7
|
-
import { DocSelectionRenderService as
|
|
8
|
-
import { IRenderManagerService as Q, DocumentEditArea as
|
|
9
|
-
import { MessageType as
|
|
10
|
-
import { IImageIoService as ui, IDrawingManagerService as fe, DRAWING_IMAGE_ALLOW_IMAGE_LIST as hi, DRAWING_IMAGE_COUNT_LIMIT as
|
|
11
|
-
import { IMessageService as
|
|
12
|
-
import { BehaviorSubject as
|
|
13
|
-
import { DrawingRenderService as gn, DrawingCommonPanel as Ai, ImageCropperObject as Pi, COMPONENT_IMAGE_POPUP_MENU as xi, OpenImageCropOperation as Ni, ImageResetSizeOperation as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
4
|
+
import { CommandType as q, ICommandService as j, IUniverInstanceService as z, TextX as St, JSONX as $, MemoryCursor as Nn, TextXActionType as Y, BuildTextUtils as Ln, ArrangeTypeEnum as Qe, Tools as Ae, Inject as Z, IContextService as Yt, LocaleService as lt, Disposable as xe, WrapTextType as ze, PositionedObjectLayoutType as k, BooleanNumber as se, DrawingTypeEnum as Pe, ObjectRelativeFromV as W, ObjectRelativeFromH as J, FOCUSING_COMMON_DRAWINGS as it, UniverInstanceType as we, Direction as he, DisposableCollection as Un, toDisposable as Xe, fromEventSubject as Zt, generateRandomId as Qt, DOCS_ZEN_EDITOR_UNIT_ID_KEY as Dt, UndoCommand as Bn, RedoCommand as Fn, Injector as Jt, DOC_DRAWING_PRINTING_COMPONENT_KEY as kn, throttle as Rt, COLORS as Wn, DocumentFlavor as mt, FOCUSING_DOC as Hn, FOCUSING_UNIVER_EDITOR as Gn, LifecycleService as Vn, LifecycleStages as At, RxDisposable as jn, isInternalEditorID as $n, DependentOn as zn, IConfigService as Xn, Plugin as qn, merge as Kn } from "@univerjs/core";
|
|
5
|
+
import { IDocDrawingService as We, UniverDocsDrawingPlugin as Yn } from "@univerjs/docs-drawing";
|
|
6
|
+
import { RichTextEditingMutation as ee, DocSelectionManagerService as Ot, DocSkeletonManagerService as te } from "@univerjs/docs";
|
|
7
|
+
import { DocSelectionRenderService as ye, getRichTextEditPath as qe, getCustomBlockIdsInSelections as Zn, docDrawingPositionToTransform as en, VIEWPORT_KEY as tn, SetDocZoomRatioOperation as nn, DocPrintInterceptorService as Qn, NodePositionConvertToCursor as Pt, getOneTextSelectionRange as xt, getAnchorBounding as Jn, TEXT_RANGE_LAYER_INDEX as ei, getDocObject as ti, IEditorService as ni, DocCanvasPopManagerService as ii } from "@univerjs/docs-ui";
|
|
8
|
+
import { IRenderManagerService as Q, DocumentEditArea as Be, getCurrentTypeOfRenderer as ri, CURSOR_TYPE as Nt, Liquid as rn, PageLayoutType as Lt, DocumentSkeletonPageType as Ut, Vector2 as si, Rect as oi, getColor as ai, TRANSFORM_CHANGE_OBSERVABLE_TYPE as ci } from "@univerjs/engine-render";
|
|
9
|
+
import { MessageType as Bt, render as di, unmount as gi, clsx as sn, InputNumber as Ue, Select as Ft, Checkbox as li, RadioGroup as kt, Radio as Te } from "@univerjs/design";
|
|
10
|
+
import { IImageIoService as ui, IDrawingManagerService as fe, DRAWING_IMAGE_ALLOW_IMAGE_LIST as hi, DRAWING_IMAGE_COUNT_LIMIT as Wt, ImageUploadStatusType as vt, DRAWING_IMAGE_ALLOW_SIZE as fi, getImageSize as pi, getDrawingShapeKeyByDrawingSearch as mi, DRAWING_IMAGE_WIDTH_LIMIT as Ht, DRAWING_IMAGE_HEIGHT_LIMIT as Gt, UniverDrawingPlugin as vi } from "@univerjs/drawing";
|
|
11
|
+
import { IMessageService as wi, ILocalFileService as Ii, ISidebarService as _i, CanvasFloatDomService as Si, getMenuHiddenObservable as on, MenuItemType as an, PrintFloatDomSingle as Di, ComponentManager as cn, connectInjector as Oi, RibbonInsertGroup as Ti, useDependency as ve, KeyCode as Fe, IMenuManagerService as yi, IShortcutService as Mi, UniverUIPlugin as bi } from "@univerjs/ui";
|
|
12
|
+
import { BehaviorSubject as Tt, debounceTime as dn, map as Vt, switchMap as Ci, of as Ei, Observable as Ri, filter as jt, takeUntil as $t } from "rxjs";
|
|
13
|
+
import { DrawingRenderService as gn, DrawingCommonPanel as Ai, ImageCropperObject as Pi, COMPONENT_IMAGE_POPUP_MENU as xi, OpenImageCropOperation as Ni, ImageResetSizeOperation as Li, UniverDrawingUIPlugin as Ui } from "@univerjs/drawing-ui";
|
|
14
|
+
import { jsx as y, jsxs as X } from "react/jsx-runtime";
|
|
15
|
+
import { useMemo as Bi, useState as re, useEffect as yt } from "react";
|
|
16
16
|
const Mt = {
|
|
17
17
|
id: "doc.command.remove-doc-image",
|
|
18
18
|
type: q.COMMAND,
|
|
19
19
|
// eslint-disable-next-line max-lines-per-function
|
|
20
20
|
handler: (r, e) => {
|
|
21
|
-
var C,
|
|
22
|
-
const t = r.get(
|
|
21
|
+
var C, M, A, U;
|
|
22
|
+
const t = r.get(j), n = r.get(z), i = r.get(Q), s = n.getCurrentUniverDocInstance();
|
|
23
23
|
if (e == null || s == null)
|
|
24
24
|
return !1;
|
|
25
|
-
const o = i.getRenderById(e.unitId).with(
|
|
25
|
+
const o = i.getRenderById(e.unitId).with(ye), { drawings: c } = e, d = (C = o.getSegment()) != null ? C : "", a = new St(), g = $.getInstance(), u = (A = (M = s.getSelfOrHeaderFooterModel(d).getBody()) == null ? void 0 : M.customBlocks) != null ? A : [], l = c.map((R) => u.find((w) => w.blockId === R.drawingId)).filter((R) => !!R).sort((R, w) => R.startIndex > w.startIndex ? 1 : -1), f = c[0].unitId, h = new Nn();
|
|
26
26
|
h.reset();
|
|
27
27
|
const m = l[0].startIndex, p = [
|
|
28
28
|
{
|
|
29
29
|
startOffset: m,
|
|
30
30
|
endOffset: m
|
|
31
31
|
}
|
|
32
|
-
],
|
|
32
|
+
], v = {
|
|
33
33
|
id: ee.id,
|
|
34
34
|
params: {
|
|
35
35
|
unitId: f,
|
|
@@ -38,28 +38,28 @@ const Mt = {
|
|
|
38
38
|
}
|
|
39
39
|
}, D = [];
|
|
40
40
|
for (const R of l) {
|
|
41
|
-
const { startIndex:
|
|
42
|
-
|
|
41
|
+
const { startIndex: w } = R;
|
|
42
|
+
w > h.cursor && a.push({
|
|
43
43
|
t: Y.RETAIN,
|
|
44
|
-
len:
|
|
44
|
+
len: w - h.cursor
|
|
45
45
|
}), a.push({
|
|
46
46
|
t: Y.DELETE,
|
|
47
47
|
len: 1
|
|
48
|
-
}), h.moveCursorTo(
|
|
48
|
+
}), h.moveCursorTo(w + 1);
|
|
49
49
|
}
|
|
50
|
-
const S =
|
|
50
|
+
const S = qe(s, d);
|
|
51
51
|
D.push(g.editOp(a.serialize(), S));
|
|
52
52
|
for (const R of l) {
|
|
53
|
-
const { blockId:
|
|
54
|
-
D.push(
|
|
53
|
+
const { blockId: w } = R, N = ((U = s.getDrawings()) != null ? U : {})[w], x = s.getDrawingsOrder().indexOf(w), G = g.removeOp(["drawings", w], N), I = g.removeOp(["drawingsOrder", x], w);
|
|
54
|
+
D.push(G), D.push(I);
|
|
55
55
|
}
|
|
56
|
-
return
|
|
56
|
+
return v.params.actions = D.reduce((R, w) => $.compose(R, w), null), !!t.syncExecuteCommand(v.id, v.params);
|
|
57
57
|
}
|
|
58
58
|
}, ln = {
|
|
59
59
|
id: "doc.command.delete-drawing",
|
|
60
60
|
type: q.COMMAND,
|
|
61
61
|
handler: (r) => {
|
|
62
|
-
const e = r.get(
|
|
62
|
+
const e = r.get(j), n = r.get(We).getFocusDrawings();
|
|
63
63
|
if (n.length === 0)
|
|
64
64
|
return !1;
|
|
65
65
|
const { unitId: i } = n[0], s = n.map((o) => {
|
|
@@ -79,69 +79,57 @@ const Mt = {
|
|
|
79
79
|
}, un = {
|
|
80
80
|
id: "doc.command.group-doc-image",
|
|
81
81
|
type: q.COMMAND,
|
|
82
|
-
handler: (r, e) =>
|
|
83
|
-
|
|
84
|
-
const t = r.get(Ne);
|
|
85
|
-
if (!e) return !1;
|
|
86
|
-
const n = [];
|
|
87
|
-
e.forEach(({ parent: g, children: u }) => {
|
|
88
|
-
n.push(g.unitId), u.forEach((l) => {
|
|
89
|
-
n.push(l.unitId);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
const i = t.getGroupDrawingOp(e), { unitId: s, subUnitId: o, undo: c, redo: d, objects: a } = i;
|
|
93
|
-
return !1;
|
|
94
|
-
}
|
|
95
|
-
}, yt = {
|
|
82
|
+
handler: (r, e) => !1
|
|
83
|
+
}, bt = {
|
|
96
84
|
id: "doc.command.insert-doc-image",
|
|
97
85
|
type: q.COMMAND,
|
|
98
86
|
// eslint-disable-next-line max-lines-per-function
|
|
99
87
|
handler: (r, e) => {
|
|
100
|
-
var
|
|
88
|
+
var M, A, U, R;
|
|
101
89
|
if (e == null)
|
|
102
90
|
return !1;
|
|
103
|
-
const t = r.get(
|
|
91
|
+
const t = r.get(j), n = r.get(Ot), i = r.get(z), s = n.getActiveTextRange(), o = i.getCurrentUniverDocInstance();
|
|
104
92
|
if (s == null || o == null)
|
|
105
93
|
return !1;
|
|
106
94
|
const c = o.getUnitId(), { drawings: d } = e, { collapsed: a, startOffset: g, segmentId: u } = s, l = o.getSelfOrHeaderFooterModel(u).getBody();
|
|
107
95
|
if (l == null)
|
|
108
96
|
return !1;
|
|
109
|
-
const f = new
|
|
110
|
-
let
|
|
97
|
+
const f = new St(), h = $.getInstance(), m = [], p = (A = (M = o.getSnapshot().drawingsOrder) == null ? void 0 : M.length) != null ? A : 0;
|
|
98
|
+
let v = 0;
|
|
111
99
|
if (a)
|
|
112
100
|
g > 0 && f.push({
|
|
113
101
|
t: Y.RETAIN,
|
|
114
102
|
len: g
|
|
115
103
|
});
|
|
116
104
|
else {
|
|
117
|
-
const
|
|
118
|
-
f.push(...
|
|
119
|
-
const N = Zn(l, [s]),
|
|
120
|
-
if (
|
|
121
|
-
for (const I of
|
|
122
|
-
const _ =
|
|
105
|
+
const w = Ln.selection.delete([s], l, 0, null, !1);
|
|
106
|
+
f.push(...w);
|
|
107
|
+
const N = Zn(l, [s]), H = (U = o.getDrawings()) != null ? U : {}, x = (R = o.getDrawingsOrder()) != null ? R : [], G = N.sort((I, _) => x.indexOf(I) > x.indexOf(_) ? -1 : x.indexOf(I) < x.indexOf(_) ? 1 : 0);
|
|
108
|
+
if (G.length > 0)
|
|
109
|
+
for (const I of G) {
|
|
110
|
+
const _ = H[I], E = x.indexOf(I);
|
|
123
111
|
if (_ == null || E < 0)
|
|
124
112
|
continue;
|
|
125
|
-
const T = h.removeOp(["drawings", I], _),
|
|
126
|
-
m.push(T), m.push(
|
|
113
|
+
const T = h.removeOp(["drawings", I], _), L = h.removeOp(["drawingsOrder", E], I);
|
|
114
|
+
m.push(T), m.push(L), v++;
|
|
127
115
|
}
|
|
128
116
|
}
|
|
129
117
|
f.push({
|
|
130
118
|
t: Y.INSERT,
|
|
131
119
|
body: {
|
|
132
120
|
dataStream: "\b".repeat(d.length),
|
|
133
|
-
customBlocks: d.map((
|
|
121
|
+
customBlocks: d.map((w, N) => ({
|
|
134
122
|
startIndex: N,
|
|
135
|
-
blockId:
|
|
123
|
+
blockId: w.drawingId
|
|
136
124
|
}))
|
|
137
125
|
},
|
|
138
126
|
len: d.length
|
|
139
127
|
});
|
|
140
|
-
const D =
|
|
128
|
+
const D = qe(o, u), S = h.editOp(f.serialize(), D);
|
|
141
129
|
m.push(S);
|
|
142
|
-
for (const
|
|
143
|
-
const { drawingId: N } =
|
|
144
|
-
m.push(
|
|
130
|
+
for (const w of d) {
|
|
131
|
+
const { drawingId: N } = w, H = h.insertOp(["drawings", N], w), x = h.insertOp(["drawingsOrder", p - v], N);
|
|
132
|
+
m.push(H), m.push(x);
|
|
145
133
|
}
|
|
146
134
|
const O = {
|
|
147
135
|
id: ee.id,
|
|
@@ -151,18 +139,18 @@ const Mt = {
|
|
|
151
139
|
textRanges: []
|
|
152
140
|
}
|
|
153
141
|
};
|
|
154
|
-
return O.params.actions = m.reduce((
|
|
142
|
+
return O.params.actions = m.reduce((w, N) => $.compose(w, N), null), !!t.syncExecuteCommand(O.id, O.params);
|
|
155
143
|
}
|
|
156
144
|
}, hn = {
|
|
157
145
|
id: "doc.command.set-drawing-arrange",
|
|
158
146
|
type: q.COMMAND,
|
|
159
147
|
handler: (r, e) => {
|
|
160
|
-
const t = r.get(
|
|
148
|
+
const t = r.get(j), n = r.get(We);
|
|
161
149
|
if (e == null)
|
|
162
150
|
return !1;
|
|
163
151
|
const { unitId: i, subUnitId: s, drawingIds: o, arrangeType: c } = e, d = { unitId: i, subUnitId: s, drawingIds: o };
|
|
164
152
|
let a;
|
|
165
|
-
if (c ===
|
|
153
|
+
if (c === Qe.forward ? a = n.getForwardDrawingsOp(d) : c === Qe.backward ? a = n.getBackwardDrawingOp(d) : c === Qe.front ? a = n.getFrontDrawingsOp(d) : c === Qe.back && (a = n.getBackDrawingsOp(d)), a == null)
|
|
166
154
|
return !1;
|
|
167
155
|
const { redo: g } = a;
|
|
168
156
|
if (g == null)
|
|
@@ -184,8 +172,7 @@ const Mt = {
|
|
|
184
172
|
id: "doc.command.ungroup-doc-image",
|
|
185
173
|
type: q.COMMAND,
|
|
186
174
|
handler: (r, e) => {
|
|
187
|
-
|
|
188
|
-
const t = r.get(Ne);
|
|
175
|
+
const t = r.get(We);
|
|
189
176
|
if (!e) return !1;
|
|
190
177
|
const n = [];
|
|
191
178
|
e.forEach(({ parent: g, children: u }) => {
|
|
@@ -199,7 +186,7 @@ const Mt = {
|
|
|
199
186
|
};
|
|
200
187
|
class ut {
|
|
201
188
|
constructor() {
|
|
202
|
-
me(this, "_refreshDrawings$", new
|
|
189
|
+
me(this, "_refreshDrawings$", new Tt(null));
|
|
203
190
|
me(this, "refreshDrawings$", this._refreshDrawings$.asObservable());
|
|
204
191
|
}
|
|
205
192
|
refreshDrawings(e) {
|
|
@@ -211,7 +198,7 @@ var Fi = Object.getOwnPropertyDescriptor, ki = (r, e, t, n) => {
|
|
|
211
198
|
(o = r[s]) && (i = o(i) || i);
|
|
212
199
|
return i;
|
|
213
200
|
}, le = (r, e) => (t, n) => e(t, n, r);
|
|
214
|
-
let
|
|
201
|
+
let rt = class extends xe {
|
|
215
202
|
constructor(r, e, t, n, i, s, o, c, d, a, g, u, l) {
|
|
216
203
|
super(), this._context = r, this._commandService = e, this._docSelectionManagerService = t, this._renderManagerSrv = n, this._imageIoService = i, this._docDrawingService = s, this._drawingManagerService = o, this._contextService = c, this._messageService = d, this._localeService = a, this._docSelectionRenderService = g, this._docRefreshDrawingsService = u, this._fileOpenerService = l, this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener(), this._transformDrawingListener(), this._editAreaChangeListener();
|
|
217
204
|
}
|
|
@@ -223,9 +210,9 @@ let it = class extends xe {
|
|
|
223
210
|
multiple: !0,
|
|
224
211
|
accept: hi.map((t) => `.${t.replace("image/", "")}`).join(",")
|
|
225
212
|
}), e = r.length;
|
|
226
|
-
return e >
|
|
227
|
-
type:
|
|
228
|
-
content: this._localeService.t("update-status.exceedMaxCount", String(
|
|
213
|
+
return e > Wt ? (this._messageService.show({
|
|
214
|
+
type: Bt.Error,
|
|
215
|
+
content: this._localeService.t("update-status.exceedMaxCount", String(Wt))
|
|
229
216
|
}), !1) : e === 0 ? !1 : (await this._insertFloatImages(r), !0);
|
|
230
217
|
}
|
|
231
218
|
// eslint-disable-next-line max-lines-per-function
|
|
@@ -237,18 +224,18 @@ let it = class extends xe {
|
|
|
237
224
|
const s = i.message;
|
|
238
225
|
let o = "";
|
|
239
226
|
switch (s) {
|
|
240
|
-
case
|
|
227
|
+
case vt.ERROR_EXCEED_SIZE:
|
|
241
228
|
o = this._localeService.t("update-status.exceedMaxSize", String(fi / (1024 * 1024)));
|
|
242
229
|
break;
|
|
243
|
-
case
|
|
230
|
+
case vt.ERROR_IMAGE_TYPE:
|
|
244
231
|
o = this._localeService.t("update-status.invalidImageType");
|
|
245
232
|
break;
|
|
246
|
-
case
|
|
233
|
+
case vt.ERROR_IMAGE:
|
|
247
234
|
o = this._localeService.t("update-status.invalidImage");
|
|
248
235
|
break;
|
|
249
236
|
}
|
|
250
237
|
this._messageService.show({
|
|
251
|
-
type:
|
|
238
|
+
type: Bt.Error,
|
|
252
239
|
content: o
|
|
253
240
|
});
|
|
254
241
|
}
|
|
@@ -261,9 +248,9 @@ let it = class extends xe {
|
|
|
261
248
|
const { imageId: s, imageSourceType: o, source: c, base64Cache: d } = i, { width: a, height: g, image: u } = await pi(d || "");
|
|
262
249
|
this._imageIoService.addImageSourceCache(s, o, u);
|
|
263
250
|
let l = 1;
|
|
264
|
-
if (a >
|
|
265
|
-
const p =
|
|
266
|
-
l = Math.min(p,
|
|
251
|
+
if (a > Ht || g > Gt) {
|
|
252
|
+
const p = Ht / a, v = Gt / g;
|
|
253
|
+
l = Math.min(p, v);
|
|
267
254
|
}
|
|
268
255
|
const f = this._getImagePosition(a * l, g * l);
|
|
269
256
|
if (f == null)
|
|
@@ -282,7 +269,7 @@ let it = class extends xe {
|
|
|
282
269
|
description: "",
|
|
283
270
|
layoutType: k.INLINE,
|
|
284
271
|
// Insert inline drawing by default.
|
|
285
|
-
wrapText:
|
|
272
|
+
wrapText: ze.BOTH_SIDES,
|
|
286
273
|
distB: 0,
|
|
287
274
|
distL: 0,
|
|
288
275
|
distR: 0,
|
|
@@ -290,7 +277,7 @@ let it = class extends xe {
|
|
|
290
277
|
};
|
|
291
278
|
this._isInsertInHeaderFooter() && (h.isMultiTransform = se.TRUE, h.transforms = h.transform ? [h.transform] : null), n.push(h);
|
|
292
279
|
}
|
|
293
|
-
this._commandService.executeCommand(
|
|
280
|
+
this._commandService.executeCommand(bt.id, {
|
|
294
281
|
unitId: t,
|
|
295
282
|
drawings: n
|
|
296
283
|
});
|
|
@@ -298,7 +285,7 @@ let it = class extends xe {
|
|
|
298
285
|
_isInsertInHeaderFooter() {
|
|
299
286
|
var n;
|
|
300
287
|
const { unitId: r } = this._context, e = (n = this._renderManagerSrv.getRenderById(r)) == null ? void 0 : n.with(te).getViewModel(), t = e == null ? void 0 : e.getEditArea();
|
|
301
|
-
return t ===
|
|
288
|
+
return t === Be.HEADER || t === Be.FOOTER;
|
|
302
289
|
}
|
|
303
290
|
_getImagePosition(r, e) {
|
|
304
291
|
const t = this._docSelectionRenderService.getActiveTextRange(), n = (t == null ? void 0 : t.getAbsolutePosition()) || {
|
|
@@ -366,12 +353,12 @@ let it = class extends xe {
|
|
|
366
353
|
var i;
|
|
367
354
|
const { transformer: e, docsLeft: t, docsTop: n } = (i = this._getCurrentSceneAndTransformer()) != null ? i : {};
|
|
368
355
|
if (r == null || r.length === 0)
|
|
369
|
-
this._contextService.setContextValue(
|
|
356
|
+
this._contextService.setContextValue(it, !1), this._docDrawingService.focusDrawing([]), e && e.resetProps({
|
|
370
357
|
zeroTop: 0,
|
|
371
358
|
zeroLeft: 0
|
|
372
359
|
});
|
|
373
360
|
else {
|
|
374
|
-
this._contextService.setContextValue(
|
|
361
|
+
this._contextService.setContextValue(it, !0), this._docDrawingService.focusDrawing(r), this._setDrawingSelections(r);
|
|
375
362
|
const s = this._docSelectionRenderService.getSegment(), o = this._findSegmentIdByDrawingId(r[0].drawingId);
|
|
376
363
|
s !== o && this._docSelectionRenderService.setSegment(o), e && e.resetProps({
|
|
377
364
|
zeroTop: n,
|
|
@@ -401,7 +388,7 @@ let it = class extends xe {
|
|
|
401
388
|
const { unit: r, scene: e, unitId: t } = this._context, n = (c = this._renderManagerSrv.getRenderById(t)) == null ? void 0 : c.with(te).getViewModel();
|
|
402
389
|
if (n == null || r == null)
|
|
403
390
|
return;
|
|
404
|
-
const i = r.getSnapshot(), { drawings: s = {} } = i, o = n.getEditArea() ===
|
|
391
|
+
const i = r.getSnapshot(), { drawings: s = {} } = i, o = n.getEditArea() === Be.BODY;
|
|
405
392
|
for (const d of Object.keys(s)) {
|
|
406
393
|
const a = s[d], g = mi({ unitId: t, drawingId: a.drawingId, subUnitId: t }), u = e.fuzzyMathObjects(g, !0);
|
|
407
394
|
if (u.length)
|
|
@@ -451,27 +438,27 @@ let it = class extends xe {
|
|
|
451
438
|
this._docSelectionManagerService.replaceDocRanges(n);
|
|
452
439
|
}
|
|
453
440
|
};
|
|
454
|
-
|
|
455
|
-
le(1,
|
|
456
|
-
le(2, Z(
|
|
441
|
+
rt = ki([
|
|
442
|
+
le(1, j),
|
|
443
|
+
le(2, Z(Ot)),
|
|
457
444
|
le(3, Q),
|
|
458
445
|
le(4, ui),
|
|
459
|
-
le(5,
|
|
446
|
+
le(5, We),
|
|
460
447
|
le(6, fe),
|
|
461
448
|
le(7, Yt),
|
|
462
|
-
le(8,
|
|
449
|
+
le(8, wi),
|
|
463
450
|
le(9, Z(lt)),
|
|
464
|
-
le(10, Z(
|
|
451
|
+
le(10, Z(ye)),
|
|
465
452
|
le(11, Z(ut)),
|
|
466
453
|
le(12, Ii)
|
|
467
|
-
],
|
|
454
|
+
], rt);
|
|
468
455
|
const pn = {
|
|
469
456
|
id: "doc.command.insert-float-image",
|
|
470
457
|
type: q.COMMAND,
|
|
471
458
|
handler: (r) => {
|
|
472
459
|
var n, i;
|
|
473
460
|
const e = r.get(z), t = r.get(Q);
|
|
474
|
-
return (i = (n = ri(
|
|
461
|
+
return (i = (n = ri(we.UNIVER_DOC, e, t)) == null ? void 0 : n.with(rt).insertDocImage()) != null ? i : !1;
|
|
475
462
|
}
|
|
476
463
|
};
|
|
477
464
|
var ue = /* @__PURE__ */ ((r) => (r.INLINE = "inline", r.BEHIND_TEXT = "behindText", r.IN_FRONT_OF_TEXT = "inFrontOfText", r.WRAP_SQUARE = "wrapSquare", r.WRAP_TOP_AND_BOTTOM = "wrapTopAndBottom", r))(ue || {});
|
|
@@ -484,7 +471,7 @@ const Wi = {
|
|
|
484
471
|
};
|
|
485
472
|
function mn(r, e, t, n, i, s, o) {
|
|
486
473
|
var f, h;
|
|
487
|
-
const c = new
|
|
474
|
+
const c = new St(), d = $.getInstance(), a = [], g = s.getSelfOrHeaderFooterModel(e).getBody(), u = s.getSelfOrHeaderFooterModel(r).getBody();
|
|
488
475
|
if (g == null || u == null)
|
|
489
476
|
return;
|
|
490
477
|
const l = (h = (f = g.customBlocks) == null ? void 0 : f.find((m) => m.blockId === i)) == null ? void 0 : h.startIndex;
|
|
@@ -529,7 +516,7 @@ function mn(r, e, t, n, i, s, o) {
|
|
|
529
516
|
},
|
|
530
517
|
len: 1
|
|
531
518
|
})), n !== l) {
|
|
532
|
-
const m =
|
|
519
|
+
const m = qe(s, e), p = d.editOp(c.serialize(), m);
|
|
533
520
|
a.push(p);
|
|
534
521
|
}
|
|
535
522
|
} else {
|
|
@@ -540,7 +527,7 @@ function mn(r, e, t, n, i, s, o) {
|
|
|
540
527
|
t: Y.DELETE,
|
|
541
528
|
len: 1
|
|
542
529
|
});
|
|
543
|
-
let m =
|
|
530
|
+
let m = qe(s, e), p = d.editOp(c.serialize(), m);
|
|
544
531
|
a.push(p), c.empty(), n > 0 && c.push({
|
|
545
532
|
t: Y.RETAIN,
|
|
546
533
|
len: n
|
|
@@ -554,54 +541,54 @@ function mn(r, e, t, n, i, s, o) {
|
|
|
554
541
|
}]
|
|
555
542
|
},
|
|
556
543
|
len: 1
|
|
557
|
-
}), m =
|
|
544
|
+
}), m = qe(s, r), p = d.editOp(c.serialize(), m), a.push(p), o.setSegment(r), o.setSegmentPage(t);
|
|
558
545
|
}
|
|
559
546
|
return a;
|
|
560
547
|
}
|
|
561
548
|
}
|
|
562
|
-
const
|
|
549
|
+
const vn = {
|
|
563
550
|
id: "doc.command.update-doc-drawing-wrapping-style",
|
|
564
551
|
type: q.COMMAND,
|
|
565
552
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
566
553
|
handler: (r, e) => {
|
|
567
|
-
var A,
|
|
554
|
+
var A, U;
|
|
568
555
|
if (e == null)
|
|
569
556
|
return !1;
|
|
570
|
-
const { drawings: t, wrappingStyle: n, unitId: i } = e, s = r.get(
|
|
557
|
+
const { drawings: t, wrappingStyle: n, unitId: i } = e, s = r.get(j), o = r.get(z), d = r.get(Q).getRenderById(i), a = d == null ? void 0 : d.with(te).getSkeleton().getSkeletonData(), g = d == null ? void 0 : d.with(te).getViewModel(), u = d == null ? void 0 : d.scene, l = o.getCurrentUniverDocInstance();
|
|
571
558
|
if (l == null || a == null || u == null || g == null)
|
|
572
559
|
return !1;
|
|
573
|
-
const f = g.getEditArea(), h = u.getTransformerByCreate(), { pages: m, skeHeaders: p, skeFooters:
|
|
560
|
+
const f = g.getEditArea(), h = u.getTransformerByCreate(), { pages: m, skeHeaders: p, skeFooters: v } = a, D = $.getInstance(), S = [], { drawings: O = {} } = l.getSnapshot();
|
|
574
561
|
for (const R of t) {
|
|
575
|
-
const { drawingId:
|
|
576
|
-
if (N !==
|
|
577
|
-
const _ = D.replaceOp(["drawings",
|
|
562
|
+
const { drawingId: w } = R, N = O[w].layoutType, H = Wi[n];
|
|
563
|
+
if (N !== H) {
|
|
564
|
+
const _ = D.replaceOp(["drawings", w, "layoutType"], N, H);
|
|
578
565
|
S.push(_);
|
|
579
566
|
}
|
|
580
567
|
if (n === "behindText" || n === "inFrontOfText") {
|
|
581
|
-
const _ = O[
|
|
568
|
+
const _ = O[w].behindDoc, E = n === "behindText" ? se.TRUE : se.FALSE;
|
|
582
569
|
if (_ !== E) {
|
|
583
|
-
const T = D.replaceOp(["drawings",
|
|
570
|
+
const T = D.replaceOp(["drawings", w, "behindDoc"], _, E);
|
|
584
571
|
S.push(T);
|
|
585
572
|
}
|
|
586
573
|
}
|
|
587
574
|
if (n === "inline")
|
|
588
575
|
continue;
|
|
589
|
-
let x = null,
|
|
576
|
+
let x = null, G = 0, I = 0;
|
|
590
577
|
for (const _ of m) {
|
|
591
|
-
const { headerId: E, footerId: T, marginTop:
|
|
578
|
+
const { headerId: E, footerId: T, marginTop: L, marginLeft: B, marginBottom: b, pageWidth: P, pageHeight: V } = _;
|
|
592
579
|
switch (f) {
|
|
593
|
-
case
|
|
580
|
+
case Be.HEADER: {
|
|
594
581
|
const F = (A = p.get(E)) == null ? void 0 : A.get(P);
|
|
595
|
-
F != null && F.skeDrawings.has(
|
|
582
|
+
F != null && F.skeDrawings.has(w) && (x = F.skeDrawings.get(w), G = F.marginTop, I = B);
|
|
596
583
|
break;
|
|
597
584
|
}
|
|
598
|
-
case
|
|
599
|
-
const F = (
|
|
600
|
-
F != null && F.skeDrawings.has(
|
|
585
|
+
case Be.FOOTER: {
|
|
586
|
+
const F = (U = v.get(T)) == null ? void 0 : U.get(P);
|
|
587
|
+
F != null && F.skeDrawings.has(w) && (x = F.skeDrawings.get(w), G = V - b + F.marginTop, I = B);
|
|
601
588
|
break;
|
|
602
589
|
}
|
|
603
|
-
case
|
|
604
|
-
_.skeDrawings.has(
|
|
590
|
+
case Be.BODY: {
|
|
591
|
+
_.skeDrawings.has(w) && (x = _.skeDrawings.get(w), G = L, I = B);
|
|
605
592
|
break;
|
|
606
593
|
}
|
|
607
594
|
}
|
|
@@ -609,26 +596,26 @@ const wn = {
|
|
|
609
596
|
break;
|
|
610
597
|
}
|
|
611
598
|
if (x != null) {
|
|
612
|
-
const { aTop: _, aLeft: E } = x, T = O[
|
|
613
|
-
let
|
|
614
|
-
T.relativeFrom === J.MARGIN ?
|
|
599
|
+
const { aTop: _, aLeft: E } = x, T = O[w].docTransform.positionH;
|
|
600
|
+
let L = E;
|
|
601
|
+
T.relativeFrom === J.MARGIN ? L -= I : T.relativeFrom === J.COLUMN && (L -= x.columnLeft);
|
|
615
602
|
const B = {
|
|
616
603
|
relativeFrom: T.relativeFrom,
|
|
617
|
-
posOffset:
|
|
604
|
+
posOffset: L
|
|
618
605
|
};
|
|
619
606
|
if (T.posOffset !== B.posOffset) {
|
|
620
|
-
const F = D.replaceOp(["drawings",
|
|
607
|
+
const F = D.replaceOp(["drawings", w, "docTransform", "positionH"], T, B);
|
|
621
608
|
S.push(F);
|
|
622
609
|
}
|
|
623
|
-
const b = O[
|
|
610
|
+
const b = O[w].docTransform.positionV;
|
|
624
611
|
let P = _;
|
|
625
|
-
b.relativeFrom === W.PAGE ? P +=
|
|
626
|
-
const
|
|
612
|
+
b.relativeFrom === W.PAGE ? P += G : b.relativeFrom === W.LINE ? P -= x.lineTop : b.relativeFrom === W.PARAGRAPH && (P -= x.blockAnchorTop);
|
|
613
|
+
const V = {
|
|
627
614
|
relativeFrom: b.relativeFrom,
|
|
628
615
|
posOffset: P
|
|
629
616
|
};
|
|
630
|
-
if (b.posOffset !==
|
|
631
|
-
const F = D.replaceOp(["drawings",
|
|
617
|
+
if (b.posOffset !== V.posOffset) {
|
|
618
|
+
const F = D.replaceOp(["drawings", w, "docTransform", "positionV"], b, V);
|
|
632
619
|
S.push(F);
|
|
633
620
|
}
|
|
634
621
|
}
|
|
@@ -641,26 +628,26 @@ const wn = {
|
|
|
641
628
|
textRanges: null
|
|
642
629
|
}
|
|
643
630
|
};
|
|
644
|
-
C.params.actions = S.reduce((R,
|
|
645
|
-
const
|
|
646
|
-
return h.refreshControls(), !!
|
|
631
|
+
C.params.actions = S.reduce((R, w) => $.compose(R, w), null);
|
|
632
|
+
const M = s.syncExecuteCommand(C.id, C.params);
|
|
633
|
+
return h.refreshControls(), !!M;
|
|
647
634
|
}
|
|
648
|
-
},
|
|
635
|
+
}, wn = {
|
|
649
636
|
id: "doc.command.update-doc-drawing-distance",
|
|
650
637
|
type: q.COMMAND,
|
|
651
638
|
handler: (r, e) => {
|
|
652
639
|
if (e == null)
|
|
653
640
|
return !1;
|
|
654
|
-
const t = r.get(
|
|
641
|
+
const t = r.get(j), i = r.get(z).getCurrentUniverDocInstance();
|
|
655
642
|
if (i == null)
|
|
656
643
|
return !1;
|
|
657
644
|
const { drawings: s, dist: o, unitId: c } = e, d = $.getInstance(), a = [], { drawings: g = {} } = i.getSnapshot();
|
|
658
645
|
for (const f of s) {
|
|
659
646
|
const { drawingId: h } = f;
|
|
660
647
|
for (const [m, p] of Object.entries(o)) {
|
|
661
|
-
const
|
|
662
|
-
if (
|
|
663
|
-
const D = d.replaceOp(["drawings", h, m],
|
|
648
|
+
const v = g[h][m];
|
|
649
|
+
if (v !== p) {
|
|
650
|
+
const D = d.replaceOp(["drawings", h, m], v, p);
|
|
664
651
|
a.push(D);
|
|
665
652
|
}
|
|
666
653
|
}
|
|
@@ -681,7 +668,7 @@ const wn = {
|
|
|
681
668
|
handler: (r, e) => {
|
|
682
669
|
if (e == null)
|
|
683
670
|
return !1;
|
|
684
|
-
const t = r.get(
|
|
671
|
+
const t = r.get(j), i = r.get(z).getCurrentUniverDocInstance();
|
|
685
672
|
if (i == null)
|
|
686
673
|
return !1;
|
|
687
674
|
const { drawings: s, wrapText: o, unitId: c } = e, d = $.getInstance(), a = [], { drawings: g = {} } = i.getSnapshot();
|
|
@@ -702,13 +689,13 @@ const wn = {
|
|
|
702
689
|
};
|
|
703
690
|
return u.params.actions = a.reduce((f, h) => $.compose(f, h), null), !!t.syncExecuteCommand(u.id, u.params);
|
|
704
691
|
}
|
|
705
|
-
},
|
|
692
|
+
}, Ke = {
|
|
706
693
|
id: "doc.command.update-drawing-doc-transform",
|
|
707
694
|
type: q.COMMAND,
|
|
708
695
|
handler: (r, e) => {
|
|
709
696
|
if (e == null)
|
|
710
697
|
return !1;
|
|
711
|
-
const t = r.get(
|
|
698
|
+
const t = r.get(j), n = r.get(z), s = r.get(Q).getRenderById(e.unitId), o = s == null ? void 0 : s.scene;
|
|
712
699
|
if (o == null)
|
|
713
700
|
return !1;
|
|
714
701
|
const c = o.getTransformerByCreate(), d = n.getCurrentUniverDocInstance();
|
|
@@ -716,9 +703,9 @@ const wn = {
|
|
|
716
703
|
return !1;
|
|
717
704
|
const { drawings: a, unitId: g } = e, u = $.getInstance(), l = [], { drawings: f = {} } = d.getSnapshot();
|
|
718
705
|
for (const p of a) {
|
|
719
|
-
const { drawingId:
|
|
706
|
+
const { drawingId: v, key: D, value: S } = p, O = f[v].docTransform[D];
|
|
720
707
|
if (!Ae.diffValue(O, S)) {
|
|
721
|
-
const C = u.replaceOp(["drawings",
|
|
708
|
+
const C = u.replaceOp(["drawings", v, "docTransform", D], O, S);
|
|
722
709
|
l.push(C);
|
|
723
710
|
}
|
|
724
711
|
}
|
|
@@ -731,7 +718,7 @@ const wn = {
|
|
|
731
718
|
debounce: !0
|
|
732
719
|
}
|
|
733
720
|
};
|
|
734
|
-
h.params.actions = l.reduce((p,
|
|
721
|
+
h.params.actions = l.reduce((p, v) => $.compose(p, v), null);
|
|
735
722
|
const m = t.syncExecuteCommand(h.id, h.params);
|
|
736
723
|
return c.refreshControls(), !!m;
|
|
737
724
|
}
|
|
@@ -739,17 +726,17 @@ const wn = {
|
|
|
739
726
|
id: "doc.command.move-inline-drawing",
|
|
740
727
|
type: q.COMMAND,
|
|
741
728
|
handler: (r, e) => {
|
|
742
|
-
var
|
|
729
|
+
var U, R;
|
|
743
730
|
if (e == null)
|
|
744
731
|
return !1;
|
|
745
|
-
const t = r.get(Q), n = (
|
|
732
|
+
const t = r.get(Q), n = (U = t.getRenderById(e.unitId)) == null ? void 0 : U.with(ye), i = r.get(ut), s = t.getRenderById(e.unitId), o = s == null ? void 0 : s.scene, c = s == null ? void 0 : s.with(te).getSkeleton();
|
|
746
733
|
if (o == null || n == null)
|
|
747
734
|
return !1;
|
|
748
|
-
const d = o.getTransformerByCreate(), a = r.get(
|
|
735
|
+
const d = o.getTransformerByCreate(), a = r.get(j), u = r.get(z).getCurrentUniverDocInstance();
|
|
749
736
|
if (u == null)
|
|
750
737
|
return !1;
|
|
751
|
-
const { drawing: l, unitId: f, offset: h, segmentId: m, segmentPage: p, needRefreshDrawings:
|
|
752
|
-
if (
|
|
738
|
+
const { drawing: l, unitId: f, offset: h, segmentId: m, segmentPage: p, needRefreshDrawings: v } = e;
|
|
739
|
+
if (v)
|
|
753
740
|
return i.refreshDrawings(c), d.refreshControls(), !0;
|
|
754
741
|
const D = [], { drawingId: S } = l, O = (R = n.getSegment()) != null ? R : "", C = mn(
|
|
755
742
|
m,
|
|
@@ -763,7 +750,7 @@ const wn = {
|
|
|
763
750
|
if (C == null || C.length === 0)
|
|
764
751
|
return i.refreshDrawings(c), d.refreshControls(), !1;
|
|
765
752
|
D.push(...C);
|
|
766
|
-
const
|
|
753
|
+
const M = {
|
|
767
754
|
id: ee.id,
|
|
768
755
|
params: {
|
|
769
756
|
unitId: f,
|
|
@@ -771,8 +758,8 @@ const wn = {
|
|
|
771
758
|
textRanges: null
|
|
772
759
|
}
|
|
773
760
|
};
|
|
774
|
-
|
|
775
|
-
const A = a.syncExecuteCommand(
|
|
761
|
+
M.params.actions = D.reduce((w, N) => $.compose(w, N), null);
|
|
762
|
+
const A = a.syncExecuteCommand(M.id, M.params);
|
|
776
763
|
return d.refreshControls(), !!A;
|
|
777
764
|
}
|
|
778
765
|
}, Sn = {
|
|
@@ -780,42 +767,42 @@ const wn = {
|
|
|
780
767
|
type: q.COMMAND,
|
|
781
768
|
// eslint-disable-next-line max-lines-per-function
|
|
782
769
|
handler: (r, e) => {
|
|
783
|
-
var x,
|
|
770
|
+
var x, G;
|
|
784
771
|
if (e == null)
|
|
785
772
|
return !1;
|
|
786
|
-
const t = r.get(Q), n = (x = t.getRenderById(e.unitId)) == null ? void 0 : x.with(
|
|
773
|
+
const t = r.get(Q), n = (x = t.getRenderById(e.unitId)) == null ? void 0 : x.with(ye), i = t.getRenderById(e.unitId), s = i == null ? void 0 : i.scene;
|
|
787
774
|
if (s == null || n == null)
|
|
788
775
|
return !1;
|
|
789
|
-
const o = s.getTransformerByCreate(), c = r.get(
|
|
776
|
+
const o = s.getTransformerByCreate(), c = r.get(j), a = r.get(z).getCurrentUniverDocInstance();
|
|
790
777
|
if (a == null)
|
|
791
778
|
return !1;
|
|
792
|
-
const { drawing: g, unitId: u, offset: l, docTransform: f, segmentId: h, segmentPage: m } = e, p = [], { drawingId:
|
|
779
|
+
const { drawing: g, unitId: u, offset: l, docTransform: f, segmentId: h, segmentPage: m } = e, p = [], { drawingId: v } = g, D = (G = n.getSegment()) != null ? G : "", S = mn(
|
|
793
780
|
h,
|
|
794
781
|
D,
|
|
795
782
|
m,
|
|
796
783
|
l,
|
|
797
|
-
|
|
784
|
+
v,
|
|
798
785
|
a,
|
|
799
786
|
n
|
|
800
787
|
);
|
|
801
788
|
if (S == null)
|
|
802
789
|
return !1;
|
|
803
790
|
S.length > 0 && p.push(...S);
|
|
804
|
-
const O = $.getInstance(), { drawings: C = {} } = a.getSnapshot(),
|
|
791
|
+
const O = $.getInstance(), { drawings: C = {} } = a.getSnapshot(), M = C[v].docTransform, { positionH: A, positionV: U, size: R, angle: w } = M;
|
|
805
792
|
if (!Ae.diffValue(A, f.positionH)) {
|
|
806
|
-
const I = O.replaceOp(["drawings",
|
|
793
|
+
const I = O.replaceOp(["drawings", v, "docTransform", "positionH"], A, f.positionH);
|
|
807
794
|
p.push(I);
|
|
808
795
|
}
|
|
809
|
-
if (!Ae.diffValue(
|
|
810
|
-
const I = O.replaceOp(["drawings",
|
|
796
|
+
if (!Ae.diffValue(U, f.positionV)) {
|
|
797
|
+
const I = O.replaceOp(["drawings", v, "docTransform", "positionV"], U, f.positionV);
|
|
811
798
|
p.push(I);
|
|
812
799
|
}
|
|
813
800
|
if (!Ae.diffValue(R, f.size)) {
|
|
814
|
-
const I = O.replaceOp(["drawings",
|
|
801
|
+
const I = O.replaceOp(["drawings", v, "docTransform", "size"], R, f.size);
|
|
815
802
|
p.push(I);
|
|
816
803
|
}
|
|
817
|
-
if (!Ae.diffValue(
|
|
818
|
-
const I = O.replaceOp(["drawings",
|
|
804
|
+
if (!Ae.diffValue(w, f.angle)) {
|
|
805
|
+
const I = O.replaceOp(["drawings", v, "docTransform", "angle"], w, f.angle);
|
|
819
806
|
p.push(I);
|
|
820
807
|
}
|
|
821
808
|
const N = {
|
|
@@ -828,26 +815,26 @@ const wn = {
|
|
|
828
815
|
}
|
|
829
816
|
};
|
|
830
817
|
N.params.actions = p.reduce((I, _) => $.compose(I, _), null);
|
|
831
|
-
const
|
|
832
|
-
return o.refreshControls(), !!
|
|
818
|
+
const H = c.syncExecuteCommand(N.id, N.params);
|
|
819
|
+
return o.refreshControls(), !!H;
|
|
833
820
|
}
|
|
834
|
-
},
|
|
821
|
+
}, Ye = {
|
|
835
822
|
id: "doc.command.move-drawing",
|
|
836
823
|
type: q.COMMAND,
|
|
837
824
|
handler: (r, e) => {
|
|
838
|
-
const t = r.get(
|
|
825
|
+
const t = r.get(j), n = r.get(We), i = r.get(z), s = r.get(Q), { direction: o } = e, c = n.getFocusDrawings();
|
|
839
826
|
if (c.length === 0)
|
|
840
827
|
return !1;
|
|
841
828
|
const d = c[0].unitId, a = s.getRenderById(d), g = a == null ? void 0 : a.scene;
|
|
842
829
|
if (g == null)
|
|
843
830
|
return !1;
|
|
844
831
|
const u = g.getTransformerByCreate(), l = i.getUniverDocInstance(d), f = c.map((m) => {
|
|
845
|
-
var
|
|
846
|
-
const { drawingId: p } = m,
|
|
847
|
-
if (
|
|
832
|
+
var M, A, U, R, w;
|
|
833
|
+
const { drawingId: p } = m, v = (M = l == null ? void 0 : l.getSnapshot().drawings) == null ? void 0 : M[p];
|
|
834
|
+
if (v == null || v.layoutType === k.INLINE)
|
|
848
835
|
return null;
|
|
849
|
-
const { positionH: D, positionV: S } =
|
|
850
|
-
return o === he.UP ? C.posOffset = ((A = C.posOffset) != null ? A : 0) - 2 : o === he.DOWN ? C.posOffset = ((
|
|
836
|
+
const { positionH: D, positionV: S } = v.docTransform, O = { ...D }, C = { ...S };
|
|
837
|
+
return o === he.UP ? C.posOffset = ((A = C.posOffset) != null ? A : 0) - 2 : o === he.DOWN ? C.posOffset = ((U = C.posOffset) != null ? U : 0) + 2 : o === he.LEFT ? O.posOffset = ((R = O.posOffset) != null ? R : 0) - 2 : o === he.RIGHT && (O.posOffset = ((w = O.posOffset) != null ? w : 0) + 2), {
|
|
851
838
|
drawingId: p,
|
|
852
839
|
key: o === he.UP || o === he.DOWN ? "positionV" : "positionH",
|
|
853
840
|
value: o === he.UP || o === he.DOWN ? C : O
|
|
@@ -855,14 +842,14 @@ const wn = {
|
|
|
855
842
|
}).filter((m) => m != null);
|
|
856
843
|
if (f.length === 0)
|
|
857
844
|
return !1;
|
|
858
|
-
const h = t.syncExecuteCommand(
|
|
845
|
+
const h = t.syncExecuteCommand(Ke.id, {
|
|
859
846
|
unitId: d,
|
|
860
847
|
subUnitId: d,
|
|
861
848
|
drawings: f
|
|
862
849
|
});
|
|
863
850
|
return u.refreshControls(), !!h;
|
|
864
851
|
}
|
|
865
|
-
},
|
|
852
|
+
}, Hi = {
|
|
866
853
|
id: "doc.operation.clear-drawing-transformer",
|
|
867
854
|
type: q.MUTATION,
|
|
868
855
|
handler: (r, e) => {
|
|
@@ -890,16 +877,16 @@ const wn = {
|
|
|
890
877
|
id: "doc.operation.edit-doc-image",
|
|
891
878
|
type: q.OPERATION,
|
|
892
879
|
handler: (r, e) => {
|
|
893
|
-
const t = r.get(fe), n = r.get(
|
|
880
|
+
const t = r.get(fe), n = r.get(j);
|
|
894
881
|
return e == null ? !1 : (t.focusDrawing([e]), n.executeCommand(On.id, { value: "open" }), !0);
|
|
895
882
|
}
|
|
896
883
|
};
|
|
897
|
-
var
|
|
898
|
-
for (var i = n > 1 ? void 0 : n ?
|
|
884
|
+
var Gi = Object.getOwnPropertyDescriptor, Vi = (r, e, t, n) => {
|
|
885
|
+
for (var i = n > 1 ? void 0 : n ? Gi(e, t) : e, s = r.length - 1, o; s >= 0; s--)
|
|
899
886
|
(o = r[s]) && (i = o(i) || i);
|
|
900
887
|
return i;
|
|
901
888
|
}, Le = (r, e) => (t, n) => e(t, n, r);
|
|
902
|
-
function
|
|
889
|
+
function yn(r, e, t = 1, n = 0) {
|
|
903
890
|
const { top: i, left: s, bottom: o, right: c } = r, d = c - s, a = o - i, g = e.getViewport(tn.VIEW_MAIN), { viewportScrollX: u, viewportScrollY: l } = g, { scaleX: f, scaleY: h } = e.getAncestorScale();
|
|
904
891
|
return {
|
|
905
892
|
startX: (s - u) * f,
|
|
@@ -918,9 +905,9 @@ function Mn(r, e, t = 1, n = 0) {
|
|
|
918
905
|
}
|
|
919
906
|
function wt(r, e) {
|
|
920
907
|
const { top: t, left: n, width: i, height: s, angle: o, opacity: c } = r;
|
|
921
|
-
return
|
|
908
|
+
return yn({ top: t, left: n, bottom: t + s, right: n + i }, e.scene, c, o);
|
|
922
909
|
}
|
|
923
|
-
let
|
|
910
|
+
let st = class extends xe {
|
|
924
911
|
constructor(e, t, n, i, s, o) {
|
|
925
912
|
super();
|
|
926
913
|
me(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
|
|
@@ -957,7 +944,7 @@ let rt = class extends xe {
|
|
|
957
944
|
_insertRects(e) {
|
|
958
945
|
e.forEach(async (t) => {
|
|
959
946
|
const { unitId: n } = t;
|
|
960
|
-
if (!this._univerInstanceService.getUnit(n,
|
|
947
|
+
if (!this._univerInstanceService.getUnit(n, we.UNIVER_DOC))
|
|
961
948
|
return;
|
|
962
949
|
const s = this._getSceneAndTransformerByDrawingSearch(n);
|
|
963
950
|
if (s == null)
|
|
@@ -969,7 +956,7 @@ let rt = class extends xe {
|
|
|
969
956
|
if (!(c == null || c.length === 0))
|
|
970
957
|
for (const d of c) {
|
|
971
958
|
this._addHoverForRect(d);
|
|
972
|
-
const a = new
|
|
959
|
+
const a = new Un(), g = wt(d, s.renderUnit), u = new Tt(g), l = s.canvas, f = o.data, h = {
|
|
973
960
|
dispose: a,
|
|
974
961
|
rect: d,
|
|
975
962
|
position$: u,
|
|
@@ -1008,15 +995,15 @@ let rt = class extends xe {
|
|
|
1008
995
|
}
|
|
1009
996
|
_addHoverForRect(e) {
|
|
1010
997
|
this.disposeWithMe(
|
|
1011
|
-
|
|
998
|
+
Xe(
|
|
1012
999
|
e.onPointerEnter$.subscribeEvent(() => {
|
|
1013
|
-
e.cursor =
|
|
1000
|
+
e.cursor = Nt.GRAB;
|
|
1014
1001
|
})
|
|
1015
1002
|
)
|
|
1016
1003
|
), this.disposeWithMe(
|
|
1017
|
-
|
|
1004
|
+
Xe(
|
|
1018
1005
|
e.onPointerLeave$.subscribeEvent(() => {
|
|
1019
|
-
e.cursor =
|
|
1006
|
+
e.cursor = Nt.DEFAULT;
|
|
1020
1007
|
})
|
|
1021
1008
|
)
|
|
1022
1009
|
);
|
|
@@ -1040,14 +1027,14 @@ let rt = class extends xe {
|
|
|
1040
1027
|
});
|
|
1041
1028
|
};
|
|
1042
1029
|
this.disposeWithMe(
|
|
1043
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(
|
|
1044
|
-
|
|
1030
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(we.UNIVER_DOC).pipe(
|
|
1031
|
+
Vt((t) => {
|
|
1045
1032
|
if (!t) return null;
|
|
1046
1033
|
const n = t.getUnitId(), i = this._renderManagerService.getRenderById(n);
|
|
1047
1034
|
return i ? { render: i, unitId: n } : null;
|
|
1048
1035
|
}),
|
|
1049
1036
|
Ci(
|
|
1050
|
-
(t) => t ? Zt(t.render.scene.getViewport(tn.VIEW_MAIN).onScrollAfter$).pipe(
|
|
1037
|
+
(t) => t ? Zt(t.render.scene.getViewport(tn.VIEW_MAIN).onScrollAfter$).pipe(Vt(() => ({ unitId: t.unitId }))) : Ei(null)
|
|
1051
1038
|
)
|
|
1052
1039
|
).subscribe((t) => {
|
|
1053
1040
|
if (!t) return;
|
|
@@ -1062,8 +1049,8 @@ let rt = class extends xe {
|
|
|
1062
1049
|
}));
|
|
1063
1050
|
}
|
|
1064
1051
|
insertFloatDom(e, t) {
|
|
1065
|
-
var m, p,
|
|
1066
|
-
const n = this._univerInstanceService.getCurrentUnitOfType(
|
|
1052
|
+
var m, p, v;
|
|
1053
|
+
const n = this._univerInstanceService.getCurrentUnitOfType(we.UNIVER_DOC);
|
|
1067
1054
|
if (!n) return !1;
|
|
1068
1055
|
const i = this._getSceneAndTransformerByDrawingSearch(n.getUnitId());
|
|
1069
1056
|
if (!i) return !1;
|
|
@@ -1083,7 +1070,7 @@ let rt = class extends xe {
|
|
|
1083
1070
|
posOffset: 0
|
|
1084
1071
|
},
|
|
1085
1072
|
angle: 0
|
|
1086
|
-
}, f = (
|
|
1073
|
+
}, f = (v = t.drawingId) != null ? v : Qt(), h = {
|
|
1087
1074
|
unitId: n.getUnitId(),
|
|
1088
1075
|
drawings: [
|
|
1089
1076
|
{
|
|
@@ -1100,851 +1087,184 @@ let rt = class extends xe {
|
|
|
1100
1087
|
}
|
|
1101
1088
|
]
|
|
1102
1089
|
};
|
|
1103
|
-
return this._commandService.syncExecuteCommand(
|
|
1090
|
+
return this._commandService.syncExecuteCommand(bt.id, h), f;
|
|
1104
1091
|
}
|
|
1105
1092
|
};
|
|
1106
|
-
|
|
1093
|
+
st = Vi([
|
|
1107
1094
|
Le(0, Q),
|
|
1108
1095
|
Le(1, fe),
|
|
1109
1096
|
Le(2, Z(gn)),
|
|
1110
1097
|
Le(3, Z(Si)),
|
|
1111
1098
|
Le(4, z),
|
|
1112
|
-
Le(5,
|
|
1113
|
-
],
|
|
1114
|
-
const
|
|
1115
|
-
const e =
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
value: String(W.LINE),
|
|
1133
|
-
disabled: g === pt.MODERN
|
|
1134
|
-
}, {
|
|
1135
|
-
label: t.t("image-position.page"),
|
|
1136
|
-
value: String(W.PAGE),
|
|
1137
|
-
disabled: g === pt.MODERN
|
|
1138
|
-
}, {
|
|
1139
|
-
label: t.t("image-position.margin"),
|
|
1140
|
-
value: String(W.MARGIN),
|
|
1141
|
-
disabled: g === pt.MODERN
|
|
1142
|
-
}, {
|
|
1143
|
-
label: t.t("image-position.paragraph"),
|
|
1144
|
-
value: String(W.PARAGRAPH)
|
|
1145
|
-
}], [p, w] = re(!0), [D, S] = re({
|
|
1146
|
-
relativeFrom: J.PAGE,
|
|
1147
|
-
posOffset: 0
|
|
1148
|
-
}), [O, C] = re({
|
|
1149
|
-
relativeFrom: W.PAGE,
|
|
1150
|
-
posOffset: 0
|
|
1151
|
-
}), [y, A] = re(!0), [L, R] = re(!0);
|
|
1152
|
-
function v(_, E) {
|
|
1153
|
-
var b;
|
|
1154
|
-
_ === "positionH" ? S(E) : C(E);
|
|
1155
|
-
const T = n.getFocusDrawings();
|
|
1156
|
-
if (T.length === 0)
|
|
1157
|
-
return;
|
|
1158
|
-
const U = T.map((P) => ({
|
|
1159
|
-
unitId: P.unitId,
|
|
1160
|
-
subUnitId: P.subUnitId,
|
|
1161
|
-
drawingId: P.drawingId
|
|
1162
|
-
}));
|
|
1163
|
-
e.executeCommand(qe.id, {
|
|
1164
|
-
unitId: T[0].unitId,
|
|
1165
|
-
subUnitId: T[0].unitId,
|
|
1166
|
-
drawings: U.map((P) => ({
|
|
1167
|
-
drawingId: P.drawingId,
|
|
1168
|
-
key: _,
|
|
1169
|
-
value: E
|
|
1170
|
-
}))
|
|
1171
|
-
});
|
|
1172
|
-
const B = (b = i.getRenderById(d)) == null ? void 0 : b.with(Me);
|
|
1173
|
-
B && B.blur(), f.refreshControls();
|
|
1174
|
-
}
|
|
1175
|
-
function N(_) {
|
|
1176
|
-
var ie, Ie, _e;
|
|
1177
|
-
const E = D.relativeFrom, T = D.posOffset, U = Number(_);
|
|
1178
|
-
if (E === U)
|
|
1179
|
-
return;
|
|
1180
|
-
const B = n.getFocusDrawings();
|
|
1181
|
-
if (B.length === 0)
|
|
1182
|
-
return;
|
|
1183
|
-
const b = B[0].drawingId, P = B[0].unitId;
|
|
1184
|
-
let j = null, F = 0;
|
|
1185
|
-
const K = (ie = i.getRenderById(P)) == null ? void 0 : ie.with(te).getSkeleton(), oe = K == null ? void 0 : K.getSkeletonData();
|
|
1186
|
-
if (oe == null)
|
|
1187
|
-
return;
|
|
1188
|
-
const { pages: Ue, skeHeaders: ye, skeFooters: We } = oe;
|
|
1189
|
-
for (const ce of Ue) {
|
|
1190
|
-
const { marginLeft: Se, skeDrawings: De, headerId: be, footerId: Ce, pageWidth: Oe } = ce;
|
|
1191
|
-
if (De.has(b)) {
|
|
1192
|
-
j = De.get(b), F = Se;
|
|
1193
|
-
break;
|
|
1194
|
-
}
|
|
1195
|
-
const de = (Ie = ye.get(be)) == null ? void 0 : Ie.get(Oe);
|
|
1196
|
-
if (de != null && de.skeDrawings.has(b)) {
|
|
1197
|
-
j = de == null ? void 0 : de.skeDrawings.get(b), F = Se;
|
|
1198
|
-
break;
|
|
1199
|
-
}
|
|
1200
|
-
const ge = (_e = We.get(Ce)) == null ? void 0 : _e.get(Oe);
|
|
1201
|
-
if (ge != null && ge.skeDrawings.has(b)) {
|
|
1202
|
-
j = ge == null ? void 0 : ge.skeDrawings.get(b), F = Se;
|
|
1203
|
-
break;
|
|
1099
|
+
Le(5, j)
|
|
1100
|
+
], st);
|
|
1101
|
+
const Mn = "doc.menu.image", bn = pn.id, ji = (r) => {
|
|
1102
|
+
const e = r.get(Ot), t = r.get(z);
|
|
1103
|
+
return new Ri((n) => {
|
|
1104
|
+
const i = e.textSelection$.subscribe(() => {
|
|
1105
|
+
var o;
|
|
1106
|
+
const s = e.getActiveTextRange();
|
|
1107
|
+
if (s) {
|
|
1108
|
+
const { segmentId: c, startOffset: d, endOffset: a } = s, g = t.getCurrentUniverDocInstance(), u = (o = g == null ? void 0 : g.getSelfOrHeaderFooterModel(c).getBody()) == null ? void 0 : o.tables;
|
|
1109
|
+
if (u && u.length && u.some((l) => {
|
|
1110
|
+
const { startIndex: f, endIndex: h } = l;
|
|
1111
|
+
return d >= f && d < h || a >= f && a < h;
|
|
1112
|
+
})) {
|
|
1113
|
+
n.next(!0);
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
} else {
|
|
1117
|
+
n.next(!0);
|
|
1118
|
+
return;
|
|
1204
1119
|
}
|
|
1120
|
+
n.next(!1);
|
|
1121
|
+
});
|
|
1122
|
+
return () => i.unsubscribe();
|
|
1123
|
+
});
|
|
1124
|
+
};
|
|
1125
|
+
function $i(r) {
|
|
1126
|
+
return {
|
|
1127
|
+
id: Mn,
|
|
1128
|
+
type: an.SUBITEMS,
|
|
1129
|
+
icon: "AddImageIcon",
|
|
1130
|
+
tooltip: "docImage.title",
|
|
1131
|
+
disabled$: ji(r),
|
|
1132
|
+
hidden$: on(r, we.UNIVER_DOC, void 0, Dt)
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
function zi(r) {
|
|
1136
|
+
return {
|
|
1137
|
+
id: bn,
|
|
1138
|
+
title: "docImage.upload.float",
|
|
1139
|
+
type: an.BUTTON,
|
|
1140
|
+
hidden$: on(r, we.UNIVER_DOC, void 0, Dt)
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
const Xi = "@univerjs/docs-drawing-ui", qi = "0.17.0", Cn = {
|
|
1144
|
+
name: Xi,
|
|
1145
|
+
version: qi
|
|
1146
|
+
}, Ki = "docs-drawing-ui.config", zt = {};
|
|
1147
|
+
var Yi = Object.getOwnPropertyDescriptor, Zi = (r, e, t, n) => {
|
|
1148
|
+
for (var i = n > 1 ? void 0 : n ? Yi(e, t) : e, s = r.length - 1, o; s >= 0; s--)
|
|
1149
|
+
(o = r[s]) && (i = o(i) || i);
|
|
1150
|
+
return i;
|
|
1151
|
+
}, Ve = (r, e) => (t, n) => e(t, n, r);
|
|
1152
|
+
function Qi(r) {
|
|
1153
|
+
var n, i, s, o;
|
|
1154
|
+
if ($.isNoop(r) || !Array.isArray(r))
|
|
1155
|
+
return null;
|
|
1156
|
+
const e = r.find((c) => Array.isArray(c) && (c == null ? void 0 : c[0]) === "drawings");
|
|
1157
|
+
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")
|
|
1158
|
+
return null;
|
|
1159
|
+
const t = [];
|
|
1160
|
+
if (Array.isArray(e == null ? void 0 : e[1]))
|
|
1161
|
+
for (const c of e)
|
|
1162
|
+
Array.isArray(c) && t.push({
|
|
1163
|
+
type: (n = c == null ? void 0 : c[1]) != null && n.i ? "add" : "remove",
|
|
1164
|
+
drawingId: c == null ? void 0 : c[0],
|
|
1165
|
+
drawing: (i = c == null ? void 0 : c[1]) == null ? void 0 : i.i
|
|
1166
|
+
});
|
|
1167
|
+
else
|
|
1168
|
+
t.push({
|
|
1169
|
+
type: (s = e[2]) != null && s.i ? "add" : "remove",
|
|
1170
|
+
drawingId: e[1],
|
|
1171
|
+
drawing: (o = e[2]) == null ? void 0 : o.i
|
|
1172
|
+
});
|
|
1173
|
+
return t;
|
|
1174
|
+
}
|
|
1175
|
+
function Ji(r) {
|
|
1176
|
+
if (!Array.isArray(r) || r.length < 3 || r[0] !== "drawingsOrder")
|
|
1177
|
+
return [];
|
|
1178
|
+
const e = [];
|
|
1179
|
+
for (let t = 1; t < r.length; t++) {
|
|
1180
|
+
const n = r[t];
|
|
1181
|
+
if (Array.isArray(n) && typeof n[0] == "number" && typeof n[1] == "object")
|
|
1182
|
+
e.push(n[0]);
|
|
1183
|
+
else {
|
|
1184
|
+
e.length = 0;
|
|
1185
|
+
break;
|
|
1205
1186
|
}
|
|
1206
|
-
if (j == null)
|
|
1207
|
-
return;
|
|
1208
|
-
let ae = 0;
|
|
1209
|
-
E === J.COLUMN ? ae -= j.columnLeft : E === J.MARGIN && (ae -= F), U === J.COLUMN ? ae += j.columnLeft : U === J.MARGIN ? ae += F : J.PAGE;
|
|
1210
|
-
const ne = {
|
|
1211
|
-
relativeFrom: U,
|
|
1212
|
-
posOffset: (T != null ? T : 0) - ae
|
|
1213
|
-
};
|
|
1214
|
-
v("positionH", ne);
|
|
1215
1187
|
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
const B = n.getFocusDrawings();
|
|
1222
|
-
if (B.length === 0)
|
|
1223
|
-
return;
|
|
1224
|
-
const { drawingId: b, unitId: P } = B[0], j = s.getUniverDocInstance(P), F = (De = i.getRenderById(P)) == null ? void 0 : De.with(te).getSkeleton(), K = (be = i.getRenderById(P)) == null ? void 0 : be.with(Me), oe = K == null ? void 0 : K.getSegment(), Ue = K == null ? void 0 : K.getSegmentPage(), ye = (Oe = (Ce = j == null ? void 0 : j.getSelfOrHeaderFooterModel(oe).getBody()) == null ? void 0 : Ce.customBlocks) == null ? void 0 : Oe.find((Ee) => Ee.blockId === b);
|
|
1225
|
-
if (ye == null || F == null || K == null)
|
|
1226
|
-
return;
|
|
1227
|
-
const { startIndex: We } = ye, ae = F.findNodeByCharIndex(We, oe, Ue), ne = (de = ae == null ? void 0 : ae.parent) == null ? void 0 : de.parent, ie = ne == null ? void 0 : ne.parent, Ie = ie == null ? void 0 : ie.lines.find((Ee) => Ee.paragraphIndex === (ne == null ? void 0 : ne.paragraphIndex) && Ee.paragraphStart), _e = (ge = ie == null ? void 0 : ie.parent) == null ? void 0 : ge.parent;
|
|
1228
|
-
if (ae == null || ne == null || Ie == null || ie == null || _e == null)
|
|
1229
|
-
return;
|
|
1230
|
-
let ce = 0;
|
|
1231
|
-
E === W.PARAGRAPH ? ce -= Ie.top : E === W.LINE ? ce -= ne.top : E === W.PAGE && (ce += _e.marginTop), U === W.PARAGRAPH ? ce += Ie.top : U === W.LINE ? ce += ne.top : U === W.PAGE && (ce -= _e.marginTop);
|
|
1232
|
-
const Se = {
|
|
1233
|
-
relativeFrom: U,
|
|
1234
|
-
posOffset: (T != null ? T : 0) - ce
|
|
1235
|
-
};
|
|
1236
|
-
v("positionV", Se);
|
|
1188
|
+
return e;
|
|
1189
|
+
}
|
|
1190
|
+
let ot = class extends xe {
|
|
1191
|
+
constructor(r, e, t, n, i) {
|
|
1192
|
+
super(), this._univerInstanceService = r, this._commandService = e, this._drawingManagerService = t, this._docDrawingService = n, this._renderManagerService = i, this._initialize();
|
|
1237
1193
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
const E = a == null ? void 0 : a.getSnapshot(), T = (P = E == null ? void 0 : E.drawings) == null ? void 0 : P[_.drawingId];
|
|
1241
|
-
if (T == null)
|
|
1242
|
-
return;
|
|
1243
|
-
const { layoutType: U } = T, {
|
|
1244
|
-
positionH: B,
|
|
1245
|
-
positionV: b
|
|
1246
|
-
} = T.docTransform;
|
|
1247
|
-
S(B), C(b), w(U === k.INLINE), A(b.relativeFrom === W.PARAGRAPH || b.relativeFrom === W.LINE);
|
|
1194
|
+
_initialize() {
|
|
1195
|
+
this._commandExecutedListener();
|
|
1248
1196
|
}
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1197
|
+
_commandExecutedListener() {
|
|
1198
|
+
this.disposeWithMe(
|
|
1199
|
+
this._commandService.beforeCommandExecuted((r) => {
|
|
1200
|
+
if (r.id !== ee.id)
|
|
1201
|
+
return;
|
|
1202
|
+
const e = r.params, { unitId: t, actions: n } = e, i = Qi(n);
|
|
1203
|
+
if (i != null)
|
|
1204
|
+
for (const { type: s, drawingId: o, drawing: c } of i)
|
|
1205
|
+
s === "add" ? this._addDrawings(t, [c]) : this._removeDrawings(t, [o]);
|
|
1206
|
+
})
|
|
1207
|
+
), this.disposeWithMe(
|
|
1208
|
+
this._commandService.onCommandExecuted((r) => {
|
|
1209
|
+
if (r.id !== ee.id)
|
|
1210
|
+
return;
|
|
1211
|
+
const e = r.params, { unitId: t, actions: n } = e;
|
|
1212
|
+
Ji(n).length > 0 && this._updateDrawingsOrder(t);
|
|
1213
|
+
})
|
|
1214
|
+
), this.disposeWithMe(
|
|
1215
|
+
this._commandService.onCommandExecuted((r) => {
|
|
1216
|
+
var o;
|
|
1217
|
+
if (r.id !== Bn.id && r.id !== Fn.id)
|
|
1218
|
+
return;
|
|
1219
|
+
const e = (o = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : o.getUnitId(), t = this._drawingManagerService.getFocusDrawings();
|
|
1220
|
+
if (e == null || t.length === 0)
|
|
1221
|
+
return;
|
|
1222
|
+
const n = this._renderManagerService.getRenderById(e), i = n == null ? void 0 : n.scene;
|
|
1223
|
+
if (i == null)
|
|
1224
|
+
return !1;
|
|
1225
|
+
i.getTransformerByCreate().refreshControls();
|
|
1226
|
+
})
|
|
1227
|
+
);
|
|
1252
1228
|
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1229
|
+
_addDrawings(r, e) {
|
|
1230
|
+
const t = this._drawingManagerService, n = this._docDrawingService, i = this._docDrawingService.getBatchAddOp(e), { subUnitId: s, redo: o, objects: c } = i;
|
|
1231
|
+
t.applyJson1(r, s, o), n.applyJson1(r, s, o), t.addNotification(c), n.addNotification(c);
|
|
1255
1232
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
/* @__PURE__ */ M(
|
|
1278
|
-
"header",
|
|
1279
|
-
{
|
|
1280
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1281
|
-
children: /* @__PURE__ */ M("div", { children: t.t("image-position.title") })
|
|
1282
|
-
}
|
|
1283
|
-
),
|
|
1284
|
-
/* @__PURE__ */ M(
|
|
1285
|
-
"div",
|
|
1286
|
-
{
|
|
1287
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1288
|
-
children: /* @__PURE__ */ M("div", { children: t.t("image-position.horizontal") })
|
|
1289
|
-
}
|
|
1290
|
-
),
|
|
1291
|
-
/* @__PURE__ */ X(
|
|
1292
|
-
"div",
|
|
1293
|
-
{
|
|
1294
|
-
className: "univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",
|
|
1295
|
-
children: [
|
|
1296
|
-
/* @__PURE__ */ X("div", { children: [
|
|
1297
|
-
/* @__PURE__ */ M("span", { children: t.t("image-position.absolutePosition") }),
|
|
1298
|
-
/* @__PURE__ */ M(
|
|
1299
|
-
Be,
|
|
1300
|
-
{
|
|
1301
|
-
min: zt,
|
|
1302
|
-
max: Xt,
|
|
1303
|
-
precision: 1,
|
|
1304
|
-
disabled: p,
|
|
1305
|
-
value: D.posOffset,
|
|
1306
|
-
onChange: (_) => {
|
|
1307
|
-
v("positionH", {
|
|
1308
|
-
relativeFrom: D.relativeFrom,
|
|
1309
|
-
posOffset: _
|
|
1310
|
-
});
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
)
|
|
1314
|
-
] }),
|
|
1315
|
-
/* @__PURE__ */ X("div", { children: [
|
|
1316
|
-
/* @__PURE__ */ M("span", { children: t.t("image-position.toTheRightOf") }),
|
|
1317
|
-
/* @__PURE__ */ M(
|
|
1318
|
-
Bt,
|
|
1319
|
-
{
|
|
1320
|
-
value: String(D.relativeFrom),
|
|
1321
|
-
disabled: p,
|
|
1322
|
-
options: h,
|
|
1323
|
-
onChange: N
|
|
1324
|
-
}
|
|
1325
|
-
)
|
|
1326
|
-
] })
|
|
1327
|
-
]
|
|
1328
|
-
}
|
|
1329
|
-
),
|
|
1330
|
-
/* @__PURE__ */ M(
|
|
1331
|
-
"div",
|
|
1332
|
-
{
|
|
1333
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1334
|
-
children: /* @__PURE__ */ M("div", { children: t.t("image-position.vertical") })
|
|
1335
|
-
}
|
|
1336
|
-
),
|
|
1337
|
-
/* @__PURE__ */ X(
|
|
1338
|
-
"div",
|
|
1339
|
-
{
|
|
1340
|
-
className: "univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",
|
|
1341
|
-
children: [
|
|
1342
|
-
/* @__PURE__ */ X("div", { children: [
|
|
1343
|
-
/* @__PURE__ */ M("span", { children: t.t("image-position.absolutePosition") }),
|
|
1344
|
-
/* @__PURE__ */ M(
|
|
1345
|
-
Be,
|
|
1346
|
-
{
|
|
1347
|
-
min: zt,
|
|
1348
|
-
max: Xt,
|
|
1349
|
-
precision: 1,
|
|
1350
|
-
disabled: p,
|
|
1351
|
-
value: O.posOffset,
|
|
1352
|
-
onChange: (_) => {
|
|
1353
|
-
v("positionV", {
|
|
1354
|
-
relativeFrom: O.relativeFrom,
|
|
1355
|
-
posOffset: _
|
|
1356
|
-
});
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
)
|
|
1360
|
-
] }),
|
|
1361
|
-
/* @__PURE__ */ X("div", { children: [
|
|
1362
|
-
/* @__PURE__ */ M("span", { children: t.t("image-position.bellow") }),
|
|
1363
|
-
/* @__PURE__ */ M(
|
|
1364
|
-
Bt,
|
|
1365
|
-
{
|
|
1366
|
-
disabled: p,
|
|
1367
|
-
value: String(O.relativeFrom),
|
|
1368
|
-
options: m,
|
|
1369
|
-
onChange: G
|
|
1370
|
-
}
|
|
1371
|
-
)
|
|
1372
|
-
] })
|
|
1373
|
-
]
|
|
1374
|
-
}
|
|
1375
|
-
),
|
|
1376
|
-
/* @__PURE__ */ M(
|
|
1377
|
-
"div",
|
|
1378
|
-
{
|
|
1379
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1380
|
-
children: /* @__PURE__ */ M("div", { children: t.t("image-position.options") })
|
|
1381
|
-
}
|
|
1382
|
-
),
|
|
1383
|
-
/* @__PURE__ */ M("div", { children: /* @__PURE__ */ M(
|
|
1384
|
-
di,
|
|
1385
|
-
{
|
|
1386
|
-
disabled: p,
|
|
1387
|
-
checked: y,
|
|
1388
|
-
onChange: I,
|
|
1389
|
-
children: t.t("image-position.moveObjectWithText")
|
|
1390
|
-
}
|
|
1391
|
-
) })
|
|
1392
|
-
]
|
|
1393
|
-
}
|
|
1394
|
-
);
|
|
1395
|
-
}, Qe = 0, Je = 100, zi = (r) => {
|
|
1396
|
-
const e = we(V), t = we(lt), n = we(fe), i = we(Q), s = we(z), { drawings: o } = r, c = o[0];
|
|
1397
|
-
if (c == null)
|
|
1398
|
-
return null;
|
|
1399
|
-
const { unitId: d } = c, a = s.getUniverDocInstance(d), g = i.getRenderById(d);
|
|
1400
|
-
if ((g == null ? void 0 : g.scene) == null)
|
|
1401
|
-
return null;
|
|
1402
|
-
const [l, f] = re(!0), [h, m] = re(!0), [p, w] = re(!0), [D, S] = re(ue.INLINE), [O, C] = re(""), [y, A] = re({
|
|
1403
|
-
distT: 0,
|
|
1404
|
-
distL: 0,
|
|
1405
|
-
distB: 0,
|
|
1406
|
-
distR: 0
|
|
1407
|
-
}), [L, R] = re(!0);
|
|
1408
|
-
function v(I) {
|
|
1409
|
-
S(I);
|
|
1410
|
-
const _ = n.getFocusDrawings();
|
|
1411
|
-
if (_.length === 0)
|
|
1412
|
-
return;
|
|
1413
|
-
const { unitId: E, subUnitId: T } = _[0], U = _.map(({ unitId: B, subUnitId: b, drawingId: P }) => ({
|
|
1414
|
-
unitId: B,
|
|
1415
|
-
subUnitId: b,
|
|
1416
|
-
drawingId: P
|
|
1417
|
-
}));
|
|
1418
|
-
e.executeCommand(wn.id, {
|
|
1419
|
-
unitId: E,
|
|
1420
|
-
subUnitId: T,
|
|
1421
|
-
drawings: U,
|
|
1422
|
-
wrappingStyle: I
|
|
1423
|
-
});
|
|
1424
|
-
}
|
|
1425
|
-
function N(I) {
|
|
1426
|
-
C(I);
|
|
1427
|
-
const _ = n.getFocusDrawings();
|
|
1428
|
-
if (_.length === 0)
|
|
1429
|
-
return;
|
|
1430
|
-
const E = _.map((T) => ({
|
|
1431
|
-
unitId: T.unitId,
|
|
1432
|
-
subUnitId: T.subUnitId,
|
|
1433
|
-
drawingId: T.drawingId
|
|
1434
|
-
}));
|
|
1435
|
-
e.executeCommand(In.id, {
|
|
1436
|
-
unitId: _[0].unitId,
|
|
1437
|
-
subUnitId: _[0].unitId,
|
|
1438
|
-
drawings: E,
|
|
1439
|
-
wrapText: I
|
|
1440
|
-
});
|
|
1441
|
-
}
|
|
1442
|
-
function G(I, _) {
|
|
1443
|
-
if (I == null)
|
|
1444
|
-
return;
|
|
1445
|
-
const E = { ...y, [_]: I };
|
|
1446
|
-
A(E);
|
|
1447
|
-
const T = n.getFocusDrawings();
|
|
1448
|
-
if (T.length === 0)
|
|
1449
|
-
return;
|
|
1450
|
-
const U = T.map((B) => ({
|
|
1451
|
-
unitId: B.unitId,
|
|
1452
|
-
subUnitId: B.subUnitId,
|
|
1453
|
-
drawingId: B.drawingId
|
|
1454
|
-
}));
|
|
1455
|
-
e.executeCommand(vn.id, {
|
|
1456
|
-
unitId: T[0].unitId,
|
|
1457
|
-
subUnitId: T[0].unitId,
|
|
1458
|
-
drawings: U,
|
|
1459
|
-
dist: {
|
|
1460
|
-
[_]: I
|
|
1461
|
-
}
|
|
1462
|
-
});
|
|
1463
|
-
}
|
|
1464
|
-
function x() {
|
|
1465
|
-
const I = n.getFocusDrawings();
|
|
1466
|
-
I.length !== 0 && H(I[0]);
|
|
1467
|
-
}
|
|
1468
|
-
function H(I) {
|
|
1469
|
-
var K, oe;
|
|
1470
|
-
const _ = (oe = (K = a == null ? void 0 : a.getSnapshot()) == null ? void 0 : K.drawings) == null ? void 0 : oe[I.drawingId];
|
|
1471
|
-
if (_ == null)
|
|
1472
|
-
return;
|
|
1473
|
-
const {
|
|
1474
|
-
distT: E = 0,
|
|
1475
|
-
distL: T = 0,
|
|
1476
|
-
distB: U = 0,
|
|
1477
|
-
distR: B = 0,
|
|
1478
|
-
layoutType: b = k.INLINE,
|
|
1479
|
-
behindDoc: P = se.FALSE,
|
|
1480
|
-
wrapText: j = $e.BOTH_SIDES
|
|
1481
|
-
} = _;
|
|
1482
|
-
if (A({
|
|
1483
|
-
distT: E,
|
|
1484
|
-
distL: T,
|
|
1485
|
-
distB: U,
|
|
1486
|
-
distR: B
|
|
1487
|
-
}), C(j), f(b !== k.WRAP_SQUARE), b === k.WRAP_NONE || b === k.INLINE ? m(!0) : m(!1), b === k.WRAP_NONE || b === k.INLINE || b === k.WRAP_TOP_AND_BOTTOM ? w(!0) : w(!1), b === k.WRAP_NONE)
|
|
1488
|
-
P === se.TRUE ? S(ue.BEHIND_TEXT) : S(ue.IN_FRONT_OF_TEXT);
|
|
1489
|
-
else
|
|
1490
|
-
switch (b) {
|
|
1491
|
-
case k.INLINE:
|
|
1492
|
-
S(ue.INLINE);
|
|
1493
|
-
break;
|
|
1494
|
-
case k.WRAP_SQUARE:
|
|
1495
|
-
S(ue.WRAP_SQUARE);
|
|
1496
|
-
break;
|
|
1497
|
-
case k.WRAP_TOP_AND_BOTTOM:
|
|
1498
|
-
S(ue.WRAP_TOP_AND_BOTTOM);
|
|
1499
|
-
break;
|
|
1500
|
-
default:
|
|
1501
|
-
throw new Error(`Unsupported layout type: ${b}`);
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
return Tt(() => {
|
|
1505
|
-
x();
|
|
1506
|
-
const I = n.focus$.subscribe((E) => {
|
|
1507
|
-
if (E.length === 0) {
|
|
1508
|
-
R(!1);
|
|
1509
|
-
return;
|
|
1510
|
-
}
|
|
1511
|
-
R(!0), H(E[0]);
|
|
1512
|
-
}), _ = e.onCommandExecuted(async (E) => {
|
|
1513
|
-
E.id === ee.id && x();
|
|
1514
|
-
});
|
|
1515
|
-
return () => {
|
|
1516
|
-
I.unsubscribe(), _.dispose();
|
|
1517
|
-
};
|
|
1518
|
-
}, []), /* @__PURE__ */ X(
|
|
1519
|
-
"div",
|
|
1520
|
-
{
|
|
1521
|
-
className: sn("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", {
|
|
1522
|
-
"univer-hidden": !L
|
|
1523
|
-
}),
|
|
1524
|
-
children: [
|
|
1525
|
-
/* @__PURE__ */ M(
|
|
1526
|
-
"header",
|
|
1527
|
-
{
|
|
1528
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1529
|
-
children: /* @__PURE__ */ M("div", { children: t.t("image-text-wrap.title") })
|
|
1530
|
-
}
|
|
1531
|
-
),
|
|
1532
|
-
/* @__PURE__ */ M(
|
|
1533
|
-
"div",
|
|
1534
|
-
{
|
|
1535
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1536
|
-
children: /* @__PURE__ */ M("div", { children: t.t("image-text-wrap.wrappingStyle") })
|
|
1537
|
-
}
|
|
1538
|
-
),
|
|
1539
|
-
/* @__PURE__ */ M("div", { children: /* @__PURE__ */ X(Ft, { value: D, onChange: v, direction: "vertical", children: [
|
|
1540
|
-
/* @__PURE__ */ M(Te, { value: ue.INLINE, children: t.t("image-text-wrap.inline") }),
|
|
1541
|
-
/* @__PURE__ */ M(Te, { value: ue.WRAP_SQUARE, children: t.t("image-text-wrap.square") }),
|
|
1542
|
-
/* @__PURE__ */ M(Te, { value: ue.WRAP_TOP_AND_BOTTOM, children: t.t("image-text-wrap.topAndBottom") }),
|
|
1543
|
-
/* @__PURE__ */ M(Te, { value: ue.BEHIND_TEXT, children: t.t("image-text-wrap.behindText") }),
|
|
1544
|
-
/* @__PURE__ */ M(Te, { value: ue.IN_FRONT_OF_TEXT, children: t.t("image-text-wrap.inFrontText") })
|
|
1545
|
-
] }) }),
|
|
1546
|
-
/* @__PURE__ */ M(
|
|
1547
|
-
"div",
|
|
1548
|
-
{
|
|
1549
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1550
|
-
children: /* @__PURE__ */ M("div", { children: t.t("image-text-wrap.wrapText") })
|
|
1551
|
-
}
|
|
1552
|
-
),
|
|
1553
|
-
/* @__PURE__ */ M("div", { children: /* @__PURE__ */ X(Ft, { disabled: l, value: O, onChange: N, direction: "horizontal", children: [
|
|
1554
|
-
/* @__PURE__ */ M(Te, { value: $e.BOTH_SIDES, children: t.t("image-text-wrap.bothSide") }),
|
|
1555
|
-
/* @__PURE__ */ M(Te, { value: $e.LEFT, children: t.t("image-text-wrap.leftOnly") }),
|
|
1556
|
-
/* @__PURE__ */ M(Te, { value: $e.RIGHT, children: t.t("image-text-wrap.rightOnly") })
|
|
1557
|
-
] }) }),
|
|
1558
|
-
/* @__PURE__ */ M(
|
|
1559
|
-
"div",
|
|
1560
|
-
{
|
|
1561
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1562
|
-
children: /* @__PURE__ */ M("div", { children: t.t("image-text-wrap.distanceFromText") })
|
|
1563
|
-
}
|
|
1564
|
-
),
|
|
1565
|
-
/* @__PURE__ */ X(
|
|
1566
|
-
"div",
|
|
1567
|
-
{
|
|
1568
|
-
className: "univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",
|
|
1569
|
-
children: [
|
|
1570
|
-
/* @__PURE__ */ X("div", { children: [
|
|
1571
|
-
/* @__PURE__ */ M("span", { children: t.t("image-text-wrap.top") }),
|
|
1572
|
-
/* @__PURE__ */ M(
|
|
1573
|
-
Be,
|
|
1574
|
-
{
|
|
1575
|
-
min: Qe,
|
|
1576
|
-
max: Je,
|
|
1577
|
-
disabled: h,
|
|
1578
|
-
precision: 1,
|
|
1579
|
-
value: y.distT,
|
|
1580
|
-
onChange: (I) => {
|
|
1581
|
-
G(I, "distT");
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
)
|
|
1585
|
-
] }),
|
|
1586
|
-
/* @__PURE__ */ X("div", { children: [
|
|
1587
|
-
/* @__PURE__ */ M("span", { children: t.t("image-text-wrap.left") }),
|
|
1588
|
-
/* @__PURE__ */ M(
|
|
1589
|
-
Be,
|
|
1590
|
-
{
|
|
1591
|
-
min: Qe,
|
|
1592
|
-
max: Je,
|
|
1593
|
-
disabled: p,
|
|
1594
|
-
precision: 1,
|
|
1595
|
-
value: y.distL,
|
|
1596
|
-
onChange: (I) => {
|
|
1597
|
-
G(I, "distL");
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1600
|
-
)
|
|
1601
|
-
] })
|
|
1602
|
-
]
|
|
1603
|
-
}
|
|
1604
|
-
),
|
|
1605
|
-
/* @__PURE__ */ X(
|
|
1606
|
-
"div",
|
|
1607
|
-
{
|
|
1608
|
-
className: "univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",
|
|
1609
|
-
children: [
|
|
1610
|
-
/* @__PURE__ */ X("div", { children: [
|
|
1611
|
-
/* @__PURE__ */ M("span", { children: t.t("image-text-wrap.bottom") }),
|
|
1612
|
-
/* @__PURE__ */ M(
|
|
1613
|
-
Be,
|
|
1614
|
-
{
|
|
1615
|
-
min: Qe,
|
|
1616
|
-
max: Je,
|
|
1617
|
-
disabled: h,
|
|
1618
|
-
precision: 1,
|
|
1619
|
-
value: y.distB,
|
|
1620
|
-
onChange: (I) => {
|
|
1621
|
-
G(I, "distB");
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
)
|
|
1625
|
-
] }),
|
|
1626
|
-
/* @__PURE__ */ X("div", { children: [
|
|
1627
|
-
/* @__PURE__ */ M("span", { children: t.t("image-text-wrap.right") }),
|
|
1628
|
-
/* @__PURE__ */ M(
|
|
1629
|
-
Be,
|
|
1630
|
-
{
|
|
1631
|
-
min: Qe,
|
|
1632
|
-
max: Je,
|
|
1633
|
-
disabled: p,
|
|
1634
|
-
precision: 1,
|
|
1635
|
-
value: y.distR,
|
|
1636
|
-
onChange: (I) => {
|
|
1637
|
-
G(I, "distR");
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
)
|
|
1641
|
-
] })
|
|
1642
|
-
]
|
|
1643
|
-
}
|
|
1644
|
-
)
|
|
1645
|
-
]
|
|
1646
|
-
}
|
|
1647
|
-
);
|
|
1648
|
-
}, Xi = () => {
|
|
1649
|
-
const r = we(fe), e = r.getFocusDrawings(), [t, n] = re(e);
|
|
1650
|
-
return Tt(() => {
|
|
1651
|
-
const i = r.focus$.subscribe((s) => {
|
|
1652
|
-
n(s);
|
|
1653
|
-
});
|
|
1654
|
-
return () => {
|
|
1655
|
-
i.unsubscribe();
|
|
1656
|
-
};
|
|
1657
|
-
}, []), !!(t != null && t.length) && /* @__PURE__ */ X("div", { className: "univer-text-sm", children: [
|
|
1658
|
-
/* @__PURE__ */ M(Ai, { drawings: t, hasAlign: !1, hasCropper: !1, hasGroup: !1, hasTransform: !1 }),
|
|
1659
|
-
/* @__PURE__ */ M(zi, { drawings: t }),
|
|
1660
|
-
/* @__PURE__ */ M($i, { drawings: t })
|
|
1661
|
-
] });
|
|
1662
|
-
}, yn = "doc.menu.image", bn = pn.id, qi = (r) => {
|
|
1663
|
-
const e = r.get(Dt), t = r.get(z);
|
|
1664
|
-
return new Ri((n) => {
|
|
1665
|
-
const i = e.textSelection$.subscribe(() => {
|
|
1666
|
-
var o;
|
|
1667
|
-
const s = e.getActiveTextRange();
|
|
1668
|
-
if (s) {
|
|
1669
|
-
const { segmentId: c, startOffset: d, endOffset: a } = s, g = t.getCurrentUniverDocInstance(), u = (o = g == null ? void 0 : g.getSelfOrHeaderFooterModel(c).getBody()) == null ? void 0 : o.tables;
|
|
1670
|
-
if (u && u.length && u.some((l) => {
|
|
1671
|
-
const { startIndex: f, endIndex: h } = l;
|
|
1672
|
-
return d >= f && d < h || a >= f && a < h;
|
|
1673
|
-
})) {
|
|
1674
|
-
n.next(!0);
|
|
1675
|
-
return;
|
|
1676
|
-
}
|
|
1677
|
-
} else {
|
|
1678
|
-
n.next(!0);
|
|
1679
|
-
return;
|
|
1680
|
-
}
|
|
1681
|
-
n.next(!1);
|
|
1682
|
-
});
|
|
1683
|
-
return () => i.unsubscribe();
|
|
1684
|
-
});
|
|
1685
|
-
};
|
|
1686
|
-
function Ki(r) {
|
|
1687
|
-
return {
|
|
1688
|
-
id: yn,
|
|
1689
|
-
type: an.SUBITEMS,
|
|
1690
|
-
icon: "AddImageIcon",
|
|
1691
|
-
tooltip: "docImage.title",
|
|
1692
|
-
disabled$: qi(r),
|
|
1693
|
-
hidden$: on(r, ve.UNIVER_DOC, void 0, St)
|
|
1694
|
-
};
|
|
1695
|
-
}
|
|
1696
|
-
function Yi(r) {
|
|
1697
|
-
return {
|
|
1698
|
-
id: bn,
|
|
1699
|
-
title: "docImage.upload.float",
|
|
1700
|
-
type: an.BUTTON,
|
|
1701
|
-
hidden$: on(r, ve.UNIVER_DOC, void 0, St)
|
|
1702
|
-
};
|
|
1703
|
-
}
|
|
1704
|
-
const Zi = {
|
|
1705
|
-
[Di.MEDIA]: {
|
|
1706
|
-
[yn]: {
|
|
1707
|
-
order: 0,
|
|
1708
|
-
menuItemFactory: Ki,
|
|
1709
|
-
[bn]: {
|
|
1710
|
-
order: 0,
|
|
1711
|
-
menuItemFactory: Yi
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
};
|
|
1716
|
-
function Ye(r) {
|
|
1717
|
-
return r.getContextValue(Bn) && r.getContextValue(Fn) && r.getContextValue(nt);
|
|
1718
|
-
}
|
|
1719
|
-
const Qi = {
|
|
1720
|
-
id: Ke.id,
|
|
1721
|
-
description: "shortcut.drawing-move-down",
|
|
1722
|
-
group: "4_drawing-view",
|
|
1723
|
-
binding: ke.ARROW_DOWN,
|
|
1724
|
-
priority: 100,
|
|
1725
|
-
preconditions: Ye,
|
|
1726
|
-
staticParameters: {
|
|
1727
|
-
direction: he.DOWN
|
|
1728
|
-
}
|
|
1729
|
-
}, Ji = {
|
|
1730
|
-
id: Ke.id,
|
|
1731
|
-
description: "shortcut.drawing-move-up",
|
|
1732
|
-
group: "4_drawing-view",
|
|
1733
|
-
binding: ke.ARROW_UP,
|
|
1734
|
-
priority: 100,
|
|
1735
|
-
preconditions: Ye,
|
|
1736
|
-
staticParameters: {
|
|
1737
|
-
direction: he.UP
|
|
1738
|
-
}
|
|
1739
|
-
}, er = {
|
|
1740
|
-
id: Ke.id,
|
|
1741
|
-
description: "shortcut.drawing-move-left",
|
|
1742
|
-
group: "4_drawing-view",
|
|
1743
|
-
binding: ke.ARROW_LEFT,
|
|
1744
|
-
priority: 100,
|
|
1745
|
-
preconditions: Ye,
|
|
1746
|
-
staticParameters: {
|
|
1747
|
-
direction: he.LEFT
|
|
1748
|
-
}
|
|
1749
|
-
}, tr = {
|
|
1750
|
-
id: Ke.id,
|
|
1751
|
-
description: "shortcut.drawing-move-right",
|
|
1752
|
-
group: "4_drawing-view",
|
|
1753
|
-
binding: ke.ARROW_RIGHT,
|
|
1754
|
-
priority: 100,
|
|
1755
|
-
preconditions: Ye,
|
|
1756
|
-
staticParameters: {
|
|
1757
|
-
direction: he.RIGHT
|
|
1758
|
-
}
|
|
1759
|
-
}, nr = {
|
|
1760
|
-
id: ln.id,
|
|
1761
|
-
description: "shortcut.drawing-delete",
|
|
1762
|
-
group: "4_drawing-view",
|
|
1763
|
-
// when focusing on any other input tag do not trigger this shortcut
|
|
1764
|
-
preconditions: Ye,
|
|
1765
|
-
binding: ke.DELETE,
|
|
1766
|
-
mac: ke.BACKSPACE
|
|
1767
|
-
};
|
|
1768
|
-
var ir = Object.getOwnPropertyDescriptor, rr = (r, e, t, n) => {
|
|
1769
|
-
for (var i = n > 1 ? void 0 : n ? ir(e, t) : e, s = r.length - 1, o; s >= 0; s--)
|
|
1770
|
-
(o = r[s]) && (i = o(i) || i);
|
|
1771
|
-
return i;
|
|
1772
|
-
}, et = (r, e) => (t, n) => e(t, n, r);
|
|
1773
|
-
let st = class extends xe {
|
|
1774
|
-
constructor(r, e, t, n) {
|
|
1775
|
-
super(), this._componentManager = r, this._menuManagerService = e, this._commandService = t, this._shortcutService = n, this._init();
|
|
1776
|
-
}
|
|
1777
|
-
_initCustomComponents() {
|
|
1778
|
-
const r = this._componentManager;
|
|
1779
|
-
this.disposeWithMe(r.register(Dn, Xi));
|
|
1780
|
-
}
|
|
1781
|
-
_initMenus() {
|
|
1782
|
-
this._menuManagerService.mergeMenu(Zi);
|
|
1783
|
-
}
|
|
1784
|
-
_initCommands() {
|
|
1785
|
-
[
|
|
1786
|
-
pn,
|
|
1787
|
-
yt,
|
|
1788
|
-
wn,
|
|
1789
|
-
vn,
|
|
1790
|
-
In,
|
|
1791
|
-
qe,
|
|
1792
|
-
_n,
|
|
1793
|
-
Sn,
|
|
1794
|
-
Mt,
|
|
1795
|
-
On,
|
|
1796
|
-
Gi,
|
|
1797
|
-
Tn,
|
|
1798
|
-
un,
|
|
1799
|
-
fn,
|
|
1800
|
-
Ke,
|
|
1801
|
-
ln,
|
|
1802
|
-
hn
|
|
1803
|
-
].forEach((r) => this.disposeWithMe(this._commandService.registerCommand(r)));
|
|
1804
|
-
}
|
|
1805
|
-
_initShortcuts() {
|
|
1806
|
-
[
|
|
1807
|
-
// sheet drawing shortcuts
|
|
1808
|
-
Qi,
|
|
1809
|
-
Ji,
|
|
1810
|
-
er,
|
|
1811
|
-
tr,
|
|
1812
|
-
nr
|
|
1813
|
-
].forEach((r) => {
|
|
1814
|
-
this.disposeWithMe(this._shortcutService.registerShortcut(r));
|
|
1815
|
-
});
|
|
1816
|
-
}
|
|
1817
|
-
_init() {
|
|
1818
|
-
this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
|
|
1819
|
-
}
|
|
1820
|
-
};
|
|
1821
|
-
st = rr([
|
|
1822
|
-
et(0, Z(cn)),
|
|
1823
|
-
et(1, Oi),
|
|
1824
|
-
et(2, V),
|
|
1825
|
-
et(3, Ti)
|
|
1826
|
-
], st);
|
|
1827
|
-
var sr = Object.getOwnPropertyDescriptor, or = (r, e, t, n) => {
|
|
1828
|
-
for (var i = n > 1 ? void 0 : n ? sr(e, t) : e, s = r.length - 1, o; s >= 0; s--)
|
|
1829
|
-
(o = r[s]) && (i = o(i) || i);
|
|
1830
|
-
return i;
|
|
1831
|
-
}, He = (r, e) => (t, n) => e(t, n, r);
|
|
1832
|
-
function ar(r) {
|
|
1833
|
-
var n, i, s, o;
|
|
1834
|
-
if ($.isNoop(r) || !Array.isArray(r))
|
|
1835
|
-
return null;
|
|
1836
|
-
const e = r.find((c) => Array.isArray(c) && (c == null ? void 0 : c[0]) === "drawings");
|
|
1837
|
-
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")
|
|
1838
|
-
return null;
|
|
1839
|
-
const t = [];
|
|
1840
|
-
if (Array.isArray(e == null ? void 0 : e[1]))
|
|
1841
|
-
for (const c of e)
|
|
1842
|
-
Array.isArray(c) && t.push({
|
|
1843
|
-
type: (n = c == null ? void 0 : c[1]) != null && n.i ? "add" : "remove",
|
|
1844
|
-
drawingId: c == null ? void 0 : c[0],
|
|
1845
|
-
drawing: (i = c == null ? void 0 : c[1]) == null ? void 0 : i.i
|
|
1846
|
-
});
|
|
1847
|
-
else
|
|
1848
|
-
t.push({
|
|
1849
|
-
type: (s = e[2]) != null && s.i ? "add" : "remove",
|
|
1850
|
-
drawingId: e[1],
|
|
1851
|
-
drawing: (o = e[2]) == null ? void 0 : o.i
|
|
1852
|
-
});
|
|
1853
|
-
return t;
|
|
1854
|
-
}
|
|
1855
|
-
function cr(r) {
|
|
1856
|
-
if (!Array.isArray(r) || r.length < 3 || r[0] !== "drawingsOrder")
|
|
1857
|
-
return [];
|
|
1858
|
-
const e = [];
|
|
1859
|
-
for (let t = 1; t < r.length; t++) {
|
|
1860
|
-
const n = r[t];
|
|
1861
|
-
if (Array.isArray(n) && typeof n[0] == "number" && typeof n[1] == "object")
|
|
1862
|
-
e.push(n[0]);
|
|
1863
|
-
else {
|
|
1864
|
-
e.length = 0;
|
|
1865
|
-
break;
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
|
-
return e;
|
|
1869
|
-
}
|
|
1870
|
-
let ot = class extends xe {
|
|
1871
|
-
constructor(r, e, t, n, i) {
|
|
1872
|
-
super(), this._univerInstanceService = r, this._commandService = e, this._drawingManagerService = t, this._docDrawingService = n, this._renderManagerService = i, this._initialize();
|
|
1873
|
-
}
|
|
1874
|
-
_initialize() {
|
|
1875
|
-
this._commandExecutedListener();
|
|
1876
|
-
}
|
|
1877
|
-
_commandExecutedListener() {
|
|
1878
|
-
this.disposeWithMe(
|
|
1879
|
-
this._commandService.beforeCommandExecuted((r) => {
|
|
1880
|
-
if (r.id !== ee.id)
|
|
1881
|
-
return;
|
|
1882
|
-
const e = r.params, { unitId: t, actions: n } = e, i = ar(n);
|
|
1883
|
-
if (i != null)
|
|
1884
|
-
for (const { type: s, drawingId: o, drawing: c } of i)
|
|
1885
|
-
s === "add" ? this._addDrawings(t, [c]) : this._removeDrawings(t, [o]);
|
|
1886
|
-
})
|
|
1887
|
-
), this.disposeWithMe(
|
|
1888
|
-
this._commandService.onCommandExecuted((r) => {
|
|
1889
|
-
if (r.id !== ee.id)
|
|
1890
|
-
return;
|
|
1891
|
-
const e = r.params, { unitId: t, actions: n } = e;
|
|
1892
|
-
cr(n).length > 0 && this._updateDrawingsOrder(t);
|
|
1893
|
-
})
|
|
1894
|
-
), this.disposeWithMe(
|
|
1895
|
-
this._commandService.onCommandExecuted((r) => {
|
|
1896
|
-
var o;
|
|
1897
|
-
if (r.id !== kn.id && r.id !== Wn.id)
|
|
1898
|
-
return;
|
|
1899
|
-
const e = (o = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : o.getUnitId(), t = this._drawingManagerService.getFocusDrawings();
|
|
1900
|
-
if (e == null || t.length === 0)
|
|
1901
|
-
return;
|
|
1902
|
-
const n = this._renderManagerService.getRenderById(e), i = n == null ? void 0 : n.scene;
|
|
1903
|
-
if (i == null)
|
|
1904
|
-
return !1;
|
|
1905
|
-
i.getTransformerByCreate().refreshControls();
|
|
1906
|
-
})
|
|
1907
|
-
);
|
|
1908
|
-
}
|
|
1909
|
-
_addDrawings(r, e) {
|
|
1910
|
-
const t = this._drawingManagerService, n = this._docDrawingService, i = this._docDrawingService.getBatchAddOp(e), { subUnitId: s, redo: o, objects: c } = i;
|
|
1911
|
-
t.applyJson1(r, s, o), n.applyJson1(r, s, o), t.addNotification(c), n.addNotification(c);
|
|
1912
|
-
}
|
|
1913
|
-
_removeDrawings(r, e) {
|
|
1914
|
-
const t = this._drawingManagerService, n = this._docDrawingService, i = this._docDrawingService.getBatchRemoveOp(e.map((d) => ({
|
|
1915
|
-
unitId: r,
|
|
1916
|
-
subUnitId: r,
|
|
1917
|
-
drawingId: d
|
|
1918
|
-
}))), { subUnitId: s, redo: o, objects: c } = i;
|
|
1919
|
-
t.applyJson1(r, s, o), n.applyJson1(r, s, o), t.removeNotification(c), n.removeNotification(c);
|
|
1920
|
-
}
|
|
1921
|
-
_updateDrawingsOrder(r) {
|
|
1922
|
-
const e = this._univerInstanceService.getUniverDocInstance(r);
|
|
1923
|
-
if (e == null)
|
|
1924
|
-
return;
|
|
1925
|
-
const t = e.getSnapshot().drawingsOrder;
|
|
1926
|
-
if (t == null)
|
|
1927
|
-
return;
|
|
1928
|
-
const n = this._drawingManagerService, i = this._docDrawingService;
|
|
1929
|
-
n.setDrawingOrder(r, r, t), i.setDrawingOrder(r, r, t);
|
|
1930
|
-
const s = {
|
|
1931
|
-
unitId: r,
|
|
1932
|
-
subUnitId: r,
|
|
1933
|
-
drawingIds: t
|
|
1233
|
+
_removeDrawings(r, e) {
|
|
1234
|
+
const t = this._drawingManagerService, n = this._docDrawingService, i = this._docDrawingService.getBatchRemoveOp(e.map((d) => ({
|
|
1235
|
+
unitId: r,
|
|
1236
|
+
subUnitId: r,
|
|
1237
|
+
drawingId: d
|
|
1238
|
+
}))), { subUnitId: s, redo: o, objects: c } = i;
|
|
1239
|
+
t.applyJson1(r, s, o), n.applyJson1(r, s, o), t.removeNotification(c), n.removeNotification(c);
|
|
1240
|
+
}
|
|
1241
|
+
_updateDrawingsOrder(r) {
|
|
1242
|
+
const e = this._univerInstanceService.getUniverDocInstance(r);
|
|
1243
|
+
if (e == null)
|
|
1244
|
+
return;
|
|
1245
|
+
const t = e.getSnapshot().drawingsOrder;
|
|
1246
|
+
if (t == null)
|
|
1247
|
+
return;
|
|
1248
|
+
const n = this._drawingManagerService, i = this._docDrawingService;
|
|
1249
|
+
n.setDrawingOrder(r, r, t), i.setDrawingOrder(r, r, t);
|
|
1250
|
+
const s = {
|
|
1251
|
+
unitId: r,
|
|
1252
|
+
subUnitId: r,
|
|
1253
|
+
drawingIds: t
|
|
1934
1254
|
};
|
|
1935
1255
|
n.orderNotification(s), i.orderNotification(s);
|
|
1936
1256
|
}
|
|
1937
1257
|
};
|
|
1938
|
-
ot =
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1258
|
+
ot = Zi([
|
|
1259
|
+
Ve(0, z),
|
|
1260
|
+
Ve(1, j),
|
|
1261
|
+
Ve(2, fe),
|
|
1262
|
+
Ve(3, We),
|
|
1263
|
+
Ve(4, Q)
|
|
1944
1264
|
], ot);
|
|
1945
|
-
const
|
|
1265
|
+
const er = (r) => {
|
|
1946
1266
|
const { floatDomInfos: e, scene: t, offset: n, bound: i } = r, s = i.right - i.left, o = i.bottom - i.top, c = Bi(() => e.map((d) => {
|
|
1947
|
-
const { width: a = 0, height: g = 0, left: u = 0, top: l = 0 } = d.transform, h =
|
|
1267
|
+
const { width: a = 0, height: g = 0, left: u = 0, top: l = 0 } = d.transform, h = yn(
|
|
1948
1268
|
{
|
|
1949
1269
|
left: u,
|
|
1950
1270
|
right: u + a,
|
|
@@ -1953,7 +1273,7 @@ const dr = (r) => {
|
|
|
1953
1273
|
},
|
|
1954
1274
|
t
|
|
1955
1275
|
), m = {
|
|
1956
|
-
position$: new
|
|
1276
|
+
position$: new Tt(h),
|
|
1957
1277
|
position: h,
|
|
1958
1278
|
id: d.drawingId,
|
|
1959
1279
|
componentKey: d.componentKey,
|
|
@@ -1970,13 +1290,13 @@ const dr = (r) => {
|
|
|
1970
1290
|
};
|
|
1971
1291
|
return [d.drawingId, m];
|
|
1972
1292
|
}).filter(([d, a]) => !(a.position.endX < 0 || a.position.endY < 0 || a.position.startX > s || a.position.startY > o)), [e, t, n, s, o]);
|
|
1973
|
-
return /* @__PURE__ */
|
|
1293
|
+
return /* @__PURE__ */ y("div", { className: "univer-absolute univer-left-0 univer-top-0", children: c.map(([d, a]) => /* @__PURE__ */ y(Di, { layer: a, id: d, position: a.position }, d)) });
|
|
1974
1294
|
};
|
|
1975
|
-
var
|
|
1976
|
-
for (var i = n > 1 ? void 0 : n ?
|
|
1295
|
+
var tr = Object.getOwnPropertyDescriptor, nr = (r, e, t, n) => {
|
|
1296
|
+
for (var i = n > 1 ? void 0 : n ? tr(e, t) : e, s = r.length - 1, o; s >= 0; s--)
|
|
1977
1297
|
(o = r[s]) && (i = o(i) || i);
|
|
1978
1298
|
return i;
|
|
1979
|
-
},
|
|
1299
|
+
}, je = (r, e) => (t, n) => e(t, n, r);
|
|
1980
1300
|
let at = class extends xe {
|
|
1981
1301
|
constructor(r, e, t, n, i) {
|
|
1982
1302
|
super(), this._docPrintInterceptorService = r, this._drawingRenderService = e, this._drawingManagerService = t, this._componetManager = n, this._injector = i, this._initPrinting(), this._initPrintingDom();
|
|
@@ -2010,7 +1330,7 @@ let at = class extends xe {
|
|
|
2010
1330
|
if (a.drawingType === Pe.DRAWING_CHART)
|
|
2011
1331
|
return {
|
|
2012
1332
|
...a,
|
|
2013
|
-
componentKey: this._componetManager.get(
|
|
1333
|
+
componentKey: this._componetManager.get(kn)
|
|
2014
1334
|
};
|
|
2015
1335
|
if (a.drawingType === Pe.DRAWING_DOM) {
|
|
2016
1336
|
const g = this._docPrintInterceptorService.getPrintComponent(a.componentKey);
|
|
@@ -2020,9 +1340,9 @@ let at = class extends xe {
|
|
|
2020
1340
|
};
|
|
2021
1341
|
}
|
|
2022
1342
|
return null;
|
|
2023
|
-
}).filter(Boolean), c =
|
|
2024
|
-
return
|
|
2025
|
-
/* @__PURE__ */
|
|
1343
|
+
}).filter(Boolean), c = Oi(er, this._injector);
|
|
1344
|
+
return di(
|
|
1345
|
+
/* @__PURE__ */ y(
|
|
2026
1346
|
c,
|
|
2027
1347
|
{
|
|
2028
1348
|
unitId: n,
|
|
@@ -2035,7 +1355,7 @@ let at = class extends xe {
|
|
|
2035
1355
|
),
|
|
2036
1356
|
e.root
|
|
2037
1357
|
), r == null || r.add(() => {
|
|
2038
|
-
|
|
1358
|
+
gi(e.root);
|
|
2039
1359
|
}), t(r);
|
|
2040
1360
|
}
|
|
2041
1361
|
}
|
|
@@ -2044,20 +1364,20 @@ let at = class extends xe {
|
|
|
2044
1364
|
);
|
|
2045
1365
|
}
|
|
2046
1366
|
};
|
|
2047
|
-
at =
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
1367
|
+
at = nr([
|
|
1368
|
+
je(0, Z(Qn)),
|
|
1369
|
+
je(1, Z(gn)),
|
|
1370
|
+
je(2, fe),
|
|
1371
|
+
je(3, Z(cn)),
|
|
1372
|
+
je(4, Z(Jt))
|
|
2053
1373
|
], at);
|
|
2054
|
-
var
|
|
2055
|
-
for (var i = n > 1 ? void 0 : n ?
|
|
1374
|
+
var ir = Object.getOwnPropertyDescriptor, rr = (r, e, t, n) => {
|
|
1375
|
+
for (var i = n > 1 ? void 0 : n ? ir(e, t) : e, s = r.length - 1, o; s >= 0; s--)
|
|
2056
1376
|
(o = r[s]) && (i = o(i) || i);
|
|
2057
1377
|
return i;
|
|
2058
|
-
},
|
|
2059
|
-
const
|
|
2060
|
-
function
|
|
1378
|
+
}, Je = (r, e) => (t, n) => e(t, n, r);
|
|
1379
|
+
const sr = "__InlineDrawingAnchor__";
|
|
1380
|
+
function Xt(r) {
|
|
2061
1381
|
const { path: e } = r;
|
|
2062
1382
|
return e.some((t) => t === "cells");
|
|
2063
1383
|
}
|
|
@@ -2093,7 +1413,7 @@ let ct = class extends xe {
|
|
|
2093
1413
|
if (t == null)
|
|
2094
1414
|
return;
|
|
2095
1415
|
this.disposeWithMe(
|
|
2096
|
-
|
|
1416
|
+
Xe(
|
|
2097
1417
|
t.changeStart$.subscribe((s) => {
|
|
2098
1418
|
var c;
|
|
2099
1419
|
this._transformerCache.clear();
|
|
@@ -2102,14 +1422,14 @@ let ct = class extends xe {
|
|
|
2102
1422
|
const { oKey: a, width: g, height: u, left: l, top: f, angle: h } = d, m = this._drawingManagerService.getDrawingOKey(a);
|
|
2103
1423
|
if (m == null)
|
|
2104
1424
|
continue;
|
|
2105
|
-
const p = this._univerInstanceService.getUniverDocInstance(m.unitId),
|
|
2106
|
-
if ((
|
|
1425
|
+
const p = this._univerInstanceService.getUniverDocInstance(m.unitId), v = (c = p == null ? void 0 : p.getSnapshot().drawings) == null ? void 0 : c[m.drawingId];
|
|
1426
|
+
if ((v == null ? void 0 : v.layoutType) === k.INLINE)
|
|
2107
1427
|
try {
|
|
2108
1428
|
d.setOpacity(0.2);
|
|
2109
1429
|
} catch {
|
|
2110
1430
|
}
|
|
2111
|
-
|
|
2112
|
-
drawing:
|
|
1431
|
+
v != null && this._transformerCache.set(m.drawingId, {
|
|
1432
|
+
drawing: v,
|
|
2113
1433
|
top: f,
|
|
2114
1434
|
left: l,
|
|
2115
1435
|
width: g,
|
|
@@ -2120,9 +1440,9 @@ let ct = class extends xe {
|
|
|
2120
1440
|
})
|
|
2121
1441
|
)
|
|
2122
1442
|
);
|
|
2123
|
-
const n =
|
|
2124
|
-
|
|
2125
|
-
|
|
1443
|
+
const n = Rt(this._updateMultipleDrawingDocTransform.bind(this), 50);
|
|
1444
|
+
Rt(this._nonInlineDrawingTransform.bind(this), 50), this.disposeWithMe(
|
|
1445
|
+
Xe(
|
|
2126
1446
|
t.changing$.subscribe((s) => {
|
|
2127
1447
|
const { objects: o, offsetX: c, offsetY: d } = s;
|
|
2128
1448
|
if (o.size > 1)
|
|
@@ -2136,7 +1456,7 @@ let ct = class extends xe {
|
|
|
2136
1456
|
})
|
|
2137
1457
|
)
|
|
2138
1458
|
), this.disposeWithMe(
|
|
2139
|
-
|
|
1459
|
+
Xe(
|
|
2140
1460
|
// eslint-disable-next-line complexity
|
|
2141
1461
|
t.changeEnd$.subscribe((s) => {
|
|
2142
1462
|
const { objects: o, offsetX: c, offsetY: d } = s;
|
|
@@ -2180,8 +1500,8 @@ let ct = class extends xe {
|
|
|
2180
1500
|
const f = this._transformerCache.get(l.drawingId);
|
|
2181
1501
|
if (f == null)
|
|
2182
1502
|
continue;
|
|
2183
|
-
const { drawing: h, top: m, left: p, width:
|
|
2184
|
-
if (g = Math.min(g, O), u = Math.min(u, C), (
|
|
1503
|
+
const { drawing: h, top: m, left: p, width: v, height: D, angle: S } = f, { width: O, height: C } = this._getPageContentSize(h);
|
|
1504
|
+
if (g = Math.min(g, O), u = Math.min(u, C), (v !== g || D !== u) && t.push({
|
|
2185
1505
|
drawingId: l.drawingId,
|
|
2186
1506
|
key: "size",
|
|
2187
1507
|
value: {
|
|
@@ -2193,13 +1513,13 @@ let ct = class extends xe {
|
|
|
2193
1513
|
key: "angle",
|
|
2194
1514
|
value: a
|
|
2195
1515
|
}), m !== d || p !== c) {
|
|
2196
|
-
const
|
|
2197
|
-
|
|
1516
|
+
const M = d - m, A = c - p;
|
|
1517
|
+
M !== 0 && t.push({
|
|
2198
1518
|
drawingId: l.drawingId,
|
|
2199
1519
|
key: "positionV",
|
|
2200
1520
|
value: {
|
|
2201
1521
|
relativeFrom: h.docTransform.positionV.relativeFrom,
|
|
2202
|
-
posOffset: h.docTransform.positionV.posOffset +
|
|
1522
|
+
posOffset: h.docTransform.positionV.posOffset + M
|
|
2203
1523
|
}
|
|
2204
1524
|
}), A !== 0 && t.push({
|
|
2205
1525
|
drawingId: l.drawingId,
|
|
@@ -2211,7 +1531,7 @@ let ct = class extends xe {
|
|
|
2211
1531
|
});
|
|
2212
1532
|
}
|
|
2213
1533
|
}
|
|
2214
|
-
t.length > 0 && n && i && this._commandService.executeCommand(
|
|
1534
|
+
t.length > 0 && n && i && this._commandService.executeCommand(Ke.id, {
|
|
2215
1535
|
unitId: n,
|
|
2216
1536
|
subUnitId: i,
|
|
2217
1537
|
drawings: t
|
|
@@ -2232,20 +1552,20 @@ let ct = class extends xe {
|
|
|
2232
1552
|
i != null && this._createOrUpdateInlineAnchor(e.unitId, i);
|
|
2233
1553
|
}
|
|
2234
1554
|
_getInlineDrawingAnchor(e, t, n) {
|
|
2235
|
-
var x,
|
|
1555
|
+
var x, G;
|
|
2236
1556
|
const i = this._renderManagerService.getRenderById(e.unitId), s = i == null ? void 0 : i.with(te).getSkeleton();
|
|
2237
1557
|
if (i == null)
|
|
2238
1558
|
return;
|
|
2239
1559
|
const { mainComponent: o, scene: c } = i, d = o, a = c.getViewports()[0], {
|
|
2240
|
-
pageLayoutType: g =
|
|
1560
|
+
pageLayoutType: g = Lt.VERTICAL,
|
|
2241
1561
|
pageMarginLeft: u,
|
|
2242
1562
|
pageMarginTop: l
|
|
2243
1563
|
} = d.getOffsetConfig();
|
|
2244
1564
|
let f = null, h = !1, m = -1, p = "";
|
|
2245
|
-
const
|
|
1565
|
+
const v = 0.5, D = this._getTransformCoordForDocumentOffset(d, a, t, n);
|
|
2246
1566
|
if (D == null)
|
|
2247
1567
|
return;
|
|
2248
|
-
const S = (x = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : x.with(
|
|
1568
|
+
const S = (x = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : x.with(ye);
|
|
2249
1569
|
if (S == null)
|
|
2250
1570
|
return;
|
|
2251
1571
|
const O = s == null ? void 0 : s.findNodeByCoord(D, g, u, l, {
|
|
@@ -2255,19 +1575,19 @@ let ct = class extends xe {
|
|
|
2255
1575
|
});
|
|
2256
1576
|
if (O) {
|
|
2257
1577
|
const { node: I, ratioX: _, segmentPage: E, segmentId: T } = O;
|
|
2258
|
-
h = _ <
|
|
1578
|
+
h = _ < v, f = I, m = E, p = T;
|
|
2259
1579
|
}
|
|
2260
1580
|
if (f == null)
|
|
2261
1581
|
return;
|
|
2262
|
-
const C = s == null ? void 0 : s.findPositionByGlyph(f, m),
|
|
2263
|
-
if (C == null || s == null ||
|
|
1582
|
+
const C = s == null ? void 0 : s.findPositionByGlyph(f, m), M = this._getDocObject();
|
|
1583
|
+
if (C == null || s == null || M == null || Xt(C))
|
|
2264
1584
|
return;
|
|
2265
1585
|
const A = {
|
|
2266
1586
|
...C,
|
|
2267
1587
|
isBack: h
|
|
2268
|
-
},
|
|
2269
|
-
if (
|
|
2270
|
-
return { offset:
|
|
1588
|
+
}, U = M.document.getOffsetConfig(), R = new Pt(U, s), { cursorList: w, contentBoxPointGroup: N } = R.getRangePointData(A, A), { startOffset: H } = (G = xt(w)) != null ? G : {};
|
|
1589
|
+
if (H != null)
|
|
1590
|
+
return { offset: H, contentBoxPointGroup: N, segmentId: p, segmentPage: m };
|
|
2271
1591
|
}
|
|
2272
1592
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
2273
1593
|
_getDrawingAnchor(e, t) {
|
|
@@ -2275,61 +1595,61 @@ let ct = class extends xe {
|
|
|
2275
1595
|
const n = this._renderManagerService.getRenderById(e.unitId), i = n == null ? void 0 : n.with(te).getSkeleton(), s = i == null ? void 0 : i.getSkeletonData();
|
|
2276
1596
|
if (s == null || n == null)
|
|
2277
1597
|
return;
|
|
2278
|
-
const { pages: o, skeHeaders: c, skeFooters: d } = s, { mainComponent: a, scene: g } = n, u = a, l = g.getViewports()[0], { pageLayoutType: f =
|
|
2279
|
-
let { width: C, height:
|
|
2280
|
-
const { positionV: A, positionH:
|
|
2281
|
-
C = Math.min(C, R),
|
|
2282
|
-
let N = null,
|
|
2283
|
-
const
|
|
1598
|
+
const { pages: o, skeHeaders: c, skeFooters: d } = s, { mainComponent: a, scene: g } = n, u = a, l = g.getViewports()[0], { pageLayoutType: f = Lt.VERTICAL, pageMarginLeft: h, pageMarginTop: m, docsLeft: p, docsTop: v } = u.getOffsetConfig(), { left: D, top: S, angle: O } = t;
|
|
1599
|
+
let { width: C, height: M } = t;
|
|
1600
|
+
const { positionV: A, positionH: U } = e.docTransform, { width: R, height: w } = this._getPageContentSize(e);
|
|
1601
|
+
C = Math.min(C, R), M = Math.min(M, w);
|
|
1602
|
+
let N = null, H = "", x = -1;
|
|
1603
|
+
const G = !1, I = {
|
|
2284
1604
|
...e.docTransform,
|
|
2285
1605
|
size: {
|
|
2286
1606
|
width: C,
|
|
2287
|
-
height:
|
|
1607
|
+
height: M
|
|
2288
1608
|
},
|
|
2289
1609
|
angle: O
|
|
2290
1610
|
}, { x: _, y: E } = g.getViewportScrollXY(l), T = this._getTransformCoordForDocumentOffset(u, l, D - _, S - E);
|
|
2291
1611
|
if (T == null)
|
|
2292
1612
|
return;
|
|
2293
|
-
const
|
|
2294
|
-
if (
|
|
1613
|
+
const L = (Ie = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : Ie.with(ye);
|
|
1614
|
+
if (L == null)
|
|
2295
1615
|
return;
|
|
2296
1616
|
const B = i == null ? void 0 : i.findNodeByCoord(T, f, h, m, {
|
|
2297
1617
|
strict: !1,
|
|
2298
|
-
segmentId:
|
|
2299
|
-
segmentPage:
|
|
1618
|
+
segmentId: L.getSegment(),
|
|
1619
|
+
segmentPage: L.getSegmentPage()
|
|
2300
1620
|
});
|
|
2301
1621
|
if (B) {
|
|
2302
|
-
const { node: pe, segmentPage:
|
|
2303
|
-
N = pe, x =
|
|
1622
|
+
const { node: pe, segmentPage: ft, segmentId: pt } = B;
|
|
1623
|
+
N = pe, x = ft, H = pt;
|
|
2304
1624
|
}
|
|
2305
1625
|
if (N == null)
|
|
2306
1626
|
return;
|
|
2307
|
-
const b = (_e = N.parent) == null ? void 0 : _e.parent, P = b == null ? void 0 : b.parent,
|
|
2308
|
-
if (b == null || P == null ||
|
|
1627
|
+
const b = (_e = N.parent) == null ? void 0 : _e.parent, P = b == null ? void 0 : b.parent, V = (ce = P == null ? void 0 : P.lines.find((pe) => pe.paragraphIndex === (b == null ? void 0 : b.paragraphIndex) && pe.paragraphStart)) != null ? ce : P == null ? void 0 : P.lines[0], F = (Se = P == null ? void 0 : P.parent) == null ? void 0 : Se.parent;
|
|
1628
|
+
if (b == null || P == null || V == null || F == null)
|
|
2309
1629
|
return;
|
|
2310
1630
|
this._liquid.reset();
|
|
2311
1631
|
const K = F.type;
|
|
2312
1632
|
for (const pe of o) {
|
|
2313
|
-
const { headerId:
|
|
1633
|
+
const { headerId: ft, footerId: pt, pageHeight: En, pageWidth: Ct, marginLeft: Et, marginBottom: Rn } = pe, An = o.indexOf(pe);
|
|
2314
1634
|
if (x > -1 && An === x) {
|
|
2315
1635
|
switch (K) {
|
|
2316
1636
|
case Ut.HEADER: {
|
|
2317
|
-
const Ge = (De = c.get(
|
|
1637
|
+
const Ge = (De = c.get(ft)) == null ? void 0 : De.get(Ct);
|
|
2318
1638
|
if (Ge)
|
|
2319
1639
|
this._liquid.translatePagePadding({
|
|
2320
1640
|
marginTop: Ge.marginTop,
|
|
2321
|
-
marginLeft:
|
|
1641
|
+
marginLeft: Et
|
|
2322
1642
|
});
|
|
2323
1643
|
else
|
|
2324
1644
|
throw new Error("header skeleton not found");
|
|
2325
1645
|
break;
|
|
2326
1646
|
}
|
|
2327
1647
|
case Ut.FOOTER: {
|
|
2328
|
-
const Ge = (be = d.get(
|
|
1648
|
+
const Ge = (be = d.get(pt)) == null ? void 0 : be.get(Ct);
|
|
2329
1649
|
if (Ge)
|
|
2330
1650
|
this._liquid.translatePagePadding({
|
|
2331
1651
|
marginTop: En - Rn + Ge.marginTop,
|
|
2332
|
-
marginLeft:
|
|
1652
|
+
marginLeft: Et
|
|
2333
1653
|
});
|
|
2334
1654
|
else
|
|
2335
1655
|
throw new Error("footer skeleton not found");
|
|
@@ -2342,10 +1662,10 @@ let ct = class extends xe {
|
|
|
2342
1662
|
break;
|
|
2343
1663
|
this._liquid.restorePagePadding(pe), this._liquid.translatePage(pe, f, h, m);
|
|
2344
1664
|
}
|
|
2345
|
-
switch (A.relativeFrom === W.LINE ? N = b.divides[0].glyphGroup[0] : N = (ge = (de = (Oe = (Ce =
|
|
2346
|
-
relativeFrom:
|
|
1665
|
+
switch (A.relativeFrom === W.LINE ? N = b.divides[0].glyphGroup[0] : N = (ge = (de = (Oe = (Ce = V.divides) == null ? void 0 : Ce[0]) == null ? void 0 : Oe.glyphGroup) == null ? void 0 : de[0]) != null ? ge : N, I.positionH = {
|
|
1666
|
+
relativeFrom: U.relativeFrom,
|
|
2347
1667
|
posOffset: D - this._liquid.x - p
|
|
2348
|
-
},
|
|
1668
|
+
}, U.relativeFrom) {
|
|
2349
1669
|
case J.MARGIN: {
|
|
2350
1670
|
I.positionH.posOffset = D - this._liquid.x - p - F.marginLeft;
|
|
2351
1671
|
break;
|
|
@@ -2357,339 +1677,872 @@ let ct = class extends xe {
|
|
|
2357
1677
|
}
|
|
2358
1678
|
switch (I.positionV = {
|
|
2359
1679
|
relativeFrom: A.relativeFrom,
|
|
2360
|
-
posOffset: S - this._liquid.y -
|
|
1680
|
+
posOffset: S - this._liquid.y - v
|
|
2361
1681
|
}, A.relativeFrom) {
|
|
2362
1682
|
case W.PAGE: {
|
|
2363
|
-
I.positionV.posOffset = S - this._liquid.y -
|
|
1683
|
+
I.positionV.posOffset = S - this._liquid.y - v - F.marginTop;
|
|
1684
|
+
break;
|
|
1685
|
+
}
|
|
1686
|
+
case W.LINE: {
|
|
1687
|
+
I.positionV.posOffset = S - this._liquid.y - v - b.top;
|
|
1688
|
+
break;
|
|
1689
|
+
}
|
|
1690
|
+
case W.PARAGRAPH: {
|
|
1691
|
+
I.positionV.posOffset = S - this._liquid.y - v - V.top;
|
|
1692
|
+
break;
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
if (N == null)
|
|
1696
|
+
return;
|
|
1697
|
+
const oe = i == null ? void 0 : i.findPositionByGlyph(N, x), Ne = this._getDocObject();
|
|
1698
|
+
if (oe == null || i == null || Ne == null || Xt(oe))
|
|
1699
|
+
return;
|
|
1700
|
+
const Me = {
|
|
1701
|
+
...oe,
|
|
1702
|
+
isBack: G
|
|
1703
|
+
}, He = Ne.document.getOffsetConfig(), ae = new Pt(He, i), { cursorList: ne } = ae.getRangePointData(Me, Me), { startOffset: ie } = (Ee = xt(ne)) != null ? Ee : {};
|
|
1704
|
+
if (ie != null)
|
|
1705
|
+
return { offset: ie, docTransform: I, segmentId: H, segmentPage: x };
|
|
1706
|
+
}
|
|
1707
|
+
// Update drawing when use transformer to resize it.
|
|
1708
|
+
_updateDrawingSize(e, t) {
|
|
1709
|
+
const n = [], { drawing: i, width: s, height: o, angle: c } = e, { unitId: d, subUnitId: a } = i;
|
|
1710
|
+
let { width: g, height: u, angle: l } = t;
|
|
1711
|
+
const { width: f, height: h } = this._getPageContentSize(i);
|
|
1712
|
+
g = Math.min(f, g), u = Math.min(h, u), (g !== s || u !== o) && n.push({
|
|
1713
|
+
drawingId: i.drawingId,
|
|
1714
|
+
key: "size",
|
|
1715
|
+
value: {
|
|
1716
|
+
width: g,
|
|
1717
|
+
height: u
|
|
1718
|
+
}
|
|
1719
|
+
}), l !== c && n.push({
|
|
1720
|
+
drawingId: i.drawingId,
|
|
1721
|
+
key: "angle",
|
|
1722
|
+
value: l
|
|
1723
|
+
}), n.length > 0 && d && a && this._commandService.executeCommand(Ke.id, {
|
|
1724
|
+
unitId: d,
|
|
1725
|
+
subUnitId: a,
|
|
1726
|
+
drawings: n
|
|
1727
|
+
});
|
|
1728
|
+
}
|
|
1729
|
+
// Update inline drawing when use transformer to move it.
|
|
1730
|
+
_moveInlineDrawing(e, t, n) {
|
|
1731
|
+
const i = this._getInlineDrawingAnchor(e, t, n), { offset: s, segmentId: o, segmentPage: c } = i != null ? i : {};
|
|
1732
|
+
return this._commandService.executeCommand(_n.id, {
|
|
1733
|
+
unitId: e.unitId,
|
|
1734
|
+
subUnitId: e.unitId,
|
|
1735
|
+
drawing: e,
|
|
1736
|
+
offset: s,
|
|
1737
|
+
segmentId: o,
|
|
1738
|
+
segmentPage: c,
|
|
1739
|
+
needRefreshDrawings: s == null
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
// Limit the drawing to the page area, mainly in the vertical direction,
|
|
1743
|
+
// and the upper and lower limits cannot exceed the page margin area.
|
|
1744
|
+
_limitDrawingInPage(e, t) {
|
|
1745
|
+
const n = this._renderManagerService.getRenderById(e.unitId), { left: i, top: s, width: o, height: c, angle: d } = t, a = n == null ? void 0 : n.with(te).getSkeleton(), g = a == null ? void 0 : a.getSkeletonData(), { pages: u } = g != null ? g : {};
|
|
1746
|
+
if (g == null || n == null || u == null)
|
|
1747
|
+
return {
|
|
1748
|
+
left: i,
|
|
1749
|
+
top: s,
|
|
1750
|
+
width: o,
|
|
1751
|
+
height: c,
|
|
1752
|
+
angle: d
|
|
1753
|
+
};
|
|
1754
|
+
const { mainComponent: l } = n, f = l, { top: h, pageLayoutType: m, pageMarginLeft: p, pageMarginTop: v } = f;
|
|
1755
|
+
let D = s;
|
|
1756
|
+
this._liquid.reset();
|
|
1757
|
+
for (const S of u) {
|
|
1758
|
+
const { marginBottom: O, pageHeight: C } = S, M = u.indexOf(S), A = u[M + 1];
|
|
1759
|
+
if (A == null)
|
|
1760
|
+
continue;
|
|
1761
|
+
if (Ae.hasIntersectionBetweenTwoRanges(
|
|
1762
|
+
s,
|
|
1763
|
+
s + c,
|
|
1764
|
+
this._liquid.y + h + C - O,
|
|
1765
|
+
this._liquid.y + h + C + v + A.marginTop
|
|
1766
|
+
)) {
|
|
1767
|
+
const R = s + c / 2, w = this._liquid.y + h + C + v / 2;
|
|
1768
|
+
R < w ? D = Math.min(s, this._liquid.y + h + C - O - c) : D = Math.max(s, this._liquid.y + h + C + v + A.marginTop);
|
|
1769
|
+
}
|
|
1770
|
+
this._liquid.translatePage(S, m, p, v);
|
|
1771
|
+
}
|
|
1772
|
+
return {
|
|
1773
|
+
left: i,
|
|
1774
|
+
top: D,
|
|
1775
|
+
width: o,
|
|
1776
|
+
height: c,
|
|
1777
|
+
angle: d
|
|
1778
|
+
};
|
|
1779
|
+
}
|
|
1780
|
+
_nonInlineDrawingTransform(e, t, n = !1) {
|
|
1781
|
+
const i = e.isMultiTransform === se.TRUE ? t : this._limitDrawingInPage(e, t);
|
|
1782
|
+
if (n && i.top !== t.top)
|
|
1783
|
+
return;
|
|
1784
|
+
const s = this._getDrawingAnchor(e, i), { offset: o, docTransform: c, segmentId: d, segmentPage: a } = s != null ? s : {};
|
|
1785
|
+
return o == null || c == null ? this._updateMultipleDrawingDocTransform(/* @__PURE__ */ new Map([[e.drawingId, t]])) : this._commandService.executeCommand(Sn.id, {
|
|
1786
|
+
unitId: e.unitId,
|
|
1787
|
+
subUnitId: e.unitId,
|
|
1788
|
+
drawing: e,
|
|
1789
|
+
offset: o,
|
|
1790
|
+
docTransform: c,
|
|
1791
|
+
segmentId: d,
|
|
1792
|
+
segmentPage: a
|
|
1793
|
+
});
|
|
1794
|
+
}
|
|
1795
|
+
_getSceneAndTransformerByDrawingSearch(e) {
|
|
1796
|
+
if (e == null)
|
|
1797
|
+
return;
|
|
1798
|
+
const t = this._renderManagerService.getRenderById(e), n = t == null ? void 0 : t.scene;
|
|
1799
|
+
if (n == null)
|
|
1800
|
+
return;
|
|
1801
|
+
const i = n.getTransformerByCreate();
|
|
1802
|
+
return { scene: n, transformer: i };
|
|
1803
|
+
}
|
|
1804
|
+
_getTransformCoordForDocumentOffset(e, t, n, i) {
|
|
1805
|
+
const { documentTransform: s } = e.getOffsetConfig(), o = t.transformVector2SceneCoord(si.FromArray([n, i]));
|
|
1806
|
+
if (o)
|
|
1807
|
+
return s.clone().invert().applyPoint(o);
|
|
1808
|
+
}
|
|
1809
|
+
_createOrUpdateInlineAnchor(e, t) {
|
|
1810
|
+
const n = this._renderManagerService.getRenderById(e);
|
|
1811
|
+
if (n == null)
|
|
1812
|
+
return;
|
|
1813
|
+
const { mainComponent: i, scene: s } = n, o = i, {
|
|
1814
|
+
docsLeft: c,
|
|
1815
|
+
docsTop: d
|
|
1816
|
+
} = o.getOffsetConfig(), a = Jn(t), { left: g, top: u, height: l } = a, f = g + c, h = u + d;
|
|
1817
|
+
if (this._anchorShape) {
|
|
1818
|
+
this._anchorShape.transformByState({ left: f, top: h, height: l }), this._anchorShape.show();
|
|
1819
|
+
return;
|
|
1820
|
+
}
|
|
1821
|
+
const m = 6, p = new oi(sr + Qt(m), {
|
|
1822
|
+
left: f,
|
|
1823
|
+
top: h,
|
|
1824
|
+
height: l,
|
|
1825
|
+
strokeWidth: 2,
|
|
1826
|
+
stroke: ai(Wn.darkgray, 1),
|
|
1827
|
+
evented: !1
|
|
1828
|
+
});
|
|
1829
|
+
this._anchorShape = p, s.addObject(p, ei);
|
|
1830
|
+
}
|
|
1831
|
+
_getDocObject() {
|
|
1832
|
+
return ti(this._univerInstanceService, this._renderManagerService);
|
|
1833
|
+
}
|
|
1834
|
+
_getPageContentSize(e) {
|
|
1835
|
+
const t = this._renderManagerService.getRenderById(e.unitId), n = t == null ? void 0 : t.with(te).getSkeleton(), i = 500, s = 500, o = n == null ? void 0 : n.getSkeletonData();
|
|
1836
|
+
if (o == null || t == null)
|
|
1837
|
+
return {
|
|
1838
|
+
width: i,
|
|
1839
|
+
height: s
|
|
1840
|
+
};
|
|
1841
|
+
const { pages: c } = o;
|
|
1842
|
+
let d = null;
|
|
1843
|
+
for (const a of c) {
|
|
1844
|
+
const { skeDrawings: g } = a;
|
|
1845
|
+
if (g.has(e.drawingId)) {
|
|
1846
|
+
d = a;
|
|
1847
|
+
break;
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
if (d) {
|
|
1851
|
+
const { pageWidth: a, pageHeight: g, marginLeft: u, marginBottom: l, marginRight: f, marginTop: h } = d;
|
|
1852
|
+
return {
|
|
1853
|
+
width: Math.max(i, a - u - f),
|
|
1854
|
+
height: Math.max(s, g - h - l)
|
|
1855
|
+
};
|
|
1856
|
+
} else
|
|
1857
|
+
return {
|
|
1858
|
+
width: i,
|
|
1859
|
+
height: s
|
|
1860
|
+
};
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1863
|
+
ct = rr([
|
|
1864
|
+
Je(0, j),
|
|
1865
|
+
Je(1, z),
|
|
1866
|
+
Je(2, fe),
|
|
1867
|
+
Je(3, Q)
|
|
1868
|
+
], ct);
|
|
1869
|
+
const or = {
|
|
1870
|
+
[Ti.MEDIA]: {
|
|
1871
|
+
[Mn]: {
|
|
1872
|
+
order: 0,
|
|
1873
|
+
menuItemFactory: $i,
|
|
1874
|
+
[bn]: {
|
|
1875
|
+
order: 0,
|
|
1876
|
+
menuItemFactory: zi
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
}, qt = -1e3, Kt = 1e3, ar = (r) => {
|
|
1881
|
+
const e = ve(j), t = ve(lt), n = ve(fe), i = ve(Q), s = ve(z), { drawings: o } = r, c = o[0];
|
|
1882
|
+
if (c == null)
|
|
1883
|
+
return;
|
|
1884
|
+
const { unitId: d } = c, a = s.getUniverDocInstance(d), g = a == null ? void 0 : a.getSnapshot().documentStyle.documentFlavor, u = i.getRenderById(d), l = u == null ? void 0 : u.scene;
|
|
1885
|
+
if (l == null)
|
|
1886
|
+
return;
|
|
1887
|
+
const f = l.getTransformerByCreate(), h = [{
|
|
1888
|
+
label: t.t("image-position.column"),
|
|
1889
|
+
value: String(J.COLUMN)
|
|
1890
|
+
}, {
|
|
1891
|
+
label: t.t("image-position.page"),
|
|
1892
|
+
value: String(J.PAGE)
|
|
1893
|
+
}, {
|
|
1894
|
+
label: t.t("image-position.margin"),
|
|
1895
|
+
value: String(J.MARGIN)
|
|
1896
|
+
}], m = [{
|
|
1897
|
+
label: t.t("image-position.line"),
|
|
1898
|
+
value: String(W.LINE),
|
|
1899
|
+
disabled: g === mt.MODERN
|
|
1900
|
+
}, {
|
|
1901
|
+
label: t.t("image-position.page"),
|
|
1902
|
+
value: String(W.PAGE),
|
|
1903
|
+
disabled: g === mt.MODERN
|
|
1904
|
+
}, {
|
|
1905
|
+
label: t.t("image-position.margin"),
|
|
1906
|
+
value: String(W.MARGIN),
|
|
1907
|
+
disabled: g === mt.MODERN
|
|
1908
|
+
}, {
|
|
1909
|
+
label: t.t("image-position.paragraph"),
|
|
1910
|
+
value: String(W.PARAGRAPH)
|
|
1911
|
+
}], [p, v] = re(!0), [D, S] = re({
|
|
1912
|
+
relativeFrom: J.PAGE,
|
|
1913
|
+
posOffset: 0
|
|
1914
|
+
}), [O, C] = re({
|
|
1915
|
+
relativeFrom: W.PAGE,
|
|
1916
|
+
posOffset: 0
|
|
1917
|
+
}), [M, A] = re(!0), [U, R] = re(!0);
|
|
1918
|
+
function w(_, E) {
|
|
1919
|
+
var b;
|
|
1920
|
+
_ === "positionH" ? S(E) : C(E);
|
|
1921
|
+
const T = n.getFocusDrawings();
|
|
1922
|
+
if (T.length === 0)
|
|
1923
|
+
return;
|
|
1924
|
+
const L = T.map((P) => ({
|
|
1925
|
+
unitId: P.unitId,
|
|
1926
|
+
subUnitId: P.subUnitId,
|
|
1927
|
+
drawingId: P.drawingId
|
|
1928
|
+
}));
|
|
1929
|
+
e.executeCommand(Ke.id, {
|
|
1930
|
+
unitId: T[0].unitId,
|
|
1931
|
+
subUnitId: T[0].unitId,
|
|
1932
|
+
drawings: L.map((P) => ({
|
|
1933
|
+
drawingId: P.drawingId,
|
|
1934
|
+
key: _,
|
|
1935
|
+
value: E
|
|
1936
|
+
}))
|
|
1937
|
+
});
|
|
1938
|
+
const B = (b = i.getRenderById(d)) == null ? void 0 : b.with(ye);
|
|
1939
|
+
B && B.blur(), f.refreshControls();
|
|
1940
|
+
}
|
|
1941
|
+
function N(_) {
|
|
1942
|
+
var ie, Ie, _e;
|
|
1943
|
+
const E = D.relativeFrom, T = D.posOffset, L = Number(_);
|
|
1944
|
+
if (E === L)
|
|
1945
|
+
return;
|
|
1946
|
+
const B = n.getFocusDrawings();
|
|
1947
|
+
if (B.length === 0)
|
|
1948
|
+
return;
|
|
1949
|
+
const b = B[0].drawingId, P = B[0].unitId;
|
|
1950
|
+
let V = null, F = 0;
|
|
1951
|
+
const K = (ie = i.getRenderById(P)) == null ? void 0 : ie.with(te).getSkeleton(), oe = K == null ? void 0 : K.getSkeletonData();
|
|
1952
|
+
if (oe == null)
|
|
1953
|
+
return;
|
|
1954
|
+
const { pages: Ne, skeHeaders: Me, skeFooters: He } = oe;
|
|
1955
|
+
for (const ce of Ne) {
|
|
1956
|
+
const { marginLeft: Se, skeDrawings: De, headerId: be, footerId: Ce, pageWidth: Oe } = ce;
|
|
1957
|
+
if (De.has(b)) {
|
|
1958
|
+
V = De.get(b), F = Se;
|
|
2364
1959
|
break;
|
|
2365
1960
|
}
|
|
2366
|
-
|
|
2367
|
-
|
|
1961
|
+
const de = (Ie = Me.get(be)) == null ? void 0 : Ie.get(Oe);
|
|
1962
|
+
if (de != null && de.skeDrawings.has(b)) {
|
|
1963
|
+
V = de == null ? void 0 : de.skeDrawings.get(b), F = Se;
|
|
2368
1964
|
break;
|
|
2369
1965
|
}
|
|
2370
|
-
|
|
2371
|
-
|
|
1966
|
+
const ge = (_e = He.get(Ce)) == null ? void 0 : _e.get(Oe);
|
|
1967
|
+
if (ge != null && ge.skeDrawings.has(b)) {
|
|
1968
|
+
V = ge == null ? void 0 : ge.skeDrawings.get(b), F = Se;
|
|
2372
1969
|
break;
|
|
2373
1970
|
}
|
|
2374
1971
|
}
|
|
2375
|
-
if (
|
|
1972
|
+
if (V == null)
|
|
1973
|
+
return;
|
|
1974
|
+
let ae = 0;
|
|
1975
|
+
E === J.COLUMN ? ae -= V.columnLeft : E === J.MARGIN && (ae -= F), L === J.COLUMN ? ae += V.columnLeft : L === J.MARGIN ? ae += F : J.PAGE;
|
|
1976
|
+
const ne = {
|
|
1977
|
+
relativeFrom: L,
|
|
1978
|
+
posOffset: (T != null ? T : 0) - ae
|
|
1979
|
+
};
|
|
1980
|
+
w("positionH", ne);
|
|
1981
|
+
}
|
|
1982
|
+
function H(_) {
|
|
1983
|
+
var De, be, Ce, Oe, de, ge;
|
|
1984
|
+
const E = O.relativeFrom, T = O.posOffset, L = Number(_);
|
|
1985
|
+
if (E === L)
|
|
1986
|
+
return;
|
|
1987
|
+
const B = n.getFocusDrawings();
|
|
1988
|
+
if (B.length === 0)
|
|
2376
1989
|
return;
|
|
2377
|
-
const
|
|
2378
|
-
if (
|
|
1990
|
+
const { drawingId: b, unitId: P } = B[0], V = s.getUniverDocInstance(P), F = (De = i.getRenderById(P)) == null ? void 0 : De.with(te).getSkeleton(), K = (be = i.getRenderById(P)) == null ? void 0 : be.with(ye), oe = K == null ? void 0 : K.getSegment(), Ne = K == null ? void 0 : K.getSegmentPage(), Me = (Oe = (Ce = V == null ? void 0 : V.getSelfOrHeaderFooterModel(oe).getBody()) == null ? void 0 : Ce.customBlocks) == null ? void 0 : Oe.find((Ee) => Ee.blockId === b);
|
|
1991
|
+
if (Me == null || F == null || K == null)
|
|
2379
1992
|
return;
|
|
2380
|
-
const
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
1993
|
+
const { startIndex: He } = Me, ae = F.findNodeByCharIndex(He, oe, Ne), ne = (de = ae == null ? void 0 : ae.parent) == null ? void 0 : de.parent, ie = ne == null ? void 0 : ne.parent, Ie = ie == null ? void 0 : ie.lines.find((Ee) => Ee.paragraphIndex === (ne == null ? void 0 : ne.paragraphIndex) && Ee.paragraphStart), _e = (ge = ie == null ? void 0 : ie.parent) == null ? void 0 : ge.parent;
|
|
1994
|
+
if (ae == null || ne == null || Ie == null || ie == null || _e == null)
|
|
1995
|
+
return;
|
|
1996
|
+
let ce = 0;
|
|
1997
|
+
E === W.PARAGRAPH ? ce -= Ie.top : E === W.LINE ? ce -= ne.top : E === W.PAGE && (ce += _e.marginTop), L === W.PARAGRAPH ? ce += Ie.top : L === W.LINE ? ce += ne.top : L === W.PAGE && (ce -= _e.marginTop);
|
|
1998
|
+
const Se = {
|
|
1999
|
+
relativeFrom: L,
|
|
2000
|
+
posOffset: (T != null ? T : 0) - ce
|
|
2001
|
+
};
|
|
2002
|
+
w("positionV", Se);
|
|
2386
2003
|
}
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
const
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
height: u
|
|
2398
|
-
}
|
|
2399
|
-
}), l !== c && n.push({
|
|
2400
|
-
drawingId: i.drawingId,
|
|
2401
|
-
key: "angle",
|
|
2402
|
-
value: l
|
|
2403
|
-
}), n.length > 0 && d && a && this._commandService.executeCommand(qe.id, {
|
|
2404
|
-
unitId: d,
|
|
2405
|
-
subUnitId: a,
|
|
2406
|
-
drawings: n
|
|
2407
|
-
});
|
|
2004
|
+
function x(_) {
|
|
2005
|
+
var P;
|
|
2006
|
+
const E = a == null ? void 0 : a.getSnapshot(), T = (P = E == null ? void 0 : E.drawings) == null ? void 0 : P[_.drawingId];
|
|
2007
|
+
if (T == null)
|
|
2008
|
+
return;
|
|
2009
|
+
const { layoutType: L } = T, {
|
|
2010
|
+
positionH: B,
|
|
2011
|
+
positionV: b
|
|
2012
|
+
} = T.docTransform;
|
|
2013
|
+
S(B), C(b), v(L === k.INLINE), A(b.relativeFrom === W.PARAGRAPH || b.relativeFrom === W.LINE);
|
|
2408
2014
|
}
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
return this._commandService.executeCommand(_n.id, {
|
|
2413
|
-
unitId: e.unitId,
|
|
2414
|
-
subUnitId: e.unitId,
|
|
2415
|
-
drawing: e,
|
|
2416
|
-
offset: s,
|
|
2417
|
-
segmentId: o,
|
|
2418
|
-
segmentPage: c,
|
|
2419
|
-
needRefreshDrawings: s == null
|
|
2420
|
-
});
|
|
2015
|
+
function G() {
|
|
2016
|
+
const _ = n.getFocusDrawings();
|
|
2017
|
+
_.length !== 0 && x(_[0]);
|
|
2421
2018
|
}
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
height: c,
|
|
2432
|
-
angle: d
|
|
2433
|
-
};
|
|
2434
|
-
const { mainComponent: l } = n, f = l, { top: h, pageLayoutType: m, pageMarginLeft: p, pageMarginTop: w } = f;
|
|
2435
|
-
let D = s;
|
|
2436
|
-
this._liquid.reset();
|
|
2437
|
-
for (const S of u) {
|
|
2438
|
-
const { marginBottom: O, pageHeight: C } = S, y = u.indexOf(S), A = u[y + 1];
|
|
2439
|
-
if (A == null)
|
|
2440
|
-
continue;
|
|
2441
|
-
if (Ae.hasIntersectionBetweenTwoRanges(
|
|
2442
|
-
s,
|
|
2443
|
-
s + c,
|
|
2444
|
-
this._liquid.y + h + C - O,
|
|
2445
|
-
this._liquid.y + h + C + w + A.marginTop
|
|
2446
|
-
)) {
|
|
2447
|
-
const R = s + c / 2, v = this._liquid.y + h + C + w / 2;
|
|
2448
|
-
R < v ? D = Math.min(s, this._liquid.y + h + C - O - c) : D = Math.max(s, this._liquid.y + h + C + w + A.marginTop);
|
|
2019
|
+
function I(_) {
|
|
2020
|
+
A(_), H(String(_ ? W.PARAGRAPH : W.PAGE));
|
|
2021
|
+
}
|
|
2022
|
+
return yt(() => {
|
|
2023
|
+
G();
|
|
2024
|
+
const _ = n.focus$.subscribe((T) => {
|
|
2025
|
+
if (T.length === 0) {
|
|
2026
|
+
R(!1);
|
|
2027
|
+
return;
|
|
2449
2028
|
}
|
|
2450
|
-
|
|
2451
|
-
}
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
height: c,
|
|
2457
|
-
angle: d
|
|
2029
|
+
R(!0), x(T[0]);
|
|
2030
|
+
}), E = e.onCommandExecuted(async (T) => {
|
|
2031
|
+
T.id === ee.id && G();
|
|
2032
|
+
});
|
|
2033
|
+
return () => {
|
|
2034
|
+
_.unsubscribe(), E.dispose();
|
|
2458
2035
|
};
|
|
2459
|
-
}
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2036
|
+
}, []), /* @__PURE__ */ X(
|
|
2037
|
+
"div",
|
|
2038
|
+
{
|
|
2039
|
+
className: sn("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", {
|
|
2040
|
+
"univer-hidden": !U
|
|
2041
|
+
}),
|
|
2042
|
+
children: [
|
|
2043
|
+
/* @__PURE__ */ y(
|
|
2044
|
+
"header",
|
|
2045
|
+
{
|
|
2046
|
+
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2047
|
+
children: /* @__PURE__ */ y("div", { children: t.t("image-position.title") })
|
|
2048
|
+
}
|
|
2049
|
+
),
|
|
2050
|
+
/* @__PURE__ */ y(
|
|
2051
|
+
"div",
|
|
2052
|
+
{
|
|
2053
|
+
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2054
|
+
children: /* @__PURE__ */ y("div", { children: t.t("image-position.horizontal") })
|
|
2055
|
+
}
|
|
2056
|
+
),
|
|
2057
|
+
/* @__PURE__ */ X(
|
|
2058
|
+
"div",
|
|
2059
|
+
{
|
|
2060
|
+
className: "univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",
|
|
2061
|
+
children: [
|
|
2062
|
+
/* @__PURE__ */ X("div", { children: [
|
|
2063
|
+
/* @__PURE__ */ y("span", { children: t.t("image-position.absolutePosition") }),
|
|
2064
|
+
/* @__PURE__ */ y(
|
|
2065
|
+
Ue,
|
|
2066
|
+
{
|
|
2067
|
+
min: qt,
|
|
2068
|
+
max: Kt,
|
|
2069
|
+
precision: 1,
|
|
2070
|
+
disabled: p,
|
|
2071
|
+
value: D.posOffset,
|
|
2072
|
+
onChange: (_) => {
|
|
2073
|
+
w("positionH", {
|
|
2074
|
+
relativeFrom: D.relativeFrom,
|
|
2075
|
+
posOffset: _
|
|
2076
|
+
});
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
)
|
|
2080
|
+
] }),
|
|
2081
|
+
/* @__PURE__ */ X("div", { children: [
|
|
2082
|
+
/* @__PURE__ */ y("span", { children: t.t("image-position.toTheRightOf") }),
|
|
2083
|
+
/* @__PURE__ */ y(
|
|
2084
|
+
Ft,
|
|
2085
|
+
{
|
|
2086
|
+
value: String(D.relativeFrom),
|
|
2087
|
+
disabled: p,
|
|
2088
|
+
options: h,
|
|
2089
|
+
onChange: N
|
|
2090
|
+
}
|
|
2091
|
+
)
|
|
2092
|
+
] })
|
|
2093
|
+
]
|
|
2094
|
+
}
|
|
2095
|
+
),
|
|
2096
|
+
/* @__PURE__ */ y(
|
|
2097
|
+
"div",
|
|
2098
|
+
{
|
|
2099
|
+
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2100
|
+
children: /* @__PURE__ */ y("div", { children: t.t("image-position.vertical") })
|
|
2101
|
+
}
|
|
2102
|
+
),
|
|
2103
|
+
/* @__PURE__ */ X(
|
|
2104
|
+
"div",
|
|
2105
|
+
{
|
|
2106
|
+
className: "univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",
|
|
2107
|
+
children: [
|
|
2108
|
+
/* @__PURE__ */ X("div", { children: [
|
|
2109
|
+
/* @__PURE__ */ y("span", { children: t.t("image-position.absolutePosition") }),
|
|
2110
|
+
/* @__PURE__ */ y(
|
|
2111
|
+
Ue,
|
|
2112
|
+
{
|
|
2113
|
+
min: qt,
|
|
2114
|
+
max: Kt,
|
|
2115
|
+
precision: 1,
|
|
2116
|
+
disabled: p,
|
|
2117
|
+
value: O.posOffset,
|
|
2118
|
+
onChange: (_) => {
|
|
2119
|
+
w("positionV", {
|
|
2120
|
+
relativeFrom: O.relativeFrom,
|
|
2121
|
+
posOffset: _
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
)
|
|
2126
|
+
] }),
|
|
2127
|
+
/* @__PURE__ */ X("div", { children: [
|
|
2128
|
+
/* @__PURE__ */ y("span", { children: t.t("image-position.bellow") }),
|
|
2129
|
+
/* @__PURE__ */ y(
|
|
2130
|
+
Ft,
|
|
2131
|
+
{
|
|
2132
|
+
disabled: p,
|
|
2133
|
+
value: String(O.relativeFrom),
|
|
2134
|
+
options: m,
|
|
2135
|
+
onChange: H
|
|
2136
|
+
}
|
|
2137
|
+
)
|
|
2138
|
+
] })
|
|
2139
|
+
]
|
|
2140
|
+
}
|
|
2141
|
+
),
|
|
2142
|
+
/* @__PURE__ */ y(
|
|
2143
|
+
"div",
|
|
2144
|
+
{
|
|
2145
|
+
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2146
|
+
children: /* @__PURE__ */ y("div", { children: t.t("image-position.options") })
|
|
2147
|
+
}
|
|
2148
|
+
),
|
|
2149
|
+
/* @__PURE__ */ y("div", { children: /* @__PURE__ */ y(
|
|
2150
|
+
li,
|
|
2151
|
+
{
|
|
2152
|
+
disabled: p,
|
|
2153
|
+
checked: M,
|
|
2154
|
+
onChange: I,
|
|
2155
|
+
children: t.t("image-position.moveObjectWithText")
|
|
2156
|
+
}
|
|
2157
|
+
) })
|
|
2158
|
+
]
|
|
2159
|
+
}
|
|
2160
|
+
);
|
|
2161
|
+
}, et = 0, tt = 100, cr = (r) => {
|
|
2162
|
+
const e = ve(j), t = ve(lt), n = ve(fe), i = ve(Q), s = ve(z), { drawings: o } = r, c = o[0];
|
|
2163
|
+
if (c == null)
|
|
2164
|
+
return null;
|
|
2165
|
+
const { unitId: d } = c, a = s.getUniverDocInstance(d), g = i.getRenderById(d);
|
|
2166
|
+
if ((g == null ? void 0 : g.scene) == null)
|
|
2167
|
+
return null;
|
|
2168
|
+
const [l, f] = re(!0), [h, m] = re(!0), [p, v] = re(!0), [D, S] = re(ue.INLINE), [O, C] = re(""), [M, A] = re({
|
|
2169
|
+
distT: 0,
|
|
2170
|
+
distL: 0,
|
|
2171
|
+
distB: 0,
|
|
2172
|
+
distR: 0
|
|
2173
|
+
}), [U, R] = re(!0);
|
|
2174
|
+
function w(I) {
|
|
2175
|
+
S(I);
|
|
2176
|
+
const _ = n.getFocusDrawings();
|
|
2177
|
+
if (_.length === 0)
|
|
2463
2178
|
return;
|
|
2464
|
-
const
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2179
|
+
const { unitId: E, subUnitId: T } = _[0], L = _.map(({ unitId: B, subUnitId: b, drawingId: P }) => ({
|
|
2180
|
+
unitId: B,
|
|
2181
|
+
subUnitId: b,
|
|
2182
|
+
drawingId: P
|
|
2183
|
+
}));
|
|
2184
|
+
e.executeCommand(vn.id, {
|
|
2185
|
+
unitId: E,
|
|
2186
|
+
subUnitId: T,
|
|
2187
|
+
drawings: L,
|
|
2188
|
+
wrappingStyle: I
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
function N(I) {
|
|
2192
|
+
C(I);
|
|
2193
|
+
const _ = n.getFocusDrawings();
|
|
2194
|
+
if (_.length === 0)
|
|
2195
|
+
return;
|
|
2196
|
+
const E = _.map((T) => ({
|
|
2197
|
+
unitId: T.unitId,
|
|
2198
|
+
subUnitId: T.subUnitId,
|
|
2199
|
+
drawingId: T.drawingId
|
|
2200
|
+
}));
|
|
2201
|
+
e.executeCommand(In.id, {
|
|
2202
|
+
unitId: _[0].unitId,
|
|
2203
|
+
subUnitId: _[0].unitId,
|
|
2204
|
+
drawings: E,
|
|
2205
|
+
wrapText: I
|
|
2473
2206
|
});
|
|
2474
2207
|
}
|
|
2475
|
-
|
|
2476
|
-
if (
|
|
2208
|
+
function H(I, _) {
|
|
2209
|
+
if (I == null)
|
|
2477
2210
|
return;
|
|
2478
|
-
const
|
|
2479
|
-
|
|
2211
|
+
const E = { ...M, [_]: I };
|
|
2212
|
+
A(E);
|
|
2213
|
+
const T = n.getFocusDrawings();
|
|
2214
|
+
if (T.length === 0)
|
|
2480
2215
|
return;
|
|
2481
|
-
const
|
|
2482
|
-
|
|
2216
|
+
const L = T.map((B) => ({
|
|
2217
|
+
unitId: B.unitId,
|
|
2218
|
+
subUnitId: B.subUnitId,
|
|
2219
|
+
drawingId: B.drawingId
|
|
2220
|
+
}));
|
|
2221
|
+
e.executeCommand(wn.id, {
|
|
2222
|
+
unitId: T[0].unitId,
|
|
2223
|
+
subUnitId: T[0].unitId,
|
|
2224
|
+
drawings: L,
|
|
2225
|
+
dist: {
|
|
2226
|
+
[_]: I
|
|
2227
|
+
}
|
|
2228
|
+
});
|
|
2483
2229
|
}
|
|
2484
|
-
|
|
2485
|
-
const
|
|
2486
|
-
|
|
2487
|
-
return s.clone().invert().applyPoint(o);
|
|
2230
|
+
function x() {
|
|
2231
|
+
const I = n.getFocusDrawings();
|
|
2232
|
+
I.length !== 0 && G(I[0]);
|
|
2488
2233
|
}
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
const { mainComponent: i, scene: s } = n, o = i, {
|
|
2494
|
-
docsLeft: c,
|
|
2495
|
-
docsTop: d
|
|
2496
|
-
} = o.getOffsetConfig(), a = Jn(t), { left: g, top: u, height: l } = a, f = g + c, h = u + d;
|
|
2497
|
-
if (this._anchorShape) {
|
|
2498
|
-
this._anchorShape.transformByState({ left: f, top: h, height: l }), this._anchorShape.show();
|
|
2234
|
+
function G(I) {
|
|
2235
|
+
var K, oe;
|
|
2236
|
+
const _ = (oe = (K = a == null ? void 0 : a.getSnapshot()) == null ? void 0 : K.drawings) == null ? void 0 : oe[I.drawingId];
|
|
2237
|
+
if (_ == null)
|
|
2499
2238
|
return;
|
|
2239
|
+
const {
|
|
2240
|
+
distT: E = 0,
|
|
2241
|
+
distL: T = 0,
|
|
2242
|
+
distB: L = 0,
|
|
2243
|
+
distR: B = 0,
|
|
2244
|
+
layoutType: b = k.INLINE,
|
|
2245
|
+
behindDoc: P = se.FALSE,
|
|
2246
|
+
wrapText: V = ze.BOTH_SIDES
|
|
2247
|
+
} = _;
|
|
2248
|
+
if (A({
|
|
2249
|
+
distT: E,
|
|
2250
|
+
distL: T,
|
|
2251
|
+
distB: L,
|
|
2252
|
+
distR: B
|
|
2253
|
+
}), C(V), f(b !== k.WRAP_SQUARE), b === k.WRAP_NONE || b === k.INLINE ? m(!0) : m(!1), b === k.WRAP_NONE || b === k.INLINE || b === k.WRAP_TOP_AND_BOTTOM ? v(!0) : v(!1), b === k.WRAP_NONE)
|
|
2254
|
+
P === se.TRUE ? S(ue.BEHIND_TEXT) : S(ue.IN_FRONT_OF_TEXT);
|
|
2255
|
+
else
|
|
2256
|
+
switch (b) {
|
|
2257
|
+
case k.INLINE:
|
|
2258
|
+
S(ue.INLINE);
|
|
2259
|
+
break;
|
|
2260
|
+
case k.WRAP_SQUARE:
|
|
2261
|
+
S(ue.WRAP_SQUARE);
|
|
2262
|
+
break;
|
|
2263
|
+
case k.WRAP_TOP_AND_BOTTOM:
|
|
2264
|
+
S(ue.WRAP_TOP_AND_BOTTOM);
|
|
2265
|
+
break;
|
|
2266
|
+
default:
|
|
2267
|
+
throw new Error(`Unsupported layout type: ${b}`);
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
return yt(() => {
|
|
2271
|
+
x();
|
|
2272
|
+
const I = n.focus$.subscribe((E) => {
|
|
2273
|
+
if (E.length === 0) {
|
|
2274
|
+
R(!1);
|
|
2275
|
+
return;
|
|
2276
|
+
}
|
|
2277
|
+
R(!0), G(E[0]);
|
|
2278
|
+
}), _ = e.onCommandExecuted(async (E) => {
|
|
2279
|
+
E.id === ee.id && x();
|
|
2280
|
+
});
|
|
2281
|
+
return () => {
|
|
2282
|
+
I.unsubscribe(), _.dispose();
|
|
2283
|
+
};
|
|
2284
|
+
}, []), /* @__PURE__ */ X(
|
|
2285
|
+
"div",
|
|
2286
|
+
{
|
|
2287
|
+
className: sn("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", {
|
|
2288
|
+
"univer-hidden": !U
|
|
2289
|
+
}),
|
|
2290
|
+
children: [
|
|
2291
|
+
/* @__PURE__ */ y(
|
|
2292
|
+
"header",
|
|
2293
|
+
{
|
|
2294
|
+
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2295
|
+
children: /* @__PURE__ */ y("div", { children: t.t("image-text-wrap.title") })
|
|
2296
|
+
}
|
|
2297
|
+
),
|
|
2298
|
+
/* @__PURE__ */ y(
|
|
2299
|
+
"div",
|
|
2300
|
+
{
|
|
2301
|
+
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2302
|
+
children: /* @__PURE__ */ y("div", { children: t.t("image-text-wrap.wrappingStyle") })
|
|
2303
|
+
}
|
|
2304
|
+
),
|
|
2305
|
+
/* @__PURE__ */ y("div", { children: /* @__PURE__ */ X(kt, { value: D, onChange: w, direction: "vertical", children: [
|
|
2306
|
+
/* @__PURE__ */ y(Te, { value: ue.INLINE, children: t.t("image-text-wrap.inline") }),
|
|
2307
|
+
/* @__PURE__ */ y(Te, { value: ue.WRAP_SQUARE, children: t.t("image-text-wrap.square") }),
|
|
2308
|
+
/* @__PURE__ */ y(Te, { value: ue.WRAP_TOP_AND_BOTTOM, children: t.t("image-text-wrap.topAndBottom") }),
|
|
2309
|
+
/* @__PURE__ */ y(Te, { value: ue.BEHIND_TEXT, children: t.t("image-text-wrap.behindText") }),
|
|
2310
|
+
/* @__PURE__ */ y(Te, { value: ue.IN_FRONT_OF_TEXT, children: t.t("image-text-wrap.inFrontText") })
|
|
2311
|
+
] }) }),
|
|
2312
|
+
/* @__PURE__ */ y(
|
|
2313
|
+
"div",
|
|
2314
|
+
{
|
|
2315
|
+
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2316
|
+
children: /* @__PURE__ */ y("div", { children: t.t("image-text-wrap.wrapText") })
|
|
2317
|
+
}
|
|
2318
|
+
),
|
|
2319
|
+
/* @__PURE__ */ y("div", { children: /* @__PURE__ */ X(kt, { disabled: l, value: O, onChange: N, direction: "horizontal", children: [
|
|
2320
|
+
/* @__PURE__ */ y(Te, { value: ze.BOTH_SIDES, children: t.t("image-text-wrap.bothSide") }),
|
|
2321
|
+
/* @__PURE__ */ y(Te, { value: ze.LEFT, children: t.t("image-text-wrap.leftOnly") }),
|
|
2322
|
+
/* @__PURE__ */ y(Te, { value: ze.RIGHT, children: t.t("image-text-wrap.rightOnly") })
|
|
2323
|
+
] }) }),
|
|
2324
|
+
/* @__PURE__ */ y(
|
|
2325
|
+
"div",
|
|
2326
|
+
{
|
|
2327
|
+
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2328
|
+
children: /* @__PURE__ */ y("div", { children: t.t("image-text-wrap.distanceFromText") })
|
|
2329
|
+
}
|
|
2330
|
+
),
|
|
2331
|
+
/* @__PURE__ */ X(
|
|
2332
|
+
"div",
|
|
2333
|
+
{
|
|
2334
|
+
className: "univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",
|
|
2335
|
+
children: [
|
|
2336
|
+
/* @__PURE__ */ X("div", { children: [
|
|
2337
|
+
/* @__PURE__ */ y("span", { children: t.t("image-text-wrap.top") }),
|
|
2338
|
+
/* @__PURE__ */ y(
|
|
2339
|
+
Ue,
|
|
2340
|
+
{
|
|
2341
|
+
min: et,
|
|
2342
|
+
max: tt,
|
|
2343
|
+
disabled: h,
|
|
2344
|
+
precision: 1,
|
|
2345
|
+
value: M.distT,
|
|
2346
|
+
onChange: (I) => {
|
|
2347
|
+
H(I, "distT");
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
)
|
|
2351
|
+
] }),
|
|
2352
|
+
/* @__PURE__ */ X("div", { children: [
|
|
2353
|
+
/* @__PURE__ */ y("span", { children: t.t("image-text-wrap.left") }),
|
|
2354
|
+
/* @__PURE__ */ y(
|
|
2355
|
+
Ue,
|
|
2356
|
+
{
|
|
2357
|
+
min: et,
|
|
2358
|
+
max: tt,
|
|
2359
|
+
disabled: p,
|
|
2360
|
+
precision: 1,
|
|
2361
|
+
value: M.distL,
|
|
2362
|
+
onChange: (I) => {
|
|
2363
|
+
H(I, "distL");
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
)
|
|
2367
|
+
] })
|
|
2368
|
+
]
|
|
2369
|
+
}
|
|
2370
|
+
),
|
|
2371
|
+
/* @__PURE__ */ X(
|
|
2372
|
+
"div",
|
|
2373
|
+
{
|
|
2374
|
+
className: "univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",
|
|
2375
|
+
children: [
|
|
2376
|
+
/* @__PURE__ */ X("div", { children: [
|
|
2377
|
+
/* @__PURE__ */ y("span", { children: t.t("image-text-wrap.bottom") }),
|
|
2378
|
+
/* @__PURE__ */ y(
|
|
2379
|
+
Ue,
|
|
2380
|
+
{
|
|
2381
|
+
min: et,
|
|
2382
|
+
max: tt,
|
|
2383
|
+
disabled: h,
|
|
2384
|
+
precision: 1,
|
|
2385
|
+
value: M.distB,
|
|
2386
|
+
onChange: (I) => {
|
|
2387
|
+
H(I, "distB");
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
)
|
|
2391
|
+
] }),
|
|
2392
|
+
/* @__PURE__ */ X("div", { children: [
|
|
2393
|
+
/* @__PURE__ */ y("span", { children: t.t("image-text-wrap.right") }),
|
|
2394
|
+
/* @__PURE__ */ y(
|
|
2395
|
+
Ue,
|
|
2396
|
+
{
|
|
2397
|
+
min: et,
|
|
2398
|
+
max: tt,
|
|
2399
|
+
disabled: p,
|
|
2400
|
+
precision: 1,
|
|
2401
|
+
value: M.distR,
|
|
2402
|
+
onChange: (I) => {
|
|
2403
|
+
H(I, "distR");
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
)
|
|
2407
|
+
] })
|
|
2408
|
+
]
|
|
2409
|
+
}
|
|
2410
|
+
)
|
|
2411
|
+
]
|
|
2500
2412
|
}
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
evented: !1
|
|
2413
|
+
);
|
|
2414
|
+
}, dr = () => {
|
|
2415
|
+
const r = ve(fe), e = r.getFocusDrawings(), [t, n] = re(e);
|
|
2416
|
+
return yt(() => {
|
|
2417
|
+
const i = r.focus$.subscribe((s) => {
|
|
2418
|
+
n(s);
|
|
2508
2419
|
});
|
|
2509
|
-
|
|
2420
|
+
return () => {
|
|
2421
|
+
i.unsubscribe();
|
|
2422
|
+
};
|
|
2423
|
+
}, []), !!(t != null && t.length) && /* @__PURE__ */ X("div", { className: "univer-text-sm", children: [
|
|
2424
|
+
/* @__PURE__ */ y(Ai, { drawings: t, hasAlign: !1, hasCropper: !1, hasGroup: !1, hasTransform: !1 }),
|
|
2425
|
+
/* @__PURE__ */ y(cr, { drawings: t }),
|
|
2426
|
+
/* @__PURE__ */ y(ar, { drawings: t })
|
|
2427
|
+
] });
|
|
2428
|
+
};
|
|
2429
|
+
function Ze(r) {
|
|
2430
|
+
return r.getContextValue(Hn) && r.getContextValue(Gn) && r.getContextValue(it);
|
|
2431
|
+
}
|
|
2432
|
+
const gr = {
|
|
2433
|
+
id: Ye.id,
|
|
2434
|
+
description: "shortcut.drawing-move-down",
|
|
2435
|
+
group: "4_drawing-view",
|
|
2436
|
+
binding: Fe.ARROW_DOWN,
|
|
2437
|
+
priority: 100,
|
|
2438
|
+
preconditions: Ze,
|
|
2439
|
+
staticParameters: {
|
|
2440
|
+
direction: he.DOWN
|
|
2510
2441
|
}
|
|
2511
|
-
|
|
2512
|
-
|
|
2442
|
+
}, lr = {
|
|
2443
|
+
id: Ye.id,
|
|
2444
|
+
description: "shortcut.drawing-move-up",
|
|
2445
|
+
group: "4_drawing-view",
|
|
2446
|
+
binding: Fe.ARROW_UP,
|
|
2447
|
+
priority: 100,
|
|
2448
|
+
preconditions: Ze,
|
|
2449
|
+
staticParameters: {
|
|
2450
|
+
direction: he.UP
|
|
2513
2451
|
}
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
width: Math.max(i, a - u - f),
|
|
2534
|
-
height: Math.max(s, g - h - l)
|
|
2535
|
-
};
|
|
2536
|
-
} else
|
|
2537
|
-
return {
|
|
2538
|
-
width: i,
|
|
2539
|
-
height: s
|
|
2540
|
-
};
|
|
2452
|
+
}, ur = {
|
|
2453
|
+
id: Ye.id,
|
|
2454
|
+
description: "shortcut.drawing-move-left",
|
|
2455
|
+
group: "4_drawing-view",
|
|
2456
|
+
binding: Fe.ARROW_LEFT,
|
|
2457
|
+
priority: 100,
|
|
2458
|
+
preconditions: Ze,
|
|
2459
|
+
staticParameters: {
|
|
2460
|
+
direction: he.LEFT
|
|
2461
|
+
}
|
|
2462
|
+
}, hr = {
|
|
2463
|
+
id: Ye.id,
|
|
2464
|
+
description: "shortcut.drawing-move-right",
|
|
2465
|
+
group: "4_drawing-view",
|
|
2466
|
+
binding: Fe.ARROW_RIGHT,
|
|
2467
|
+
priority: 100,
|
|
2468
|
+
preconditions: Ze,
|
|
2469
|
+
staticParameters: {
|
|
2470
|
+
direction: he.RIGHT
|
|
2541
2471
|
}
|
|
2472
|
+
}, fr = {
|
|
2473
|
+
id: ln.id,
|
|
2474
|
+
description: "shortcut.drawing-delete",
|
|
2475
|
+
group: "4_drawing-view",
|
|
2476
|
+
// when focusing on any other input tag do not trigger this shortcut
|
|
2477
|
+
preconditions: Ze,
|
|
2478
|
+
binding: Fe.DELETE,
|
|
2479
|
+
mac: Fe.BACKSPACE
|
|
2542
2480
|
};
|
|
2543
|
-
ct = hr([
|
|
2544
|
-
tt(0, V),
|
|
2545
|
-
tt(1, z),
|
|
2546
|
-
tt(2, fe),
|
|
2547
|
-
tt(3, Q)
|
|
2548
|
-
], ct);
|
|
2549
2481
|
var pr = Object.getOwnPropertyDescriptor, mr = (r, e, t, n) => {
|
|
2550
2482
|
for (var i = n > 1 ? void 0 : n ? pr(e, t) : e, s = r.length - 1, o; s >= 0; s--)
|
|
2551
2483
|
(o = r[s]) && (i = o(i) || i);
|
|
2552
2484
|
return i;
|
|
2553
|
-
},
|
|
2554
|
-
let dt = class extends
|
|
2555
|
-
constructor(e, t, n
|
|
2556
|
-
super();
|
|
2557
|
-
me(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
|
|
2558
|
-
me(this, "_disposePopups", []);
|
|
2559
|
-
this._drawingManagerService = e, this._canvasPopManagerService = t, this._renderManagerService = n, this._univerInstanceService = i, this._contextService = s, this._init();
|
|
2560
|
-
}
|
|
2561
|
-
_init() {
|
|
2562
|
-
this.disposeWithMe(
|
|
2563
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(ve.UNIVER_DOC).pipe(Vt(this.dispose$)).subscribe((e) => this._create(e))
|
|
2564
|
-
), this.disposeWithMe(
|
|
2565
|
-
this._univerInstanceService.getTypeOfUnitDisposed$(ve.UNIVER_DOC).pipe(Vt(this.dispose$)).subscribe((e) => this._dispose(e))
|
|
2566
|
-
), this._univerInstanceService.getAllUnitsForType(ve.UNIVER_DOC).forEach((e) => this._create(e));
|
|
2485
|
+
}, nt = (r, e) => (t, n) => e(t, n, r);
|
|
2486
|
+
let dt = class extends xe {
|
|
2487
|
+
constructor(r, e, t, n) {
|
|
2488
|
+
super(), this._componentManager = r, this._menuManagerService = e, this._commandService = t, this._shortcutService = n, this._init();
|
|
2567
2489
|
}
|
|
2568
|
-
|
|
2569
|
-
const
|
|
2570
|
-
this.
|
|
2490
|
+
_initCustomComponents() {
|
|
2491
|
+
const r = this._componentManager;
|
|
2492
|
+
this.disposeWithMe(r.register(Dn, dr));
|
|
2571
2493
|
}
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
return;
|
|
2575
|
-
const t = e.getUnitId();
|
|
2576
|
-
jn(t) || this._renderManagerService.has(t) && !this._initImagePopupMenu.has(t) && (this._popupMenuListener(t), this._initImagePopupMenu.add(t));
|
|
2494
|
+
_initMenus() {
|
|
2495
|
+
this._menuManagerService.mergeMenu(or);
|
|
2577
2496
|
}
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2497
|
+
_initCommands() {
|
|
2498
|
+
[
|
|
2499
|
+
pn,
|
|
2500
|
+
bt,
|
|
2501
|
+
vn,
|
|
2502
|
+
wn,
|
|
2503
|
+
In,
|
|
2504
|
+
Ke,
|
|
2505
|
+
_n,
|
|
2506
|
+
Sn,
|
|
2507
|
+
Mt,
|
|
2508
|
+
On,
|
|
2509
|
+
Hi,
|
|
2510
|
+
Tn,
|
|
2511
|
+
un,
|
|
2512
|
+
fn,
|
|
2513
|
+
Ye,
|
|
2514
|
+
ln,
|
|
2515
|
+
hn
|
|
2516
|
+
].forEach((r) => this.disposeWithMe(this._commandService.registerCommand(r)));
|
|
2584
2517
|
}
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
n.createControl$.subscribe(
|
|
2597
|
-
() => {
|
|
2598
|
-
if (this._hasCropObject(t))
|
|
2599
|
-
return;
|
|
2600
|
-
const o = n.getSelectedObjectMap();
|
|
2601
|
-
if (i.forEach((w) => w.dispose()), i.length = 0, o.size > 1)
|
|
2602
|
-
return;
|
|
2603
|
-
const c = o.values().next().value;
|
|
2604
|
-
if (!c)
|
|
2605
|
-
return;
|
|
2606
|
-
const d = c.oKey, a = this._drawingManagerService.getDrawingOKey(d);
|
|
2607
|
-
if (!a || a.drawingType === Pe.DRAWING_DOM)
|
|
2608
|
-
return;
|
|
2609
|
-
const { unitId: g, subUnitId: u, drawingId: l, drawingType: f } = a, h = this._canvasPopManagerService.attachPopupToObject(
|
|
2610
|
-
c,
|
|
2611
|
-
{
|
|
2612
|
-
componentKey: xi,
|
|
2613
|
-
direction: "horizontal",
|
|
2614
|
-
offset: [2, 0],
|
|
2615
|
-
extraProps: {
|
|
2616
|
-
menuItems: this._getImageMenuItems(g, u, l, f)
|
|
2617
|
-
}
|
|
2618
|
-
},
|
|
2619
|
-
g
|
|
2620
|
-
);
|
|
2621
|
-
i.push(this.disposeWithMe(h)), !this._drawingManagerService.getFocusDrawings().find((w) => w.unitId === g && w.subUnitId === u && w.drawingId === l) && this._drawingManagerService.focusDrawing([{
|
|
2622
|
-
unitId: g,
|
|
2623
|
-
subUnitId: u,
|
|
2624
|
-
drawingId: l
|
|
2625
|
-
}]);
|
|
2626
|
-
}
|
|
2627
|
-
)
|
|
2628
|
-
), this.disposeWithMe(
|
|
2629
|
-
n.clearControl$.subscribe(() => {
|
|
2630
|
-
i.forEach((o) => o.dispose()), i.length = 0, this._contextService.setContextValue(nt, !1), this._drawingManagerService.focusDrawing(null);
|
|
2631
|
-
})
|
|
2632
|
-
), this.disposeWithMe(
|
|
2633
|
-
n.changing$.subscribe(
|
|
2634
|
-
() => {
|
|
2635
|
-
i.forEach((o) => o.dispose()), i.length = 0;
|
|
2636
|
-
}
|
|
2637
|
-
)
|
|
2638
|
-
), this.disposeWithMe(
|
|
2639
|
-
n.changeStart$.subscribe(() => {
|
|
2640
|
-
i.forEach((o) => o.dispose()), i.length = 0;
|
|
2641
|
-
})
|
|
2642
|
-
);
|
|
2518
|
+
_initShortcuts() {
|
|
2519
|
+
[
|
|
2520
|
+
// sheet drawing shortcuts
|
|
2521
|
+
gr,
|
|
2522
|
+
lr,
|
|
2523
|
+
ur,
|
|
2524
|
+
hr,
|
|
2525
|
+
fr
|
|
2526
|
+
].forEach((r) => {
|
|
2527
|
+
this.disposeWithMe(this._shortcutService.registerShortcut(r));
|
|
2528
|
+
});
|
|
2643
2529
|
}
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
{
|
|
2647
|
-
label: "image-popup.edit",
|
|
2648
|
-
index: 0,
|
|
2649
|
-
commandId: Tn.id,
|
|
2650
|
-
commandParams: { unitId: e, subUnitId: t, drawingId: n },
|
|
2651
|
-
// disable: !!SHEET_EDITOR_UNITS.includes(unitId) || drawingType === DrawingTypeEnum.DRAWING_DOM,
|
|
2652
|
-
disable: !0
|
|
2653
|
-
},
|
|
2654
|
-
{
|
|
2655
|
-
label: "image-popup.delete",
|
|
2656
|
-
index: 1,
|
|
2657
|
-
commandId: Mt.id,
|
|
2658
|
-
commandParams: { unitId: e, drawings: [{ unitId: e, subUnitId: t, drawingId: n }] },
|
|
2659
|
-
disable: !1
|
|
2660
|
-
},
|
|
2661
|
-
{
|
|
2662
|
-
label: "image-popup.crop",
|
|
2663
|
-
index: 2,
|
|
2664
|
-
commandId: Ni.id,
|
|
2665
|
-
commandParams: { unitId: e, subUnitId: t, drawingId: n },
|
|
2666
|
-
disable: !0
|
|
2667
|
-
// TODO: @JOCS, feature is not ready.
|
|
2668
|
-
},
|
|
2669
|
-
{
|
|
2670
|
-
label: "image-popup.reset",
|
|
2671
|
-
index: 3,
|
|
2672
|
-
commandId: Ui.id,
|
|
2673
|
-
commandParams: [{ unitId: e, subUnitId: t, drawingId: n }],
|
|
2674
|
-
disable: !0
|
|
2675
|
-
// TODO: @JOCS, feature is not ready.
|
|
2676
|
-
}
|
|
2677
|
-
];
|
|
2530
|
+
_init() {
|
|
2531
|
+
this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
|
|
2678
2532
|
}
|
|
2679
2533
|
};
|
|
2680
2534
|
dt = mr([
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
je(4, Yt)
|
|
2535
|
+
nt(0, Z(cn)),
|
|
2536
|
+
nt(1, yi),
|
|
2537
|
+
nt(2, j),
|
|
2538
|
+
nt(3, Mi)
|
|
2686
2539
|
], dt);
|
|
2687
|
-
var
|
|
2688
|
-
for (var i = n > 1 ? void 0 : n ?
|
|
2540
|
+
var vr = Object.getOwnPropertyDescriptor, wr = (r, e, t, n) => {
|
|
2541
|
+
for (var i = n > 1 ? void 0 : n ? vr(e, t) : e, s = r.length - 1, o; s >= 0; s--)
|
|
2689
2542
|
(o = r[s]) && (i = o(i) || i);
|
|
2690
2543
|
return i;
|
|
2691
2544
|
}, Re = (r, e) => (t, n) => e(t, n, r);
|
|
2692
|
-
let
|
|
2545
|
+
let _t = class extends xe {
|
|
2693
2546
|
constructor(e, t, n, i, s, o, c, d) {
|
|
2694
2547
|
super();
|
|
2695
2548
|
me(this, "_liquid", new rn());
|
|
@@ -2720,7 +2573,7 @@ let It = class extends xe {
|
|
|
2720
2573
|
const c = this._docSkeletonManagerService.getSkeleton();
|
|
2721
2574
|
if (c == null)
|
|
2722
2575
|
return;
|
|
2723
|
-
if (this._editorService.isEditor(s) && s !==
|
|
2576
|
+
if (this._editorService.isEditor(s) && s !== Dt) {
|
|
2724
2577
|
o == null || o.makeDirty();
|
|
2725
2578
|
return;
|
|
2726
2579
|
}
|
|
@@ -2749,35 +2602,35 @@ let It = class extends xe {
|
|
|
2749
2602
|
const { left: o, top: c, pageLayoutType: d, pageMarginLeft: a, pageMarginTop: g } = s, { pages: u, skeHeaders: l, skeFooters: f } = t, h = {};
|
|
2750
2603
|
this._liquid.reset();
|
|
2751
2604
|
for (let O = 0, C = u.length; O < C; O++) {
|
|
2752
|
-
const
|
|
2605
|
+
const M = u[O], { headerId: A, footerId: U, pageWidth: R } = M;
|
|
2753
2606
|
if (A) {
|
|
2754
|
-
const
|
|
2755
|
-
|
|
2607
|
+
const w = (D = l.get(A)) == null ? void 0 : D.get(R);
|
|
2608
|
+
w && this._calculateDrawingPosition(
|
|
2756
2609
|
i,
|
|
2757
|
-
|
|
2610
|
+
w,
|
|
2758
2611
|
o,
|
|
2759
2612
|
c,
|
|
2760
2613
|
h,
|
|
2761
|
-
|
|
2762
|
-
|
|
2614
|
+
w.marginTop,
|
|
2615
|
+
M.marginLeft
|
|
2763
2616
|
);
|
|
2764
2617
|
}
|
|
2765
|
-
if (
|
|
2766
|
-
const
|
|
2767
|
-
|
|
2618
|
+
if (U) {
|
|
2619
|
+
const w = (S = f.get(U)) == null ? void 0 : S.get(R);
|
|
2620
|
+
w && this._calculateDrawingPosition(
|
|
2768
2621
|
i,
|
|
2769
|
-
|
|
2622
|
+
w,
|
|
2770
2623
|
o,
|
|
2771
2624
|
c,
|
|
2772
2625
|
h,
|
|
2773
|
-
|
|
2774
|
-
|
|
2626
|
+
M.pageHeight - M.marginBottom + w.marginTop,
|
|
2627
|
+
M.marginLeft
|
|
2775
2628
|
);
|
|
2776
2629
|
}
|
|
2777
|
-
this._calculateDrawingPosition(i,
|
|
2630
|
+
this._calculateDrawingPosition(i, M, o, c, h, M.marginTop, M.marginLeft), this._liquid.translatePage(M, d, a, g);
|
|
2778
2631
|
}
|
|
2779
|
-
const m = Object.values(h), p = m.filter((O) => !O.isMultiTransform),
|
|
2780
|
-
p.length > 0 && this._drawingManagerService.refreshTransform(p), this._handleMultiDrawingsTransform(
|
|
2632
|
+
const m = Object.values(h), p = m.filter((O) => !O.isMultiTransform), v = m.filter((O) => O.isMultiTransform);
|
|
2633
|
+
p.length > 0 && this._drawingManagerService.refreshTransform(p), this._handleMultiDrawingsTransform(v);
|
|
2781
2634
|
}
|
|
2782
2635
|
_handleMultiDrawingsTransform(e) {
|
|
2783
2636
|
const { scene: t, unitId: n } = this._context, i = t.getTransformerByCreate();
|
|
@@ -2798,7 +2651,7 @@ let It = class extends xe {
|
|
|
2798
2651
|
marginTop: o,
|
|
2799
2652
|
marginLeft: c
|
|
2800
2653
|
}), d.forEach((a) => {
|
|
2801
|
-
const { aLeft: g, aTop: u, height: l, width: f, angle: h, drawingId: m, drawingOrigin: p } = a,
|
|
2654
|
+
const { aLeft: g, aTop: u, height: l, width: f, angle: h, drawingId: m, drawingOrigin: p } = a, v = p.layoutType === k.WRAP_NONE && p.behindDoc === se.TRUE, { isMultiTransform: D = se.FALSE } = p, S = {
|
|
2802
2655
|
left: g + n + this._liquid.x,
|
|
2803
2656
|
top: u + i + this._liquid.y,
|
|
2804
2657
|
width: f,
|
|
@@ -2809,7 +2662,7 @@ let It = class extends xe {
|
|
|
2809
2662
|
unitId: e,
|
|
2810
2663
|
subUnitId: e,
|
|
2811
2664
|
drawingId: m,
|
|
2812
|
-
behindText:
|
|
2665
|
+
behindText: v,
|
|
2813
2666
|
transform: S,
|
|
2814
2667
|
transforms: [S],
|
|
2815
2668
|
isMultiTransform: D
|
|
@@ -2824,76 +2677,215 @@ let It = class extends xe {
|
|
|
2824
2677
|
const t = this._docSkeletonManagerService.getSkeleton();
|
|
2825
2678
|
t != null && (this._refreshDrawing(t), this._drawingManagerService.initializeNotification(this._context.unitId));
|
|
2826
2679
|
};
|
|
2827
|
-
this._lifecycleService.stage >=
|
|
2680
|
+
this._lifecycleService.stage >= At.Rendered ? this._docSkeletonManagerService.getSkeleton() ? e() : setTimeout(e, 500) : this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(jt((t) => t === At.Rendered)).subscribe(e));
|
|
2828
2681
|
}
|
|
2829
2682
|
};
|
|
2830
|
-
|
|
2683
|
+
_t = wr([
|
|
2831
2684
|
Re(1, Z(te)),
|
|
2832
|
-
Re(2,
|
|
2833
|
-
Re(3,
|
|
2685
|
+
Re(2, j),
|
|
2686
|
+
Re(3, ni),
|
|
2834
2687
|
Re(4, fe),
|
|
2835
2688
|
Re(5, Z(ut)),
|
|
2836
2689
|
Re(6, z),
|
|
2837
|
-
Re(7, Z(
|
|
2838
|
-
],
|
|
2839
|
-
var Ir = Object.
|
|
2840
|
-
for (var i = n > 1 ? void 0 : n ?
|
|
2690
|
+
Re(7, Z(Vn))
|
|
2691
|
+
], _t);
|
|
2692
|
+
var Ir = Object.getOwnPropertyDescriptor, _r = (r, e, t, n) => {
|
|
2693
|
+
for (var i = n > 1 ? void 0 : n ? Ir(e, t) : e, s = r.length - 1, o; s >= 0; s--)
|
|
2694
|
+
(o = r[s]) && (i = o(i) || i);
|
|
2695
|
+
return i;
|
|
2696
|
+
}, $e = (r, e) => (t, n) => e(t, n, r);
|
|
2697
|
+
let gt = class extends jn {
|
|
2698
|
+
constructor(e, t, n, i, s) {
|
|
2699
|
+
super();
|
|
2700
|
+
me(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
|
|
2701
|
+
me(this, "_disposePopups", []);
|
|
2702
|
+
this._drawingManagerService = e, this._canvasPopManagerService = t, this._renderManagerService = n, this._univerInstanceService = i, this._contextService = s, this._init();
|
|
2703
|
+
}
|
|
2704
|
+
_init() {
|
|
2705
|
+
this.disposeWithMe(
|
|
2706
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(we.UNIVER_DOC).pipe($t(this.dispose$)).subscribe((e) => this._create(e))
|
|
2707
|
+
), this.disposeWithMe(
|
|
2708
|
+
this._univerInstanceService.getTypeOfUnitDisposed$(we.UNIVER_DOC).pipe($t(this.dispose$)).subscribe((e) => this._dispose(e))
|
|
2709
|
+
), this._univerInstanceService.getAllUnitsForType(we.UNIVER_DOC).forEach((e) => this._create(e));
|
|
2710
|
+
}
|
|
2711
|
+
_dispose(e) {
|
|
2712
|
+
const t = e.getUnitId();
|
|
2713
|
+
this._disposePopups.length && (this._disposePopups.forEach((n) => n.dispose()), this._disposePopups.length = 0), this._renderManagerService.removeRender(t);
|
|
2714
|
+
}
|
|
2715
|
+
_create(e) {
|
|
2716
|
+
if (!e)
|
|
2717
|
+
return;
|
|
2718
|
+
const t = e.getUnitId();
|
|
2719
|
+
$n(t) || this._renderManagerService.has(t) && !this._initImagePopupMenu.has(t) && (this._popupMenuListener(t), this._initImagePopupMenu.add(t));
|
|
2720
|
+
}
|
|
2721
|
+
_hasCropObject(e) {
|
|
2722
|
+
const t = e.getAllObjects();
|
|
2723
|
+
for (const n of t)
|
|
2724
|
+
if (n instanceof Pi)
|
|
2725
|
+
return !0;
|
|
2726
|
+
return !1;
|
|
2727
|
+
}
|
|
2728
|
+
// eslint-disable-next-line max-lines-per-function
|
|
2729
|
+
_popupMenuListener(e) {
|
|
2730
|
+
var s;
|
|
2731
|
+
const t = (s = this._renderManagerService.getRenderById(e)) == null ? void 0 : s.scene;
|
|
2732
|
+
if (!t)
|
|
2733
|
+
return;
|
|
2734
|
+
const n = t.getTransformerByCreate();
|
|
2735
|
+
if (!n)
|
|
2736
|
+
return;
|
|
2737
|
+
const i = this._disposePopups;
|
|
2738
|
+
this.disposeWithMe(
|
|
2739
|
+
n.createControl$.subscribe(
|
|
2740
|
+
() => {
|
|
2741
|
+
if (this._hasCropObject(t))
|
|
2742
|
+
return;
|
|
2743
|
+
const o = n.getSelectedObjectMap();
|
|
2744
|
+
if (i.forEach((v) => v.dispose()), i.length = 0, o.size > 1)
|
|
2745
|
+
return;
|
|
2746
|
+
const c = o.values().next().value;
|
|
2747
|
+
if (!c)
|
|
2748
|
+
return;
|
|
2749
|
+
const d = c.oKey, a = this._drawingManagerService.getDrawingOKey(d);
|
|
2750
|
+
if (!a || a.drawingType === Pe.DRAWING_DOM)
|
|
2751
|
+
return;
|
|
2752
|
+
const { unitId: g, subUnitId: u, drawingId: l, drawingType: f } = a, h = this._canvasPopManagerService.attachPopupToObject(
|
|
2753
|
+
c,
|
|
2754
|
+
{
|
|
2755
|
+
componentKey: xi,
|
|
2756
|
+
direction: "horizontal",
|
|
2757
|
+
offset: [2, 0],
|
|
2758
|
+
extraProps: {
|
|
2759
|
+
menuItems: this._getImageMenuItems(g, u, l, f)
|
|
2760
|
+
}
|
|
2761
|
+
},
|
|
2762
|
+
g
|
|
2763
|
+
);
|
|
2764
|
+
i.push(this.disposeWithMe(h)), !this._drawingManagerService.getFocusDrawings().find((v) => v.unitId === g && v.subUnitId === u && v.drawingId === l) && this._drawingManagerService.focusDrawing([{
|
|
2765
|
+
unitId: g,
|
|
2766
|
+
subUnitId: u,
|
|
2767
|
+
drawingId: l
|
|
2768
|
+
}]);
|
|
2769
|
+
}
|
|
2770
|
+
)
|
|
2771
|
+
), this.disposeWithMe(
|
|
2772
|
+
n.clearControl$.subscribe(() => {
|
|
2773
|
+
i.forEach((o) => o.dispose()), i.length = 0, this._contextService.setContextValue(it, !1), this._drawingManagerService.focusDrawing(null);
|
|
2774
|
+
})
|
|
2775
|
+
), this.disposeWithMe(
|
|
2776
|
+
n.changing$.subscribe(
|
|
2777
|
+
() => {
|
|
2778
|
+
i.forEach((o) => o.dispose()), i.length = 0;
|
|
2779
|
+
}
|
|
2780
|
+
)
|
|
2781
|
+
), this.disposeWithMe(
|
|
2782
|
+
n.changeStart$.subscribe(() => {
|
|
2783
|
+
i.forEach((o) => o.dispose()), i.length = 0;
|
|
2784
|
+
})
|
|
2785
|
+
);
|
|
2786
|
+
}
|
|
2787
|
+
_getImageMenuItems(e, t, n, i) {
|
|
2788
|
+
return [
|
|
2789
|
+
{
|
|
2790
|
+
label: "image-popup.edit",
|
|
2791
|
+
index: 0,
|
|
2792
|
+
commandId: Tn.id,
|
|
2793
|
+
commandParams: { unitId: e, subUnitId: t, drawingId: n },
|
|
2794
|
+
// disable: !!SHEET_EDITOR_UNITS.includes(unitId) || drawingType === DrawingTypeEnum.DRAWING_DOM,
|
|
2795
|
+
disable: !0
|
|
2796
|
+
},
|
|
2797
|
+
{
|
|
2798
|
+
label: "image-popup.delete",
|
|
2799
|
+
index: 1,
|
|
2800
|
+
commandId: Mt.id,
|
|
2801
|
+
commandParams: { unitId: e, drawings: [{ unitId: e, subUnitId: t, drawingId: n }] },
|
|
2802
|
+
disable: !1
|
|
2803
|
+
},
|
|
2804
|
+
{
|
|
2805
|
+
label: "image-popup.crop",
|
|
2806
|
+
index: 2,
|
|
2807
|
+
commandId: Ni.id,
|
|
2808
|
+
commandParams: { unitId: e, subUnitId: t, drawingId: n },
|
|
2809
|
+
disable: !0
|
|
2810
|
+
// TODO: @JOCS, feature is not ready.
|
|
2811
|
+
},
|
|
2812
|
+
{
|
|
2813
|
+
label: "image-popup.reset",
|
|
2814
|
+
index: 3,
|
|
2815
|
+
commandId: Li.id,
|
|
2816
|
+
commandParams: [{ unitId: e, subUnitId: t, drawingId: n }],
|
|
2817
|
+
disable: !0
|
|
2818
|
+
// TODO: @JOCS, feature is not ready.
|
|
2819
|
+
}
|
|
2820
|
+
];
|
|
2821
|
+
}
|
|
2822
|
+
};
|
|
2823
|
+
gt = _r([
|
|
2824
|
+
$e(0, fe),
|
|
2825
|
+
$e(1, Z(ii)),
|
|
2826
|
+
$e(2, Q),
|
|
2827
|
+
$e(3, z),
|
|
2828
|
+
$e(4, Yt)
|
|
2829
|
+
], gt);
|
|
2830
|
+
var Sr = Object.defineProperty, Dr = Object.getOwnPropertyDescriptor, Or = (r, e, t) => e in r ? Sr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Tr = (r, e, t, n) => {
|
|
2831
|
+
for (var i = n > 1 ? void 0 : n ? Dr(e, t) : e, s = r.length - 1, o; s >= 0; s--)
|
|
2841
2832
|
(o = r[s]) && (i = o(i) || i);
|
|
2842
2833
|
return i;
|
|
2843
|
-
},
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
constructor(r = $t, e, t, n) {
|
|
2834
|
+
}, It = (r, e) => (t, n) => e(t, n, r), ht = (r, e, t) => Or(r, typeof e != "symbol" ? e + "" : e, t);
|
|
2835
|
+
let ke = class extends qn {
|
|
2836
|
+
constructor(r = zt, e, t, n) {
|
|
2847
2837
|
super(), this._config = r, this._injector = e, this._renderManagerSrv = t, this._configService = n;
|
|
2848
2838
|
const { ...i } = Kn(
|
|
2849
2839
|
{},
|
|
2850
|
-
|
|
2840
|
+
zt,
|
|
2851
2841
|
this._config
|
|
2852
2842
|
);
|
|
2853
|
-
this._configService.setConfig(
|
|
2843
|
+
this._configService.setConfig(Ki, i);
|
|
2854
2844
|
}
|
|
2855
2845
|
onStarting() {
|
|
2856
2846
|
[
|
|
2857
|
-
[st],
|
|
2858
2847
|
[dt],
|
|
2848
|
+
[gt],
|
|
2859
2849
|
[ct],
|
|
2860
2850
|
[ot],
|
|
2861
2851
|
[ut],
|
|
2862
|
-
[
|
|
2852
|
+
[st],
|
|
2863
2853
|
[at]
|
|
2864
2854
|
].forEach((e) => this._injector.add(e));
|
|
2865
2855
|
}
|
|
2866
2856
|
onReady() {
|
|
2867
2857
|
[
|
|
2868
|
-
[
|
|
2869
|
-
[
|
|
2870
|
-
].forEach((r) => this._renderManagerSrv.registerRenderModule(
|
|
2858
|
+
[rt],
|
|
2859
|
+
[_t]
|
|
2860
|
+
].forEach((r) => this._renderManagerSrv.registerRenderModule(we.UNIVER_DOC, r)), this._injector.get(ot), this._injector.get(dt), this._injector.get(ct), this._injector.get(at);
|
|
2871
2861
|
}
|
|
2872
2862
|
onRendered() {
|
|
2873
|
-
this._injector.get(
|
|
2863
|
+
this._injector.get(gt), this._injector.get(st);
|
|
2874
2864
|
}
|
|
2875
2865
|
};
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2866
|
+
ht(ke, "type", we.UNIVER_DOC);
|
|
2867
|
+
ht(ke, "pluginName", "DOC_DRAWING_UI_PLUGIN");
|
|
2868
|
+
ht(ke, "packageName", Cn.name);
|
|
2869
|
+
ht(ke, "version", Cn.version);
|
|
2870
|
+
ke = Tr([
|
|
2871
|
+
zn(Ui, vi, Yn, bi),
|
|
2872
|
+
It(1, Z(Jt)),
|
|
2873
|
+
It(2, Q),
|
|
2874
|
+
It(3, Xn)
|
|
2875
|
+
], ke);
|
|
2884
2876
|
export {
|
|
2885
|
-
|
|
2886
|
-
|
|
2877
|
+
Hi as ClearDocDrawingTransformerOperation,
|
|
2878
|
+
Mn as DOCS_IMAGE_MENU_ID,
|
|
2887
2879
|
ln as DeleteDocDrawingsCommand,
|
|
2888
|
-
|
|
2880
|
+
st as DocFloatDomController,
|
|
2889
2881
|
Tn as EditDocDrawingOperation,
|
|
2890
2882
|
un as GroupDocDrawingCommand,
|
|
2891
|
-
|
|
2883
|
+
bt as InsertDocDrawingCommand,
|
|
2892
2884
|
pn as InsertDocImageCommand,
|
|
2893
|
-
|
|
2885
|
+
Ye as MoveDocDrawingsCommand,
|
|
2894
2886
|
Mt as RemoveDocDrawingCommand,
|
|
2895
2887
|
hn as SetDocDrawingArrangeCommand,
|
|
2896
2888
|
On as SidebarDocDrawingOperation,
|
|
2897
2889
|
fn as UngroupDocDrawingCommand,
|
|
2898
|
-
|
|
2890
|
+
ke as UniverDocsDrawingUIPlugin
|
|
2899
2891
|
};
|