Skip to content

Conversation

@Skalakid
Copy link
Contributor

@Skalakid Skalakid commented Sep 18, 2025

Details

This PR fixes moving the cursor to the end of the line using CMD + ➡ or the End key. To fix this problem, we implemented splitting italic and strikethrough markdown types on the starting and ending syntax of the inline code. Because of the HTML structure, we couldn't split the range directly on the inline code. So similarly to other applications like Slack, the styles are applied to the text inside inline code separately. Thanks to that, we could remove the display: inline-block style, which was causing the problem with moving the cursor with CMD + ➡

Screenshot 2025-09-18 at 17 22 46

Related Issues

Expensify/App#69493

Manual Tests

  1. Open the example app
  2. Paste the following text:
_test🚀_
~🚀test~
~_tes🚀t_~
_`test🚀`_
~`🚀test`~
~_`tes🚀t`_~
  1. Verify if strikethrough or italic styles aren't applied to any emoji
  2. Test if emojis or any text aren't duplicated while writing inside the inline code markdowns
  3. Clear input
  4. Paste the following text:
🚀 sample text
  1. Move the cursor to the beginning of the line
  2. Press Cmd + ➡️
  3. Verify if the cursor is moved to the end of the line and doesn't stop on the emoji

Linked PRs

#598 (review)

@Skalakid Skalakid marked this pull request as ready for review September 19, 2025 08:14
Copy link
Collaborator

@jmusial jmusial left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM + one suggestion

* @param baseMarkdownType - The base markdown type to exclude formatting from (e.g., 'italic').
* @param rangesToExclude - The array of MarkdownRange objects representing the ranges to exclude from formatting.
*/
function excludeRangeTypesFromFormatting(ranges: MarkdownRange[], baseMarkdownType: MarkdownType, rangesToExclude: MarkdownRange[]): MarkdownRange[] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB but baseMarkdownType could be an array of types maybe ? would save one loop over rangesToExclude and one line in parseExpensiMark :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would require more changes in the current algorithm. Right now, we need to execute excludeRangeTypesFromFormatting one after another, because otherwise, split ranges start to overlap each other, and it breaks the markdown rendering then

@jmusial jmusial merged commit 48a4d16 into Expensify:main Sep 24, 2025
5 checks passed
@os-botify
Copy link
Contributor

os-botify bot commented Sep 24, 2025

🚀 Published to npm in 0.1.305 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants