简体   繁体   中英

How to open a *.ipynb file editor through vscode extension API?

How can I open an existing *.ipynb file with a Jupyter Notebook editor from the file's url in a VSCode extension through VSCode extension APIs?

There is a vscode.window.showTextDocument API. Are there any equivalent APIs for notebook files like showNotebookDocument ?

For example

const filePath = 'path/to/notebook.ipynb';
vscode.workspace.openNotebookDocument(vscode.Uri.file(filePath)).then((doc) => {
    vscode.window.showNotebookDocument(doc);
});

Just found my answer

vscode.commands.executeCommand("vscode.openWith", vscode.Uri.file(filePath), 'jupyter-notebook');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM