From 8b11d429dad08f7cc1786644dc686bfcfce1278e Mon Sep 17 00:00:00 2001 From: frostime Date: Sat, 3 Jun 2023 16:51:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E5=8A=9F=E8=83=BD=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 49 +++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/src/index.ts b/src/index.ts index ee7db52..8947cf8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,6 +27,8 @@ export default class PluginSample extends Plugin { async onload() { this.data[STORAGE_NAME] = {readonlyText: "Readonly"}; + console.log("loading plugin-sample", this.i18n); + const frontEnd = getFrontend(); this.isMobile = frontEnd === "mobile" || frontEnd === "browser-mobile"; // 图标的制作参见帮助文档 @@ -127,6 +129,7 @@ export default class PluginSample extends Plugin { } }); + console.log(this.i18n.helloPlugin); } onLayoutReady() { @@ -156,19 +159,16 @@ export default class PluginSample extends Plugin { }); } - private eventBusLog({ detail }: any) { + private eventBusLog({detail}: any) { console.log(detail); } - private blockIconEvent({ detail }: any) { - console.log(detail); - detail.menu.addSeparator(0); + private blockIconEvent({detail}: any) { const ids: string[] = []; detail.blockElements.forEach((item: HTMLElement) => { ids.push(item.getAttribute("data-node-id")); }); detail.menu.addItem({ - index: 1, iconHTML: "", type: "readonly", label: "IDs
" + ids.join("
"), @@ -176,10 +176,21 @@ export default class PluginSample extends Plugin { } private showDialog() { - new Dialog({ - title: "Info", - content: '
This is a dialog
', - width: this.isMobile ? "92vw" : "520px", + let dialog = new Dialog({ + title: "Hello World", + content: `
`, + width: this.isMobile ? "92vw" : "720px", + destroyCallback(options) { + //Destroy the component when the dialog is closed + // hello.$destroy(); + }, + }); + let hello = new HelloExample({ + target: dialog.element.querySelector("#helloPanel"), + props: { + name: this.i18n.name, + i18n: this.i18n.hello + } }); } @@ -191,7 +202,7 @@ export default class PluginSample extends Plugin { icon: "iconInfo", label: "Dialog", accelerator: this.commands[0].customHotkey, - click: this.showDialog + click: () => this.showDialog() }); if (!this.isMobile) { menu.addItem({ @@ -371,22 +382,4 @@ export default class PluginSample extends Plugin { }); } } - - private openHelloInDialog() { - let dialog = new Dialog({ - title: "Hello World", - content: `
`, - destroyCallback(options) { - //You must destroy the component when the dialog is closed - hello.$destroy(); - }, - }); - let hello = new HelloExample({ - target: dialog.element.querySelector("#helloPanel"), - props: { - name: this.i18n.name, - i18n: this.i18n.hello - } - }); - } }