Skip to content

Conversation

@IvanIhnatsiuk
Copy link
Contributor

Description

Added the ability to get the HTML value from the reference of the EnrichedTextInput itself. This way, we don't need to parse the text with every change, which improves speed.

How to test?

  1. Open app
  2. Write any text in the input
  3. Press on the "Get input's HTML value"
  4. Observe value in the logs

Videos

iOS:

Screen.Recording.2025-11-07.at.13.26.06.mov

Android:

Screen.Recording.2025-11-07.at.13.27.06.mp4

import com.swmansion.enriched.utils.EnrichedParser

@ReactModule(name = EnrichedTextInputModule.NAME)
class EnrichedTextInputModule(val reactContext: ReactApplicationContext) :
Copy link
Member

Choose a reason for hiding this comment

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

I don't like the fact that this PR introduces a native module. Why exactly is that needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is necessary because native commands do not allow you to return any values. If you have any other ideas on how the second option in this list can be implemented without a module, I would be happy to change the current implementation 🙂

- (nonnull NSString *)getHTMLValue:(NSInteger)inputTag {
__block NSString *value = @"";

dispatch_sync(dispatch_get_main_queue(), ^{
Copy link
Member

Choose a reason for hiding this comment

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

I don't like the fact that we need dispatch_sync here. It blocks the current thread.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I have a compromise approach. We can keep this method and add another one

  1. The new method will work like this: On the main or background thread, we can copy the editable/attributed text value and then parse it on the background thread. Since I think the performant work is done in the parser
  2. We can add a BOOOOLD note that the sync method might block the UI thread, and it's not recommended for usage or use it with caution.

It would be nice to hear your point of view 🙂

Co-authored-by: Tomasz Zawadzki <tomekzawadzki98@gmail.com>
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