mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-07-24 23:34:28 +08:00
feat: add message renderer style
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import { marked } from "marked";
|
||||
import { useUserStore } from "../../store";
|
||||
import { Message } from "../../types";
|
||||
import "highlight.js/styles/github.css";
|
||||
|
||||
interface Props {
|
||||
message: Message;
|
||||
@ -14,12 +13,14 @@ const MessageView = (props: Props) => {
|
||||
const isCurrentUser = message.creatorId === currentUser.id;
|
||||
|
||||
return (
|
||||
<div className={`w-full flex flex-row justify-start items-start my-4 ${isCurrentUser ? "justify-end pl-8 sm:pl-16" : "pr-8 sm:pr-16"}`}>
|
||||
<div className={`w-full flex flex-row justify-start items-start my-4 ${isCurrentUser ? "justify-end pl-8 sm:pl-24" : "pr-8 sm:pr-24"}`}>
|
||||
{isCurrentUser ? (
|
||||
<div className="w-auto max-w-full bg-indigo-600 text-white px-4 py-2 rounded-lg rounded-tr-none shadow">{message.content}</div>
|
||||
<div className="w-auto max-w-full bg-indigo-600 text-white px-4 py-2 rounded-lg rounded-tr-none shadow whitespace-pre">
|
||||
{message.content}
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
className="w-auto max-w-full bg-gray-100 px-4 py-2 rounded-lg rounded-tl-none shadow"
|
||||
className="w-auto max-w-full bg-gray-100 px-4 py-2 rounded-lg rounded-tl-none shadow prose prose-neutral"
|
||||
dangerouslySetInnerHTML={{ __html: marked.parse(message.content) }}
|
||||
></div>
|
||||
)}
|
||||
|
@ -24,6 +24,7 @@
|
||||
"zustand": "^4.3.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
"@types/marked": "^4.0.8",
|
||||
"@types/node": "^18.11.18",
|
||||
"@types/react": "^18.0.26",
|
||||
|
30
pnpm-lock.yaml
generated
30
pnpm-lock.yaml
generated
@ -2,6 +2,7 @@ lockfileVersion: 5.4
|
||||
|
||||
specifiers:
|
||||
'@headlessui/react': ^1.7.13
|
||||
'@tailwindcss/typography': ^0.5.9
|
||||
'@types/marked': ^4.0.8
|
||||
'@types/node': ^18.11.18
|
||||
'@types/react': ^18.0.26
|
||||
@ -45,6 +46,7 @@ dependencies:
|
||||
zustand: 4.3.6_react@18.2.0
|
||||
|
||||
devDependencies:
|
||||
'@tailwindcss/typography': 0.5.9_tailwindcss@3.2.7
|
||||
'@types/marked': 4.0.8
|
||||
'@types/node': 18.15.3
|
||||
'@types/react': 18.0.28
|
||||
@ -266,6 +268,18 @@ packages:
|
||||
tslib: 2.5.0
|
||||
dev: false
|
||||
|
||||
/@tailwindcss/typography/0.5.9_tailwindcss@3.2.7:
|
||||
resolution: {integrity: sha512-t8Sg3DyynFysV9f4JDOVISGsjazNb48AeIYQwcL+Bsq5uf4RYL75C1giZ43KISjeDGBaTN3Kxh7Xj/vRSMJUUg==}
|
||||
peerDependencies:
|
||||
tailwindcss: '>=3.0.0 || insiders'
|
||||
dependencies:
|
||||
lodash.castarray: 4.4.0
|
||||
lodash.isplainobject: 4.0.6
|
||||
lodash.merge: 4.6.2
|
||||
postcss-selector-parser: 6.0.10
|
||||
tailwindcss: 3.2.7_postcss@8.4.21
|
||||
dev: true
|
||||
|
||||
/@types/json5/0.0.29:
|
||||
resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==}
|
||||
dev: true
|
||||
@ -1661,6 +1675,14 @@ packages:
|
||||
engines: {node: '>=10'}
|
||||
dev: true
|
||||
|
||||
/lodash.castarray/4.4.0:
|
||||
resolution: {integrity: sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==}
|
||||
dev: true
|
||||
|
||||
/lodash.isplainobject/4.0.6:
|
||||
resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==}
|
||||
dev: true
|
||||
|
||||
/lodash.merge/4.6.2:
|
||||
resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==}
|
||||
dev: true
|
||||
@ -1983,6 +2005,14 @@ packages:
|
||||
postcss-selector-parser: 6.0.11
|
||||
dev: true
|
||||
|
||||
/postcss-selector-parser/6.0.10:
|
||||
resolution: {integrity: sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==}
|
||||
engines: {node: '>=4'}
|
||||
dependencies:
|
||||
cssesc: 3.0.0
|
||||
util-deprecate: 1.0.2
|
||||
dev: true
|
||||
|
||||
/postcss-selector-parser/6.0.11:
|
||||
resolution: {integrity: sha512-zbARubNdogI9j7WY4nQJBiNqQf3sLS3wCP4WfOidu+p28LofJqDH1tcXypGrcmMHhDk2t9wGhCsYe/+szLTy1g==}
|
||||
engines: {node: '>=4'}
|
||||
|
@ -8,5 +8,5 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
plugins: [require("@tailwindcss/typography")],
|
||||
};
|
||||
|
Reference in New Issue
Block a user