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

Refactor formatSelection callback #615

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

QichenZhu
Copy link
Contributor

@QichenZhu QichenZhu commented Feb 7, 2025

Details

This PR refactors the formatSelection callback to make it more generic and updates the web example to support format toggling.

Currently, the interface is as follows:

Arguments: selectedText, formatCommand
Returns: formattedText

After this change, the interface will be:

Arguments: text, selectionStart, selectionEnd, formatCommand
Returns: updatedText, cursorOffset

Related Issues

Expensify/App#55088
PROPOSAL: Expensify/App#55088 (comment)

Manual Tests

N/A

Linked PRs


function getFormatRule(formatCommand: string): FormatRule | null {
// We reuse regexes from expensify-common with modified flags, and they don’t sync automatically.
// When expensify-common updates its regexes, we should manually maintain the regex and matchGroup properties here.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should add some comments to expensify-common rules that will remind developers to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will do!

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