diff --git a/examples/src/electron/index.html b/examples/src/electron/index.html index 83bb5a4bf394f..2ab4e49f40be0 100644 --- a/examples/src/electron/index.html +++ b/examples/src/electron/index.html @@ -43,7 +43,7 @@ 'vs/platform/commands/common/commands' ], (basic, css, ts, html, json, commands) => { const global = self; - global.monaco.editor.CommandsRegistry = commands.CommandsRegistry; + global.monaco.commands.CommandsRegistry = commands.CommandsRegistry; require("./bundle.js"); }); }); diff --git a/examples/src/web/index.ts b/examples/src/web/index.ts index de8861552b0b0..7dc22300cf2b3 100644 --- a/examples/src/web/index.ts +++ b/examples/src/web/index.ts @@ -10,7 +10,7 @@ window.onload = () => { 'vs/platform/commands/common/commands' ], (basic: any, css: any, ts: any, html: any, json: any, commands: any) => { const global: any = self; - global.monaco.editor.CommandsRegistry = commands.CommandsRegistry; + global.monaco.commands.CommandsRegistry = commands.CommandsRegistry; require('./main'); }); }); diff --git a/src/editor/browser/editor-contextmenu.ts b/src/editor/browser/editor-contextmenu.ts index 2451cdc1ccbb7..7a6cea7b4a841 100644 --- a/src/editor/browser/editor-contextmenu.ts +++ b/src/editor/browser/editor-contextmenu.ts @@ -1,6 +1,6 @@ import { injectable } from "inversify"; import IContextMenuService = monaco.editor.IContextMenuService; -import CommandsRegistry = monaco.editor.CommandsRegistry; +import CommandsRegistry = monaco.commands.CommandsRegistry; export const EditorContextMenuService = Symbol("EditorContextMenuService"); @@ -12,8 +12,14 @@ export interface EditorContextMenuService extends IContextMenuService { export class BrowserContextMenuService implements EditorContextMenuService { showContextMenu(delegate: any): void { - console.log(JSON.stringify(CommandsRegistry.getCommands())); - console.log(JSON.stringify(monaco.editor.CommandsRegistry.getCommands())); + const ids = Object.keys(CommandsRegistry.getCommands()); + console.log(ids.length); + // for (let id of ids) { + // const command = CommandsRegistry.getCommand(id); + // console.log(); + // console.log(id); + // console.log(command); + // } } } \ No newline at end of file diff --git a/typings/monaco/index.d.ts b/typings/monaco/index.d.ts index bf1ee78efc828..cff15f2c04305 100644 --- a/typings/monaco/index.d.ts +++ b/typings/monaco/index.d.ts @@ -98,6 +98,37 @@ declare module monaco.editor { showContextMenu(delegate: any): void; } +} + +declare module monaco.commands { + + /** + * Identifies a service of type T + */ + export interface ServiceIdentifier { + (...args: any[]): void; + type: T; + } + + export interface ServicesAccessor { + get(id: ServiceIdentifier, isOptional?: any): T; + } + + export interface ICommandHandler { + (accessor: ServicesAccessor, ...args: any[]): void; + } + + export interface ICommand { + handler: ICommandHandler; + description?: ICommandHandlerDescription; + } + + export interface ICommandHandlerDescription { + description: string; + args: { name: string; description?: string; constraint?: string | Function; }[]; + returns?: string; + } + export interface ICommandsMap { /** * A read only mapping from command IDs to the commands.