mirror of https://github.com/status-im/codimd.git
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:
parent
89a0de4205
commit
5847bf09bf
|
@ -253,6 +253,32 @@
|
||||||
padding-right: 40px;
|
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 {
|
.ui-toc-dropdown .nav .nav>li>a:focus,.ui-toc-dropdown .nav .nav>li>a:hover {
|
||||||
padding-left: 29px;
|
padding-left: 29px;
|
||||||
}
|
}
|
||||||
|
@ -269,6 +295,22 @@
|
||||||
padding-right: 39px;
|
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 {
|
.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;
|
padding-left: 28px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
@ -287,6 +329,24 @@
|
||||||
padding-right: 38px;
|
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 */
|
/* support japanese font */
|
||||||
.markdown-body[lang^="ja"] {
|
.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", "MS ゴシック", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, "Hiragino Kaku Gothic Pro", "ヒラギノ角ゴ Pro W3", Osaka, Meiryo, "メイリオ", "MS Gothic", "MS ゴシック", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||||
|
|
|
@ -128,6 +128,22 @@ This option allows you to enable Disqus with your shortname.
|
||||||
disqus: codimd
|
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
|
type
|
||||||
---
|
---
|
||||||
This option allows you to switch the document view to the slide preview, to simplify live editing of presentations.
|
This option allows you to switch the document view to the slide preview, to simplify live editing of presentations.
|
||||||
|
|
|
@ -811,8 +811,12 @@ export function generateToc (id) {
|
||||||
const target = $(`#${id}`)
|
const target = $(`#${id}`)
|
||||||
target.html('')
|
target.html('')
|
||||||
/* eslint-disable no-unused-vars */
|
/* 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', {
|
var toc = new window.Toc('doc', {
|
||||||
level: 3,
|
level: maxLevel,
|
||||||
top: -1,
|
top: -1,
|
||||||
class: 'toc',
|
class: 'toc',
|
||||||
ulClass: 'nav',
|
ulClass: 'nav',
|
||||||
|
@ -1010,8 +1014,12 @@ export function renderTOC (view) {
|
||||||
const target = $(`#${id}`)
|
const target = $(`#${id}`)
|
||||||
target.html('')
|
target.html('')
|
||||||
/* eslint-disable no-unused-vars */
|
/* 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', {
|
const TOC = new window.Toc('doc', {
|
||||||
level: 3,
|
level: maxLevel,
|
||||||
top: -1,
|
top: -1,
|
||||||
class: 'toc',
|
class: 'toc',
|
||||||
targetId: id,
|
targetId: id,
|
||||||
|
|
Loading…
Reference in New Issue