Skip to content

Commit

Permalink
fix: fix text cannot select part problem and url dont need context me…
Browse files Browse the repository at this point in the history
…nu problem
  • Loading branch information
moonrailgun committed Apr 13, 2024
1 parent a3a442a commit a02ad80
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
3 changes: 2 additions & 1 deletion client/shared/i18n/langs/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -387,13 +386,15 @@
"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",
"ke3a77a77": "Unlimited",
"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",
Expand Down
3 changes: 2 additions & 1 deletion client/shared/i18n/langs/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@
"k872b58dd": "向邮箱发送校验码",
"k87a609ad": "请不要安装不明来源的插件,这可能会盗取你在 Tailchat 的个人信息",
"k87dd7754": "提及(@)您的消息会在这里出现哦",
"k887e1f4b": "复制纯文本成功",
"k8990744f": "最大使用次数",
"k89df1d1e": "网络出现异常",
"k8abdba5c": "已发送",
Expand Down Expand Up @@ -387,13 +386,15 @@
"ke03e2010": "没有面板访问权限",
"ke040edce": "没有找到该类型的渲染方式",
"ke071c620": "允许成员管理用户,如禁言、移除用户等操作",
"ke08ea159": "复制选中文本成功",
"ke17b2c87": "请勿上传违反当地法律法规的图片",
"ke187440d": "面板类型不能为空",
"ke2431c67": "插件渲染函数不存在",
"ke3a77a77": "无限制",
"ke3d797fd": "拖放文件以发送到当前会话",
"ke59ffe49": "禁言中, 还剩 {{remain}}",
"ke6da074f": "消息撤回成功",
"keb053701": "复制消息文本成功",
"kec46a57f": "添加成员",
"kecb51e2c": "旧密码",
"kecbb0e45": "系统",
Expand Down
15 changes: 12 additions & 3 deletions client/web/plugins/com.msgbyte.bbcode/src/tags/UrlTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const UrlTag: React.FC<TagProps> = React.memo((props) => {
if (url.startsWith('/')) {
// 内部地址,使用 react-router 进行导航
return (
<Link to={url}>
<Link to={url} onContextMenu={(e) => e.stopPropagation()}>
<UnderlineSpan>{text}</UnderlineSpan>
</Link>
);
Expand All @@ -25,14 +25,23 @@ export const UrlTag: React.FC<TagProps> = React.memo((props) => {
if (url.startsWith(window.location.origin)) {
// 内部地址,使用 react-router 进行导航
return (
<Link to={url.replace(window.location.origin, '')}>
<Link
to={url.replace(window.location.origin, '')}
onContextMenu={(e) => e.stopPropagation()}
>
<UnderlineSpan>{text}</UnderlineSpan>
</Link>
);
}

return (
<a href={url} title={text} target="_blank" rel="noopener noreferrer">
<a
href={url}
title={text}
target="_blank"
rel="noopener noreferrer"
onContextMenu={(e) => e.stopPropagation()}
>
<UnderlineSpan>{text}</UnderlineSpan>
</a>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit a02ad80

Please sign in to comment.