From 1f630b97675d4e2109a98bbbe468d47b7c121d0b Mon Sep 17 00:00:00 2001 From: Chris LaFreniere <40371649+chlafreniere@users.noreply.github.com> Date: Mon, 14 Dec 2020 17:20:29 -0800 Subject: [PATCH] Notebook Deep Link to Section (#13795) * Notebook deep link to section * fragment wip --- .../contrib/notebook/browser/notebook.component.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sql/workbench/contrib/notebook/browser/notebook.component.ts b/src/sql/workbench/contrib/notebook/browser/notebook.component.ts index 5b9b09d32a..896e7ca995 100644 --- a/src/sql/workbench/contrib/notebook/browser/notebook.component.ts +++ b/src/sql/workbench/contrib/notebook/browser/notebook.component.ts @@ -294,7 +294,6 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe this.setViewInErrorState(localize('displayFailed', "Could not display contents: {0}", getErrorMessage(error))); this.setLoading(false); this._modelReadyDeferred.reject(error); - this.notebookService.addNotebookEditor(this); } } @@ -342,6 +341,8 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe this._model = this._register(model); await this._model.loadContents(trusted); this.setLoading(false); + // Check if URI fragment is present; if it is, navigate to section by default + this.navigateToSectionIfURIFragmentExists(); this.updateToolbarComponents(); this.detectChanges(); } @@ -759,6 +760,12 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe return headers; } + private navigateToSectionIfURIFragmentExists(): void { + if (this.notebookParams.notebookUri?.fragment) { + this.navigateToSection(this.notebookParams.notebookUri.fragment); + } + } + navigateToSection(id: string): void { id = id.toLowerCase(); let chromeHeight: number = 0;