Merge pull request #21 from siyuan-note/dev

Update
This commit is contained in:
Frostime 2023-09-16 16:25:54 +08:00 committed by GitHub
commit deb065668f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 73 additions and 15 deletions

View file

@ -1,4 +1,20 @@
## 0.2.0 # Changelog
## 0.2.3 2023-09-05
* [Plugin API add openWindow and command.globalCallback](https://github.com/siyuan-note/siyuan/issues/9032)
## 0.2.2 2023-08-29
* [Add plugin event bus `destroy-protyle`](https://github.com/siyuan-note/siyuan/issues/9033)
* [Add plugin event bus `loaded-protyle-dynamic`](https://github.com/siyuan-note/siyuan/issues/9021)
## 0.2.1 2023-08-21
* [Plugin API add getOpenedTab method](https://github.com/siyuan-note/siyuan/issues/9002)
* [Plugin API custom.fn => custom.id in openTab](https://github.com/siyuan-note/siyuan/issues/8944)
## 0.2.0 2023-08-15
* [Add plugin event bus `open-siyuan-url-plugin` and `open-siyuan-url-block`](https://github.com/siyuan-note/siyuan/pull/8927) * [Add plugin event bus `open-siyuan-url-plugin` and `open-siyuan-url-block`](https://github.com/siyuan-note/siyuan/pull/8927)

View file

@ -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.12](https://github.com/siyuan-note/plugin-sample/tree/v0.1.12) > Consistent with [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.2.3](https://github.com/siyuan-note/plugin-sample/tree/v0.2.3)

View file

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

View file

@ -1,6 +1,6 @@
{ {
"name": "plugin-sample-vite-svelte", "name": "plugin-sample-vite-svelte",
"version": "0.1.12", "version": "0.2.3",
"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.8.1", "siyuan": "0.8.3",
"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",

View file

@ -2,8 +2,8 @@
"name": "plugin-sample-vite-svelte", "name": "plugin-sample-vite-svelte",
"author": "frostime", "author": "frostime",
"url": "https://github.com/siyuan-note/plugin-sample-vite-svelte", "url": "https://github.com/siyuan-note/plugin-sample-vite-svelte",
"version": "0.1.12", "version": "0.2.3",
"minAppVersion": "2.9.0", "minAppVersion": "2.10.3",
"backends": ["all"], "backends": ["all"],
"frontends": ["all"], "frontends": ["all"],
"displayName": { "displayName": {

View file

@ -9,6 +9,7 @@
"removedData": "Data deleted", "removedData": "Data deleted",
"confirmRemove": "Confirm to delete the data in ${name}?", "confirmRemove": "Confirm to delete the data in ${name}?",
"insertEmoji": "Insert Emoji", "insertEmoji": "Insert Emoji",
"getTab": "Print out all opened custom tabs in the debugger",
"name": "SiYuan", "name": "SiYuan",
"hello": { "hello": {
"makesure": "Before using this template, please read the <a href=\"https://github.com/siyuan-note/plugin-sample\">offical sample</a>, make sure that you've known about the pipeline for plugin developing." "makesure": "Before using this template, please read the <a href=\"https://github.com/siyuan-note/plugin-sample\">offical sample</a>, make sure that you've known about the pipeline for plugin developing."

View file

@ -9,6 +9,7 @@
"removedData": "数据已删除", "removedData": "数据已删除",
"confirmRemove": "确认删除 ${name} 中的数据?", "confirmRemove": "确认删除 ${name} 中的数据?",
"insertEmoji": "插入表情", "insertEmoji": "插入表情",
"getTab": "在日志中打印出已打开的所有自定义页签",
"name": "思源", "name": "思源",
"hello": { "hello": {
"makesure": "使用这个模板之前,请阅读<a href=\"https://github.com/siyuan-note/plugin-sample\">官方教程</a>, 确保自己已经理解了插件的基本开发流程。" "makesure": "使用这个模板之前,请阅读<a href=\"https://github.com/siyuan-note/plugin-sample\">官方教程</a>, 确保自己已经理解了插件的基本开发流程。"

View file

@ -11,7 +11,7 @@ import {
IModel, IModel,
Setting, Setting,
fetchPost, fetchPost,
Protyle Protyle, openWindow
} from "siyuan"; } from "siyuan";
import "@/index.scss"; import "@/index.scss";
@ -105,7 +105,7 @@ export default class PluginSample extends Plugin {
this.addCommand({ this.addCommand({
langKey: "showDialog", langKey: "showDialog",
hotkey: "⇧⌘M", hotkey: "⇧⌘O",
callback: () => { callback: () => {
this.showDialog(); this.showDialog();
}, },
@ -119,6 +119,13 @@ export default class PluginSample extends Plugin {
console.log(element, "dockCallback"); console.log(element, "dockCallback");
}, },
}); });
this.addCommand({
langKey: "getTab",
hotkey: "⇧⌘M",
globalCallback: () => {
console.log(this.getOpenedTab());
},
});
this.addDock({ this.addDock({
config: { config: {
@ -267,7 +274,7 @@ export default class PluginSample extends Plugin {
}); });
if (!this.isMobile) { if (!this.isMobile) {
menu.addItem({ menu.addItem({
icon: "iconLayoutBottom", icon: "iconFace",
label: "Open Custom Tab", label: "Open Custom Tab",
click: () => { click: () => {
const tab = openTab({ const tab = openTab({
@ -278,14 +285,14 @@ export default class PluginSample extends Plugin {
data: { data: {
text: "This is my custom tab", text: "This is my custom tab",
}, },
fn: this.customTab id: this.name + TAB_TYPE
}, },
}); });
console.log(tab); console.log(tab);
} }
}); });
menu.addItem({ menu.addItem({
icon: "iconLayoutBottom", icon: "iconImage",
label: "Open Asset Tab(open help first)", label: "Open Asset Tab(open help first)",
click: () => { click: () => {
const tab = openTab({ const tab = openTab({
@ -298,7 +305,7 @@ export default class PluginSample extends Plugin {
} }
}); });
menu.addItem({ menu.addItem({
icon: "iconLayoutBottom", icon: "iconFile",
label: "Open Doc Tab(open help first)", label: "Open Doc Tab(open help first)",
click: async () => { click: async () => {
const tab = await openTab({ const tab = await openTab({
@ -311,7 +318,7 @@ export default class PluginSample extends Plugin {
} }
}); });
menu.addItem({ menu.addItem({
icon: "iconLayoutBottom", icon: "iconSearch",
label: "Open Search Tab", label: "Open Search Tab",
click: () => { click: () => {
const tab = openTab({ const tab = openTab({
@ -324,7 +331,7 @@ export default class PluginSample extends Plugin {
} }
}); });
menu.addItem({ menu.addItem({
icon: "iconLayoutBottom", icon: "iconRiffCard",
label: "Open Card Tab", label: "Open Card Tab",
click: () => { click: () => {
const tab = openTab({ const tab = openTab({
@ -348,6 +355,15 @@ export default class PluginSample extends Plugin {
}); });
} }
}); });
menu.addItem({
icon: "iconOpenWindow",
label: "Open Doc Window(open help first)",
click: () => {
openWindow({
doc: {id: "20200812220555-lj3enxa"}
});
}
});
} }
menu.addItem({ menu.addItem({
icon: "iconScrollHoriz", icon: "iconScrollHoriz",
@ -431,6 +447,30 @@ export default class PluginSample extends Plugin {
click: () => { click: () => {
this.eventBus.on("loaded-protyle", this.eventBusLog); this.eventBus.on("loaded-protyle", this.eventBusLog);
} }
}, {
icon: "iconSelect",
label: "On loaded-protyle-dynamic",
click: () => {
this.eventBus.on("loaded-protyle-dynamic", this.eventBusLog);
}
}, {
icon: "iconClose",
label: "Off loaded-protyle-dynamic",
click: () => {
this.eventBus.off("loaded-protyle-dynamic", this.eventBusLog);
}
}, {
icon: "iconSelect",
label: "On destroy-protyle",
click: () => {
this.eventBus.on("destroy-protyle", this.eventBusLog);
}
}, {
icon: "iconClose",
label: "Off destroy-protyle",
click: () => {
this.eventBus.off("destroy-protyle", this.eventBusLog);
}
}, { }, {
icon: "iconClose", icon: "iconClose",
label: "Off loaded-protyle", label: "Off loaded-protyle",