如何实现点击文档标题自动展开文档所在的目录

如题,如果目录为折叠状态,点击一篇文档标题,自动展开文档所在的目录

module.exports = async ({ app }) => {
    // https://github.com/shichongrui/obsidian-reveal-active-file/blob/master/main.ts#L27C1-L28C1
    app.commands.executeCommandById('file-explorer:reveal-active-file');

    const currentFile = app.workspace.getActiveFile()
    if (!currentFile) {
        new Notice('No active file to reveal.');
        return;
    }

    const existTab = app.workspace.activeTabGroup.children.find(tab => tab.view?.file?.basename && tab.view?.file?.basename === currentFile?.basename)

    await new Promise((resolve) => setTimeout(resolve, 100));
    app.workspace.setActiveLeaf(existTab, { focus: true });
}

放到CSS代码片段中?咋不管用

你先看看这个插件是不是你要的

image
ob自带有此功能