base commit
This commit is contained in:
@@ -257,7 +257,7 @@ export function AdminOrdersPage() {
|
||||
{m.authorType === 'admin' ? 'Админ (вы)' : 'Пользователь'} ·{' '}
|
||||
{new Date(m.createdAt).toLocaleString()}
|
||||
</Typography>
|
||||
<RichTextMessageContent value={m.text} />
|
||||
<RichTextMessageContent value={m.text} tone="chat" />
|
||||
</Box>
|
||||
))}
|
||||
{detail.messages.length === 0 && <Typography color="text.secondary">Нет сообщений.</Typography>}
|
||||
|
||||
@@ -69,7 +69,7 @@ export function AdminReviewsPage() {
|
||||
<TableCell>
|
||||
<Chip label={String(r.rating)} size="small" />
|
||||
</TableCell>
|
||||
<TableCell>{r.text?.trim() ? <RichTextMessageContent value={r.text} /> : '—'}</TableCell>
|
||||
<TableCell>{r.text?.trim() ? <RichTextMessageContent value={r.text} tone="review" /> : '—'}</TableCell>
|
||||
<TableCell align="right">
|
||||
<Button
|
||||
size="small"
|
||||
|
||||
@@ -176,7 +176,7 @@ export function MessagesPage() {
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
{m.authorType === 'admin' ? 'Админ' : 'Вы'} · {new Date(m.createdAt).toLocaleString()}
|
||||
</Typography>
|
||||
<RichTextMessageContent value={m.text} />
|
||||
<RichTextMessageContent value={m.text} tone="chat" />
|
||||
</Box>
|
||||
))}
|
||||
{order.messages.length === 0 && <Typography color="text.secondary">Нет сообщений.</Typography>}
|
||||
|
||||
@@ -332,7 +332,7 @@ export function OrderDetailPage() {
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
{m.authorType === 'admin' ? 'Админ' : 'Вы'} · {new Date(m.createdAt).toLocaleString()}
|
||||
</Typography>
|
||||
<RichTextMessageContent value={m.text} />
|
||||
<RichTextMessageContent value={m.text} tone="chat" />
|
||||
</Box>
|
||||
))}
|
||||
{order.messages.length === 0 && <Typography color="text.secondary">Пока сообщений нет.</Typography>}
|
||||
|
||||
@@ -216,7 +216,7 @@ export function ProductPage() {
|
||||
/>
|
||||
{body ? (
|
||||
<Box sx={{ color: 'text.secondary' }}>
|
||||
<RichTextMessageContent value={body} />
|
||||
<RichTextMessageContent value={body} tone="review" />
|
||||
</Box>
|
||||
) : (
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
|
||||
@@ -5,9 +5,10 @@ import TiptapStarterKit from '@tiptap/starter-kit'
|
||||
|
||||
type RichTextMessageContentProps = {
|
||||
value: string
|
||||
tone?: 'default' | 'review' | 'chat'
|
||||
}
|
||||
|
||||
export function RichTextMessageContent({ value }: RichTextMessageContentProps) {
|
||||
export function RichTextMessageContent({ value, tone = 'default' }: RichTextMessageContentProps) {
|
||||
const editor = useEditor({
|
||||
extensions: [
|
||||
TiptapStarterKit.configure({ heading: false, codeBlock: false, blockquote: false, horizontalRule: false }),
|
||||
@@ -30,14 +31,31 @@ export function RichTextMessageContent({ value }: RichTextMessageContentProps) {
|
||||
outline: 'none',
|
||||
whiteSpace: 'pre-wrap',
|
||||
wordBreak: 'break-word',
|
||||
...(tone === 'review'
|
||||
? {
|
||||
fontSize: '0.875rem',
|
||||
lineHeight: 1.5,
|
||||
}
|
||||
: tone === 'chat'
|
||||
? {
|
||||
fontSize: '0.95rem',
|
||||
lineHeight: 1.45,
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
'& .ProseMirror p': {
|
||||
m: 0,
|
||||
},
|
||||
'& .ProseMirror p + p': {
|
||||
mt: tone === 'review' ? 0.75 : tone === 'chat' ? 0.5 : 0.5,
|
||||
},
|
||||
'& .ProseMirror ul, & .ProseMirror ol': {
|
||||
m: 0,
|
||||
my: tone === 'review' ? 0.75 : tone === 'chat' ? 0.25 : 0,
|
||||
pl: 3,
|
||||
},
|
||||
'& .ProseMirror li + li': {
|
||||
mt: tone === 'review' ? 0.25 : tone === 'chat' ? 0.15 : 0,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<EditorContent editor={editor} />
|
||||
|
||||
@@ -107,7 +107,7 @@ export function ReviewsBlock() {
|
||||
</Stack>
|
||||
|
||||
<Box sx={{ color: 'text.secondary', flex: 1 }}>
|
||||
<RichTextMessageContent value={text} />
|
||||
<RichTextMessageContent value={text} tone="review" />
|
||||
</Box>
|
||||
</Stack>
|
||||
{r.imageUrl && (
|
||||
|
||||
@@ -20,6 +20,10 @@ export default defineConfig({
|
||||
target: 'http://127.0.0.1:3333',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/uploads': {
|
||||
target: 'http://127.0.0.1:3333',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user