Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

发送 Prompt 时,在中文输入法下表现异常 #127

Open
1 task
j10ccc opened this issue Jan 16, 2024 · 1 comment
Open
1 task

发送 Prompt 时,在中文输入法下表现异常 #127

j10ccc opened this issue Jan 16, 2024 · 1 comment
Labels
use issue when using `anse.app`

Comments

@j10ccc
Copy link

j10ccc commented Jan 16, 2024

What operating system are you using?

Mac

What browser are you using?

Safari

Describe the bug

发送 Prompt 时,在中文输入法下表现异常。Safari 浏览器,在中文输入法下按回车的时候,会触发发送 Prompt。源码里通过 isComposing 解决,但是 Safari 对这个 api 表现有所差异。

目标就是在输出回车的时候判断是否在中文输入法下。

我看了下其他项目的实现

https://github.com/labring/FastGPT/blob/006ad17c6a34cd6144ee871a2d9f1a9577ffaf21/projects/app/src/components/ChatBox/MessageInput.tsx#L335-L340

他用的是键盘事件的 keyCode。对于回车键,在中文输入法(Mac 微信输入法)下 keyCode 输出的值是 229,而默认英文输入下,是 13。通过这个 API 可以达到目标。而 anse 现在使用的是 key,两种输入状态下的输出都是 "Enter",无法判断中文输入法,并且 isComposing 也无法在全平台下正确判断

keyCode 这个属性被标记为 Deprecated,目前应该没有什么好方法处理这个问题了吧?

What provider are you using?

None

What prompt did you enter?

No response

Console Logs

No response

Participation

  • I am willing to submit a pull request for this issue.
@j10ccc j10ccc added the use issue when using `anse.app` label Jan 16, 2024
@j10ccc
Copy link
Author

j10ccc commented Jan 16, 2024

有一个方案,能完全避开中文输入法的检测。就是发送 Prompt 的快捷键改成 cmd+enter / shift+enter,textarea 的换行用默认的 enter。就是互换两个快捷键的行为,可以给用户一个选择。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
use issue when using `anse.app`
Projects
None yet
Development

No branches or pull requests

1 participant