因为用浮窗打开有时稍显麻烦,目前可以用 ctrl + 单击虚拟引用后台打开页签,alt + 虚拟引用右侧打开对应页签。
因 shift+ 单击会选文字,就用不了了。
对了,要先安装个 sy-run-js 插件,再配置代码片段。
代码如下:
(async () => {
const targetButtonSelector = "[data-type~='virtual-block-ref']";
document.addEventListener('click', isClickVirtualBlock);
function isClickVirtualBlock(event){
if (event.target.matches(targetButtonSelector)) {
if (event.ctrlKey) {
handleCtrlClick(event.target);
} else if (event.shiftKey) {
// handleShiftClick(event.target);
} else if (event.altKey) {
handleAltClick(event.target);
}
}
}
async function getBlockDefIDs(text){
let res = await runJs.siyuan.fetchSyncPost("/api/block/getBlockDefIDsByRefText", {anchor:text,excludeIDs:[]});
return res.data.refDefs.map(a=>a.refID);
}
async function handleCtrlClick(node) {
let ids = await getBlockDefIDs(node.innerText);
Array.from(ids).forEach(async (id)=>{
await runJs.siyuan.openTab({
app:runJs.plugin.app,
doc: {
id: id,
action: ["cb-get-context","cb-get-hl","cb-get-focus"],
zoomIn: false
},
keepCursor:true,
removeCurrentTab:false
});
})
}
async function handleAltClick(node) {
let ids = await getBlockDefIDs(node.innerText);
Array.from(ids).forEach(async (id)=>{
await runJs.siyuan.openTab({
app:runJs.plugin.app,
doc: {
id: id,
action: ["cb-get-context","cb-get-hl","cb-get-focus"],
zoomIn: false
},
position:"right",
keepCursor:true,
removeCurrentTab:false
});
})
}
})()
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于