From c66b26097b518b08f52d6c93ebc27d8122135cb4 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 30 Aug 2023 21:57:59 +0800 Subject: [PATCH] :sparkles: https://github.com/siyuan-note/siyuan/issues/9032 --- CHANGELOG.md | 2 ++ src/i18n/en_US.json | 1 + src/i18n/zh_CN.json | 1 + src/index.ts | 17 ++++++++--------- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06f5a4a..4da04c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.2.3 2023-08 +* [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) diff --git a/src/i18n/en_US.json b/src/i18n/en_US.json index 7807833..ec2ab65 100644 --- a/src/i18n/en_US.json +++ b/src/i18n/en_US.json @@ -6,6 +6,7 @@ "helloPlugin": "Hello, Plugin!", "byePlugin": "Bye, Plugin!", "showDialog": "Show dialog", + "showMessage": "Show message", "removedData": "Data deleted", "confirmRemove": "Confirm to delete the data in ${name}?", "insertEmoji": "Insert Emoji" diff --git a/src/i18n/zh_CN.json b/src/i18n/zh_CN.json index e288d69..16fb203 100644 --- a/src/i18n/zh_CN.json +++ b/src/i18n/zh_CN.json @@ -6,6 +6,7 @@ "helloPlugin": "你好,插件!", "byePlugin": "再见,插件!", "showDialog": "弹出一个对话框", + "showMessage": "弹出一个消息", "removedData": "数据已删除", "confirmRemove": "确认删除 ${name} 中的数据?", "insertEmoji": "插入表情" diff --git a/src/index.ts b/src/index.ts index bfcec42..ad986b0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -93,18 +93,17 @@ export default class PluginSample extends Plugin { this.addCommand({ langKey: "showDialog", - hotkey: "⇧⌘M", + hotkey: "⇧⌘O", callback: () => { this.showDialog(); }, - fileTreeCallback: (file: any) => { - console.log(file, "fileTreeCallback"); - }, - editorCallback: (protyle: any) => { - console.log(protyle, "editorCallback"); - }, - dockCallback: (element: HTMLElement) => { - console.log(element, "dockCallback"); + }); + + this.addCommand({ + langKey: "showMessage", + hotkey: "⇧⌘M", + globalCallback: () => { + showMessage("👋 I'm from global command"); }, });