@@ -12,12 +12,13 @@ import type {
1212// @ts-ignore
1313import { Picker , EmojiIndex } from " emoji-mart-vue-fast/src" ;
1414import " emoji-mart-vue-fast/css/emoji-mart.css" ;
15- import { inject , ref , watchEffect , type Ref } from " vue" ;
15+ import { inject , ref , type Ref } from " vue" ;
1616import { apiClient } from " @/utils/api-client" ;
17- import { useLocalStorage , useMagicKeys } from " @vueuse/core" ;
17+ import { useLocalStorage } from " @vueuse/core" ;
1818import axios from " axios" ;
1919import { onClickOutside } from " @vueuse/core" ;
2020import autosize from " autosize" ;
21+ import { isMac } from " @/utils/device" ;
2122
2223interface CustomAccount {
2324 displayName: string ;
@@ -240,16 +241,20 @@ onClickOutside(emojiPickerRef, () => {
240241});
241242
242243// KeyBoard shortcuts
243- const { Command_Enter } = useMagicKeys ();
244+ function onKeydown(e : KeyboardEvent ) {
245+ if (! raw .value ) {
246+ return ;
247+ }
244248
245- watchEffect (() => {
246- if (Command_Enter .value ) {
249+ const isEnter = e .key === " Enter" ;
250+ const isShortcut = isMac ? e .metaKey : e .ctrlKey ;
251+ if (isShortcut && isEnter ) {
247252 handleSubmit ();
253+ e .preventDefault ();
248254 }
249- });
255+ }
250256
251257// login
252-
253258const parentDomId = ` #comment-${[group ?.replaceAll (" ." , " -" ), kind , name ]
254259 .join (" -" )
255260 .replaceAll (/ -+ / g , " -" )} ` ;
@@ -264,7 +269,7 @@ function handleOpenLoginPage() {
264269 </script >
265270
266271<template >
267- <div class =" comment-form flex gap-4" >
272+ <div class =" comment-form flex gap-4" @keydown = " onKeydown " >
268273 <div class =" flex flex-1 flex-col gap-y-4" >
269274 <textarea
270275 ref =" contentInputRef"
0 commit comments