Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
reduce indent of TOC when larger headings are not being used, fixes #4363
zadamde8c351e254b
diff --git a/src/public/app/widgets/toc.js b/src/public/app/widgets/toc.jsindex 01fbad1a7e..1c0dbc496c 100644--- a/src/public/app/widgets/toc.js+++ b/src/public/app/widgets/toc.js@@ -133,7 +133,7 @@ export default class TocWidget extends RightPanelWidget {// Use jquery to build the table rather than html text, since it makes// it easier to set the onclick event that will be executed with the// right captured callback context- const $toc = $("<ol>");+ let $toc = $("<ol>");// Note heading 2 is the first level Trilium makes available to the notelet curLevel = 2;const $ols = [$toc];@@ -171,12 +171,36 @@ export default class TocWidget extends RightPanelWidget {headingCount = headingIndex;}+ $toc = this.pullLeft($toc);+return {$toc,headingCount};}+ /**+ * Reduce indent if a larger headings are not being used: https://github.com/zadam/trilium/issues/4363+ */+ pullLeft($toc) {+ while (true) {+ const $children = $toc.children();++ if ($children.length !== 1) {+ break;+ }++ const $first = $toc.children(":first");++ if ($first[0].tagName !== 'OL') {+ break;+ }++ $toc = $first;+ }+ return $toc;+ }+async jumpToHeading(headingIndex) {// A readonly note can change state to "readonly disabled// temporarily" (ie "edit this note" button) without any