@expensify/react-native-live-markdown 0.1.252 → 0.1.253

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.
@@ -29,10 +29,17 @@
29
29
  // After adding a newline at the end of the blockquote, the typing attributes in the next line still contain
30
30
  // NSParagraphStyle with non-zero firstLineHeadIndent and headIntent added by `_updateTypingAttributes` call.
31
31
  // This causes the cursor to be shifted to the right instead of being located at the beginning of the line.
32
- // The following code removes NSParagraphStyle from typing attributes to fix the position of the cursor.
33
- NSMutableDictionary *typingAttributes = [_textView.typingAttributes mutableCopy];
34
- [typingAttributes removeObjectForKey:NSParagraphStyleAttributeName];
35
- _textView.typingAttributes = typingAttributes;
32
+ // The following code resets firstLineHeadIndent and headIndent in NSParagraphStyle in typing attributes
33
+ // in order to fix the position of the cursor.
34
+ NSDictionary<NSAttributedStringKey, id> *typingAttributes = _textView.typingAttributes;
35
+ if (typingAttributes[NSParagraphStyleAttributeName] != nil) {
36
+ NSMutableDictionary *mutableTypingAttributes = [typingAttributes mutableCopy];
37
+ NSMutableParagraphStyle *mutableParagraphStyle = [typingAttributes[NSParagraphStyleAttributeName] mutableCopy];
38
+ mutableParagraphStyle.firstLineHeadIndent = 0;
39
+ mutableParagraphStyle.headIndent = 0;
40
+ mutableTypingAttributes[NSParagraphStyleAttributeName] = mutableParagraphStyle;
41
+ _textView.typingAttributes = mutableTypingAttributes;
42
+ }
36
43
  }
37
44
 
38
45
  // Delegate all remaining calls to the original text input delegate
@@ -49,10 +49,17 @@ using namespace expensify::livemarkdown;
49
49
  // After adding a newline at the end of the blockquote, the typing attributes in the next line still contain
50
50
  // NSParagraphStyle with non-zero firstLineHeadIndent and headIntent added by `_updateTypingAttributes` call.
51
51
  // This causes the cursor to be shifted to the right instead of being located at the beginning of the line.
52
- // The following code removes NSParagraphStyle from typing attributes to fix the position of the cursor.
53
- NSMutableDictionary *typingAttributes = [backedTextInputView.typingAttributes mutableCopy];
54
- [typingAttributes removeObjectForKey:NSParagraphStyleAttributeName];
55
- backedTextInputView.typingAttributes = typingAttributes;
52
+ // The following code resets firstLineHeadIndent and headIndent in NSParagraphStyle in typing attributes
53
+ // in order to fix the position of the cursor.
54
+ NSDictionary<NSAttributedStringKey, id> *typingAttributes = backedTextInputView.typingAttributes;
55
+ if (typingAttributes[NSParagraphStyleAttributeName] != nil) {
56
+ NSMutableDictionary *mutableTypingAttributes = [typingAttributes mutableCopy];
57
+ NSMutableParagraphStyle *mutableParagraphStyle = [typingAttributes[NSParagraphStyleAttributeName] mutableCopy];
58
+ mutableParagraphStyle.firstLineHeadIndent = 0;
59
+ mutableParagraphStyle.headIndent = 0;
60
+ mutableTypingAttributes[NSParagraphStyleAttributeName] = mutableParagraphStyle;
61
+ backedTextInputView.typingAttributes = mutableTypingAttributes;
62
+ }
56
63
  }
57
64
  }
58
65
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expensify/react-native-live-markdown",
3
- "version": "0.1.252",
3
+ "version": "0.1.253",
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",