rollback to innerText

This commit is contained in:
Gabe Yuan
2023-08-03 15:29:54 +08:00
parent d735ee977c
commit 5aca06fb9c
8 changed files with 14 additions and 36 deletions

View File

@@ -7,7 +7,6 @@ import {
OPT_STYLE_WAVYLINE,
OPT_STYLE_FUZZY,
OPT_STYLE_HIGHTLIGHT,
OPT_TRANS_OPENAI,
} from "../../config";
import { useTranslate } from "../../hooks/Translate";
@@ -77,30 +76,13 @@ export default function Content({ q, rule }) {
return (
<>
{q.length > 40 ? <br /> : " "}
{rule.translator === OPT_TRANS_OPENAI ? (
<span
style={style}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
>
{text}
</span>
) : (
<span
style={style}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
dangerouslySetInnerHTML={{
__html: text.replace(
/<code>(.*?)<\/code>/gi,
(_match, p1) =>
`<code>${p1
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")}</code>`
),
}}
/>
)}
<span
style={style}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
>
{text}
</span>
</>
);
}