mirror of
https://github.com/felvesthe/Note-Locker.git
synced 2026-07-22 05:44:06 +00:00
* https://github.com/Felvesthe/Note-Locker/issues/6 Signed-off-by: Felvesthe <23108389+Felvesthe@users.noreply.github.com>
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { Modal, App, Setting } from "obsidian";
|
|
|
|
export class StrictUnlockModal extends Modal {
|
|
private onUnlock: () => void;
|
|
private title: string;
|
|
private message: string;
|
|
|
|
constructor(
|
|
app: App,
|
|
onUnlock: () => void,
|
|
title: string = "Strictly Locked Note",
|
|
message: string = "This note is strictly locked to prevent accidental editing.") {
|
|
super(app);
|
|
this.onUnlock = onUnlock;
|
|
this.title = title;
|
|
this.message = message;
|
|
}
|
|
|
|
onOpen() {
|
|
const { contentEl } = this;
|
|
contentEl.empty();
|
|
|
|
contentEl.createEl("h2", { text: this.title });
|
|
contentEl.createEl("p", { text: this.message });
|
|
contentEl.createEl("p", { text: "Are you sure you want to unlock?" });
|
|
|
|
new Setting(contentEl)
|
|
.addButton((btn) =>
|
|
btn
|
|
.setButtonText("Unlock")
|
|
.setCta()
|
|
.onClick(() => {
|
|
this.onUnlock();
|
|
this.close();
|
|
})
|
|
)
|
|
.addButton((btn) =>
|
|
btn
|
|
.setButtonText("Cancel")
|
|
.onClick(() => {
|
|
this.close();
|
|
})
|
|
);
|
|
}
|
|
|
|
onClose() {
|
|
const { contentEl } = this;
|
|
contentEl.empty();
|
|
}
|
|
}
|