本文整理匯總了TypeScript中@jupyterlab/filebrowser.FileBrowser類的典型用法代碼示例。如果您正苦於以下問題:TypeScript FileBrowser類的具體用法?TypeScript FileBrowser怎麽用?TypeScript FileBrowser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FileBrowser類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: FileBrowserModel
const createFileBrowser = (
id: string,
options: IFileBrowserFactory.IOptions = {}
) => {
const model = new FileBrowserModel({
manager: docManager,
driveName: options.driveName || '',
state: options.state === null ? null : options.state || state
});
const widget = new FileBrowser({
id,
model,
commands: options.commands || commands
});
const { registry } = docManager;
// Add a launcher toolbar item.
let launcher = new ToolbarButton({
className: 'jp-AddIcon',
onClick: () => {
return createLauncher(commands, widget);
},
tooltip: 'New Launcher'
});
launcher.addClass('jp-MaterialIcon');
widget.toolbar.insertItem(0, 'launch', launcher);
// Add a context menu handler to the file browser's directory listing.
let node = widget.node.getElementsByClassName('jp-DirListing-content')[0];
node.addEventListener('contextmenu', (event: MouseEvent) => {
event.preventDefault();
const model = widget.modelForClick(event);
const menu = createContextMenu(model, commands, registry);
menu.open(event.clientX, event.clientY);
});
// Track the newly created file browser.
tracker.add(widget);
return widget;
};
示例2: createContextMenu
node.addEventListener('contextmenu', (event: MouseEvent) => {
event.preventDefault();
const model = widget.modelForClick(event);
if (model) {
const menu = createContextMenu(model, commands, registry);
menu.open(event.clientX, event.clientY);
}
});
示例3:
execute: () => {
const item = browser.selectedItems().next();
if (!item) {
return;
}
Clipboard.copyToSystem(item.path);
},
示例4:
execute: () => {
const widget = tracker.currentWidget;
if (!widget) {
return;
}
return browser.model.manager.services.contents
.getDownloadUrl(browser.selectedItems().next().path)
.then(url => {
Clipboard.copyToSystem(url);
});
},
示例5: createContextMenu
node.addEventListener('contextmenu', (event: MouseEvent) => {
event.preventDefault();
const path = widget.pathForClick(event) || '';
const menu = createContextMenu(path, commands, registry);
menu.open(event.clientX, event.clientY);
});