按楼主要求写 QuickAdd 里了,用 Ob API 偷点懒。
基本配置参 QuickAdd JS & Templater JS 简介及相互修改“QuickAdd Capture 加载内部代码”。
效果 GIF,点击展开
js quickadd 代码:
const title = await this.quickAddApi.inputPrompt('命名:')
, parent = `${app.workspace.getActiveFile().parent.path}/${title}`
, filePath = `${parent}/!${title}.md`; if (!title) return
await app.vault.createFolder(parent); await app.vault.create(filePath, '')
await app.workspace.getLeaf('tab').openFile(app.vault.getAbstractFileByPath(filePath))
考虑实际应用默认在当前活动文档同文件夹下创建新文件夹及文档,不想要可把 parent 前面的 ${app.workspace.getActiveFile().parent.path}/
删除。
为了让同名文档在文件夹置顶我在文档命名前加了 !,不想要可把 ! 删除。