Obsidian 原装 URI 只能在当前活动文档打开新文档,可以通过插件注册的方式自定义 URI 实现多样化的打开。示例 main.js 代码如下:
const ob = require('obsidian')
module.exports = class extends ob.Plugin {
onload() {
this.registerObsidianProtocolHandler('open-tab', (uri)=> {
if (uri.action != 'open-tab' || !uri.file) return
const file = this.app.metadataCache.getFirstLinkpathDest(uri.file, uri.file)
this.app.workspace.getLeaf('tab').openFile(file)
})
}
onunload() {}
}
加载插件重启 Ob 一次后,obsidian://open-tab?
的 URI 将会默认在新标签页打开。