@univerjs/ui 0.17.0 → 0.18.0
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 +377 -43
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.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/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.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/facade.js +1 -391
- package/lib/es/index.js +378 -12224
- package/lib/es/locale/ca-ES.js +1 -85
- package/lib/es/locale/en-US.js +1 -85
- package/lib/es/locale/es-ES.js +1 -85
- package/lib/es/locale/fa-IR.js +1 -85
- package/lib/es/locale/fr-FR.js +1 -85
- package/lib/es/locale/ja-JP.js +1 -85
- package/lib/es/locale/ko-KR.js +1 -85
- package/lib/es/locale/ru-RU.js +1 -85
- package/lib/es/locale/sk-SK.js +1 -85
- package/lib/es/locale/vi-VN.js +1 -85
- package/lib/es/locale/zh-CN.js +1 -85
- package/lib/es/locale/zh-TW.js +1 -85
- package/lib/facade.js +1 -391
- package/lib/index.css +1662 -1
- package/lib/index.js +378 -12224
- package/lib/locale/ca-ES.js +1 -85
- package/lib/locale/en-US.js +1 -85
- package/lib/locale/es-ES.js +1 -85
- package/lib/locale/fa-IR.js +1 -85
- package/lib/locale/fr-FR.js +1 -85
- package/lib/locale/ja-JP.js +1 -85
- package/lib/locale/ko-KR.js +1 -85
- package/lib/locale/ru-RU.js +1 -85
- package/lib/locale/sk-SK.js +1 -85
- package/lib/locale/vi-VN.js +1 -85
- package/lib/locale/zh-CN.js +1 -85
- package/lib/locale/zh-TW.js +1 -85
- package/lib/types/commands/operations/toggle-shortcut-panel.operation.d.ts +16 -1
- package/lib/types/common/component-manager.d.ts +17 -1
- package/lib/types/common/lifecycle.d.ts +16 -1
- package/lib/types/common/menu-hidden-observable.d.ts +16 -1
- package/lib/types/common/menu-merge-configs.d.ts +16 -1
- package/lib/types/components/custom-label/CustomLabel.d.ts +18 -3
- package/lib/types/components/font-family/FontFamily.d.ts +16 -1
- package/lib/types/components/font-family/interface.d.ts +17 -2
- package/lib/types/components/font-size/FontSize.d.ts +16 -1
- package/lib/types/components/font-size/interface.d.ts +17 -2
- package/lib/types/components/heading-item/index.d.ts +16 -1
- package/lib/types/components/hooks/layout.d.ts +16 -1
- package/lib/types/components/hooks/locale.d.ts +15 -0
- package/lib/types/components/hooks/update-effect.d.ts +15 -0
- package/lib/types/components/hooks/use-click-out-side.d.ts +16 -1
- package/lib/types/components/menu/common/hook.d.ts +16 -1
- package/lib/types/components/menu/desktop/DesignTinyMenuGroup.d.ts +30 -0
- package/lib/types/components/menu/desktop/TinyMenuGroup.d.ts +17 -2
- package/lib/types/components/menu/mobile/MobileMenu.d.ts +20 -3
- package/lib/types/components/menu/mobile/MobileMenu.stories.d.ts +16 -1
- package/lib/types/components/menu/types.d.ts +29 -0
- package/lib/types/components/notification/Notification.d.ts +17 -1
- package/lib/types/components/notification/Notification.stories.d.ts +16 -1
- package/lib/types/components/slider/Slider.stories.d.ts +16 -1
- package/lib/types/config/config.d.ts +18 -3
- package/lib/types/controllers/error/error.controller.d.ts +15 -0
- package/lib/types/controllers/menus/menus.d.ts +17 -2
- package/lib/types/controllers/shared-shortcut.controller.d.ts +17 -1
- package/lib/types/controllers/shortcut-display/menu.d.ts +16 -1
- package/lib/types/controllers/shortcut-display/shortcut-panel.controller.d.ts +15 -0
- package/lib/types/controllers/ui/ui-desktop.controller.d.ts +18 -2
- package/lib/types/controllers/ui/ui-mobile.controller.d.ts +25 -4
- package/lib/types/controllers/ui/ui-shared.controller.d.ts +19 -3
- package/lib/types/controllers/ui/ui.controller.d.ts +17 -2
- package/lib/types/facade/f-enum.d.ts +15 -0
- package/lib/types/facade/f-hooks.d.ts +16 -1
- package/lib/types/facade/f-menu-builder.d.ts +17 -1
- package/lib/types/facade/f-shortcut.d.ts +17 -1
- package/lib/types/facade/f-univer.d.ts +21 -4
- package/lib/types/index.d.ts +1 -2
- package/lib/types/locale/ca-ES.d.ts +16 -1
- package/lib/types/locale/es-ES.d.ts +16 -1
- package/lib/types/locale/fa-IR.d.ts +16 -1
- package/lib/types/locale/fr-FR.d.ts +16 -1
- package/lib/types/locale/ja-JP.d.ts +16 -1
- package/lib/types/locale/ko-KR.d.ts +16 -1
- package/lib/types/locale/ru-RU.d.ts +16 -1
- package/lib/types/locale/sk-SK.d.ts +16 -1
- package/lib/types/locale/vi-VN.d.ts +16 -1
- package/lib/types/locale/zh-CN.d.ts +16 -1
- package/lib/types/locale/zh-TW.d.ts +16 -1
- package/lib/types/menu/schema.d.ts +16 -1
- package/lib/types/mobile-plugin.d.ts +16 -1
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/services/before-close/before-close.service.d.ts +17 -2
- package/lib/types/services/clipboard/clipboard-interface.service.d.ts +16 -1
- package/lib/types/services/clipboard/clipboard.command.d.ts +16 -1
- package/lib/types/services/confirm/desktop-confirm.service.d.ts +18 -2
- package/lib/types/services/contextmenu/contextmenu-host.service.d.ts +18 -2
- package/lib/types/services/contextmenu/contextmenu.service.d.ts +19 -3
- package/lib/types/services/dialog/desktop-dialog.service.d.ts +20 -4
- package/lib/types/services/dialog/dialog.service.d.ts +19 -4
- package/lib/types/services/dom/canvas-dom-layer.service.d.ts +17 -2
- package/lib/types/services/font.service.d.ts +18 -2
- package/lib/types/services/gallery/desktop-gallery.service.d.ts +19 -3
- package/lib/types/services/gallery/gallery.service.d.ts +19 -4
- package/lib/types/services/global-zone/desktop-global-zone.service.d.ts +18 -3
- package/lib/types/services/global-zone/global-zone.service.d.ts +18 -3
- package/lib/types/services/layout/layout.service.d.ts +18 -2
- package/lib/types/services/local-file/desktop-local-file.service.d.ts +16 -1
- package/lib/types/services/local-file/local-file.service.d.ts +1 -1
- package/lib/types/services/local-storage/local-storage.service.d.ts +16 -1
- package/lib/types/services/menu/menu-manager.service.d.ts +21 -4
- package/lib/types/services/menu/menu.d.ts +18 -2
- package/lib/types/services/menu/types.d.ts +5 -1
- package/lib/types/services/message/__testing__/mock-message.service.d.ts +18 -3
- package/lib/types/services/message/desktop-message.service.d.ts +19 -3
- package/lib/types/services/message/message.service.d.ts +18 -3
- package/lib/types/services/notification/desktop-notification.service.d.ts +19 -3
- package/lib/types/services/notification/notification.service.d.ts +18 -3
- package/lib/types/services/parts/parts.service.d.ts +20 -4
- package/lib/types/services/platform/platform.service.d.ts +1 -1
- package/lib/types/services/popup/canvas-popup.service.d.ts +21 -5
- package/lib/types/services/ribbon/ribbon.service.d.ts +19 -3
- package/lib/types/services/shortcut/shortcut-panel.service.d.ts +16 -1
- package/lib/types/services/shortcut/shortcut.service.d.ts +20 -4
- package/lib/types/services/sidebar/desktop-sidebar.service.d.ts +18 -3
- package/lib/types/services/sidebar/sidebar.service.d.ts +20 -5
- package/lib/types/services/theme-switcher/theme-switcher.service.d.ts +16 -1
- package/lib/types/services/zen-zone/desktop-zen-zone.service.d.ts +20 -4
- package/lib/types/services/zen-zone/zen-zone.service.d.ts +19 -4
- package/lib/types/utils/cell.d.ts +16 -1
- package/lib/types/utils/di.d.ts +19 -4
- package/lib/types/views/components/ComponentContainer.d.ts +18 -3
- package/lib/types/views/components/confirm-part/interface.d.ts +17 -2
- package/lib/types/views/components/context-menu/AnchoredContextMenu.d.ts +16 -1
- package/lib/types/views/components/context-menu/ContextMenuPanel.d.ts +17 -1
- package/lib/types/views/components/context-menu/MobileContextMenu.d.ts +1 -1
- package/lib/types/views/components/dialog-part/interface.d.ts +17 -2
- package/lib/types/views/components/dom/FloatDom.d.ts +17 -2
- package/lib/types/views/components/dom/print.d.ts +17 -2
- package/lib/types/views/components/popup/CanvasPopup.d.ts +17 -2
- package/lib/types/views/components/popup/RectPopup.d.ts +18 -3
- package/lib/types/views/components/ribbon/MobileRibbon.d.ts +22 -0
- package/lib/types/views/components/ribbon/Ribbon.d.ts +17 -2
- package/lib/types/views/components/ribbon/ToolbarItem.d.ts +18 -3
- package/lib/types/views/components/ribbon/TooltipButtonWrapper.d.ts +19 -4
- package/lib/types/views/components/ribbon/hook.d.ts +16 -1
- package/lib/types/views/components/ribbon/ribbon-menu/ClassicMenu.d.ts +16 -1
- package/lib/types/views/components/ribbon/ribbon-menu/DefaultMenu.d.ts +16 -1
- package/lib/types/views/components/sidebar/Sidebar.d.ts +17 -2
- package/lib/types/views/mobile-workbench/MobileWorkbench.d.ts +16 -1
- package/lib/types/views/workbench/Workbench.d.ts +16 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +384 -43
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.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/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.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 +10 -9
- package/lib/types/components/menu/desktop/Menu.d.ts +0 -17
package/lib/facade.js
CHANGED
|
@@ -1,391 +1 @@
|
|
|
1
|
-
var
|
|
2
|
-
var R = (n, e, t) => e in n ? B(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 E, RibbonStartGroup as w, RibbonPosition as T, MenuManagerPosition as O, IShortcutService as G, CopyCommand as v, PasteCommand as _, ISidebarService as V, IDialogService as $, ComponentManager as I, IMessageService as N, IUIPartsService as g, connectInjector as H, IFontService as K, SheetPasteShortKeyCommandName as k, BuiltInUIPart as L, KeyCode as A } from "@univerjs/ui";
|
|
7
|
-
import { Inject as m, Injector as f, ICommandService as d, generateRandomId as W, CommandType as q, IUniverInstanceService as z, UniverInstanceType as J } from "@univerjs/core";
|
|
8
|
-
var Q = Object.getOwnPropertyDescriptor, x = (n, e, t, r) => {
|
|
9
|
-
for (var i = r > 1 ? void 0 : r ? Q(e, t) : e, s = n.length - 1, c; s >= 0; s--)
|
|
10
|
-
(c = n[s]) && (i = c(i) || i);
|
|
11
|
-
return i;
|
|
12
|
-
}, u = (n, e) => (t, r) => e(t, r, n);
|
|
13
|
-
class D 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, F) => {
|
|
46
|
-
F === 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 D {
|
|
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 : W(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: E.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: q.COMMAND,
|
|
79
|
-
handler: e
|
|
80
|
-
});
|
|
81
|
-
}), { [this._item.id]: this._buildingSchema };
|
|
82
|
-
}
|
|
83
|
-
}, o(a, "RibbonStartGroup", w), o(a, "RibbonPosition", T), o(a, "MenuManagerPosition", O), a);
|
|
84
|
-
p = x([
|
|
85
|
-
u(1, m(f)),
|
|
86
|
-
u(2, d),
|
|
87
|
-
u(3, P)
|
|
88
|
-
], p);
|
|
89
|
-
let l = class extends D {
|
|
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: E.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
|
-
l = x([
|
|
190
|
-
u(1, m(f)),
|
|
191
|
-
u(2, P)
|
|
192
|
-
], l);
|
|
193
|
-
var X = Object.getOwnPropertyDescriptor, Y = (n, e, t, r) => {
|
|
194
|
-
for (var i = r > 1 ? void 0 : r ? X(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(J.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 = Y([
|
|
289
|
-
h(0, m(f)),
|
|
290
|
-
h(1, m(U)),
|
|
291
|
-
h(2, z),
|
|
292
|
-
h(3, G)
|
|
293
|
-
], b);
|
|
294
|
-
class Z 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(_.id);
|
|
306
|
-
}
|
|
307
|
-
createMenu(e) {
|
|
308
|
-
return this._injector.createInstance(p, e);
|
|
309
|
-
}
|
|
310
|
-
createSubmenu(e) {
|
|
311
|
-
return this._injector.createInstance(l, 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
|
-
addFonts(e) {
|
|
353
|
-
const t = this._injector.get(K);
|
|
354
|
-
e.forEach((r) => {
|
|
355
|
-
t.addFont(r);
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
M.extend(Z);
|
|
360
|
-
class ee extends j {
|
|
361
|
-
onBeforeCopy(e) {
|
|
362
|
-
return this._injector.get(d).beforeCommandExecuted((r) => {
|
|
363
|
-
r.id === v.id && e();
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
onCopy(e) {
|
|
367
|
-
return this._injector.get(d).onCommandExecuted((r) => {
|
|
368
|
-
r.id === v.id && e();
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
onBeforePaste(e) {
|
|
372
|
-
return this._injector.get(d).beforeCommandExecuted((r) => {
|
|
373
|
-
r.id === _.id && e();
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
onPaste(e) {
|
|
377
|
-
return this._injector.get(d).onCommandExecuted((r) => {
|
|
378
|
-
(r.id === _.id || r.id === k) && e();
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
j.extend(ee);
|
|
383
|
-
class te extends y {
|
|
384
|
-
get BuiltInUIPart() {
|
|
385
|
-
return L;
|
|
386
|
-
}
|
|
387
|
-
get KeyCode() {
|
|
388
|
-
return A;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
y.extend(te);
|
|
1
|
+
import{FBase as e,FEnum as t,FHooks as n,FUniver as r}from"@univerjs/core/facade";import{IRenderManagerService as i}from"@univerjs/engine-render";import{BuiltInUIPart as a,ComponentManager as o,CopyCommand as s,IDialogService as c,IFontService as l,IMenuManagerService as u,IMessageService as d,IShortcutService as f,ISidebarService as p,IUIPartsService as m,KeyCode as h,MenuItemType as g,MenuManagerPosition as _,PasteCommand as v,RibbonPosition as y,RibbonStartGroup as b,SheetPasteShortKeyCommandName as x,connectInjector as S}from"@univerjs/ui";import{CommandType as C,ICommandService as w,IUniverInstanceService as T,Inject as E,Injector as D,UniverInstanceType as O,generateRandomId as k}from"@univerjs/core";function A(e){"@babel/helpers - typeof";return A=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},A(e)}function j(e,t){if(A(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(A(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function M(e){var t=j(e,`string`);return A(t)==`symbol`?t:t+``}function N(e,t,n){return(t=M(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function P(e,t){return function(n,r){t(n,r,e)}}function F(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var I=class extends e{appendTo(e){let t=typeof e==`string`?e.split(`|`):e,n=t.length,r={},i=r,a=this.__getSchema();t.forEach((e,t)=>{t===n-1?i[e]=a:i[e]={},i=i[e]}),this._menuManagerService.mergeMenu(r)}};let L=class extends I{constructor(e,t,n,r){super(),this._item=e,this._injector=t,this._commandService=n,this._menuManagerService=r,N(this,`_commandToRegister`,new Map),N(this,`_buildingSchema`,void 0);let i=typeof e.action==`string`?e.action:k(12);i!==e.action&&this._commandToRegister.set(i,e.action),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:g.BUTTON,icon:e.icon,title:e.title,tooltip:e.tooltip,commandId:i})},e.order!==void 0&&(this._buildingSchema.order=e.order)}__getSchema(){return this._commandToRegister.forEach((e,t)=>{this._commandService.hasCommand(t)||this._commandService.registerCommand({id:t,type:C.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}};N(L,`RibbonStartGroup`,b),N(L,`RibbonPosition`,y),N(L,`MenuManagerPosition`,_),L=F([P(1,E(D)),P(2,w),P(3,u)],L);let R=class extends I{constructor(e,t,n){super(),this._item=e,this._injector=t,this._menuManagerService=n,N(this,`_menuByGroups`,[]),N(this,`_submenus`,[]),N(this,`_buildingSchema`,void 0),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:g.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},e.order!==void 0&&(this._buildingSchema.order=e.order)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){let e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{let r={};t.forEach(e=>{Object.assign(r,e.__getSchema())}),e[`${this._item.id}-group-${n}`]=r}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};R=F([P(1,E(D)),P(2,u)],R);let z=class extends e{constructor(e,t,n,r){super(),this._injector=e,this._renderManagerService=t,this._univerInstanceService=n,this._shortcutService=r,N(this,`_forceDisableDisposable`,null)}enableShortcut(){var e;return(e=this._forceDisableDisposable)==null||e.dispose(),this._forceDisableDisposable=null,this}disableShortcut(){return this._forceDisableDisposable||(this._forceDisableDisposable=this._shortcutService.forceDisable()),this}triggerShortcut(e){let t=this._univerInstanceService.getCurrentUnitForType(O.UNIVER_SHEET);if(!t)return;let n=this._renderManagerService.getRenderById(t.getUnitId());if(n)return n.engine.getCanvasElement().dispatchEvent(e),this._shortcutService.dispatch(e)}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};z=F([P(0,E(D)),P(1,E(i)),P(2,T),P(3,f)],z);var B=class extends r{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(z)}copy(){return this._commandService.executeCommand(s.id)}paste(){return this._commandService.executeCommand(v.id)}createMenu(e){return this._injector.createInstance(L,e)}createSubmenu(e){return this._injector.createInstance(R,e)}openSiderbar(e){return this._injector.get(p).open(e)}openSidebar(e){return this.openSiderbar(e)}openDialog(e){let t=this._injector.get(c).open({...e,onClose:()=>{t.dispose()}});return t}getComponentManager(){return this._injector.get(o)}showMessage(e){return this._injector.get(d).show(e),this}setUIVisible(e,t){return this._injector.get(m).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(m).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(m).registerComponent(e,()=>S(t,this._injector))}registerComponent(e,t,n){let r=this._injector.get(o);return this.disposeWithMe(r.register(e,t,n))}setCurrent(e){if(!this._injector.get(i).getRenderById(e))throw Error(`Unit not found`);this._univerInstanceService.setCurrentUnitForType(e)}addFonts(e){let t=this._injector.get(l);e.forEach(e=>{t.addFont(e)})}};r.extend(B);var V=class extends n{onBeforeCopy(e){return this._injector.get(w).beforeCommandExecuted(t=>{t.id===s.id&&e()})}onCopy(e){return this._injector.get(w).onCommandExecuted(t=>{t.id===s.id&&e()})}onBeforePaste(e){return this._injector.get(w).beforeCommandExecuted(t=>{t.id===v.id&&e()})}onPaste(e){return this._injector.get(w).onCommandExecuted(t=>{(t.id===v.id||t.id===x)&&e()})}};n.extend(V);var H=class extends t{get BuiltInUIPart(){return a}get KeyCode(){return h}};t.extend(H);export{};
|