Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove splitting ranges on emojis on the web #598

Merged
merged 6 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 1 addition & 13 deletions example/src/testConstants.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
const LOCAL_URL = 'http://localhost:19006/';

const EXAMPLE_CONTENT = [
'Hello, *world*!',
'😀🍕🍔',
'https://expensify.com',
'# header1',
'> blockquote',
'`inline code`',
'```\ncodeblock\n```',
'@here',
'@someone@swmansion.com',
'#mention-report',
'![demo image](https://picsum.photos/id/1067/200/300)',
].join('\n');
const EXAMPLE_CONTENT = ['~_😀🍕🍔_~'].join('\n');
Skalakid marked this conversation as resolved.
Show resolved Hide resolved

const INPUT_ID = 'MarkdownInput_Example';
const INPUT_HISTORY_DEBOUNCE_TIME_MS = 150;
Expand Down
13 changes: 8 additions & 5 deletions src/parseExpensiMark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,14 @@ function parseExpensiMark(markdown: string): MarkdownRange[] {
);
return [];
}

let splittedRanges = splitRangesOnEmojis(ranges, 'italic');
splittedRanges = splitRangesOnEmojis(splittedRanges, 'strikethrough');

const sortedRanges = sortRanges(splittedRanges);
let markdownRanges = ranges;
// Blocks applying italic and strikethrough styles to emojis on Android
// TODO: Remove this condition when splitting emojis inside the inline code block will be fixed on the web
if (Platform.OS === 'android') {
Skalakid marked this conversation as resolved.
Show resolved Hide resolved
markdownRanges = splitRangesOnEmojis(markdownRanges, 'italic');
Skalakid marked this conversation as resolved.
Show resolved Hide resolved
markdownRanges = splitRangesOnEmojis(markdownRanges, 'strikethrough');
}
const sortedRanges = sortRanges(markdownRanges);
const groupedRanges = groupRanges(sortedRanges);

return groupedRanges;
Expand Down
8 changes: 7 additions & 1 deletion src/web/utils/blockUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ function addStyleToBlock(targetElement: HTMLElement, type: NodeType, markdownSty
node.style.textDecoration = 'line-through';
break;
case 'emoji':
Object.assign(node.style, {...markdownStyle.emoji, verticalAlign: 'middle'});
Object.assign(node.style, {
...markdownStyle.emoji,
verticalAlign: 'middle',
fontStyle: 'normal',
textDecoration: 'none',
Skalakid marked this conversation as resolved.
Show resolved Hide resolved
display: 'inline-block',
});
break;
case 'mention-here':
Object.assign(node.style, markdownStyle.mentionHere);
Expand Down
Loading