迁移聊天表单提交事件
This commit is contained in:
@@ -6,6 +6,7 @@ export { bindGlobalDialogControls } from "./chat-room/dialog.js";
|
|||||||
export { bindDailySignInControls } from "./chat-room/daily-sign-in.js";
|
export { bindDailySignInControls } from "./chat-room/daily-sign-in.js";
|
||||||
export { applyFontSize, bindChatFontSizeControl, CHAT_FONT_SIZE_STORAGE_KEY, restoreChatFontSize } from "./chat-room/font-size.js";
|
export { applyFontSize, bindChatFontSizeControl, CHAT_FONT_SIZE_STORAGE_KEY, restoreChatFontSize } from "./chat-room/font-size.js";
|
||||||
export { bindChatImageUploadControl } from "./chat-room/image-upload.js";
|
export { bindChatImageUploadControl } from "./chat-room/image-upload.js";
|
||||||
|
export { bindChatComposerControls } from "./chat-room/composer.js";
|
||||||
export { bindFriendPanelControls, closeFriendPanel, friendSearch, loadFriends, openFriendPanel, quickFriendAction } from "./chat-room/friend-panel.js";
|
export { bindFriendPanelControls, closeFriendPanel, friendSearch, loadFriends, openFriendPanel, quickFriendAction } from "./chat-room/friend-panel.js";
|
||||||
export { closeChatImageLightbox, initChatImageLightboxEvents, openChatImageLightbox } from "./chat-room/lightbox.js";
|
export { closeChatImageLightbox, initChatImageLightboxEvents, openChatImageLightbox } from "./chat-room/lightbox.js";
|
||||||
export {
|
export {
|
||||||
@@ -76,6 +77,7 @@ import { bindGlobalDialogControls } from "./chat-room/dialog.js";
|
|||||||
import { bindDailySignInControls } from "./chat-room/daily-sign-in.js";
|
import { bindDailySignInControls } from "./chat-room/daily-sign-in.js";
|
||||||
import { applyFontSize, bindChatFontSizeControl, CHAT_FONT_SIZE_STORAGE_KEY, restoreChatFontSize } from "./chat-room/font-size.js";
|
import { applyFontSize, bindChatFontSizeControl, CHAT_FONT_SIZE_STORAGE_KEY, restoreChatFontSize } from "./chat-room/font-size.js";
|
||||||
import { bindChatImageUploadControl } from "./chat-room/image-upload.js";
|
import { bindChatImageUploadControl } from "./chat-room/image-upload.js";
|
||||||
|
import { bindChatComposerControls } from "./chat-room/composer.js";
|
||||||
import { bindFriendPanelControls, closeFriendPanel, friendSearch, loadFriends, openFriendPanel, quickFriendAction } from "./chat-room/friend-panel.js";
|
import { bindFriendPanelControls, closeFriendPanel, friendSearch, loadFriends, openFriendPanel, quickFriendAction } from "./chat-room/friend-panel.js";
|
||||||
import { closeChatImageLightbox, initChatImageLightboxEvents, openChatImageLightbox } from "./chat-room/lightbox.js";
|
import { closeChatImageLightbox, initChatImageLightboxEvents, openChatImageLightbox } from "./chat-room/lightbox.js";
|
||||||
import {
|
import {
|
||||||
@@ -151,6 +153,7 @@ if (typeof window !== "undefined") {
|
|||||||
applyFontSize,
|
applyFontSize,
|
||||||
bindChatFontSizeControl,
|
bindChatFontSizeControl,
|
||||||
bindChatImageUploadControl,
|
bindChatImageUploadControl,
|
||||||
|
bindChatComposerControls,
|
||||||
bindFriendPanelControls,
|
bindFriendPanelControls,
|
||||||
closeFriendPanel,
|
closeFriendPanel,
|
||||||
friendSearch,
|
friendSearch,
|
||||||
@@ -253,6 +256,7 @@ if (typeof window !== "undefined") {
|
|||||||
bindDailySignInControls();
|
bindDailySignInControls();
|
||||||
bindChatFontSizeControl();
|
bindChatFontSizeControl();
|
||||||
bindChatImageUploadControl();
|
bindChatImageUploadControl();
|
||||||
|
bindChatComposerControls();
|
||||||
bindFriendPanelControls();
|
bindFriendPanelControls();
|
||||||
bindToolbarControls();
|
bindToolbarControls();
|
||||||
bindAdminMenuControls();
|
bindAdminMenuControls();
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// 聊天输入区事件绑定,逐步替代底部输入栏内联提交事件。
|
||||||
|
|
||||||
|
let chatComposerEventsBound = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定聊天表单提交事件。
|
||||||
|
* 发送主流程仍由 Blade 主脚本的 sendMessage 维护,这里只统一 submit 入口。
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
export function bindChatComposerControls() {
|
||||||
|
if (chatComposerEventsBound || typeof document === "undefined") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
chatComposerEventsBound = true;
|
||||||
|
document.addEventListener("submit", (event) => {
|
||||||
|
const form = event.target;
|
||||||
|
if (!(form instanceof HTMLFormElement) || !form.matches("[data-chat-form]")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
if (typeof window.sendMessage === "function") {
|
||||||
|
void window.sendMessage(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
<div class="input-bar">
|
<div class="input-bar">
|
||||||
<form id="chat-form" onsubmit="sendMessage(event)" enctype="multipart/form-data">
|
<form id="chat-form" data-chat-form enctype="multipart/form-data">
|
||||||
{{-- 第一行:工具选项 --}}
|
{{-- 第一行:工具选项 --}}
|
||||||
<div class="input-row">
|
<div class="input-row">
|
||||||
<label>对
|
<label>对
|
||||||
|
|||||||
Reference in New Issue
Block a user