Merge pull request #1598 from cryptpad/generated-avatars-display-on-two-lines

Fix emoji avatar handling and team name overflowing in sidebar teams
This commit is contained in:
yflory 2024-09-09 13:27:15 +02:00 committed by GitHub
commit 564748718f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View File

@ -123,8 +123,19 @@ define([
if (!seed) { return; }
return ANIMALS[seed % ANIMALS.length] || '';
};
//this regex identifies both discord and unicode emojis (with optional skin tone modifiers) and complex zwj emoji sequences
const emojiWithZWJRegex = /(?:\p{Extended_Pictographic}(?:\p{Emoji_Modifier}|\uFE0F)?(?:\u200D\p{Extended_Pictographic}(?:\p{Emoji_Modifier}|\uFE0F)?)*|\p{Extended_Pictographic})/gu;
var getPrettyInitials = MT.getPrettyInitials = function (name) {
let matches = name.match(emojiWithZWJRegex);
if (matches && name.startsWith(matches[0])) {
return matches[0];
}
else {
//this is for removing all trailing white characters and unnecessary/redundant emojis
name = name.replace(emojiWithZWJRegex, '');
name = name.replace(/\uFE0F/g, '').replace(/\u200D/g, '').replace(/\u2060/g, '');
name = name.trim();
}
var parts = name.split(/\s+/);
var text;
if (parts.length > 1) {

View File

@ -108,7 +108,7 @@
}
}
.cp-team-cat-header {
justify-content: center;
justify-content: left;
background-color: transparent !important;
box-shadow: none !important;
.avatar_main(30px);
@ -118,6 +118,7 @@
}
media-tag, .cp-avatar-default {
margin-right: 3px;
flex-shrink: 0;
}
media-tag {
order: -1;
@ -125,7 +126,12 @@
cursor: default !important;
font-size: 18px;
span.cp-sidebarlayout-category-name {
max-width: 12rem;
padding-left: 5px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
min-width: 0;
}
}
.cp-team-cat-chat {