Closed M2uyo closed 1 month ago
开启文档的api在这里可以找到:https://github.com/siyuan-note/plugin-sample/blob/main/src/index.ts
这个方法的实现在:https://github.com/siyuan-note/siyuan/blob/master/app/src/plugin/API.ts
文档事件可以监听protyle的相关事件,也就是
this.eventBus.on("loaded-protyle-static", this.eventBusLog);
this.eventBus.on("loaded-protyle-dynamic", this.eventBusLog);
this.eventBus.on("switch-protyle", this.eventBusLog);
this.eventBus.on("destroy-protyle", this.eventBusLog);
相关示例代码同样在:https://github.com/siyuan-note/plugin-sample/blob/main/src/index.ts
感谢,有时间我自己尝试一下,但是好似还缺少一个订住文档的API。
@leolee9086 不知道我写的哪里有差错, 当我关闭 钉住的文档时就会报错(纯后端, 不是很能看明白前端的报错 (╯︵╰,)) 只开启了本插件和Asri主题
async onload() {
this.eventBus.on("destroy-protyle", this.OnDestroy_protyle);
}
private async OnDestroy_protyle({detail}: any) {
if (detail.protyle.model.headElement.classList.contains("item--pin")) {
console.log("inner", detail.protyle.block.id)
await openTab({
app: this.app,
doc: {
id: detail.protyle.block.id
},
keepCursor: true
})
}
}
我先关闭了,如果还有问题请继续跟帖,谢谢 :pray:
In what scenarios do you need this feature?
想自己做个关闭指定窗口时重新打开并并钉住的插件 真的很需要 某个文档始终不被关闭
Describe the optimal solution
新增API
新增事件
Describe the candidate solution
No response
Other information
No response