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