迁移全局弹窗键盘事件
This commit is contained in:
@@ -36,4 +36,22 @@ export function bindGlobalDialogControls() {
|
||||
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?.();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user