基本功能保持一致
This commit is contained in:
parent
9f8f1fb69e
commit
8b11d429da
1 changed files with 21 additions and 28 deletions
45
src/index.ts
45
src/index.ts
|
@ -27,6 +27,8 @@ export default class PluginSample extends Plugin {
|
||||||
async onload() {
|
async onload() {
|
||||||
this.data[STORAGE_NAME] = {readonlyText: "Readonly"};
|
this.data[STORAGE_NAME] = {readonlyText: "Readonly"};
|
||||||
|
|
||||||
|
console.log("loading plugin-sample", this.i18n);
|
||||||
|
|
||||||
const frontEnd = getFrontend();
|
const frontEnd = getFrontend();
|
||||||
this.isMobile = frontEnd === "mobile" || frontEnd === "browser-mobile";
|
this.isMobile = frontEnd === "mobile" || frontEnd === "browser-mobile";
|
||||||
// 图标的制作参见帮助文档
|
// 图标的制作参见帮助文档
|
||||||
|
@ -127,6 +129,7 @@ export default class PluginSample extends Plugin {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(this.i18n.helloPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
onLayoutReady() {
|
onLayoutReady() {
|
||||||
|
@ -161,14 +164,11 @@ export default class PluginSample extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private blockIconEvent({detail}: any) {
|
private blockIconEvent({detail}: any) {
|
||||||
console.log(detail);
|
|
||||||
detail.menu.addSeparator(0);
|
|
||||||
const ids: string[] = [];
|
const ids: string[] = [];
|
||||||
detail.blockElements.forEach((item: HTMLElement) => {
|
detail.blockElements.forEach((item: HTMLElement) => {
|
||||||
ids.push(item.getAttribute("data-node-id"));
|
ids.push(item.getAttribute("data-node-id"));
|
||||||
});
|
});
|
||||||
detail.menu.addItem({
|
detail.menu.addItem({
|
||||||
index: 1,
|
|
||||||
iconHTML: "",
|
iconHTML: "",
|
||||||
type: "readonly",
|
type: "readonly",
|
||||||
label: "IDs<br>" + ids.join("<br>"),
|
label: "IDs<br>" + ids.join("<br>"),
|
||||||
|
@ -176,10 +176,21 @@ export default class PluginSample extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private showDialog() {
|
private showDialog() {
|
||||||
new Dialog({
|
let dialog = new Dialog({
|
||||||
title: "Info",
|
title: "Hello World",
|
||||||
content: '<div class="b3-dialog__content">This is a dialog</div>',
|
content: `<div id="helloPanel" class="b3-dialog__content"></div>`,
|
||||||
width: this.isMobile ? "92vw" : "520px",
|
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",
|
icon: "iconInfo",
|
||||||
label: "Dialog",
|
label: "Dialog",
|
||||||
accelerator: this.commands[0].customHotkey,
|
accelerator: this.commands[0].customHotkey,
|
||||||
click: this.showDialog
|
click: () => this.showDialog()
|
||||||
});
|
});
|
||||||
if (!this.isMobile) {
|
if (!this.isMobile) {
|
||||||
menu.addItem({
|
menu.addItem({
|
||||||
|
@ -371,22 +382,4 @@ export default class PluginSample extends Plugin {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private openHelloInDialog() {
|
|
||||||
let dialog = new Dialog({
|
|
||||||
title: "Hello World",
|
|
||||||
content: `<div id="helloPanel"></div>`,
|
|
||||||
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
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue