feat(right_pane_widget): handle zero headings

This commit is contained in:
Elian Doran 2025-12-19 23:32:58 +02:00
parent fad6414e1d
commit 6da42fac20
No known key found for this signature in database
2 changed files with 9 additions and 4 deletions

View File

@ -1796,7 +1796,8 @@
}, },
"toc": { "toc": {
"table_of_contents": "Table of Contents", "table_of_contents": "Table of Contents",
"options": "Options" "options": "Options",
"no_headings": "No headings."
}, },
"watched_file_update_status": { "watched_file_update_status": {
"file_last_modified": "File <code class=\"file-path\"></code> has been last modified on <span class=\"file-last-modified\"></span>.", "file_last_modified": "File <code class=\"file-path\"></code> has been last modified on <span class=\"file-last-modified\"></span>.",

View File

@ -40,9 +40,13 @@ function AbstractTableOfContents<T extends RawHeading>({ headings, scrollToHeadi
const nestedHeadings = buildHeadingTree(headings); const nestedHeadings = buildHeadingTree(headings);
return ( return (
<span className="toc"> <span className="toc">
<ol> {nestedHeadings.length > 0 ? (
{nestedHeadings.map(heading => <TableOfContentsHeading key={heading.id} heading={heading} scrollToHeading={scrollToHeading} />)} <ol>
</ol> {nestedHeadings.map(heading => <TableOfContentsHeading key={heading.id} heading={heading} scrollToHeading={scrollToHeading} />)}
</ol>
) : (
<div className="no-headings">{t("toc.no_headings")}</div>
)}
</span> </span>
); );
} }