feat: add copy/toolbar to user messages
- msg-toolbar now rendered for all roles, not just assistant - addCopyButtons and addMessageToolbar applied to any message with content
This commit is contained in:
@@ -1433,7 +1433,7 @@ function appendMessage(role, content, animate, isSearch = false, afterEl = null)
|
|||||||
const months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
const months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
||||||
const ms = now.getMilliseconds();
|
const ms = now.getMilliseconds();
|
||||||
const timeStr = months[now.getMonth()] + ' ' + String(now.getDate()).padStart(2,'0') + ', ' + now.getFullYear() + ' ' + String(now.getHours()).padStart(2,'0') + ':' + String(now.getMinutes()).padStart(2,'0') + ':' + String(now.getSeconds()).padStart(2,'0') + '.' + String(Math.floor(ms / 10)).padStart(2,'0');
|
const timeStr = months[now.getMonth()] + ' ' + String(now.getDate()).padStart(2,'0') + ', ' + now.getFullYear() + ' ' + String(now.getHours()).padStart(2,'0') + ':' + String(now.getMinutes()).padStart(2,'0') + ':' + String(now.getSeconds()).padStart(2,'0') + '.' + String(Math.floor(ms / 10)).padStart(2,'0');
|
||||||
div.innerHTML = `<div class="avatar">${role === 'user' ? 'YOU' : 'AI'}</div><div class="content"><div class="role-label">${role}${role === 'user' ? ' <span class="msg-time">' + timeStr + '</span>' : ''}</div><div class="text">${content ? renderMarkdown(content) : ''}</div>${role === 'assistant' ? '<div class="msg-toolbar"></div>' : ''}</div>`;
|
div.innerHTML = `<div class="avatar">${role === 'user' ? 'YOU' : 'AI'}</div><div class="content"><div class="role-label">${role}${role === 'user' ? ' <span class="msg-time">' + timeStr + '</span>' : ''}</div><div class="text">${content ? renderMarkdown(content) : ''}</div><div class="msg-toolbar"></div></div>`;
|
||||||
if (role === 'user') {
|
if (role === 'user') {
|
||||||
const pair = document.createElement('div');
|
const pair = document.createElement('div');
|
||||||
pair.className = 'msg-pair' + (isSearch ? ' search-pair' : '');
|
pair.className = 'msg-pair' + (isSearch ? ' search-pair' : '');
|
||||||
@@ -1449,7 +1449,7 @@ function appendMessage(role, content, animate, isSearch = false, afterEl = null)
|
|||||||
} else {
|
} else {
|
||||||
container.prepend(div);
|
container.prepend(div);
|
||||||
}
|
}
|
||||||
if (content && role === 'assistant') { addCopyButtons(div); addMessageToolbar(div); }
|
if (content) { addCopyButtons(div); addMessageToolbar(div); }
|
||||||
scrollToTop();
|
scrollToTop();
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user