aboutsummaryrefslogtreecommitdiff
path: root/client-web
diff options
context:
space:
mode:
authorkirill <polferov@live.com>2024-12-08 23:12:59 +0100
committerkirill <polferov@live.com>2024-12-08 23:12:59 +0100
commit169b675f9d725ae94d9a1fdc6ae67932b4a4a163 (patch)
tree3a02e3509ca166c9e0e8b535dadd6c10e6f7c6c0 /client-web
parent440c12ac024e84f166eaa4115ef6715c39de2eea (diff)
downloadkeks-meet-169b675f9d725ae94d9a1fdc6ae67932b4a4a163.tar
keks-meet-169b675f9d725ae94d9a1fdc6ae67932b4a4a163.tar.bz2
keks-meet-169b675f9d725ae94d9a1fdc6ae67932b4a4a163.tar.zst
add hyperlink support for chat
Diffstat (limited to 'client-web')
-rw-r--r--client-web/source/chat.ts15
-rw-r--r--client-web/style/chat.sass3
2 files changed, 16 insertions, 2 deletions
diff --git a/client-web/source/chat.ts b/client-web/source/chat.ts
index 1eb9fa5..4531a76 100644
--- a/client-web/source/chat.ts
+++ b/client-web/source/chat.ts
@@ -93,9 +93,20 @@ export class Chat {
el.scrollIntoView({ block: "end", behavior: "smooth", inline: "end" })
}
+ create_text_message(text: string) : HTMLElement {
+ const div = document.createElement("div")
+ div.classList.add("text")
+
+ // test for uris and make them clickable
+ const regex = (/(\b[a-z]{2,15}:\/\/\S+\b)/ig)
+ div.innerText = text // assigning to innerText will escape the html
+ div.innerHTML = div.innerHTML.replaceAll(regex, '<a href="$1" target="_blank" class="chat-link">$1</a>')
+ return div
+ }
+
add_message(sender: User, message: ChatMessage) {
- const els = []
- if (message.text) els.push(e("span", { class: "text" }, message.text))
+ const els : HTMLElement[] = []
+ if (message.text) els.push(this.create_text_message(message.text))
if (message.image) els.push(image_view(message.image, { class: "image" }))
chat_control(true)
diff --git a/client-web/style/chat.sass b/client-web/style/chat.sass
index a2f78fe..1e0c1d6 100644
--- a/client-web/style/chat.sass
+++ b/client-web/style/chat.sass
@@ -36,3 +36,6 @@
border-radius: 5px
padding: 0.5em
box-sizing: border-box
+
+ .chat-link
+ color: var(--ac-light) \ No newline at end of file