mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-23 23:44:06 +01:00
This commit is contained in:
parent
e200bc61d9
commit
bb0ddc4147
4 changed files with 37 additions and 24 deletions
|
|
@ -16,23 +16,31 @@ export const confirmDialog = (title: string, text: string,
|
|||
<div class="ft__breakword">${text}</div>
|
||||
</div>
|
||||
<div class="b3-dialog__action">
|
||||
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
||||
<button class="b3-button b3-button--cancel" id="cancelDialogConfirmBtn">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
||||
<button class="b3-button ${isDelete ? "b3-button--remove" : "b3-button--text"}" id="confirmDialogConfirmBtn">${window.siyuan.languages[isDelete ? "delete" : "confirm"]}</button>
|
||||
</div>`,
|
||||
width: isMobile() ? "92vw" : "520px",
|
||||
});
|
||||
const btnsElement = dialog.element.querySelectorAll(".b3-button");
|
||||
btnsElement[0].addEventListener("click", () => {
|
||||
if (cancel) {
|
||||
cancel(dialog);
|
||||
|
||||
dialog.element.addEventListener("click", (event) => {
|
||||
let target = event.target as HTMLElement;
|
||||
const isDispatch = typeof event.detail === "string";
|
||||
while (target && !target.isSameNode(dialog.element) || isDispatch) {
|
||||
if (target.id === "cancelDialogConfirmBtn" || (isDispatch && event.detail=== "Escape")) {
|
||||
if (cancel) {
|
||||
cancel(dialog);
|
||||
}
|
||||
dialog.destroy();
|
||||
break;
|
||||
} else if (target.id === "confirmDialogConfirmBtn" || (isDispatch && event.detail=== "Enter")) {
|
||||
if (confirm) {
|
||||
confirm(dialog);
|
||||
}
|
||||
dialog.destroy();
|
||||
break;
|
||||
}
|
||||
target = target.parentElement;
|
||||
}
|
||||
dialog.destroy();
|
||||
});
|
||||
btnsElement[1].addEventListener("click", () => {
|
||||
if (confirm) {
|
||||
confirm(dialog);
|
||||
}
|
||||
dialog.destroy();
|
||||
});
|
||||
dialog.element.setAttribute("data-key", Constants.DIALOG_CONFIRM);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue