Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createContextMenu(path: string, commands: CommandRegistry, registry: DocumentRegistry): Menu {
const menu = new Menu({ commands });
menu.addItem({ command: CommandIDs.open });
const ext = DocumentRegistry.extname(path);
const factories = registry.preferredWidgetFactories(ext).map(f => f.name);
if (path && factories.length > 1) {
const command = 'docmanager:open';
const openWith = new Menu({ commands });
openWith.title.label = 'Open With...';
factories.forEach(factory => {
openWith.addItem({ args: { factory, path }, command });
});
menu.addItem({ type: 'submenu', submenu: openWith });
}
menu.addItem({ command: CommandIDs.rename });
menu.addItem({ command: CommandIDs.del });
menu.addItem({ command: CommandIDs.duplicate });
menu.addItem({ command: CommandIDs.cut });
menu.addItem({ command: CommandIDs.copy });
get ext(): string {
return DocumentRegistry.extname(this.inputNode.value);
}
constructor(path: string, manager: DocumentManager) {
super({ node: Private.createOpenWithNode() });
this._manager = manager;
this.inputNode.textContent = path;
this._ext = DocumentRegistry.extname(path);
this.populateFactories();
this.widgetDropdown.onchange = this.widgetChanged.bind(this);
}