@univerjs/ui 0.5.4 → 0.5.5-experimental.20250123-34738ff
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 +23 -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/facade.js +211 -155
- package/lib/es/index.js +5756 -6080
- package/lib/es/locale/en-US.js +2 -2
- package/lib/es/locale/fa-IR.js +2 -2
- package/lib/es/locale/fr-FR.js +2 -2
- package/lib/es/locale/ru-RU.js +2 -2
- package/lib/es/locale/vi-VN.js +2 -2
- package/lib/es/locale/zh-CN.js +2 -2
- package/lib/es/locale/zh-TW.js +2 -2
- package/lib/index.css +1 -1
- package/lib/types/components/custom-label/CustomLabel.d.ts +2 -2
- package/lib/types/components/font-family/FontFamily.d.ts +1 -2
- package/lib/types/components/font-family/FontFamilyItem.d.ts +1 -2
- package/lib/types/components/font-size/FontSize.d.ts +1 -2
- package/lib/types/components/hooks/{__tests__/observable.spec.d.ts → index.d.ts} +5 -1
- package/lib/types/components/hooks/update-effect.d.ts +2 -0
- package/lib/types/components/hooks/useClickOutSide.d.ts +5 -0
- package/lib/types/components/menu/desktop/Menu.d.ts +1 -2
- package/lib/types/components/menu/mobile/MobileMenu.d.ts +1 -2
- package/lib/types/components/menu/mobile/MobileMenu.stories.d.ts +1 -2
- package/lib/types/components/notification/Notification.d.ts +2 -3
- package/lib/types/components/notification/Notification.stories.d.ts +1 -2
- package/lib/types/components/progress-bar/ProgressBar.d.ts +16 -2
- package/lib/types/controllers/ui/ui-mobile.controller.d.ts +3 -3
- package/lib/types/facade/f-enum.d.ts +6 -0
- package/lib/types/facade/f-hooks.d.ts +6 -0
- package/lib/types/facade/f-menu-builder.d.ts +67 -18
- package/lib/types/facade/f-shortcut.d.ts +30 -2
- package/lib/types/facade/f-univer.d.ts +17 -1
- package/lib/types/index.d.ts +3 -5
- package/lib/types/services/clipboard/clipboard-interface.service.d.ts +1 -0
- package/lib/types/services/parts/parts.service.d.ts +2 -1
- package/lib/types/views/MobileApp.d.ts +1 -2
- package/lib/types/views/components/ComponentContainer.d.ts +1 -1
- package/lib/types/views/components/confirm-part/ConfirmPart.d.ts +16 -2
- package/lib/types/views/components/context-menu/ContextMenu.d.ts +16 -2
- package/lib/types/views/components/context-menu/MobileContextMenu.d.ts +16 -2
- package/lib/types/views/components/dialog-part/DialogPart.d.ts +16 -2
- package/lib/types/views/components/dom/FloatDom.d.ts +16 -2
- package/lib/types/views/components/global-zone/GlobalZone.d.ts +16 -2
- package/lib/types/views/components/popup/CanvasPopup.d.ts +16 -2
- package/lib/types/views/components/popup/RectPopup.d.ts +3 -2
- package/lib/types/views/components/popup/dom-popup.d.ts +12 -0
- package/lib/types/views/components/popup/single-canvas-popup.d.ts +9 -0
- package/lib/types/views/components/ribbon/Button/ToolbarButton.d.ts +1 -1
- package/lib/types/views/components/ribbon/Ribbon.d.ts +2 -2
- package/lib/types/views/components/ribbon/TooltipButtonWrapper.d.ts +1 -1
- package/lib/types/views/components/shortcut-panel/ShortcutPanel.d.ts +16 -2
- package/lib/types/views/components/sidebar/Sidebar.d.ts +16 -2
- package/lib/types/views/components/zen-zone/ZenZone.d.ts +16 -2
- package/lib/types/views/workbench/Workbench.d.ts +1 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +23 -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 +9 -9
- package/LICENSE +0 -176
package/lib/cjs/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={ribbon:{start:"Start",insert:"Insert",formulas:"Formulas",data:"Data",view:"View",others:"Others",more:"More"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"Microsoft YaHei",SimSun:"SimSun",SimHei:"SimHei",Kaiti:"Kaiti",FangSong:"FangSong",NSimSun:"NSimSun",STXinwei:"STXinwei",STXingkai:"STXingkai",STLiti:"STLiti",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},"shortcut-panel":{title:"Shortcuts"},shortcut:{undo:"Undo",redo:"Redo",cut:"Cut",copy:"Copy",paste:"Paste","shortcut-panel":"Toggle Shortcut Panel"},"common-edit":"Common Editing Shortcuts","toggle-shortcut-panel":"Toggle Shortcut Panel",clipboard:{authentication:{title:"Permission Denied",content:"Please allow Univer to access your clipboard."}},textEditor:{formulaError:"Please enter a valid formula, such as =SUM(A1)",rangeError:"Please enter a valid range, such as A1:B10"},rangeSelector:{title:"Select a data range",addAnotherRange:"Add range",buttonTooltip:"Select data range",placeHolder:"Select range or enter.",confirm:"Confirm",cancel:"Cancel"},"global-shortcut":"Global Shortcut"};module.exports=locale;
|
package/lib/cjs/locale/fa-IR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={ribbon:{start:"شروع",insert:"درج",formulas:"فرمولها",data:"دادهها",view:"نمایش",others:"دیگر",more:"بیشتر"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"Microsoft YaHei",SimSun:"SimSun",SimHei:"SimHei",Kaiti:"Kaiti",FangSong:"FangSong",NSimSun:"NSimSun",STXinwei:"STXinwei",STXingkai:"STXingkai",STLiti:"STLiti",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},"shortcut-panel":{title:"کلیدهای میانبر"},shortcut:{undo:"بازگرداندن",redo:"تکرار",cut:"بریدن",copy:"کپی کردن",paste:"چسباندن","shortcut-panel":"نمایش/مخفی کردن پنل کلیدهای میانبر"},"common-edit":"کلیدهای میانبر ویرایش عمومی","toggle-shortcut-panel":"نمایش/مخفی کردن پنل کلیدهای میانبر",clipboard:{authentication:{title:"اجازه دسترسی داده نشده است",content:"لطفا به Univer اجازه دسترسی به کلیپ بورد خود را بدهید."}},textEditor:{formulaError:"لطفا یک فرمول معتبر مانند =SUM(A1) وارد کنید.",rangeError:"لطفا یک محدوده معتبر مانند A1:B10 وارد کنید."},rangeSelector:{title:"انتخاب محدوده داده",addAnotherRange:"افزودن محدوده",buttonTooltip:"انتخاب محدوده داده",placeHolder:"انتخاب محدوده یا وارد کردن.",confirm:"تایید",cancel:"انصراف"},"global-shortcut":"کلید میانبر جهانی"};module.exports=locale;
|
package/lib/cjs/locale/fr-FR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={ribbon:{start:"Démarrer",insert:"Insérer",formulas:"Formules",data:"Données",view:"Vue",others:"Autres",more:"Plus"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"Microsoft YaHei",SimSun:"SimSun",SimHei:"SimHei",Kaiti:"Kaiti",FangSong:"FangSong",NSimSun:"NSimSun",STXinwei:"STXinwei",STXingkai:"STXingkai",STLiti:"STLiti",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},"shortcut-panel":{title:"Raccourcis"},shortcut:{undo:"Annuler",redo:"Refaire",cut:"Couper",copy:"Copier",paste:"Coller","shortcut-panel":"Basculer le panneau de raccourcis"},"common-edit":"Raccourcis d'édition courants","toggle-shortcut-panel":"Basculer le panneau de raccourcis",clipboard:{authentication:{title:"Permission refusée",content:"Veuillez autoriser Univer à accéder à votre presse-papiers."}},textEditor:{formulaError:"Veuillez entrer une formule valide, telle que =SOMME(A1)",rangeError:"Veuillez entrer une plage valide, telle que A1:B10"},rangeSelector:{title:"Sélectionner une plage de données",addAnotherRange:"Ajouter une plage",buttonTooltip:"Sélectionner une plage de données",placeHolder:"Sélectionner une plage ou entrer.",confirm:"Confirmer",cancel:"Annuler"},"global-shortcut":"Raccourci global"};module.exports=locale;
|
package/lib/cjs/locale/ru-RU.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={ribbon:{start:"Начало",insert:"Вставка",formulas:"Формулы",data:"Данные",view:"Вид",others:"Другие",more:"Больше"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"Microsoft YaHei",SimSun:"SimSun",SimHei:"SimHei",Kaiti:"Kaiti",FangSong:"FangSong",NSimSun:"NSimSun",STXinwei:"STXinwei",STXingkai:"STXingkai",STLiti:"STLiti",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},"shortcut-panel":{title:"Ярлыки"},shortcut:{undo:"Отменить",redo:"Повторить",cut:"Вырезать",copy:"Копировать",paste:"Вставить","shortcut-panel":"Переключить панель ярлыков"},"common-edit":"Общие команды редактирования","toggle-shortcut-panel":"Переключить панель ярлыков",clipboard:{authentication:{title:"Доступ запрещен",content:"Пожалуйста, разрешите Univer доступ к вашему буферу обмена."}},textEditor:{formulaError:"Пожалуйста, введите корректную формулу, например =SUM(A1)",rangeError:"Пожалуйста, введите корректный диапазон, например A1:B10"},rangeSelector:{title:"Выберите диапазон данных",addAnotherRange:"Добавить диапазон",buttonTooltip:"Выбрать диапазон данных",placeHolder:"Выберите диапазон или введите.",confirm:"Подтвердить",cancel:"Отменить"},"global-shortcut":"Глобальные ярлыки"};module.exports=locale;
|
package/lib/cjs/locale/vi-VN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={ribbon:{start:"Bắt đầu",insert:"Chèn",formulas:"Công thức",data:"Dữ liệu",view:"Xem",others:"Khác",more:"Thêm"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"Microsoft YaHei",SimSun:"SimSun",SimHei:"SimHei",Kaiti:"Kaiti",FangSong:"FangSong",NSimSun:"NSimSun",STXinwei:"STXinwei",STXingkai:"STXingkai",STLiti:"STLiti",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},"shortcut-panel":{title:"Bảng phím tắt"},shortcut:{undo:"Hoàn tác",redo:"Làm lại",cut:"Cắt",copy:"Sao chép",paste:"Dán","shortcut-panel":"Mở/Đóng bảng phím tắt"},"common-edit":"Chỉnh sửa thường dùng","toggle-shortcut-panel":"Mở/Đóng bảng phím tắt",clipboard:{authentication:{title:"Không thể truy cập vào bảng nhớ tạm",content:"Vui lòng cho phép Univer truy cập vào bảng nhớ tạm của bạn."}},textEditor:{formulaError:"Vui lòng nhập công thức hợp lệ, ví dụ =SUM(A1)",rangeError:"Vui lòng nhập phạm vi hợp lệ, ví dụ A1:B10"},rangeSelector:{title:"Chọn một phạm vi dữ liệu",addAnotherRange:"Thêm phạm vi",buttonTooltip:"Chọn phạm vi dữ liệu",placeHolder:"Chọn phạm vi hoặc nhập",confirm:"Xác nhận",cancel:"Hủy"},"global-shortcut":"Phím tắt toàn cầu"};module.exports=locale;
|
package/lib/cjs/locale/zh-CN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={ribbon:{start:"开始",insert:"插入",formulas:"公式",data:"数据",view:"视图",others:"其他",more:"更多"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"微软雅黑",SimSun:"宋体",SimHei:"黑体",Kaiti:"楷体",FangSong:"仿宋",NSimSun:"新宋体",STXinwei:"华文新魏",STXingkai:"华文行楷",STLiti:"华文隶书",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},"shortcut-panel":{title:"快捷键面板"},shortcut:{undo:"撤销",redo:"重做",cut:"剪切",copy:"复制",paste:"粘贴","shortcut-panel":"打开收起快捷键面板"},"common-edit":"常用编辑","toggle-shortcut-panel":"打开收起快捷键面板",clipboard:{authentication:{title:"无法访问剪贴板",content:"请允许 Univer 访问您的剪贴板。"}},textEditor:{formulaError:"请输入合法的公式,例如=SUM(A1)",rangeError:"请输入合法的范围,例如 A1:B10"},rangeSelector:{title:"选择一个数据范围",addAnotherRange:"添加范围",buttonTooltip:"选择数据范围",placeHolder:"框选范围或输入",confirm:"确认",cancel:"取消"},"global-shortcut":"全局快捷键"};module.exports=locale;
|
package/lib/cjs/locale/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={ribbon:{start:"開始",insert:"插入",formulas:"公式",data:"資料",view:"視圖",others:"其他",more:"更多"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"微軟雅黑",SimSun:"宋體",SimHei:"黑體",Kaiti:"楷體",FangSong:"仿宋",NSimSun:"新宋體",STXinwei:"華文新魏",STXingkai:"華文行楷",STLiti:"華文隸書",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},"shortcut-panel":{title:"快捷鍵面板"},shortcut:{undo:"撤銷",redo:"重做",cut:"剪切",copy:"複製",paste:"貼上","shortcut-panel":"開啟收起快捷鍵面板"},"common-edit":"常用編輯","toggle-shortcut-panel":"開啟收起快速鍵面板",clipboard:{authentication:{title:"無法存取剪貼簿",content:"請允許 Univer 存取您的剪貼簿。 "}},textEditor:{formulaError:"請輸入合法的公式,例如=SUM(A1)",rangeError:"請輸入合法的範圍,例如 A1:B10"},rangeSelector:{title:"選擇一個資料範圍",addAnotherRange:"新增範圍",buttonTooltip:"選擇資料範圍",placeHolder:"框選範圍或輸入",confirm:"確認",cancel:"取消"},"global-shortcut":"全域快捷鍵"};module.exports=locale;
|
package/lib/es/facade.js
CHANGED
|
@@ -1,219 +1,275 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { Inject, Injector, ICommandService, Tools, CommandType, FBase, FUniver, connectInjector, FHooks, FEnum } from "@univerjs/core";
|
|
6
|
+
import { IMenuManagerService, MenuItemType, RibbonStartGroup, RibbonPosition, MenuManagerPosition, IShortcutService, CopyCommand, PasteCommand, ISidebarService, IDialogService, ComponentManager, IMessageService, IUIPartsService, SheetPasteShortKeyCommandName, BuiltInUIPart } from "@univerjs/ui";
|
|
7
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
8
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
10
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
11
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
|
|
12
|
+
const _FMenuBase = class _FMenuBase extends FBase {
|
|
13
|
+
/**
|
|
14
|
+
* Append the menu to any menu position on Univer UI.
|
|
15
|
+
* @param {string | string[]} path - Some predefined path to append the menu. The paths can be an array,
|
|
16
|
+
* or an array joined by `|` separator. Since lots of submenus reuse the same name,
|
|
17
|
+
* you may need to specify their parent menus as well.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // This menu item will appear on every `contextMenu.others` section.
|
|
22
|
+
* univerAPI.createMenu({
|
|
23
|
+
* id: 'custom-menu-id-1',
|
|
24
|
+
* title: 'Custom Menu 1',
|
|
25
|
+
* action: () => {},
|
|
26
|
+
* }).appendTo('contextMenu.others');
|
|
27
|
+
*
|
|
28
|
+
* // This menu item will only appear on the `contextMenu.others` section on the main area.
|
|
29
|
+
* univerAPI.createMenu({
|
|
30
|
+
* id: 'custom-menu-id-2',
|
|
31
|
+
* title: 'Custom Menu 2',
|
|
32
|
+
* action: () => { console.log(123); },
|
|
33
|
+
* }).appendTo(['contextMenu.mainArea', 'contextMenu.others']);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
appendTo(path) {
|
|
37
|
+
const paths = typeof path == "string" ? path.split("|") : path, len = paths.length, menuConfig = {};
|
|
38
|
+
let obj = menuConfig;
|
|
39
|
+
const schema = this.__getSchema();
|
|
40
|
+
paths.forEach((p, index) => {
|
|
41
|
+
index === len - 1 ? obj[p] = schema : obj[p] = {}, obj = obj[p];
|
|
42
|
+
}), this._menuManagerService.mergeMenu(menuConfig);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
__name(_FMenuBase, "FMenuBase");
|
|
46
|
+
let FMenuBase = _FMenuBase;
|
|
47
|
+
var _a;
|
|
48
|
+
let FMenu = (_a = class extends FMenuBase {
|
|
49
|
+
constructor(_item, _injector, _commandService, _menuManagerService) {
|
|
13
50
|
super();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this._item =
|
|
17
|
-
const
|
|
18
|
-
|
|
51
|
+
__publicField(this, "_commandToRegister", /* @__PURE__ */ new Map());
|
|
52
|
+
__publicField(this, "_buildingSchema");
|
|
53
|
+
this._item = _item, this._injector = _injector, this._commandService = _commandService, this._menuManagerService = _menuManagerService;
|
|
54
|
+
const commandId = typeof _item.action == "string" ? _item.action : Tools.generateRandomId(12);
|
|
55
|
+
commandId !== _item.action && this._commandToRegister.set(commandId, _item.action), this._buildingSchema = {
|
|
19
56
|
// eslint-disable-next-line ts/explicit-function-return-type
|
|
20
|
-
menuItemFactory: () => ({
|
|
21
|
-
id:
|
|
22
|
-
type:
|
|
57
|
+
menuItemFactory: /* @__PURE__ */ __name(() => ({
|
|
58
|
+
id: _item.id,
|
|
59
|
+
type: MenuItemType.BUTTON,
|
|
23
60
|
// we only support button for now
|
|
24
|
-
icon:
|
|
25
|
-
title:
|
|
26
|
-
tooltip:
|
|
27
|
-
commandId
|
|
28
|
-
})
|
|
29
|
-
}, typeof
|
|
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: B.COMMAND,
|
|
37
|
-
handler: e
|
|
38
|
-
});
|
|
39
|
-
}), { [this._item.id]: this._buildingSchema };
|
|
61
|
+
icon: _item.icon,
|
|
62
|
+
title: _item.title,
|
|
63
|
+
tooltip: _item.tooltip,
|
|
64
|
+
commandId
|
|
65
|
+
}), "menuItemFactory")
|
|
66
|
+
}, typeof _item.order < "u" && (this._buildingSchema.order = _item.order);
|
|
40
67
|
}
|
|
41
68
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param path Some predefined path to append the menu.
|
|
69
|
+
* @ignore
|
|
44
70
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
71
|
+
__getSchema() {
|
|
72
|
+
return this._commandToRegister.forEach((command, id) => {
|
|
73
|
+
this._commandService.hasCommand(id) || this._commandService.registerCommand({
|
|
74
|
+
id,
|
|
75
|
+
type: CommandType.COMMAND,
|
|
76
|
+
handler: command
|
|
77
|
+
});
|
|
78
|
+
}), { [this._item.id]: this._buildingSchema };
|
|
50
79
|
}
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
],
|
|
57
|
-
|
|
58
|
-
|
|
80
|
+
}, __name(_a, "FMenu"), __publicField(_a, "RibbonStartGroup", RibbonStartGroup), __publicField(_a, "RibbonPosition", RibbonPosition), __publicField(_a, "MenuManagerPosition", MenuManagerPosition), _a);
|
|
81
|
+
FMenu = __decorateClass$1([
|
|
82
|
+
__decorateParam$1(1, Inject(Injector)),
|
|
83
|
+
__decorateParam$1(2, ICommandService),
|
|
84
|
+
__decorateParam$1(3, IMenuManagerService)
|
|
85
|
+
], FMenu);
|
|
86
|
+
var _a2;
|
|
87
|
+
let FSubmenu = (_a2 = class extends FMenuBase {
|
|
88
|
+
constructor(_item, _injector, _menuManagerService) {
|
|
59
89
|
super();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this._item =
|
|
90
|
+
__publicField(this, "_menuByGroups", []);
|
|
91
|
+
__publicField(this, "_submenus", []);
|
|
92
|
+
__publicField(this, "_buildingSchema");
|
|
93
|
+
this._item = _item, this._injector = _injector, this._menuManagerService = _menuManagerService, this._buildingSchema = {
|
|
64
94
|
// eslint-disable-next-line ts/explicit-function-return-type
|
|
65
|
-
menuItemFactory: () => ({
|
|
66
|
-
id:
|
|
67
|
-
type:
|
|
68
|
-
icon:
|
|
69
|
-
title:
|
|
70
|
-
tooltip:
|
|
71
|
-
})
|
|
72
|
-
}, typeof
|
|
95
|
+
menuItemFactory: /* @__PURE__ */ __name(() => ({
|
|
96
|
+
id: _item.id,
|
|
97
|
+
type: MenuItemType.SUBITEMS,
|
|
98
|
+
icon: _item.icon,
|
|
99
|
+
title: _item.title,
|
|
100
|
+
tooltip: _item.tooltip
|
|
101
|
+
}), "menuItemFactory")
|
|
102
|
+
}, typeof _item.order < "u" && (this._buildingSchema.order = _item.order);
|
|
73
103
|
}
|
|
74
104
|
/**
|
|
75
105
|
* 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.
|
|
106
|
+
* @param {FMenu | FSubmenu} submenu - Menu to add to the submenu.
|
|
107
|
+
* @returns {FSubmenu} The FSubmenu itself for chaining calls.
|
|
78
108
|
*/
|
|
79
|
-
addSubmenu(
|
|
80
|
-
return this._submenus.push(
|
|
109
|
+
addSubmenu(submenu) {
|
|
110
|
+
return this._submenus.push(submenu), this;
|
|
81
111
|
}
|
|
82
112
|
/**
|
|
83
113
|
* Add a separator to the submenu.
|
|
84
|
-
* @returns The FSubmenu itself for chaining calls.
|
|
114
|
+
* @returns {FSubmenu} The FSubmenu itself for chaining calls.
|
|
85
115
|
*/
|
|
86
116
|
addSeparator() {
|
|
87
117
|
return this._menuByGroups.push(this._submenus), this._submenus = [], this;
|
|
88
118
|
}
|
|
89
119
|
/**
|
|
90
|
-
*
|
|
91
|
-
* @param path Some predefined path to append the menu.
|
|
120
|
+
* @ignore
|
|
92
121
|
*/
|
|
93
|
-
appendTo(e) {
|
|
94
|
-
const t = this.__getSchema();
|
|
95
|
-
this._menuManagerService.mergeMenu({
|
|
96
|
-
[e]: t
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
/** @ignore */
|
|
100
122
|
__getSchema() {
|
|
101
|
-
const
|
|
102
|
-
return this.addSeparator(), this._menuByGroups.forEach((
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
Object.assign(
|
|
106
|
-
}),
|
|
107
|
-
}), { [this._item.id]: Object.assign(this._buildingSchema,
|
|
123
|
+
const schema = {};
|
|
124
|
+
return this.addSeparator(), this._menuByGroups.forEach((group, index) => {
|
|
125
|
+
const groupSchema = {};
|
|
126
|
+
group.forEach((menu) => {
|
|
127
|
+
Object.assign(groupSchema, menu.__getSchema());
|
|
128
|
+
}), schema[`${this._item.id}-group-${index}`] = groupSchema;
|
|
129
|
+
}), { [this._item.id]: Object.assign(this._buildingSchema, schema) };
|
|
108
130
|
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
],
|
|
114
|
-
var
|
|
115
|
-
for (var
|
|
116
|
-
(
|
|
117
|
-
return
|
|
118
|
-
},
|
|
119
|
-
let
|
|
120
|
-
constructor(
|
|
131
|
+
}, __name(_a2, "FSubmenu"), _a2);
|
|
132
|
+
FSubmenu = __decorateClass$1([
|
|
133
|
+
__decorateParam$1(1, Inject(Injector)),
|
|
134
|
+
__decorateParam$1(2, IMenuManagerService)
|
|
135
|
+
], FSubmenu);
|
|
136
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
137
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
138
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
139
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
140
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a3;
|
|
141
|
+
let FShortcut = (_a3 = class extends FBase {
|
|
142
|
+
constructor(_injector, _shortcutService) {
|
|
121
143
|
super();
|
|
122
|
-
|
|
123
|
-
this._injector =
|
|
144
|
+
__publicField(this, "_forceEscapeDisposable", null);
|
|
145
|
+
this._injector = _injector, this._shortcutService = _shortcutService;
|
|
124
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Enable shortcuts of Univer.
|
|
149
|
+
* @returns {FShortcut} The Facade API instance itself for chaining.
|
|
150
|
+
*/
|
|
125
151
|
enableShortcut() {
|
|
126
|
-
var
|
|
127
|
-
(
|
|
152
|
+
var _a4;
|
|
153
|
+
return (_a4 = this._forceEscapeDisposable) == null || _a4.dispose(), this._forceEscapeDisposable = null, this;
|
|
128
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Disable shortcuts of Univer.
|
|
157
|
+
* @returns {FShortcut} The Facade API instance itself for chaining.
|
|
158
|
+
*/
|
|
129
159
|
disableShortcut() {
|
|
130
|
-
this._forceEscapeDisposable || (this._forceEscapeDisposable = this._shortcutService.forceEscape());
|
|
160
|
+
return this._forceEscapeDisposable || (this._forceEscapeDisposable = this._shortcutService.forceEscape()), this;
|
|
131
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Dispatch a KeyboardEvent to the shortcut service and return the matched shortcut item.
|
|
164
|
+
* @param {KeyboardEvent} e - The KeyboardEvent to dispatch.
|
|
165
|
+
* @returns {IShortcutItem<object> | undefined} The matched shortcut item.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const fShortcut = univerAPI.getShortcut();
|
|
170
|
+
* const pseudoEvent = new KeyboardEvent('keydown', { key: 's', ctrlKey: true });
|
|
171
|
+
* const ifShortcutItem = fShortcut.dispatchShortcutEvent(pseudoEvent);
|
|
172
|
+
* if (ifShortcutItem) {
|
|
173
|
+
* const commandId = ifShortcutItem.id;
|
|
174
|
+
* // Do something with the commandId.
|
|
175
|
+
* }
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
132
178
|
dispatchShortcutEvent(e) {
|
|
133
179
|
return this._shortcutService.dispatch(e);
|
|
134
180
|
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
],
|
|
140
|
-
class
|
|
181
|
+
}, __name(_a3, "FShortcut"), _a3);
|
|
182
|
+
FShortcut = __decorateClass([
|
|
183
|
+
__decorateParam(0, Inject(Injector)),
|
|
184
|
+
__decorateParam(1, IShortcutService)
|
|
185
|
+
], FShortcut);
|
|
186
|
+
const _FUniverUIMixin = class _FUniverUIMixin extends FUniver {
|
|
141
187
|
getURL() {
|
|
142
188
|
return new URL(window.location.href);
|
|
143
189
|
}
|
|
144
190
|
getShortcut() {
|
|
145
|
-
return this._injector.createInstance(
|
|
191
|
+
return this._injector.createInstance(FShortcut);
|
|
146
192
|
}
|
|
147
193
|
copy() {
|
|
148
|
-
return this._commandService.
|
|
194
|
+
return this._commandService.syncExecuteCommand(CopyCommand.id);
|
|
149
195
|
}
|
|
150
196
|
paste() {
|
|
151
|
-
return this._commandService.
|
|
197
|
+
return this._commandService.syncExecuteCommand(PasteCommand.id);
|
|
152
198
|
}
|
|
153
|
-
createMenu(
|
|
154
|
-
return this._injector.createInstance(
|
|
199
|
+
createMenu(menuItem) {
|
|
200
|
+
return this._injector.createInstance(FMenu, menuItem);
|
|
155
201
|
}
|
|
156
|
-
createSubmenu(
|
|
157
|
-
return this._injector.createInstance(
|
|
202
|
+
createSubmenu(submenuItem) {
|
|
203
|
+
return this._injector.createInstance(FSubmenu, submenuItem);
|
|
158
204
|
}
|
|
159
|
-
openSiderbar(
|
|
160
|
-
return this._injector.get(
|
|
205
|
+
openSiderbar(params) {
|
|
206
|
+
return this._injector.get(ISidebarService).open(params);
|
|
161
207
|
}
|
|
162
|
-
openSidebar(
|
|
163
|
-
return this.openSiderbar(
|
|
208
|
+
openSidebar(params) {
|
|
209
|
+
return this.openSiderbar(params);
|
|
164
210
|
}
|
|
165
|
-
openDialog(
|
|
166
|
-
const
|
|
167
|
-
...
|
|
168
|
-
onClose: () => {
|
|
169
|
-
|
|
170
|
-
}
|
|
211
|
+
openDialog(dialog) {
|
|
212
|
+
const disposable = this._injector.get(IDialogService).open({
|
|
213
|
+
...dialog,
|
|
214
|
+
onClose: /* @__PURE__ */ __name(() => {
|
|
215
|
+
disposable.dispose();
|
|
216
|
+
}, "onClose")
|
|
171
217
|
});
|
|
172
|
-
return
|
|
218
|
+
return disposable;
|
|
173
219
|
}
|
|
174
220
|
getComponentManager() {
|
|
175
|
-
return this._injector.get(
|
|
221
|
+
return this._injector.get(ComponentManager);
|
|
222
|
+
}
|
|
223
|
+
showMessage(options) {
|
|
224
|
+
return this._injector.get(IMessageService).show(options), this;
|
|
176
225
|
}
|
|
177
|
-
|
|
178
|
-
return this._injector.get(
|
|
226
|
+
setUIVisible(ui, visible) {
|
|
227
|
+
return this._injector.get(IUIPartsService).setUIVisible(ui, visible), this;
|
|
179
228
|
}
|
|
180
|
-
|
|
181
|
-
return this._injector.get(
|
|
229
|
+
isUIVisible(ui) {
|
|
230
|
+
return this._injector.get(IUIPartsService).isUIVisible(ui);
|
|
182
231
|
}
|
|
183
|
-
|
|
184
|
-
return this._injector.get(
|
|
232
|
+
registerUIPart(key, component) {
|
|
233
|
+
return this._injector.get(IUIPartsService).registerComponent(key, () => connectInjector(component, this._injector));
|
|
185
234
|
}
|
|
186
|
-
|
|
187
|
-
|
|
235
|
+
registerComponent(name, component, options) {
|
|
236
|
+
const componentManager = this._injector.get(ComponentManager);
|
|
237
|
+
return this.disposeWithMe(componentManager.register(name, component, options));
|
|
188
238
|
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
239
|
+
};
|
|
240
|
+
__name(_FUniverUIMixin, "FUniverUIMixin");
|
|
241
|
+
let FUniverUIMixin = _FUniverUIMixin;
|
|
242
|
+
FUniver.extend(FUniverUIMixin);
|
|
243
|
+
const _FHooksSheetsMixin = class _FHooksSheetsMixin extends FHooks {
|
|
244
|
+
onBeforeCopy(callback) {
|
|
245
|
+
return this._injector.get(ICommandService).beforeCommandExecuted((command) => {
|
|
246
|
+
command.id === CopyCommand.id && callback();
|
|
195
247
|
});
|
|
196
248
|
}
|
|
197
|
-
onCopy(
|
|
198
|
-
return this._injector.get(
|
|
199
|
-
|
|
249
|
+
onCopy(callback) {
|
|
250
|
+
return this._injector.get(ICommandService).onCommandExecuted((command) => {
|
|
251
|
+
command.id === CopyCommand.id && callback();
|
|
200
252
|
});
|
|
201
253
|
}
|
|
202
|
-
onBeforePaste(
|
|
203
|
-
return this._injector.get(
|
|
204
|
-
|
|
254
|
+
onBeforePaste(callback) {
|
|
255
|
+
return this._injector.get(ICommandService).beforeCommandExecuted((command) => {
|
|
256
|
+
command.id === PasteCommand.id && callback();
|
|
205
257
|
});
|
|
206
258
|
}
|
|
207
|
-
onPaste(
|
|
208
|
-
return this._injector.get(
|
|
209
|
-
(
|
|
259
|
+
onPaste(callback) {
|
|
260
|
+
return this._injector.get(ICommandService).onCommandExecuted((command) => {
|
|
261
|
+
(command.id === PasteCommand.id || command.id === SheetPasteShortKeyCommandName) && callback();
|
|
210
262
|
});
|
|
211
263
|
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
264
|
+
};
|
|
265
|
+
__name(_FHooksSheetsMixin, "FHooksSheetsMixin");
|
|
266
|
+
let FHooksSheetsMixin = _FHooksSheetsMixin;
|
|
267
|
+
FHooks.extend(FHooksSheetsMixin);
|
|
268
|
+
const _FUIEnum = class _FUIEnum extends FEnum {
|
|
215
269
|
get BuiltInUIPart() {
|
|
216
|
-
return
|
|
270
|
+
return BuiltInUIPart;
|
|
217
271
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
272
|
+
};
|
|
273
|
+
__name(_FUIEnum, "FUIEnum");
|
|
274
|
+
let FUIEnum = _FUIEnum;
|
|
275
|
+
FEnum.extend(FUIEnum);
|