本文整理汇总了TypeScript中@phosphor/widgets.CommandPalette.addClass方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CommandPalette.addClass方法的具体用法?TypeScript CommandPalette.addClass怎么用?TypeScript CommandPalette.addClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@phosphor/widgets.CommandPalette
的用法示例。
在下文中一共展示了CommandPalette.addClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createApp
function createApp(manager: ServiceManager.IManager): void {
// Initialize the command registry with the bindings.
let commands = new CommandRegistry();
let useCapture = true;
// Setup the keydown listener for the document.
document.addEventListener(
'keydown',
event => {
commands.processKeydownEvent(event);
},
useCapture
);
let rendermime = new RenderMimeRegistry({
initialFactories: initialFactories,
latexTypesetter: new MathJaxTypesetter({
url: PageConfig.getOption('mathjaxUrl'),
config: PageConfig.getOption('mathjaxConfig')
})
});
let opener = {
open: (widget: Widget) => {
// Do nothing for sibling widgets for now.
}
};
let docRegistry = new DocumentRegistry();
let docManager = new DocumentManager({
registry: docRegistry,
manager,
opener
});
let mFactory = new NotebookModelFactory({});
let editorFactory = editorServices.factoryService.newInlineEditor;
let contentFactory = new NotebookPanel.ContentFactory({ editorFactory });
let wFactory = new NotebookWidgetFactory({
name: 'Notebook',
modelName: 'notebook',
fileTypes: ['notebook'],
defaultFor: ['notebook'],
preferKernel: true,
canStartKernel: true,
rendermime,
contentFactory,
mimeTypeService: editorServices.mimeTypeService
});
docRegistry.addModelFactory(mFactory);
docRegistry.addWidgetFactory(wFactory);
let notebookPath = PageConfig.getOption('notebookPath');
let nbWidget = docManager.open(notebookPath) as NotebookPanel;
let palette = new CommandPalette({ commands });
palette.addClass('notebookCommandPalette');
const editor =
nbWidget.content.activeCell && nbWidget.content.activeCell.editor;
const model = new CompleterModel();
const completer = new Completer({ editor, model });
const connector = new KernelConnector({ session: nbWidget.session });
const handler = new CompletionHandler({ completer, connector });
// Set the handler's editor.
handler.editor = editor;
// Listen for active cell changes.
nbWidget.content.activeCellChanged.connect((sender, cell) => {
handler.editor = cell && cell.editor;
});
// Hide the widget when it first loads.
completer.hide();
let panel = new SplitPanel();
panel.id = 'main';
panel.orientation = 'horizontal';
panel.spacing = 0;
SplitPanel.setStretch(palette, 0);
SplitPanel.setStretch(nbWidget, 1);
panel.addWidget(palette);
panel.addWidget(nbWidget);
// Attach the panel to the DOM.
Widget.attach(panel, document.body);
Widget.attach(completer, document.body);
// Handle resize events.
window.addEventListener('resize', () => {
panel.update();
});
SetupCommands(commands, palette, nbWidget, handler);
}