@univerjs/ui 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +19 -15
- package/lib/es/facade.js +176 -21
- package/lib/es/index.js +3011 -3002
- package/lib/index.css +1 -1
- package/lib/types/controllers/ui/ui.controller.d.ts +12 -0
- package/lib/types/facade/f-menu-builder.d.ts +106 -0
- package/lib/types/facade/f-shortcut.d.ts +11 -0
- package/lib/types/facade/f-univer.d.ts +79 -0
- package/lib/types/facade/index.d.ts +2 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/services/clipboard/clipboard.command.d.ts +1 -0
- package/lib/types/services/dialog/desktop-dialog.service.d.ts +2 -2
- package/lib/types/services/message/__testing__/mock-message.service.d.ts +2 -2
- package/lib/types/services/message/desktop-message.service.d.ts +9 -8
- package/lib/types/services/message/message.service.d.ts +2 -5
- package/lib/types/services/parts/parts.service.d.ts +2 -1
- package/lib/types/services/shortcut/shortcut.service.d.ts +6 -1
- package/lib/types/views/components/ribbon/Button/ToolbarButton.d.ts +4 -0
- package/lib/types/views/components/ribbon/ToolbarItem.d.ts +3 -3
- package/lib/types/views/components/ribbon/TooltipButtonWrapper.d.ts +2 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +19 -15
- package/package.json +8 -9
package/lib/es/facade.js
CHANGED
|
@@ -1,49 +1,204 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var I = Object.defineProperty;
|
|
2
|
+
var P = (i, e, t) => e in i ? I(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var s = (i, e, t) => P(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Inject as g, Injector as l, ICommandService as d, FBase as v, Tools as x, CommandType as E, FUniver as f, FHooks as M } from "@univerjs/core";
|
|
5
|
+
import { IMenuManagerService as j, MenuItemType as C, RibbonStartGroup as D, RibbonPosition as O, MenuManagerPosition as T, IShortcutService as w, CopyCommand as m, PasteCommand as u, ISidebarService as B, IDialogService as F, ComponentManager as R, IMessageService as U, SheetPasteShortKeyCommandName as $ } from "@univerjs/ui";
|
|
6
|
+
var G = Object.defineProperty, N = Object.getOwnPropertyDescriptor, y = (i, e, t, r) => {
|
|
7
|
+
for (var n = r > 1 ? void 0 : r ? N(e, t) : e, o = i.length - 1, c; o >= 0; o--)
|
|
8
|
+
(c = i[o]) && (n = (r ? c(e, t, n) : c(n)) || n);
|
|
9
|
+
return r && n && G(e, t, n), n;
|
|
10
|
+
}, h = (i, e) => (t, r) => e(t, r, i), a;
|
|
11
|
+
let p = (a = class extends v {
|
|
12
|
+
constructor(e, t, r, n) {
|
|
13
|
+
super();
|
|
14
|
+
s(this, "_commandToRegister", /* @__PURE__ */ new Map());
|
|
15
|
+
s(this, "_buildingSchema");
|
|
16
|
+
this._item = e, this._injector = t, this._commandService = r, this._menuManagerService = n;
|
|
17
|
+
const o = typeof e.action == "string" ? e.action : x.generateRandomId(12);
|
|
18
|
+
o !== e.action && this._commandToRegister.set(o, e.action), this._buildingSchema = {
|
|
19
|
+
// eslint-disable-next-line ts/explicit-function-return-type
|
|
20
|
+
menuItemFactory: () => ({
|
|
21
|
+
id: e.id,
|
|
22
|
+
type: C.BUTTON,
|
|
23
|
+
// we only support button for now
|
|
24
|
+
icon: e.icon,
|
|
25
|
+
title: e.title,
|
|
26
|
+
tooltip: e.tooltip,
|
|
27
|
+
commandId: o
|
|
28
|
+
})
|
|
29
|
+
}, typeof e.order < "u" && (this._buildingSchema.order = e.order);
|
|
30
|
+
}
|
|
31
|
+
/** @ignore */
|
|
32
|
+
__getSchema() {
|
|
33
|
+
return this._commandToRegister.forEach((e, t) => {
|
|
34
|
+
this._commandService.hasCommand(t) || this._commandService.registerCommand({
|
|
35
|
+
id: t,
|
|
36
|
+
type: E.COMMAND,
|
|
37
|
+
handler: e
|
|
38
|
+
});
|
|
39
|
+
}), { [this._item.id]: this._buildingSchema };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Append the menu to any menu position on Univer UI.
|
|
43
|
+
* @param path Some predefined path to append the menu.
|
|
44
|
+
*/
|
|
45
|
+
appendTo(e) {
|
|
46
|
+
const t = this.__getSchema();
|
|
47
|
+
this._menuManagerService.mergeMenu({
|
|
48
|
+
[e]: t
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, s(a, "RibbonStartGroup", D), s(a, "RibbonPosition", O), s(a, "MenuManagerPosition", T), a);
|
|
52
|
+
p = y([
|
|
53
|
+
h(1, g(l)),
|
|
54
|
+
h(2, d),
|
|
55
|
+
h(3, j)
|
|
56
|
+
], p);
|
|
57
|
+
let S = class extends v {
|
|
58
|
+
constructor(e, t, r) {
|
|
59
|
+
super();
|
|
60
|
+
s(this, "_menuByGroups", []);
|
|
61
|
+
s(this, "_submenus", []);
|
|
62
|
+
s(this, "_buildingSchema");
|
|
63
|
+
this._item = e, this._injector = t, this._menuManagerService = r, this._buildingSchema = {
|
|
64
|
+
// eslint-disable-next-line ts/explicit-function-return-type
|
|
65
|
+
menuItemFactory: () => ({
|
|
66
|
+
id: e.id,
|
|
67
|
+
type: C.SUBITEMS,
|
|
68
|
+
icon: e.icon,
|
|
69
|
+
title: e.title,
|
|
70
|
+
tooltip: e.tooltip
|
|
71
|
+
})
|
|
72
|
+
}, typeof e.order < "u" && (this._buildingSchema.order = e.order);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Add a menu to the submenu. It can be a {@link FMenu} or a {@link FSubmenu}.
|
|
76
|
+
* @param submenu Menu to add to the submenu.
|
|
77
|
+
* @returns The FSubmenu itself for chaining calls.
|
|
78
|
+
*/
|
|
79
|
+
addSubmenu(e) {
|
|
80
|
+
return this._submenus.push(e), this;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Add a separator to the submenu.
|
|
84
|
+
* @returns The FSubmenu itself for chaining calls.
|
|
85
|
+
*/
|
|
86
|
+
addSeparator() {
|
|
87
|
+
return this._menuByGroups.push(this._submenus), this._submenus = [], this;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Append the menu to any menu position on Univer UI.
|
|
91
|
+
* @param path Some predefined path to append the menu.
|
|
92
|
+
*/
|
|
93
|
+
appendTo(e) {
|
|
94
|
+
const t = this.__getSchema();
|
|
95
|
+
this._menuManagerService.mergeMenu({
|
|
96
|
+
[e]: t
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/** @ignore */
|
|
100
|
+
__getSchema() {
|
|
101
|
+
const e = {};
|
|
102
|
+
return this.addSeparator(), this._menuByGroups.forEach((t, r) => {
|
|
103
|
+
const n = {};
|
|
104
|
+
t.forEach((o) => {
|
|
105
|
+
Object.assign(n, o.__getSchema());
|
|
106
|
+
}), e[`${this._item.id}-group-${r}`] = n;
|
|
107
|
+
}), { [this._item.id]: Object.assign(this._buildingSchema, e) };
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
S = y([
|
|
111
|
+
h(1, g(l)),
|
|
112
|
+
h(2, j)
|
|
113
|
+
], S);
|
|
114
|
+
var H = Object.defineProperty, L = Object.getOwnPropertyDescriptor, A = (i, e, t, r) => {
|
|
115
|
+
for (var n = r > 1 ? void 0 : r ? L(e, t) : e, o = i.length - 1, c; o >= 0; o--)
|
|
116
|
+
(c = i[o]) && (n = (r ? c(e, t, n) : c(n)) || n);
|
|
117
|
+
return r && n && H(e, t, n), n;
|
|
118
|
+
}, b = (i, e) => (t, r) => e(t, r, i);
|
|
119
|
+
let _ = class extends v {
|
|
120
|
+
constructor(e, t) {
|
|
121
|
+
super();
|
|
122
|
+
s(this, "_forceEscapeDisposable", null);
|
|
123
|
+
this._injector = e, this._shortcutService = t;
|
|
124
|
+
}
|
|
125
|
+
enableShortcut() {
|
|
126
|
+
var e;
|
|
127
|
+
(e = this._forceEscapeDisposable) == null || e.dispose(), this._forceEscapeDisposable = null;
|
|
128
|
+
}
|
|
129
|
+
disableShortcut() {
|
|
130
|
+
this._forceEscapeDisposable || (this._forceEscapeDisposable = this._shortcutService.forceEscape());
|
|
131
|
+
}
|
|
132
|
+
dispatchShortcutEvent(e) {
|
|
133
|
+
return this._shortcutService.dispatch(e);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
_ = A([
|
|
137
|
+
b(0, g(l)),
|
|
138
|
+
b(1, w)
|
|
139
|
+
], _);
|
|
140
|
+
class K extends f {
|
|
141
|
+
getURL() {
|
|
142
|
+
return new URL(window.location.href);
|
|
143
|
+
}
|
|
144
|
+
getShortcut() {
|
|
145
|
+
return this._injector.createInstance(_);
|
|
146
|
+
}
|
|
4
147
|
copy() {
|
|
5
|
-
return this._commandService.executeCommand(
|
|
148
|
+
return this._commandService.executeCommand(m.id);
|
|
6
149
|
}
|
|
7
150
|
paste() {
|
|
8
|
-
return this._commandService.executeCommand(
|
|
151
|
+
return this._commandService.executeCommand(u.id);
|
|
152
|
+
}
|
|
153
|
+
createMenu(e) {
|
|
154
|
+
return this._injector.createInstance(p, e);
|
|
155
|
+
}
|
|
156
|
+
createSubmenu(e) {
|
|
157
|
+
return this._injector.createInstance(S, e);
|
|
9
158
|
}
|
|
10
159
|
openSiderbar(e) {
|
|
11
|
-
return this._injector.get(
|
|
160
|
+
return this._injector.get(B).open(e);
|
|
161
|
+
}
|
|
162
|
+
openSidebar(e) {
|
|
163
|
+
return this.openSiderbar(e);
|
|
12
164
|
}
|
|
13
165
|
openDialog(e) {
|
|
14
|
-
const
|
|
166
|
+
const r = this._injector.get(F).open({
|
|
15
167
|
...e,
|
|
16
168
|
onClose: () => {
|
|
17
|
-
|
|
169
|
+
r.dispose();
|
|
18
170
|
}
|
|
19
171
|
});
|
|
20
|
-
return
|
|
172
|
+
return r;
|
|
21
173
|
}
|
|
22
174
|
getComponentManager() {
|
|
23
|
-
return this._injector.get(
|
|
175
|
+
return this._injector.get(R);
|
|
176
|
+
}
|
|
177
|
+
showMessage(e) {
|
|
178
|
+
this._injector.get(U).show(e);
|
|
24
179
|
}
|
|
25
180
|
}
|
|
26
|
-
|
|
27
|
-
class
|
|
181
|
+
f.extend(K);
|
|
182
|
+
class q extends M {
|
|
28
183
|
onBeforeCopy(e) {
|
|
29
|
-
return this._injector.get(
|
|
30
|
-
|
|
184
|
+
return this._injector.get(d).beforeCommandExecuted((r) => {
|
|
185
|
+
r.id === m.id && e();
|
|
31
186
|
});
|
|
32
187
|
}
|
|
33
188
|
onCopy(e) {
|
|
34
|
-
return this._injector.get(
|
|
35
|
-
|
|
189
|
+
return this._injector.get(d).onCommandExecuted((r) => {
|
|
190
|
+
r.id === m.id && e();
|
|
36
191
|
});
|
|
37
192
|
}
|
|
38
193
|
onBeforePaste(e) {
|
|
39
|
-
return this._injector.get(
|
|
40
|
-
|
|
194
|
+
return this._injector.get(d).beforeCommandExecuted((r) => {
|
|
195
|
+
r.id === u.id && e();
|
|
41
196
|
});
|
|
42
197
|
}
|
|
43
198
|
onPaste(e) {
|
|
44
|
-
return this._injector.get(
|
|
45
|
-
|
|
199
|
+
return this._injector.get(d).onCommandExecuted((r) => {
|
|
200
|
+
(r.id === u.id || r.id === $) && e();
|
|
46
201
|
});
|
|
47
202
|
}
|
|
48
203
|
}
|
|
49
|
-
|
|
204
|
+
M.extend(q);
|