Notebooks: Support for In-Proc Markdown Renderer (#6164)

* NB improve startup using built-in markdown render

This is a sample branch showing perf improvements if we load content using built-in markdown rendering
- Has issues where images aren't correctly rendered due to sanitization, need to copy renderer code and update settings
- Moves content load up before anythign to do with providers since we can render without knowing about these things

# Conflicts:
#	src/sql/workbench/parts/notebook/cellViews/textCell.component.ts

* Re-enable logging of each cell's rendering time

* Fix test issue

* Kernel loading working with new markdown renderer

# Conflicts:
#	src/sql/workbench/parts/notebook/cellViews/textCell.component.ts

* Fixed tests, cleaned up code

* markdownOutput component integration

* PR Comments

* PR feedback 2

* PR feedback again
This commit is contained in:
Chris LaFreniere
2019-06-27 20:55:50 -07:00
committed by GitHub
parent b34e3cbe90
commit 8cf4120c27
10 changed files with 409 additions and 77 deletions

View File

@@ -69,7 +69,6 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
protected isLoading: boolean;
private notebookManagers: INotebookManager[] = [];
private _modelReadyDeferred = new Deferred<NotebookModel>();
private _modelRegisteredDeferred = new Deferred<NotebookModel>();
private profile: IConnectionProfile;
private _trustedAction: TrustedAction;
private _runAllCellsAction: RunAllCellsAction;
@@ -146,10 +145,6 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
return this._model && this._model.activeCell ? this._model.activeCell.id : '';
}
public get modelRegistered(): Promise<NotebookModel> {
return this._modelRegisteredDeferred.promise;
}
public get cells(): ICellModel[] {
return this._model ? this._model.cells : [];
}
@@ -222,6 +217,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
private async doLoad(): Promise<void> {
try {
await this.createModelAndLoadContents();
await this.setNotebookManager();
await this.loadModel();
this._modelReadyDeferred.resolve(this._model);
@@ -268,7 +264,17 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
}
private async loadModel(): Promise<void> {
// Wait on provider information to be available before loading kernel and other information
await this.awaitNonDefaultProvider();
await this._model.requestModelLoad();
this.detectChanges();
await this._model.startSession(this._model.notebookManager, undefined, true);
this.setContextKeyServiceWithProviderId(this._model.providerId);
this.fillInActionsForCurrentContext();
this.detectChanges();
}
private async createModelAndLoadContents(): Promise<void> {
let model = new NotebookModel({
factory: this.modelFactory,
notebookUri: this._notebookParams.notebookUri,
@@ -276,27 +282,22 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
notificationService: this.notificationService,
notebookManagers: this.notebookManagers,
contentManager: this._notebookParams.input.contentManager,
standardKernels: this._notebookParams.input.standardKernels,
cellMagicMapper: new CellMagicMapper(this.notebookService.languageMagics),
providerId: 'sql', // this is tricky; really should also depend on the connection profile
providerId: 'sql',
defaultKernel: this._notebookParams.input.defaultKernel,
layoutChanged: this._notebookParams.input.layoutChanged,
capabilitiesService: this.capabilitiesService,
editorLoadedTimestamp: this._notebookParams.input.editorOpenedTimestamp
}, this.profile, this.logService, this.notificationService, this.telemetryService);
model.onError((errInfo: INotification) => this.handleModelError(errInfo));
let trusted = await this.notebookService.isNotebookTrustCached(this._notebookParams.notebookUri, this.isDirty());
await model.requestModelLoad(trusted);
model.onError((errInfo: INotification) => this.handleModelError(errInfo));
model.contentChanged((change) => this.handleContentChanged(change));
model.onProviderIdChange((provider) => this.handleProviderIdChanged(provider));
model.kernelChanged((kernelArgs) => this.handleKernelChanged(kernelArgs));
this._model = this._register(model);
this.updateToolbarComponents(this._model.trustedMode);
this._modelRegisteredDeferred.resolve(this._model);
await this._model.loadContents(trusted);
this.setLoading(false);
await model.startSession(this.model.notebookManager, undefined, true);
this.setContextKeyServiceWithProviderId(model.providerId);
this.fillInActionsForCurrentContext();
this.updateToolbarComponents(this._model.trustedMode);
this.detectChanges();
}
@@ -311,6 +312,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
private async awaitNonDefaultProvider(): Promise<void> {
// Wait on registration for now. Long-term would be good to cache and refresh
await this.notebookService.registrationComplete;
this.model.standardKernels = this._notebookParams.input.standardKernels;
// Refresh the provider if we had been using default
let providerInfo = await this._notebookParams.providerInfo;