Skip to content

Commit

Permalink
Merge branch 'main' into @tomekzaw/fix-ios-option-key-diacritics
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekzaw committed Feb 22, 2024
2 parents 642651c + 56b3ca8 commit f755217
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 1,209 deletions.
17 changes: 13 additions & 4 deletions ios/RCTBaseTextInputView+Markdown.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,19 @@ - (void)markdown_updateLocalData
{
RCTMarkdownUtils *markdownUtils = [self getMarkdownUtils];
if (markdownUtils != nil) {
UITextRange *range = self.backedTextInputView.selectedTextRange;
NSAttributedString *attributedText = [markdownUtils parseMarkdown:self.backedTextInputView.attributedText];
[self.backedTextInputView setAttributedText:attributedText];
[self.backedTextInputView setSelectedTextRange:range notifyDelegate:YES];
id<RCTBackedTextInputViewProtocol> backedTextInputView = self.backedTextInputView;
NSAttributedString *oldAttributedText = backedTextInputView.attributedText;
NSAttributedString *newAttributedText = [markdownUtils parseMarkdown:oldAttributedText];
UITextRange *range = backedTextInputView.selectedTextRange;

// update attributed text without emitting onSelectionChange event
id<RCTBackedTextInputDelegate> delegate = backedTextInputView.textInputDelegate;
backedTextInputView.textInputDelegate = nil;
[backedTextInputView setAttributedText:newAttributedText];
backedTextInputView.textInputDelegate = delegate;

// restore original selection and emit onSelectionChange event
[backedTextInputView setSelectedTextRange:range notifyDelegate:YES];
}

// Call the original method
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@expensify/react-native-live-markdown",
"version": "0.1.5",
"version": "0.1.12",
"description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
Loading

0 comments on commit f755217

Please sign in to comment.