mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
add API to open an untitled notebook, https://github.com/microsoft/vscode/issues/121974
This commit is contained in:
@@ -1036,9 +1036,18 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
|
||||
// namespace: notebook
|
||||
const notebook: typeof vscode.notebook = {
|
||||
openNotebookDocument: (uriComponents) => {
|
||||
async openNotebookDocument(uriOrOptions?: URI | string, content?: vscode.NotebookData) {
|
||||
checkProposedApiEnabled(extension);
|
||||
return extHostNotebook.openNotebookDocument(uriComponents);
|
||||
let uri: URI;
|
||||
if (URI.isUri(uriOrOptions)) {
|
||||
uri = uriOrOptions;
|
||||
await extHostNotebook.openNotebookDocument(uriOrOptions);
|
||||
} else if (typeof uriOrOptions === 'string') {
|
||||
uri = URI.revive(await extHostNotebook.createNotebookDocument({ viewType: uriOrOptions, content }));
|
||||
} else {
|
||||
throw new Error('Invalid arguments');
|
||||
}
|
||||
return extHostNotebook.getNotebookDocument(uri).apiNotebook;
|
||||
},
|
||||
get onDidOpenNotebookDocument(): Event<vscode.NotebookDocument> {
|
||||
checkProposedApiEnabled(extension);
|
||||
|
||||
Reference in New Issue
Block a user