xcloud-ai49 downloadsGenerate clickable table of contents from any Markdown file headings. Supports dynamic code block rendering, command insertion, custom heading levels, styling, and hotkey configuration with conflict detection.
读取指定 Markdown 文件的标题,生成带层级缩进的可点击目录树。支持代码块动态渲染、命令插入、标题层级与样式自定义、快捷键配置与冲突检测,替代 DataviewJS 的 filecatalog 脚本,无需 Dataview 依赖。
English description below for review purposes. / 以下为英文说明,用于过审。
Reads headings from a specified Markdown file and generates a clickable, hierarchically indented table of contents. Supports code block dynamic rendering, command insertion, heading level customization, style customization, and hotkey configuration with conflict detection. Replaces DataviewJS filecatalog scripts without Dataview dependency.
```filecatalog 代码块,阅读视图自动渲染目标文件的标题目录[[]] 链接格式:代码块里写 [[文件名]] 可触发 Obsidian 自动补全,快速选择文件[[test]] → 直接替换为目录;无选中 → 插入代码块框架,光标定位到内部[[]] 链接的标题显示蓝色,不含链接的标题显示黑色<a> 标签,不被 Obsidian 追踪,文件重命名时不自动更新```filecatalog renders TOC in reading view[[]] link format with Obsidian autocomplete[[file]] with TOC, or insert code block framemain.js、manifest.json、styles.css 三个文件.obsidian/plugins/file-catalog/From Obsidian Community Directory:
Manual Installation:
main.js, manifest.json, styles.css from the latest release<vault>/.obsidian/plugins/file-catalog/在笔记里写:
```filecatalog
[[test]]
```
或直接写文件名:
```filecatalog
test
```
阅读视图会动态渲染 test 文件的标题目录。推荐用 [[test]] 格式,因为输入 [[ 时 Obsidian 会弹出文件列表供选择。
Ctrl+P 搜索「插入文件目录」,两种模式:
| 操作 | 结果 |
|---|---|
先选中 [[test]],再触发命令 |
[[test]] 直接被替换为 test 的目录(静态 markdown) |
| 无选中文本,直接触发命令 | 插入 ```filecatalog 代码块框架,光标定位到内部,自行输入文件名 |
一级标题 ← 黑色(HTML <a>,可点击但不被追踪)
二级标题 ← 黑色
三级标题 ← 黑色
[[other|已有链接]] ← 蓝色(保留原样,被 Obsidian 追踪)
[[]] 链接 → 保留原样,Obsidian 渲染为蓝色链接<a> 标签,黑色,可点击跳转但不被追踪Code block rendering:
```filecatalog with [[filename]] insideCommand: Insert file catalog:
[[file]] selected: replaces with TOC| 设置项 | 说明 |
|---|---|
| 显示的标题层级 | 勾选 H1-H6 中要显示的层级,默认 H2 + H3 |
| 快捷键设置 | 为「插入文件目录」配置快捷键,即时检测冲突 |
| 超链接标题颜色 | 含 [[]] 链接的标题颜色(如 #7c3aed),留空用默认 |
| 无链接标题颜色 | 不含链接的标题颜色(如 #333333),留空用正文色 |
| 字体大小 | 目录字体大小(px),留空用默认 |
| 行间距 | 目录行间距,默认 1.4 |
| 层级缩进 | 每级标题缩进距离(px),默认 20 |
| DataviewJS (原) | 本插件 | |
|---|---|---|
| 依赖 | 需要 Dataview 插件 | 无依赖 |
| 代码块 | ```dataviewjs |
```filecatalog |
| 文件选择 | 手动输入文件名 | 支持 [[文件名]] 自动补全 |
| 标题层级 | 全部显示 | 可自定义 H1-H6 |
| 样式自定义 | 不支持 | 颜色/字体/行间距/缩进 |
| 颜色区别 | 无 | 链接蓝色 / 非链接黑色 |
| 快捷键 | 不支持 | 内置配置 + 冲突检测 |
| 命令插入 | 不支持 | 支持(双模式) |
main.js),无需编译,直接可用main.ts 为 TypeScript 源码参考,供二次开发使用metadataCache.getFileCache 读取标题元数据MarkdownRenderer.renderMarkdown 渲染目录hotkeyManager.setHotkeys 绑定,与 Obsidian 系统快捷键互通loadSettings 每次以 DEFAULT_SETTINGS 为准重建 hotkeyConfigs,自动清理已删除的命令!important,通过提高选择器特异性覆盖默认样式MIT License - Copyright (c) 2026 旭说云原生