Merge pull request #19 from siyuan-note/dev

Update
This commit is contained in:
Frostime 2023-07-15 15:31:11 +08:00 committed by GitHub
commit e6f5580c26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 119 additions and 13 deletions

View file

@ -1,3 +1,12 @@
## 0.1.10
* [Add `bind this` example for eventBus in plugins](https://github.com/siyuan-note/siyuan/issues/8668)
* [Add `open-menu-breadcrumbmore` event bus to plugins](https://github.com/siyuan-note/siyuan/issues/8666)
## 0.1.9
* [Add `open-menu-xxx` event bus for plugins ](https://github.com/siyuan-note/siyuan/issues/8617)
## 0.1.8
* [Add protyleSlash to the plugin](https://github.com/siyuan-note/siyuan/issues/8599)

View file

@ -3,7 +3,7 @@
[中文版](./README_zh_CN.md)
> Consistent with [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.1.8](https://github.com/siyuan-note/plugin-sample/tree/v0.1.8).
> Consistent with [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.1.10](https://github.com/siyuan-note/plugin-sample/tree/v0.1.10)

View file

@ -4,7 +4,7 @@
[English](./README.md)
> 本例和 [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.1.8](https://github.com/siyuan-note/plugin-sample/tree/v0.1.8)
> 本例和 [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.1.10](https://github.com/siyuan-note/plugin-sample/tree/v0.1.10)
1. 使用 vite 打包
2. 使用符号链接、而不是把项目放到插件目录下的模式进行开发

View file

@ -1,6 +1,6 @@
{
"name": "plugin-sample-vite-svelte",
"version": "0.1.8",
"version": "0.1.10",
"type": "module",
"description": "",
"repository": "",
@ -22,7 +22,7 @@
"minimist": "^1.2.8",
"rollup-plugin-livereload": "^2.0.5",
"sass": "^1.62.1",
"siyuan": "0.7.5",
"siyuan": "0.7.7",
"svelte": "^3.57.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",

View file

@ -93,7 +93,7 @@ if (targetDir === '') {
log('"targetDir" is empty, try to get SiYuan directory automatically....')
let res = await getSiYuanDir();
if (res === null) {
if (res === null || res === undefined || res.length === 0) {
log('Failed! You can set the plugin directory in scripts/make_dev_link.js and try again');
process.exit(1);
}

View file

@ -26,6 +26,7 @@ export default class PluginSample extends Plugin {
private customTab: () => IModel;
private isMobile: boolean;
private blockIconEventBindThis = this.blockIconEvent.bind(this);
async onload() {
this.data[STORAGE_NAME] = { readonlyText: "Readonly" };
@ -359,13 +360,13 @@ export default class PluginSample extends Plugin {
icon: "iconSelect",
label: "On click-blockicon",
click: () => {
this.eventBus.on("click-blockicon", this.blockIconEvent);
this.eventBus.on("click-blockicon", this.blockIconEventBindThis);
}
}, {
icon: "iconClose",
label: "Off click-blockicon",
click: () => {
this.eventBus.off("click-blockicon", this.blockIconEvent);
this.eventBus.off("click-blockicon", this.blockIconEventBindThis);
}
}, {
icon: "iconSelect",
@ -427,6 +428,102 @@ export default class PluginSample extends Plugin {
click: () => {
this.eventBus.off("loaded-protyle", this.eventBusLog);
}
}, {
icon: "iconSelect",
label: "On open-menu-blockref",
click: () => {
this.eventBus.on("open-menu-blockref", this.eventBusLog);
}
}, {
icon: "iconClose",
label: "Off open-menu-blockref",
click: () => {
this.eventBus.off("open-menu-blockref", this.eventBusLog);
}
}, {
icon: "iconSelect",
label: "On open-menu-fileannotationref",
click: () => {
this.eventBus.on("open-menu-fileannotationref", this.eventBusLog);
}
}, {
icon: "iconClose",
label: "Off open-menu-fileannotationref",
click: () => {
this.eventBus.off("open-menu-fileannotationref", this.eventBusLog);
}
}, {
icon: "iconSelect",
label: "On open-menu-tag",
click: () => {
this.eventBus.on("open-menu-tag", this.eventBusLog);
}
}, {
icon: "iconClose",
label: "Off open-menu-tag",
click: () => {
this.eventBus.off("open-menu-tag", this.eventBusLog);
}
}, {
icon: "iconSelect",
label: "On open-menu-link",
click: () => {
this.eventBus.on("open-menu-link", this.eventBusLog);
}
}, {
icon: "iconClose",
label: "Off open-menu-link",
click: () => {
this.eventBus.off("open-menu-link", this.eventBusLog);
}
}, {
icon: "iconSelect",
label: "On open-menu-image",
click: () => {
this.eventBus.on("open-menu-image", this.eventBusLog);
}
}, {
icon: "iconClose",
label: "Off open-menu-image",
click: () => {
this.eventBus.off("open-menu-image", this.eventBusLog);
}
}, {
icon: "iconSelect",
label: "On open-menu-av",
click: () => {
this.eventBus.on("open-menu-av", this.eventBusLog);
}
}, {
icon: "iconClose",
label: "Off open-menu-av",
click: () => {
this.eventBus.off("open-menu-av", this.eventBusLog);
}
}, {
icon: "iconSelect",
label: "On open-menu-content",
click: () => {
this.eventBus.on("open-menu-content", this.eventBusLog);
}
}, {
icon: "iconClose",
label: "Off open-menu-content",
click: () => {
this.eventBus.off("open-menu-content", this.eventBusLog);
}
}, {
icon: "iconSelect",
label: "On open-menu-breadcrumbmore",
click: () => {
this.eventBus.on("open-menu-breadcrumbmore", this.eventBusLog);
}
}, {
icon: "iconClose",
label: "Off open-menu-breadcrumbmore",
click: () => {
this.eventBus.off("open-menu-breadcrumbmore", this.eventBusLog);
}
}]
});
menu.addSeparator();