本文整理匯總了TypeScript中phosphor-commandpalette.StandardPaletteModel.addItems方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript StandardPaletteModel.addItems方法的具體用法?TypeScript StandardPaletteModel.addItems怎麽用?TypeScript StandardPaletteModel.addItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phosphor-commandpalette.StandardPaletteModel
的用法示例。
在下文中一共展示了StandardPaletteModel.addItems方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: main
function main() {
let p1 = new CommandPalette();
let m1 = new StandardPaletteModel();
m1.addItems(EMPIRES.map(createOptions));
p1.model = m1;
let p2 = new CommandPalette();
let m2 = new StandardPaletteModel();
m2.addItems(LANGUAGES.map(createOptions));
p2.model = m2;
let output = new Widget();
output.id = 'output';
let palettes = new BoxPanel();
palettes.direction = BoxPanel.LeftToRight;
palettes.spacing = 4;
let outer = new BoxPanel();
outer.id = 'main';
outer.direction = BoxPanel.TopToBottom;
outer.spacing = 4;
BoxPanel.setStretch(p1, 1);
BoxPanel.setStretch(p2, 1);
BoxPanel.setSizeBasis(output, 60);
BoxPanel.setStretch(palettes, 1);
palettes.addChild(p1);
palettes.addChild(p2);
outer.addChild(palettes);
outer.addChild(output);
outer.attach(document.body);
window.onresize = () => { outer.update(); };
}
示例2: createApp
//.........這裏部分代碼省略.........
handler: markdownHandler
},
{
category: 'Notebook Cell',
text: 'To Raw Type',
shortcut: 'R',
handler: rawHandler
},
{
category: 'Notebook Cell',
text: 'Select Above',
shortcut: 'ArrowUp',
handler: selectAboveHandler
},
{
category: 'Notebook Cell',
text: 'Select Below',
shortcut: 'ArrowDown',
handler: selectBelowHandler
},
{
category: 'Notebook Cell',
text: 'Undo Cell Action',
shortcut: 'Z',
handler: undoHandler
},
{
category: 'Notebook Cell',
text: 'Redo Cell Action',
shortcut: 'Y',
handler: redoHandler
},
];
pModel.addItems(items);
let bindings = [
{
selector: '.jp-Notebook',
sequence: ['Shift Enter'],
handler: runAdvanceHandler
},
{
selector: '.jp-Notebook',
sequence: ['Accel S'],
handler: saveHandler
},
{
selector: '.jp-Notebook.jp-mod-commandMode',
sequence: ['I', 'I'],
handler: interruptHandler
},
{
selector: '.jp-Notebook.jp-mod-commandMode',
sequence: ['0', '0'],
handler: restartHandler
},
{
selector: '.jp-Notebook.jp-mod-commandMode',
sequence: ['Enter'],
handler: editHandler
},
{
selector: '.jp-Notebook.jp-mod-editMode',
sequence: ['Escape'],
handler: commandHandler
},
示例3: main
//.........這裏部分代碼省略.........
handler: () => { nbManager.merge() ; }
},
{
category: 'Notebook Cell',
text: 'To Code Type',
shortcut: 'Y',
handler: () => { nbManager.changeCellType('code') ; }
},
{
category: 'Notebook Cell',
text: 'To Markdown Type',
shortcut: 'M',
handler: () => { nbManager.changeCellType('markdown') ; }
},
{
category: 'Notebook Cell',
text: 'To Raw Type',
shortcut: 'R',
handler: () => { nbManager.changeCellType('raw') ; }
},
{
category: 'Notebook Cell',
text: 'Select Previous',
shortcut: 'ArrowUp',
handler: () => { nbModel.activeCellIndex -= 1; }
},
{
category: 'Notebook Cell',
text: 'Select Next',
shortcut: 'ArrowDown',
handler: () => { nbModel.activeCellIndex += 1; }
},
];
pModel.addItems(items);
let bindings = [
{
selector: '.jp-Notebook',
sequence: ['Shift Enter'],
handler: () => {
nbManager.runAndAdvance();
return true;
}
},
{
selector: '.jp-Notebook',
sequence: ['Accel S'],
handler: () => {
nbManager.save();
return true;
}
},
{
selector: '.jp-Notebook.jp-mod-commandMode',
sequence: ['I', 'I'],
handler: () => {
nbManager.interrupt();
return true;
}
},
{
selector: '.jp-Notebook.jp-mod-commandMode',
sequence: ['0', '0'],
handler: () => {
nbManager.restart();
return true;
示例4: startApp
function startApp(session: ISession) {
// Initialize the keymap manager with the bindings.
let keymap = new KeymapManager();
// Setup the keydown listener for the document.
document.addEventListener('keydown', event => {
keymap.processKeydownEvent(event);
});
const transformers = [
new JavascriptRenderer(),
new MarkdownRenderer(),
new HTMLRenderer(),
new ImageRenderer(),
new SVGRenderer(),
new LatexRenderer(),
new TextRenderer()
];
let renderers: MimeMap<IRenderer<Widget>> = {};
let order: string[] = [];
for (let t of transformers) {
for (let m of t.mimetypes) {
renderers[m] = t;
order.push(m);
}
}
let rendermime = new RenderMime<Widget>(renderers, order);
let consolePanel = new ConsolePanel(session, rendermime);
consolePanel.title.text = TITLE;
let pModel = new StandardPaletteModel();
let palette = new CommandPalette();
palette.model = pModel;
let panel = new SplitPanel();
panel.id = 'main';
panel.orientation = SplitPanel.Horizontal;
panel.spacing = 0;
SplitPanel.setStretch(palette, 0);
SplitPanel.setStretch(consolePanel, 1);
panel.attach(document.body);
panel.addChild(palette);
panel.addChild(consolePanel);
window.onresize = () => { panel.update(); };
let items: IStandardPaletteItemOptions[] = [
{
category: 'Console',
text: 'Clear',
shortcut: 'Accel R',
handler: () => { consolePanel.content.clear(); }
},
{
category: 'Console',
text: 'Execute Prompt',
shortcut: 'Shift Enter',
handler: () => { consolePanel.content.execute(); }
}
];
pModel.addItems(items);
let bindings = [
{
selector: '.jp-Console',
sequence: ['Accel R'],
handler: () => { consolePanel.content.clear(); }
},
{
selector: '.jp-Console',
sequence: ['Shift Enter'],
handler: () => { consolePanel.content.execute(); }
}
];
keymap.add(bindings);
}
示例5: main
//.........這裏部分代碼省略.........
handler: () => { nbManager.split() ; }
},
{
category: 'Notebook Cell',
text: 'To Code Type',
shortcut: 'Y',
handler: () => { nbManager.changeCellType('code') ; }
},
{
category: 'Notebook Cell',
text: 'To Markdown Type',
shortcut: 'M',
handler: () => { nbManager.changeCellType('markdown') ; }
},
{
category: 'Notebook Cell',
text: 'To Raw Type',
shortcut: 'R',
handler: () => { nbManager.changeCellType('raw') ; }
},
{
category: 'Notebook Cell',
text: 'Select Above',
shortcut: 'ArrowUp',
handler: () => { nbManager.selectAbove(); }
},
{
category: 'Notebook Cell',
text: 'Select Below',
shortcut: 'ArrowDown',
handler: () => { nbManager.selectBelow(); }
},
];
pModel.addItems(items);
let bindings = [
{
selector: '.jp-Notebook',
sequence: ['Shift Enter'],
handler: () => { nbManager.runAndAdvance(); }
},
{
selector: '.jp-Notebook',
sequence: ['Accel S'],
handler: () => { nbManager.save(); }
},
{
selector: '.jp-Notebook.jp-mod-commandMode',
sequence: ['I', 'I'],
handler: () => { nbManager.interrupt(); }
},
{
selector: '.jp-Notebook.jp-mod-commandMode',
sequence: ['0', '0'],
handler: () => { nbManager.restart(); }
},
{
selector: '.jp-Notebook.jp-mod-commandMode',
sequence: ['Enter'],
handler: () => { nbModel.mode = 'edit'; }
},
{
selector: '.jp-Notebook.jp-mod-editMode',
sequence: ['Escape'],
handler: () => { nbModel.mode = 'command'; }
},
示例6: main
function main(): void {
// Initialize the keymap manager with the bindings.
var keymap = new KeymapManager();
// Setup the keydown listener for the document.
document.addEventListener('keydown', event => {
keymap.processKeydownEvent(event);
});
let contents = new ContentsManager(SERVER_URL);
let rendermime = new RenderMime<Widget>();
const transformers = [
new JavascriptRenderer(),
new HTMLRenderer(),
new ImageRenderer(),
new SVGRenderer(),
new LatexRenderer(),
new ConsoleTextRenderer(),
new TextRenderer(),
new MarkdownRenderer()
];
for (let t of transformers) {
for (let m of t.mimetypes) {
rendermime.order.push(m);
rendermime.renderers[m] = t;
}
}
let consoleModel = new ConsoleModel();
let consoleWidget = new ConsolePanel(consoleModel, rendermime);
consoleWidget.title.text = TITLE;
let pModel = new StandardPaletteModel();
let palette = new CommandPalette();
palette.model = pModel;
let panel = new SplitPanel();
panel.id = 'main';
panel.orientation = SplitPanel.Horizontal;
panel.spacing = 0;
SplitPanel.setStretch(palette, 0);
SplitPanel.setStretch(consoleWidget, 1);
panel.attach(document.body);
panel.addChild(palette);
panel.addChild(consoleWidget);
window.onresize = () => { panel.update(); };
let kernelspecs: IKernelSpecIds;
let items: IStandardPaletteItemOptions[] = [
{
category: 'Console',
text: 'Execute Prompt',
shortcut: 'Shift Enter',
handler: () => { consoleModel.run(); }
}
];
pModel.addItems(items);
let bindings = [
{
selector: '.jp-Console',
sequence: ['Shift Enter'],
handler: () => { consoleModel.run(); }
}
]
keymap.add(bindings);
getKernelSpecs({}).then(specs => {
kernelspecs = specs;
let kernelName = specs.default;
let language = specs.default;
console.log('specs', specs);
return startNewSession({
notebookPath: 'fake_path',
kernelName: findKernel(kernelName, language, specs),
baseUrl: SERVER_URL
});
}).then(session => consoleModel.session = session);
}