Skip to content

Commit

Permalink
fix: disabled user promp using dangerouslySetInnerHTML
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Feb 27, 2024
1 parent fbee753 commit 4feaac9
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions web/screens/Chat/SimpleTextMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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
Expand Down Expand Up @@ -282,7 +269,7 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
</div>
)}

{isUser && !isMarkdownValue(text) ? (
{isUser ? (
<>
{editMessage === props.id ? (
<div>
Expand Down

0 comments on commit 4feaac9

Please sign in to comment.