|
|
|
@ -10,7 +10,6 @@ export interface TocEntry { |
|
|
|
children: TocEntry[]; |
|
|
|
children: TocEntry[]; |
|
|
|
parent?: TocEntry; |
|
|
|
parent?: TocEntry; |
|
|
|
depth: number; |
|
|
|
depth: number; |
|
|
|
expanded: boolean; |
|
|
|
|
|
|
|
childrenResolved: boolean; |
|
|
|
childrenResolved: boolean; |
|
|
|
resolveChildren: () => Promise<void>; |
|
|
|
resolveChildren: () => Promise<void>; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -24,7 +23,8 @@ export interface TocEntry { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export class TableOfContents { |
|
|
|
export class TableOfContents { |
|
|
|
public addressMap: SvelteMap<string, TocEntry> = new SvelteMap(); |
|
|
|
public addressMap: SvelteMap<string, TocEntry> = new SvelteMap(); |
|
|
|
|
|
|
|
public expandedMap: SvelteMap<string, boolean> = new SvelteMap(); |
|
|
|
|
|
|
|
|
|
|
|
#root: TocEntry | null = null; |
|
|
|
#root: TocEntry | null = null; |
|
|
|
#publicationTree: SveltePublicationTree; |
|
|
|
#publicationTree: SveltePublicationTree; |
|
|
|
#pagePathname: string; |
|
|
|
#pagePathname: string; |
|
|
|
@ -92,11 +92,11 @@ export class TableOfContents { |
|
|
|
href, |
|
|
|
href, |
|
|
|
depth, |
|
|
|
depth, |
|
|
|
children: [], |
|
|
|
children: [], |
|
|
|
expanded: false, |
|
|
|
|
|
|
|
childrenResolved: true, |
|
|
|
childrenResolved: true, |
|
|
|
resolveChildren: () => Promise.resolve(), |
|
|
|
resolveChildren: () => Promise.resolve(), |
|
|
|
}; |
|
|
|
}; |
|
|
|
parentEntry.children.push(tocEntry); |
|
|
|
parentEntry.children.push(tocEntry); |
|
|
|
|
|
|
|
this.expandedMap.set(tocEntry.address, false); |
|
|
|
|
|
|
|
|
|
|
|
this.buildTocFromDocument(header, tocEntry, depth + 1); |
|
|
|
this.buildTocFromDocument(header, tocEntry, depth + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -213,10 +213,10 @@ export class TableOfContents { |
|
|
|
href: `${this.#pagePathname}#${address}`, |
|
|
|
href: `${this.#pagePathname}#${address}`, |
|
|
|
children: [], |
|
|
|
children: [], |
|
|
|
depth, |
|
|
|
depth, |
|
|
|
expanded: false, |
|
|
|
|
|
|
|
childrenResolved: false, |
|
|
|
childrenResolved: false, |
|
|
|
resolveChildren: resolver, |
|
|
|
resolveChildren: resolver, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
this.expandedMap.set(address, false); |
|
|
|
|
|
|
|
|
|
|
|
return entry; |
|
|
|
return entry; |
|
|
|
} |
|
|
|
} |
|
|
|
|