Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
021add2a
authored
May 16, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: safari reg error
parent
371e0e36
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
4 deletions
+14
-4
src/components/Markdown/index.tsx
+11
-3
src/pages/chat/index.tsx
+1
-0
src/pages/chat/share.tsx
+1
-0
src/utils/tools.ts
+1
-1
No files found.
src/components/Markdown/index.tsx
View file @
021add2a
...
...
@@ -13,12 +13,20 @@ import 'katex/dist/katex.min.css';
import
styles
from
'./index.module.scss'
;
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
formatSource
=
useMemo
(()
=>
{
return
formatLink
TextToHtml
(
source
)
;
},
[
source
]);
return
formatLink
?
formatLinkTextToHtml
(
source
)
:
source
;
},
[
source
,
formatLink
]);
return
(
<
ReactMarkdown
...
...
src/pages/chat/index.tsx
View file @
021add2a
...
...
@@ -826,6 +826,7 @@ const Chat = ({
<Markdown
source={item.value}
isChatting={isChatting && index === chatData.history.length - 1}
formatLink
/>
{item.systemPrompt && (
<Button
...
...
src/pages/chat/share.tsx
View file @
021add2a
...
...
@@ -716,6 +716,7 @@ const Chat = ({
<Markdown
source={item.value}
isChatting={isChatting && index === shareChatData.history.length - 1}
formatLink
/>
{item.systemPrompt && (
<Button
...
...
src/utils/tools.ts
View file @
021add2a
...
...
@@ -117,6 +117,6 @@ export const voiceBroadcast = ({ text }: { text: string }) => {
export
const
formatLinkTextToHtml
=
(
text
:
string
)
=>
{
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>'
);
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment