mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 08:25:07 +00:00
fix: safari reg error
This commit is contained in:
@@ -13,12 +13,20 @@ import 'katex/dist/katex.min.css';
|
|||||||
import styles from './index.module.scss';
|
import styles from './index.module.scss';
|
||||||
import { codeLight } from './codeLight';
|
import { codeLight } from './codeLight';
|
||||||
|
|
||||||
const Markdown = ({ source, isChatting = false }: { source: string; isChatting?: boolean }) => {
|
const Markdown = ({
|
||||||
|
source,
|
||||||
|
isChatting = false,
|
||||||
|
formatLink
|
||||||
|
}: {
|
||||||
|
source: string;
|
||||||
|
formatLink?: boolean;
|
||||||
|
isChatting?: boolean;
|
||||||
|
}) => {
|
||||||
const { copyData } = useCopyData();
|
const { copyData } = useCopyData();
|
||||||
|
|
||||||
const formatSource = useMemo(() => {
|
const formatSource = useMemo(() => {
|
||||||
return formatLinkTextToHtml(source);
|
return formatLink ? formatLinkTextToHtml(source) : source;
|
||||||
}, [source]);
|
}, [source, formatLink]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
|
@@ -826,6 +826,7 @@ const Chat = ({
|
|||||||
<Markdown
|
<Markdown
|
||||||
source={item.value}
|
source={item.value}
|
||||||
isChatting={isChatting && index === chatData.history.length - 1}
|
isChatting={isChatting && index === chatData.history.length - 1}
|
||||||
|
formatLink
|
||||||
/>
|
/>
|
||||||
{item.systemPrompt && (
|
{item.systemPrompt && (
|
||||||
<Button
|
<Button
|
||||||
|
@@ -716,6 +716,7 @@ const Chat = ({
|
|||||||
<Markdown
|
<Markdown
|
||||||
source={item.value}
|
source={item.value}
|
||||||
isChatting={isChatting && index === shareChatData.history.length - 1}
|
isChatting={isChatting && index === shareChatData.history.length - 1}
|
||||||
|
formatLink
|
||||||
/>
|
/>
|
||||||
{item.systemPrompt && (
|
{item.systemPrompt && (
|
||||||
<Button
|
<Button
|
||||||
|
@@ -117,6 +117,6 @@ export const voiceBroadcast = ({ text }: { text: string }) => {
|
|||||||
|
|
||||||
export const formatLinkTextToHtml = (text: string) => {
|
export const formatLinkTextToHtml = (text: string) => {
|
||||||
const httpReg =
|
const httpReg =
|
||||||
/(?<!\[.*\]\()((http|https|ftp):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)(?![\)])/gi;
|
/(http|https|ftp):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/gi;
|
||||||
return text.replace(httpReg, '<a href="$&" target="_blank">$&</a>');
|
return text.replace(httpReg, '<a href="$&" target="_blank">$&</a>');
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user