From a02ad80bf177b1c6086e9c6150df744ba2027b84 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sat, 13 Apr 2024 18:13:45 +0800 Subject: [PATCH] fix: fix text cannot select part problem and url dont need context menu problem --- client/shared/i18n/langs/en-US/translation.json | 3 ++- client/shared/i18n/langs/zh-CN/translation.json | 3 ++- .../com.msgbyte.bbcode/src/tags/UrlTag.tsx | 15 ++++++++++++--- .../ChatMessageList/useChatMessageItemAction.tsx | 10 +++++++++- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/client/shared/i18n/langs/en-US/translation.json b/client/shared/i18n/langs/en-US/translation.json index e61f1d03300..a7e7e5fb5e0 100644 --- a/client/shared/i18n/langs/en-US/translation.json +++ b/client/shared/i18n/langs/en-US/translation.json @@ -214,7 +214,6 @@ "k872b58dd": "Send OTP code to email", "k87a609ad": "Please do not install plugins from unknown sources, it may steal your personal information in Tailchat", "k87dd7754": "Mention (@) your message will appear here", - "k887e1f4b": "Copy plain text succeeded", "k8990744f": "Maximum number of uses", "k89df1d1e": "The network is abnormal", "k8abdba5c": "Has been sent", @@ -387,6 +386,7 @@ "ke03e2010": "No panel access", "ke040edce": "No rendering method of this type found", "ke071c620": "Allow members to manage users, such as banning, removing users, etc.", + "ke08ea159": "Copy selected text successfully", "ke17b2c87": "Do not upload pictures that violate local laws and regulations", "ke187440d": "Panel type cannot be empty", "ke2431c67": "Plugin render function does not exist", @@ -394,6 +394,7 @@ "ke3d797fd": "Drop files to send into current converse", "ke59ffe49": "Muted, there are {{remain}} left", "ke6da074f": "The message was withdrawn successfully", + "keb053701": "Copy message text successfully", "kec46a57f": "Add members", "kecb51e2c": "Old password", "kecbb0e45": "System", diff --git a/client/shared/i18n/langs/zh-CN/translation.json b/client/shared/i18n/langs/zh-CN/translation.json index c9ee3de388b..9526a825cee 100644 --- a/client/shared/i18n/langs/zh-CN/translation.json +++ b/client/shared/i18n/langs/zh-CN/translation.json @@ -214,7 +214,6 @@ "k872b58dd": "向邮箱发送校验码", "k87a609ad": "请不要安装不明来源的插件,这可能会盗取你在 Tailchat 的个人信息", "k87dd7754": "提及(@)您的消息会在这里出现哦", - "k887e1f4b": "复制纯文本成功", "k8990744f": "最大使用次数", "k89df1d1e": "网络出现异常", "k8abdba5c": "已发送", @@ -387,6 +386,7 @@ "ke03e2010": "没有面板访问权限", "ke040edce": "没有找到该类型的渲染方式", "ke071c620": "允许成员管理用户,如禁言、移除用户等操作", + "ke08ea159": "复制选中文本成功", "ke17b2c87": "请勿上传违反当地法律法规的图片", "ke187440d": "面板类型不能为空", "ke2431c67": "插件渲染函数不存在", @@ -394,6 +394,7 @@ "ke3d797fd": "拖放文件以发送到当前会话", "ke59ffe49": "禁言中, 还剩 {{remain}}", "ke6da074f": "消息撤回成功", + "keb053701": "复制消息文本成功", "kec46a57f": "添加成员", "kecb51e2c": "旧密码", "kecbb0e45": "系统", diff --git a/client/web/plugins/com.msgbyte.bbcode/src/tags/UrlTag.tsx b/client/web/plugins/com.msgbyte.bbcode/src/tags/UrlTag.tsx index 3431ad3cec2..1cd65b11a83 100644 --- a/client/web/plugins/com.msgbyte.bbcode/src/tags/UrlTag.tsx +++ b/client/web/plugins/com.msgbyte.bbcode/src/tags/UrlTag.tsx @@ -16,7 +16,7 @@ export const UrlTag: React.FC = React.memo((props) => { if (url.startsWith('/')) { // 内部地址,使用 react-router 进行导航 return ( - + e.stopPropagation()}> {text} ); @@ -25,14 +25,23 @@ export const UrlTag: React.FC = React.memo((props) => { if (url.startsWith(window.location.origin)) { // 内部地址,使用 react-router 进行导航 return ( - + e.stopPropagation()} + > {text} ); } return ( - + e.stopPropagation()} + > {text} ); diff --git a/client/web/src/components/ChatBox/ChatMessageList/useChatMessageItemAction.tsx b/client/web/src/components/ChatBox/ChatMessageList/useChatMessageItemAction.tsx index 64accc17a68..9b63687bcf0 100644 --- a/client/web/src/components/ChatBox/ChatMessageList/useChatMessageItemAction.tsx +++ b/client/web/src/components/ChatBox/ChatMessageList/useChatMessageItemAction.tsx @@ -36,8 +36,16 @@ export function useChatMessageItemAction( ); const handleCopy = useCallback(() => { + const selection = window.getSelection(); + if (selection && selection.toString().length > 0) { + // 复制选中的文本 + copy(selection.toString()); + showSuccessToasts(t('复制选中文本成功')); + return; + } + copy(getMessageTextDecorators().serialize(payload.content)); - showSuccessToasts(t('复制纯文本成功')); + showSuccessToasts(t('复制消息文本成功')); }, [payload.content]); const [, handleRecallMessage] = useAsyncRequest(async () => {