Skip to content

Commit

Permalink
render large emoji if message contains only emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
slatinsky committed Apr 15, 2023
1 parent faf7e0e commit fa97ec0
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion frontend/src/components/messages/MessageMarkdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
export let guildId: string
let processedContent: string
function messageContainsOnlyEmojis(content: string): boolean {
let regex = /<a?:\w+:\d{17,32}>/g
let matches = content.match(regex)
if (matches) {
return matches.length === content.split(' ').length
}
return false
}
let onlyemojis = messageContainsOnlyEmojis(content)
function escapeHTML(unsafeText: string): string { // source https://stackoverflow.com/a/48054293
let div = document.createElement('div');
div.innerText = unsafeText;
Expand Down Expand Up @@ -83,7 +94,7 @@
$: process(content)
</script>

<span>{@html processedContent}</span>
<span class:onlyemojis={onlyemojis}>{@html processedContent}</span>


<style>
Expand All @@ -93,6 +104,14 @@
height: 22px;
transform: translate(0px, 2px);
}
:global(.onlyemojis .message-emoji),
:global(.onlyemojis .d-emoji) {
width: 50px;
height: 50px;
}
:global(.message-mention) {
color: #D4E0FC;
background-color: #414675;
Expand Down

0 comments on commit fa97ec0

Please sign in to comment.