fix(toc): table of contents not rendering for doc notes

This commit is contained in:
Elian Doran 2025-11-22 10:59:50 +02:00
parent 5fc10fe041
commit 7daee36d3e
No known key found for this signature in database

View File

@ -199,6 +199,7 @@ export default class TocWidget extends RightPanelWidget {
* For document note types, we obtain the content directly from the DOM since it allows us to obtain processed data without * For document note types, we obtain the content directly from the DOM since it allows us to obtain processed data without
* requesting data twice. However, when immediately navigating to a new note the new document is not yet attached to the hierarchy, * requesting data twice. However, when immediately navigating to a new note the new document is not yet attached to the hierarchy,
* resulting in an empty TOC. The fix is to simply wait for it to pop up. * resulting in an empty TOC. The fix is to simply wait for it to pop up.
* TODO: Use a better method that is not prone to unnecessary delays and race conditions.
*/ */
setTimeout(async () => { setTimeout(async () => {
const $contentEl = await this.noteContext?.getContentElement(); const $contentEl = await this.noteContext?.getContentElement();
@ -209,7 +210,7 @@ export default class TocWidget extends RightPanelWidget {
} else { } else {
console.warn("Unable to get content element for doctype"); console.warn("Unable to get content element for doctype");
} }
}, 10); }, 250);
} }
} }