mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: garbled text displayed on avatars (#6575)
Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
parent
e0f2869374
commit
306e133651
3 changed files with 27 additions and 28 deletions
|
@ -20,9 +20,13 @@ export const getClientColors = (clientId: string, appState: AppState) => {
|
|||
};
|
||||
};
|
||||
|
||||
export const getClientInitials = (userName?: string | null) => {
|
||||
if (!userName?.trim()) {
|
||||
return "?";
|
||||
}
|
||||
return userName.trim()[0].toUpperCase();
|
||||
/**
|
||||
* returns first char, capitalized
|
||||
*/
|
||||
export const getNameInitial = (name?: string | null) => {
|
||||
// first char can be a surrogate pair, hence using codePointAt
|
||||
const firstCodePoint = name?.trim()?.codePointAt(0);
|
||||
return (
|
||||
firstCodePoint ? String.fromCodePoint(firstCodePoint) : "?"
|
||||
).toUpperCase();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue