blob: ae2bdf911a8368546dc99c8639a9f79bbd364a3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<script>
import { marked } from 'marked';
import DOMPurify from 'dompurify';
function scroll(message) {
message.scrollIntoView();
}
let { at, body } = $props();
let renderedBody = $derived(DOMPurify.sanitize(marked.parse(body, { breaks: true })));
</script>
<div class="message relative">
<span class="timestamp chip variant-soft absolute top-0 right-0">{at}</span>
<section use:scroll class="py-1 message-body">
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
{@html renderedBody}
</section>
</div>
<style>
.message .timestamp {
display: none;
}
.message:hover .timestamp {
display: flex;
}
.message-body {
overflow: auto;
max-width: 80vw;
@media (width > 640px) {
/* 21rem is width of the nav bar in full-screen mode. */
max-width: calc(90vw - 21rem);
}
}
.message-body:empty:after {
content: '.';
visibility: hidden;
}
.message-body blockquote {
border-left: 0.25rem solid gray !important;
margin-left: 0.5rem;
padding-left: 0.5rem;
}
</style>
|