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

fix: ime #249

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/web/decs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'react-mentions-fix';
3 changes: 1 addition & 2 deletions client/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"react-helmet": "^6.1.0",
"react-is": "^18.2.0",
"react-markdown": "^8.0.5",
"react-mentions": "^4.4.7",
"react-mentions-fix": "4.4.11",
"react-router": "^6.8.1",
"react-router-dom": "^6.8.1",
"react-split": "^2.0.14",
Expand Down Expand Up @@ -104,7 +104,6 @@
"@types/react": "18.0.20",
"@types/react-dom": "18.0.6",
"@types/react-helmet": "^6.1.6",
"@types/react-mentions": "^4.1.8",
"@types/react-router": "^5.1.20",
"@types/react-router-dom": "^5.3.3",
"@types/react-transition-group": "^4.4.5",
Expand Down
14 changes: 7 additions & 7 deletions client/web/src/components/ChatBox/ChatInputBox/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { UserListItem } from '@/components/UserListItem';
import { getMessageTextDecorators, useGroupIdContext } from '@/plugin/common';
import { stopPropagation } from '@/utils/dom-helper';
import React from 'react';
import { Mention, MentionsInput } from 'react-mentions';
import { Mention, MentionsInput } from 'react-mentions-fix';
import { getGroupConfigWithInfo, t, useGroupInfo } from 'tailchat-shared';
import { useChatInputMentionsContext } from './context';
import { MentionCommandItem } from './MentionCommandItem';
Expand Down Expand Up @@ -46,7 +46,7 @@ export const ChatInputBoxInput: React.FC<ChatInputBoxInputProps> = React.memo(
style={defaultChatInputBoxInputStyle}
maxLength={1000}
value={props.value}
onChange={(e, newValue, _, mentions) =>
onChange={(e: any, newValue: string, _: any, mentions: any[]) =>
props.onChange(
newValue,
mentions.filter((m) => m.display.startsWith('@')).map((m) => m.id) // 仅处理mention的数据进行记录
Expand All @@ -61,14 +61,14 @@ export const ChatInputBoxInput: React.FC<ChatInputBoxInputProps> = React.memo(
<Mention
trigger="@"
data={
(query) =>
(query: any) =>
(users ?? [])
.filter((u) => u.display?.includes(query))
.slice(0, 20) // max display 20 item at most
}
displayTransform={(id, display) => `@${display}`}
displayTransform={(id: any, display: any) => `@${display}`}
appendSpaceOnAdd={true}
renderSuggestion={(suggestion) => (
renderSuggestion={(suggestion: { id: any }) => (
<UserListItem
userId={String(suggestion.id)}
hideDiscriminator={hideGroupMemberDiscriminator}
Expand All @@ -79,9 +79,9 @@ export const ChatInputBoxInput: React.FC<ChatInputBoxInputProps> = React.memo(
<Mention
trigger="#"
data={panels ?? []}
displayTransform={(id, display) => `#${display}`}
displayTransform={(id: any, display: any) => `#${display}`}
appendSpaceOnAdd={true}
renderSuggestion={(suggestion) => (
renderSuggestion={(suggestion: { display: any; id: any }) => (
<MentionCommandItem
icon="mdi:pound"
label={suggestion.display ?? String(suggestion.id)}
Expand Down
49 changes: 35 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading