@expensify/react-native-live-markdown 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,10 +27,19 @@
27
27
  {
28
28
  RCTMarkdownUtils *markdownUtils = [self getMarkdownUtils];
29
29
  if (markdownUtils != nil) {
30
- UITextRange *range = self.backedTextInputView.selectedTextRange;
31
- NSAttributedString *attributedText = [markdownUtils parseMarkdown:self.backedTextInputView.attributedText];
32
- [self.backedTextInputView setAttributedText:attributedText];
33
- [self.backedTextInputView setSelectedTextRange:range notifyDelegate:YES];
30
+ id<RCTBackedTextInputViewProtocol> backedTextInputView = self.backedTextInputView;
31
+ NSAttributedString *oldAttributedText = backedTextInputView.attributedText;
32
+ NSAttributedString *newAttributedText = [markdownUtils parseMarkdown:oldAttributedText];
33
+ UITextRange *range = backedTextInputView.selectedTextRange;
34
+
35
+ // update attributed text without emitting onSelectionChange event
36
+ id<RCTBackedTextInputDelegate> delegate = backedTextInputView.textInputDelegate;
37
+ backedTextInputView.textInputDelegate = nil;
38
+ [backedTextInputView setAttributedText:newAttributedText];
39
+ backedTextInputView.textInputDelegate = delegate;
40
+
41
+ // restore original selection and emit onSelectionChange event
42
+ [backedTextInputView setSelectedTextRange:range notifyDelegate:YES];
34
43
  }
35
44
 
36
45
  // Call the original method
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expensify/react-native-live-markdown",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",