本文整理匯總了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;
}