本文整理汇总了TypeScript中@jupyterlab/application.JupyterLabPlugin.addCommand方法的典型用法代码示例。如果您正苦于以下问题:TypeScript JupyterLabPlugin.addCommand方法的具体用法?TypeScript JupyterLabPlugin.addCommand怎么用?TypeScript JupyterLabPlugin.addCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@jupyterlab/application.JupyterLabPlugin
的用法示例。
在下文中一共展示了JupyterLabPlugin.addCommand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: activateEditorCommands
//.........这里部分代码省略.........
tracker.widgetAdded.connect((sender, widget) => {
if (widget.content.editor instanceof CodeMirrorEditor) {
let cm = widget.content.editor.editor;
cm.setOption('keyMap', keyMap);
cm.setOption('theme', theme);
cm.setOption('scrollPastEnd', scrollPastEnd);
cm.setOption('styleActiveLine', styleActiveLine);
cm.setOption('styleSelectedText', styleSelectedText);
cm.setOption('selectionPointer', selectionPointer);
}
});
/**
* A test for whether the tracker has an active widget.
*/
function isEnabled(): boolean {
return (
tracker.currentWidget !== null &&
tracker.currentWidget === app.shell.currentWidget
);
}
/**
* Create a menu for the editor.
*/
const themeMenu = new Menu({ commands });
const keyMapMenu = new Menu({ commands });
const modeMenu = new Menu({ commands });
themeMenu.title.label = 'Text Editor Theme';
keyMapMenu.title.label = 'Text Editor Key Map';
modeMenu.title.label = 'Text Editor Syntax Highlighting';
commands.addCommand(CommandIDs.changeTheme, {
label: args => {
if (args['theme'] === 'default') {
return 'codemirror';
} else {
return args['theme'] as string;
}
},
execute: args => {
const key = 'theme';
const value = (theme = (args['theme'] as string) || theme);
updateTracker();
return settingRegistry.set(id, key, value).catch((reason: Error) => {
console.error(`Failed to set ${id}:${key} - ${reason.message}`);
});
},
isToggled: args => args['theme'] === theme
});
commands.addCommand(CommandIDs.changeKeyMap, {
label: args => {
let title = args['keyMap'] as string;
return title === 'sublime' ? 'Sublime Text' : title;
},
execute: args => {
const key = 'keyMap';
const value = (keyMap = (args['keyMap'] as string) || keyMap);
updateTracker();
return settingRegistry.set(id, key, value).catch((reason: Error) => {
console.error(`Failed to set ${id}:${key} - ${reason.message}`);
});