emojis now display with the correct height

This commit is contained in:
2026-01-27 00:14:34 +01:00
parent 966b04dbaf
commit f03b938fd0

View File

@@ -87,7 +87,7 @@ class UserCommentSystem {
renderEmoji(match, name) {
if (this.customEmojis && this.customEmojis[name]) {
return `<img src="${this.customEmojis[name]}" style="height:24px;vertical-align:middle;" alt="${name}">`;
return `<img src="${this.customEmojis[name]}" style="height:60px;vertical-align:middle;" alt="${name}">`;
}
return match;
}
@@ -106,11 +106,18 @@ class UserCommentSystem {
// Also handle raw > just in case
safe = safe.replace(/^>(?=[^ ])/gm, '> ');
// Fix Images: Server sends <img src="..." ...> -> convert to markdown ![]()
// Fix Images: Server sends <img src="..." ...> -> convert to markdown ![]() or :emoji:
// This avoids them being escaped by our HTML escaping later
safe = safe.replace(/<img\s+[^>]*src="([^"]+)"[^>]*>/g, (match, src) => {
let altMatch = match.match(/alt="([^"]*)"/);
let alt = altMatch ? altMatch[1] : '';
// Check if it's a known emoji (convert back to :code: for consistent rendering)
// We check if the name exists in our map. Validating src is good but name check is usually enough here.
if (alt && this.customEmojis && this.customEmojis[alt]) {
return `:${alt}:`;
}
return `![${alt}](${src})`;
});
@@ -149,23 +156,20 @@ class UserCommentSystem {
// We add a header indicating which item this comment belongs to
return `
<div class="user-comment-wrapper" style="margin-bottom: 20px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 4px;">
<div style="margin-bottom: 10px; font-size: 0.9em; color: #aaa; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 5px;">
Comment on <a href="/${c.item_id}#c${c.id}" style="color: #fff; font-weight: bold;">Item #${c.item_id}</a>
<div class="comment" id="c${c.id}">
<div class="comment-avatar">
<a href="/${c.item_id}">
<img src="/t/${c.item_id}.webp" alt="Item Thumbnail">
</a>
</div>
<div class="comment" id="c${c.id}" style="border:none; padding:0; background:transparent;">
<div class="comment-avatar">
<a href="/${c.item_id}"><img src="/t/${c.item_id}.webp" alt="Item Thumbnail" style="width:50px; height:50px; object-fit:cover; border-radius:4px;"></a>
</div>
<div class="comment-body">
<div class="comment-meta">
<span class="comment-author">${this.username}</span>
<span class="comment-time">${date}</span>
<a href="/${c.item_id}#c${c.id}" class="comment-permalink">#${c.id}</a>
</div>
<div class="comment-content">${content}</div>
<div class="comment-body">
<div class="comment-meta">
<span class="comment-author">${this.username}</span>
<span class="comment-time">${date}</span>
<a href="/${c.item_id}#c${c.id}" class="comment-permalink">#${c.id}</a>
<span class="comment-item-ref">on <a href="/${c.item_id}">Item #${c.item_id}</a></span>
</div>
<div class="comment-content">${content}</div>
</div>
</div>
`;