added an option to set the depth of the table of contents freely for every note

Signed-off-by: Gereon Dusella <git@gereondusella.de>
This commit is contained in:
Gereon Dusella 2020-06-01 22:27:16 +02:00
parent 89a0de4205
commit 5847bf09bf
3 changed files with 86 additions and 2 deletions

View File

@ -253,6 +253,32 @@
padding-right: 40px;
}
.ui-toc-dropdown .nav .nav>li>ul>li>ul>li>a {
padding-top: 1px;
padding-bottom: 1px;
padding-left: 50px;
font-size: 12px;
font-weight: 400;
}
.ui-toc-dropdown[dir='rtl'] .nav .nav>li>ul>li>ul>li>a {
padding-right: 50px;
}
.ui-toc-dropdown .nav .nav>li>ul>li>ul>li>ul>li>a {
padding-top: 1px;
padding-bottom: 1px;
padding-left: 60px;
font-size: 12px;
font-weight: 400;
}
.ui-toc-dropdown[dir='rtl'] .nav .nav>li>ul>li>ul>li>ul>li>a {
padding-right: 60px;
}
.ui-toc-dropdown .nav .nav>li>a:focus,.ui-toc-dropdown .nav .nav>li>a:hover {
padding-left: 29px;
}
@ -269,6 +295,22 @@
padding-right: 39px;
}
.ui-toc-dropdown .nav .nav>li>ul>li>ul>li>a:focus,.ui-toc-dropdown .nav .nav>li>ul>li>ul>li>a:hover {
padding-left: 49px;
}
.ui-toc-dropdown[dir='rtl'] .nav .nav>li>ul>li>ul>li>a:focus,.ui-toc-dropdown[dir='rtl'] .nav .nav>li>ul>li>ul>li>a:hover {
padding-right: 49px;
}
.ui-toc-dropdown .nav .nav>li>ul>li>ul>li>ul>li>a:focus,.ui-toc-dropdown .nav .nav>li>ul>li>ul>li>ul>li>a:hover {
padding-left: 59px;
}
.ui-toc-dropdown[dir='rtl'] .nav .nav>li>ul>li>ul>li>ul>li>a:focus,.ui-toc-dropdown[dir='rtl'] .nav .nav>li>ul>li>ul>li>ul>li>a:hover {
padding-right: 59px;
}
.ui-toc-dropdown .nav .nav>.active:focus>a,.ui-toc-dropdown .nav .nav>.active:hover>a,.ui-toc-dropdown .nav .nav>.active>a {
padding-left: 28px;
font-weight: 500;
@ -287,6 +329,24 @@
padding-right: 38px;
}
.ui-toc-dropdown .nav .nav>.active>.nav>.active>.nav>.active:focus>a,.ui-toc-dropdown .nav .nav>.active>.nav>.active>.nav>.active:hover>a,.ui-toc-dropdown .nav .nav>.active>.nav>.active>.nav>.active>a {
padding-left: 48px;
font-weight: 500;
}
.ui-toc-dropdown[dir='rtl'] .nav .nav>.active>.nav>.active>.nav>.active:focus>a,.ui-toc-dropdown[dir='rtl'] .nav .nav>.active>.nav>.active>.nav>.active:hover>a,.ui-toc-dropdown[dir='rtl'] .nav .nav>.active>.active>.nav>.nav>.active>a {
padding-right: 48px;
}
.ui-toc-dropdown .nav .nav>.active>.nav>.active>.nav>.active>.nav>.active:focus>a,.ui-toc-dropdown .nav .nav>.active>.nav>.active>.nav>.active>.nav>.active:hover>a,.ui-toc-dropdown .nav .nav>.active>.nav>.active>.nav>.active>.nav>.active>a {
padding-left: 58px;
font-weight: 500;
}
.ui-toc-dropdown[dir='rtl'] .nav .nav>.active>.nav>.active>.nav>.active>.nav>.active:focus>a,.ui-toc-dropdown[dir='rtl'] .nav .nav>.active>.nav>.active>.nav>.active>.nav>.active:hover>a,.ui-toc-dropdown[dir='rtl'] .nav .nav>.active>.active>.nav>.nav>.active>.nav>.active>a {
padding-right: 58px;
}
/* support japanese font */
.markdown-body[lang^="ja"] {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, "Hiragino Kaku Gothic Pro", "ヒラギノ角ゴ Pro W3", Osaka, Meiryo, "メイリオ", "MS Gothic", " ゴシック", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";

View File

@ -128,6 +128,22 @@ This option allows you to enable Disqus with your shortname.
disqus: codimd
```
toc
---
This option allows you to set options regarding the table of contents (toc). Currently, its only option is to set the maxDepth.
**Notice: always use two spaces as indention in YAML metadata!**
> **maxDepth:**
> default: not set (whioch will show everything until level 3 (h1 -- h3))
> max: 5 (as defined by doctoc)
**Example**
type
---
This option allows you to switch the document view to the slide preview, to simplify live editing of presentations.

View File

@ -811,8 +811,12 @@ export function generateToc (id) {
const target = $(`#${id}`)
target.html('')
/* eslint-disable no-unused-vars */
var tocOptions = md.meta.toc || {}
var maxLevel = (typeof tocOptions.maxLevel === 'number' && tocOptions.maxLevel > 0) ? tocOptions.maxLevel : 3
var toc = new window.Toc('doc', {
level: 3,
level: maxLevel,
top: -1,
class: 'toc',
ulClass: 'nav',
@ -1010,8 +1014,12 @@ export function renderTOC (view) {
const target = $(`#${id}`)
target.html('')
/* eslint-disable no-unused-vars */
var tocOptions = md.meta.toc || {}
var maxLevel = (typeof tocOptions.maxLevel === 'number' && tocOptions.maxLevel > 0) ? tocOptions.maxLevel : 3
const TOC = new window.Toc('doc', {
level: 3,
level: maxLevel,
top: -1,
class: 'toc',
targetId: id,