Enable VSCode extension APIs for opening notebooks. (#18080)

* Also moved notebook conversion classes to a common folder, and moved several conversion utility methods to a common file.
This commit is contained in:
Cory Rivera
2022-01-13 16:40:48 -08:00
committed by GitHub
parent 117d9365d5
commit 050d2cc98f
14 changed files with 243 additions and 199 deletions

View File

@@ -27,6 +27,8 @@ import { localize } from 'vs/nls';
import { IFileService } from 'vs/platform/files/common/files';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { NotebookEditor } from 'sql/workbench/contrib/notebook/browser/notebookEditor';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { NewNotebookAction } from 'sql/workbench/contrib/notebook/browser/notebookActions';
class MainThreadNotebookEditor extends Disposable {
private _contentChangedEmitter = new Emitter<NotebookContentChange>();
@@ -320,7 +322,8 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
@IInstantiationService private _instantiationService: IInstantiationService,
@INotebookService private readonly _notebookService: INotebookService,
@IFileService private readonly _fileService: IFileService,
@ITextFileService private readonly _textFileService: ITextFileService
@ITextFileService private readonly _textFileService: ITextFileService,
@ICommandService private readonly _commandService: ICommandService
) {
super();
if (extHostContext) {
@@ -709,4 +712,12 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
}
});
}
$createNotebookDocument(providerId: string, contents: azdata.nb.INotebookContents): Promise<azdata.nb.NotebookDocument> {
return this._commandService.executeCommand(NewNotebookAction.INTERNAL_NEW_NOTEBOOK_CMD_ID, {
providerId: providerId,
initialContent: contents,
initialDirtyState: false
});
}
}