fix: remove translate hook in code block (#2080)
This commit is contained in:
parent
3df9da91b4
commit
cc400da44e
1 changed files with 1 additions and 3 deletions
|
|
@ -1,13 +1,11 @@
|
||||||
import copy from "copy-to-clipboard";
|
import copy from "copy-to-clipboard";
|
||||||
import hljs from "highlight.js";
|
import hljs from "highlight.js";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
|
||||||
import { matcher } from "../matcher";
|
import { matcher } from "../matcher";
|
||||||
|
|
||||||
export const CODE_BLOCK_REG = /^```(\S*?)\s([\s\S]*?)```/;
|
export const CODE_BLOCK_REG = /^```(\S*?)\s([\s\S]*?)```/;
|
||||||
|
|
||||||
const renderer = (rawStr: string) => {
|
const renderer = (rawStr: string) => {
|
||||||
const t = useTranslate();
|
|
||||||
const matchResult = matcher(rawStr, CODE_BLOCK_REG);
|
const matchResult = matcher(rawStr, CODE_BLOCK_REG);
|
||||||
if (!matchResult) {
|
if (!matchResult) {
|
||||||
return <>{rawStr}</>;
|
return <>{rawStr}</>;
|
||||||
|
|
@ -27,7 +25,7 @@ const renderer = (rawStr: string) => {
|
||||||
|
|
||||||
const handleCopyButtonClick = () => {
|
const handleCopyButtonClick = () => {
|
||||||
copy(matchResult[2]);
|
copy(matchResult[2]);
|
||||||
toast.success(t("message.succeed-copy-code"));
|
toast.success("Copied to clipboard!");
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue