Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to
- šŸ›(frontend) make summary button fixed to remain visible during scroll #1581
- šŸ›(frontend) fix pdf embed to use full width #1526
- šŸ›(pdf) fix table cell alignment issue in exported documents #1582
- šŸ›(frontend) prevent duplicate emoji when used as first character in t… #1595

## [3.9.0] - 2025-11-10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,22 @@ const DocTitleInput = ({ doc }: DocTitleProps) => {
if (isTopRoot) {
const sanitizedTitle = updateDocTitle(doc, inputText);
setTitleDisplay(sanitizedTitle);
return sanitizedTitle;
} else {
const sanitizedTitle = updateDocTitle(
doc,
emoji ? `${emoji} ${inputText}` : inputText,
);
const { emoji: pastedEmoji } = getEmojiAndTitle(inputText);
const textPreservingPastedEmoji = pastedEmoji
? `\u200B${inputText}`
: inputText;
const finalTitle = emoji
? `${emoji} ${textPreservingPastedEmoji}`
: textPreservingPastedEmoji;

const sanitizedTitle = updateDocTitle(doc, finalTitle);
const { titleWithoutEmoji: sanitizedTitleWithoutEmoji } =
getEmojiAndTitle(sanitizedTitle);

setTitleDisplay(sanitizedTitleWithoutEmoji);
return sanitizedTitleWithoutEmoji;
}
},
[updateDocTitle, doc, emoji, isTopRoot],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ export const getEmojiAndTitle = (title: string) => {
// Use emoji-regex library for comprehensive emoji detection compatible with ES5
const regex = emojiRegex();

// Check if the title starts with an emoji
const match = title.match(regex);
// Ignore leading spaces when checking for a leading emoji
const leadingSpacesLength = title.match(/^\s+/)?.[0]?.length ?? 0;
const trimmedStart = title.slice(leadingSpacesLength);
const match = trimmedStart.match(regex);

if (match && title.startsWith(match[0])) {
if (match && trimmedStart.startsWith(match[0])) {
const emoji = match[0];
const titleWithoutEmoji = title.substring(emoji.length).trim();
const titleWithoutEmoji = trimmedStart.substring(emoji.length).trim();
return { emoji, titleWithoutEmoji };
}

Expand Down
Loading