@univerjs/docs-drawing-ui 0.1.13
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/LICENSE +176 -0
- package/README.md +16 -0
- package/lib/cjs/index.js +1 -0
- package/lib/es/index.js +963 -0
- package/lib/index.css +1 -0
- package/lib/locale/en-US.json +24 -0
- package/lib/locale/ru-RU.json +24 -0
- package/lib/locale/zh-CN.json +24 -0
- package/lib/types/commands/commands/delete-drawings.command.d.ts +3 -0
- package/lib/types/commands/commands/group-doc-drawing.command.d.ts +6 -0
- package/lib/types/commands/commands/insert-doc-drawing.command.d.ts +6 -0
- package/lib/types/commands/commands/interfaces.d.ts +21 -0
- package/lib/types/commands/commands/move-drawings.command.d.ts +6 -0
- package/lib/types/commands/commands/remove-doc-drawing.command.d.ts +6 -0
- package/lib/types/commands/commands/set-doc-drawing.command.d.ts +6 -0
- package/lib/types/commands/commands/set-drawing-arrange.command.d.ts +10 -0
- package/lib/types/commands/commands/ungroup-doc-drawing.command.d.ts +6 -0
- package/lib/types/commands/commands/utils.d.ts +4 -0
- package/lib/types/commands/operations/clear-drawing-transformer.operation.d.ts +3 -0
- package/lib/types/commands/operations/edit-doc-drawing.operation.d.ts +4 -0
- package/lib/types/commands/operations/insert-image.operation.d.ts +6 -0
- package/lib/types/commands/operations/open-drawing-panel.operation.d.ts +6 -0
- package/lib/types/controllers/doc-drawing-update.controller.d.ts +35 -0
- package/lib/types/controllers/doc-drawing.controller.d.ts +17 -0
- package/lib/types/controllers/drawing-popup-menu.controller.d.ts +20 -0
- package/lib/types/controllers/shortcuts/drawing.shortcut.d.ts +10 -0
- package/lib/types/index.d.ts +16 -0
- package/lib/types/locale/en-US.d.ts +4 -0
- package/lib/types/locale/ru-RU.d.ts +4 -0
- package/lib/types/locale/zh-CN.d.ts +40 -0
- package/lib/types/plugin.d.ts +12 -0
- package/lib/types/views/doc-image-panel/DocDrawingAnchor.d.ts +7 -0
- package/lib/types/views/doc-image-panel/DocDrawingPanel.d.ts +3 -0
- package/lib/types/views/doc-image-panel/component-name.d.ts +16 -0
- package/lib/types/views/menu/image.menu.d.ts +6 -0
- package/lib/types/views/upload-component/UploadFile.d.ts +3 -0
- package/lib/types/views/upload-component/component-name.d.ts +16 -0
- package/lib/umd/index.js +1 -0
- package/package.json +100 -0
package/lib/es/index.js
ADDED
|
@@ -0,0 +1,963 @@
|
|
|
1
|
+
var Be = Object.defineProperty;
|
|
2
|
+
var He = (e, n, t) => n in e ? Be(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
|
|
3
|
+
var $ = (e, n, t) => (He(e, typeof n != "symbol" ? n + "" : n, t), t);
|
|
4
|
+
import { CommandType as C, ICommandService as _, IUndoRedoService as x, LocaleService as Q, RxDisposable as ke, UniverInstanceType as R, toDisposable as ee, FOCUSING_COMMON_DRAWINGS as Y, OnLifecycle as re, LifecycleStages as ie, IUniverInstanceService as he, IContextService as Ie, Direction as E, FOCUSING_UNIVER_EDITOR as Ke, Disposable as ve, PositionedObjectLayoutType as ze, ObjectRelativeFromH as Ze, ObjectRelativeFromV as qe, Plugin as Ye } from "@univerjs/core";
|
|
5
|
+
import { Inject as b, Injector as _e } from "@wendellhu/redi";
|
|
6
|
+
import { IRenderManagerService as X, getGroupState as Qe, transformObjectOutOfGroup as Xe, Liquid as Je } from "@univerjs/engine-render";
|
|
7
|
+
import { ImageCropperObject as en, COMPONENT_IMAGE_POPUP_MENU as nn, OpenImageCropOperation as tn, ImageResetSizeOperation as rn, DrawingCommonPanel as on } from "@univerjs/drawing-ui";
|
|
8
|
+
import { takeUntil as ce } from "rxjs";
|
|
9
|
+
import { DocCanvasPopManagerService as an, transformToDocDrawingPosition as we, docDrawingPositionToTransform as de } from "@univerjs/docs-ui";
|
|
10
|
+
import { IDrawingManagerService as L, DRAWING_IMAGE_ALLOW_IMAGE_LIST as sn, ArrangeTypeEnum as B, DrawingTypeEnum as oe, DRAWING_IMAGE_COUNT_LIMIT as ue, ImageUploadStatusType as ne, DRAWING_IMAGE_ALLOW_SIZE as cn, getImageSize as dn, DRAWING_IMAGE_WIDTH_LIMIT as me, DRAWING_IMAGE_HEIGHT_LIMIT as le, IImageIoService as un } from "@univerjs/drawing";
|
|
11
|
+
import { IDocDrawingService as P, SetDocDrawingApplyMutation as h, DocDrawingApplyType as I } from "@univerjs/docs-drawing";
|
|
12
|
+
import { ISidebarService as mn, MenuItemType as Se, MenuPosition as ln, MenuGroup as gn, getMenuHiddenObservable as Ce, KeyCode as A, ComponentManager as pn, IMenuService as fn, IShortcutService as hn, IMessageService as In } from "@univerjs/ui";
|
|
13
|
+
import { useDependency as N } from "@wendellhu/redi/react-bindings";
|
|
14
|
+
import M, { forwardRef as De, useRef as Me, createElement as Oe, useState as te, useEffect as Pe } from "react";
|
|
15
|
+
import H from "clsx";
|
|
16
|
+
import { MessageType as k } from "@univerjs/design";
|
|
17
|
+
import { TextSelectionManagerService as vn, DocSkeletonManagerService as _n } from "@univerjs/docs";
|
|
18
|
+
const S = {
|
|
19
|
+
id: "sheet.operation.clear-drawing-transformer",
|
|
20
|
+
type: C.MUTATION,
|
|
21
|
+
handler: (e, n) => {
|
|
22
|
+
const t = e.get(X);
|
|
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
|
+
}, ae = {
|
|
29
|
+
id: "doc.command.remove-doc-image",
|
|
30
|
+
type: C.COMMAND,
|
|
31
|
+
handler: (e, n) => {
|
|
32
|
+
const t = e.get(_), r = e.get(x), i = e.get(P);
|
|
33
|
+
if (!n)
|
|
34
|
+
return !1;
|
|
35
|
+
const { drawings: o } = n, a = [];
|
|
36
|
+
o.forEach((p) => {
|
|
37
|
+
const { unitId: f } = p;
|
|
38
|
+
a.push(f);
|
|
39
|
+
});
|
|
40
|
+
const s = i.getBatchRemoveOp(o), { unitId: c, subUnitId: d, undo: m, redo: u, objects: l } = s;
|
|
41
|
+
return t.syncExecuteCommand(h.id, { unitId: c, subUnitId: d, op: u, objects: l, type: I.REMOVE }) ? (r.pushUndoRedo({
|
|
42
|
+
unitID: c,
|
|
43
|
+
undoMutations: [
|
|
44
|
+
{ id: h.id, params: { unitId: c, subUnitId: d, op: m, objects: l, type: I.INSERT } },
|
|
45
|
+
{ id: S.id, params: a }
|
|
46
|
+
],
|
|
47
|
+
redoMutations: [
|
|
48
|
+
{ id: h.id, params: { unitId: c, subUnitId: d, op: u, objects: l, type: I.REMOVE } },
|
|
49
|
+
{ id: S.id, params: a }
|
|
50
|
+
]
|
|
51
|
+
}), !0) : !1;
|
|
52
|
+
}
|
|
53
|
+
}, ye = "COMPONENT_DOC_DRAWING_PANEL", Ee = {
|
|
54
|
+
id: "sidebar.operation.doc-image",
|
|
55
|
+
type: C.COMMAND,
|
|
56
|
+
handler: async (e, n) => {
|
|
57
|
+
const t = e.get(mn), r = e.get(Q), i = e.get(L);
|
|
58
|
+
switch (n.value) {
|
|
59
|
+
case "open":
|
|
60
|
+
t.open({
|
|
61
|
+
header: { title: r.t("docImage.panel.title") },
|
|
62
|
+
children: { label: ye },
|
|
63
|
+
onClose: () => {
|
|
64
|
+
i.focusDrawing(null);
|
|
65
|
+
},
|
|
66
|
+
width: 360
|
|
67
|
+
});
|
|
68
|
+
break;
|
|
69
|
+
case "close":
|
|
70
|
+
default:
|
|
71
|
+
t.close();
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
return !0;
|
|
75
|
+
}
|
|
76
|
+
}, be = {
|
|
77
|
+
id: "sheet.operation.edit-sheet-image",
|
|
78
|
+
type: C.OPERATION,
|
|
79
|
+
handler: (e, n) => {
|
|
80
|
+
const t = e.get(L), r = e.get(_);
|
|
81
|
+
return n == null ? !1 : (t.focusDrawing([n]), r.executeCommand(Ee.id, { value: "open" }), !0);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var wn = Object.defineProperty, Sn = Object.getOwnPropertyDescriptor, Cn = (e, n, t, r) => {
|
|
85
|
+
for (var i = r > 1 ? void 0 : r ? Sn(n, t) : n, o = e.length - 1, a; o >= 0; o--)
|
|
86
|
+
(a = e[o]) && (i = (r ? a(n, t, i) : a(i)) || i);
|
|
87
|
+
return r && i && wn(n, t, i), i;
|
|
88
|
+
}, j = (e, n) => (t, r) => n(t, r, e);
|
|
89
|
+
let z = class extends ke {
|
|
90
|
+
constructor(n, t, r, i, o) {
|
|
91
|
+
super();
|
|
92
|
+
$(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
|
|
93
|
+
this._drawingManagerService = n, this._canvasPopManagerService = t, this._renderManagerService = r, this._univerInstanceService = i, this._contextService = o, this._init();
|
|
94
|
+
}
|
|
95
|
+
_init() {
|
|
96
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(R.UNIVER_DOC).pipe(ce(this.dispose$)).subscribe((n) => this._create(n)), this._univerInstanceService.getTypeOfUnitDisposed$(R.UNIVER_DOC).pipe(ce(this.dispose$)).subscribe((n) => this._dispose(n)), this._univerInstanceService.getAllUnitsForType(R.UNIVER_DOC).forEach((n) => this._create(n));
|
|
97
|
+
}
|
|
98
|
+
_dispose(n) {
|
|
99
|
+
const t = n.getUnitId();
|
|
100
|
+
this._renderManagerService.removeRender(t);
|
|
101
|
+
}
|
|
102
|
+
_create(n) {
|
|
103
|
+
if (!n)
|
|
104
|
+
return;
|
|
105
|
+
const t = n.getUnitId();
|
|
106
|
+
this._renderManagerService.has(t) && !this._initImagePopupMenu.has(t) && (this._popupMenuListener(t), this._initImagePopupMenu.add(t));
|
|
107
|
+
}
|
|
108
|
+
_hasCropObject(n) {
|
|
109
|
+
const t = n.getAllObjects();
|
|
110
|
+
for (const r of t)
|
|
111
|
+
if (r instanceof en)
|
|
112
|
+
return !0;
|
|
113
|
+
return !1;
|
|
114
|
+
}
|
|
115
|
+
_popupMenuListener(n) {
|
|
116
|
+
var o;
|
|
117
|
+
const t = (o = this._renderManagerService.getRenderById(n)) == null ? void 0 : o.scene;
|
|
118
|
+
if (!t)
|
|
119
|
+
return;
|
|
120
|
+
const r = t.getTransformerByCreate();
|
|
121
|
+
if (!r)
|
|
122
|
+
return;
|
|
123
|
+
const i = [];
|
|
124
|
+
this.disposeWithMe(
|
|
125
|
+
ee(
|
|
126
|
+
r.onCreateControlObservable.add(() => {
|
|
127
|
+
if (this._hasCropObject(t))
|
|
128
|
+
return;
|
|
129
|
+
const a = r.getSelectedObjectMap();
|
|
130
|
+
if (a.size > 1) {
|
|
131
|
+
i.forEach((g) => g.dispose());
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const s = a.values().next().value;
|
|
135
|
+
if (!s)
|
|
136
|
+
return;
|
|
137
|
+
const c = s.oKey, d = this._drawingManagerService.getDrawingOKey(c);
|
|
138
|
+
if (!d)
|
|
139
|
+
return;
|
|
140
|
+
const { unitId: m, subUnitId: u, drawingId: l } = d;
|
|
141
|
+
i.push(this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s, {
|
|
142
|
+
componentKey: nn,
|
|
143
|
+
direction: "horizontal",
|
|
144
|
+
offset: [2, 0],
|
|
145
|
+
extraProps: {
|
|
146
|
+
menuItems: this._getImageMenuItems(m, u, l)
|
|
147
|
+
}
|
|
148
|
+
}))), this._drawingManagerService.focusDrawing([{
|
|
149
|
+
unitId: m,
|
|
150
|
+
subUnitId: u,
|
|
151
|
+
drawingId: l
|
|
152
|
+
}]);
|
|
153
|
+
})
|
|
154
|
+
)
|
|
155
|
+
), this.disposeWithMe(
|
|
156
|
+
ee(
|
|
157
|
+
r.onClearControlObservable.add(() => {
|
|
158
|
+
i.forEach((a) => a.dispose()), this._contextService.setContextValue(Y, !1), this._drawingManagerService.focusDrawing(null);
|
|
159
|
+
})
|
|
160
|
+
)
|
|
161
|
+
), this.disposeWithMe(
|
|
162
|
+
ee(
|
|
163
|
+
r.onChangingObservable.add(() => {
|
|
164
|
+
i.forEach((a) => a.dispose());
|
|
165
|
+
})
|
|
166
|
+
)
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
_getImageMenuItems(n, t, r) {
|
|
170
|
+
return [
|
|
171
|
+
{
|
|
172
|
+
label: "image-popup.edit",
|
|
173
|
+
index: 0,
|
|
174
|
+
commandId: be.id,
|
|
175
|
+
commandParams: { unitId: n, subUnitId: t, drawingId: r },
|
|
176
|
+
disable: !1
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
label: "image-popup.delete",
|
|
180
|
+
index: 1,
|
|
181
|
+
commandId: ae.id,
|
|
182
|
+
commandParams: { unitId: n, drawings: [{ unitId: n, subUnitId: t, drawingId: r }] },
|
|
183
|
+
disable: !1
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
label: "image-popup.crop",
|
|
187
|
+
index: 2,
|
|
188
|
+
commandId: tn.id,
|
|
189
|
+
commandParams: { unitId: n, subUnitId: t, drawingId: r },
|
|
190
|
+
disable: !1
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
label: "image-popup.reset",
|
|
194
|
+
index: 3,
|
|
195
|
+
commandId: rn.id,
|
|
196
|
+
commandParams: [{ unitId: n, subUnitId: t, drawingId: r }],
|
|
197
|
+
disable: !1
|
|
198
|
+
}
|
|
199
|
+
];
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
z = Cn([
|
|
203
|
+
re(ie.Rendered, z),
|
|
204
|
+
j(0, L),
|
|
205
|
+
j(1, b(an)),
|
|
206
|
+
j(2, X),
|
|
207
|
+
j(3, he),
|
|
208
|
+
j(4, Ie)
|
|
209
|
+
], z);
|
|
210
|
+
var w = function() {
|
|
211
|
+
return w = Object.assign || function(e) {
|
|
212
|
+
for (var n, t = 1, r = arguments.length; t < r; t++) {
|
|
213
|
+
n = arguments[t];
|
|
214
|
+
for (var i in n)
|
|
215
|
+
Object.prototype.hasOwnProperty.call(n, i) && (e[i] = n[i]);
|
|
216
|
+
}
|
|
217
|
+
return e;
|
|
218
|
+
}, w.apply(this, arguments);
|
|
219
|
+
}, Dn = function(e, n) {
|
|
220
|
+
var t = {};
|
|
221
|
+
for (var r in e)
|
|
222
|
+
Object.prototype.hasOwnProperty.call(e, r) && n.indexOf(r) < 0 && (t[r] = e[r]);
|
|
223
|
+
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
224
|
+
for (var i = 0, r = Object.getOwnPropertySymbols(e); i < r.length; i++)
|
|
225
|
+
n.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i]) && (t[r[i]] = e[r[i]]);
|
|
226
|
+
return t;
|
|
227
|
+
}, Re = De(function(e, n) {
|
|
228
|
+
var t = e.icon, r = e.id, i = e.className, o = e.extend, a = Dn(e, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(r, " ").concat(i || "").trim(), c = Me("_".concat(Pn()));
|
|
229
|
+
return Ue(t, "".concat(r), { defIds: t.defIds, idSuffix: c.current }, w({ ref: n, className: s }, a), o);
|
|
230
|
+
});
|
|
231
|
+
function Ue(e, n, t, r, i) {
|
|
232
|
+
return Oe(e.tag, w(w({ key: n }, Mn(e, t, i)), r), (On(e, t).children || []).map(function(o, a) {
|
|
233
|
+
return Ue(o, "".concat(n, "-").concat(e.tag, "-").concat(a), t, void 0, i);
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
function Mn(e, n, t) {
|
|
237
|
+
var r = w({}, e.attrs);
|
|
238
|
+
t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1);
|
|
239
|
+
var i = n.defIds;
|
|
240
|
+
return !i || i.length === 0 || (e.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + n.idSuffix), Object.entries(r).forEach(function(o) {
|
|
241
|
+
var a = o[0], s = o[1];
|
|
242
|
+
typeof s == "string" && (r[a] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(n.idSuffix, ")")));
|
|
243
|
+
})), r;
|
|
244
|
+
}
|
|
245
|
+
function On(e, n) {
|
|
246
|
+
var t, r = n.defIds;
|
|
247
|
+
return !r || r.length === 0 ? e : e.tag === "defs" && (!((t = e.children) === null || t === void 0) && t.length) ? w(w({}, e), { children: e.children.map(function(i) {
|
|
248
|
+
return typeof i.attrs.id == "string" && r && r.indexOf(i.attrs.id) > -1 ? w(w({}, i), { attrs: w(w({}, i.attrs), { id: i.attrs.id + n.idSuffix }) }) : i;
|
|
249
|
+
}) }) : e;
|
|
250
|
+
}
|
|
251
|
+
function Pn() {
|
|
252
|
+
return Math.random().toString(36).substring(2, 8);
|
|
253
|
+
}
|
|
254
|
+
Re.displayName = "UniverIcon";
|
|
255
|
+
var yn = { 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" } }] }, Te = De(function(e, n) {
|
|
256
|
+
return Oe(Re, Object.assign({}, e, {
|
|
257
|
+
id: "add-image-single",
|
|
258
|
+
ref: n,
|
|
259
|
+
icon: yn
|
|
260
|
+
}));
|
|
261
|
+
});
|
|
262
|
+
Te.displayName = "AddImageSingle";
|
|
263
|
+
const J = {
|
|
264
|
+
id: "doc.operation.insert-float-image",
|
|
265
|
+
type: C.OPERATION,
|
|
266
|
+
handler: (e, n) => !0
|
|
267
|
+
}, En = "univer-upload-file-menu", bn = "univer-upload-file-menu-input", ge = {
|
|
268
|
+
uploadFileMenu: En,
|
|
269
|
+
uploadFileMenuInput: bn
|
|
270
|
+
}, Rn = () => {
|
|
271
|
+
const e = N(_), n = Me(null), t = () => {
|
|
272
|
+
var o;
|
|
273
|
+
(o = n.current) == null || o.click();
|
|
274
|
+
}, r = sn.map((o) => `.${o.replace("image/", "")}`).join(","), i = (o) => {
|
|
275
|
+
const a = o.target.files;
|
|
276
|
+
if (a == null)
|
|
277
|
+
return;
|
|
278
|
+
const s = Array.from(a);
|
|
279
|
+
e.executeCommand(J.id, { files: s }), n.current && (n.current.value = "");
|
|
280
|
+
};
|
|
281
|
+
return /* @__PURE__ */ M.createElement("div", { onClick: t, className: ge.uploadFileMenu }, /* @__PURE__ */ M.createElement(
|
|
282
|
+
"input",
|
|
283
|
+
{
|
|
284
|
+
type: "file",
|
|
285
|
+
className: ge.uploadFileMenuInput,
|
|
286
|
+
ref: n,
|
|
287
|
+
onChange: i,
|
|
288
|
+
accept: r,
|
|
289
|
+
multiple: !0
|
|
290
|
+
}
|
|
291
|
+
));
|
|
292
|
+
}, Ne = "COMPONENT_DOC_UPLOAD_FILE_MENU", Ae = "addition-and-subtraction-single", xe = "doc.menu.image";
|
|
293
|
+
function Un(e) {
|
|
294
|
+
return {
|
|
295
|
+
id: xe,
|
|
296
|
+
type: Se.SUBITEMS,
|
|
297
|
+
positions: [ln.TOOLBAR_START],
|
|
298
|
+
group: gn.TOOLBAR_LAYOUT,
|
|
299
|
+
icon: Ae,
|
|
300
|
+
tooltip: "docImage.title",
|
|
301
|
+
hidden$: Ce(e, R.UNIVER_DOC)
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function Tn(e) {
|
|
305
|
+
return {
|
|
306
|
+
id: J.id,
|
|
307
|
+
title: "docImage.upload.float",
|
|
308
|
+
type: Se.SELECTOR,
|
|
309
|
+
label: {
|
|
310
|
+
name: Ne
|
|
311
|
+
},
|
|
312
|
+
positions: [xe],
|
|
313
|
+
hidden$: Ce(e, R.UNIVER_DOC)
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
const Nn = "univer-image-common-panel", An = "univer-image-common-panel-grid", xn = "univer-image-common-panel-border", Ln = "univer-image-common-panel-title", Gn = "univer-image-common-panel-row", jn = "univer-image-common-panel-row-vertical", Wn = "univer-image-common-panel-column", Fn = "univer-image-common-panel-column-center", Vn = "univer-image-common-panel-inline", $n = "univer-image-common-panel-span2", Bn = "univer-image-common-panel-span3", Hn = "univer-image-common-panel-input", kn = "univer-sheet-image-menu", Kn = "univer-sheet-image-menu-input", y = {
|
|
317
|
+
imageCommonPanel: Nn,
|
|
318
|
+
imageCommonPanelGrid: An,
|
|
319
|
+
imageCommonPanelBorder: xn,
|
|
320
|
+
imageCommonPanelTitle: Ln,
|
|
321
|
+
imageCommonPanelRow: Gn,
|
|
322
|
+
imageCommonPanelRowVertical: jn,
|
|
323
|
+
imageCommonPanelColumn: Wn,
|
|
324
|
+
imageCommonPanelColumnCenter: Fn,
|
|
325
|
+
imageCommonPanelInline: Vn,
|
|
326
|
+
imageCommonPanelSpan2: $n,
|
|
327
|
+
imageCommonPanelSpan3: Bn,
|
|
328
|
+
imageCommonPanelInput: Hn,
|
|
329
|
+
sheetImageMenu: kn,
|
|
330
|
+
sheetImageMenuInput: Kn
|
|
331
|
+
}, se = {
|
|
332
|
+
id: "doc.command.set-doc-image",
|
|
333
|
+
type: C.COMMAND,
|
|
334
|
+
handler: (e, n) => {
|
|
335
|
+
const t = e.get(_), r = e.get(x), i = e.get(P);
|
|
336
|
+
if (!n)
|
|
337
|
+
return !1;
|
|
338
|
+
const { drawings: o } = n, a = i.getBatchUpdateOp(o), { unitId: s, subUnitId: c, undo: d, redo: m, objects: u } = a;
|
|
339
|
+
return t.syncExecuteCommand(h.id, { unitId: s, subUnitId: c, op: m, objects: u, type: I.UPDATE }) ? (r.pushUndoRedo({
|
|
340
|
+
unitID: s,
|
|
341
|
+
undoMutations: [
|
|
342
|
+
{ id: h.id, params: { unitId: s, subUnitId: c, op: d, objects: u, type: I.UPDATE } },
|
|
343
|
+
{ id: S.id, params: [s] }
|
|
344
|
+
],
|
|
345
|
+
redoMutations: [
|
|
346
|
+
{ id: h.id, params: { unitId: s, subUnitId: c, op: m, objects: u, type: I.UPDATE } },
|
|
347
|
+
{ id: S.id, params: [s] }
|
|
348
|
+
]
|
|
349
|
+
}), !0) : !1;
|
|
350
|
+
}
|
|
351
|
+
}, zn = (e) => {
|
|
352
|
+
N(_);
|
|
353
|
+
const n = N(Q), t = N(L), r = N(X), { drawings: i } = e, o = i[0];
|
|
354
|
+
if (o == null)
|
|
355
|
+
return;
|
|
356
|
+
const { unitId: a } = o, s = r.getRenderById(a), c = s == null ? void 0 : s.scene;
|
|
357
|
+
if (c == null)
|
|
358
|
+
return;
|
|
359
|
+
const d = c.getTransformerByCreate(), [m, u] = te(!0);
|
|
360
|
+
te("");
|
|
361
|
+
function l(p, f) {
|
|
362
|
+
const v = [];
|
|
363
|
+
return p.forEach((O) => {
|
|
364
|
+
const { oKey: U } = O;
|
|
365
|
+
if (f.getDrawingOKey(U) == null)
|
|
366
|
+
return v.push(null), !0;
|
|
367
|
+
}), v;
|
|
368
|
+
}
|
|
369
|
+
Pe(() => {
|
|
370
|
+
const p = d.onClearControlObservable.add((v) => {
|
|
371
|
+
v === !0 && u(!1);
|
|
372
|
+
}), f = d.onChangeStartObservable.add((v) => {
|
|
373
|
+
const { objects: O } = v;
|
|
374
|
+
l(O, t);
|
|
375
|
+
});
|
|
376
|
+
return () => {
|
|
377
|
+
f == null || f.dispose(), p == null || p.dispose();
|
|
378
|
+
};
|
|
379
|
+
}, []);
|
|
380
|
+
const g = (p) => p ? "block" : "none";
|
|
381
|
+
return /* @__PURE__ */ M.createElement("div", { className: H(y.imageCommonPanelGrid, y.imageCommonPanelBorder), style: { display: g(m) } }, /* @__PURE__ */ M.createElement("div", { className: y.imageCommonPanelRow }, /* @__PURE__ */ M.createElement("div", { className: H(y.imageCommonPanelColumn, y.imageCommonPanelTitle) }, /* @__PURE__ */ M.createElement("div", null, n.t("drawing-anchor.title")))), /* @__PURE__ */ M.createElement("div", { className: H(y.imageCommonPanelRow) }, /* @__PURE__ */ M.createElement("div", { className: H(y.imageCommonPanelColumn) })));
|
|
382
|
+
}, Zn = () => {
|
|
383
|
+
const e = N(L), n = e.getFocusDrawings();
|
|
384
|
+
if (n == null || n.length === 0)
|
|
385
|
+
return;
|
|
386
|
+
const [t, r] = te(n);
|
|
387
|
+
return Pe(() => {
|
|
388
|
+
const i = e.focus$.subscribe((o) => {
|
|
389
|
+
r(o);
|
|
390
|
+
});
|
|
391
|
+
return () => {
|
|
392
|
+
i.unsubscribe();
|
|
393
|
+
};
|
|
394
|
+
}, []), /* @__PURE__ */ M.createElement("div", { className: y.imageCommonPanel }, /* @__PURE__ */ M.createElement(on, { drawings: t }), /* @__PURE__ */ M.createElement(zn, { drawings: t }));
|
|
395
|
+
}, F = {
|
|
396
|
+
id: "doc.command.move-drawing",
|
|
397
|
+
type: C.COMMAND,
|
|
398
|
+
handler: (e, n) => {
|
|
399
|
+
const t = e.get(_), r = e.get(P), { direction: i } = n, o = r.getFocusDrawings();
|
|
400
|
+
if (o.length === 0)
|
|
401
|
+
return !1;
|
|
402
|
+
const a = o[0].unitId, s = o.map((d) => {
|
|
403
|
+
const { transform: m } = d;
|
|
404
|
+
if (m == null)
|
|
405
|
+
return null;
|
|
406
|
+
const u = { ...m }, { left: l = 0, top: g = 0 } = m;
|
|
407
|
+
return i === E.UP ? u.top = g - 1 : i === E.DOWN ? u.top = g + 1 : i === E.LEFT ? u.left = l - 1 : i === E.RIGHT && (u.left = l + 1), {
|
|
408
|
+
...d,
|
|
409
|
+
transform: u,
|
|
410
|
+
docTransform: we(u)
|
|
411
|
+
};
|
|
412
|
+
}).filter((d) => d != null);
|
|
413
|
+
return t.syncExecuteCommand(se.id, {
|
|
414
|
+
unitId: a,
|
|
415
|
+
drawings: s
|
|
416
|
+
}) ? (t.syncExecuteCommand(S.id, [a]), !0) : !1;
|
|
417
|
+
}
|
|
418
|
+
}, Le = {
|
|
419
|
+
id: "doc.command.delete-drawing",
|
|
420
|
+
type: C.COMMAND,
|
|
421
|
+
handler: (e) => {
|
|
422
|
+
const n = e.get(_), r = e.get(P).getFocusDrawings();
|
|
423
|
+
if (r.length === 0)
|
|
424
|
+
return !1;
|
|
425
|
+
const i = r[0].unitId, o = r.map((a) => {
|
|
426
|
+
const { unitId: s, subUnitId: c, drawingId: d, drawingType: m } = a;
|
|
427
|
+
return {
|
|
428
|
+
unitId: s,
|
|
429
|
+
subUnitId: c,
|
|
430
|
+
drawingId: d,
|
|
431
|
+
drawingType: m
|
|
432
|
+
};
|
|
433
|
+
});
|
|
434
|
+
return n.executeCommand(ae.id, {
|
|
435
|
+
unitId: i,
|
|
436
|
+
drawings: o
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}, Ge = {
|
|
440
|
+
id: "doc.command.set-drawing-arrange",
|
|
441
|
+
type: C.COMMAND,
|
|
442
|
+
handler: (e, n) => {
|
|
443
|
+
const t = e.get(_), r = e.get(x);
|
|
444
|
+
if (!n)
|
|
445
|
+
return !1;
|
|
446
|
+
const i = e.get(P), { unitId: o, subUnitId: a, drawingIds: s, arrangeType: c } = n, d = { unitId: o, subUnitId: a, drawingIds: s };
|
|
447
|
+
let m;
|
|
448
|
+
if (c === B.forward ? m = i.getForwardDrawingsOp(d) : c === B.backward ? m = i.getBackwardDrawingOp(d) : c === B.front ? m = i.getFrontDrawingsOp(d) : c === B.back && (m = i.getBackDrawingsOp(d)), m == null)
|
|
449
|
+
return !1;
|
|
450
|
+
const { objects: u, redo: l, undo: g } = m;
|
|
451
|
+
return t.syncExecuteCommand(h.id, { op: l, unitId: o, subUnitId: a, objects: u, type: I.ARRANGE }) ? (r.pushUndoRedo({
|
|
452
|
+
unitID: o,
|
|
453
|
+
undoMutations: [
|
|
454
|
+
{ id: h.id, params: { op: g, unitId: o, subUnitId: a, objects: u, type: I.ARRANGE } }
|
|
455
|
+
],
|
|
456
|
+
redoMutations: [
|
|
457
|
+
{ id: h.id, params: { op: l, unitId: o, subUnitId: a, objects: u, type: I.ARRANGE } }
|
|
458
|
+
]
|
|
459
|
+
}), !0) : !1;
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
function qn(e) {
|
|
463
|
+
const n = [];
|
|
464
|
+
return e.forEach((t) => {
|
|
465
|
+
const { parent: r, children: i } = t, { unitId: o, subUnitId: a, drawingId: s } = r, c = Qe(0, 0, i.map((u) => u.transform || {})), d = i.map((u) => {
|
|
466
|
+
const l = u.transform || { left: 0, top: 0 }, { unitId: g, subUnitId: p, drawingId: f } = u;
|
|
467
|
+
return {
|
|
468
|
+
unitId: g,
|
|
469
|
+
subUnitId: p,
|
|
470
|
+
drawingId: f,
|
|
471
|
+
transform: {
|
|
472
|
+
...l,
|
|
473
|
+
left: l.left - c.left,
|
|
474
|
+
top: l.top - c.top
|
|
475
|
+
},
|
|
476
|
+
groupId: s
|
|
477
|
+
};
|
|
478
|
+
}), m = {
|
|
479
|
+
unitId: o,
|
|
480
|
+
subUnitId: a,
|
|
481
|
+
drawingId: s,
|
|
482
|
+
drawingType: oe.DRAWING_GROUP,
|
|
483
|
+
transform: c
|
|
484
|
+
};
|
|
485
|
+
n.push({
|
|
486
|
+
parent: m,
|
|
487
|
+
children: d
|
|
488
|
+
});
|
|
489
|
+
}), n;
|
|
490
|
+
}
|
|
491
|
+
function Yn(e) {
|
|
492
|
+
const n = [];
|
|
493
|
+
return e.forEach((t) => {
|
|
494
|
+
const { parent: r, children: i } = t, { unitId: o, subUnitId: a, drawingId: s, transform: c = { width: 0, height: 0 } } = r;
|
|
495
|
+
if (c == null)
|
|
496
|
+
return;
|
|
497
|
+
const d = i.map((u) => {
|
|
498
|
+
const { transform: l } = u, { unitId: g, subUnitId: p, drawingId: f } = u, v = Xe(l || {}, c, c.width || 0, c.height || 0);
|
|
499
|
+
return {
|
|
500
|
+
unitId: g,
|
|
501
|
+
subUnitId: p,
|
|
502
|
+
drawingId: f,
|
|
503
|
+
transform: v,
|
|
504
|
+
groupId: void 0
|
|
505
|
+
};
|
|
506
|
+
}), m = {
|
|
507
|
+
unitId: o,
|
|
508
|
+
subUnitId: a,
|
|
509
|
+
drawingId: s,
|
|
510
|
+
drawingType: oe.DRAWING_GROUP,
|
|
511
|
+
transform: {
|
|
512
|
+
left: 0,
|
|
513
|
+
top: 0
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
n.push({
|
|
517
|
+
parent: m,
|
|
518
|
+
children: d
|
|
519
|
+
});
|
|
520
|
+
}), n;
|
|
521
|
+
}
|
|
522
|
+
const je = {
|
|
523
|
+
id: "doc.command.ungroup-doc-image",
|
|
524
|
+
type: C.COMMAND,
|
|
525
|
+
handler: (e, n) => {
|
|
526
|
+
const t = e.get(_), r = e.get(x), i = e.get(P);
|
|
527
|
+
if (!n)
|
|
528
|
+
return !1;
|
|
529
|
+
const o = [];
|
|
530
|
+
n.forEach(({ parent: g, children: p }) => {
|
|
531
|
+
o.push(g.unitId), p.forEach((f) => {
|
|
532
|
+
o.push(f.unitId);
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
const a = i.getUngroupDrawingOp(n), { unitId: s, subUnitId: c, undo: d, redo: m, objects: u } = a;
|
|
536
|
+
return t.syncExecuteCommand(h.id, { op: m, unitId: s, subUnitId: c, objects: u, type: I.UNGROUP }) ? (r.pushUndoRedo({
|
|
537
|
+
unitID: s,
|
|
538
|
+
undoMutations: [
|
|
539
|
+
{ id: h.id, params: { op: d, unitId: s, subUnitId: c, objects: qn(u), type: I.GROUP } },
|
|
540
|
+
{ id: S.id, params: o }
|
|
541
|
+
],
|
|
542
|
+
redoMutations: [
|
|
543
|
+
{ id: h.id, params: { op: m, unitId: s, subUnitId: c, objects: u, type: I.UNGROUP } },
|
|
544
|
+
{ id: S.id, params: o }
|
|
545
|
+
]
|
|
546
|
+
}), !0) : !1;
|
|
547
|
+
}
|
|
548
|
+
}, We = {
|
|
549
|
+
id: "doc.command.group-doc-image",
|
|
550
|
+
type: C.COMMAND,
|
|
551
|
+
handler: (e, n) => {
|
|
552
|
+
const t = e.get(_), r = e.get(x), i = e.get(P);
|
|
553
|
+
if (!n)
|
|
554
|
+
return !1;
|
|
555
|
+
const o = [];
|
|
556
|
+
n.forEach(({ parent: g, children: p }) => {
|
|
557
|
+
o.push(g.unitId), p.forEach((f) => {
|
|
558
|
+
o.push(f.unitId);
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
const a = i.getGroupDrawingOp(n), { unitId: s, subUnitId: c, undo: d, redo: m, objects: u } = a;
|
|
562
|
+
return t.syncExecuteCommand(h.id, { op: m, unitId: s, subUnitId: c, objects: u, type: I.GROUP }) ? (r.pushUndoRedo({
|
|
563
|
+
unitID: s,
|
|
564
|
+
undoMutations: [
|
|
565
|
+
{ id: h.id, params: { op: d, unitId: s, subUnitId: c, objects: Yn(u), type: I.UNGROUP } },
|
|
566
|
+
{ id: S.id, params: o }
|
|
567
|
+
],
|
|
568
|
+
redoMutations: [
|
|
569
|
+
{ id: h.id, params: { op: m, unitId: s, subUnitId: c, objects: u, type: I.GROUP } },
|
|
570
|
+
{ id: S.id, params: o }
|
|
571
|
+
]
|
|
572
|
+
}), !0) : !1;
|
|
573
|
+
}
|
|
574
|
+
}, Fe = {
|
|
575
|
+
id: "doc.command.insert-doc-image",
|
|
576
|
+
type: C.COMMAND,
|
|
577
|
+
handler: (e, n) => {
|
|
578
|
+
const t = e.get(_), r = e.get(x), i = e.get(P);
|
|
579
|
+
if (!n)
|
|
580
|
+
return !1;
|
|
581
|
+
const o = n.drawings, a = o.map((p) => p.unitId), s = i.getBatchAddOp(o), { unitId: c, subUnitId: d, undo: m, redo: u, objects: l } = s;
|
|
582
|
+
return t.syncExecuteCommand(h.id, { op: u, unitId: c, subUnitId: d, objects: l, type: I.INSERT }) ? (r.pushUndoRedo({
|
|
583
|
+
unitID: c,
|
|
584
|
+
undoMutations: [
|
|
585
|
+
{ id: h.id, params: { op: m, unitId: c, subUnitId: d, objects: l, type: I.REMOVE } },
|
|
586
|
+
{ id: S.id, params: a }
|
|
587
|
+
],
|
|
588
|
+
redoMutations: [
|
|
589
|
+
{ id: h.id, params: { op: u, unitId: c, subUnitId: d, objects: l, type: I.INSERT } },
|
|
590
|
+
{ id: S.id, params: a }
|
|
591
|
+
]
|
|
592
|
+
}), !0) : !1;
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
function V(e) {
|
|
596
|
+
return !e.getContextValue(Ke) && e.getContextValue(Y);
|
|
597
|
+
}
|
|
598
|
+
const Qn = {
|
|
599
|
+
id: F.id,
|
|
600
|
+
description: "shortcut.doc.drawing-move-down",
|
|
601
|
+
group: "4_doc-drawing-view",
|
|
602
|
+
binding: A.ARROW_DOWN,
|
|
603
|
+
priority: 100,
|
|
604
|
+
preconditions: V,
|
|
605
|
+
staticParameters: {
|
|
606
|
+
direction: E.DOWN
|
|
607
|
+
}
|
|
608
|
+
}, Xn = {
|
|
609
|
+
id: F.id,
|
|
610
|
+
description: "shortcut.doc.drawing-move-up",
|
|
611
|
+
group: "4_doc-drawing-view",
|
|
612
|
+
binding: A.ARROW_UP,
|
|
613
|
+
priority: 100,
|
|
614
|
+
preconditions: V,
|
|
615
|
+
staticParameters: {
|
|
616
|
+
direction: E.UP
|
|
617
|
+
}
|
|
618
|
+
}, Jn = {
|
|
619
|
+
id: F.id,
|
|
620
|
+
description: "shortcut.doc.drawing-move-left",
|
|
621
|
+
group: "4_doc-drawing-view",
|
|
622
|
+
binding: A.ARROW_LEFT,
|
|
623
|
+
priority: 100,
|
|
624
|
+
preconditions: V,
|
|
625
|
+
staticParameters: {
|
|
626
|
+
direction: E.LEFT
|
|
627
|
+
}
|
|
628
|
+
}, et = {
|
|
629
|
+
id: F.id,
|
|
630
|
+
description: "shortcut.doc.drawing-move-right",
|
|
631
|
+
group: "4_doc-drawing-view",
|
|
632
|
+
binding: A.ARROW_RIGHT,
|
|
633
|
+
priority: 100,
|
|
634
|
+
preconditions: V,
|
|
635
|
+
staticParameters: {
|
|
636
|
+
direction: E.RIGHT
|
|
637
|
+
}
|
|
638
|
+
}, nt = {
|
|
639
|
+
id: Le.id,
|
|
640
|
+
description: "shortcut.doc.drawing-delete",
|
|
641
|
+
group: "4_doc-drawing-view",
|
|
642
|
+
// when focusing on any other input tag do not trigger this shortcut
|
|
643
|
+
preconditions: V,
|
|
644
|
+
binding: A.DELETE,
|
|
645
|
+
mac: A.BACKSPACE
|
|
646
|
+
};
|
|
647
|
+
var tt = Object.defineProperty, rt = Object.getOwnPropertyDescriptor, it = (e, n, t, r) => {
|
|
648
|
+
for (var i = r > 1 ? void 0 : r ? rt(n, t) : n, o = e.length - 1, a; o >= 0; o--)
|
|
649
|
+
(a = e[o]) && (i = (r ? a(n, t, i) : a(i)) || i);
|
|
650
|
+
return r && i && tt(n, t, i), i;
|
|
651
|
+
}, W = (e, n) => (t, r) => n(t, r, e);
|
|
652
|
+
let Z = class extends ve {
|
|
653
|
+
constructor(e, n, t, r, i) {
|
|
654
|
+
super(), this._injector = e, this._componentManager = n, this._menuService = t, this._commandService = r, this._shortcutService = i, this._init();
|
|
655
|
+
}
|
|
656
|
+
_initCustomComponents() {
|
|
657
|
+
const e = this._componentManager;
|
|
658
|
+
this.disposeWithMe(e.register(Ae, Te)), this.disposeWithMe(e.register(Ne, Rn)), this.disposeWithMe(e.register(ye, Zn));
|
|
659
|
+
}
|
|
660
|
+
_initMenus() {
|
|
661
|
+
[
|
|
662
|
+
Un,
|
|
663
|
+
Tn
|
|
664
|
+
].forEach((e) => {
|
|
665
|
+
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e), {}));
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
_initCommands() {
|
|
669
|
+
[
|
|
670
|
+
J,
|
|
671
|
+
Fe,
|
|
672
|
+
ae,
|
|
673
|
+
se,
|
|
674
|
+
Ee,
|
|
675
|
+
S,
|
|
676
|
+
be,
|
|
677
|
+
We,
|
|
678
|
+
je,
|
|
679
|
+
F,
|
|
680
|
+
Le,
|
|
681
|
+
Ge
|
|
682
|
+
].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e)));
|
|
683
|
+
}
|
|
684
|
+
_initShortcuts() {
|
|
685
|
+
[
|
|
686
|
+
// sheet drawing shortcuts
|
|
687
|
+
Qn,
|
|
688
|
+
Xn,
|
|
689
|
+
Jn,
|
|
690
|
+
et,
|
|
691
|
+
nt
|
|
692
|
+
].forEach((e) => {
|
|
693
|
+
this.disposeWithMe(this._shortcutService.registerShortcut(e));
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
_init() {
|
|
697
|
+
this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
Z = it([
|
|
701
|
+
re(ie.Ready, Z),
|
|
702
|
+
W(0, b(_e)),
|
|
703
|
+
W(1, b(pn)),
|
|
704
|
+
W(2, fn),
|
|
705
|
+
W(3, _),
|
|
706
|
+
W(4, hn)
|
|
707
|
+
], Z);
|
|
708
|
+
var ot = Object.defineProperty, at = Object.getOwnPropertyDescriptor, st = (e, n, t, r) => {
|
|
709
|
+
for (var i = r > 1 ? void 0 : r ? at(n, t) : n, o = e.length - 1, a; o >= 0; o--)
|
|
710
|
+
(a = e[o]) && (i = (r ? a(n, t, i) : a(i)) || i);
|
|
711
|
+
return r && i && ot(n, t, i), i;
|
|
712
|
+
}, D = (e, n) => (t, r) => n(t, r, e);
|
|
713
|
+
let q = class extends ve {
|
|
714
|
+
constructor(e, n, t, r, i, o, a, s, c, d, m) {
|
|
715
|
+
super(), this._commandService = e, this._univerInstanceService = n, this._textSelectionManagerService = t, this._imageIoService = r, this._sheetDrawingService = i, this._drawingManagerService = o, this._contextService = a, this._messageService = s, this._localeService = c, this._docSkeletonManagerService = d, this._renderManagerService = m, this._init();
|
|
716
|
+
}
|
|
717
|
+
_init() {
|
|
718
|
+
this._initCommandListeners(), this._updateDrawingListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener();
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Upload image to cell or float image
|
|
722
|
+
*/
|
|
723
|
+
_initCommandListeners() {
|
|
724
|
+
this.disposeWithMe(
|
|
725
|
+
this._commandService.onCommandExecuted(async (e) => {
|
|
726
|
+
if (e.id === J.id) {
|
|
727
|
+
const n = e.params;
|
|
728
|
+
if (n.files == null)
|
|
729
|
+
return;
|
|
730
|
+
const t = n.files.length;
|
|
731
|
+
if (t > ue) {
|
|
732
|
+
this._messageService.show({
|
|
733
|
+
type: k.Error,
|
|
734
|
+
content: this._localeService.t("update-status.exceedMaxCount", String(ue))
|
|
735
|
+
});
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
this._imageIoService.setWaitCount(t), n.files.forEach(async (r) => {
|
|
739
|
+
await this._insertFloatImage(r);
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
})
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
async _insertFloatImage(e) {
|
|
746
|
+
var U;
|
|
747
|
+
let n;
|
|
748
|
+
try {
|
|
749
|
+
n = await this._imageIoService.saveImage(e);
|
|
750
|
+
} catch (G) {
|
|
751
|
+
const T = G.message;
|
|
752
|
+
T === ne.ERROR_EXCEED_SIZE ? this._messageService.show({
|
|
753
|
+
type: k.Error,
|
|
754
|
+
content: this._localeService.t("update-status.exceedMaxSize", String(cn / (1024 * 1024)))
|
|
755
|
+
}) : T === ne.ERROR_IMAGE_TYPE ? this._messageService.show({
|
|
756
|
+
type: k.Error,
|
|
757
|
+
content: this._localeService.t("update-status.invalidImageType")
|
|
758
|
+
}) : T === ne.ERROR_IMAGE && this._messageService.show({
|
|
759
|
+
type: k.Error,
|
|
760
|
+
content: this._localeService.t("update-status.invalidImage")
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
if (n == null)
|
|
764
|
+
return;
|
|
765
|
+
const t = this._getUnitInfo();
|
|
766
|
+
if (t == null)
|
|
767
|
+
return;
|
|
768
|
+
const { unitId: r, subUnitId: i } = t, { imageId: o, imageSourceType: a, source: s, base64Cache: c } = n, { width: d, height: m, image: u } = await dn(c || ""), l = this._renderManagerService.getRenderById(r);
|
|
769
|
+
if (l == null)
|
|
770
|
+
return;
|
|
771
|
+
const { width: g, height: p } = l.scene;
|
|
772
|
+
this._imageIoService.addImageSourceCache(o, a, u);
|
|
773
|
+
let f = 1;
|
|
774
|
+
if (d > me || m > le) {
|
|
775
|
+
const G = me / d, T = le / m;
|
|
776
|
+
f = Math.max(G, T);
|
|
777
|
+
}
|
|
778
|
+
const v = this._getImagePosition(d * f, m * f, g, p);
|
|
779
|
+
if (v == null)
|
|
780
|
+
return;
|
|
781
|
+
const O = {
|
|
782
|
+
unitId: r,
|
|
783
|
+
subUnitId: i,
|
|
784
|
+
drawingId: o,
|
|
785
|
+
drawingType: oe.DRAWING_IMAGE,
|
|
786
|
+
imageSourceType: a,
|
|
787
|
+
source: s,
|
|
788
|
+
transform: de(v),
|
|
789
|
+
docTransform: v,
|
|
790
|
+
title: "",
|
|
791
|
+
description: "",
|
|
792
|
+
layoutType: ze.WRAP_SQUARE
|
|
793
|
+
};
|
|
794
|
+
this._commandService.executeCommand(Fe.id, {
|
|
795
|
+
unitId: r,
|
|
796
|
+
drawings: [O]
|
|
797
|
+
}), (U = this._docSkeletonManagerService.getCurrent()) == null || U.skeleton.calculate();
|
|
798
|
+
}
|
|
799
|
+
_getUnitInfo() {
|
|
800
|
+
const e = this._univerInstanceService.getCurrentUnitForType(R.UNIVER_DOC);
|
|
801
|
+
if (e == null)
|
|
802
|
+
return;
|
|
803
|
+
const n = e.getUnitId();
|
|
804
|
+
return {
|
|
805
|
+
unitId: n,
|
|
806
|
+
subUnitId: n
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
_getImagePosition(e, n, t, r) {
|
|
810
|
+
const i = this._textSelectionManagerService.getActiveTextRange(), o = (i == null ? void 0 : i.getAbsolutePosition()) || {
|
|
811
|
+
left: 0,
|
|
812
|
+
top: 0
|
|
813
|
+
};
|
|
814
|
+
return {
|
|
815
|
+
size: {
|
|
816
|
+
width: e,
|
|
817
|
+
height: n
|
|
818
|
+
},
|
|
819
|
+
positionH: {
|
|
820
|
+
relativeFrom: Ze.MARGIN,
|
|
821
|
+
posOffset: o.left
|
|
822
|
+
},
|
|
823
|
+
positionV: {
|
|
824
|
+
relativeFrom: qe.PAGE,
|
|
825
|
+
posOffset: o.top
|
|
826
|
+
},
|
|
827
|
+
angle: 0
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
_updateOrderListener() {
|
|
831
|
+
this._drawingManagerService.featurePluginOrderUpdate$.subscribe((e) => {
|
|
832
|
+
const { unitId: n, subUnitId: t, drawingIds: r, arrangeType: i } = e;
|
|
833
|
+
this._commandService.executeCommand(Ge.id, {
|
|
834
|
+
unitId: n,
|
|
835
|
+
subUnitId: t,
|
|
836
|
+
drawingIds: r,
|
|
837
|
+
arrangeType: i
|
|
838
|
+
});
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
_updateDrawingListener() {
|
|
842
|
+
this._drawingManagerService.featurePluginUpdate$.subscribe((e) => {
|
|
843
|
+
const n = [];
|
|
844
|
+
e.length !== 0 && (e.forEach((t) => {
|
|
845
|
+
const { unitId: r, subUnitId: i, drawingId: o, drawingType: a, transform: s } = t;
|
|
846
|
+
if (s == null)
|
|
847
|
+
return;
|
|
848
|
+
const c = this._sheetDrawingService.getDrawingByParam({ unitId: r, subUnitId: i, drawingId: o });
|
|
849
|
+
if (c == null)
|
|
850
|
+
return;
|
|
851
|
+
const d = we({ ...c.transform, ...s });
|
|
852
|
+
if (d == null)
|
|
853
|
+
return;
|
|
854
|
+
const m = {
|
|
855
|
+
...t,
|
|
856
|
+
transform: { ...s, ...de(d) },
|
|
857
|
+
docTransform: { ...d }
|
|
858
|
+
};
|
|
859
|
+
n.push(m);
|
|
860
|
+
}), n.length > 0 && (this._commandService.syncExecuteCommand(se.id, {
|
|
861
|
+
unitId: e[0].unitId,
|
|
862
|
+
drawings: n
|
|
863
|
+
}), this._refreshDocSkeleton()));
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
_getDocsOffsetInfo() {
|
|
867
|
+
const e = this._docSkeletonManagerService.getCurrent();
|
|
868
|
+
if (e == null)
|
|
869
|
+
return {
|
|
870
|
+
pageMarginCache: /* @__PURE__ */ new Map(),
|
|
871
|
+
docsLeft: 0,
|
|
872
|
+
docsTop: 0
|
|
873
|
+
};
|
|
874
|
+
const { unitId: n, skeleton: t } = e, r = this._renderManagerService.getRenderById(n), i = t == null ? void 0 : t.getSkeletonData();
|
|
875
|
+
if (r == null || !i)
|
|
876
|
+
return {
|
|
877
|
+
pageMarginCache: /* @__PURE__ */ new Map(),
|
|
878
|
+
docsLeft: 0,
|
|
879
|
+
docsTop: 0
|
|
880
|
+
};
|
|
881
|
+
const { mainComponent: o } = r, a = o, { left: s, top: c, pageLayoutType: d, pageMarginLeft: m, pageMarginTop: u } = a, { pages: l } = i, g = new Je(), p = /* @__PURE__ */ new Map();
|
|
882
|
+
for (let f = 0, v = l.length; f < v; f++) {
|
|
883
|
+
const O = l[f], { skeDrawings: U, marginLeft: G, marginTop: T } = O;
|
|
884
|
+
g.translatePagePadding(O), U.forEach((Ve) => {
|
|
885
|
+
const { aLeft: lt, aTop: gt, height: pt, width: ft, drawingId: $e, drawingOrigin: ht } = Ve;
|
|
886
|
+
p.set($e, {
|
|
887
|
+
marginLeft: g.x,
|
|
888
|
+
marginTop: g.y
|
|
889
|
+
});
|
|
890
|
+
}), g.restorePagePadding(O), g.translatePage(O, d, m, u);
|
|
891
|
+
}
|
|
892
|
+
return { pageMarginCache: p, docsLeft: s, docsTop: c };
|
|
893
|
+
}
|
|
894
|
+
_refreshDocSkeleton() {
|
|
895
|
+
const e = this._docSkeletonManagerService.getCurrent();
|
|
896
|
+
if (e == null)
|
|
897
|
+
return;
|
|
898
|
+
const { unitId: n, skeleton: t } = e, r = this._renderManagerService.getRenderById(n);
|
|
899
|
+
if (r == null)
|
|
900
|
+
return;
|
|
901
|
+
const { mainComponent: i } = r;
|
|
902
|
+
t == null || t.calculate(), i == null || i.makeDirty();
|
|
903
|
+
}
|
|
904
|
+
_groupDrawingListener() {
|
|
905
|
+
this._drawingManagerService.featurePluginGroupUpdate$.subscribe((e) => {
|
|
906
|
+
this._commandService.executeCommand(We.id, e);
|
|
907
|
+
}), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((e) => {
|
|
908
|
+
this._commandService.executeCommand(je.id, e);
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
_focusDrawingListener() {
|
|
912
|
+
this.disposeWithMe(
|
|
913
|
+
this._drawingManagerService.focus$.subscribe((e) => {
|
|
914
|
+
e == null || e.length === 0 ? (this._contextService.setContextValue(Y, !1), this._sheetDrawingService.focusDrawing([])) : (this._contextService.setContextValue(Y, !0), this._sheetDrawingService.focusDrawing(e));
|
|
915
|
+
})
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
q = st([
|
|
920
|
+
re(ie.Rendered, q),
|
|
921
|
+
D(0, _),
|
|
922
|
+
D(1, he),
|
|
923
|
+
D(2, b(vn)),
|
|
924
|
+
D(3, un),
|
|
925
|
+
D(4, P),
|
|
926
|
+
D(5, L),
|
|
927
|
+
D(6, Ie),
|
|
928
|
+
D(7, In),
|
|
929
|
+
D(8, b(Q)),
|
|
930
|
+
D(9, b(_n)),
|
|
931
|
+
D(10, X)
|
|
932
|
+
], q);
|
|
933
|
+
var ct = Object.defineProperty, dt = Object.getOwnPropertyDescriptor, ut = (e, n, t, r) => {
|
|
934
|
+
for (var i = r > 1 ? void 0 : r ? dt(n, t) : n, o = e.length - 1, a; o >= 0; o--)
|
|
935
|
+
(a = e[o]) && (i = (r ? a(n, t, i) : a(i)) || i);
|
|
936
|
+
return r && i && ct(n, t, i), i;
|
|
937
|
+
}, pe = (e, n) => (t, r) => n(t, r, e);
|
|
938
|
+
const mt = "Docs_Drawing_UI_PLUGIN";
|
|
939
|
+
var K;
|
|
940
|
+
let fe = (K = class extends Ye {
|
|
941
|
+
constructor(e, n, t) {
|
|
942
|
+
super(), this._injector = n, this._localeService = t;
|
|
943
|
+
}
|
|
944
|
+
onStarting(e) {
|
|
945
|
+
this._initDependencies(e);
|
|
946
|
+
}
|
|
947
|
+
_initDependencies(e) {
|
|
948
|
+
[
|
|
949
|
+
// services
|
|
950
|
+
// controllers
|
|
951
|
+
[Z],
|
|
952
|
+
[q],
|
|
953
|
+
[z]
|
|
954
|
+
].forEach((t) => e.add(t));
|
|
955
|
+
}
|
|
956
|
+
}, $(K, "type", R.UNIVER_DOC), $(K, "pluginName", mt), K);
|
|
957
|
+
fe = ut([
|
|
958
|
+
pe(1, b(_e)),
|
|
959
|
+
pe(2, b(Q))
|
|
960
|
+
], fe);
|
|
961
|
+
export {
|
|
962
|
+
fe as UniverDocsDrawingUIPlugin
|
|
963
|
+
};
|