Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed May 16, 2023
1 parent 3d4b484 commit 0df4e28
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/index.ts
Expand Up @@ -10,7 +10,7 @@ export default class PluginSample extends Plugin {
private customTab: () => any;

onload() {
console.log(this.i18n.helloPlugin);
this.data[STORAGE_NAME] = {readonlyText: "Readonly"};

const topBarElement = this.addTopBar({
icon: "iconEmoji",
Expand Down Expand Up @@ -62,6 +62,7 @@ export default class PluginSample extends Plugin {
}
});

console.log(this.i18n.helloPlugin);
}

onunload() {
Expand All @@ -79,6 +80,7 @@ export default class PluginSample extends Plugin {
width: isMobile() ? "92vw" : "520px",
});
const inputElement = dialog.element.querySelector("textarea");
inputElement.value = this.data[STORAGE_NAME].readonlyText;
const btnsElement = dialog.element.querySelectorAll(".b3-button");
dialog.bindInput(inputElement, () => {
(btnsElement[1] as HTMLButtonElement).click();
Expand All @@ -88,7 +90,7 @@ export default class PluginSample extends Plugin {
dialog.destroy();
});
btnsElement[1].addEventListener("click", () => {
this.saveData(STORAGE_NAME, inputElement.value);
this.saveData(STORAGE_NAME, {readonlyText: inputElement.value});
dialog.destroy();
});
}
Expand All @@ -98,10 +100,6 @@ export default class PluginSample extends Plugin {
}

private async addMenu(rect: DOMRect) {
if (!this.data) {
await this.loadData(STORAGE_NAME);
}

const menu = new Menu("topBarSample", () => {
console.log(this.i18n.byeMenu);
});
Expand Down Expand Up @@ -154,7 +152,9 @@ export default class PluginSample extends Plugin {
icon: "iconTrashcan",
label: "Remove Data",
click: () => {
this.removeData(STORAGE_NAME);
this.removeData(STORAGE_NAME).then(() => {
this.data[STORAGE_NAME] = {readonlyText: "Readonly"};
});
}
});
menu.addItem({
Expand All @@ -174,7 +174,7 @@ export default class PluginSample extends Plugin {
menu.addSeparator();
menu.addItem({
icon: "iconSparkles",
label: this.data[STORAGE_NAME] || "Readonly",
label: this.data[STORAGE_NAME].readonlyText || "Readonly",
type: "readonly",
});
if (isMobile()) {
Expand Down

0 comments on commit 0df4e28

Please sign in to comment.