Open jnyblom opened 7 months ago
可以参考下
function onInsertToc(editor, view) {
const content = editor.getValue();
const tocAlreadyExists = content.includes('# 目录');
if (!tocAlreadyExists) {
view.sourceMode.cmEditor.exec("goStart");
const markdown = '# 目录\n```' + codeblockId + '\n```\n';
editor.replaceRange(markdown, editor.getCursor());
} else {
new obsidian.Notice('目录已被添加');
}
}
function onInsertTocWithDocs(editor, view) {
const content = editor.getValue();
const tocAlreadyExists = content.includes('# 目录');
if (!tocAlreadyExists) {
view.sourceMode.cmEditor.exec("goStart");
let markdown = ['# 目录\n```' + codeblockId]
Object.keys(availableOptions).forEach((optionName) => {
const option = availableOptions[optionName]
const comment = option.comment.length > 0 ? ` # ${option.comment}` : ''
markdown.push(`${optionName}: ${option.default}${comment}`)
})
markdown.push('```\n')
editor.replaceRange(markdown.join('\n'), editor.getCursor())
} else {
new obsidian.Notice('目录已被添加');
}
}
Hi,
I'd like to be able to set a "starting point" for the table of contents. Say I do not want the first h1 and sub headings to be part of the toc. Ex:
Would result in table of contents starting from "first section in toc":
Hope this makes sense. Thanks.