系统文件资源管理器双击打开已索引的 Obsidian Markdown 文件

20260113 更新:


可以通过插件注册的方式自定义 URI 实现多样化的打开。示例 main.js 代码如下:

const ob = require('obsidian')
module.exports = class extends ob.Plugin {
  onload() {
    uri_1(this)
  }
  onunload() {}
}

const uri_1 = (plg)=> {
  const { app } = plg
  const ptc = 'open-tab'
  plg.registerObsidianProtocolHandler(ptc, async (uri)=> {
    if (uri.action != ptc) return
    if (uri.file) {
      const file = app.metadataCache.getFirstLinkpathDest(uri.file, uri.file)
      await app.workspace.getLeaf('tab').openFile(file)
    }
  })
}

加载插件重启 Ob 一次后,obsidian://open-tab? 的 URI 将会默认在新标签页打开。

3 个赞