@univerjs/ui 0.20.1 → 0.21.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 +501 -1
- package/lib/cjs/index.js +8117 -87
- package/lib/cjs/locale/ca-ES.js +79 -1
- package/lib/cjs/locale/en-US.js +94 -1
- package/lib/cjs/locale/es-ES.js +79 -1
- package/lib/cjs/locale/fa-IR.js +79 -1
- package/lib/cjs/locale/fr-FR.js +79 -1
- package/lib/cjs/locale/ja-JP.js +79 -1
- package/lib/cjs/locale/ko-KR.js +79 -1
- package/lib/cjs/locale/ru-RU.js +79 -1
- package/lib/cjs/locale/sk-SK.js +79 -1
- package/lib/cjs/locale/vi-VN.js +79 -1
- package/lib/cjs/locale/zh-CN.js +79 -1
- package/lib/cjs/locale/zh-TW.js +79 -1
- package/lib/es/facade.js +502 -1
- package/lib/es/index.js +7765 -87
- package/lib/es/locale/ca-ES.js +78 -1
- package/lib/es/locale/en-US.js +93 -1
- package/lib/es/locale/es-ES.js +78 -1
- package/lib/es/locale/fa-IR.js +78 -1
- package/lib/es/locale/fr-FR.js +78 -1
- package/lib/es/locale/ja-JP.js +78 -1
- package/lib/es/locale/ko-KR.js +78 -1
- package/lib/es/locale/ru-RU.js +78 -1
- package/lib/es/locale/sk-SK.js +78 -1
- package/lib/es/locale/vi-VN.js +78 -1
- package/lib/es/locale/zh-CN.js +78 -1
- package/lib/es/locale/zh-TW.js +78 -1
- package/lib/facade.js +502 -1
- package/lib/index.js +7765 -87
- package/lib/locale/ca-ES.js +78 -1
- package/lib/locale/en-US.js +93 -1
- package/lib/locale/es-ES.js +78 -1
- package/lib/locale/fa-IR.js +78 -1
- package/lib/locale/fr-FR.js +78 -1
- package/lib/locale/ja-JP.js +78 -1
- package/lib/locale/ko-KR.js +78 -1
- package/lib/locale/ru-RU.js +78 -1
- package/lib/locale/sk-SK.js +78 -1
- package/lib/locale/vi-VN.js +78 -1
- package/lib/locale/zh-CN.js +78 -1
- package/lib/locale/zh-TW.js +78 -1
- package/lib/umd/index.js +6 -6
- package/package.json +8 -8
package/lib/es/facade.js
CHANGED
|
@@ -1 +1,502 @@
|
|
|
1
|
-
import{FBase
|
|
1
|
+
import { FBase, FEnum, FHooks, FUniver } from "@univerjs/core/facade";
|
|
2
|
+
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
3
|
+
import { BuiltInUIPart, ComponentManager, CopyCommand, IDialogService, IFontService, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, IUIPartsService, KeyCode, MenuItemType, MenuManagerPosition, PasteCommand, RibbonPosition, RibbonStartGroup, SheetPasteShortKeyCommandName, connectInjector } from "@univerjs/ui";
|
|
4
|
+
import { CommandType, ICommandService, IUniverInstanceService, Inject, Injector, UniverInstanceType, generateRandomId } from "@univerjs/core";
|
|
5
|
+
|
|
6
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
|
|
7
|
+
function _typeof(o) {
|
|
8
|
+
"@babel/helpers - typeof";
|
|
9
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
10
|
+
return typeof o;
|
|
11
|
+
} : function(o) {
|
|
12
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
13
|
+
}, _typeof(o);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
|
|
18
|
+
function toPrimitive(t, r) {
|
|
19
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
20
|
+
var e = t[Symbol.toPrimitive];
|
|
21
|
+
if (void 0 !== e) {
|
|
22
|
+
var i = e.call(t, r || "default");
|
|
23
|
+
if ("object" != _typeof(i)) return i;
|
|
24
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
25
|
+
}
|
|
26
|
+
return ("string" === r ? String : Number)(t);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
|
|
31
|
+
function toPropertyKey(t) {
|
|
32
|
+
var i = toPrimitive(t, "string");
|
|
33
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
|
|
38
|
+
function _defineProperty(e, r, t) {
|
|
39
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
40
|
+
value: t,
|
|
41
|
+
enumerable: !0,
|
|
42
|
+
configurable: !0,
|
|
43
|
+
writable: !0
|
|
44
|
+
}) : e[r] = t, e;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
|
|
49
|
+
function __decorateParam(paramIndex, decorator) {
|
|
50
|
+
return function(target, key) {
|
|
51
|
+
decorator(target, key, paramIndex);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
|
|
57
|
+
function __decorate(decorators, target, key, desc) {
|
|
58
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
59
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
60
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
61
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/facade/f-menu-builder.ts
|
|
66
|
+
/**
|
|
67
|
+
* @ignore
|
|
68
|
+
*/
|
|
69
|
+
var FMenuBase = class extends FBase {
|
|
70
|
+
/**
|
|
71
|
+
* Append the menu to any menu position on Univer UI.
|
|
72
|
+
* @param {string | string[]} path - Some predefined path to append the menu. The paths can be an array,
|
|
73
|
+
* or an array joined by `|` separator. Since lots of submenus reuse the same name,
|
|
74
|
+
* you may need to specify their parent menus as well.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* // This menu item will appear on every `contextMenu.others` section.
|
|
79
|
+
* univerAPI.createMenu({
|
|
80
|
+
* id: 'custom-menu-id-1',
|
|
81
|
+
* title: 'Custom Menu 1',
|
|
82
|
+
* action: () => {
|
|
83
|
+
* console.log('Custom Menu 1 clicked');
|
|
84
|
+
* },
|
|
85
|
+
* }).appendTo('contextMenu.others');
|
|
86
|
+
*
|
|
87
|
+
* // This menu item will only appear on the `contextMenu.others` section on the main area.
|
|
88
|
+
* univerAPI.createMenu({
|
|
89
|
+
* id: 'custom-menu-id-2',
|
|
90
|
+
* title: 'Custom Menu 2',
|
|
91
|
+
* action: () => {
|
|
92
|
+
* console.log('Custom Menu 2 clicked');
|
|
93
|
+
* },
|
|
94
|
+
* }).appendTo(['contextMenu.mainArea', 'contextMenu.others']);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
appendTo(path) {
|
|
98
|
+
const paths = typeof path === "string" ? path.split("|") : path;
|
|
99
|
+
const len = paths.length;
|
|
100
|
+
const menuConfig = {};
|
|
101
|
+
let obj = menuConfig;
|
|
102
|
+
const schema = this.__getSchema();
|
|
103
|
+
paths.forEach((p, index) => {
|
|
104
|
+
if (index === len - 1) obj[p] = schema;
|
|
105
|
+
else obj[p] = {};
|
|
106
|
+
obj = obj[p];
|
|
107
|
+
});
|
|
108
|
+
this._menuManagerService.mergeMenu(menuConfig);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
let FMenu = class FMenu extends FMenuBase {
|
|
112
|
+
constructor(_item, _injector, _commandService, _menuManagerService) {
|
|
113
|
+
super();
|
|
114
|
+
this._item = _item;
|
|
115
|
+
this._injector = _injector;
|
|
116
|
+
this._commandService = _commandService;
|
|
117
|
+
this._menuManagerService = _menuManagerService;
|
|
118
|
+
_defineProperty(this, "_commandToRegister", /* @__PURE__ */ new Map());
|
|
119
|
+
_defineProperty(this, "_buildingSchema", void 0);
|
|
120
|
+
const commandId = typeof _item.action === "string" ? _item.action : generateRandomId(12);
|
|
121
|
+
if (commandId !== _item.action) this._commandToRegister.set(commandId, _item.action);
|
|
122
|
+
this._buildingSchema = { menuItemFactory: () => ({
|
|
123
|
+
id: _item.id,
|
|
124
|
+
type: MenuItemType.BUTTON,
|
|
125
|
+
icon: _item.icon,
|
|
126
|
+
title: _item.title,
|
|
127
|
+
tooltip: _item.tooltip,
|
|
128
|
+
commandId
|
|
129
|
+
}) };
|
|
130
|
+
if (typeof _item.order !== "undefined") this._buildingSchema.order = _item.order;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* @ignore
|
|
134
|
+
*/
|
|
135
|
+
__getSchema() {
|
|
136
|
+
this._commandToRegister.forEach((command, id) => {
|
|
137
|
+
if (!this._commandService.hasCommand(id)) this._commandService.registerCommand({
|
|
138
|
+
id,
|
|
139
|
+
type: CommandType.COMMAND,
|
|
140
|
+
handler: command
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
return { [this._item.id]: this._buildingSchema };
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
_defineProperty(FMenu, "RibbonStartGroup", RibbonStartGroup);
|
|
147
|
+
_defineProperty(FMenu, "RibbonPosition", RibbonPosition);
|
|
148
|
+
_defineProperty(FMenu, "MenuManagerPosition", MenuManagerPosition);
|
|
149
|
+
FMenu = __decorate([
|
|
150
|
+
__decorateParam(1, Inject(Injector)),
|
|
151
|
+
__decorateParam(2, ICommandService),
|
|
152
|
+
__decorateParam(3, IMenuManagerService)
|
|
153
|
+
], FMenu);
|
|
154
|
+
let FSubmenu = class FSubmenu extends FMenuBase {
|
|
155
|
+
constructor(_item, _injector, _menuManagerService) {
|
|
156
|
+
super();
|
|
157
|
+
this._item = _item;
|
|
158
|
+
this._injector = _injector;
|
|
159
|
+
this._menuManagerService = _menuManagerService;
|
|
160
|
+
_defineProperty(this, "_menuByGroups", []);
|
|
161
|
+
_defineProperty(this, "_submenus", []);
|
|
162
|
+
_defineProperty(this, "_buildingSchema", void 0);
|
|
163
|
+
this._buildingSchema = { menuItemFactory: () => ({
|
|
164
|
+
id: _item.id,
|
|
165
|
+
type: MenuItemType.SUBITEMS,
|
|
166
|
+
icon: _item.icon,
|
|
167
|
+
title: _item.title,
|
|
168
|
+
tooltip: _item.tooltip
|
|
169
|
+
}) };
|
|
170
|
+
if (typeof _item.order !== "undefined") this._buildingSchema.order = _item.order;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Add a menu to the submenu. It can be a {@link FMenu} or a {@link FSubmenu}.
|
|
174
|
+
* @param {FMenu | FSubmenu} submenu - Menu to add to the submenu.
|
|
175
|
+
* @returns {FSubmenu} The FSubmenu itself for chaining calls.
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* // Create two leaf menus.
|
|
179
|
+
* const menu1 = univerAPI.createMenu({
|
|
180
|
+
* id: 'submenu-nested-1',
|
|
181
|
+
* title: 'Item 1',
|
|
182
|
+
* action: () => {
|
|
183
|
+
* console.log('Item 1 clicked');
|
|
184
|
+
* }
|
|
185
|
+
* });
|
|
186
|
+
* const menu2 = univerAPI.createMenu({
|
|
187
|
+
* id: 'submenu-nested-2',
|
|
188
|
+
* title: 'Item 2',
|
|
189
|
+
* action: () => {
|
|
190
|
+
* console.log('Item 2 clicked');
|
|
191
|
+
* }
|
|
192
|
+
* });
|
|
193
|
+
*
|
|
194
|
+
* // Add the leaf menus to a submenu.
|
|
195
|
+
* const submenu = univerAPI.createSubmenu({ id: 'submenu-nested', title: 'Nested Submenu' })
|
|
196
|
+
* .addSubmenu(menu1)
|
|
197
|
+
* .addSeparator()
|
|
198
|
+
* .addSubmenu(menu2);
|
|
199
|
+
*
|
|
200
|
+
* // Create a root submenu append to the `contextMenu.others` section.
|
|
201
|
+
* univerAPI.createSubmenu({ id: 'custom-submenu', title: 'Custom Submenu' })
|
|
202
|
+
* .addSubmenu(submenu)
|
|
203
|
+
* .appendTo('contextMenu.others');
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
addSubmenu(submenu) {
|
|
207
|
+
this._submenus.push(submenu);
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Add a separator to the submenu.
|
|
212
|
+
* @returns {FSubmenu} The FSubmenu itself for chaining calls.
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* // Create two leaf menus.
|
|
216
|
+
* const menu1 = univerAPI.createMenu({
|
|
217
|
+
* id: 'submenu-nested-1',
|
|
218
|
+
* title: 'Item 1',
|
|
219
|
+
* action: () => {
|
|
220
|
+
* console.log('Item 1 clicked');
|
|
221
|
+
* }
|
|
222
|
+
* });
|
|
223
|
+
* const menu2 = univerAPI.createMenu({
|
|
224
|
+
* id: 'submenu-nested-2',
|
|
225
|
+
* title: 'Item 2',
|
|
226
|
+
* action: () => {
|
|
227
|
+
* console.log('Item 2 clicked');
|
|
228
|
+
* }
|
|
229
|
+
* });
|
|
230
|
+
*
|
|
231
|
+
* // Add the leaf menus to a submenu and add a separator between them.
|
|
232
|
+
* // Append the submenu to the `contextMenu.others` section.
|
|
233
|
+
* univerAPI.createSubmenu({ id: 'submenu-nested', title: 'Nested Submenu' })
|
|
234
|
+
* .addSubmenu(menu1)
|
|
235
|
+
* .addSeparator()
|
|
236
|
+
* .addSubmenu(menu2)
|
|
237
|
+
* .appendTo('contextMenu.others');
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
addSeparator() {
|
|
241
|
+
this._menuByGroups.push(this._submenus);
|
|
242
|
+
this._submenus = [];
|
|
243
|
+
return this;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @ignore
|
|
247
|
+
*/
|
|
248
|
+
__getSchema() {
|
|
249
|
+
const schema = {};
|
|
250
|
+
this.addSeparator();
|
|
251
|
+
this._menuByGroups.forEach((group, index) => {
|
|
252
|
+
const groupSchema = {};
|
|
253
|
+
group.forEach((menu) => {
|
|
254
|
+
Object.assign(groupSchema, menu.__getSchema());
|
|
255
|
+
});
|
|
256
|
+
schema[`${this._item.id}-group-${index}`] = groupSchema;
|
|
257
|
+
});
|
|
258
|
+
return { [this._item.id]: Object.assign(this._buildingSchema, schema) };
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
FSubmenu = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IMenuManagerService)], FSubmenu);
|
|
262
|
+
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/facade/f-shortcut.ts
|
|
265
|
+
let FShortcut = class FShortcut extends FBase {
|
|
266
|
+
constructor(_injector, _renderManagerService, _univerInstanceService, _shortcutService) {
|
|
267
|
+
super();
|
|
268
|
+
this._injector = _injector;
|
|
269
|
+
this._renderManagerService = _renderManagerService;
|
|
270
|
+
this._univerInstanceService = _univerInstanceService;
|
|
271
|
+
this._shortcutService = _shortcutService;
|
|
272
|
+
_defineProperty(this, "_forceDisableDisposable", null);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Enable shortcuts of Univer.
|
|
276
|
+
* @returns {FShortcut} The Facade API instance itself for chaining.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* fShortcut.enableShortcut(); // Use the FShortcut instance used by disableShortcut before, do not create a new instance
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
enableShortcut() {
|
|
284
|
+
var _this$_forceDisableDi;
|
|
285
|
+
(_this$_forceDisableDi = this._forceDisableDisposable) === null || _this$_forceDisableDi === void 0 || _this$_forceDisableDi.dispose();
|
|
286
|
+
this._forceDisableDisposable = null;
|
|
287
|
+
return this;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Disable shortcuts of Univer.
|
|
291
|
+
* @returns {FShortcut} The Facade API instance itself for chaining.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```typescript
|
|
295
|
+
* const fShortcut = univerAPI.getShortcut();
|
|
296
|
+
* fShortcut.disableShortcut();
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
disableShortcut() {
|
|
300
|
+
if (!this._forceDisableDisposable) this._forceDisableDisposable = this._shortcutService.forceDisable();
|
|
301
|
+
return this;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Trigger shortcut of Univer by a KeyboardEvent and return the matched shortcut item.
|
|
305
|
+
* @param {KeyboardEvent} e - The KeyboardEvent to trigger.
|
|
306
|
+
* @returns {IShortcutItem<object> | undefined} The matched shortcut item.
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```typescript
|
|
310
|
+
* // Assum the current sheet is empty sheet.
|
|
311
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
312
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
313
|
+
* const fRange = fWorksheet.getRange('A1');
|
|
314
|
+
*
|
|
315
|
+
* // Set A1 cell active and set value to 'Hello Univer'.
|
|
316
|
+
* fRange.activate();
|
|
317
|
+
* fRange.setValue('Hello Univer');
|
|
318
|
+
* console.log(fRange.getCellStyle().bold); // false
|
|
319
|
+
*
|
|
320
|
+
* // Set A1 cell bold by shortcut.
|
|
321
|
+
* const fShortcut = univerAPI.getShortcut();
|
|
322
|
+
* const pseudoEvent = new KeyboardEvent('keydown', {
|
|
323
|
+
* key: 'b',
|
|
324
|
+
* ctrlKey: true,
|
|
325
|
+
* keyCode: univerAPI.Enum.KeyCode.B
|
|
326
|
+
* });
|
|
327
|
+
* const ifShortcutItem = fShortcut.triggerShortcut(pseudoEvent);
|
|
328
|
+
* if (ifShortcutItem) {
|
|
329
|
+
* const commandId = ifShortcutItem.id;
|
|
330
|
+
* console.log(fRange.getCellStyle().bold); // true
|
|
331
|
+
* }
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
triggerShortcut(e) {
|
|
335
|
+
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
336
|
+
if (!workbook) return;
|
|
337
|
+
const renderUnit = this._renderManagerService.getRenderById(workbook.getUnitId());
|
|
338
|
+
if (!renderUnit) return;
|
|
339
|
+
renderUnit.engine.getCanvasElement().dispatchEvent(e);
|
|
340
|
+
return this._shortcutService.dispatch(e);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Dispatch a KeyboardEvent to the shortcut service and return the matched shortcut item.
|
|
344
|
+
* @param {KeyboardEvent} e - The KeyboardEvent to dispatch.
|
|
345
|
+
* @returns {IShortcutItem<object> | undefined} The matched shortcut item.
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```typescript
|
|
349
|
+
* const fShortcut = univerAPI.getShortcut();
|
|
350
|
+
* const pseudoEvent = new KeyboardEvent('keydown', { key: 's', ctrlKey: true });
|
|
351
|
+
* const ifShortcutItem = fShortcut.dispatchShortcutEvent(pseudoEvent);
|
|
352
|
+
* if (ifShortcutItem) {
|
|
353
|
+
* const commandId = ifShortcutItem.id;
|
|
354
|
+
* // Do something with the commandId.
|
|
355
|
+
* }
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
dispatchShortcutEvent(e) {
|
|
359
|
+
return this._shortcutService.dispatch(e);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
FShortcut = __decorate([
|
|
363
|
+
__decorateParam(0, Inject(Injector)),
|
|
364
|
+
__decorateParam(1, Inject(IRenderManagerService)),
|
|
365
|
+
__decorateParam(2, IUniverInstanceService),
|
|
366
|
+
__decorateParam(3, IShortcutService)
|
|
367
|
+
], FShortcut);
|
|
368
|
+
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/facade/f-univer.ts
|
|
371
|
+
/**
|
|
372
|
+
* @ignore
|
|
373
|
+
*/
|
|
374
|
+
var FUniverUIMixin = class extends FUniver {
|
|
375
|
+
getURL() {
|
|
376
|
+
return new URL(window.location.href);
|
|
377
|
+
}
|
|
378
|
+
getShortcut() {
|
|
379
|
+
return this._injector.createInstance(FShortcut);
|
|
380
|
+
}
|
|
381
|
+
copy() {
|
|
382
|
+
return this._commandService.executeCommand(CopyCommand.id);
|
|
383
|
+
}
|
|
384
|
+
paste() {
|
|
385
|
+
return this._commandService.executeCommand(PasteCommand.id);
|
|
386
|
+
}
|
|
387
|
+
createMenu(menuItem) {
|
|
388
|
+
return this._injector.createInstance(FMenu, menuItem);
|
|
389
|
+
}
|
|
390
|
+
createSubmenu(submenuItem) {
|
|
391
|
+
return this._injector.createInstance(FSubmenu, submenuItem);
|
|
392
|
+
}
|
|
393
|
+
openSiderbar(params) {
|
|
394
|
+
return this._injector.get(ISidebarService).open(params);
|
|
395
|
+
}
|
|
396
|
+
openSidebar(params) {
|
|
397
|
+
return this.openSiderbar(params);
|
|
398
|
+
}
|
|
399
|
+
openDialog(dialog) {
|
|
400
|
+
const disposable = this._injector.get(IDialogService).open({
|
|
401
|
+
...dialog,
|
|
402
|
+
onClose: () => {
|
|
403
|
+
disposable.dispose();
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
return disposable;
|
|
407
|
+
}
|
|
408
|
+
getComponentManager() {
|
|
409
|
+
return this._injector.get(ComponentManager);
|
|
410
|
+
}
|
|
411
|
+
showMessage(options) {
|
|
412
|
+
this._injector.get(IMessageService).show(options);
|
|
413
|
+
return this;
|
|
414
|
+
}
|
|
415
|
+
setUIVisible(ui, visible) {
|
|
416
|
+
this._injector.get(IUIPartsService).setUIVisible(ui, visible);
|
|
417
|
+
return this;
|
|
418
|
+
}
|
|
419
|
+
isUIVisible(ui) {
|
|
420
|
+
return this._injector.get(IUIPartsService).isUIVisible(ui);
|
|
421
|
+
}
|
|
422
|
+
registerUIPart(key, component) {
|
|
423
|
+
return this._injector.get(IUIPartsService).registerComponent(key, () => connectInjector(component, this._injector));
|
|
424
|
+
}
|
|
425
|
+
registerComponent(name, component, options) {
|
|
426
|
+
const componentManager = this._injector.get(ComponentManager);
|
|
427
|
+
return this.disposeWithMe(componentManager.register(name, component, options));
|
|
428
|
+
}
|
|
429
|
+
setCurrent(unitId) {
|
|
430
|
+
if (!this._injector.get(IRenderManagerService).getRenderById(unitId)) throw new Error("Unit not found");
|
|
431
|
+
this._univerInstanceService.setCurrentUnitForType(unitId);
|
|
432
|
+
}
|
|
433
|
+
addFonts(fonts) {
|
|
434
|
+
const fontService = this._injector.get(IFontService);
|
|
435
|
+
fonts.forEach((font) => {
|
|
436
|
+
fontService.addFont(font);
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
FUniver.extend(FUniverUIMixin);
|
|
441
|
+
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/facade/f-hooks.ts
|
|
444
|
+
/**
|
|
445
|
+
* @ignore
|
|
446
|
+
*/
|
|
447
|
+
var FHooksSheetsMixin = class extends FHooks {
|
|
448
|
+
onBeforeCopy(callback) {
|
|
449
|
+
return this._injector.get(ICommandService).beforeCommandExecuted((command) => {
|
|
450
|
+
if (command.id === CopyCommand.id) callback();
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
onCopy(callback) {
|
|
454
|
+
return this._injector.get(ICommandService).onCommandExecuted((command) => {
|
|
455
|
+
if (command.id === CopyCommand.id) callback();
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
onBeforePaste(callback) {
|
|
459
|
+
return this._injector.get(ICommandService).beforeCommandExecuted((command) => {
|
|
460
|
+
if (command.id === PasteCommand.id) callback();
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
onPaste(callback) {
|
|
464
|
+
return this._injector.get(ICommandService).onCommandExecuted((command) => {
|
|
465
|
+
if (command.id === PasteCommand.id || command.id === SheetPasteShortKeyCommandName) callback();
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
FHooks.extend(FHooksSheetsMixin);
|
|
470
|
+
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region src/facade/f-enum.ts
|
|
473
|
+
/**
|
|
474
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
475
|
+
*
|
|
476
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
477
|
+
* you may not use this file except in compliance with the License.
|
|
478
|
+
* You may obtain a copy of the License at
|
|
479
|
+
*
|
|
480
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
481
|
+
*
|
|
482
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
483
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
484
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
485
|
+
* See the License for the specific language governing permissions and
|
|
486
|
+
* limitations under the License.
|
|
487
|
+
*/
|
|
488
|
+
/**
|
|
489
|
+
* @ignore
|
|
490
|
+
*/
|
|
491
|
+
var FUIEnumMixin = class extends FEnum {
|
|
492
|
+
get BuiltInUIPart() {
|
|
493
|
+
return BuiltInUIPart;
|
|
494
|
+
}
|
|
495
|
+
get KeyCode() {
|
|
496
|
+
return KeyCode;
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
FEnum.extend(FUIEnumMixin);
|
|
500
|
+
|
|
501
|
+
//#endregion
|
|
502
|
+
export { };
|