commit
e6f5580c26
6 changed files with 119 additions and 13 deletions
|
@ -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
|
## 0.1.8
|
||||||
|
|
||||||
* [Add protyleSlash to the plugin](https://github.com/siyuan-note/siyuan/issues/8599)
|
* [Add protyleSlash to the plugin](https://github.com/siyuan-note/siyuan/issues/8599)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
[中文版](./README_zh_CN.md)
|
[中文版](./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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
[English](./README.md)
|
[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 打包
|
1. 使用 vite 打包
|
||||||
2. 使用符号链接、而不是把项目放到插件目录下的模式进行开发
|
2. 使用符号链接、而不是把项目放到插件目录下的模式进行开发
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "plugin-sample-vite-svelte",
|
"name": "plugin-sample-vite-svelte",
|
||||||
"version": "0.1.8",
|
"version": "0.1.10",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "",
|
"description": "",
|
||||||
"repository": "",
|
"repository": "",
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
"minimist": "^1.2.8",
|
"minimist": "^1.2.8",
|
||||||
"rollup-plugin-livereload": "^2.0.5",
|
"rollup-plugin-livereload": "^2.0.5",
|
||||||
"sass": "^1.62.1",
|
"sass": "^1.62.1",
|
||||||
"siyuan": "0.7.5",
|
"siyuan": "0.7.7",
|
||||||
"svelte": "^3.57.0",
|
"svelte": "^3.57.0",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "^5.0.4",
|
"typescript": "^5.0.4",
|
||||||
|
|
|
@ -93,7 +93,7 @@ if (targetDir === '') {
|
||||||
log('"targetDir" is empty, try to get SiYuan directory automatically....')
|
log('"targetDir" is empty, try to get SiYuan directory automatically....')
|
||||||
let res = await getSiYuanDir();
|
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');
|
log('Failed! You can set the plugin directory in scripts/make_dev_link.js and try again');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
101
src/index.ts
101
src/index.ts
|
@ -26,6 +26,7 @@ export default class PluginSample extends Plugin {
|
||||||
|
|
||||||
private customTab: () => IModel;
|
private customTab: () => IModel;
|
||||||
private isMobile: boolean;
|
private isMobile: boolean;
|
||||||
|
private blockIconEventBindThis = this.blockIconEvent.bind(this);
|
||||||
|
|
||||||
async onload() {
|
async onload() {
|
||||||
this.data[STORAGE_NAME] = { readonlyText: "Readonly" };
|
this.data[STORAGE_NAME] = { readonlyText: "Readonly" };
|
||||||
|
@ -359,13 +360,13 @@ export default class PluginSample extends Plugin {
|
||||||
icon: "iconSelect",
|
icon: "iconSelect",
|
||||||
label: "On click-blockicon",
|
label: "On click-blockicon",
|
||||||
click: () => {
|
click: () => {
|
||||||
this.eventBus.on("click-blockicon", this.blockIconEvent);
|
this.eventBus.on("click-blockicon", this.blockIconEventBindThis);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
icon: "iconClose",
|
icon: "iconClose",
|
||||||
label: "Off click-blockicon",
|
label: "Off click-blockicon",
|
||||||
click: () => {
|
click: () => {
|
||||||
this.eventBus.off("click-blockicon", this.blockIconEvent);
|
this.eventBus.off("click-blockicon", this.blockIconEventBindThis);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
icon: "iconSelect",
|
icon: "iconSelect",
|
||||||
|
@ -427,6 +428,102 @@ export default class PluginSample extends Plugin {
|
||||||
click: () => {
|
click: () => {
|
||||||
this.eventBus.off("loaded-protyle", this.eventBusLog);
|
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();
|
menu.addSeparator();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue