@univerjs/docs-drawing-ui 0.1.13-nightly.202406041140
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 -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 $e = (e, n, t) => n in e ? Be(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
|
|
3
|
+
var V = (e, n, t) => ($e(e, typeof n != "symbol" ? n + "" : n, t), t);
|
|
4
|
+
import { CommandType as C, ICommandService as _, IUndoRedoService as x, LocaleService as Q, RxDisposable as He, UniverInstanceType as b, toDisposable as ee, FOCUSING_COMMON_DRAWINGS as Y, OnLifecycle as ie, LifecycleStages as re, IUniverInstanceService as he, IContextService as Ie, Direction as P, 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 R, 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 y, 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 ye } from "react";
|
|
15
|
+
import $ from "clsx";
|
|
16
|
+
import { MessageType as H } 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((i) => {
|
|
24
|
+
var r, o;
|
|
25
|
+
(o = (r = t.getRenderById(i)) == null ? void 0 : r.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(_), i = e.get(x), r = e.get(y);
|
|
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 = r.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 }) ? (i.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
|
+
}, Ee = "COMPONENT_DOC_DRAWING_PANEL", Pe = {
|
|
54
|
+
id: "sidebar.operation.doc-image",
|
|
55
|
+
type: C.COMMAND,
|
|
56
|
+
handler: async (e, n) => {
|
|
57
|
+
const t = e.get(mn), i = e.get(Q), r = e.get(L);
|
|
58
|
+
switch (n.value) {
|
|
59
|
+
case "open":
|
|
60
|
+
t.open({
|
|
61
|
+
header: { title: i.t("docImage.panel.title") },
|
|
62
|
+
children: { label: Ee },
|
|
63
|
+
onClose: () => {
|
|
64
|
+
r.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
|
+
}, Re = {
|
|
77
|
+
id: "sheet.operation.edit-sheet-image",
|
|
78
|
+
type: C.OPERATION,
|
|
79
|
+
handler: (e, n) => {
|
|
80
|
+
const t = e.get(L), i = e.get(_);
|
|
81
|
+
return n == null ? !1 : (t.focusDrawing([n]), i.executeCommand(Pe.id, { value: "open" }), !0);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var wn = (e, n, t, i) => {
|
|
85
|
+
for (var r = n, o = e.length - 1, a; o >= 0; o--)
|
|
86
|
+
(a = e[o]) && (r = a(r) || r);
|
|
87
|
+
return r;
|
|
88
|
+
}, j = (e, n) => (t, i) => n(t, i, e);
|
|
89
|
+
let z = class extends He {
|
|
90
|
+
constructor(n, t, i, r, o) {
|
|
91
|
+
super();
|
|
92
|
+
V(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
|
|
93
|
+
this._drawingManagerService = n, this._canvasPopManagerService = t, this._renderManagerService = i, this._univerInstanceService = r, this._contextService = o, this._init();
|
|
94
|
+
}
|
|
95
|
+
_init() {
|
|
96
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(b.UNIVER_DOC).pipe(ce(this.dispose$)).subscribe((n) => this._create(n)), this._univerInstanceService.getTypeOfUnitDisposed$(b.UNIVER_DOC).pipe(ce(this.dispose$)).subscribe((n) => this._dispose(n)), this._univerInstanceService.getAllUnitsForType(b.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 i of t)
|
|
111
|
+
if (i 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 i = t.getTransformerByCreate();
|
|
121
|
+
if (!i)
|
|
122
|
+
return;
|
|
123
|
+
const r = [];
|
|
124
|
+
this.disposeWithMe(
|
|
125
|
+
ee(
|
|
126
|
+
i.onCreateControlObservable.add(() => {
|
|
127
|
+
if (this._hasCropObject(t))
|
|
128
|
+
return;
|
|
129
|
+
const a = i.getSelectedObjectMap();
|
|
130
|
+
if (a.size > 1) {
|
|
131
|
+
r.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
|
+
r.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
|
+
i.onClearControlObservable.add(() => {
|
|
158
|
+
r.forEach((a) => a.dispose()), this._contextService.setContextValue(Y, !1), this._drawingManagerService.focusDrawing(null);
|
|
159
|
+
})
|
|
160
|
+
)
|
|
161
|
+
), this.disposeWithMe(
|
|
162
|
+
ee(
|
|
163
|
+
i.onChangingObservable.add(() => {
|
|
164
|
+
r.forEach((a) => a.dispose());
|
|
165
|
+
})
|
|
166
|
+
)
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
_getImageMenuItems(n, t, i) {
|
|
170
|
+
return [
|
|
171
|
+
{
|
|
172
|
+
label: "image-popup.edit",
|
|
173
|
+
index: 0,
|
|
174
|
+
commandId: Re.id,
|
|
175
|
+
commandParams: { unitId: n, subUnitId: t, drawingId: i },
|
|
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: i }] },
|
|
183
|
+
disable: !1
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
label: "image-popup.crop",
|
|
187
|
+
index: 2,
|
|
188
|
+
commandId: tn.id,
|
|
189
|
+
commandParams: { unitId: n, subUnitId: t, drawingId: i },
|
|
190
|
+
disable: !1
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
label: "image-popup.reset",
|
|
194
|
+
index: 3,
|
|
195
|
+
commandId: rn.id,
|
|
196
|
+
commandParams: [{ unitId: n, subUnitId: t, drawingId: i }],
|
|
197
|
+
disable: !1
|
|
198
|
+
}
|
|
199
|
+
];
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
z = wn([
|
|
203
|
+
ie(re.Rendered, z),
|
|
204
|
+
j(0, L),
|
|
205
|
+
j(1, R(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, i = arguments.length; t < i; t++) {
|
|
213
|
+
n = arguments[t];
|
|
214
|
+
for (var r in n)
|
|
215
|
+
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
|
|
216
|
+
}
|
|
217
|
+
return e;
|
|
218
|
+
}, w.apply(this, arguments);
|
|
219
|
+
}, Sn = function(e, n) {
|
|
220
|
+
var t = {};
|
|
221
|
+
for (var i in e)
|
|
222
|
+
Object.prototype.hasOwnProperty.call(e, i) && n.indexOf(i) < 0 && (t[i] = e[i]);
|
|
223
|
+
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
224
|
+
for (var r = 0, i = Object.getOwnPropertySymbols(e); r < i.length; r++)
|
|
225
|
+
n.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(e, i[r]) && (t[i[r]] = e[i[r]]);
|
|
226
|
+
return t;
|
|
227
|
+
}, be = De(function(e, n) {
|
|
228
|
+
var t = e.icon, i = e.id, r = e.className, o = e.extend, a = Sn(e, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), c = Me("_".concat(Mn()));
|
|
229
|
+
return Ue(t, "".concat(i), { defIds: t.defIds, idSuffix: c.current }, w({ ref: n, className: s }, a), o);
|
|
230
|
+
});
|
|
231
|
+
function Ue(e, n, t, i, r) {
|
|
232
|
+
return Oe(e.tag, w(w({ key: n }, Cn(e, t, r)), i), (Dn(e, t).children || []).map(function(o, a) {
|
|
233
|
+
return Ue(o, "".concat(n, "-").concat(e.tag, "-").concat(a), t, void 0, r);
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
function Cn(e, n, t) {
|
|
237
|
+
var i = w({}, e.attrs);
|
|
238
|
+
t != null && t.colorChannel1 && i.fill === "colorChannel1" && (i.fill = t.colorChannel1);
|
|
239
|
+
var r = n.defIds;
|
|
240
|
+
return !r || r.length === 0 || (e.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + n.idSuffix), Object.entries(i).forEach(function(o) {
|
|
241
|
+
var a = o[0], s = o[1];
|
|
242
|
+
typeof s == "string" && (i[a] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(n.idSuffix, ")")));
|
|
243
|
+
})), i;
|
|
244
|
+
}
|
|
245
|
+
function Dn(e, n) {
|
|
246
|
+
var t, i = n.defIds;
|
|
247
|
+
return !i || i.length === 0 ? e : e.tag === "defs" && (!((t = e.children) === null || t === void 0) && t.length) ? w(w({}, e), { children: e.children.map(function(r) {
|
|
248
|
+
return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? w(w({}, r), { attrs: w(w({}, r.attrs), { id: r.attrs.id + n.idSuffix }) }) : r;
|
|
249
|
+
}) }) : e;
|
|
250
|
+
}
|
|
251
|
+
function Mn() {
|
|
252
|
+
return Math.random().toString(36).substring(2, 8);
|
|
253
|
+
}
|
|
254
|
+
be.displayName = "UniverIcon";
|
|
255
|
+
var On = { 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(be, Object.assign({}, e, {
|
|
257
|
+
id: "add-image-single",
|
|
258
|
+
ref: n,
|
|
259
|
+
icon: On
|
|
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
|
+
}, yn = "univer-upload-file-menu", En = "univer-upload-file-menu-input", ge = {
|
|
268
|
+
uploadFileMenu: yn,
|
|
269
|
+
uploadFileMenuInput: En
|
|
270
|
+
}, Pn = () => {
|
|
271
|
+
const e = N(_), n = Me(null), t = () => {
|
|
272
|
+
var o;
|
|
273
|
+
(o = n.current) == null || o.click();
|
|
274
|
+
}, i = sn.map((o) => `.${o.replace("image/", "")}`).join(","), r = (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: r,
|
|
288
|
+
accept: i,
|
|
289
|
+
multiple: !0
|
|
290
|
+
}
|
|
291
|
+
));
|
|
292
|
+
}, Ne = "COMPONENT_DOC_UPLOAD_FILE_MENU", Ae = "addition-and-subtraction-single", xe = "doc.menu.image";
|
|
293
|
+
function Rn(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, b.UNIVER_DOC)
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function bn(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, b.UNIVER_DOC)
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
const Un = "univer-image-common-panel", Tn = "univer-image-common-panel-grid", Nn = "univer-image-common-panel-border", An = "univer-image-common-panel-title", xn = "univer-image-common-panel-row", Ln = "univer-image-common-panel-row-vertical", Gn = "univer-image-common-panel-column", jn = "univer-image-common-panel-column-center", Wn = "univer-image-common-panel-inline", kn = "univer-image-common-panel-span2", Fn = "univer-image-common-panel-span3", Vn = "univer-image-common-panel-input", Bn = "univer-sheet-image-menu", $n = "univer-sheet-image-menu-input", E = {
|
|
317
|
+
imageCommonPanel: Un,
|
|
318
|
+
imageCommonPanelGrid: Tn,
|
|
319
|
+
imageCommonPanelBorder: Nn,
|
|
320
|
+
imageCommonPanelTitle: An,
|
|
321
|
+
imageCommonPanelRow: xn,
|
|
322
|
+
imageCommonPanelRowVertical: Ln,
|
|
323
|
+
imageCommonPanelColumn: Gn,
|
|
324
|
+
imageCommonPanelColumnCenter: jn,
|
|
325
|
+
imageCommonPanelInline: Wn,
|
|
326
|
+
imageCommonPanelSpan2: kn,
|
|
327
|
+
imageCommonPanelSpan3: Fn,
|
|
328
|
+
imageCommonPanelInput: Vn,
|
|
329
|
+
sheetImageMenu: Bn,
|
|
330
|
+
sheetImageMenuInput: $n
|
|
331
|
+
}, se = {
|
|
332
|
+
id: "doc.command.set-doc-image",
|
|
333
|
+
type: C.COMMAND,
|
|
334
|
+
handler: (e, n) => {
|
|
335
|
+
const t = e.get(_), i = e.get(x), r = e.get(y);
|
|
336
|
+
if (!n)
|
|
337
|
+
return !1;
|
|
338
|
+
const { drawings: o } = n, a = r.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 }) ? (i.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
|
+
}, Hn = (e) => {
|
|
352
|
+
N(_);
|
|
353
|
+
const n = N(Q), t = N(L), i = N(X), { drawings: r } = e, o = r[0];
|
|
354
|
+
if (o == null)
|
|
355
|
+
return;
|
|
356
|
+
const { unitId: a } = o, s = i.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
|
+
ye(() => {
|
|
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: $(E.imageCommonPanelGrid, E.imageCommonPanelBorder), style: { display: g(m) } }, /* @__PURE__ */ M.createElement("div", { className: E.imageCommonPanelRow }, /* @__PURE__ */ M.createElement("div", { className: $(E.imageCommonPanelColumn, E.imageCommonPanelTitle) }, /* @__PURE__ */ M.createElement("div", null, n.t("drawing-anchor.title")))), /* @__PURE__ */ M.createElement("div", { className: $(E.imageCommonPanelRow) }, /* @__PURE__ */ M.createElement("div", { className: $(E.imageCommonPanelColumn) })));
|
|
382
|
+
}, Kn = () => {
|
|
383
|
+
const e = N(L), n = e.getFocusDrawings();
|
|
384
|
+
if (n == null || n.length === 0)
|
|
385
|
+
return;
|
|
386
|
+
const [t, i] = te(n);
|
|
387
|
+
return ye(() => {
|
|
388
|
+
const r = e.focus$.subscribe((o) => {
|
|
389
|
+
i(o);
|
|
390
|
+
});
|
|
391
|
+
return () => {
|
|
392
|
+
r.unsubscribe();
|
|
393
|
+
};
|
|
394
|
+
}, []), /* @__PURE__ */ M.createElement("div", { className: E.imageCommonPanel }, /* @__PURE__ */ M.createElement(on, { drawings: t }), /* @__PURE__ */ M.createElement(Hn, { drawings: t }));
|
|
395
|
+
}, k = {
|
|
396
|
+
id: "doc.command.move-drawing",
|
|
397
|
+
type: C.COMMAND,
|
|
398
|
+
handler: (e, n) => {
|
|
399
|
+
const t = e.get(_), i = e.get(y), { direction: r } = n, o = i.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 r === P.UP ? u.top = g - 1 : r === P.DOWN ? u.top = g + 1 : r === P.LEFT ? u.left = l - 1 : r === P.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(_), i = e.get(y).getFocusDrawings();
|
|
423
|
+
if (i.length === 0)
|
|
424
|
+
return !1;
|
|
425
|
+
const r = i[0].unitId, o = i.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: r,
|
|
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(_), i = e.get(x);
|
|
444
|
+
if (!n)
|
|
445
|
+
return !1;
|
|
446
|
+
const r = e.get(y), { 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 = r.getForwardDrawingsOp(d) : c === B.backward ? m = r.getBackwardDrawingOp(d) : c === B.front ? m = r.getFrontDrawingsOp(d) : c === B.back && (m = r.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 }) ? (i.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 zn(e) {
|
|
463
|
+
const n = [];
|
|
464
|
+
return e.forEach((t) => {
|
|
465
|
+
const { parent: i, children: r } = t, { unitId: o, subUnitId: a, drawingId: s } = i, c = Qe(0, 0, r.map((u) => u.transform || {})), d = r.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 Zn(e) {
|
|
492
|
+
const n = [];
|
|
493
|
+
return e.forEach((t) => {
|
|
494
|
+
const { parent: i, children: r } = t, { unitId: o, subUnitId: a, drawingId: s, transform: c = { width: 0, height: 0 } } = i;
|
|
495
|
+
if (c == null)
|
|
496
|
+
return;
|
|
497
|
+
const d = r.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(_), i = e.get(x), r = e.get(y);
|
|
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 = r.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 }) ? (i.pushUndoRedo({
|
|
537
|
+
unitID: s,
|
|
538
|
+
undoMutations: [
|
|
539
|
+
{ id: h.id, params: { op: d, unitId: s, subUnitId: c, objects: zn(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(_), i = e.get(x), r = e.get(y);
|
|
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 = r.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 }) ? (i.pushUndoRedo({
|
|
563
|
+
unitID: s,
|
|
564
|
+
undoMutations: [
|
|
565
|
+
{ id: h.id, params: { op: d, unitId: s, subUnitId: c, objects: Zn(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
|
+
}, ke = {
|
|
575
|
+
id: "doc.command.insert-doc-image",
|
|
576
|
+
type: C.COMMAND,
|
|
577
|
+
handler: (e, n) => {
|
|
578
|
+
const t = e.get(_), i = e.get(x), r = e.get(y);
|
|
579
|
+
if (!n)
|
|
580
|
+
return !1;
|
|
581
|
+
const o = n.drawings, a = o.map((p) => p.unitId), s = r.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 }) ? (i.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 F(e) {
|
|
596
|
+
return !e.getContextValue(Ke) && e.getContextValue(Y);
|
|
597
|
+
}
|
|
598
|
+
const qn = {
|
|
599
|
+
id: k.id,
|
|
600
|
+
description: "shortcut.doc.drawing-move-down",
|
|
601
|
+
group: "4_doc-drawing-view",
|
|
602
|
+
binding: A.ARROW_DOWN,
|
|
603
|
+
priority: 100,
|
|
604
|
+
preconditions: F,
|
|
605
|
+
staticParameters: {
|
|
606
|
+
direction: P.DOWN
|
|
607
|
+
}
|
|
608
|
+
}, Yn = {
|
|
609
|
+
id: k.id,
|
|
610
|
+
description: "shortcut.doc.drawing-move-up",
|
|
611
|
+
group: "4_doc-drawing-view",
|
|
612
|
+
binding: A.ARROW_UP,
|
|
613
|
+
priority: 100,
|
|
614
|
+
preconditions: F,
|
|
615
|
+
staticParameters: {
|
|
616
|
+
direction: P.UP
|
|
617
|
+
}
|
|
618
|
+
}, Qn = {
|
|
619
|
+
id: k.id,
|
|
620
|
+
description: "shortcut.doc.drawing-move-left",
|
|
621
|
+
group: "4_doc-drawing-view",
|
|
622
|
+
binding: A.ARROW_LEFT,
|
|
623
|
+
priority: 100,
|
|
624
|
+
preconditions: F,
|
|
625
|
+
staticParameters: {
|
|
626
|
+
direction: P.LEFT
|
|
627
|
+
}
|
|
628
|
+
}, Xn = {
|
|
629
|
+
id: k.id,
|
|
630
|
+
description: "shortcut.doc.drawing-move-right",
|
|
631
|
+
group: "4_doc-drawing-view",
|
|
632
|
+
binding: A.ARROW_RIGHT,
|
|
633
|
+
priority: 100,
|
|
634
|
+
preconditions: F,
|
|
635
|
+
staticParameters: {
|
|
636
|
+
direction: P.RIGHT
|
|
637
|
+
}
|
|
638
|
+
}, Jn = {
|
|
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: F,
|
|
644
|
+
binding: A.DELETE,
|
|
645
|
+
mac: A.BACKSPACE
|
|
646
|
+
};
|
|
647
|
+
var et = (e, n, t, i) => {
|
|
648
|
+
for (var r = n, o = e.length - 1, a; o >= 0; o--)
|
|
649
|
+
(a = e[o]) && (r = a(r) || r);
|
|
650
|
+
return r;
|
|
651
|
+
}, W = (e, n) => (t, i) => n(t, i, e);
|
|
652
|
+
let Z = class extends ve {
|
|
653
|
+
constructor(e, n, t, i, r) {
|
|
654
|
+
super(), this._injector = e, this._componentManager = n, this._menuService = t, this._commandService = i, this._shortcutService = r, this._init();
|
|
655
|
+
}
|
|
656
|
+
_initCustomComponents() {
|
|
657
|
+
const e = this._componentManager;
|
|
658
|
+
this.disposeWithMe(e.register(Ae, Te)), this.disposeWithMe(e.register(Ne, Pn)), this.disposeWithMe(e.register(Ee, Kn));
|
|
659
|
+
}
|
|
660
|
+
_initMenus() {
|
|
661
|
+
[
|
|
662
|
+
Rn,
|
|
663
|
+
bn
|
|
664
|
+
].forEach((e) => {
|
|
665
|
+
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e), {}));
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
_initCommands() {
|
|
669
|
+
[
|
|
670
|
+
J,
|
|
671
|
+
ke,
|
|
672
|
+
ae,
|
|
673
|
+
se,
|
|
674
|
+
Pe,
|
|
675
|
+
S,
|
|
676
|
+
Re,
|
|
677
|
+
We,
|
|
678
|
+
je,
|
|
679
|
+
k,
|
|
680
|
+
Le,
|
|
681
|
+
Ge
|
|
682
|
+
].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e)));
|
|
683
|
+
}
|
|
684
|
+
_initShortcuts() {
|
|
685
|
+
[
|
|
686
|
+
// sheet drawing shortcuts
|
|
687
|
+
qn,
|
|
688
|
+
Yn,
|
|
689
|
+
Qn,
|
|
690
|
+
Xn,
|
|
691
|
+
Jn
|
|
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 = et([
|
|
701
|
+
ie(re.Ready, Z),
|
|
702
|
+
W(0, R(_e)),
|
|
703
|
+
W(1, R(pn)),
|
|
704
|
+
W(2, fn),
|
|
705
|
+
W(3, _),
|
|
706
|
+
W(4, hn)
|
|
707
|
+
], Z);
|
|
708
|
+
var nt = (e, n, t, i) => {
|
|
709
|
+
for (var r = n, o = e.length - 1, a; o >= 0; o--)
|
|
710
|
+
(a = e[o]) && (r = a(r) || r);
|
|
711
|
+
return r;
|
|
712
|
+
}, D = (e, n) => (t, i) => n(t, i, e);
|
|
713
|
+
let q = class extends ve {
|
|
714
|
+
constructor(e, n, t, i, r, o, a, s, c, d, m) {
|
|
715
|
+
super(), this._commandService = e, this._univerInstanceService = n, this._textSelectionManagerService = t, this._imageIoService = i, this._sheetDrawingService = r, 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: H.Error,
|
|
734
|
+
content: this._localeService.t("update-status.exceedMaxCount", String(ue))
|
|
735
|
+
});
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
this._imageIoService.setWaitCount(t), n.files.forEach(async (i) => {
|
|
739
|
+
await this._insertFloatImage(i);
|
|
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: H.Error,
|
|
754
|
+
content: this._localeService.t("update-status.exceedMaxSize", String(cn / (1024 * 1024)))
|
|
755
|
+
}) : T === ne.ERROR_IMAGE_TYPE ? this._messageService.show({
|
|
756
|
+
type: H.Error,
|
|
757
|
+
content: this._localeService.t("update-status.invalidImageType")
|
|
758
|
+
}) : T === ne.ERROR_IMAGE && this._messageService.show({
|
|
759
|
+
type: H.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: i, subUnitId: r } = t, { imageId: o, imageSourceType: a, source: s, base64Cache: c } = n, { width: d, height: m, image: u } = await dn(c || ""), l = this._renderManagerService.getRenderById(i);
|
|
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: i,
|
|
783
|
+
subUnitId: r,
|
|
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(ke.id, {
|
|
795
|
+
unitId: i,
|
|
796
|
+
drawings: [O]
|
|
797
|
+
}), (U = this._docSkeletonManagerService.getCurrent()) == null || U.skeleton.calculate();
|
|
798
|
+
}
|
|
799
|
+
_getUnitInfo() {
|
|
800
|
+
const e = this._univerInstanceService.getCurrentUnitForType(b.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, i) {
|
|
810
|
+
const r = this._textSelectionManagerService.getActiveTextRange(), o = (r == null ? void 0 : r.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: i, arrangeType: r } = e;
|
|
833
|
+
this._commandService.executeCommand(Ge.id, {
|
|
834
|
+
unitId: n,
|
|
835
|
+
subUnitId: t,
|
|
836
|
+
drawingIds: i,
|
|
837
|
+
arrangeType: r
|
|
838
|
+
});
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
_updateDrawingListener() {
|
|
842
|
+
this._drawingManagerService.featurePluginUpdate$.subscribe((e) => {
|
|
843
|
+
const n = [];
|
|
844
|
+
e.length !== 0 && (e.forEach((t) => {
|
|
845
|
+
const { unitId: i, subUnitId: r, drawingId: o, drawingType: a, transform: s } = t;
|
|
846
|
+
if (s == null)
|
|
847
|
+
return;
|
|
848
|
+
const c = this._sheetDrawingService.getDrawingByParam({ unitId: i, subUnitId: r, 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, i = this._renderManagerService.getRenderById(n), r = t == null ? void 0 : t.getSkeletonData();
|
|
875
|
+
if (i == null || !r)
|
|
876
|
+
return {
|
|
877
|
+
pageMarginCache: /* @__PURE__ */ new Map(),
|
|
878
|
+
docsLeft: 0,
|
|
879
|
+
docsTop: 0
|
|
880
|
+
};
|
|
881
|
+
const { mainComponent: o } = i, a = o, { left: s, top: c, pageLayoutType: d, pageMarginLeft: m, pageMarginTop: u } = a, { pages: l } = r, 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((Fe) => {
|
|
885
|
+
const { aLeft: rt, aTop: ot, height: at, width: st, drawingId: Ve, drawingOrigin: ct } = Fe;
|
|
886
|
+
p.set(Ve, {
|
|
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, i = this._renderManagerService.getRenderById(n);
|
|
899
|
+
if (i == null)
|
|
900
|
+
return;
|
|
901
|
+
const { mainComponent: r } = i;
|
|
902
|
+
t == null || t.calculate(), r == null || r.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 = nt([
|
|
920
|
+
ie(re.Rendered, q),
|
|
921
|
+
D(0, _),
|
|
922
|
+
D(1, he),
|
|
923
|
+
D(2, R(vn)),
|
|
924
|
+
D(3, un),
|
|
925
|
+
D(4, y),
|
|
926
|
+
D(5, L),
|
|
927
|
+
D(6, Ie),
|
|
928
|
+
D(7, In),
|
|
929
|
+
D(8, R(Q)),
|
|
930
|
+
D(9, R(_n)),
|
|
931
|
+
D(10, X)
|
|
932
|
+
], q);
|
|
933
|
+
var tt = (e, n, t, i) => {
|
|
934
|
+
for (var r = n, o = e.length - 1, a; o >= 0; o--)
|
|
935
|
+
(a = e[o]) && (r = a(r) || r);
|
|
936
|
+
return r;
|
|
937
|
+
}, pe = (e, n) => (t, i) => n(t, i, e);
|
|
938
|
+
const it = "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
|
+
}, V(K, "type", b.UNIVER_DOC), V(K, "pluginName", it), K);
|
|
957
|
+
fe = tt([
|
|
958
|
+
pe(1, R(_e)),
|
|
959
|
+
pe(2, R(Q))
|
|
960
|
+
], fe);
|
|
961
|
+
export {
|
|
962
|
+
fe as UniverDocsDrawingUIPlugin
|
|
963
|
+
};
|