This commit is contained in:
Johannes Rieken
2021-05-19 15:27:23 +02:00
parent 734b79dada
commit 53352a2954
11 changed files with 164 additions and 51 deletions

View File

@@ -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);