Skip to content

Commit

Permalink
Merge pull request #21 from siyuan-note/dev
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
frostime authored Sep 16, 2023
2 parents f114305 + 06f598b commit deb0656
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 15 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[中文版](./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)


Expand Down
2 changes: 1 addition & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[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 打包
2. 使用符号链接、而不是把项目放到插件目录下的模式进行开发
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plugin-sample-vite-svelte",
"version": "0.1.12",
"version": "0.2.3",
"type": "module",
"description": "",
"repository": "",
Expand All @@ -22,7 +22,7 @@
"minimist": "^1.2.8",
"rollup-plugin-livereload": "^2.0.5",
"sass": "^1.62.1",
"siyuan": "0.8.1",
"siyuan": "0.8.3",
"svelte": "^3.57.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
Expand Down
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "plugin-sample-vite-svelte",
"author": "frostime",
"url": "https://github.com/siyuan-note/plugin-sample-vite-svelte",
"version": "0.1.12",
"minAppVersion": "2.9.0",
"version": "0.2.3",
"minAppVersion": "2.10.3",
"backends": ["all"],
"frontends": ["all"],
"displayName": {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"removedData": "Data deleted",
"confirmRemove": "Confirm to delete the data in ${name}?",
"insertEmoji": "Insert Emoji",
"getTab": "Print out all opened custom tabs in the debugger",
"name": "SiYuan",
"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."
Expand Down
1 change: 1 addition & 0 deletions src/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"removedData": "数据已删除",
"confirmRemove": "确认删除 ${name} 中的数据?",
"insertEmoji": "插入表情",
"getTab": "在日志中打印出已打开的所有自定义页签",
"name": "思源",
"hello": {
"makesure": "使用这个模板之前,请阅读<a href=\"https://github.com/siyuan-note/plugin-sample\">官方教程</a>, 确保自己已经理解了插件的基本开发流程。"
Expand Down
56 changes: 48 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
IModel,
Setting,
fetchPost,
Protyle
Protyle, openWindow
} from "siyuan";
import "@/index.scss";

Expand Down Expand Up @@ -105,7 +105,7 @@ export default class PluginSample extends Plugin {

this.addCommand({
langKey: "showDialog",
hotkey: "⇧⌘M",
hotkey: "⇧⌘O",
callback: () => {
this.showDialog();
},
Expand All @@ -119,6 +119,13 @@ export default class PluginSample extends Plugin {
console.log(element, "dockCallback");
},
});
this.addCommand({
langKey: "getTab",
hotkey: "⇧⌘M",
globalCallback: () => {
console.log(this.getOpenedTab());
},
});

this.addDock({
config: {
Expand Down Expand Up @@ -267,7 +274,7 @@ export default class PluginSample extends Plugin {
});
if (!this.isMobile) {
menu.addItem({
icon: "iconLayoutBottom",
icon: "iconFace",
label: "Open Custom Tab",
click: () => {
const tab = openTab({
Expand All @@ -278,14 +285,14 @@ export default class PluginSample extends Plugin {
data: {
text: "This is my custom tab",
},
fn: this.customTab
id: this.name + TAB_TYPE
},
});
console.log(tab);
}
});
menu.addItem({
icon: "iconLayoutBottom",
icon: "iconImage",
label: "Open Asset Tab(open help first)",
click: () => {
const tab = openTab({
Expand All @@ -298,7 +305,7 @@ export default class PluginSample extends Plugin {
}
});
menu.addItem({
icon: "iconLayoutBottom",
icon: "iconFile",
label: "Open Doc Tab(open help first)",
click: async () => {
const tab = await openTab({
Expand All @@ -311,7 +318,7 @@ export default class PluginSample extends Plugin {
}
});
menu.addItem({
icon: "iconLayoutBottom",
icon: "iconSearch",
label: "Open Search Tab",
click: () => {
const tab = openTab({
Expand All @@ -324,7 +331,7 @@ export default class PluginSample extends Plugin {
}
});
menu.addItem({
icon: "iconLayoutBottom",
icon: "iconRiffCard",
label: "Open Card Tab",
click: () => {
const tab = openTab({
Expand All @@ -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({
icon: "iconScrollHoriz",
Expand Down Expand Up @@ -431,6 +447,30 @@ export default class PluginSample extends Plugin {
click: () => {
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",
label: "Off loaded-protyle",
Expand Down

0 comments on commit deb0656

Please sign in to comment.