mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
reduce indent of TOC when larger headings are not being used, fixes #4363
This commit is contained in:
parent
695c9d5cf3
commit
de8c351e25
@ -133,7 +133,7 @@ export default class TocWidget extends RightPanelWidget {
|
|||||||
// Use jquery to build the table rather than html text, since it makes
|
// 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
|
// it easier to set the onclick event that will be executed with the
|
||||||
// right captured callback context
|
// right captured callback context
|
||||||
const $toc = $("<ol>");
|
let $toc = $("<ol>");
|
||||||
// Note heading 2 is the first level Trilium makes available to the note
|
// Note heading 2 is the first level Trilium makes available to the note
|
||||||
let curLevel = 2;
|
let curLevel = 2;
|
||||||
const $ols = [$toc];
|
const $ols = [$toc];
|
||||||
@ -171,12 +171,36 @@ export default class TocWidget extends RightPanelWidget {
|
|||||||
headingCount = headingIndex;
|
headingCount = headingIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$toc = this.pullLeft($toc);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
$toc,
|
$toc,
|
||||||
headingCount
|
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) {
|
async jumpToHeading(headingIndex) {
|
||||||
// A readonly note can change state to "readonly disabled
|
// A readonly note can change state to "readonly disabled
|
||||||
// temporarily" (ie "edit this note" button) without any
|
// temporarily" (ie "edit this note" button) without any
|
||||||
|
Loading…
x
Reference in New Issue
Block a user