Skip to content

Commit

Permalink
GH-22: Moved commands from monaco.editor to monaco.commands module.
Browse files Browse the repository at this point in the history
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
  • Loading branch information
kittaakos committed Apr 5, 2017
1 parent 26d036c commit 6c8c767
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/src/electron/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
Expand Down
2 changes: 1 addition & 1 deletion examples/src/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Expand Down
12 changes: 9 additions & 3 deletions src/editor/browser/editor-contextmenu.ts
Original file line number Diff line number Diff line change
@@ -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");

Expand All @@ -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);
// }
}

}
31 changes: 31 additions & 0 deletions typings/monaco/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
(...args: any[]): void;
type: T;
}

export interface ServicesAccessor {
get<T>(id: ServiceIdentifier<T>, 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.
Expand Down

0 comments on commit 6c8c767

Please sign in to comment.