Skip to content

Commit a02ad80

Browse files
committed
fix: fix text cannot select part problem and url dont need context menu problem
1 parent a3a442a commit a02ad80

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

client/shared/i18n/langs/en-US/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@
214214
"k872b58dd": "Send OTP code to email",
215215
"k87a609ad": "Please do not install plugins from unknown sources, it may steal your personal information in Tailchat",
216216
"k87dd7754": "Mention (@) your message will appear here",
217-
"k887e1f4b": "Copy plain text succeeded",
218217
"k8990744f": "Maximum number of uses",
219218
"k89df1d1e": "The network is abnormal",
220219
"k8abdba5c": "Has been sent",
@@ -387,13 +386,15 @@
387386
"ke03e2010": "No panel access",
388387
"ke040edce": "No rendering method of this type found",
389388
"ke071c620": "Allow members to manage users, such as banning, removing users, etc.",
389+
"ke08ea159": "Copy selected text successfully",
390390
"ke17b2c87": "Do not upload pictures that violate local laws and regulations",
391391
"ke187440d": "Panel type cannot be empty",
392392
"ke2431c67": "Plugin render function does not exist",
393393
"ke3a77a77": "Unlimited",
394394
"ke3d797fd": "Drop files to send into current converse",
395395
"ke59ffe49": "Muted, there are {{remain}} left",
396396
"ke6da074f": "The message was withdrawn successfully",
397+
"keb053701": "Copy message text successfully",
397398
"kec46a57f": "Add members",
398399
"kecb51e2c": "Old password",
399400
"kecbb0e45": "System",

client/shared/i18n/langs/zh-CN/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@
214214
"k872b58dd": "向邮箱发送校验码",
215215
"k87a609ad": "请不要安装不明来源的插件,这可能会盗取你在 Tailchat 的个人信息",
216216
"k87dd7754": "提及(@)您的消息会在这里出现哦",
217-
"k887e1f4b": "复制纯文本成功",
218217
"k8990744f": "最大使用次数",
219218
"k89df1d1e": "网络出现异常",
220219
"k8abdba5c": "已发送",
@@ -387,13 +386,15 @@
387386
"ke03e2010": "没有面板访问权限",
388387
"ke040edce": "没有找到该类型的渲染方式",
389388
"ke071c620": "允许成员管理用户,如禁言、移除用户等操作",
389+
"ke08ea159": "复制选中文本成功",
390390
"ke17b2c87": "请勿上传违反当地法律法规的图片",
391391
"ke187440d": "面板类型不能为空",
392392
"ke2431c67": "插件渲染函数不存在",
393393
"ke3a77a77": "无限制",
394394
"ke3d797fd": "拖放文件以发送到当前会话",
395395
"ke59ffe49": "禁言中, 还剩 {{remain}}",
396396
"ke6da074f": "消息撤回成功",
397+
"keb053701": "复制消息文本成功",
397398
"kec46a57f": "添加成员",
398399
"kecb51e2c": "旧密码",
399400
"kecbb0e45": "系统",

client/web/plugins/com.msgbyte.bbcode/src/tags/UrlTag.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const UrlTag: React.FC<TagProps> = React.memo((props) => {
1616
if (url.startsWith('/')) {
1717
// 内部地址,使用 react-router 进行导航
1818
return (
19-
<Link to={url}>
19+
<Link to={url} onContextMenu={(e) => e.stopPropagation()}>
2020
<UnderlineSpan>{text}</UnderlineSpan>
2121
</Link>
2222
);
@@ -25,14 +25,23 @@ export const UrlTag: React.FC<TagProps> = React.memo((props) => {
2525
if (url.startsWith(window.location.origin)) {
2626
// 内部地址,使用 react-router 进行导航
2727
return (
28-
<Link to={url.replace(window.location.origin, '')}>
28+
<Link
29+
to={url.replace(window.location.origin, '')}
30+
onContextMenu={(e) => e.stopPropagation()}
31+
>
2932
<UnderlineSpan>{text}</UnderlineSpan>
3033
</Link>
3134
);
3235
}
3336

3437
return (
35-
<a href={url} title={text} target="_blank" rel="noopener noreferrer">
38+
<a
39+
href={url}
40+
title={text}
41+
target="_blank"
42+
rel="noopener noreferrer"
43+
onContextMenu={(e) => e.stopPropagation()}
44+
>
3645
<UnderlineSpan>{text}</UnderlineSpan>
3746
</a>
3847
);

client/web/src/components/ChatBox/ChatMessageList/useChatMessageItemAction.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,16 @@ export function useChatMessageItemAction(
3636
);
3737

3838
const handleCopy = useCallback(() => {
39+
const selection = window.getSelection();
40+
if (selection && selection.toString().length > 0) {
41+
// 复制选中的文本
42+
copy(selection.toString());
43+
showSuccessToasts(t('复制选中文本成功'));
44+
return;
45+
}
46+
3947
copy(getMessageTextDecorators().serialize(payload.content));
40-
showSuccessToasts(t('复制纯文本成功'));
48+
showSuccessToasts(t('复制消息文本成功'));
4149
}, [payload.content]);
4250

4351
const [, handleRecallMessage] = useAsyncRequest(async () => {

0 commit comments

Comments
 (0)