【QuickAdd脚本】在侧边中打开

模仿浏览器的“在边栏中打开”的选项,使笔记在侧边栏中打开并固定。

PixPin_2024-12-27_17-11-35

QuickAdd Capture

```js quickadd
const activefile = app.workspace.getActiveFile();
const filePath = app.vault.getAbstractFileByPath(activefile.path)
app.workspace.getLeaf('split', 'vertical').openFile(filePath);

const comm = str => app.commands.executeCommandById(str);

const setPanel = percent => {
    let right = document.querySelector('.workspace-split.mod-vertical.mod-root').lastElementChild;
    right.previousSibling.style.flexGrow = percent;
    right.style.flexGrow = 100 - percent;
};

setTimeout(() => {
    setPanel(75); // 50、80
    comm('editor:focus-right');
    comm("workspace:toggle-pin");
}, 50);

```

Reference

2 个赞