|
@@ -35,7 +35,7 @@ export class Dialog {
|
|
|
this.element.innerHTML = `<div class="b3-dialog" style="z-index: ${++window.siyuan.zIndex};">
|
|
|
<div class="b3-dialog__scrim"${options.transparent ? 'style="background-color:transparent"' : ""}></div>
|
|
|
<div class="b3-dialog__container" style="width:${options.width || "auto"};height:${options.height || "auto"}">
|
|
|
- <svg ${(isMobile() && options.title) ? 'style="top:0;right:0;"' : ""} class="b3-dialog__close${(this.disableClose||options.hideCloseIcon) ? " fn__none" : ""}"><use xlink:href="#iconCloseRound"></use></svg>
|
|
|
+ <svg ${(isMobile() && options.title) ? 'style="top:0;right:0;"' : ""} class="b3-dialog__close${(this.disableClose || options.hideCloseIcon) ? " fn__none" : ""}"><use xlink:href="#iconCloseRound"></use></svg>
|
|
|
<div class="resize__move b3-dialog__header${options.title ? "" : " fn__none"}" onselectstart="return false;">${options.title || ""}</div>
|
|
|
<div class="b3-dialog__body">${options.content}</div>
|
|
|
<div class="resize__rd"></div><div class="resize__ld"></div><div class="resize__lt"></div><div class="resize__rt"></div><div class="resize__r"></div><div class="resize__d"></div><div class="resize__t"></div><div class="resize__l"></div>
|
|
@@ -86,30 +86,21 @@ export class Dialog {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- public bindInput(inputElement: HTMLInputElement | HTMLTextAreaElement, enterEvent?: () => void) {
|
|
|
+ public bindInput(inputElement: HTMLInputElement | HTMLTextAreaElement, enterEvent?: () => void, bindEnter = true) {
|
|
|
inputElement.focus();
|
|
|
inputElement.addEventListener("keydown", (event: KeyboardEvent) => {
|
|
|
if (event.isComposing) {
|
|
|
event.preventDefault();
|
|
|
return;
|
|
|
}
|
|
|
- const confirmElement = document.querySelector("#confirmDialogConfirmBtn");
|
|
|
if (event.key === "Escape") {
|
|
|
- if (confirmElement) {
|
|
|
- confirmElement.previousElementSibling.previousElementSibling.dispatchEvent(new CustomEvent("click"));
|
|
|
- } else {
|
|
|
- this.destroy();
|
|
|
- }
|
|
|
+ this.destroy();
|
|
|
event.preventDefault();
|
|
|
event.stopPropagation();
|
|
|
return;
|
|
|
}
|
|
|
- if (!event.shiftKey && isNotCtrl(event) && event.key === "Enter" && enterEvent) {
|
|
|
- if (confirmElement) {
|
|
|
- confirmElement.dispatchEvent(new CustomEvent("click"));
|
|
|
- } else {
|
|
|
- enterEvent();
|
|
|
- }
|
|
|
+ if (!event.shiftKey && isNotCtrl(event) && event.key === "Enter" && enterEvent && bindEnter) {
|
|
|
+ enterEvent();
|
|
|
event.preventDefault();
|
|
|
event.stopPropagation();
|
|
|
}
|