Love from ChatGPT: How to make <p> show all space like <pre>
This commit is contained in:
@@ -21,3 +21,7 @@
|
|||||||
body::-webkit-scrollbar {
|
body::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.message-content {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ export default function Message(props: Props) {
|
|||||||
const chat = chatStore.history[messageIndex];
|
const chat = chatStore.history[messageIndex];
|
||||||
const pClassName =
|
const pClassName =
|
||||||
chat.role === "assistant"
|
chat.role === "assistant"
|
||||||
? "p-2 rounded relative bg-white my-2 text-left dark:bg-gray-700 dark:text-white"
|
? "message-content p-2 rounded bg-white my-2 text-left dark:bg-gray-700 dark:text-white"
|
||||||
: "p-2 rounded relative bg-green-400 my-2 text-right";
|
: "message-content p-2 rounded bg-green-400 my-2 text-right";
|
||||||
const iconClassName =
|
const iconClassName =
|
||||||
chat.role === "user"
|
chat.role === "user"
|
||||||
? "absolute bottom-0 left-0"
|
? "absolute bottom-0 left-0"
|
||||||
@@ -38,14 +38,9 @@ export default function Message(props: Props) {
|
|||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<p className={pClassName}>
|
<div className="relative">
|
||||||
{chat.content
|
<p className={pClassName}>{chat.content}</p>
|
||||||
.split("\n")
|
|
||||||
.filter((line) => line)
|
|
||||||
.map((line) => (
|
|
||||||
<p className="my-1">{line}</p>
|
|
||||||
))}
|
|
||||||
<DeleteIcon />
|
<DeleteIcon />
|
||||||
</p>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user