feat: validate html elements in markdown, refactor cursor type, disable markdown input rendering
This commit is contained in:
parent
db779446f0
commit
223496192d
@ -18,6 +18,9 @@ import CodeBlock from './CodeBlock'
|
||||
import ImagePreview from './ImagePreview'
|
||||
import Link from './Link'
|
||||
|
||||
const ALLOWED_ELEMENTS =
|
||||
/<(style|p|div|span|b|i|strong|em|ul|ol|li|table|tr|td|th|thead|tbody|h[1-6]|blockquote|pre|code|br|hr)/i
|
||||
|
||||
interface Props {
|
||||
message: Message
|
||||
}
|
||||
@ -36,8 +39,8 @@ const Markdown: FC<Props> = ({ message }) => {
|
||||
}, [message.content, message.status, t])
|
||||
|
||||
const rehypePlugins = useMemo(() => {
|
||||
const hasUnsafeElements = /<(input|textarea|select|menuitem)/i.test(messageContent)
|
||||
return hasUnsafeElements ? [rehypeMath] : [rehypeRaw, rehypeMath]
|
||||
const hasElements = ALLOWED_ELEMENTS.test(messageContent)
|
||||
return hasElements ? [rehypeRaw, rehypeMath] : [rehypeMath]
|
||||
}, [messageContent, rehypeMath])
|
||||
|
||||
if (message.role === 'user' && !renderInputMessageAsMarkdown) {
|
||||
|
||||
@ -181,7 +181,7 @@ const ProviderListItem = styled.div`
|
||||
align-items: center;
|
||||
padding: 5px 8px;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
cursor: grab;
|
||||
border-radius: 5px;
|
||||
font-size: 14px;
|
||||
transition: all 0.2s ease-in-out;
|
||||
|
||||
@ -56,7 +56,7 @@ const initialState: SettingsState = {
|
||||
pasteLongTextAsFile: false,
|
||||
clickAssistantToShowTopic: false,
|
||||
manualUpdateCheck: false,
|
||||
renderInputMessageAsMarkdown: true,
|
||||
renderInputMessageAsMarkdown: false,
|
||||
codeShowLineNumbers: false,
|
||||
codeCollapsible: false,
|
||||
mathEngine: 'MathJax',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user