fix: disabled user promp using dangerouslySetInnerHTML (#2176)
This commit is contained in:
parent
222b4ad897
commit
d4df43ed68
@ -18,7 +18,7 @@ import hljs from 'highlight.js'
|
||||
|
||||
import { useAtomValue } from 'jotai'
|
||||
import { FolderOpenIcon } from 'lucide-react'
|
||||
import { Marked, Renderer, marked as markedDefault } from 'marked'
|
||||
import { Marked, Renderer } from 'marked'
|
||||
|
||||
import { markedHighlight } from 'marked-highlight'
|
||||
|
||||
@ -43,19 +43,6 @@ import {
|
||||
getCurrentChatMessagesAtom,
|
||||
} from '@/helpers/atoms/ChatMessage.atom'
|
||||
|
||||
function isMarkdownValue(value: string): boolean {
|
||||
const tokenTypes: string[] = []
|
||||
markedDefault(value, {
|
||||
walkTokens: (token) => {
|
||||
tokenTypes.push(token.type)
|
||||
},
|
||||
})
|
||||
const isMarkdown = ['code', 'codespan'].some((tokenType) => {
|
||||
return tokenTypes.includes(tokenType)
|
||||
})
|
||||
return isMarkdown
|
||||
}
|
||||
|
||||
const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
|
||||
let text = ''
|
||||
const isUser = props.role === ChatCompletionRole.User
|
||||
@ -282,7 +269,7 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isUser && !isMarkdownValue(text) ? (
|
||||
{isUser ? (
|
||||
<>
|
||||
{editMessage === props.id ? (
|
||||
<div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user