迁移全局弹窗键盘事件
This commit is contained in:
@@ -36,4 +36,22 @@ export function bindGlobalDialogControls() {
|
|||||||
window.chatDialog?._cancel?.();
|
window.chatDialog?._cancel?.();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.addEventListener("keydown", (event) => {
|
||||||
|
if (!(event.target instanceof HTMLTextAreaElement) || event.target.id !== "global-dialog-input") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prompt 输入框沿用旧体验:Enter 确认,Shift+Enter 保留换行,Esc 取消。
|
||||||
|
if (event.key === "Enter" && !event.shiftKey) {
|
||||||
|
event.preventDefault();
|
||||||
|
window.chatDialog?._confirm?.();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
event.preventDefault();
|
||||||
|
window.chatDialog?._cancel?.();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,15 +220,4 @@
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// prompt 模式支持按 Enter 确认、Esc 取消
|
|
||||||
document.getElementById('global-dialog-input').addEventListener('keydown', function(e) {
|
|
||||||
if (e.key === 'Enter' && !e.shiftKey) {
|
|
||||||
e.preventDefault();
|
|
||||||
window.chatDialog._confirm();
|
|
||||||
} else if (e.key === 'Escape') {
|
|
||||||
e.preventDefault();
|
|
||||||
window.chatDialog._cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user