Skip to content

Commit 704386b

Browse files
committed
Исправлены отступы и переносы строк в AI чате
1 parent 65fc46b commit 704386b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

resources/views/components/page/ai-chat.blade.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<div class="d-flex flex-row justify-content-end mb-4">
2020
<div class="p-3 me-3 border bg-body-tertiary"
2121
style="border-radius: 15px; max-width: 75%;">
22-
<p class="small mb-0" x-text="msg.text"></p>
22+
<p class="small mb-0" x-html="msg.text" style="white-space: pre;"></p>
2323
</div>
2424
<img class="rounded-circle h-100" :src="userAvatar" alt="avatar 1"
2525
style="width: 45px;">
@@ -80,6 +80,11 @@ class="form-control bg-body-tertiary border-1" id="promptTextArea" rows="4" x-bi
8080
}, ],
8181
chatMessages: null,
8282
renderedChatMessages: null,
83+
stripTags(html) {
84+
const div = document.createElement("div");
85+
div.innerHTML = html;
86+
return div.textContent || div.innerText || "";
87+
},
8388
init() {
8489
this.aiClient = new AiTeacherApi(this.aiChatUrl);
8590
this.scrollArea = document.getElementById('scrollArea');
@@ -120,7 +125,7 @@ class="form-control bg-body-tertiary border-1" id="promptTextArea" rows="4" x-bi
120125
});
121126
if (!this.loading && this.message?.length > 0) {
122127
let messageObj = {
123-
text: this.message,
128+
text: this.stripTags(this.message).replaceAll('\n', '<br>'),
124129
date: new Date().toLocaleString(),
125130
isTeacher: false
126131
};

0 commit comments

Comments
 (0)