@devchitchat/chat 4.1.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -165,6 +165,9 @@ export default function CallIsland(root) {
|
|
|
165
165
|
if (!article.querySelector('.message-hover-actions')) {
|
|
166
166
|
const toolbar = document.createElement('div')
|
|
167
167
|
toolbar.className = 'message-hover-actions'
|
|
168
|
+
const quickPicks = document.createElement('span')
|
|
169
|
+
quickPicks.className = 'quick-picks'
|
|
170
|
+
toolbar.appendChild(quickPicks)
|
|
168
171
|
const reactBtn = document.createElement('button')
|
|
169
172
|
reactBtn.className = 'btn-react btn-icon'
|
|
170
173
|
reactBtn.type = 'button'
|
|
@@ -181,6 +184,7 @@ export default function CallIsland(root) {
|
|
|
181
184
|
toolbar.appendChild(actionsBtn)
|
|
182
185
|
}
|
|
183
186
|
article.appendChild(toolbar)
|
|
187
|
+
renderQuickPicks(toolbar)
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
// Apply inline rendering (URLs, @mentions) to server-rendered message text.
|
|
@@ -695,6 +699,8 @@ export default function CallIsland(root) {
|
|
|
695
699
|
}
|
|
696
700
|
|
|
697
701
|
enableTaskCheckboxes(article)
|
|
702
|
+
const toolbar = article.querySelector('.message-hover-actions')
|
|
703
|
+
if (toolbar) renderQuickPicks(toolbar)
|
|
698
704
|
messages.appendChild(article)
|
|
699
705
|
renderReactionBar(article, reactions ?? [], msg_id)
|
|
700
706
|
messages.scrollTop = messages.scrollHeight
|
|
@@ -736,6 +742,22 @@ export default function CallIsland(root) {
|
|
|
736
742
|
recents.unshift(emoji)
|
|
737
743
|
if (recents.length > RECENT_MAX) recents = recents.slice(0, RECENT_MAX)
|
|
738
744
|
localStorage.setItem(RECENT_KEY, JSON.stringify(recents))
|
|
745
|
+
refreshAllQuickPicks()
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
function renderQuickPicks(toolbar) {
|
|
749
|
+
const slot = toolbar.querySelector('.quick-picks')
|
|
750
|
+
if (!slot) return
|
|
751
|
+
const recents = loadRecentEmoji().slice(0, 4)
|
|
752
|
+
slot.innerHTML = recents.map(emoji =>
|
|
753
|
+
`<button class="btn-quick-react btn-icon" data-emoji="${escHtml(emoji)}" type="button" title="${escHtml(emoji)}">${emoji}</button>`
|
|
754
|
+
).join('')
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
function refreshAllQuickPicks() {
|
|
758
|
+
for (const toolbar of messages.querySelectorAll('.message-hover-actions')) {
|
|
759
|
+
renderQuickPicks(toolbar)
|
|
760
|
+
}
|
|
739
761
|
}
|
|
740
762
|
|
|
741
763
|
let emojiPickerEl = null
|
|
@@ -913,6 +935,18 @@ export default function CallIsland(root) {
|
|
|
913
935
|
ws.send({ t: 'msg.edit', body: { msg_id: article.dataset.msgId, channel_id: channelId, text: newText } })
|
|
914
936
|
})
|
|
915
937
|
|
|
938
|
+
// Delegated click on .btn-quick-react — send reaction without opening picker
|
|
939
|
+
messages.addEventListener('click', e => {
|
|
940
|
+
const btn = e.target.closest('.btn-quick-react')
|
|
941
|
+
if (!btn) return
|
|
942
|
+
e.stopPropagation()
|
|
943
|
+
const emoji = btn.dataset.emoji
|
|
944
|
+
const msgId = btn.closest('article.message')?.dataset.msgId
|
|
945
|
+
if (!emoji || !msgId) return
|
|
946
|
+
saveRecentEmoji(emoji)
|
|
947
|
+
ws.send({ t: 'reaction.add', body: { msg_id: msgId, channel_id: channelId, emoji } })
|
|
948
|
+
})
|
|
949
|
+
|
|
916
950
|
// Delegated click on .reaction-pill — toggle reaction
|
|
917
951
|
messages.addEventListener('click', e => {
|
|
918
952
|
const pill = e.target.closest('.reaction-pill')
|
|
@@ -134,7 +134,7 @@ export function makeMessageEl({ msg_id, seq, user_id, user_display_name, ts, tex
|
|
|
134
134
|
const isSelf = userId != null && user_id === userId
|
|
135
135
|
const attachmentHtml = (attachments ?? []).map(a => renderAttachment(a)).join('')
|
|
136
136
|
const editedHtml = edited_at ? '<span class="message-edited">(edited)</span>' : ''
|
|
137
|
-
const actionsHtml = `<div class="message-hover-actions"><button class="btn-react btn-icon" type="button" title="Add reaction" aria-label="Add reaction">🙂</button>${isSelf ? '<button class="btn-msg-actions btn-icon" type="button" title="Message actions">…</button>' : ''}</div>`
|
|
137
|
+
const actionsHtml = `<div class="message-hover-actions"><span class="quick-picks"></span><button class="btn-react btn-icon" type="button" title="Add reaction" aria-label="Add reaction">🙂</button>${isSelf ? '<button class="btn-msg-actions btn-icon" type="button" title="Message actions">…</button>' : ''}</div>`
|
|
138
138
|
const textHtml = rendered_text ?? (text ? renderText(text, { userHandle }) : '')
|
|
139
139
|
article.innerHTML = `
|
|
140
140
|
<span class="message-handle${isSelf ? '' : ' dm-trigger'}" data-user-id="${escHtml(user_id)}" title="${isSelf ? '' : 'Send a direct message'}">${escHtml(user_display_name ?? user_id)}</span>
|
|
@@ -547,6 +547,9 @@ details summary {
|
|
|
547
547
|
.message-text h3,.message-text h4 { font-size: 1em; }
|
|
548
548
|
.message-text ul,.message-text ol { margin: 4px 0; padding-left: 1.75em; }
|
|
549
549
|
.message-text li { margin: 2px 0; }
|
|
550
|
+
.message-text .task-list-item { list-style: none; margin-left: -1.25em; }
|
|
551
|
+
.message-text .task-list-item-checkbox { margin-right: 6px; cursor: pointer; vertical-align: middle; position: relative; top: -1px; }
|
|
552
|
+
.message-text .task-list-item:has(.task-list-item-checkbox:checked) { text-decoration: line-through; color: var(--text-muted); }
|
|
550
553
|
.message-text code { font-family: var(--font-mono, monospace); font-size: 0.875em; background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 3px; padding: 1px 4px; }
|
|
551
554
|
.message-text pre { background: var(--bg-input, var(--bg-sidebar)); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 14px; overflow-x: auto; margin: 6px 0; }
|
|
552
555
|
.message-text pre code { background: none; padding: 0; font-size: 0.85em; }
|
|
@@ -1800,6 +1803,9 @@ article.message { position: relative; }
|
|
|
1800
1803
|
z-index: 10;
|
|
1801
1804
|
}
|
|
1802
1805
|
article.message:hover .message-hover-actions { opacity: 1; pointer-events: auto; }
|
|
1806
|
+
.quick-picks { display: contents; }
|
|
1807
|
+
.quick-picks:not(:empty) + .btn-react { border-left: 1px solid var(--border); margin-left: 1px; padding-left: 6px; }
|
|
1808
|
+
.btn-quick-react,
|
|
1803
1809
|
.btn-react,
|
|
1804
1810
|
.btn-msg-actions {
|
|
1805
1811
|
background: none;
|
|
@@ -1812,6 +1818,7 @@ article.message:hover .message-hover-actions { opacity: 1; pointer-events: auto;
|
|
|
1812
1818
|
color: var(--text-secondary);
|
|
1813
1819
|
transition: background var(--transition), color var(--transition);
|
|
1814
1820
|
}
|
|
1821
|
+
.btn-quick-react:hover,
|
|
1815
1822
|
.btn-react:hover,
|
|
1816
1823
|
.btn-msg-actions:hover {
|
|
1817
1824
|
background: color-mix(in srgb, var(--accent) 15%, transparent);
|