Skip to content

Commit

Permalink
Added auto scroll to the table of contents.
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniotejada committed Apr 25, 2022
1 parent 737c030 commit 6ab61f3
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions TocWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* the tag noTocWidget to a text note.
*
* By design there's no support for non-sensical or malformed constructs:
* - headings inside elements (eg Trilium allows headings inside tables, but
* - headings inside elements (eg Trilium allows headings inside tables, but
* not inside lists)
* - nested headings when using raw HTML <H2><H3></H3></H2>
* - malformed headings when using raw HTML <H2></H3></H2><H3>
Expand All @@ -22,11 +22,11 @@
* to the wrong heading (although what "right" means in those cases is not
* clear), but it won't crash.
*
* See https://github.com/zadam/trilium/discussions/2799 for discussions
* * See https://github.com/zadam/trilium/discussions/2799 for discussions
*/

const TEMPLATE = `<div style="padding: 0px; border-top: 1px solid var(--main-border-color); contain: none;">
<span class="toc"></span>
const TEMPLATE = `<div style="padding: 0px; border-top: 1px solid var(--main-border-color); contain: none; overflow:auto">
<span class="toc"></span>
</div>`;

const showDebug = (api.startNote.getAttribute("label", "debug") != null);
Expand All @@ -53,13 +53,13 @@ function debugbreak() {
}

/**
* Find a heading node in the parent's children given its index.
*
* @param {Element} parent Parent node to find a headingIndex'th in.
* @param {uint} headingIndex Index for the heading
* @returns {Element|null} Heading node with the given index, null couldn't be
* found (ie malformed like nested headings, etc)
*/
* Find a heading node in the parent's children given its index.
*
* @param {Element} parent Parent node to find a headingIndex'th in.
* @param {uint} headingIndex Index for the heading
* @returns {Element|null} Heading node with the given index, null couldn't be
* found (ie malformed like nested headings, etc)
*/
function findHeadingNodeByIndex(parent, headingIndex) {
dbg("Finding headingIndex " + headingIndex + " in parent " + parent.name);
let headingNode = null;
Expand Down Expand Up @@ -113,10 +113,10 @@ function findHeadingElementByIndex(parent, headingIndex) {
}

/**
* Return the active tab's element containing the HTML element that contains
* a readonly note's HTML.
*
*/
* Return the active tab's element containing the HTML element that contains
* a readonly note's HTML.
*
*/
function getActiveTabReadOnlyTextElement() {
// The note's html is in the following hierarchy
// note-split data-ntx-id=XXXX
Expand Down

0 comments on commit 6ab61f3

Please sign in to comment.