mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Fix anchor links in notebooks (#9848)
* Fix links using anchors issue #8428 * Address PR comments
This commit is contained in:
@@ -58,7 +58,7 @@ export class LinkHandlerDirective {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
if (uri && this.openerService && this.isSupportedLink(uri)) {
|
if (uri && this.openerService && this.isSupportedLink(uri)) {
|
||||||
if (uri.fragment && uri.fragment.length > 0 && uri.path === this.workbenchFilePath.path) {
|
if (uri.fragment && uri.fragment.length > 0 && uri.fsPath === this.workbenchFilePath.fsPath) {
|
||||||
this.notebookService.navigateTo(this.notebookUri, uri.fragment);
|
this.notebookService.navigateTo(this.notebookUri, uri.fragment);
|
||||||
} else {
|
} else {
|
||||||
this.openerService.open(uri).catch(onUnexpectedError);
|
this.openerService.open(uri).catch(onUnexpectedError);
|
||||||
|
|||||||
@@ -654,10 +654,10 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
|||||||
private getSectionElements(): NotebookSection[] {
|
private getSectionElements(): NotebookSection[] {
|
||||||
let headers: NotebookSection[] = [];
|
let headers: NotebookSection[] = [];
|
||||||
let el: HTMLElement = this.container.nativeElement;
|
let el: HTMLElement = this.container.nativeElement;
|
||||||
let headerElements = el.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
let headerElements = el.querySelectorAll('h1, h2, h3, h4, h5, h6, a[name], a[id]');
|
||||||
for (let i = 0; i < headerElements.length; i++) {
|
for (let i = 0; i < headerElements.length; i++) {
|
||||||
let headerEl = headerElements[i] as HTMLElement;
|
let headerEl = headerElements[i] as HTMLElement;
|
||||||
if (headerEl['id']) {
|
if (headerEl['id'] || headerEl['name']) {
|
||||||
headers.push(new NotebookSection(headerEl));
|
headers.push(new NotebookSection(headerEl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -685,7 +685,7 @@ class NotebookSection implements INotebookSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get relativeUri(): string {
|
get relativeUri(): string {
|
||||||
return this.headerEl['id'];
|
return this.headerEl['id'] || this.headerEl['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
get header(): string {
|
get header(): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user