upgrade to v0.1.10
This commit is contained in:
parent
77e337b9f5
commit
38b8677c15
5 changed files with 118 additions and 12 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
|
||||
|
||||
* [Add protyleSlash to the plugin](https://github.com/siyuan-note/siyuan/issues/8599)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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. 使用符号链接、而不是把项目放到插件目录下的模式进行开发
|
||||
|
|
|
@ -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",
|
||||
|
|
113
src/index.ts
113
src/index.ts
|
@ -26,9 +26,10 @@ 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"};
|
||||
this.data[STORAGE_NAME] = { readonlyText: "Readonly" };
|
||||
|
||||
console.log("loading plugin-sample", this.i18n);
|
||||
|
||||
|
@ -72,7 +73,7 @@ export default class PluginSample extends Plugin {
|
|||
statusIconTemp.content.firstElementChild.addEventListener("click", () => {
|
||||
confirm("⚠️", this.i18n.confirmRemove.replace("${name}", this.name), () => {
|
||||
this.removeData(STORAGE_NAME).then(() => {
|
||||
this.data[STORAGE_NAME] = {readonlyText: "Readonly"};
|
||||
this.data[STORAGE_NAME] = { readonlyText: "Readonly" };
|
||||
showMessage(`[${this.name}]: ${this.i18n.removedData}`);
|
||||
});
|
||||
});
|
||||
|
@ -113,7 +114,7 @@ export default class PluginSample extends Plugin {
|
|||
this.addDock({
|
||||
config: {
|
||||
position: "LeftBottom",
|
||||
size: {width: 200, height: 0},
|
||||
size: { width: 200, height: 0 },
|
||||
icon: "iconSaving",
|
||||
title: "Custom Dock",
|
||||
},
|
||||
|
@ -144,7 +145,7 @@ export default class PluginSample extends Plugin {
|
|||
const textareaElement = document.createElement("textarea");
|
||||
this.setting = new Setting({
|
||||
confirmCallback: () => {
|
||||
this.saveData(STORAGE_NAME, {readonlyText: textareaElement.value});
|
||||
this.saveData(STORAGE_NAME, { readonlyText: textareaElement.value });
|
||||
}
|
||||
});
|
||||
this.setting.addItem({
|
||||
|
@ -210,11 +211,11 @@ export default class PluginSample extends Plugin {
|
|||
});
|
||||
}
|
||||
|
||||
private eventBusLog({detail}: any) {
|
||||
private eventBusLog({ detail }: any) {
|
||||
console.log(detail);
|
||||
}
|
||||
|
||||
private blockIconEvent({detail}: any) {
|
||||
private blockIconEvent({ detail }: any) {
|
||||
const ids: string[] = [];
|
||||
detail.blockElements.forEach((item: HTMLElement) => {
|
||||
ids.push(item.getAttribute("data-node-id"));
|
||||
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue