本文整理汇总了TypeScript中@jupyterlab/codemirror.Mode.getModeInfo方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Mode.getModeInfo方法的具体用法?TypeScript Mode.getModeInfo怎么用?TypeScript Mode.getModeInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@jupyterlab/codemirror.Mode
的用法示例。
在下文中一共展示了Mode.getModeInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: activateEditorCommands
//.........这里部分代码省略.........
return;
}
let editor = widget.content.editor as CodeMirrorEditor;
editor.execCommand('jumpToLine');
},
isEnabled
});
commands.addCommand(CommandIDs.changeMode, {
label: args => args['name'] as string,
execute: args => {
let name = args['name'] as string;
let widget = tracker.currentWidget;
if (name && widget) {
let spec = Mode.findByName(name);
if (spec) {
widget.content.model.mimeType = spec.mime;
}
}
},
isEnabled,
isToggled: args => {
let widget = tracker.currentWidget;
if (!widget) {
return false;
}
let mime = widget.content.model.mimeType;
let spec = Mode.findByMIME(mime);
let name = spec && spec.name;
return args['name'] === name;
}
});
Mode.getModeInfo()
.sort((a, b) => {
let aName = a.name || '';
let bName = b.name || '';
return aName.localeCompare(bName);
})
.forEach(spec => {
// Avoid mode name with a curse word.
if (spec.mode.indexOf('brainf') === 0) {
return;
}
modeMenu.addItem({
command: CommandIDs.changeMode,
args: { ...spec }
});
});
[
'jupyter',
'default',
'abcdef',
'base16-dark',
'base16-light',
'hopscotch',
'material',
'mbo',
'mdn-like',
'seti',
'solarized dark',
'solarized light',
'the-matrix',
'xq-light',
'zenburn'
示例2: createMenu
//.........这里部分代码省略.........
});
commands.addCommand(CommandIDs.findAndReplace, {
label: 'Find & Replace',
execute: () => {
let widget = tracker.currentWidget;
if (!widget) {
return;
}
let editor = widget.editor as CodeMirrorEditor;
editor.execCommand('replace');
},
isEnabled: hasWidget
});
commands.addCommand(CommandIDs.changeMode, {
label: args => args['name'] as string,
execute: args => {
let name = args['name'] as string;
let widget = tracker.currentWidget;
if (name && widget) {
let spec = Mode.findByName(name);
if (spec) {
widget.model.mimeType = spec.mime;
}
}
},
isEnabled: hasWidget,
isToggled: args => {
let widget = tracker.currentWidget;
if (!widget) {
return false;
}
let mime = widget.model.mimeType;
let spec = Mode.findByMIME(mime);
let name = spec && spec.name;
return args['name'] === name;
}
});
Mode.getModeInfo().sort((a, b) => {
let aName = a.name || '';
let bName = b.name || '';
return aName.localeCompare(bName);
}).forEach(spec => {
// Avoid mode name with a curse word.
if (spec.mode.indexOf('brainf') === 0) {
return;
}
modeMenu.addItem({
command: CommandIDs.changeMode,
args: {...spec}
});
});
[
'jupyter', 'default', 'abcdef', 'base16-dark', 'base16-light',
'hopscotch', 'material', 'mbo', 'mdn-like', 'seti', 'the-matrix',
'xq-light', 'zenburn'
].forEach(name => themeMenu.addItem({
command: CommandIDs.changeTheme,
args: { theme: name }
}));
['default', 'sublime', 'vim', 'emacs'].forEach(name => {
keyMapMenu.addItem({
command: CommandIDs.changeKeyMap,
args: { keyMap: name }
});
});
let args: JSONObject = {
insertSpaces: false, size: 4, name: 'Indent with Tab'
};
let command = 'fileeditor:change-tabs';
tabMenu.addItem({ command, args });
palette.addItem({ command, args, category: 'Editor' });
for (let size of [1, 2, 4, 8]) {
let args: JSONObject = {
insertSpaces: true, size, name: `Spaces: ${size} `
};
tabMenu.addItem({ command, args });
palette.addItem({ command, args, category: 'Editor' });
}
menu.addItem({ type: 'submenu', submenu: modeMenu });
menu.addItem({ type: 'submenu', submenu: tabMenu });
menu.addItem({ command: CommandIDs.find });
menu.addItem({ command: CommandIDs.findAndReplace });
menu.addItem({ type: 'separator' });
menu.addItem({ command: 'fileeditor:toggle-line-numbers' });
menu.addItem({ command: 'fileeditor:toggle-line-wrap' });
menu.addItem({ command: 'fileeditor:toggle-match-brackets' });
menu.addItem({ command: 'fileeditor:toggle-autoclosing-brackets' });
menu.addItem({ type: 'submenu', submenu: keyMapMenu });
menu.addItem({ type: 'submenu', submenu: themeMenu });
return menu;
}