@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
103 lines • 5.86 kB
TypeScript
import { MenuBar, Menu as MenuWidget, Widget } from '@phosphor/widgets';
import { CommandRegistry as PhosphorCommandRegistry } from '@phosphor/commands';
import { CommandRegistry, DisposableCollection, Disposable, MenuModelRegistry, MenuPath, MenuNode, MenuCommandExecutor, CompoundMenuNode, CommandMenuNode } from '../../common';
import { KeybindingRegistry } from '../keybinding';
import { FrontendApplicationContribution, FrontendApplication } from '../frontend-application';
import { ContextKeyService, ContextMatcher } from '../context-key-service';
import { ContextMenuContext } from './context-menu-context';
import { ApplicationShell } from '../shell';
import { CorePreferences } from '../core-preferences';
import { PreferenceService } from '../preferences/preference-service';
export declare abstract class MenuBarWidget extends MenuBar {
abstract activateMenu(label: string, ...labels: string[]): Promise<MenuWidget>;
abstract triggerMenuItem(label: string, ...labels: string[]): Promise<MenuWidget.IItem>;
}
export interface BrowserMenuOptions extends MenuWidget.IOptions {
commands: MenuCommandRegistry;
context?: HTMLElement;
contextKeyService?: ContextMatcher;
rootMenuPath: MenuPath;
}
export declare class BrowserMainMenuFactory implements MenuWidgetFactory {
protected readonly contextKeyService: ContextKeyService;
protected readonly context: ContextMenuContext;
protected readonly commandRegistry: CommandRegistry;
protected readonly menuCommandExecutor: MenuCommandExecutor;
protected readonly corePreferences: CorePreferences;
protected readonly keybindingRegistry: KeybindingRegistry;
protected readonly menuProvider: MenuModelRegistry;
createMenuBar(): MenuBarWidget;
protected showMenuBar(menuBar: DynamicMenuBarWidget, preference: string | undefined): void;
protected fillMenuBar(menuBar: MenuBarWidget): void;
createContextMenu(path: MenuPath, args?: unknown[], context?: HTMLElement, contextKeyService?: ContextMatcher): MenuWidget;
createMenuWidget(menu: CompoundMenuNode, options: BrowserMenuOptions): DynamicMenuWidget;
protected createMenuCommandRegistry(menu: CompoundMenuNode, args?: unknown[]): MenuCommandRegistry;
protected registerMenu(menuCommandRegistry: MenuCommandRegistry, menu: MenuNode, args: unknown[]): void;
protected get services(): MenuServices;
}
export declare class DynamicMenuBarWidget extends MenuBarWidget {
/**
* We want to restore the focus after the menu closes.
*/
protected previousFocusedElement: HTMLElement | undefined;
constructor();
activateMenu(label: string, ...labels: string[]): Promise<MenuWidget>;
triggerMenuItem(label: string, ...labels: string[]): Promise<MenuWidget.IItem>;
}
export declare class MenuServices {
readonly commandRegistry: CommandRegistry;
readonly keybindingRegistry: KeybindingRegistry;
readonly contextKeyService: ContextKeyService;
readonly context: ContextMenuContext;
readonly menuWidgetFactory: MenuWidgetFactory;
readonly commandExecutor: MenuCommandExecutor;
}
export interface MenuWidgetFactory {
createMenuWidget(menu: MenuNode & Required<Pick<MenuNode, 'children'>>, options: BrowserMenuOptions): MenuWidget;
}
/**
* A menu widget that would recompute its items on update.
*/
export declare class DynamicMenuWidget extends MenuWidget {
protected menu: CompoundMenuNode;
protected options: BrowserMenuOptions;
protected services: MenuServices;
/**
* We want to restore the focus after the menu closes.
*/
protected previousFocusedElement: HTMLElement | undefined;
constructor(menu: CompoundMenuNode, options: BrowserMenuOptions, services: MenuServices);
aboutToShow({ previousFocusedElement }: {
previousFocusedElement: HTMLElement | undefined;
}): void;
open(x: number, y: number, options?: MenuWidget.IOpenOptions): void;
protected updateSubMenus(parent: MenuWidget, menu: CompoundMenuNode, commands: MenuCommandRegistry): void;
protected buildSubMenus(parentItems: MenuWidget.IItemOptions[], menu: MenuNode, commands: MenuCommandRegistry): MenuWidget.IItemOptions[];
protected undefinedOrMatch(contextKeyService: ContextMatcher, expression?: string, context?: HTMLElement): boolean;
protected preserveFocusedElement(previousFocusedElement?: Element | null): boolean;
protected restoreFocusedElement(): boolean;
protected runWithPreservedFocusContext(what: () => void): void;
}
export declare class BrowserMenuBarContribution implements FrontendApplicationContribution {
protected readonly factory: BrowserMainMenuFactory;
protected readonly shell: ApplicationShell;
protected readonly preferenceService: PreferenceService;
constructor(factory: BrowserMainMenuFactory);
onStart(app: FrontendApplication): void;
get menuBar(): MenuBarWidget | undefined;
protected appendMenu(shell: ApplicationShell): void;
protected createLogo(): Widget;
}
/**
* Stores Theia-specific action menu nodes instead of PhosphorJS commands with their handlers.
*/
export declare class MenuCommandRegistry extends PhosphorCommandRegistry {
protected services: MenuServices;
protected actions: Map<string, [import("../../common").MenuNodeMetadata & import("../../common").MenuNodeRenderingData & Partial<CompoundMenuNode> & Partial<CommandMenuNode> & Partial<import("../../common").AlternativeHandlerMenuNode> & CommandMenuNode, unknown[]]>;
protected toDispose: DisposableCollection;
constructor(services: MenuServices);
registerActionMenu(menu: MenuNode & CommandMenuNode, args: unknown[]): void;
snapshot(menuPath: MenuPath): this;
protected registerCommand(menu: MenuNode & CommandMenuNode, args: unknown[], menuPath: MenuPath): Disposable;
}
//# sourceMappingURL=browser-menu-plugin.d.ts.map