From 1735ec4bce08cd36bc7700417fdcd270ff852fe3 Mon Sep 17 00:00:00 2001 From: frostime Date: Sat, 13 Jan 2024 21:40:22 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20update=20to=20v0.3.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- README_zh_CN.md | 2 +- package.json | 4 +-- plugin.json | 4 +-- src/api.ts | 2 +- src/index.ts | 73 ++++++++++++++++++++++++++++++++++++++++++++++++- 6 files changed, 79 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4d2e0be..1f4ea7a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [中文版](./README_zh_CN.md) -> Consistent with [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.3.1](https://github.com/siyuan-note/plugin-sample/tree/v0.3.1) +> Consistent with [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.3.2](https://github.com/siyuan-note/plugin-sample/tree/v0.3.2) diff --git a/README_zh_CN.md b/README_zh_CN.md index 817c11e..a0f9538 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -4,7 +4,7 @@ [English](./README.md) -> 本例同 [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.3.1](https://github.com/siyuan-note/plugin-sample/tree/v0.3.1) +> 本例同 [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.3.2](https://github.com/siyuan-note/plugin-sample/tree/v0.3.2) 1. 使用 vite 打包 2. 使用符号链接、而不是把项目放到插件目录下的模式进行开发 diff --git a/package.json b/package.json index 7a6045b..ed76517 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plugin-sample-vite-svelte", - "version": "0.3.1", + "version": "0.3.2", "type": "module", "description": "This is a sample plugin based on vite and svelte for Siyuan (https://b3log.org/siyuan)", "repository": "", @@ -22,7 +22,7 @@ "minimist": "^1.2.8", "rollup-plugin-livereload": "^2.0.5", "sass": "^1.62.1", - "siyuan": "0.9.1", + "siyuan": "0.9.2", "svelte": "^3.57.0", "ts-node": "^10.9.1", "typescript": "^5.0.4", diff --git a/plugin.json b/plugin.json index 2385760..c9be70d 100644 --- a/plugin.json +++ b/plugin.json @@ -2,8 +2,8 @@ "name": "plugin-sample-vite-svelte", "author": "frostime", "url": "https://github.com/siyuan-note/plugin-sample-vite-svelte", - "version": "0.3.1", - "minAppVersion": "2.11.4", + "version": "0.3.2", + "minAppVersion": "2.12.1", "backends": [ "windows", "linux", diff --git a/src/api.ts b/src/api.ts index 95c2816..c227518 100644 --- a/src/api.ts +++ b/src/api.ts @@ -9,7 +9,7 @@ import { fetchSyncPost, IWebSocketData } from "siyuan"; -async function request(url: string, data: any) { +export async function request(url: string, data: any) { let response: IWebSocketData = await fetchSyncPost(url, data); let res = response.code === 0 ? response.data : null; return res; diff --git a/src/index.ts b/src/index.ts index d70da65..d434c5f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,10 @@ import { openWindow, IOperation, Constants, - openMobileFileById + openMobileFileById, + lockScreen, + ICard, + ICardData } from "siyuan"; import "@/index.scss"; @@ -227,6 +230,38 @@ export default class PluginSample extends Plugin { } }]; + this.protyleOptions = { + toolbar: ["block-ref", + "a", + "|", + "text", + "strong", + "em", + "u", + "s", + "mark", + "sup", + "sub", + "clear", + "|", + "code", + "kbd", + "tag", + "inline-math", + "inline-memo", + "|", + { + name: "insert-smail-emoji", + icon: "iconEmoji", + hotkey: "⇧⌘I", + tipPosition: "n", + tip: this.i18n.insertEmoji, + click(protyle: Protyle) { + protyle.insert("😊"); + } + }], + }; + console.log(this.i18n.helloPlugin); } @@ -263,6 +298,23 @@ export default class PluginSample extends Plugin { console.log("onunload"); } + uninstall() { + console.log("uninstall"); + } + + async updateCards(options: ICardData) { + options.cards.sort((a: ICard, b: ICard) => { + if (a.blockID < b.blockID) { + return -1; + } + if (a.blockID > b.blockID) { + return 1; + } + return 0; + }); + return options; + } + /** * A custom setting pannel provided by svelte */ @@ -447,6 +499,13 @@ export default class PluginSample extends Plugin { } }); } + menu.addItem({ + icon: "iconLock", + label: "Lockscreen", + click: () => { + lockScreen(this.app); + } + }); menu.addItem({ icon: "iconScrollHoriz", label: "Event Bus", @@ -679,6 +738,18 @@ export default class PluginSample extends Plugin { click: () => { this.eventBus.off("open-menu-breadcrumbmore", this.eventBusLog); } + }, { + icon: "iconSelect", + label: "On open-menu-inbox", + click: () => { + this.eventBus.on("open-menu-inbox", this.eventBusLog); + } + }, { + icon: "iconClose", + label: "Off open-menu-inbox", + click: () => { + this.eventBus.off("open-menu-inbox", this.eventBusLog); + } }, { icon: "iconSelect", label: "On input-search",