Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webapp-conversation
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
webapp-conversation
Commits
d8cfcc9e
Commit
d8cfcc9e
authored
May 12, 2023
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: input method enter also send message
parent
f5432694
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
index.tsx
app/components/chat/index.tsx
+7
-3
index.ts
config/index.ts
+1
-1
No files found.
app/components/chat/index.tsx
View file @
d8cfcc9e
'use client'
import
type
{
FC
}
from
'react'
import
React
,
{
useEffect
}
from
'react'
import
type
{
FC
,
}
from
'react'
import
React
,
{
useEffect
,
useRef
}
from
'react'
import
cn
from
'classnames'
import
{
HandThumbDownIcon
,
HandThumbUpIcon
}
from
'@heroicons/react/24/outline'
import
{
useTranslation
}
from
'react-i18next'
...
...
@@ -232,6 +232,7 @@ const Chat: FC<IChatProps> = ({
})
=>
{
const
{
t
}
=
useTranslation
()
const
{
notify
}
=
Toast
const
isUseInputMethod
=
useRef
(
false
)
const
[
query
,
setQuery
]
=
React
.
useState
(
''
)
const
handleContentChange
=
(
e
:
any
)
=>
{
...
...
@@ -267,12 +268,15 @@ const Chat: FC<IChatProps> = ({
const
handleKeyUp
=
(
e
:
any
)
=>
{
if
(
e
.
code
===
'Enter'
)
{
e
.
preventDefault
()
if
(
!
e
.
shiftKey
)
// prevent send message when using input method enter
if
(
!
e
.
shiftKey
&&
!
isUseInputMethod
.
current
)
{
handleSend
()
}
}
}
const
haneleKeyDown
=
(
e
:
any
)
=>
{
isUseInputMethod
.
current
=
e
.
nativeEvent
.
isComposing
if
(
e
.
code
===
'Enter'
&&
!
e
.
shiftKey
)
{
setQuery
(
query
.
replace
(
/
\n
$/
,
''
))
e
.
preventDefault
()
...
...
config/index.ts
View file @
d8cfcc9e
...
...
@@ -3,7 +3,7 @@ export const APP_ID = ''
export
const
API_KEY
=
''
export
const
APP_INFO
:
AppInfo
=
{
"title"
:
'Chat APP'
,
"title"
:
'Chat APP
11
'
,
"description"
:
''
,
"copyright"
:
''
,
"privacy_policy"
:
''
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment