Notebook Deep Link to Section (#13795)

* Notebook deep link to section

* fragment wip
This commit is contained in:
Chris LaFreniere
2020-12-14 17:20:29 -08:00
committed by GitHub
parent 7496aea1b0
commit 1f630b9767

View File

@@ -294,7 +294,6 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
this.setViewInErrorState(localize('displayFailed', "Could not display contents: {0}", getErrorMessage(error))); this.setViewInErrorState(localize('displayFailed', "Could not display contents: {0}", getErrorMessage(error)));
this.setLoading(false); this.setLoading(false);
this._modelReadyDeferred.reject(error); this._modelReadyDeferred.reject(error);
this.notebookService.addNotebookEditor(this); this.notebookService.addNotebookEditor(this);
} }
} }
@@ -342,6 +341,8 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
this._model = this._register(model); this._model = this._register(model);
await this._model.loadContents(trusted); await this._model.loadContents(trusted);
this.setLoading(false); this.setLoading(false);
// Check if URI fragment is present; if it is, navigate to section by default
this.navigateToSectionIfURIFragmentExists();
this.updateToolbarComponents(); this.updateToolbarComponents();
this.detectChanges(); this.detectChanges();
} }
@@ -759,6 +760,12 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
return headers; return headers;
} }
private navigateToSectionIfURIFragmentExists(): void {
if (this.notebookParams.notebookUri?.fragment) {
this.navigateToSection(this.notebookParams.notebookUri.fragment);
}
}
navigateToSection(id: string): void { navigateToSection(id: string): void {
id = id.toLowerCase(); id = id.toLowerCase();
let chromeHeight: number = 0; let chromeHeight: number = 0;