-
Notifications
You must be signed in to change notification settings - Fork 20
feat: add ability to get html value imperatively #228
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
base: main
Are you sure you want to change the base?
feat: add ability to get html value imperatively #228
Conversation
| import com.swmansion.enriched.utils.EnrichedParser | ||
|
|
||
| @ReactModule(name = EnrichedTextInputModule.NAME) | ||
| class EnrichedTextInputModule(val reactContext: ReactApplicationContext) : |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(), ^{ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
- 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
- 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>
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?
Videos
iOS:
Screen.Recording.2025-11-07.at.13.26.06.mov
Android:
Screen.Recording.2025-11-07.at.13.27.06.mp4