@opensumi/ide-core-browser 2.21.8-rc-1670567192.0 → 2.21.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/components/actions/index.d.ts.map +1 -1
- package/lib/components/actions/index.js +22 -2
- package/lib/components/actions/index.js.map +1 -1
- package/lib/components/tree/tree.module.less +0 -1
- package/lib/contextkey/testing.d.ts +0 -1
- package/lib/contextkey/testing.d.ts.map +1 -1
- package/lib/contextkey/testing.js +1 -2
- package/lib/contextkey/testing.js.map +1 -1
- package/lib/menu/next/menu.contrib.interface.d.ts +2 -3
- package/lib/menu/next/menu.contrib.interface.d.ts.map +1 -1
- package/lib/menu/next/menu.contrib.interface.js.map +1 -1
- package/lib/preferences/preference-configurations.js +1 -1
- package/lib/preferences/preference-configurations.js.map +1 -1
- package/lib/react-providers/config-provider.d.ts +0 -4
- package/lib/react-providers/config-provider.d.ts.map +1 -1
- package/lib/react-providers/config-provider.js.map +1 -1
- package/lib/services/storage-service.d.ts.map +1 -1
- package/lib/services/storage-service.js +1 -7
- package/lib/services/storage-service.js.map +1 -1
- package/lib/utils/label.d.ts.map +1 -1
- package/lib/utils/label.js +9 -16
- package/lib/utils/label.js.map +1 -1
- package/package.json +6 -7
- package/src/application/application-state-service.ts +0 -54
- package/src/application/application.service.ts +0 -51
- package/src/application/index.ts +0 -2
- package/src/authentication/authentication.contribution.ts +0 -35
- package/src/authentication/authentication.service.ts +0 -517
- package/src/bootstrap/app.ts +0 -745
- package/src/bootstrap/app.view.tsx +0 -88
- package/src/bootstrap/connection.ts +0 -116
- package/src/bootstrap/index.ts +0 -3
- package/src/bootstrap/inner-providers.ts +0 -297
- package/src/bootstrap/lifecycle.service.ts +0 -19
- package/src/browser-module.ts +0 -24
- package/src/common/common.command.ts +0 -977
- package/src/common/common.contribution.ts +0 -343
- package/src/common/common.define.ts +0 -55
- package/src/common/common.module.ts +0 -33
- package/src/common/common.storage.ts +0 -22
- package/src/common/container-id.ts +0 -12
- package/src/common/index.ts +0 -4
- package/src/components/actions/index.tsx +0 -486
- package/src/components/actions/placements.ts +0 -47
- package/src/components/actions/styles.module.less +0 -144
- package/src/components/badge/index.tsx +0 -1
- package/src/components/index.ts +0 -26
- package/src/components/layout/box-panel.tsx +0 -88
- package/src/components/layout/default-layout.tsx +0 -61
- package/src/components/layout/index.ts +0 -4
- package/src/components/layout/layout.ts +0 -80
- package/src/components/layout/split-panel.service.ts +0 -56
- package/src/components/layout/split-panel.tsx +0 -296
- package/src/components/layout/styles.module.less +0 -21
- package/src/components/loading/index.ts +0 -1
- package/src/components/loading/loading.less +0 -14
- package/src/components/loading/loading.view.tsx +0 -7
- package/src/components/loading/media/loading-dark.svg +0 -52
- package/src/components/loading/media/loading-hc.svg +0 -52
- package/src/components/loading/media/loading.svg +0 -52
- package/src/components/popover/styles.module.less +0 -81
- package/src/components/portal/index.tsx +0 -13
- package/src/components/progressbar/index.tsx +0 -16
- package/src/components/progressbar/styles.module.less +0 -31
- package/src/components/recycle-tree/index.ts +0 -1
- package/src/components/recycle-tree/recycle-tree.view.tsx +0 -368
- package/src/components/resize/resize.module.less +0 -78
- package/src/components/resize/resize.tsx +0 -663
- package/src/components/scroll/index.tsx +0 -386
- package/src/components/scroll/scroll.module.less +0 -108
- package/src/components/scrollbar/index.ts +0 -1
- package/src/components/scrollbar/scrollbar.less +0 -36
- package/src/components/scrollbar/scrollbar.view.ts +0 -8
- package/src/components/select/index.tsx +0 -12
- package/src/components/select/styles.less +0 -6
- package/src/components/tree/index.ts +0 -3
- package/src/components/tree/tree-node.view.tsx +0 -546
- package/src/components/tree/tree.module.less +0 -297
- package/src/components/tree/tree.view.tsx +0 -486
- package/src/context-key.ts +0 -48
- package/src/contextkey/dialog.ts +0 -3
- package/src/contextkey/explorer.ts +0 -26
- package/src/contextkey/index.ts +0 -6
- package/src/contextkey/outline.ts +0 -4
- package/src/contextkey/resource.ts +0 -61
- package/src/contextkey/terminal.ts +0 -7
- package/src/contextkey/testing.ts +0 -9
- package/src/contextkey/workspace.ts +0 -7
- package/src/core-preferences.ts +0 -318
- package/src/dom/index.ts +0 -176
- package/src/encoding-registry.ts +0 -83
- package/src/extensions/extensions-point.service.ts +0 -78
- package/src/extensions/index.ts +0 -3
- package/src/extensions/schema/browserViews.ts +0 -96
- package/src/extensions/schema/menu.ts +0 -245
- package/src/extensions/schema/opensumiExtensionPackageSchema.ts +0 -12
- package/src/extensions/schema/toolbar.ts +0 -338
- package/src/extensions/schema/vscodeExtensionPackageSchema.ts +0 -330
- package/src/fs/index.ts +0 -12
- package/src/hash-calculate/hash-calculate.contribution.ts +0 -19
- package/src/index.ts +0 -42
- package/src/keybinding/index.ts +0 -1
- package/src/keybinding/keybinding.ts +0 -908
- package/src/keyboard/index.ts +0 -3
- package/src/keyboard/keyboard-layout-provider.ts +0 -412
- package/src/keyboard/keyboard-layout-service.ts +0 -449
- package/src/keyboard/keys.ts +0 -748
- package/src/keyboard/layouts/_.contribution.ts +0 -24
- package/src/keyboard/layouts/cz.win.ts +0 -168
- package/src/keyboard/layouts/de-swiss.win.ts +0 -168
- package/src/keyboard/layouts/de.darwin.ts +0 -131
- package/src/keyboard/layouts/de.linux.ts +0 -186
- package/src/keyboard/layouts/de.win.ts +0 -168
- package/src/keyboard/layouts/dk.win.ts +0 -168
- package/src/keyboard/layouts/dvorak.darwin.ts +0 -131
- package/src/keyboard/layouts/en-belgian.win.ts +0 -168
- package/src/keyboard/layouts/en-ext.darwin.ts +0 -131
- package/src/keyboard/layouts/en-in.win.ts +0 -168
- package/src/keyboard/layouts/en-intl.darwin.ts +0 -131
- package/src/keyboard/layouts/en-intl.win.ts +0 -168
- package/src/keyboard/layouts/en-uk.darwin.ts +0 -131
- package/src/keyboard/layouts/en-uk.win.ts +0 -168
- package/src/keyboard/layouts/en.darwin.ts +0 -139
- package/src/keyboard/layouts/en.linux.ts +0 -186
- package/src/keyboard/layouts/en.win.ts +0 -173
- package/src/keyboard/layouts/es-latin.win.ts +0 -168
- package/src/keyboard/layouts/es.darwin.ts +0 -131
- package/src/keyboard/layouts/es.linux.ts +0 -186
- package/src/keyboard/layouts/es.win.ts +0 -168
- package/src/keyboard/layouts/fr.darwin.ts +0 -131
- package/src/keyboard/layouts/fr.linux.ts +0 -186
- package/src/keyboard/layouts/fr.win.ts +0 -168
- package/src/keyboard/layouts/hu.win.ts +0 -168
- package/src/keyboard/layouts/it.darwin.ts +0 -131
- package/src/keyboard/layouts/it.win.ts +0 -168
- package/src/keyboard/layouts/jp-roman.darwin.ts +0 -131
- package/src/keyboard/layouts/jp.darwin.ts +0 -131
- package/src/keyboard/layouts/ko.darwin.ts +0 -131
- package/src/keyboard/layouts/layout.contribution.darwin.ts +0 -23
- package/src/keyboard/layouts/layout.contribution.linux.ts +0 -12
- package/src/keyboard/layouts/layout.contribution.ts +0 -9
- package/src/keyboard/layouts/layout.contribution.win.ts +0 -29
- package/src/keyboard/layouts/no.win.ts +0 -168
- package/src/keyboard/layouts/pl.darwin.ts +0 -131
- package/src/keyboard/layouts/pl.win.ts +0 -168
- package/src/keyboard/layouts/pt-br.win.ts +0 -169
- package/src/keyboard/layouts/pt.darwin.ts +0 -131
- package/src/keyboard/layouts/pt.win.ts +0 -168
- package/src/keyboard/layouts/ru.darwin.ts +0 -131
- package/src/keyboard/layouts/ru.linux.ts +0 -186
- package/src/keyboard/layouts/ru.win.ts +0 -168
- package/src/keyboard/layouts/sv.darwin.ts +0 -131
- package/src/keyboard/layouts/sv.win.ts +0 -168
- package/src/keyboard/layouts/thai.win.ts +0 -168
- package/src/keyboard/layouts/tr.win.ts +0 -168
- package/src/keyboard/layouts/zh-hans.darwin.ts +0 -131
- package/src/layout/accordion/tab-bar-toolbar.tsx +0 -59
- package/src/layout/accordion/view-context-key.registry.ts +0 -34
- package/src/layout/constants.ts +0 -7
- package/src/layout/index.ts +0 -5
- package/src/layout/layout-hooks.ts +0 -68
- package/src/layout/layout-state.ts +0 -107
- package/src/layout/layout.interface.ts +0 -101
- package/src/layout/layout.ts +0 -80
- package/src/layout/view-id.ts +0 -18
- package/src/logger/browser-logger.ts +0 -51
- package/src/logger/index.ts +0 -1
- package/src/markdown/index.tsx +0 -62
- package/src/menu/next/base.ts +0 -513
- package/src/menu/next/ctxmenu-service.ts +0 -188
- package/src/menu/next/index.ts +0 -10
- package/src/menu/next/menu-id.ts +0 -86
- package/src/menu/next/menu-service.ts +0 -252
- package/src/menu/next/menu-util.ts +0 -77
- package/src/menu/next/menu.contrib.interface.ts +0 -79
- package/src/menu/next/menu.interface.ts +0 -253
- package/src/menu/next/menubar-service.ts +0 -211
- package/src/menu/next/renderer/ctxmenu/base.ts +0 -18
- package/src/menu/next/renderer/ctxmenu/browser.ts +0 -45
- package/src/menu/next/renderer/ctxmenu/electron.ts +0 -207
- package/src/menu/next/toolbar-action.service.ts +0 -132
- package/src/monaco/index.ts +0 -128
- package/src/opener/command-opener.ts +0 -42
- package/src/opener/default-opener.ts +0 -31
- package/src/opener/http-opener.ts +0 -25
- package/src/opener/index.ts +0 -19
- package/src/opener/opener.contribution.ts +0 -57
- package/src/opener/opener.service.ts +0 -66
- package/src/preferences/early-preferences.ts +0 -117
- package/src/preferences/index.ts +0 -9
- package/src/preferences/preference-configurations.ts +0 -77
- package/src/preferences/preference-contribution.ts +0 -401
- package/src/preferences/preference-provider.ts +0 -414
- package/src/preferences/preference-proxy.ts +0 -292
- package/src/preferences/preference-scope.ts +0 -3
- package/src/preferences/preference-service.ts +0 -571
- package/src/preferences/settings.ts +0 -53
- package/src/preferences/types.ts +0 -111
- package/src/progress/index.ts +0 -58
- package/src/progress/progress-bar.tsx +0 -22
- package/src/progress/progress-indicator.ts +0 -90
- package/src/progress/progress.module.less +0 -46
- package/src/progress/progress.service.tsx +0 -429
- package/src/quick-open/index.ts +0 -655
- package/src/quick-open/recent-files.ts +0 -68
- package/src/raw-context-key.ts +0 -116
- package/src/react-hooks/event.tsx +0 -80
- package/src/react-hooks/hot-key.tsx +0 -58
- package/src/react-hooks/index.ts +0 -3
- package/src/react-hooks/injectable-hooks.tsx +0 -35
- package/src/react-hooks/portal-hooks.tsx +0 -38
- package/src/react-providers/config-provider.tsx +0 -263
- package/src/react-providers/index.tsx +0 -2
- package/src/react-providers/slot.module.less +0 -19
- package/src/react-providers/slot.tsx +0 -242
- package/src/services/clipboard.service.ts +0 -97
- package/src/services/credentials-service.ts +0 -91
- package/src/services/crypto-service.ts +0 -23
- package/src/services/external-uri.service.ts +0 -68
- package/src/services/index.ts +0 -7
- package/src/services/label-service.ts +0 -386
- package/src/services/status-bar-service.ts +0 -108
- package/src/services/storage-service.ts +0 -197
- package/src/style/codicons/README.md +0 -22
- package/src/style/codicons/codicon-animations.css +0 -15
- package/src/style/codicons/generator.js +0 -15
- package/src/style/entry.less +0 -25
- package/src/style/icon/fileicons/file-default.svg +0 -1
- package/src/style/icon/fileicons/folder-default.svg +0 -1
- package/src/style/icon/fileicons.less +0 -20
- package/src/style/icon/icon.ts +0 -543
- package/src/style/icon/ide-iconfont.ts +0 -13
- package/src/style/icon/index.less +0 -54
- package/src/style/icon/seti.woff +0 -0
- package/src/style/icon/symbol-icons/boolean-dark.svg +0 -3
- package/src/style/icon/symbol-icons/boolean-light.svg +0 -3
- package/src/style/icon/symbol-icons/class-dark.svg +0 -3
- package/src/style/icon/symbol-icons/class-light.svg +0 -3
- package/src/style/icon/symbol-icons/constant-dark.svg +0 -4
- package/src/style/icon/symbol-icons/constant-light.svg +0 -4
- package/src/style/icon/symbol-icons/enumerator-dark.svg +0 -3
- package/src/style/icon/symbol-icons/enumerator-item-dark.svg +0 -3
- package/src/style/icon/symbol-icons/enumerator-item-light.svg +0 -3
- package/src/style/icon/symbol-icons/enumerator-light.svg +0 -3
- package/src/style/icon/symbol-icons/event-dark.svg +0 -3
- package/src/style/icon/symbol-icons/event-light.svg +0 -3
- package/src/style/icon/symbol-icons/field-dark.svg +0 -3
- package/src/style/icon/symbol-icons/field-light.svg +0 -3
- package/src/style/icon/symbol-icons/file-dark.svg +0 -3
- package/src/style/icon/symbol-icons/file-light.svg +0 -3
- package/src/style/icon/symbol-icons/indexer-dark.svg +0 -3
- package/src/style/icon/symbol-icons/indexer-light.svg +0 -3
- package/src/style/icon/symbol-icons/interface-dark.svg +0 -3
- package/src/style/icon/symbol-icons/interface-light.svg +0 -3
- package/src/style/icon/symbol-icons/keyword-dark.svg +0 -3
- package/src/style/icon/symbol-icons/keyword-light.svg +0 -3
- package/src/style/icon/symbol-icons/method-dark.svg +0 -3
- package/src/style/icon/symbol-icons/method-light.svg +0 -3
- package/src/style/icon/symbol-icons/namespace-dark.svg +0 -3
- package/src/style/icon/symbol-icons/namespace-light.svg +0 -3
- package/src/style/icon/symbol-icons/numeric-dark.svg +0 -3
- package/src/style/icon/symbol-icons/numeric-light.svg +0 -3
- package/src/style/icon/symbol-icons/operator-dark.svg +0 -3
- package/src/style/icon/symbol-icons/operator-light.svg +0 -3
- package/src/style/icon/symbol-icons/property-dark.svg +0 -3
- package/src/style/icon/symbol-icons/property-light.svg +0 -3
- package/src/style/icon/symbol-icons/snippet-dark.svg +0 -3
- package/src/style/icon/symbol-icons/snippet-light.svg +0 -3
- package/src/style/icon/symbol-icons/string-dark.svg +0 -3
- package/src/style/icon/symbol-icons/string-light.svg +0 -3
- package/src/style/icon/symbol-icons/structure-dark.svg +0 -3
- package/src/style/icon/symbol-icons/structure-light.svg +0 -3
- package/src/style/icon/symbol-icons/symbol-icons.css +0 -284
- package/src/style/icon/symbol-icons/template-dark.svg +0 -3
- package/src/style/icon/symbol-icons/template-light.svg +0 -3
- package/src/style/icon/symbol-icons/variable-dark.svg +0 -3
- package/src/style/icon/symbol-icons/variable-light.svg +0 -3
- package/src/style/icon.less +0 -8
- package/src/style/index.less +0 -14
- package/src/style/monaco-override.less +0 -116
- package/src/style/normalize.less +0 -92
- package/src/style/octicons/octicons-cdn.css +0 -720
- package/src/style/octicons/octicons.css +0 -714
- package/src/style/octicons/octicons.html +0 -1882
- package/src/style/octicons/octicons.svg +0 -582
- package/src/style/octicons/octicons.ttf +0 -0
- package/src/style/override.less +0 -97
- package/src/style/toolbar.less +0 -199
- package/src/style/utilities.less +0 -8
- package/src/style/variable.less +0 -8
- package/src/terminal/index.ts +0 -7
- package/src/toolbar/components/auto-complete.tsx +0 -0
- package/src/toolbar/components/button.tsx +0 -440
- package/src/toolbar/components/index.ts +0 -2
- package/src/toolbar/components/select.tsx +0 -189
- package/src/toolbar/index.ts +0 -3
- package/src/toolbar/toolbar.popover.registry.ts +0 -32
- package/src/toolbar/toolbar.registry.ts +0 -352
- package/src/toolbar/toolbar.tsx +0 -710
- package/src/toolbar/types.ts +0 -383
- package/src/tree/index.ts +0 -3
- package/src/tree/tree-expansion.ts +0 -25
- package/src/tree/tree-selection.ts +0 -89
- package/src/tree/tree.ts +0 -294
- package/src/utils/create-overlay.tsx +0 -53
- package/src/utils/electron.ts +0 -92
- package/src/utils/env.ts +0 -26
- package/src/utils/icon.ts +0 -13
- package/src/utils/index.ts +0 -7
- package/src/utils/json.ts +0 -251
- package/src/utils/label.tsx +0 -36
- package/src/utils/parse.ts +0 -72
- package/src/utils/react-hooks.ts +0 -118
- package/src/variable/index.ts +0 -1
- package/src/variable/variable.ts +0 -84
- package/src/window/index.ts +0 -34
- package/src/window/window.service.ts +0 -100
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { Autowired, Injectable, Optional } from '@opensumi/di';
|
|
2
|
-
import { CommandRegistry, CommandService, Command, IDisposable, isMacintosh, Event } from '@opensumi/ide-core-common';
|
|
3
|
-
|
|
4
|
-
import { IContextKeyService } from '../../context-key';
|
|
5
|
-
import { KeybindingRegistry } from '../../keybinding';
|
|
6
|
-
|
|
7
|
-
import { ISubmenuItem, MenuNode, IMenuActionDisplayType, IComponentMenuItem, IComponentMenuItemProps } from './base';
|
|
8
|
-
import { MenuId } from './menu-id';
|
|
9
|
-
import { ICtxMenuRenderer } from './renderer/ctxmenu/base';
|
|
10
|
-
|
|
11
|
-
export type TupleMenuNodeResult = [MenuNode[], MenuNode[]];
|
|
12
|
-
|
|
13
|
-
export interface IMenuNodeOptions {
|
|
14
|
-
/**
|
|
15
|
-
* 固定参数可从这里传入
|
|
16
|
-
*/
|
|
17
|
-
args?: any[];
|
|
18
|
-
contextDom?: HTMLElement;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type IMenuSeparator = 'navigation' | 'inline';
|
|
22
|
-
|
|
23
|
-
export interface IMenuConfig extends IMenuNodeOptions {
|
|
24
|
-
separator?: IMenuSeparator;
|
|
25
|
-
withAlt?: boolean; // 尚未支持
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@Injectable()
|
|
29
|
-
export class MenuItemNode extends MenuNode {
|
|
30
|
-
readonly item: Command;
|
|
31
|
-
private _options: IMenuNodeOptions;
|
|
32
|
-
|
|
33
|
-
@Autowired(CommandService)
|
|
34
|
-
protected readonly commandService: CommandService;
|
|
35
|
-
|
|
36
|
-
@Autowired(KeybindingRegistry)
|
|
37
|
-
protected readonly keybindings: KeybindingRegistry;
|
|
38
|
-
|
|
39
|
-
@Autowired(CommandRegistry)
|
|
40
|
-
protected readonly commandRegistry: CommandRegistry;
|
|
41
|
-
|
|
42
|
-
constructor(
|
|
43
|
-
@Optional() item: Command,
|
|
44
|
-
@Optional() icon: string | undefined,
|
|
45
|
-
@Optional() options: IMenuNodeOptions = {},
|
|
46
|
-
@Optional() disabled: boolean,
|
|
47
|
-
@Optional() checked: boolean,
|
|
48
|
-
@Optional() type?: IMenuActionDisplayType,
|
|
49
|
-
@Optional() nativeRole?: string,
|
|
50
|
-
@Optional() extraDesc?: string,
|
|
51
|
-
@Optional() private extraTailArgs?: any[],
|
|
52
|
-
@Optional() private argsTransformer?: (...args: any[]) => any[],
|
|
53
|
-
) {
|
|
54
|
-
super({
|
|
55
|
-
id: item.id,
|
|
56
|
-
icon,
|
|
57
|
-
label: item.label!,
|
|
58
|
-
type,
|
|
59
|
-
checked,
|
|
60
|
-
disabled,
|
|
61
|
-
nativeRole,
|
|
62
|
-
extraDesc,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
this.className = undefined;
|
|
66
|
-
|
|
67
|
-
const shortcutDesc = this.getShortcut(item.id);
|
|
68
|
-
|
|
69
|
-
this.keybinding = (shortcutDesc && shortcutDesc.keybinding) || '';
|
|
70
|
-
this.rawKeybinding = (shortcutDesc && shortcutDesc.rawKeybinding) || '';
|
|
71
|
-
this.isKeyCombination = !!(shortcutDesc && shortcutDesc.isKeyCombination);
|
|
72
|
-
this._options = options;
|
|
73
|
-
|
|
74
|
-
this.item = item;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
getExecuteArgs(args: any[] = []): any[] {
|
|
78
|
-
let runArgs = [...(this._options.args || []), ...(args || []), ...(this.extraTailArgs || [])];
|
|
79
|
-
// args 为 createMenu 时提供,同一个 menu 所有的都是同一 args
|
|
80
|
-
// argsTransformer 每个 action 不同,所以先合并 args,然后再经过 transformer
|
|
81
|
-
if (this.argsTransformer) {
|
|
82
|
-
runArgs = this.argsTransformer(...runArgs);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return runArgs;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
execute(args: any[] = []): Promise<any> {
|
|
89
|
-
return this.commandService.executeCommand(this.item.id, ...this.getExecuteArgs(args));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
private getShortcut(commandId: string) {
|
|
93
|
-
if (commandId) {
|
|
94
|
-
const keybindings = this.keybindings.getKeybindingsForCommand(commandId);
|
|
95
|
-
if (keybindings.length > 0) {
|
|
96
|
-
// 取 priority 最高的 keybinding 作展示
|
|
97
|
-
const highPriorityKeybinding = keybindings.reduce((a, b) => ((a.priority || 0) > (b.priority || 0) ? a : b));
|
|
98
|
-
|
|
99
|
-
const isKeyCombination =
|
|
100
|
-
Array.isArray(highPriorityKeybinding.resolved) && highPriorityKeybinding.resolved.length > 1;
|
|
101
|
-
let keybinding = this.keybindings.acceleratorFor(highPriorityKeybinding, isMacintosh ? '' : '+').join(' ');
|
|
102
|
-
if (isKeyCombination) {
|
|
103
|
-
keybinding = `[${keybinding}]`;
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
keybinding,
|
|
107
|
-
rawKeybinding: highPriorityKeybinding.keybinding,
|
|
108
|
-
isKeyCombination,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
@Injectable({ multiple: true })
|
|
117
|
-
export class SubmenuItemNode extends MenuNode {
|
|
118
|
-
static readonly ID = 'menu.item.node.submenu';
|
|
119
|
-
|
|
120
|
-
@Autowired(ICtxMenuRenderer)
|
|
121
|
-
protected readonly ctxMenuRenderer: ICtxMenuRenderer;
|
|
122
|
-
|
|
123
|
-
readonly item: ISubmenuItem;
|
|
124
|
-
readonly submenuId: string;
|
|
125
|
-
readonly icon: string;
|
|
126
|
-
|
|
127
|
-
constructor(@Optional() item: ISubmenuItem) {
|
|
128
|
-
super({
|
|
129
|
-
id: SubmenuItemNode.ID,
|
|
130
|
-
label: item.label!,
|
|
131
|
-
type: item.type,
|
|
132
|
-
});
|
|
133
|
-
this.submenuId = item.submenu;
|
|
134
|
-
this.icon = item.iconClass!;
|
|
135
|
-
this.item = item;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// 支持 submenu 点击展开
|
|
139
|
-
execute(args: any[]): void {
|
|
140
|
-
const [anchor, ...restArgs] = args;
|
|
141
|
-
if (!anchor) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
this.ctxMenuRenderer.show({
|
|
146
|
-
anchor,
|
|
147
|
-
menuNodes: this.children || this.submenuId,
|
|
148
|
-
args: restArgs,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
@Injectable({ multiple: true })
|
|
154
|
-
export class ComponentMenuItemNode extends MenuNode {
|
|
155
|
-
static readonly ID = 'menu.item.node.component';
|
|
156
|
-
static nodeIndex = -1;
|
|
157
|
-
|
|
158
|
-
readonly item: IComponentMenuItem;
|
|
159
|
-
private _options: IMenuNodeOptions;
|
|
160
|
-
readonly component: React.ComponentType<IComponentMenuItemProps>;
|
|
161
|
-
readonly nodeId: string;
|
|
162
|
-
|
|
163
|
-
constructor(
|
|
164
|
-
@Optional() item: IComponentMenuItem,
|
|
165
|
-
@Optional() options: IMenuNodeOptions = {},
|
|
166
|
-
@Optional() private extraTailArgs?: any[],
|
|
167
|
-
@Optional() private argsTransformer?: (...args: any[]) => any[],
|
|
168
|
-
) {
|
|
169
|
-
super({
|
|
170
|
-
id: ComponentMenuItemNode.ID,
|
|
171
|
-
label: '',
|
|
172
|
-
});
|
|
173
|
-
ComponentMenuItemNode.nodeIndex++;
|
|
174
|
-
this.nodeId = String(ComponentMenuItemNode.nodeIndex);
|
|
175
|
-
this.item = item;
|
|
176
|
-
this.component = item.component;
|
|
177
|
-
this._options = options;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
getExecuteArgs(args: any[] = []): any[] {
|
|
181
|
-
let runArgs = [...(this._options.args || []), ...(args || []), ...(this.extraTailArgs || [])];
|
|
182
|
-
// args 为 createMenu 时提供,同一个 menu 所有的都是同一 args
|
|
183
|
-
// argsTransformer 每个 action 不同,所以先合并 args,然后再经过 transformer
|
|
184
|
-
if (this.argsTransformer) {
|
|
185
|
-
runArgs = this.argsTransformer(...runArgs);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return runArgs;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// 分隔符
|
|
193
|
-
export class SeparatorMenuItemNode extends MenuNode {
|
|
194
|
-
static readonly ID = 'menu.item.node.separator';
|
|
195
|
-
|
|
196
|
-
constructor(id?: string, label?: string) {
|
|
197
|
-
super({
|
|
198
|
-
id: id || SeparatorMenuItemNode.ID,
|
|
199
|
-
label: label || 'separator',
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export interface IMenu extends IDisposable {
|
|
205
|
-
/**
|
|
206
|
-
* menu-id
|
|
207
|
-
*/
|
|
208
|
-
menuId: string | MenuId;
|
|
209
|
-
readonly onDidChange: Event<IMenu | undefined>;
|
|
210
|
-
getMenuNodes(
|
|
211
|
-
options?: IMenuNodeOptions,
|
|
212
|
-
): Array<[string, Array<MenuItemNode | SubmenuItemNode | ComponentMenuItemNode>]>;
|
|
213
|
-
onDispose: Event<void>;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export function isIMenu(menus: IMenu | IContextMenu): menus is IMenu {
|
|
217
|
-
return 'getMenuNodes' in menus && typeof menus.getMenuNodes === 'function';
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export interface IContextMenu extends IDisposable {
|
|
221
|
-
/**
|
|
222
|
-
* menu-id
|
|
223
|
-
*/
|
|
224
|
-
menuId: string | MenuId;
|
|
225
|
-
/**
|
|
226
|
-
* menu 重新生成后事件,监听即可拿到最新的 menu
|
|
227
|
-
*/
|
|
228
|
-
readonly onDidChange: Event<string>;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* 获得已分好组并合并的 MenuNodes 列表
|
|
232
|
-
*/
|
|
233
|
-
getMergedMenuNodes(): MenuNode[];
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* 获得已分好组的 MenuNodes 列表
|
|
237
|
-
*/
|
|
238
|
-
getGroupedMenuNodes(): TupleMenuNodeResult;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export abstract class AbstractMenuService {
|
|
242
|
-
public abstract createMenu(id: MenuId | string, contextKeyService?: IContextKeyService): IMenu;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
export interface CreateMenuPayload {
|
|
246
|
-
id: MenuId | string;
|
|
247
|
-
config?: IMenuConfig;
|
|
248
|
-
contextKeyService?: IContextKeyService;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
export abstract class AbstractContextMenuService {
|
|
252
|
-
public abstract createMenu(payload: CreateMenuPayload): IContextMenu;
|
|
253
|
-
}
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { Injectable, Autowired } from '@opensumi/di';
|
|
2
|
-
import { IDisposable, Disposable, Event, Emitter } from '@opensumi/ide-core-common';
|
|
3
|
-
|
|
4
|
-
import { IMenubarItem, IMenuRegistry, MenuNode } from './base';
|
|
5
|
-
import { generateMergedCtxMenu } from './menu-util';
|
|
6
|
-
import { AbstractMenuService, IMenu, SubmenuItemNode } from './menu.interface';
|
|
7
|
-
|
|
8
|
-
export abstract class AbstractMenubarService extends Disposable {
|
|
9
|
-
readonly onDidMenubarChange: Event<void>;
|
|
10
|
-
abstract getMenubarItems(): IMenubarItem[];
|
|
11
|
-
abstract getMenubarItem(menuId: string): IMenubarItem | undefined;
|
|
12
|
-
|
|
13
|
-
readonly onDidMenuChange: Event<string>;
|
|
14
|
-
abstract getMenuNodes(menuId: string): MenuNode[];
|
|
15
|
-
abstract rebuildMenuNodes(menuId: string): void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Injectable()
|
|
19
|
-
export class MenubarServiceImpl extends Disposable implements AbstractMenubarService {
|
|
20
|
-
@Autowired(AbstractMenuService)
|
|
21
|
-
private readonly menuService: AbstractMenuService;
|
|
22
|
-
|
|
23
|
-
@Autowired(IMenuRegistry)
|
|
24
|
-
private readonly menuRegistry: IMenuRegistry;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Menubar 本身发生变化时的事件
|
|
28
|
-
* undefined 表示整个都需要刷新
|
|
29
|
-
* 带了 menuId 只需要刷新单个 MenuBarItem
|
|
30
|
-
*/
|
|
31
|
-
private readonly _onDidMenuBarChange = new Emitter<void>();
|
|
32
|
-
public get onDidMenubarChange(): Event<void> {
|
|
33
|
-
return this._onDidMenuBarChange.event;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
private readonly _onDidMenuChange = new Emitter<string>();
|
|
37
|
-
public get onDidMenuChange(): Event<string> {
|
|
38
|
-
return this._onDidMenuChange.event;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private readonly _onMenuChange = new Emitter<string>();
|
|
42
|
-
// internal 的 MenuChange 监听器,监听 menu/submenu 的变化
|
|
43
|
-
private get onMenuChange(): Event<string | undefined> {
|
|
44
|
-
return this._onMenuChange.event;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private _menubarIds: Set<string> = new Set();
|
|
48
|
-
private _menus: Map<string, IMenu> = new Map();
|
|
49
|
-
|
|
50
|
-
private _menubarItems: IMenubarItem[] = [];
|
|
51
|
-
private _menuItems: Map<string, MenuNode[]> = new Map();
|
|
52
|
-
|
|
53
|
-
private _menusListener: Map<string, IDisposable> = new Map();
|
|
54
|
-
|
|
55
|
-
constructor() {
|
|
56
|
-
super();
|
|
57
|
-
this._build();
|
|
58
|
-
|
|
59
|
-
// 监听 menubar 刷新事件
|
|
60
|
-
this.addDispose(Event.debounce(this.menuRegistry.onDidChangeMenubar, () => {}, 50)(this._build, this));
|
|
61
|
-
|
|
62
|
-
// 监听内部的 onMenuChange 刷新单个 menubarItem 下的所有节点
|
|
63
|
-
this.addDispose(
|
|
64
|
-
Event.debounce(this.onMenuChange, (l, menuId: string) => menuId, 50)(this._rebuildSingleRootMenus, this),
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
this.addDispose(this._onDidMenuBarChange);
|
|
68
|
-
this.addDispose(this._onDidMenuChange);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// 构建完整的 menubarIds/_menubarItems/_menubarMenus
|
|
72
|
-
private _build() {
|
|
73
|
-
// reset
|
|
74
|
-
this._menubarItems = [];
|
|
75
|
-
this._menubarIds = new Set();
|
|
76
|
-
this._menuItems.clear();
|
|
77
|
-
|
|
78
|
-
let menubarItems = this.menuRegistry.getMenubarItems();
|
|
79
|
-
menubarItems = menubarItems.sort(menubarItemsSorter);
|
|
80
|
-
|
|
81
|
-
menubarItems.forEach((menubarItem) => {
|
|
82
|
-
const menubarId = menubarItem.id;
|
|
83
|
-
this._menubarItems.push(menubarItem);
|
|
84
|
-
// keep menuId for event listener
|
|
85
|
-
this._menubarIds.add(menubarId);
|
|
86
|
-
// build mens for Menubar
|
|
87
|
-
this._buildMenus(menubarId);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
this._onDidMenuBarChange.fire();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// 根据事件监听结果更新单个 root menuId 下的 menus
|
|
94
|
-
private _rebuildSingleRootMenus(menuId: string) {
|
|
95
|
-
this._buildMenus(menuId);
|
|
96
|
-
this._onDidMenuChange.fire(menuId);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* 构建产生每个 menubar item 下方点击展开的 menus
|
|
101
|
-
* 包括递归产生多层级结构
|
|
102
|
-
* @param menubarId [string]
|
|
103
|
-
*/
|
|
104
|
-
private _buildMenus(menubarId: string) {
|
|
105
|
-
const menus = this.menuService.createMenu(menubarId);
|
|
106
|
-
|
|
107
|
-
// clean up for IMenu
|
|
108
|
-
const oldMenus = this._menus.get(menubarId);
|
|
109
|
-
if (oldMenus) {
|
|
110
|
-
oldMenus.dispose();
|
|
111
|
-
this._menus.delete(menubarId);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// clean up for menu.onDidChange
|
|
115
|
-
const oldMenusListener = this._menusListener.get(menubarId);
|
|
116
|
-
if (oldMenusListener) {
|
|
117
|
-
oldMenusListener.dispose();
|
|
118
|
-
this._menusListener.delete(menubarId);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
this._menus.set(menubarId, menus);
|
|
122
|
-
this._menusListener.set(
|
|
123
|
-
menubarId,
|
|
124
|
-
menus.onDidChange(() => this._onMenuChange.fire(menubarId), this, this.disposables),
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const menubarMenu = [] as MenuNode[];
|
|
128
|
-
this._traverseMenuItems(menus, menubarMenu, menubarId);
|
|
129
|
-
this._menuItems.set(menubarId, menubarMenu);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* 递归构建生成单个 Menubar 下所有层级菜单的数据结构的函数
|
|
134
|
-
* @param menus IMenu 实例, menuService.createMenu 返回值
|
|
135
|
-
* @param menuToPopulate 递归中用来收集数结果
|
|
136
|
-
* @param rootMenuId 顶级的 menuId, 下方所有 submenuId 的 onDidChange 都触发顶层 menuId 事件以刷新该 menuId 下所有的数据
|
|
137
|
-
*/
|
|
138
|
-
private _traverseMenuItems(menus: IMenu, menuToPopulate: MenuNode[], rootMenuId: string) {
|
|
139
|
-
const menuItems = generateMergedCtxMenu({ menus });
|
|
140
|
-
menuItems.forEach((menuItem) => {
|
|
141
|
-
if (menuItem instanceof SubmenuItemNode) {
|
|
142
|
-
const submenuItems = [] as MenuNode[];
|
|
143
|
-
|
|
144
|
-
const submenuId = menuItem.item.submenu;
|
|
145
|
-
if (!this._menus.has(submenuId)) {
|
|
146
|
-
const menus = this.registerDispose(this.menuService.createMenu(submenuId));
|
|
147
|
-
this._menus.set(submenuId, menus);
|
|
148
|
-
this.registerDispose(
|
|
149
|
-
menus.onDidChange(() => {
|
|
150
|
-
// 通知外部 顶层 menuId 下所有结构变了, 需要重新生成数据结构
|
|
151
|
-
this._onMenuChange.fire(rootMenuId);
|
|
152
|
-
}),
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const menuToDispose = this.menuService.createMenu(submenuId);
|
|
157
|
-
this._traverseMenuItems(menuToDispose, submenuItems, rootMenuId);
|
|
158
|
-
|
|
159
|
-
// 挂载 submenu 下的子级 menuItems
|
|
160
|
-
menuItem.children = submenuItems;
|
|
161
|
-
|
|
162
|
-
menuToPopulate.push(menuItem);
|
|
163
|
-
menuToDispose.dispose();
|
|
164
|
-
} else {
|
|
165
|
-
menuToPopulate.push(menuItem);
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
public dispose() {
|
|
171
|
-
this._menusListener.forEach((disposable) => disposable.dispose());
|
|
172
|
-
this._menusListener.clear();
|
|
173
|
-
this._menus.forEach((menu) => menu.dispose());
|
|
174
|
-
this._menus.clear();
|
|
175
|
-
super.dispose();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
public getMenubarItems() {
|
|
179
|
-
return this._menubarItems;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
public getMenubarItem(menuId: string) {
|
|
183
|
-
if (!this._menubarIds.has(menuId)) {
|
|
184
|
-
return undefined;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return this.menuRegistry.getMenubarItem(menuId);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
public getMenuNodes(menuId: string) {
|
|
191
|
-
return this._menuItems.get(menuId) || [];
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// 由于现在的 command 无法通知 isEnable/isVisible/isToggle
|
|
195
|
-
// 所以 web 版本 menubar 每次需要强制重新计算
|
|
196
|
-
public rebuildMenuNodes(menuId: string) {
|
|
197
|
-
this._buildMenus(menuId);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function menubarItemsSorter(a: IMenubarItem, b: IMenubarItem): number {
|
|
202
|
-
// sort on priority - default is 0
|
|
203
|
-
const aPrio = a.order || 0;
|
|
204
|
-
const bPrio = b.order || 0;
|
|
205
|
-
if (aPrio < bPrio) {
|
|
206
|
-
return -1;
|
|
207
|
-
} else if (aPrio > bPrio) {
|
|
208
|
-
return 1;
|
|
209
|
-
}
|
|
210
|
-
return 0;
|
|
211
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { IContextKeyService } from '../../../../context-key';
|
|
2
|
-
import { MenuNode } from '../../base';
|
|
3
|
-
import { MenuId } from '../../menu-id';
|
|
4
|
-
import { IMenuNodeOptions } from '../../menu.interface';
|
|
5
|
-
|
|
6
|
-
export interface CtxMenuParams extends IMenuNodeOptions {
|
|
7
|
-
menuNodes: MenuNode[] | MenuId | string;
|
|
8
|
-
contextKeyService?: IContextKeyService; // 直接传递 MenuId 时可传递 scopedContextKeyService
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface CtxMenuRenderParams extends CtxMenuParams {
|
|
12
|
-
anchor: MouseEvent | { x: number; y: number };
|
|
13
|
-
onHide?: (canceled: boolean) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export abstract class ICtxMenuRenderer {
|
|
17
|
-
abstract show(payload: CtxMenuRenderParams): void;
|
|
18
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import omit from 'lodash/omit';
|
|
2
|
-
|
|
3
|
-
import { Injectable, Autowired } from '@opensumi/di';
|
|
4
|
-
|
|
5
|
-
import { MenuNode } from '../../base';
|
|
6
|
-
import { AbstractContextMenuService } from '../../menu.interface';
|
|
7
|
-
|
|
8
|
-
import { ICtxMenuRenderer, CtxMenuRenderParams } from './base';
|
|
9
|
-
|
|
10
|
-
export abstract class IBrowserCtxMenu extends ICtxMenuRenderer {
|
|
11
|
-
visible: boolean;
|
|
12
|
-
onHide: ((canceled: boolean) => void) | undefined;
|
|
13
|
-
point?: {
|
|
14
|
-
pageX: number;
|
|
15
|
-
pageY: number;
|
|
16
|
-
};
|
|
17
|
-
context: any;
|
|
18
|
-
menuNodes: MenuNode[];
|
|
19
|
-
abstract hide(canceled: boolean): void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@Injectable()
|
|
23
|
-
export class BrowserCtxMenuRenderer implements ICtxMenuRenderer {
|
|
24
|
-
@Autowired(IBrowserCtxMenu)
|
|
25
|
-
protected readonly browserCtxMenu: IBrowserCtxMenu;
|
|
26
|
-
|
|
27
|
-
@Autowired(AbstractContextMenuService)
|
|
28
|
-
private readonly menuService: AbstractContextMenuService;
|
|
29
|
-
|
|
30
|
-
public show(payload: CtxMenuRenderParams): void {
|
|
31
|
-
if (typeof payload.menuNodes === 'string') {
|
|
32
|
-
const menus = this.menuService.createMenu({
|
|
33
|
-
id: payload.menuNodes,
|
|
34
|
-
config: {
|
|
35
|
-
args: payload.args,
|
|
36
|
-
},
|
|
37
|
-
contextKeyService: payload.contextKeyService,
|
|
38
|
-
});
|
|
39
|
-
payload.menuNodes = menus.getMergedMenuNodes();
|
|
40
|
-
menus.dispose();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
this.browserCtxMenu.show(omit(payload, ['contextKeyService']));
|
|
44
|
-
}
|
|
45
|
-
}
|