From f9cf8a2b131ac89699bb07ec474058b7d99024fe Mon Sep 17 00:00:00 2001 From: shuai Date: Tue, 28 Mar 2023 15:05:03 +0800 Subject: [PATCH] fix: html render --- ui/src/pages/Legal/Privacy/index.tsx | 10 ++++------ ui/src/pages/Legal/Tos/index.tsx | 14 ++++++-------- .../Questions/Detail/components/Answer/index.tsx | 11 +++++------ .../Questions/Detail/components/Question/index.tsx | 10 ++++------ ui/src/pages/Questions/EditAnswer/index.tsx | 8 ++++---- ui/src/pages/Tags/Info/index.tsx | 8 ++++---- 6 files changed, 27 insertions(+), 34 deletions(-) diff --git a/ui/src/pages/Legal/Privacy/index.tsx b/ui/src/pages/Legal/Privacy/index.tsx index f8fc2ace..eb36de32 100644 --- a/ui/src/pages/Legal/Privacy/index.tsx +++ b/ui/src/pages/Legal/Privacy/index.tsx @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next'; import { usePageTags } from '@/hooks'; import { useLegalPrivacy } from '@/services'; +import { htmlToReact } from '@/utils'; const Index: FC = () => { const { t } = useTranslation('translation', { keyPrefix: 'nav_menus' }); @@ -25,12 +26,9 @@ const Index: FC = () => { return ( <>

{t('privacy')}

-
+
+ {htmlToReact(privacy?.privacy_policy_parsed_text || '')} +
); }; diff --git a/ui/src/pages/Legal/Tos/index.tsx b/ui/src/pages/Legal/Tos/index.tsx index bbac2b50..1b02d74d 100644 --- a/ui/src/pages/Legal/Tos/index.tsx +++ b/ui/src/pages/Legal/Tos/index.tsx @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next'; import { usePageTags } from '@/hooks'; import { useLegalTos } from '@/services'; +import { htmlToReact } from '@/utils'; const Index: FC = () => { const { t } = useTranslation('translation', { keyPrefix: 'nav_menus' }); @@ -23,15 +24,12 @@ const Index: FC = () => { return null; } return ( - <> +

{t('tos')}

-
- +
+ {htmlToReact(tos?.terms_of_service_parsed_text || '')} +
+
); }; diff --git a/ui/src/pages/Questions/Detail/components/Answer/index.tsx b/ui/src/pages/Questions/Detail/components/Answer/index.tsx index dfbefa3d..ba1a7d50 100644 --- a/ui/src/pages/Questions/Detail/components/Answer/index.tsx +++ b/ui/src/pages/Questions/Detail/components/Answer/index.tsx @@ -12,7 +12,7 @@ import { FormatTime, htmlRender, } from '@/components'; -import { scrollToElementTop, bgFadeOut } from '@/utils'; +import { scrollToElementTop, bgFadeOut, htmlToReact } from '@/utils'; import { AnswerItem } from '@/common/interface'; import { acceptanceAnswer } from '@/services'; @@ -77,17 +77,16 @@ const Index: FC = ({ )} {data?.accepted === 2 && ( -
+
Best answer
)} -
+
+ {htmlToReact(data?.html)} +
= ({ data, initPage, hasAnswer, isLogged }) => { return ; })}
-
+
+ {htmlToReact(data?.html)} +
{
+ className="content position-absolute top-0 w-100"> + {htmlToReact(data?.question.html)} +
{ const userInfo = loggedUserInfoStore((state) => state.user); @@ -144,10 +145,9 @@ const TagIntroduction = () => { />
-
+
+ {htmlToReact(tagInfo?.parsed_text)} +
{tagInfo?.member_actions.map((action, index) => { return (