@univerjs/ui 0.6.0 → 0.6.1
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 +15 -15
- package/lib/es/facade.js +38 -27
- package/lib/es/index.js +895 -886
- package/lib/types/facade/f-shortcut.d.ts +12 -1
- package/lib/types/services/shortcut/shortcut.service.d.ts +7 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +18 -18
- package/package.json +9 -9
package/lib/es/facade.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (i, e, t) =>
|
|
1
|
+
var B = Object.defineProperty;
|
|
2
|
+
var F = (i, e, t) => e in i ? B(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var o = (i, e, t) => F(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { FBase as M, FUniver as j, FHooks as C, FEnum as y } from "@univerjs/core/facade";
|
|
5
|
-
import { IRenderManagerService as
|
|
6
|
-
import { IMenuManagerService as P, MenuItemType as
|
|
5
|
+
import { IRenderManagerService as w } from "@univerjs/engine-render";
|
|
6
|
+
import { IMenuManagerService as P, MenuItemType as U, RibbonStartGroup as R, RibbonPosition as T, MenuManagerPosition as O, IShortcutService as G, CopyCommand as S, PasteCommand as g, ISidebarService as $, IDialogService as V, ComponentManager as f, IMessageService as N, IUIPartsService as m, connectInjector as H, SheetPasteShortKeyCommandName as L, BuiltInUIPart as A } from "@univerjs/ui";
|
|
7
7
|
import { Inject as v, Injector as b, ICommandService as u, Tools as K, CommandType as W } from "@univerjs/core";
|
|
8
|
-
var k = Object.getOwnPropertyDescriptor,
|
|
8
|
+
var k = Object.getOwnPropertyDescriptor, x = (i, e, t, r) => {
|
|
9
9
|
for (var n = r > 1 ? void 0 : r ? k(e, t) : e, s = i.length - 1, c; s >= 0; s--)
|
|
10
10
|
(c = i[s]) && (n = c(n) || n);
|
|
11
11
|
return n;
|
|
12
12
|
}, d = (i, e) => (t, r) => e(t, r, i);
|
|
13
|
-
class
|
|
13
|
+
class D extends M {
|
|
14
14
|
/**
|
|
15
15
|
* Append the menu to any menu position on Univer UI.
|
|
16
16
|
* @param {string | string[]} path - Some predefined path to append the menu. The paths can be an array,
|
|
@@ -38,13 +38,13 @@ class x extends M {
|
|
|
38
38
|
const t = typeof e == "string" ? e.split("|") : e, r = t.length, n = {};
|
|
39
39
|
let s = n;
|
|
40
40
|
const c = this.__getSchema();
|
|
41
|
-
t.forEach((h,
|
|
42
|
-
|
|
41
|
+
t.forEach((h, E) => {
|
|
42
|
+
E === r - 1 ? s[h] = c : s[h] = {}, s = s[h];
|
|
43
43
|
}), this._menuManagerService.mergeMenu(n);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
var a;
|
|
47
|
-
let
|
|
47
|
+
let l = (a = class extends D {
|
|
48
48
|
constructor(e, t, r, n) {
|
|
49
49
|
super();
|
|
50
50
|
o(this, "_commandToRegister", /* @__PURE__ */ new Map());
|
|
@@ -55,7 +55,7 @@ let p = (a = class extends x {
|
|
|
55
55
|
// eslint-disable-next-line ts/explicit-function-return-type
|
|
56
56
|
menuItemFactory: () => ({
|
|
57
57
|
id: e.id,
|
|
58
|
-
type:
|
|
58
|
+
type: U.BUTTON,
|
|
59
59
|
// we only support button for now
|
|
60
60
|
icon: e.icon,
|
|
61
61
|
title: e.title,
|
|
@@ -77,12 +77,12 @@ let p = (a = class extends x {
|
|
|
77
77
|
}), { [this._item.id]: this._buildingSchema };
|
|
78
78
|
}
|
|
79
79
|
}, o(a, "RibbonStartGroup", R), o(a, "RibbonPosition", T), o(a, "MenuManagerPosition", O), a);
|
|
80
|
-
|
|
80
|
+
l = x([
|
|
81
81
|
d(1, v(b)),
|
|
82
82
|
d(2, u),
|
|
83
83
|
d(3, P)
|
|
84
|
-
],
|
|
85
|
-
let
|
|
84
|
+
], l);
|
|
85
|
+
let p = class extends D {
|
|
86
86
|
constructor(e, t, r) {
|
|
87
87
|
super();
|
|
88
88
|
o(this, "_menuByGroups", []);
|
|
@@ -92,7 +92,7 @@ let _ = class extends x {
|
|
|
92
92
|
// eslint-disable-next-line ts/explicit-function-return-type
|
|
93
93
|
menuItemFactory: () => ({
|
|
94
94
|
id: e.id,
|
|
95
|
-
type:
|
|
95
|
+
type: U.SUBITEMS,
|
|
96
96
|
icon: e.icon,
|
|
97
97
|
title: e.title,
|
|
98
98
|
tooltip: e.tooltip
|
|
@@ -127,35 +127,46 @@ let _ = class extends x {
|
|
|
127
127
|
}), { [this._item.id]: Object.assign(this._buildingSchema, e) };
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
-
|
|
130
|
+
p = x([
|
|
131
131
|
d(1, v(b)),
|
|
132
132
|
d(2, P)
|
|
133
|
-
],
|
|
133
|
+
], p);
|
|
134
134
|
var q = Object.getOwnPropertyDescriptor, z = (i, e, t, r) => {
|
|
135
135
|
for (var n = r > 1 ? void 0 : r ? q(e, t) : e, s = i.length - 1, c; s >= 0; s--)
|
|
136
136
|
(c = i[s]) && (n = c(n) || n);
|
|
137
137
|
return n;
|
|
138
138
|
}, I = (i, e) => (t, r) => e(t, r, i);
|
|
139
|
-
let
|
|
139
|
+
let _ = class extends M {
|
|
140
140
|
constructor(e, t) {
|
|
141
141
|
super();
|
|
142
|
-
o(this, "
|
|
142
|
+
o(this, "_forceDisableDisposable", null);
|
|
143
143
|
this._injector = e, this._shortcutService = t;
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
146
|
* Enable shortcuts of Univer.
|
|
147
147
|
* @returns {FShortcut} The Facade API instance itself for chaining.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* fShortcut.enableShortcut(); // Use the FShortcut instance used by disableShortcut before, do not create a new instance
|
|
152
|
+
* ```
|
|
148
153
|
*/
|
|
149
154
|
enableShortcut() {
|
|
150
155
|
var e;
|
|
151
|
-
return (e = this.
|
|
156
|
+
return (e = this._forceDisableDisposable) == null || e.dispose(), this._forceDisableDisposable = null, this;
|
|
152
157
|
}
|
|
153
158
|
/**
|
|
154
159
|
* Disable shortcuts of Univer.
|
|
155
160
|
* @returns {FShortcut} The Facade API instance itself for chaining.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const fShortcut = univerAPI.getShortcut();
|
|
165
|
+
* fShortcut.disableShortcut();
|
|
166
|
+
* ```
|
|
156
167
|
*/
|
|
157
168
|
disableShortcut() {
|
|
158
|
-
return this.
|
|
169
|
+
return this._forceDisableDisposable || (this._forceDisableDisposable = this._shortcutService.forceDisable()), this;
|
|
159
170
|
}
|
|
160
171
|
/**
|
|
161
172
|
* Dispatch a KeyboardEvent to the shortcut service and return the matched shortcut item.
|
|
@@ -177,16 +188,16 @@ let l = class extends M {
|
|
|
177
188
|
return this._shortcutService.dispatch(e);
|
|
178
189
|
}
|
|
179
190
|
};
|
|
180
|
-
|
|
191
|
+
_ = z([
|
|
181
192
|
I(0, v(b)),
|
|
182
193
|
I(1, G)
|
|
183
|
-
],
|
|
194
|
+
], _);
|
|
184
195
|
class J extends j {
|
|
185
196
|
getURL() {
|
|
186
197
|
return new URL(window.location.href);
|
|
187
198
|
}
|
|
188
199
|
getShortcut() {
|
|
189
|
-
return this._injector.createInstance(
|
|
200
|
+
return this._injector.createInstance(_);
|
|
190
201
|
}
|
|
191
202
|
copy() {
|
|
192
203
|
return this._commandService.syncExecuteCommand(S.id);
|
|
@@ -195,10 +206,10 @@ class J extends j {
|
|
|
195
206
|
return this._commandService.syncExecuteCommand(g.id);
|
|
196
207
|
}
|
|
197
208
|
createMenu(e) {
|
|
198
|
-
return this._injector.createInstance(
|
|
209
|
+
return this._injector.createInstance(l, e);
|
|
199
210
|
}
|
|
200
211
|
createSubmenu(e) {
|
|
201
|
-
return this._injector.createInstance(
|
|
212
|
+
return this._injector.createInstance(p, e);
|
|
202
213
|
}
|
|
203
214
|
openSiderbar(e) {
|
|
204
215
|
return this._injector.get($).open(e);
|
|
@@ -235,7 +246,7 @@ class J extends j {
|
|
|
235
246
|
return this.disposeWithMe(n.register(e, t, r));
|
|
236
247
|
}
|
|
237
248
|
setCurrent(e) {
|
|
238
|
-
if (!this._injector.get(
|
|
249
|
+
if (!this._injector.get(w).getRenderById(e))
|
|
239
250
|
throw new Error("Unit not found");
|
|
240
251
|
this._univerInstanceService.setCurrentUnitForType(e);
|
|
241
252
|
}
|