Enhances plugin architecture and fixes issues #1
+4
-1
@@ -254,7 +254,7 @@ class ConfirmModal {
|
|||||||
private title: string;
|
private title: string;
|
||||||
private message: string;
|
private message: string;
|
||||||
private callback: (result: boolean) => void;
|
private callback: (result: boolean) => void;
|
||||||
private modalEl: HTMLElement;
|
private modalEl: HTMLElement | null = null;
|
||||||
|
|
||||||
constructor(app: App, title: string, message: string, callback: (result: boolean) => void) {
|
constructor(app: App, title: string, message: string, callback: (result: boolean) => void) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
@@ -284,7 +284,9 @@ class ConfirmModal {
|
|||||||
const confirmButton = buttons.createEl('button', { text: 'Confirm', cls: 'mod-warning' });
|
const confirmButton = buttons.createEl('button', { text: 'Confirm', cls: 'mod-warning' });
|
||||||
confirmButton.onclick = () => this.close(true);
|
confirmButton.onclick = () => this.close(true);
|
||||||
|
|
||||||
|
if (this.modalEl) {
|
||||||
document.body.appendChild(this.modalEl);
|
document.body.appendChild(this.modalEl);
|
||||||
|
}
|
||||||
confirmButton.focus();
|
confirmButton.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,6 +294,7 @@ class ConfirmModal {
|
|||||||
if (this.modalEl && this.modalEl.parentNode) {
|
if (this.modalEl && this.modalEl.parentNode) {
|
||||||
this.modalEl.parentNode.removeChild(this.modalEl);
|
this.modalEl.parentNode.removeChild(this.modalEl);
|
||||||
}
|
}
|
||||||
|
this.modalEl = null;
|
||||||
this.callback(result);
|
this.callback(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user