@@ -33,6 +33,7 @@ import { Persist, persisted } from "@/utils/persist"
3333import { usePermission } from "@/context/permission"
3434import { useLanguage } from "@/context/language"
3535import { usePlatform } from "@/context/platform"
36+ import { useSettings } from "@/context/settings"
3637import { useSessionLayout } from "@/pages/session/session-layout"
3738import { createSessionTabs } from "@/pages/session/helpers"
3839import { createTextFragment , getCursorPosition , setCursorPosition , setRangeEdge } from "./prompt-input/editor-dom"
@@ -117,6 +118,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
117118 const permission = usePermission ( )
118119 const language = useLanguage ( )
119120 const platform = usePlatform ( )
121+ const settings = useSettings ( )
120122 const { params, tabs, view } = useSessionLayout ( )
121123 let editorRef ! : HTMLDivElement
122124 let fileInputRef : HTMLInputElement | undefined
@@ -1229,22 +1231,47 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
12291231 }
12301232
12311233 // Note: Shift+Enter is handled earlier, before IME check
1232- if ( event . key === "Enter" && ! event . shiftKey ) {
1233- event . preventDefault ( )
1234- if ( event . repeat ) return
1235- if (
1236- working ( ) &&
1237- prompt
1238- . current ( )
1239- . map ( ( part ) => ( "content" in part ? part . content : "" ) )
1240- . join ( "" )
1241- . trim ( ) . length === 0 &&
1242- imageAttachments ( ) . length === 0 &&
1243- commentCount ( ) === 0
1244- ) {
1245- return
1234+ const modEnter = event . ctrlKey || event . metaKey
1235+ const sendWithModEnter = settings . general . sendWithModEnter ( )
1236+ if ( event . key === "Enter" ) {
1237+ if ( sendWithModEnter ) {
1238+ if ( modEnter && ! event . shiftKey ) {
1239+ event . preventDefault ( )
1240+ if ( event . repeat ) return
1241+ if (
1242+ working ( ) &&
1243+ prompt
1244+ . current ( )
1245+ . map ( ( part ) => ( "content" in part ? part . content : "" ) )
1246+ . join ( "" )
1247+ . trim ( ) . length === 0 &&
1248+ imageAttachments ( ) . length === 0 &&
1249+ commentCount ( ) === 0
1250+ ) {
1251+ return
1252+ }
1253+ void handleSubmit ( event )
1254+ } else if ( ! modEnter && ! event . shiftKey ) {
1255+ addPart ( { type : "text" , content : "\n" , start : 0 , end : 0 } )
1256+ event . preventDefault ( )
1257+ }
1258+ } else if ( ! event . shiftKey ) {
1259+ event . preventDefault ( )
1260+ if ( event . repeat ) return
1261+ if (
1262+ working ( ) &&
1263+ prompt
1264+ . current ( )
1265+ . map ( ( part ) => ( "content" in part ? part . content : "" ) )
1266+ . join ( "" )
1267+ . trim ( ) . length === 0 &&
1268+ imageAttachments ( ) . length === 0 &&
1269+ commentCount ( ) === 0
1270+ ) {
1271+ return
1272+ }
1273+ void handleSubmit ( event )
12461274 }
1247- void handleSubmit ( event )
12481275 }
12491276 }
12501277
0 commit comments