Skip to content

Instantly share code, notes, and snippets.

@afshin
Last active January 26, 2016 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afshin/59b2a7d24206f54edb03 to your computer and use it in GitHub Desktop.
Save afshin/59b2a7d24206f54edb03 to your computer and use it in GitHub Desktop.
menus
/**
* Defines a section within a menu
*/
interface IMenuSection {
id: string;
items: IMenuItem[];
}
/**
* Base for menu items, not to be used by itself.
*/
interface IMenuItem {
id: string;
}
/**
* Defines a location within a menu section where new items may be added.
*/
interface IMenuExtensionPoint extends IMenuItem {}
/**
* Defines a location within a menu section where a submenu may be added.
*/
interface ISubMenuExtensionPoint extends IMenuItem {
title: string;
}
/**
* Defines a command item in a menu section.
*/
interface IMenuCommand extends IMenuItem {
command: string;
args: any;
}
const fileMenu: IMenuSection[] = [
{
id: 'file:new',
items: [
{
id: 'file:new:editor',
command: 'editor:create-tab',
args: ''
} as IMenuCommand,
{
id: 'file:new:notebook',
command: 'notebook:create-tab',
args: ''
} as IMenuCommand,
{
id: 'file:new:extension'
} as IMenuExtensionPoint
]
},
{
id: 'file:print',
items: [
{
id: 'file:print:no-prompt',
command: 'printer:default',
args: ''
} as IMenuCommand,
{
id: 'file:print:with-options',
command: 'printer:advanced',
args: ''
} as IMenuCommand,
{
id: 'file:new:extend'
} as IMenuExtensionPoint
]
}
];
const editMenu: IMenuSection[] = [
{
id: 'edit:undo',
items: [
{
id: 'edit:undo:undo',
command: 'application:undo',
args: ''
} as IMenuCommand,
{
id: 'edit:undo:redo',
command: 'application:redo',
args: ''
} as IMenuCommand
]
},
{
id: 'edit:clipboard',
items: [
{
id: 'edit:clipboard:cut',
command: 'application:cut',
args: ''
} as IMenuCommand,
{
id: 'edit:clipboard:copy',
command: 'application:copy',
args: ''
} as IMenuCommand,
{
id: 'edit:clipboard:paste',
command: 'application:paste',
args: ''
} as IMenuCommand,
{
id: 'edit:clipboard:extension'
} as IMenuExtensionPoint
]
},
{
id: 'edit:clipboard-submenu',
items: [
{
id: 'edit:clipboard-submenu:extension'
} as ISubMenuExtensionPoint
]
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment