Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix: edit comment

shuaibda7c40a1a46
diff --git a/ui/src/components/Comment/components/Form/index.tsx b/ui/src/components/Comment/components/Form/index.tsx
index 8809778c..05ae5b2d 100644
--- a/ui/src/components/Comment/components/Form/index.tsx
+++ b/ui/src/components/Comment/components/Form/index.tsx
@@ -25,6 +25,7 @@ import classNames from 'classnames';
import { TextArea, Mentions } from '@/components';
import { usePageUsers, usePromptWithUnload } from '@/hooks';
+import { parseEditMentionUser } from '@/utils';
const Index = ({
className = '',
@@ -78,7 +79,11 @@ const Index = ({
<Mentions
pageUsers={pageUsers.getUsers()}
onSelected={handleSelected}>
- <TextArea size="sm" value={value} onChange={handleChange} />
+ <TextArea
+ size="sm"
+ value={type === 'edit' ? parseEditMentionUser(value) : value}
+ onChange={handleChange}
+ />
</Mentions>
<div className="form-text">{t(`tip_${mode}`)}</div>
</div>
diff --git a/ui/src/router/routes.ts b/ui/src/router/routes.ts
index bab8b34b..9880dd38 100644
--- a/ui/src/router/routes.ts
+++ b/ui/src/router/routes.ts
@@ -219,7 +219,6 @@ const routes: RouteNode[] = [
},
],
},
-
{
path: 'users/login',
page: 'pages/Users/Login',
diff --git a/ui/src/utils/common.ts b/ui/src/utils/common.ts
index 07dc3400..8458afd1 100644
--- a/ui/src/utils/common.ts
+++ b/ui/src/utils/common.ts
@@ -108,6 +108,11 @@ function parseUserInfo(markdown) {
return markdown.replace(globalReg, '[@$1](/u/$1)');
}
+function parseEditMentionUser(markdown) {
+ const globalReg = /\[@([^\]]+)\]\([^)]+\)/g;
+ return markdown.replace(globalReg, '@$1');
+}
+
function formatUptime(value) {
const t = i18next.t.bind(i18next);
const second = parseInt(value, 10);
@@ -273,6 +278,7 @@ export {
bgFadeOut,
matchedUsers,
parseUserInfo,
+ parseEditMentionUser,
formatUptime,
escapeRemove,
handleFormError,