本文整理匯總了TypeScript中phosphor-splitpanel.SplitPanel.attach方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript SplitPanel.attach方法的具體用法?TypeScript SplitPanel.attach怎麽用?TypeScript SplitPanel.attach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phosphor-splitpanel.SplitPanel
的用法示例。
在下文中一共展示了SplitPanel.attach方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: createApp
function createApp(sessionsManager: NotebookSessionManager, specs: IKernelSpecIds): void {
// Initialize the keymap manager with the bindings.
let keymap = new KeymapManager();
let useCapture = true;
// Setup the keydown listener for the document.
document.addEventListener('keydown', event => {
keymap.processKeydownEvent(event);
}, useCapture);
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 opener = {
open: (widget: DocumentWrapper) => {
// Do nothing for sibling widgets for now.
}
};
let contentsManager = new ContentsManager();
let docRegistry = new DocumentRegistry();
let docManager = new DocumentManager(
docRegistry, contentsManager, sessionsManager, specs, opener
);
let mFactory = new NotebookModelFactory();
let clipboard = new MimeData();
let wFactory = new NotebookWidgetFactory(rendermime, clipboard);
docRegistry.registerModelFactory(mFactory);
docRegistry.registerWidgetFactory(wFactory, {
displayName: 'Notebook',
modelName: 'notebook',
fileExtensions: ['.ipynb'],
defaultFor: ['.ipynb'],
preferKernel: true,
canStartKernel: true
});
let doc = docManager.open(NOTEBOOK);
let nbWidget: NotebookPanel;
doc.populated.connect((d, widget) => {
nbWidget = widget as NotebookPanel;
});
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);
panel.attach(document.body);
panel.addChild(palette);
panel.addChild(doc);
SplitPanel.setStretch(doc, 1);
window.onresize = () => panel.update();
let saveHandler = () => nbWidget.context.save();
let interruptHandler = () => {
if (nbWidget.context.kernel) {
nbWidget.context.kernel.interrupt();
}
};
let restartHandler = () => nbWidget.restart();
let switchHandler = () => {
selectKernelForContext(nbWidget.context, nbWidget.node);
};
let runAdvanceHandler = () => {
NotebookActions.runAndAdvance(nbWidget.content, nbWidget.context.kernel);
};
let editHandler = () => { nbWidget.content.mode = 'edit'; };
let commandHandler = () => { nbWidget.content.mode = 'command'; };
let codeHandler = () => {
NotebookActions.changeCellType(nbWidget.content, 'code');
};
let markdownHandler = () => {
NotebookActions.changeCellType(nbWidget.content, 'markdown');
};
let rawHandler = () => {
NotebookActions.changeCellType(nbWidget.content, 'raw');
};
let selectBelowHandler = () => {
NotebookActions.selectBelow(nbWidget.content);
//.........這裏部分代碼省略.........
示例2: createApp
//.........這裏部分代碼省略.........
}, {
sequence: ['Ctrl P'], // Add emacs keybinding for select previous.
selector: '.jp-DirListing',
handler: () => {
fbWidget.selectPrevious();
}
}, {
sequence: ['Accel S'],
selector: '.jp-CodeMirrorWidget',
handler: () => {
activeWidget.context.save();
}
}]);
window.addEventListener('keydown', (event) => {
keymapManager.processKeydownEvent(event);
});
let contextMenu = new Menu([
new MenuItem({
text: '&Open',
icon: 'fa fa-folder-open-o',
shortcut: 'Ctrl+O',
handler: () => { fbWidget.open(); }
}),
new MenuItem({
text: '&Rename',
icon: 'fa fa-edit',
shortcut: 'Ctrl+R',
handler: () => { fbWidget.rename(); }
}),
new MenuItem({
text: '&Delete',
icon: 'fa fa-remove',
shortcut: 'Ctrl+D',
handler: () => { fbWidget.delete(); }
}),
new MenuItem({
text: 'Duplicate',
icon: 'fa fa-copy',
handler: () => { fbWidget.duplicate(); }
}),
new MenuItem({
text: 'Cut',
icon: 'fa fa-cut',
shortcut: 'Ctrl+X',
handler: () => { fbWidget.cut(); }
}),
new MenuItem({
text: '&Copy',
icon: 'fa fa-copy',
shortcut: 'Ctrl+C',
handler: () => { fbWidget.copy(); }
}),
new MenuItem({
text: '&Paste',
icon: 'fa fa-paste',
shortcut: 'Ctrl+V',
handler: () => { fbWidget.paste(); }
}),
new MenuItem({
text: 'Download',
icon: 'fa fa-download',
handler: () => { fbWidget.download(); }
}),
new MenuItem({
text: 'Shutdown Kernel',
icon: 'fa fa-stop-circle-o',
handler: () => { fbWidget.shutdownKernels(); }
}),
new MenuItem({
text: 'Dialog Demo',
handler: () => { dialogDemo(); }
}),
new MenuItem({
text: 'Info Demo',
handler: () => {
let msg = 'The quick brown fox jumped over the lazy dog'
showDialog({
title: 'Cool Title',
body: msg,
buttons: [okButton]
});
}
})
]);
// Add a context menu to the dir listing.
let node = fbWidget.node.getElementsByClassName('jp-DirListing-content')[0];
node.addEventListener('contextmenu', (event: MouseEvent) => {
event.preventDefault();
let x = event.clientX;
let y = event.clientY;
contextMenu.popup(x, y);
});
panel.attach(document.body);
window.onresize = () => panel.update();
}
示例3: 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);
});
// TODO: check out static example from the history
// and make that a separate example.
let contents = new ContentsManager(SERVER_URL);
let nbModel = new NotebookModel();
let nbManager = new NotebookManager(nbModel, contents);
let rendermime = new RenderMime<Widget>();
const transformers = [
new JavascriptRenderer(),
new HTMLRenderer(),
new ImageRenderer(),
new SVGRenderer(),
new LatexRenderer(),
new ConsoleTextRenderer(),
new TextRenderer()
];
for (let t of transformers) {
for (let m of t.mimetypes) {
rendermime.order.push(m);
rendermime.renderers[m] = t;
}
}
let nbWidget = new NotebookPanel(nbManager, rendermime);
nbWidget.title.text = NOTEBOOK;
let pModel = new StandardPaletteModel();
let palette = new CommandPalette();
palette.model = pModel;
let panel = new SplitPanel();
panel.id = 'main';
panel.orientation = SplitPanel.Horizontal;
SplitPanel.setStretch(palette, 1);
SplitPanel.setStretch(nbWidget, 2);
panel.attach(document.body);
panel.addChild(palette);
panel.addChild(nbWidget);
window.onresize = () => { panel.update(); };
let kernelspecs: IKernelSpecIds;
let items: IStandardPaletteItemOptions[] = [
{
category: 'Notebook',
text: 'Save',
shortcut: 'Accel S',
handler: () => { nbManager.save() ; }
},
{
category: 'Notebook',
text: 'Switch Kernel',
handler: () => {
if (!kernelspecs) {
return;
}
selectKernel(nbWidget.node, nbModel, kernelspecs);
}
},
{
category: 'Notebook',
text: 'Interrupt Kernel',
shortcut: 'I I',
handler: () => { nbManager.interrupt() ; }
},
{
category: 'Notebook',
text: 'Restart Kernel',
shortcut: '0 0',
handler: () => { nbManager.restart() ; }
},
{
category: 'Notebook',
text: 'Trust Notebook',
handler: () => {
trustNotebook(nbModel, nbWidget.node);
}
},
{
category: 'Notebook Cell',
text: 'Run and Advance',
shortcut: 'Shift Enter',
handler: () => { nbManager.runAndAdvance(); }
},
{
category: 'Notebook Cell',
text: 'Run Selected',
handler: () => { nbManager.run(); }
},
{
category: 'Notebook Cell',
//.........這裏部分代碼省略.........
示例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
//.........這裏部分代碼省略.........
return true;
}
}, {
sequence: ['Ctrl N'], // Add emacs keybinding for select next.
selector: '.jp-DirListing',
handler: () => {
fbWidget.selectNext();
return true;
}
}, {
sequence: ['Ctrl P'], // Add emacs keybinding for select previous.
selector: '.jp-DirListing',
handler: () => {
fbWidget.selectPrevious();
return true;
}
}, {
sequence: ['Accel S'],
selector: '.jp-CodeMirrorWidget',
handler: () => {
docManager.save();
return true;
}
}]);
window.addEventListener('keydown', (event) => {
keymapManager.processKeydownEvent(event);
});
let contextMenu = new Menu([
new MenuItem({
text: '&Open',
icon: 'fa fa-folder-open-o',
shortcut: 'Ctrl+O',
handler: () => { fbWidget.open(); }
}),
new MenuItem({
text: '&Rename',
icon: 'fa fa-edit',
shortcut: 'Ctrl+R',
handler: () => { fbWidget.rename(); }
}),
new MenuItem({
text: '&Delete',
icon: 'fa fa-remove',
shortcut: 'Ctrl+D',
handler: () => { fbWidget.delete(); }
}),
new MenuItem({
text: 'Duplicate',
icon: 'fa fa-copy',
handler: () => { fbWidget.duplicate(); }
}),
new MenuItem({
text: 'Cut',
icon: 'fa fa-cut',
shortcut: 'Ctrl+X',
handler: () => { fbWidget.cut(); }
}),
new MenuItem({
text: '&Copy',
icon: 'fa fa-copy',
shortcut: 'Ctrl+C',
handler: () => { fbWidget.copy(); }
}),
new MenuItem({
text: '&Paste',
icon: 'fa fa-paste',
shortcut: 'Ctrl+V',
handler: () => { fbWidget.paste(); }
}),
new MenuItem({
text: 'Download',
icon: 'fa fa-download',
handler: () => { fbWidget.download(); }
}),
new MenuItem({
text: 'Revert',
handler: () => { docManager.revert(); }
}),
new MenuItem({
text: 'Shutdown Kernel',
icon: 'fa fa-stop-circle-o',
handler: () => { fbWidget.shutdownKernels(); }
}),
]);
// Add a context menu to the dir listing.
let node = fbWidget.node.getElementsByClassName('jp-DirListing-content')[0];
node.addEventListener('contextmenu', (event: MouseEvent) => {
event.preventDefault();
let x = event.clientX;
let y = event.clientY;
contextMenu.popup(x, y);
});
panel.attach(document.body);
window.onresize = () => panel.update();
}
示例6: main
//.........這裏部分代碼省略.........
}, {
sequence: ['Accel S'],
selector: '.jp-CodeMirrorWidget',
handler: () => {
let path = fileHandler.findModel(activeWidget).path;
fileHandler.save(path);
return true;
}
}]);
window.addEventListener('keydown', (event) => {
keymapManager.processKeydownEvent(event);
});
let contextMenu = new Menu([
new MenuItem({
text: '&Open',
icon: 'fa fa-folder-open-o',
shortcut: 'Ctrl+O',
handler: () => { fbWidget.open(); }
}),
new MenuItem({
text: '&Rename',
icon: 'fa fa-edit',
shortcut: 'Ctrl+R',
handler: () => { fbWidget.rename(); }
}),
new MenuItem({
text: '&Delete',
icon: 'fa fa-remove',
shortcut: 'Ctrl+D',
handler: () => { fbWidget.delete(); }
}),
new MenuItem({
text: 'Duplicate',
icon: 'fa fa-copy',
handler: () => { fbWidget.duplicate(); }
}),
new MenuItem({
text: 'Cut',
icon: 'fa fa-cut',
shortcut: 'Ctrl+X',
handler: () => { fbWidget.cut(); }
}),
new MenuItem({
text: '&Copy',
icon: 'fa fa-copy',
shortcut: 'Ctrl+C',
handler: () => { fbWidget.copy(); }
}),
new MenuItem({
text: '&Paste',
icon: 'fa fa-paste',
shortcut: 'Ctrl+V',
handler: () => { fbWidget.paste(); }
}),
new MenuItem({
text: 'Download',
icon: 'fa fa-download',
handler: () => { fbWidget.download(); }
}),
new MenuItem({
text: 'Revert',
handler: () => { fbWidget.revert(); }
}),
new MenuItem({
text: 'Shutdown Kernel',
icon: 'fa fa-stop-circle-o',
handler: () => { fbWidget.shutdownKernels(); }
}),
new MenuItem({
text: 'Dialog Demo',
handler: () => { dialogDemo(); }
}),
new MenuItem({
text: 'Info Demo',
handler: () => {
let msg = 'The quick brown fox jumped over the lazy dog'
showDialog({
title: 'Cool Title',
body: msg,
buttons: [okButton]
});
}
})
]);
// Add a context menu to the dir listing.
let node = fbWidget.node.getElementsByClassName('jp-DirListing-content')[0];
node.addEventListener('contextmenu', (event: MouseEvent) => {
event.preventDefault();
let x = event.clientX;
let y = event.clientY;
contextMenu.popup(x, y);
});
panel.attach(document.body);
window.onresize = () => panel.update();
}
示例7: main
function main(): void {
// Initialize the keymap manager with the bindings.
var keymap = new KeymapManager();
let useCapture = true;
// Setup the keydown listener for the document.
document.addEventListener('keydown', event => {
keymap.processKeydownEvent(event);
}, useCapture);
// TODO: check out static example from the history
// and make that a separate example.
let contents = new ContentsManager();
let sessions = new NotebookSessionManager();
let rendermime = new RenderMime<Widget>();
const transformers = [
new JavascriptRenderer(),
new MarkdownRenderer(),
new HTMLRenderer(),
new ImageRenderer(),
new SVGRenderer(),
new LatexRenderer(),
new ConsoleTextRenderer(),
new TextRenderer()
];
for (let t of transformers) {
for (let m of t.mimetypes) {
rendermime.order.push(m);
rendermime.renderers[m] = t;
}
}
let handler = new NotebookFileHandler(contents, sessions, rendermime);
let nbWidget = handler.open(NOTEBOOK);
let nbModel = nbWidget.model;
let nbManager = nbWidget.manager;
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(nbWidget, 1);
panel.attach(document.body);
panel.addChild(palette);
panel.addChild(nbWidget);
window.onresize = () => { panel.update(); };
let kernelspecs: IKernelSpecIds;
let items: IStandardPaletteItemOptions[] = [
{
category: 'Notebook',
text: 'Save',
shortcut: 'Accel S',
handler: () => { nbManager.save() ; }
},
{
category: 'Notebook',
text: 'Switch Kernel',
handler: () => {
if (!kernelspecs) {
return;
}
selectKernel(nbWidget.node, nbModel.kernelspec.name, kernelspecs)
.then(name => {
if (name) {
nbModel.session.changeKernel({name});
}
});
}
},
{
category: 'Notebook',
text: 'Interrupt Kernel',
shortcut: 'I I',
handler: () => { nbManager.interrupt() ; }
},
{
category: 'Notebook',
text: 'Restart Kernel',
shortcut: '0 0',
handler: () => { nbManager.restart() ; }
},
{
category: 'Notebook',
text: 'Trust Notebook',
handler: () => {
trustNotebook(nbModel, nbWidget.node);
}
},
{
category: 'Notebook Cell',
text: 'Run and Advance',
shortcut: 'Shift Enter',
//.........這裏部分代碼省略.........
示例8: 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);
}