@univerjs/ui 0.6.7 → 0.6.8
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/index.js +32 -32
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/index.js +3865 -3771
- package/lib/es/locale/en-US.js +14 -0
- package/lib/es/locale/fa-IR.js +14 -0
- package/lib/es/locale/fr-FR.js +14 -0
- package/lib/es/locale/ru-RU.js +14 -0
- package/lib/es/locale/vi-VN.js +16 -2
- package/lib/es/locale/zh-CN.js +16 -2
- package/lib/es/locale/zh-TW.js +16 -2
- package/lib/facade.js +385 -0
- package/lib/index.js +8363 -0
- package/lib/locale/en-US.js +81 -0
- package/lib/locale/fa-IR.js +81 -0
- package/lib/locale/fr-FR.js +81 -0
- package/lib/locale/ru-RU.js +81 -0
- package/lib/locale/vi-VN.js +81 -0
- package/lib/locale/zh-CN.js +81 -0
- package/lib/locale/zh-TW.js +81 -0
- package/lib/types/components/common-label/index.d.ts +24 -0
- package/lib/types/components/font-size/index.d.ts +1 -1
- package/lib/types/components/font-size/interface.d.ts +5 -0
- package/lib/types/components/heading-item/index.d.ts +6 -0
- package/lib/types/components/index.d.ts +2 -0
- package/lib/types/controllers/config.schema.d.ts +1 -0
- package/lib/types/controllers/ui/ui-desktop.controller.d.ts +4 -1
- package/lib/types/locale/zh-CN.d.ts +14 -0
- package/lib/types/views/components/popup/RectPopup.d.ts +1 -1
- package/lib/umd/index.js +32 -32
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +8 -8
package/lib/es/locale/en-US.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
const e = {
|
|
2
|
+
toolbar: {
|
|
3
|
+
heading: {
|
|
4
|
+
normal: "Normal",
|
|
5
|
+
title: "Title",
|
|
6
|
+
subTitle: "Sub Title",
|
|
7
|
+
1: "Heading 1",
|
|
8
|
+
2: "Heading 2",
|
|
9
|
+
3: "Heading 3",
|
|
10
|
+
4: "Heading 4",
|
|
11
|
+
5: "Heading 5",
|
|
12
|
+
6: "Heading 6",
|
|
13
|
+
tooltip: "Set Heading"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
2
16
|
ribbon: {
|
|
3
17
|
start: "Start",
|
|
4
18
|
insert: "Insert",
|
package/lib/es/locale/fa-IR.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
const i = {
|
|
2
|
+
toolbar: {
|
|
3
|
+
heading: {
|
|
4
|
+
normal: "متن عادی",
|
|
5
|
+
title: "عنوان",
|
|
6
|
+
subTitle: "زیر عنوان",
|
|
7
|
+
1: "عنوان 1",
|
|
8
|
+
2: "عنوان 2",
|
|
9
|
+
3: "عنوان 3",
|
|
10
|
+
4: "عنوان 4",
|
|
11
|
+
5: "عنوان 5",
|
|
12
|
+
6: "عنوان 6",
|
|
13
|
+
tooltip: "تنظیم عنوان"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
2
16
|
ribbon: {
|
|
3
17
|
start: "شروع",
|
|
4
18
|
insert: "درج",
|
package/lib/es/locale/fr-FR.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
const e = {
|
|
2
|
+
toolbar: {
|
|
3
|
+
heading: {
|
|
4
|
+
normal: "Normal",
|
|
5
|
+
title: "Titre",
|
|
6
|
+
subTitle: "Sous-titre",
|
|
7
|
+
1: "Titre 1",
|
|
8
|
+
2: "Titre 2",
|
|
9
|
+
3: "Titre 3",
|
|
10
|
+
4: "Titre 4",
|
|
11
|
+
5: "Titre 5",
|
|
12
|
+
6: "Titre 6",
|
|
13
|
+
tooltip: "Définir un titre"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
2
16
|
ribbon: {
|
|
3
17
|
start: "Démarrer",
|
|
4
18
|
insert: "Insérer",
|
package/lib/es/locale/ru-RU.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
const i = {
|
|
2
|
+
toolbar: {
|
|
3
|
+
heading: {
|
|
4
|
+
normal: "Обычный текст",
|
|
5
|
+
title: "Заголовок",
|
|
6
|
+
subTitle: "Подзаголовок",
|
|
7
|
+
1: "Заголовок 1",
|
|
8
|
+
2: "Заголовок 2",
|
|
9
|
+
3: "Заголовок 3",
|
|
10
|
+
4: "Заголовок 4",
|
|
11
|
+
5: "Заголовок 5",
|
|
12
|
+
6: "Заголовок 6",
|
|
13
|
+
tooltip: "Установить заголовок"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
2
16
|
ribbon: {
|
|
3
17
|
start: "Начало",
|
|
4
18
|
insert: "Вставка",
|
package/lib/es/locale/vi-VN.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
const
|
|
1
|
+
const i = {
|
|
2
|
+
toolbar: {
|
|
3
|
+
heading: {
|
|
4
|
+
normal: "Văn bản",
|
|
5
|
+
title: "Tiêu đề",
|
|
6
|
+
subTitle: "Tiêu đề phụ",
|
|
7
|
+
1: "Tiêu đề 1",
|
|
8
|
+
2: "Tiêu đề 2",
|
|
9
|
+
3: "Tiêu đề 3",
|
|
10
|
+
4: "Tiêu đề 4",
|
|
11
|
+
5: "Tiêu đề 5",
|
|
12
|
+
6: "Tiêu đề 6",
|
|
13
|
+
tooltip: "Đặt tiêu đề"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
2
16
|
ribbon: {
|
|
3
17
|
start: "Bắt đầu",
|
|
4
18
|
insert: "Chèn",
|
|
@@ -63,5 +77,5 @@ const n = {
|
|
|
63
77
|
}
|
|
64
78
|
};
|
|
65
79
|
export {
|
|
66
|
-
|
|
80
|
+
i as default
|
|
67
81
|
};
|
package/lib/es/locale/zh-CN.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
const
|
|
1
|
+
const t = {
|
|
2
|
+
toolbar: {
|
|
3
|
+
heading: {
|
|
4
|
+
normal: "正文",
|
|
5
|
+
title: "标题",
|
|
6
|
+
subTitle: "副标题",
|
|
7
|
+
1: "标题1",
|
|
8
|
+
2: "标题2",
|
|
9
|
+
3: "标题3",
|
|
10
|
+
4: "标题4",
|
|
11
|
+
5: "标题5",
|
|
12
|
+
6: "标题6",
|
|
13
|
+
tooltip: "设置标题"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
2
16
|
ribbon: {
|
|
3
17
|
start: "开始",
|
|
4
18
|
insert: "插入",
|
|
@@ -63,5 +77,5 @@ const o = {
|
|
|
63
77
|
}
|
|
64
78
|
};
|
|
65
79
|
export {
|
|
66
|
-
|
|
80
|
+
t as default
|
|
67
81
|
};
|
package/lib/es/locale/zh-TW.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
const
|
|
1
|
+
const t = {
|
|
2
|
+
toolbar: {
|
|
3
|
+
heading: {
|
|
4
|
+
normal: "正文",
|
|
5
|
+
title: "標題",
|
|
6
|
+
subTitle: "副標題",
|
|
7
|
+
1: "標題 1",
|
|
8
|
+
2: "標題 2",
|
|
9
|
+
3: "標題 3",
|
|
10
|
+
4: "標題 4",
|
|
11
|
+
5: "標題 5",
|
|
12
|
+
6: "標題 6",
|
|
13
|
+
tooltip: "設定標題"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
2
16
|
ribbon: {
|
|
3
17
|
start: "開始",
|
|
4
18
|
insert: "插入",
|
|
@@ -63,5 +77,5 @@ const o = {
|
|
|
63
77
|
}
|
|
64
78
|
};
|
|
65
79
|
export {
|
|
66
|
-
|
|
80
|
+
t as default
|
|
67
81
|
};
|
package/lib/facade.js
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
var F = Object.defineProperty;
|
|
2
|
+
var R = (n, e, t) => e in n ? F(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var o = (n, e, t) => R(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { FBase as C, FUniver as M, FHooks as j, FEnum as y } from "@univerjs/core/facade";
|
|
5
|
+
import { IRenderManagerService as U } from "@univerjs/engine-render";
|
|
6
|
+
import { IMenuManagerService as P, MenuItemType as x, RibbonStartGroup as T, RibbonPosition as w, MenuManagerPosition as O, IShortcutService as G, CopyCommand as v, PasteCommand as l, ISidebarService as V, IDialogService as $, ComponentManager as I, IMessageService as N, IUIPartsService as g, connectInjector as H, SheetPasteShortKeyCommandName as K, BuiltInUIPart as k, KeyCode as L } from "@univerjs/ui";
|
|
7
|
+
import { Inject as m, Injector as f, ICommandService as u, Tools as A, CommandType as W, IUniverInstanceService as q, UniverInstanceType as z } from "@univerjs/core";
|
|
8
|
+
var J = Object.getOwnPropertyDescriptor, D = (n, e, t, r) => {
|
|
9
|
+
for (var i = r > 1 ? void 0 : r ? J(e, t) : e, s = n.length - 1, c; s >= 0; s--)
|
|
10
|
+
(c = n[s]) && (i = c(i) || i);
|
|
11
|
+
return i;
|
|
12
|
+
}, d = (n, e) => (t, r) => e(t, r, n);
|
|
13
|
+
class E extends C {
|
|
14
|
+
/**
|
|
15
|
+
* Append the menu to any menu position on Univer UI.
|
|
16
|
+
* @param {string | string[]} path - Some predefined path to append the menu. The paths can be an array,
|
|
17
|
+
* or an array joined by `|` separator. Since lots of submenus reuse the same name,
|
|
18
|
+
* you may need to specify their parent menus as well.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // This menu item will appear on every `contextMenu.others` section.
|
|
23
|
+
* univerAPI.createMenu({
|
|
24
|
+
* id: 'custom-menu-id-1',
|
|
25
|
+
* title: 'Custom Menu 1',
|
|
26
|
+
* action: () => {
|
|
27
|
+
* console.log('Custom Menu 1 clicked');
|
|
28
|
+
* },
|
|
29
|
+
* }).appendTo('contextMenu.others');
|
|
30
|
+
*
|
|
31
|
+
* // This menu item will only appear on the `contextMenu.others` section on the main area.
|
|
32
|
+
* univerAPI.createMenu({
|
|
33
|
+
* id: 'custom-menu-id-2',
|
|
34
|
+
* title: 'Custom Menu 2',
|
|
35
|
+
* action: () => {
|
|
36
|
+
* console.log('Custom Menu 2 clicked');
|
|
37
|
+
* },
|
|
38
|
+
* }).appendTo(['contextMenu.mainArea', 'contextMenu.others']);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
appendTo(e) {
|
|
42
|
+
const t = typeof e == "string" ? e.split("|") : e, r = t.length, i = {};
|
|
43
|
+
let s = i;
|
|
44
|
+
const c = this.__getSchema();
|
|
45
|
+
t.forEach((S, B) => {
|
|
46
|
+
B === r - 1 ? s[S] = c : s[S] = {}, s = s[S];
|
|
47
|
+
}), this._menuManagerService.mergeMenu(i);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
var a;
|
|
51
|
+
let p = (a = class extends E {
|
|
52
|
+
constructor(e, t, r, i) {
|
|
53
|
+
super();
|
|
54
|
+
o(this, "_commandToRegister", /* @__PURE__ */ new Map());
|
|
55
|
+
o(this, "_buildingSchema");
|
|
56
|
+
this._item = e, this._injector = t, this._commandService = r, this._menuManagerService = i;
|
|
57
|
+
const s = typeof e.action == "string" ? e.action : A.generateRandomId(12);
|
|
58
|
+
s !== e.action && this._commandToRegister.set(s, e.action), this._buildingSchema = {
|
|
59
|
+
// eslint-disable-next-line ts/explicit-function-return-type
|
|
60
|
+
menuItemFactory: () => ({
|
|
61
|
+
id: e.id,
|
|
62
|
+
type: x.BUTTON,
|
|
63
|
+
// we only support button for now
|
|
64
|
+
icon: e.icon,
|
|
65
|
+
title: e.title,
|
|
66
|
+
tooltip: e.tooltip,
|
|
67
|
+
commandId: s
|
|
68
|
+
})
|
|
69
|
+
}, typeof e.order < "u" && (this._buildingSchema.order = e.order);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @ignore
|
|
73
|
+
*/
|
|
74
|
+
__getSchema() {
|
|
75
|
+
return this._commandToRegister.forEach((e, t) => {
|
|
76
|
+
this._commandService.hasCommand(t) || this._commandService.registerCommand({
|
|
77
|
+
id: t,
|
|
78
|
+
type: W.COMMAND,
|
|
79
|
+
handler: e
|
|
80
|
+
});
|
|
81
|
+
}), { [this._item.id]: this._buildingSchema };
|
|
82
|
+
}
|
|
83
|
+
}, o(a, "RibbonStartGroup", T), o(a, "RibbonPosition", w), o(a, "MenuManagerPosition", O), a);
|
|
84
|
+
p = D([
|
|
85
|
+
d(1, m(f)),
|
|
86
|
+
d(2, u),
|
|
87
|
+
d(3, P)
|
|
88
|
+
], p);
|
|
89
|
+
let _ = class extends E {
|
|
90
|
+
constructor(e, t, r) {
|
|
91
|
+
super();
|
|
92
|
+
o(this, "_menuByGroups", []);
|
|
93
|
+
o(this, "_submenus", []);
|
|
94
|
+
o(this, "_buildingSchema");
|
|
95
|
+
this._item = e, this._injector = t, this._menuManagerService = r, this._buildingSchema = {
|
|
96
|
+
// eslint-disable-next-line ts/explicit-function-return-type
|
|
97
|
+
menuItemFactory: () => ({
|
|
98
|
+
id: e.id,
|
|
99
|
+
type: x.SUBITEMS,
|
|
100
|
+
icon: e.icon,
|
|
101
|
+
title: e.title,
|
|
102
|
+
tooltip: e.tooltip
|
|
103
|
+
})
|
|
104
|
+
}, typeof e.order < "u" && (this._buildingSchema.order = e.order);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Add a menu to the submenu. It can be a {@link FMenu} or a {@link FSubmenu}.
|
|
108
|
+
* @param {FMenu | FSubmenu} submenu - Menu to add to the submenu.
|
|
109
|
+
* @returns {FSubmenu} The FSubmenu itself for chaining calls.
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // Create two leaf menus.
|
|
113
|
+
* const menu1 = univerAPI.createMenu({
|
|
114
|
+
* id: 'submenu-nested-1',
|
|
115
|
+
* title: 'Item 1',
|
|
116
|
+
* action: () => {
|
|
117
|
+
* console.log('Item 1 clicked');
|
|
118
|
+
* }
|
|
119
|
+
* });
|
|
120
|
+
* const menu2 = univerAPI.createMenu({
|
|
121
|
+
* id: 'submenu-nested-2',
|
|
122
|
+
* title: 'Item 2',
|
|
123
|
+
* action: () => {
|
|
124
|
+
* console.log('Item 2 clicked');
|
|
125
|
+
* }
|
|
126
|
+
* });
|
|
127
|
+
*
|
|
128
|
+
* // Add the leaf menus to a submenu.
|
|
129
|
+
* const submenu = univerAPI.createSubmenu({ id: 'submenu-nested', title: 'Nested Submenu' })
|
|
130
|
+
* .addSubmenu(menu1)
|
|
131
|
+
* .addSeparator()
|
|
132
|
+
* .addSubmenu(menu2);
|
|
133
|
+
*
|
|
134
|
+
* // Create a root submenu append to the `contextMenu.others` section.
|
|
135
|
+
* univerAPI.createSubmenu({ id: 'custom-submenu', title: 'Custom Submenu' })
|
|
136
|
+
* .addSubmenu(submenu)
|
|
137
|
+
* .appendTo('contextMenu.others');
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
addSubmenu(e) {
|
|
141
|
+
return this._submenus.push(e), this;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Add a separator to the submenu.
|
|
145
|
+
* @returns {FSubmenu} The FSubmenu itself for chaining calls.
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* // Create two leaf menus.
|
|
149
|
+
* const menu1 = univerAPI.createMenu({
|
|
150
|
+
* id: 'submenu-nested-1',
|
|
151
|
+
* title: 'Item 1',
|
|
152
|
+
* action: () => {
|
|
153
|
+
* console.log('Item 1 clicked');
|
|
154
|
+
* }
|
|
155
|
+
* });
|
|
156
|
+
* const menu2 = univerAPI.createMenu({
|
|
157
|
+
* id: 'submenu-nested-2',
|
|
158
|
+
* title: 'Item 2',
|
|
159
|
+
* action: () => {
|
|
160
|
+
* console.log('Item 2 clicked');
|
|
161
|
+
* }
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* // Add the leaf menus to a submenu and add a separator between them.
|
|
165
|
+
* // Append the submenu to the `contextMenu.others` section.
|
|
166
|
+
* univerAPI.createSubmenu({ id: 'submenu-nested', title: 'Nested Submenu' })
|
|
167
|
+
* .addSubmenu(menu1)
|
|
168
|
+
* .addSeparator()
|
|
169
|
+
* .addSubmenu(menu2)
|
|
170
|
+
* .appendTo('contextMenu.others');
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
addSeparator() {
|
|
174
|
+
return this._menuByGroups.push(this._submenus), this._submenus = [], this;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @ignore
|
|
178
|
+
*/
|
|
179
|
+
__getSchema() {
|
|
180
|
+
const e = {};
|
|
181
|
+
return this.addSeparator(), this._menuByGroups.forEach((t, r) => {
|
|
182
|
+
const i = {};
|
|
183
|
+
t.forEach((s) => {
|
|
184
|
+
Object.assign(i, s.__getSchema());
|
|
185
|
+
}), e[`${this._item.id}-group-${r}`] = i;
|
|
186
|
+
}), { [this._item.id]: Object.assign(this._buildingSchema, e) };
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
_ = D([
|
|
190
|
+
d(1, m(f)),
|
|
191
|
+
d(2, P)
|
|
192
|
+
], _);
|
|
193
|
+
var Q = Object.getOwnPropertyDescriptor, X = (n, e, t, r) => {
|
|
194
|
+
for (var i = r > 1 ? void 0 : r ? Q(e, t) : e, s = n.length - 1, c; s >= 0; s--)
|
|
195
|
+
(c = n[s]) && (i = c(i) || i);
|
|
196
|
+
return i;
|
|
197
|
+
}, h = (n, e) => (t, r) => e(t, r, n);
|
|
198
|
+
let b = class extends C {
|
|
199
|
+
constructor(e, t, r, i) {
|
|
200
|
+
super();
|
|
201
|
+
o(this, "_forceDisableDisposable", null);
|
|
202
|
+
this._injector = e, this._renderManagerService = t, this._univerInstanceService = r, this._shortcutService = i;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Enable shortcuts of Univer.
|
|
206
|
+
* @returns {FShortcut} The Facade API instance itself for chaining.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* fShortcut.enableShortcut(); // Use the FShortcut instance used by disableShortcut before, do not create a new instance
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
enableShortcut() {
|
|
214
|
+
var e;
|
|
215
|
+
return (e = this._forceDisableDisposable) == null || e.dispose(), this._forceDisableDisposable = null, this;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Disable shortcuts of Univer.
|
|
219
|
+
* @returns {FShortcut} The Facade API instance itself for chaining.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* const fShortcut = univerAPI.getShortcut();
|
|
224
|
+
* fShortcut.disableShortcut();
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
disableShortcut() {
|
|
228
|
+
return this._forceDisableDisposable || (this._forceDisableDisposable = this._shortcutService.forceDisable()), this;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Trigger shortcut of Univer by a KeyboardEvent and return the matched shortcut item.
|
|
232
|
+
* @param {KeyboardEvent} e - The KeyboardEvent to trigger.
|
|
233
|
+
* @returns {IShortcutItem<object> | undefined} The matched shortcut item.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* // Assum the current sheet is empty sheet.
|
|
238
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
239
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
240
|
+
* const fRange = fWorksheet.getRange('A1');
|
|
241
|
+
*
|
|
242
|
+
* // Set A1 cell active and set value to 'Hello Univer'.
|
|
243
|
+
* fRange.activate();
|
|
244
|
+
* fRange.setValue('Hello Univer');
|
|
245
|
+
* console.log(fRange.getCellStyle().bold); // false
|
|
246
|
+
*
|
|
247
|
+
* // Set A1 cell bold by shortcut.
|
|
248
|
+
* const fShortcut = univerAPI.getShortcut();
|
|
249
|
+
* const pseudoEvent = new KeyboardEvent('keydown', {
|
|
250
|
+
* key: 'b',
|
|
251
|
+
* ctrlKey: true,
|
|
252
|
+
* keyCode: univerAPI.Enum.KeyCode.B
|
|
253
|
+
* });
|
|
254
|
+
* const ifShortcutItem = fShortcut.triggerShortcut(pseudoEvent);
|
|
255
|
+
* if (ifShortcutItem) {
|
|
256
|
+
* const commandId = ifShortcutItem.id;
|
|
257
|
+
* console.log(fRange.getCellStyle().bold); // true
|
|
258
|
+
* }
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
triggerShortcut(e) {
|
|
262
|
+
const t = this._univerInstanceService.getCurrentUnitForType(z.UNIVER_SHEET);
|
|
263
|
+
if (!t)
|
|
264
|
+
return;
|
|
265
|
+
const r = this._renderManagerService.getRenderById(t.getUnitId());
|
|
266
|
+
return r ? (r.engine.getCanvasElement().dispatchEvent(e), this._shortcutService.dispatch(e)) : void 0;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Dispatch a KeyboardEvent to the shortcut service and return the matched shortcut item.
|
|
270
|
+
* @param {KeyboardEvent} e - The KeyboardEvent to dispatch.
|
|
271
|
+
* @returns {IShortcutItem<object> | undefined} The matched shortcut item.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* const fShortcut = univerAPI.getShortcut();
|
|
276
|
+
* const pseudoEvent = new KeyboardEvent('keydown', { key: 's', ctrlKey: true });
|
|
277
|
+
* const ifShortcutItem = fShortcut.dispatchShortcutEvent(pseudoEvent);
|
|
278
|
+
* if (ifShortcutItem) {
|
|
279
|
+
* const commandId = ifShortcutItem.id;
|
|
280
|
+
* // Do something with the commandId.
|
|
281
|
+
* }
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
dispatchShortcutEvent(e) {
|
|
285
|
+
return this._shortcutService.dispatch(e);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
b = X([
|
|
289
|
+
h(0, m(f)),
|
|
290
|
+
h(1, m(U)),
|
|
291
|
+
h(2, q),
|
|
292
|
+
h(3, G)
|
|
293
|
+
], b);
|
|
294
|
+
class Y extends M {
|
|
295
|
+
getURL() {
|
|
296
|
+
return new URL(window.location.href);
|
|
297
|
+
}
|
|
298
|
+
getShortcut() {
|
|
299
|
+
return this._injector.createInstance(b);
|
|
300
|
+
}
|
|
301
|
+
copy() {
|
|
302
|
+
return this._commandService.executeCommand(v.id);
|
|
303
|
+
}
|
|
304
|
+
paste() {
|
|
305
|
+
return this._commandService.executeCommand(l.id);
|
|
306
|
+
}
|
|
307
|
+
createMenu(e) {
|
|
308
|
+
return this._injector.createInstance(p, e);
|
|
309
|
+
}
|
|
310
|
+
createSubmenu(e) {
|
|
311
|
+
return this._injector.createInstance(_, e);
|
|
312
|
+
}
|
|
313
|
+
openSiderbar(e) {
|
|
314
|
+
return this._injector.get(V).open(e);
|
|
315
|
+
}
|
|
316
|
+
openSidebar(e) {
|
|
317
|
+
return this.openSiderbar(e);
|
|
318
|
+
}
|
|
319
|
+
openDialog(e) {
|
|
320
|
+
const r = this._injector.get($).open({
|
|
321
|
+
...e,
|
|
322
|
+
onClose: () => {
|
|
323
|
+
r.dispose();
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
return r;
|
|
327
|
+
}
|
|
328
|
+
getComponentManager() {
|
|
329
|
+
return this._injector.get(I);
|
|
330
|
+
}
|
|
331
|
+
showMessage(e) {
|
|
332
|
+
return this._injector.get(N).show(e), this;
|
|
333
|
+
}
|
|
334
|
+
setUIVisible(e, t) {
|
|
335
|
+
return this._injector.get(g).setUIVisible(e, t), this;
|
|
336
|
+
}
|
|
337
|
+
isUIVisible(e) {
|
|
338
|
+
return this._injector.get(g).isUIVisible(e);
|
|
339
|
+
}
|
|
340
|
+
registerUIPart(e, t) {
|
|
341
|
+
return this._injector.get(g).registerComponent(e, () => H(t, this._injector));
|
|
342
|
+
}
|
|
343
|
+
registerComponent(e, t, r) {
|
|
344
|
+
const i = this._injector.get(I);
|
|
345
|
+
return this.disposeWithMe(i.register(e, t, r));
|
|
346
|
+
}
|
|
347
|
+
setCurrent(e) {
|
|
348
|
+
if (!this._injector.get(U).getRenderById(e))
|
|
349
|
+
throw new Error("Unit not found");
|
|
350
|
+
this._univerInstanceService.setCurrentUnitForType(e);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
M.extend(Y);
|
|
354
|
+
class Z extends j {
|
|
355
|
+
onBeforeCopy(e) {
|
|
356
|
+
return this._injector.get(u).beforeCommandExecuted((r) => {
|
|
357
|
+
r.id === v.id && e();
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
onCopy(e) {
|
|
361
|
+
return this._injector.get(u).onCommandExecuted((r) => {
|
|
362
|
+
r.id === v.id && e();
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
onBeforePaste(e) {
|
|
366
|
+
return this._injector.get(u).beforeCommandExecuted((r) => {
|
|
367
|
+
r.id === l.id && e();
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
onPaste(e) {
|
|
371
|
+
return this._injector.get(u).onCommandExecuted((r) => {
|
|
372
|
+
(r.id === l.id || r.id === K) && e();
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
j.extend(Z);
|
|
377
|
+
class ee extends y {
|
|
378
|
+
get BuiltInUIPart() {
|
|
379
|
+
return k;
|
|
380
|
+
}
|
|
381
|
+
get KeyCode() {
|
|
382
|
+
return L;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
y.extend(ee);
|