base commit

This commit is contained in:
@kirill.komarov
2026-05-03 20:30:21 +05:00
parent fe10f25b8c
commit 6885e39017
13 changed files with 253 additions and 72 deletions
@@ -0,0 +1,46 @@
import { useEffect } from 'react'
import Box from '@mui/material/Box'
import { EditorContent, useEditor } from '@tiptap/react'
import TiptapStarterKit from '@tiptap/starter-kit'
type RichTextMessageContentProps = {
value: string
}
export function RichTextMessageContent({ value }: RichTextMessageContentProps) {
const editor = useEditor({
extensions: [
TiptapStarterKit.configure({ heading: false, codeBlock: false, blockquote: false, horizontalRule: false }),
],
content: value.trim() ? value : '<p></p>',
editable: false,
})
useEffect(() => {
if (!editor) return
const normalizedValue = value.trim() ? value : '<p></p>'
if (editor.getHTML() === normalizedValue) return
editor.commands.setContent(normalizedValue, false)
}, [editor, value])
return (
<Box
sx={{
'& .ProseMirror': {
outline: 'none',
whiteSpace: 'pre-wrap',
wordBreak: 'break-word',
},
'& .ProseMirror p': {
m: 0,
},
'& .ProseMirror ul, & .ProseMirror ol': {
m: 0,
pl: 3,
},
}}
>
<EditorContent editor={editor} />
</Box>
)
}