| 1 | <script lang="ts"> |
| 2 | import MediaAttachmentView from './MediaAttachmentView.svelte'; |
| 3 | import MxcAvatar from './MxcAvatar.svelte'; |
| 4 | import Emoji from './Emoji.svelte'; |
| 5 | import EmojiText from './EmojiText.svelte'; |
| 6 | import MessageText from './MessageText.svelte'; |
| 7 | import ReactionPicker from './ReactionPicker.svelte'; |
| 8 | import LinkCard from './LinkCard.svelte'; |
| 9 | import { mediaUrl, messageMediaUrl } from './api'; |
| 10 | import type { ImagePack, LinkPreview, Person, QuickReaction, ReplyReference, SendState, TimelineContent, TimelineEvent } from './types'; |
| 11 | import { senderLabel } from './types'; |
| 12 | import { formatClock, formatDay, initialsOf, senderHue } from './format'; |
| 13 | import { findUrls } from './urls'; |
| 14 | import { mentionsFromHtml, resolveMentions, stripMarkdownPills } from './mentions'; |
| 15 | |
| 16 | export let itemId: string; |
| 17 | export let event: TimelineEvent; |
| 18 | export let showSender: boolean; |
| 19 | export let reacting: boolean; |
| 20 | export let onReact: (eventId: string, key: string, shortcode?: string) => void; |
| 21 | export let senderAvatar: string | null = null; |
| 22 | export let quickReactions: QuickReaction[] = []; |
| 23 | export let packs: ImagePack[] = []; |
| 24 | export let onQuickChange: (list: QuickReaction[]) => void = () => {}; |
| 25 | export let linkPreviews: Record<string, LinkPreview | null> = {}; |
| 26 | export let loadPreview: ((url: string) => void) | null = null; |
| 27 | export let people: Record<string, Person> = {}; |
| 28 | export let onReply: ((target: ReplyReference) => void) | null = null; |
| 29 | export let onJump: ((eventId: string) => void) | null = null; |
| 30 | export let onEdit: ((eventId: string, body: string) => void) | null = null; |
| 31 | export let editing = false; |
| 32 | export let showSent = true; |
| 33 | export let self: string | null = null; |
| 34 | export let onUser: ((userId: string, x: number, y: number, menu: boolean) => void) | null = null; |
| 35 | export let onCloneSticker: ((eventId: string, body: string, x: number, y: number) => void) | null = null; |
| 36 | export let onMore: ((event: TimelineEvent, x: number, y: number) => void) | null = null; |
| 37 | |
| 38 | function openUser(ev: MouseEvent, menu: boolean): void { |
| 39 | if (!onUser) return; |
| 40 | const rect = (ev.currentTarget as HTMLElement).getBoundingClientRect(); |
| 41 | onUser(event.sender.user_id, menu ? ev.clientX : rect.left, menu ? ev.clientY : rect.bottom + 4, menu); |
| 42 | } |
| 43 | |
| 44 | const PICKER_WIDTH = 320; |
| 45 | const PICKER_HEIGHT = 380; |
| 46 | const PICKER_MARGIN = 8; |
| 47 | const MAX_READERS = 3; |
| 48 | const STATE_LABELS: Record<string, string> = { |
| 49 | 'm.room.pinned_events': 'changed the pinned messages', |
| 50 | 'm.room.power_levels': 'changed the room permissions', |
| 51 | 'm.room.join_rules': 'changed who can join', |
| 52 | 'm.room.history_visibility': 'changed who can read history', |
| 53 | 'm.room.guest_access': 'changed guest access', |
| 54 | 'm.room.canonical_alias': 'changed the room address', |
| 55 | 'm.room.server_acl': 'changed the server access list', |
| 56 | 'm.space.child': 'changed the rooms in this space', |
| 57 | 'm.space.parent': 'changed the parent space', |
| 58 | 'im.ponies.room_emotes': 'updated a sticker pack' |
| 59 | }; |
| 60 | |
| 61 | let row: HTMLDivElement; |
| 62 | let pickerPop: HTMLDivElement | undefined; |
| 63 | let selected = false; |
| 64 | let pickerOpen = false; |
| 65 | let pickerStyle = ''; |
| 66 | |
| 67 | const MEMBERSHIP_LABELS: Record<string, string> = { |
| 68 | Joined: 'joined the room', |
| 69 | Left: 'left the room', |
| 70 | Banned: 'was banned', |
| 71 | Unbanned: 'was unbanned', |
| 72 | Kicked: 'was kicked', |
| 73 | KickedAndBanned: 'was kicked and banned', |
| 74 | Invited: 'was invited', |
| 75 | InvitationAccepted: 'accepted the invite', |
| 76 | InvitationRejected: 'rejected the invite', |
| 77 | InvitationRevoked: 'had the invite revoked', |
| 78 | Knocked: 'requested to join', |
| 79 | KnockAccepted: 'was let in', |
| 80 | KnockRetracted: 'withdrew the request to join', |
| 81 | KnockDenied: 'had the request to join denied' |
| 82 | }; |
| 83 | |
| 84 | $: name = event.sender.display_name ?? people[event.sender.user_id]?.name ?? event.sender.user_id; |
| 85 | $: displayName = event.sender.name_ambiguous ? `${name} (${event.sender.user_id})` : name; |
| 86 | $: readers = event.read_by.map((id) => people[id] ?? { user_id: id, name: id, avatar: null }); |
| 87 | $: interactive = event.content.kind === 'Message' || event.content.kind === 'Sticker' || event.content.kind === 'Poll'; |
| 88 | $: message = event.content.kind === 'Message' ? event.content.message : null; |
| 89 | $: stripped = stripMarkdownPills(message ? (message.media ? message.media.caption : message.body) ?? '' : ''); |
| 90 | $: linked = message ? [...mentionsFromHtml(message.formatted_body), ...stripped.mentions] : []; |
| 91 | $: mentions = resolveMentions(stripped.text, linked); |
| 92 | $: mentionsMe = self !== null && [...linked, ...mentions].some((m) => m.user_id === self); |
| 93 | $: previews = findUrls(stripped.text); |
| 94 | $: bundled = message ? message.link_previews : []; |
| 95 | $: cards = previews |
| 96 | .map((link) => ({ link, preview: bundled.find((b) => b.url === link.href) ?? linkPreviews[link.href] ?? null })) |
| 97 | .filter((c) => c.preview && (c.preview.title || c.preview.description || c.preview.image)); |
| 98 | $: if (loadPreview) { |
| 99 | for (const link of previews) { |
| 100 | if (!bundled.some((b) => b.url === link.href) && !(link.href in linkPreviews)) loadPreview(link.href); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | $: sent = interactive && showSent && event.own && event.send_state.kind === 'Sent' && event.event_id !== null; |
| 105 | |
| 106 | function sendLabel(state: SendState): string { |
| 107 | if (state.kind === 'Failed') return state.will_retry ? 'failed — will retry' : 'failed — not delivered'; |
| 108 | if (state.kind === 'Sending') return 'sending…'; |
| 109 | return ''; |
| 110 | } |
| 111 | |
| 112 | function toggleSelected(e: MouseEvent) { |
| 113 | if (!interactive || (e.target as Element).closest('a, button, input, video, audio, .picker-pop')) return; |
| 114 | selected = !selected; |
| 115 | } |
| 116 | |
| 117 | function deselectOutside(e: PointerEvent) { |
| 118 | if (selected && !pickerOpen && !row.contains(e.target as Node)) selected = false; |
| 119 | } |
| 120 | |
| 121 | function openPicker(e: MouseEvent) { |
| 122 | if (pickerOpen) { |
| 123 | pickerOpen = false; |
| 124 | return; |
| 125 | } |
| 126 | const rect = (e.currentTarget as HTMLElement).getBoundingClientRect(); |
| 127 | const height = Math.min(PICKER_HEIGHT, window.innerHeight - 2 * PICKER_MARGIN); |
| 128 | const below = window.innerHeight - rect.bottom - PICKER_MARGIN >= height; |
| 129 | const top = below ? rect.bottom + 4 : Math.max(PICKER_MARGIN, rect.top - height - 4); |
| 130 | const maxLeft = window.innerWidth - PICKER_WIDTH - PICKER_MARGIN; |
| 131 | const left = Math.max(PICKER_MARGIN, Math.min(rect.right - PICKER_WIDTH, maxLeft)); |
| 132 | pickerStyle = `top:${top}px;left:${left}px;height:${height}px`; |
| 133 | selected = true; |
| 134 | pickerOpen = true; |
| 135 | } |
| 136 | |
| 137 | function closePicker() { |
| 138 | pickerOpen = false; |
| 139 | } |
| 140 | |
| 141 | function isImageKey(key: string): boolean { |
| 142 | return key.startsWith('mxc://') || packs.some((p) => p.images.some((i) => i.reaction_key === key)); |
| 143 | } |
| 144 | |
| 145 | function react(key: string, shortcode: string | null) { |
| 146 | if (shortcode && isImageKey(key)) onReact(event.event_id ?? '', key, shortcode); |
| 147 | else onReact(event.event_id ?? '', key); |
| 148 | } |
| 149 | |
| 150 | function reply() { |
| 151 | if (!event.event_id || !onReply) return; |
| 152 | onReply({ |
| 153 | event_id: event.event_id, |
| 154 | details: { kind: 'Ready', sender: event.sender, content: event.content, timestamp_ms: event.timestamp_ms } |
| 155 | }); |
| 156 | } |
| 157 | |
| 158 | $: editableBody = |
| 159 | event.own && event.editable && event.event_id && event.content.kind === 'Message' && event.content.message.kind === 'Text' |
| 160 | ? event.content.message.body |
| 161 | : null; |
| 162 | |
| 163 | function edit() { |
| 164 | if (!event.event_id || editableBody === null || !onEdit) return; |
| 165 | onEdit(event.event_id, editableBody); |
| 166 | } |
| 167 | |
| 168 | function reactorNames(senders: string[]): string { |
| 169 | const names = senders.map((id) => people[id]?.name ?? id); |
| 170 | if (names.length <= 12) return names.join(', '); |
| 171 | return `${names.slice(0, 12).join(', ')} and ${names.length - 12} more`; |
| 172 | } |
| 173 | |
| 174 | function pick(key: string, shortcode: string | null) { |
| 175 | pickerOpen = false; |
| 176 | react(key, shortcode); |
| 177 | } |
| 178 | |
| 179 | function closeOnScroll(e: Event) { |
| 180 | if (pickerOpen && !pickerPop?.contains(e.target as Node)) pickerOpen = false; |
| 181 | } |
| 182 | |
| 183 | function actorLabel(userId: string, name: string | null): string { |
| 184 | return name ?? people[userId]?.name ?? userId; |
| 185 | } |
| 186 | |
| 187 | function replyPreview(content: TimelineContent): string { |
| 188 | if (content.kind === 'Message') return stripMarkdownPills(content.message.body).text; |
| 189 | if (content.kind === 'Sticker') return content.body || 'Sticker'; |
| 190 | if (content.kind === 'Poll') return `Poll: ${content.question}`; |
| 191 | if (content.kind === 'Redacted') return 'Message deleted'; |
| 192 | if (content.kind === 'UnableToDecrypt') return 'Unable to decrypt'; |
| 193 | return systemLine(content); |
| 194 | } |
| 195 | |
| 196 | function systemLine(content: TimelineContent, actor = displayName): string { |
| 197 | switch (content.kind) { |
| 198 | case 'Redacted': |
| 199 | return 'Message deleted'; |
| 200 | case 'UnableToDecrypt': |
| 201 | return `Message from ${actor} could not be decrypted`; |
| 202 | case 'Membership': { |
| 203 | const who = actorLabel(content.user_id, content.display_name); |
| 204 | return `${who} ${MEMBERSHIP_LABELS[content.change] ?? 'updated their membership'}`; |
| 205 | } |
| 206 | case 'Profile': { |
| 207 | const who = actorLabel(content.user_id, null); |
| 208 | const parts: string[] = []; |
| 209 | if (content.display_name) { |
| 210 | parts.push( |
| 211 | content.display_name.new |
| 212 | ? `changed their display name to "${content.display_name.new}"` |
| 213 | : 'removed their display name' |
| 214 | ); |
| 215 | } |
| 216 | if (content.avatar) parts.push('changed their avatar'); |
| 217 | return `${who} ${parts.length > 0 ? parts.join(' and ') : 'updated their profile'}`; |
| 218 | } |
| 219 | case 'RoomName': |
| 220 | return content.name |
| 221 | ? `${actor} changed the room name to "${content.name}"` |
| 222 | : `${actor} removed the room name`; |
| 223 | case 'RoomTopic': |
| 224 | return content.topic |
| 225 | ? `${actor} changed the topic to "${content.topic}"` |
| 226 | : `${actor} removed the topic`; |
| 227 | case 'RoomAvatar': |
| 228 | return content.avatar ? `${actor} changed the room avatar` : `${actor} removed the room avatar`; |
| 229 | case 'EncryptionEnabled': |
| 230 | return `${actor} enabled encryption in this room`; |
| 231 | case 'RoomCreated': |
| 232 | return `${actor} created the room`; |
| 233 | case 'RoomUpgraded': |
| 234 | return `${actor} upgraded the room to a new version`; |
| 235 | case 'OtherState': |
| 236 | return `${actor} ${STATE_LABELS[content.event_type] ?? `sent a state event (${content.event_type})`}`; |
| 237 | case 'Other': |
| 238 | return `${actor} sent an event (${content.event_type})`; |
| 239 | default: |
| 240 | return actor; |
| 241 | } |
| 242 | } |
| 243 | </script> |
| 244 | |
| 245 | <svelte:window |
| 246 | on:pointerdown={deselectOutside} |
| 247 | on:keydown={(e) => e.key === 'Escape' && (selected = false)} |
| 248 | on:scroll|capture={closeOnScroll} |
| 249 | on:resize={closePicker} |
| 250 | /> |
| 251 | |
| 252 | <!-- svelte-ignore a11y_click_events_have_key_events a11y_no_static_element_interactions --> |
| 253 | <div |
| 254 | class="msg" |
| 255 | class:own={event.own} |
| 256 | class:editing |
| 257 | class:mentioned={mentionsMe} |
| 258 | class:system={!interactive} |
| 259 | class:has-readers={interactive && readers.length > 0} |
| 260 | class:selected |
| 261 | data-item={itemId} |
| 262 | data-event={event.event_id} |
| 263 | bind:this={row} |
| 264 | on:click={toggleSelected} |
| 265 | > |
| 266 | {#if interactive && event.event_id} |
| 267 | <div class="actions" role="toolbar" aria-label={`Actions for message from ${displayName}`}> |
| 268 | {#each quickReactions as r (r.key)} |
| 269 | {@const label = r.shortcode ? `:${r.shortcode}:` : r.key} |
| 270 | <button |
| 271 | type="button" |
| 272 | title={`React ${label}`} |
| 273 | aria-label={`React ${label} to message from ${displayName}`} |
| 274 | disabled={reacting} |
| 275 | on:click={() => react(r.key, r.shortcode)} |
| 276 | > |
| 277 | {#if r.key.startsWith('mxc://')} |
| 278 | <img class="emote" src={mediaUrl(r.key) ?? ''} alt="" /> |
| 279 | {:else} |
| 280 | <Emoji emoji={r.key} size={18} /> |
| 281 | {/if} |
| 282 | </button> |
| 283 | {/each} |
| 284 | <button |
| 285 | type="button" |
| 286 | title="Add reaction" |
| 287 | aria-label={`Add reaction to message from ${displayName}`} |
| 288 | aria-haspopup="dialog" |
| 289 | aria-expanded={pickerOpen} |
| 290 | on:pointerdown|stopPropagation |
| 291 | on:click={openPicker} |
| 292 | > |
| 293 | ☺+ |
| 294 | </button> |
| 295 | {#if onCloneSticker && event.content.kind === 'Sticker'} |
| 296 | {@const stickerBody = event.content.body} |
| 297 | {@const stickerId = event.event_id} |
| 298 | <button |
| 299 | type="button" |
| 300 | title="Clone sticker" |
| 301 | aria-label="Clone sticker to one of your packs" |
| 302 | on:click|stopPropagation={(ev) => onCloneSticker?.(stickerId, stickerBody, ev.clientX, ev.clientY)} |
| 303 | > |
| 304 | ⧉ |
| 305 | </button> |
| 306 | {/if} |
| 307 | {#if onReply} |
| 308 | <button |
| 309 | type="button" |
| 310 | title="Reply" |
| 311 | aria-label={`Reply to message from ${displayName}`} |
| 312 | on:click|stopPropagation={reply} |
| 313 | > |
| 314 | ↩ |
| 315 | </button> |
| 316 | {/if} |
| 317 | {#if onEdit && editableBody !== null} |
| 318 | <button type="button" title="Edit" aria-label="Edit your message" on:click|stopPropagation={edit}> |
| 319 | ✎ |
| 320 | </button> |
| 321 | {/if} |
| 322 | {#if onMore} |
| 323 | <button |
| 324 | type="button" |
| 325 | title="More" |
| 326 | aria-label={`More actions for message from ${displayName}`} |
| 327 | aria-haspopup="menu" |
| 328 | on:click|stopPropagation={(ev) => onMore?.(event, ev.clientX, ev.clientY)} |
| 329 | > |
| 330 | ⋯ |
| 331 | </button> |
| 332 | {/if} |
| 333 | </div> |
| 334 | {#if pickerOpen} |
| 335 | <div class="picker-pop" style={pickerStyle} bind:this={pickerPop}> |
| 336 | <ReactionPicker {packs} quick={quickReactions} onPick={pick} {onQuickChange} onClose={closePicker} /> |
| 337 | </div> |
| 338 | {/if} |
| 339 | {/if} |
| 340 | {#if showSender} |
| 341 | <button |
| 342 | type="button" |
| 343 | class="user-hit" |
| 344 | tabindex="-1" |
| 345 | aria-hidden="true" |
| 346 | on:click|stopPropagation={(ev) => openUser(ev, false)} |
| 347 | on:contextmenu|preventDefault|stopPropagation={(ev) => openUser(ev, true)} |
| 348 | > |
| 349 | {#if senderAvatar} |
| 350 | <MxcAvatar mxc={senderAvatar} label={name} size={34} /> |
| 351 | {:else} |
| 352 | <span class="avatar" style={`background:hsl(${senderHue(event.sender.user_id)} 35% 32%)`}> |
| 353 | {initialsOf(name)} |
| 354 | </span> |
| 355 | {/if} |
| 356 | </button> |
| 357 | {:else} |
| 358 | <div class="avatar-spacer" aria-hidden="true"> |
| 359 | <span class="hover-time">{formatClock(event.timestamp_ms)}</span> |
| 360 | </div> |
| 361 | {/if} |
| 362 | <div class="msg-body"> |
| 363 | {#if showSender} |
| 364 | <div class="msg-head"> |
| 365 | <button |
| 366 | type="button" |
| 367 | class="sender" |
| 368 | style={`color:hsl(${senderHue(event.sender.user_id)} 70% var(--name-lightness))`} |
| 369 | on:click|stopPropagation={(ev) => openUser(ev, false)} |
| 370 | on:contextmenu|preventDefault|stopPropagation={(ev) => openUser(ev, true)} |
| 371 | > |
| 372 | {displayName} |
| 373 | </button> |
| 374 | <time class="time" datetime={new Date(event.timestamp_ms).toISOString()}> |
| 375 | {formatDay(event.timestamp_ms)} {formatClock(event.timestamp_ms)} |
| 376 | </time> |
| 377 | {#if event.content.kind === 'Message' && event.content.message.edited} |
| 378 | <span class="edited" title="Edited">(edited)</span> |
| 379 | {/if} |
| 380 | </div> |
| 381 | {/if} |
| 382 | {#if event.reply_to} |
| 383 | {@const target = event.reply_to.event_id} |
| 384 | <button |
| 385 | type="button" |
| 386 | class="reply-quote" |
| 387 | disabled={!onJump} |
| 388 | title="Jump to the original message" |
| 389 | on:click|stopPropagation={() => onJump?.(target)} |
| 390 | > |
| 391 | {#if event.reply_to.details.kind === 'Ready'} |
| 392 | <span class="reply-sender">{event.reply_to.details.sender.display_name ?? people[event.reply_to.details.sender.user_id]?.name ?? senderLabel(event.reply_to.details.sender)}</span> |
| 393 | <span class="reply-text"><EmojiText text={replyPreview(event.reply_to.details.content)} /></span> |
| 394 | {:else if event.reply_to.details.kind === 'Pending'} |
| 395 | Loading reply… |
| 396 | {:else} |
| 397 | Reply unavailable |
| 398 | {/if} |
| 399 | </button> |
| 400 | {/if} |
| 401 | |
| 402 | {#if event.content.kind === 'Message'} |
| 403 | {@const m = event.content.message} |
| 404 | {#if stripped.text} |
| 405 | <div class="text" class:emote={m.kind === 'Emote'} class:notice={m.kind === 'Notice' || m.kind === 'ServerNotice'}>{#if m.kind === 'Emote'}* {displayName} {/if}<MessageText text={stripped.text} html={m.formatted_body} jumbo={m.kind === 'Text'} {mentions} {self} nameOf={(id) => people[id]?.name ?? null} />{#if m.edited && !showSender}<span class="edited" title="Edited">(edited)</span>{/if}</div> |
| 406 | {/if} |
| 407 | {#if m.media} |
| 408 | <MediaAttachmentView attachment={m.media} /> |
| 409 | {/if} |
| 410 | {#if cards.length > 0} |
| 411 | <div class="link-previews"> |
| 412 | {#each cards as card (card.link.href)} |
| 413 | <LinkCard link={card.link} preview={card.preview} /> |
| 414 | {/each} |
| 415 | </div> |
| 416 | {/if} |
| 417 | {:else if event.content.kind === 'Sticker'} |
| 418 | {#if event.content.media} |
| 419 | <MediaAttachmentView attachment={event.content.media} /> |
| 420 | {:else if event.content.body}<p class="text"><EmojiText text={event.content.body} /></p>{/if} |
| 421 | {:else if event.content.kind === 'Poll'} |
| 422 | <p class="text">📊 {event.content.question}</p> |
| 423 | {:else} |
| 424 | <p class="system-line">{systemLine(event.content, displayName)}</p> |
| 425 | {/if} |
| 426 | |
| 427 | {#if interactive && event.reactions.length > 0} |
| 428 | <div class="reactions" aria-label="Reactions"> |
| 429 | {#each event.reactions as r (r.key)} |
| 430 | <button |
| 431 | type="button" |
| 432 | class="reaction" |
| 433 | class:mine={r.own} |
| 434 | aria-label={`${r.shortcode ? `:${r.shortcode}:` : r.key.startsWith('mxc://') ? 'custom emote' : r.key}, ${r.count} reaction${r.count === 1 ? '' : 's'}`} |
| 435 | disabled={!event.event_id || reacting} |
| 436 | on:click={() => event.event_id && onReact(event.event_id, r.key)} |
| 437 | > |
| 438 | {#if r.image} |
| 439 | <img class="emote" src={messageMediaUrl(r.image, 'Thumbnail')} alt={r.shortcode ?? ''} title={r.shortcode ?? ''} /> |
| 440 | {:else if r.key.startsWith('mxc://')} |
| 441 | <img class="emote" src={mediaUrl(r.key) ?? ''} alt="" /> |
| 442 | {:else} |
| 443 | <Emoji emoji={r.key} size={16} /> |
| 444 | {/if} |
| 445 | <span class="count">{r.count}</span> |
| 446 | <span class="reactors" role="tooltip" id={`${itemId}-reactors-${r.key}`}> |
| 447 | <span class="reactors-key">{r.shortcode ? `:${r.shortcode}:` : r.key.startsWith('mxc://') ? 'custom emote' : r.key}</span> |
| 448 | {reactorNames(r.senders)} |
| 449 | </span> |
| 450 | </button> |
| 451 | {/each} |
| 452 | </div> |
| 453 | {/if} |
| 454 | {#if sent}<span class="sent-tick" title="Sent" aria-label="Sent">✓</span>{/if} |
| 455 | {#if interactive && sendLabel(event.send_state)} |
| 456 | <div class="msg-foot"> |
| 457 | <span class="sendstate" class:failed={event.send_state.kind === 'Failed'}>{sendLabel(event.send_state)}</span> |
| 458 | </div> |
| 459 | {/if} |
| 460 | {#if interactive && readers.length > 0} |
| 461 | {@const seenBy = `Seen by ${readers.map((r) => r.name).join(', ')}`} |
| 462 | <div class="readby" title={seenBy} aria-label={seenBy} role="img"> |
| 463 | {#each readers.slice(0, MAX_READERS) as r (r.user_id)} |
| 464 | <MxcAvatar mxc={r.avatar} label={r.name} size={16} /> |
| 465 | {/each} |
| 466 | {#if readers.length > MAX_READERS}<span class="more">+{readers.length - MAX_READERS}</span>{/if} |
| 467 | </div> |
| 468 | {/if} |
| 469 | </div> |
| 470 | </div> |
| 471 | |
| 472 | <style> |
| 473 | .msg { position: relative; display: flex; gap: 10px; padding: var(--msg-gap, 3px) 0; } |
| 474 | .msg:hover, .msg.selected { background: var(--hover-faint); } |
| 475 | .msg:hover .hover-time, .msg.selected .hover-time { opacity: 1; } |
| 476 | .msg-foot { display: flex; align-items: center; gap: 8px; } |
| 477 | .sendstate { font-size: 11px; color: var(--muted); } |
| 478 | .sent-tick { position: absolute; right: 12px; bottom: 4px; font-size: 11px; color: var(--muted); } |
| 479 | .sendstate.failed { color: var(--danger); } |
| 480 | .link-previews { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-width: 420px; } |
| 481 | .avatar { |
| 482 | flex: none; |
| 483 | width: 34px; height: 34px; |
| 484 | border-radius: 50%; |
| 485 | display: grid; place-items: center; |
| 486 | font-size: 12px; font-weight: 700; color: #fff; |
| 487 | } |
| 488 | .avatar-spacer { flex: none; width: 34px; padding-top: 2px; text-align: center; } |
| 489 | .hover-time { opacity: 0; font-size: 10.5px; color: var(--muted); } |
| 490 | .msg-body { min-width: 0; flex: 1; } |
| 491 | .msg-head { display: flex; align-items: baseline; gap: 8px; } |
| 492 | .sender { font-weight: 650; font-size: 13.5px; padding: 0; border: none; background: none; font-family: inherit; cursor: pointer; } |
| 493 | .sender:hover { text-decoration: underline; } |
| 494 | .user-hit { flex: none; align-self: flex-start; padding: 0; border: none; background: none; border-radius: 50%; cursor: pointer; } |
| 495 | .time, .edited { color: var(--muted); font-size: 11.5px; } |
| 496 | .text .edited { margin-left: 6px; } |
| 497 | .msg.editing { background: color-mix(in srgb, var(--accent) 10%, transparent); } |
| 498 | .msg.mentioned { background: color-mix(in srgb, var(--warn) 8%, transparent); box-shadow: inset 2px 0 0 var(--warn); } |
| 499 | .reply-quote { |
| 500 | display: flex; gap: 6px; align-items: baseline; |
| 501 | max-width: min(100%, 520px); |
| 502 | border: none; |
| 503 | border-left: 2px solid var(--accent); |
| 504 | padding: 2px 8px; |
| 505 | margin: 2px 0 4px; |
| 506 | color: var(--muted); |
| 507 | font-size: 12.5px; |
| 508 | text-align: left; |
| 509 | background: var(--bg-soft); |
| 510 | border-radius: 0 var(--r-sm) var(--r-sm) 0; |
| 511 | cursor: pointer; |
| 512 | } |
| 513 | .reply-quote:disabled { cursor: default; } |
| 514 | .reply-quote:hover:not(:disabled) { color: var(--text); } |
| 515 | .reply-sender { flex: none; font-weight: 650; } |
| 516 | .reply-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } |
| 517 | :global(.msg.flash) { animation: reply-flash 1.2s ease-out; } |
| 518 | @keyframes -global-reply-flash { from { background: color-mix(in srgb, var(--accent) 22%, transparent); } } |
| 519 | .text { |
| 520 | margin: 1px 0 2px; |
| 521 | font-size: 14px; |
| 522 | line-height: var(--msg-line-height, 1.5); |
| 523 | white-space: pre-wrap; |
| 524 | overflow-wrap: anywhere; |
| 525 | } |
| 526 | .text.emote { font-style: italic; color: var(--muted); } |
| 527 | .text.notice { color: var(--muted); } |
| 528 | .system-line { color: var(--muted); font-size: 12.5px; font-style: italic; margin: 1px 0; } |
| 529 | .msg.system { opacity: 0.85; --msg-gap: 1.5px; } |
| 530 | .msg.system .avatar-spacer { height: 0; padding-top: 0; } |
| 531 | .reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: max(4px, var(--msg-gap, 3px)); } |
| 532 | .reaction { |
| 533 | display: inline-flex; align-items: center; gap: 4px; |
| 534 | background: var(--bg-soft); |
| 535 | border: 1px solid var(--border); |
| 536 | border-radius: var(--r-sm); |
| 537 | padding: 1px 8px; |
| 538 | font-size: 13px; |
| 539 | color: var(--text); |
| 540 | cursor: pointer; |
| 541 | } |
| 542 | .reaction { position: relative; } |
| 543 | .reactors { |
| 544 | position: absolute; |
| 545 | left: 0; |
| 546 | bottom: calc(100% + 6px); |
| 547 | z-index: 15; |
| 548 | display: none; |
| 549 | width: max-content; |
| 550 | max-width: 260px; |
| 551 | padding: 6px 9px; |
| 552 | border: 1px solid var(--border); |
| 553 | border-radius: var(--r-md); |
| 554 | background: var(--panel-2); |
| 555 | box-shadow: 0 6px 18px rgb(0 0 0 / 0.3); |
| 556 | color: var(--text); |
| 557 | font-size: 12px; |
| 558 | line-height: 1.35; |
| 559 | text-align: left; |
| 560 | white-space: normal; |
| 561 | pointer-events: none; |
| 562 | } |
| 563 | .reactors-key { display: block; color: var(--muted); font-size: 11px; } |
| 564 | .reaction:hover .reactors, .reaction:focus-visible .reactors { display: block; } |
| 565 | .reaction.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); } |
| 566 | .reaction:disabled { cursor: default; opacity: 0.85; } |
| 567 | .msg.has-readers .msg-body { padding-right: 72px; } |
| 568 | .readby { position: absolute; right: 12px; bottom: 4px; display: flex; align-items: center; } |
| 569 | .readby > :global(* + *) { margin-left: -4px; } |
| 570 | .readby :global(.mxc-avatar), .readby :global(.mxc-fallback) { box-shadow: 0 0 0 1.5px var(--bg); } |
| 571 | .readby .more { margin-left: 3px; font-size: 10.5px; color: var(--muted); } |
| 572 | .actions { |
| 573 | position: absolute; top: -12px; right: 10px; z-index: 2; |
| 574 | display: flex; gap: 2px; |
| 575 | padding: 2px; |
| 576 | background: var(--bg-soft); |
| 577 | border: 1px solid var(--border); |
| 578 | border-radius: var(--r-md); |
| 579 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); |
| 580 | opacity: 0; |
| 581 | visibility: hidden; |
| 582 | pointer-events: none; |
| 583 | } |
| 584 | .msg:hover .actions, .msg:focus-within .actions, .msg.selected .actions { opacity: 1; visibility: visible; pointer-events: auto; } |
| 585 | :global(.timeline-inner:has(.msg.selected)) .msg:not(.selected) .actions { opacity: 0; visibility: hidden; pointer-events: none; } |
| 586 | .actions button { |
| 587 | background: transparent; |
| 588 | border: 1px solid transparent; |
| 589 | border-radius: var(--r-sm); |
| 590 | cursor: pointer; |
| 591 | font-size: 14px; |
| 592 | padding: 1px 5px; |
| 593 | } |
| 594 | .actions button:hover:not(:disabled) { border-color: var(--border); background: var(--hover); } |
| 595 | .actions button:disabled { opacity: 0.4; cursor: default; } |
| 596 | .emote { width: 1.3em; height: 1.3em; object-fit: contain; vertical-align: middle; } |
| 597 | .picker-pop { position: fixed; z-index: 60; width: 320px; max-width: calc(100vw - 16px); animation: pop-in var(--pop); } |
| 598 | </style> |