Streaming-Cursor: Block-Cursor-Stil, schnelleres Blinken, korrekte Inline-Positionierung

This commit is contained in:
Meleki committed 2026-02-28 21:48:15 +01:00
1 parent e79a69a364
commit f20d94b08f
2 files changed
+14 -13

No files matched your search

+8 -2
View File
@@ -121,7 +121,7 @@ let _streamText = '';
function startStreamBubble() {
_streamDiv = document.createElement('div');
_streamDiv.className = 'msg assistant markdown streamed';
_streamDiv.innerHTML = '<span class="cursor"></span>';
_streamDiv.innerHTML = '<p><span class="cursor"></span></p>';
_streamText = '';
chatEl().appendChild(_streamDiv);
scrollDown();
@@ -131,9 +131,15 @@ function appendToStream(text) {
if (!_streamDiv) startStreamBubble();
_streamText += text;
_streamDiv.innerHTML = renderMarkdown(_streamText);
// Cursor ins letzte Inline/Text-Element einfügen, damit er nicht auf eine neue Zeile rutscht
const cursor = document.createElement('span');
cursor.className = 'cursor';
_streamDiv.appendChild(cursor);
const lastBlock = _streamDiv.lastElementChild;
if (lastBlock) {
lastBlock.appendChild(cursor);
} else {
_streamDiv.appendChild(cursor);
}
scrollDown();
}