diff --git a/src/components/editor/MentionEditor.tsx b/src/components/editor/MentionEditor.tsx index f597ba7..7fadd8a 100644 --- a/src/components/editor/MentionEditor.tsx +++ b/src/components/editor/MentionEditor.tsx @@ -667,6 +667,9 @@ export const MentionEditor = forwardRef< // Build extensions array const extensions = useMemo(() => { + // Detect mobile devices (touch support) + const isMobile = "ontouchstart" in window || navigator.maxTouchPoints > 0; + // Custom extension for keyboard shortcuts (runs before suggestion plugins) const SubmitShortcut = Extension.create({ name: "submitShortcut", @@ -677,10 +680,16 @@ export const MentionEditor = forwardRef< handleSubmitRef.current(editor); return true; }, - // Plain Enter submits (Shift+Enter handled by hardBreak for newlines) + // Plain Enter behavior depends on device Enter: ({ editor }) => { - handleSubmitRef.current(editor); - return true; + if (isMobile) { + // On mobile, Enter inserts a newline (hardBreak) + return editor.commands.setHardBreak(); + } else { + // On desktop, Enter submits the message + handleSubmitRef.current(editor); + return true; + } }, }; },