mirror of
https://github.com/siyuan-note/plugin-sample-vite-svelte.git
synced 2025-08-01 16:13:30 +00:00
feat: svelte example for setting pannel
This commit is contained in:
parent
18fc66f0f6
commit
925d5c5aac
5 changed files with 195 additions and 38 deletions
44
src/index.ts
44
src/index.ts
|
@ -2,9 +2,10 @@
|
|||
* Copyright (c) 2023 frostime. All rights reserved.
|
||||
* https://github.com/frostime/sy-plugin-template-vite
|
||||
*/
|
||||
import { Plugin, showMessage, Dialog } from "siyuan"
|
||||
import Hello from "./hello.svelte"
|
||||
import "./index.scss"
|
||||
import { Plugin, showMessage, Dialog } from "siyuan";
|
||||
import Hello from "./hello.svelte";
|
||||
import SettingPannel from "./libs/setting-panel.svelte";
|
||||
import "./index.scss";
|
||||
|
||||
export default class SamplePlugin extends Plugin {
|
||||
|
||||
|
@ -15,22 +16,35 @@ export default class SamplePlugin extends Plugin {
|
|||
{
|
||||
icon: "iconEmoji",
|
||||
"title": "Hello SiYuan",
|
||||
"callback": () => {
|
||||
let dialog = new Dialog({
|
||||
title: "Hello World",
|
||||
content: `<div id="helloPanel"></div>`,
|
||||
});
|
||||
new Hello({
|
||||
target: dialog.element.querySelector("#helloPanel"),
|
||||
props: {
|
||||
name: this.i18n.name,
|
||||
}
|
||||
});
|
||||
}
|
||||
"callback": () => this.openHelloDialog()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
openSetting(): void {
|
||||
let dialog = new Dialog({
|
||||
title: "SettingPannel",
|
||||
content: `<div id="SettingPanel"></div>`,
|
||||
width: "600px"
|
||||
});
|
||||
new SettingPannel({
|
||||
target: dialog.element.querySelector("#SettingPanel"),
|
||||
});
|
||||
}
|
||||
|
||||
private openHelloDialog() {
|
||||
let dialog = new Dialog({
|
||||
title: "Hello World",
|
||||
content: `<div id="helloPanel"></div>`,
|
||||
});
|
||||
new Hello({
|
||||
target: dialog.element.querySelector("#helloPanel"),
|
||||
props: {
|
||||
name: this.i18n.name,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async onunload() {
|
||||
showMessage("Goodbye World");
|
||||
console.log("onunload");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue