react-native-enriched 0.2.0 → 0.3.0

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.
Files changed (186) hide show
  1. package/README.md +16 -17
  2. package/android/build.gradle +77 -72
  3. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +21 -0
  4. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +7 -0
  5. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.cpp +156 -0
  6. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h +147 -0
  7. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.cpp +10 -0
  8. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.h +194 -0
  9. package/android/lint.gradle +70 -0
  10. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputConnectionWrapper.kt +140 -0
  11. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt +304 -83
  12. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewLayoutManager.kt +3 -1
  13. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +166 -51
  14. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewPackage.kt +1 -3
  15. package/android/src/main/java/com/swmansion/enriched/MeasurementStore.kt +70 -21
  16. package/android/src/main/java/com/swmansion/enriched/events/MentionHandler.kt +21 -11
  17. package/android/src/main/java/com/swmansion/enriched/events/OnChangeHtmlEvent.kt +8 -9
  18. package/android/src/main/java/com/swmansion/enriched/events/OnChangeSelectionEvent.kt +10 -9
  19. package/android/src/main/java/com/swmansion/enriched/events/OnChangeStateDeprecatedEvent.kt +21 -0
  20. package/android/src/main/java/com/swmansion/enriched/events/OnChangeStateEvent.kt +9 -12
  21. package/android/src/main/java/com/swmansion/enriched/events/OnChangeTextEvent.kt +10 -10
  22. package/android/src/main/java/com/swmansion/enriched/events/OnInputBlurEvent.kt +7 -9
  23. package/android/src/main/java/com/swmansion/enriched/events/OnInputFocusEvent.kt +7 -9
  24. package/android/src/main/java/com/swmansion/enriched/events/OnInputKeyPressEvent.kt +27 -0
  25. package/android/src/main/java/com/swmansion/enriched/events/OnLinkDetectedEvent.kt +13 -11
  26. package/android/src/main/java/com/swmansion/enriched/events/OnMentionDetectedEvent.kt +10 -9
  27. package/android/src/main/java/com/swmansion/enriched/events/OnMentionEvent.kt +9 -8
  28. package/android/src/main/java/com/swmansion/enriched/events/OnRequestHtmlResultEvent.kt +32 -0
  29. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBlockQuoteSpan.kt +24 -5
  30. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBoldSpan.kt +8 -1
  31. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedCodeBlockSpan.kt +10 -2
  32. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH1Span.kt +8 -1
  33. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH2Span.kt +8 -1
  34. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH3Span.kt +8 -1
  35. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH4Span.kt +24 -0
  36. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH5Span.kt +24 -0
  37. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH6Span.kt +24 -0
  38. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedImageSpan.kt +34 -17
  39. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedInlineCodeSpan.kt +8 -1
  40. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedItalicSpan.kt +7 -1
  41. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedLinkSpan.kt +10 -4
  42. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedMentionSpan.kt +14 -11
  43. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedOrderedListSpan.kt +18 -11
  44. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedSpans.kt +174 -72
  45. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedStrikeThroughSpan.kt +7 -1
  46. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnderlineSpan.kt +7 -1
  47. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnorderedListSpan.kt +11 -5
  48. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedBlockSpan.kt +3 -2
  49. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedHeadingSpan.kt +1 -2
  50. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedInlineSpan.kt +1 -2
  51. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedParagraphSpan.kt +3 -2
  52. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedSpan.kt +5 -0
  53. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedZeroWidthSpaceSpan.kt +1 -2
  54. package/android/src/main/java/com/swmansion/enriched/spans/utils/ForceRedrawSpan.kt +2 -1
  55. package/android/src/main/java/com/swmansion/enriched/styles/HtmlStyle.kt +155 -20
  56. package/android/src/main/java/com/swmansion/enriched/styles/InlineStyles.kt +25 -8
  57. package/android/src/main/java/com/swmansion/enriched/styles/ListStyles.kt +60 -20
  58. package/android/src/main/java/com/swmansion/enriched/styles/ParagraphStyles.kt +161 -25
  59. package/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt +128 -52
  60. package/android/src/main/java/com/swmansion/enriched/utils/AsyncDrawable.kt +10 -7
  61. package/android/src/main/java/com/swmansion/enriched/utils/EnrichedConstants.kt +11 -0
  62. package/android/src/main/java/com/swmansion/enriched/utils/EnrichedEditableFactory.kt +17 -0
  63. package/android/src/main/java/com/swmansion/enriched/utils/EnrichedParser.java +136 -87
  64. package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSelection.kt +71 -42
  65. package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSpanState.kt +183 -48
  66. package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSpannable.kt +82 -0
  67. package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSpannableStringBuilder.kt +15 -0
  68. package/android/src/main/java/com/swmansion/enriched/utils/Utils.kt +0 -70
  69. package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedSpanWatcher.kt +46 -14
  70. package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedTextWatcher.kt +34 -11
  71. package/android/src/main/new_arch/CMakeLists.txt +6 -0
  72. package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.cpp +6 -6
  73. package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.h +6 -6
  74. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputComponentDescriptor.h +19 -19
  75. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.cpp +40 -51
  76. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.h +13 -15
  77. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.cpp +23 -21
  78. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.h +35 -36
  79. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.cpp +4 -4
  80. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.h +13 -14
  81. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/conversions.h +33 -14
  82. package/ios/EnrichedTextInputView.h +26 -14
  83. package/ios/EnrichedTextInputView.mm +1209 -586
  84. package/ios/config/InputConfig.h +24 -6
  85. package/ios/config/InputConfig.mm +154 -38
  86. package/ios/{utils → extensions}/ColorExtension.mm +7 -5
  87. package/ios/extensions/FontExtension.mm +106 -0
  88. package/ios/{utils → extensions}/LayoutManagerExtension.h +1 -1
  89. package/ios/extensions/LayoutManagerExtension.mm +396 -0
  90. package/ios/{utils → extensions}/StringExtension.mm +19 -16
  91. package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.cpp +156 -0
  92. package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.h +147 -0
  93. package/ios/generated/RNEnrichedTextInputViewSpec/Props.cpp +10 -0
  94. package/ios/generated/RNEnrichedTextInputViewSpec/Props.h +194 -0
  95. package/ios/generated/RNEnrichedTextInputViewSpec/RCTComponentViewHelpers.h +95 -0
  96. package/ios/inputParser/InputParser.h +5 -5
  97. package/ios/inputParser/InputParser.mm +864 -380
  98. package/ios/inputTextView/InputTextView.h +1 -1
  99. package/ios/inputTextView/InputTextView.mm +100 -59
  100. package/ios/{utils → interfaces}/BaseStyleProtocol.h +2 -2
  101. package/ios/interfaces/ImageAttachment.h +10 -0
  102. package/ios/interfaces/ImageAttachment.mm +36 -0
  103. package/ios/interfaces/LinkRegexConfig.h +19 -0
  104. package/ios/interfaces/LinkRegexConfig.mm +37 -0
  105. package/ios/interfaces/MediaAttachment.h +23 -0
  106. package/ios/interfaces/MediaAttachment.mm +31 -0
  107. package/ios/{utils → interfaces}/MentionParams.h +0 -1
  108. package/ios/{utils → interfaces}/MentionStyleProps.mm +27 -20
  109. package/ios/{utils → interfaces}/StyleHeaders.h +37 -15
  110. package/ios/{utils → interfaces}/StyleTypeEnum.h +3 -0
  111. package/ios/internals/EnrichedTextInputViewComponentDescriptor.h +11 -9
  112. package/ios/internals/EnrichedTextInputViewShadowNode.h +28 -25
  113. package/ios/internals/EnrichedTextInputViewShadowNode.mm +45 -40
  114. package/ios/internals/EnrichedTextInputViewState.h +3 -1
  115. package/ios/styles/BlockQuoteStyle.mm +189 -118
  116. package/ios/styles/BoldStyle.mm +110 -63
  117. package/ios/styles/CodeBlockStyle.mm +204 -128
  118. package/ios/styles/H1Style.mm +10 -4
  119. package/ios/styles/H2Style.mm +10 -4
  120. package/ios/styles/H3Style.mm +10 -4
  121. package/ios/styles/H4Style.mm +17 -0
  122. package/ios/styles/H5Style.mm +17 -0
  123. package/ios/styles/H6Style.mm +17 -0
  124. package/ios/styles/HeadingStyleBase.mm +148 -86
  125. package/ios/styles/ImageStyle.mm +75 -73
  126. package/ios/styles/InlineCodeStyle.mm +162 -88
  127. package/ios/styles/ItalicStyle.mm +76 -52
  128. package/ios/styles/LinkStyle.mm +411 -232
  129. package/ios/styles/MentionStyle.mm +363 -246
  130. package/ios/styles/OrderedListStyle.mm +171 -106
  131. package/ios/styles/StrikethroughStyle.mm +52 -35
  132. package/ios/styles/UnderlineStyle.mm +68 -46
  133. package/ios/styles/UnorderedListStyle.mm +169 -106
  134. package/ios/utils/OccurenceUtils.h +42 -42
  135. package/ios/utils/OccurenceUtils.mm +142 -119
  136. package/ios/utils/ParagraphAttributesUtils.h +10 -2
  137. package/ios/utils/ParagraphAttributesUtils.mm +182 -71
  138. package/ios/utils/ParagraphsUtils.h +2 -1
  139. package/ios/utils/ParagraphsUtils.mm +41 -27
  140. package/ios/utils/TextInsertionUtils.h +13 -2
  141. package/ios/utils/TextInsertionUtils.mm +38 -20
  142. package/ios/utils/WordsUtils.h +2 -1
  143. package/ios/utils/WordsUtils.mm +32 -22
  144. package/ios/utils/ZeroWidthSpaceUtils.h +3 -1
  145. package/ios/utils/ZeroWidthSpaceUtils.mm +145 -79
  146. package/lib/module/EnrichedTextInput.js +61 -2
  147. package/lib/module/EnrichedTextInput.js.map +1 -1
  148. package/lib/module/EnrichedTextInputNativeComponent.ts +149 -12
  149. package/lib/module/{normalizeHtmlStyle.js → utils/normalizeHtmlStyle.js} +12 -0
  150. package/lib/module/utils/normalizeHtmlStyle.js.map +1 -0
  151. package/lib/module/utils/regexParser.js +46 -0
  152. package/lib/module/utils/regexParser.js.map +1 -0
  153. package/lib/typescript/src/EnrichedTextInput.d.ts +24 -14
  154. package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -1
  155. package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts +129 -12
  156. package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +1 -1
  157. package/lib/typescript/src/index.d.ts +1 -1
  158. package/lib/typescript/src/index.d.ts.map +1 -1
  159. package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts +4 -0
  160. package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts.map +1 -0
  161. package/lib/typescript/src/utils/regexParser.d.ts +3 -0
  162. package/lib/typescript/src/utils/regexParser.d.ts.map +1 -0
  163. package/package.json +17 -6
  164. package/src/EnrichedTextInput.tsx +96 -13
  165. package/src/EnrichedTextInputNativeComponent.ts +149 -12
  166. package/src/index.tsx +2 -0
  167. package/src/{normalizeHtmlStyle.ts → utils/normalizeHtmlStyle.ts} +14 -2
  168. package/src/utils/regexParser.ts +56 -0
  169. package/ios/utils/FontExtension.mm +0 -91
  170. package/ios/utils/LayoutManagerExtension.mm +0 -286
  171. package/lib/module/normalizeHtmlStyle.js.map +0 -1
  172. package/lib/typescript/src/normalizeHtmlStyle.d.ts +0 -4
  173. package/lib/typescript/src/normalizeHtmlStyle.d.ts.map +0 -1
  174. package/ios/{utils → extensions}/ColorExtension.h +0 -0
  175. package/ios/{utils → extensions}/FontExtension.h +0 -0
  176. package/ios/{utils → extensions}/StringExtension.h +1 -1
  177. package/ios/{utils → interfaces}/ImageData.h +0 -0
  178. package/ios/{utils → interfaces}/ImageData.mm +0 -0
  179. package/ios/{utils → interfaces}/LinkData.h +0 -0
  180. package/ios/{utils → interfaces}/LinkData.mm +0 -0
  181. package/ios/{utils → interfaces}/MentionParams.mm +0 -0
  182. package/ios/{utils → interfaces}/MentionStyleProps.h +1 -1
  183. /package/ios/{utils → interfaces}/StylePair.h +0 -0
  184. /package/ios/{utils → interfaces}/StylePair.mm +0 -0
  185. /package/ios/{utils → interfaces}/TextDecorationLineEnum.h +0 -0
  186. /package/ios/{utils → interfaces}/TextDecorationLineEnum.mm +0 -0
@@ -33,7 +33,136 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
33
33
  std::string value;
34
34
  };
35
35
 
36
+ struct OnChangeStateBold {
37
+ bool isActive;
38
+ bool isConflicting;
39
+ bool isBlocking;
40
+ };
41
+
42
+ struct OnChangeStateItalic {
43
+ bool isActive;
44
+ bool isConflicting;
45
+ bool isBlocking;
46
+ };
47
+
48
+ struct OnChangeStateUnderline {
49
+ bool isActive;
50
+ bool isConflicting;
51
+ bool isBlocking;
52
+ };
53
+
54
+ struct OnChangeStateStrikeThrough {
55
+ bool isActive;
56
+ bool isConflicting;
57
+ bool isBlocking;
58
+ };
59
+
60
+ struct OnChangeStateInlineCode {
61
+ bool isActive;
62
+ bool isConflicting;
63
+ bool isBlocking;
64
+ };
65
+
66
+ struct OnChangeStateH1 {
67
+ bool isActive;
68
+ bool isConflicting;
69
+ bool isBlocking;
70
+ };
71
+
72
+ struct OnChangeStateH2 {
73
+ bool isActive;
74
+ bool isConflicting;
75
+ bool isBlocking;
76
+ };
77
+
78
+ struct OnChangeStateH3 {
79
+ bool isActive;
80
+ bool isConflicting;
81
+ bool isBlocking;
82
+ };
83
+
84
+ struct OnChangeStateH4 {
85
+ bool isActive;
86
+ bool isConflicting;
87
+ bool isBlocking;
88
+ };
89
+
90
+ struct OnChangeStateH5 {
91
+ bool isActive;
92
+ bool isConflicting;
93
+ bool isBlocking;
94
+ };
95
+
96
+ struct OnChangeStateH6 {
97
+ bool isActive;
98
+ bool isConflicting;
99
+ bool isBlocking;
100
+ };
101
+
102
+ struct OnChangeStateCodeBlock {
103
+ bool isActive;
104
+ bool isConflicting;
105
+ bool isBlocking;
106
+ };
107
+
108
+ struct OnChangeStateBlockQuote {
109
+ bool isActive;
110
+ bool isConflicting;
111
+ bool isBlocking;
112
+ };
113
+
114
+ struct OnChangeStateOrderedList {
115
+ bool isActive;
116
+ bool isConflicting;
117
+ bool isBlocking;
118
+ };
119
+
120
+ struct OnChangeStateUnorderedList {
121
+ bool isActive;
122
+ bool isConflicting;
123
+ bool isBlocking;
124
+ };
125
+
126
+ struct OnChangeStateLink {
127
+ bool isActive;
128
+ bool isConflicting;
129
+ bool isBlocking;
130
+ };
131
+
132
+ struct OnChangeStateImage {
133
+ bool isActive;
134
+ bool isConflicting;
135
+ bool isBlocking;
136
+ };
137
+
138
+ struct OnChangeStateMention {
139
+ bool isActive;
140
+ bool isConflicting;
141
+ bool isBlocking;
142
+ };
143
+
36
144
  struct OnChangeState {
145
+ OnChangeStateBold bold;
146
+ OnChangeStateItalic italic;
147
+ OnChangeStateUnderline underline;
148
+ OnChangeStateStrikeThrough strikeThrough;
149
+ OnChangeStateInlineCode inlineCode;
150
+ OnChangeStateH1 h1;
151
+ OnChangeStateH2 h2;
152
+ OnChangeStateH3 h3;
153
+ OnChangeStateH4 h4;
154
+ OnChangeStateH5 h5;
155
+ OnChangeStateH6 h6;
156
+ OnChangeStateCodeBlock codeBlock;
157
+ OnChangeStateBlockQuote blockQuote;
158
+ OnChangeStateOrderedList orderedList;
159
+ OnChangeStateUnorderedList unorderedList;
160
+ OnChangeStateLink link;
161
+ OnChangeStateImage image;
162
+ OnChangeStateMention mention;
163
+ };
164
+
165
+ struct OnChangeStateDeprecated {
37
166
  bool isBold;
38
167
  bool isItalic;
39
168
  bool isUnderline;
@@ -42,6 +171,9 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
42
171
  bool isH1;
43
172
  bool isH2;
44
173
  bool isH3;
174
+ bool isH4;
175
+ bool isH5;
176
+ bool isH6;
45
177
  bool isCodeBlock;
46
178
  bool isBlockQuote;
47
179
  bool isOrderedList;
@@ -74,6 +206,15 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
74
206
  int end;
75
207
  std::string text;
76
208
  };
209
+
210
+ struct OnRequestHtmlResult {
211
+ int requestId;
212
+ folly::dynamic html;
213
+ };
214
+
215
+ struct OnInputKeyPress {
216
+ std::string key;
217
+ };
77
218
  void onInputFocus(OnInputFocus value) const;
78
219
 
79
220
  void onInputBlur(OnInputBlur value) const;
@@ -84,6 +225,8 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
84
225
 
85
226
  void onChangeState(OnChangeState value) const;
86
227
 
228
+ void onChangeStateDeprecated(OnChangeStateDeprecated value) const;
229
+
87
230
  void onLinkDetected(OnLinkDetected value) const;
88
231
 
89
232
  void onMentionDetected(OnMentionDetected value) const;
@@ -91,5 +234,9 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
91
234
  void onMention(OnMention value) const;
92
235
 
93
236
  void onChangeSelection(OnChangeSelection value) const;
237
+
238
+ void onRequestHtmlResult(OnRequestHtmlResult value) const;
239
+
240
+ void onInputKeyPress(OnInputKeyPress value) const;
94
241
  };
95
242
  } // namespace facebook::react
@@ -31,12 +31,14 @@ EnrichedTextInputViewProps::EnrichedTextInputViewProps(
31
31
  autoCapitalize(convertRawProp(context, rawProps, "autoCapitalize", sourceProps.autoCapitalize, {})),
32
32
  htmlStyle(convertRawProp(context, rawProps, "htmlStyle", sourceProps.htmlStyle, {})),
33
33
  scrollEnabled(convertRawProp(context, rawProps, "scrollEnabled", sourceProps.scrollEnabled, {false})),
34
+ linkRegex(convertRawProp(context, rawProps, "linkRegex", sourceProps.linkRegex, {})),
34
35
  color(convertRawProp(context, rawProps, "color", sourceProps.color, {})),
35
36
  fontSize(convertRawProp(context, rawProps, "fontSize", sourceProps.fontSize, {0.0})),
36
37
  fontFamily(convertRawProp(context, rawProps, "fontFamily", sourceProps.fontFamily, {})),
37
38
  fontWeight(convertRawProp(context, rawProps, "fontWeight", sourceProps.fontWeight, {})),
38
39
  fontStyle(convertRawProp(context, rawProps, "fontStyle", sourceProps.fontStyle, {})),
39
40
  isOnChangeHtmlSet(convertRawProp(context, rawProps, "isOnChangeHtmlSet", sourceProps.isOnChangeHtmlSet, {false})),
41
+ isOnChangeTextSet(convertRawProp(context, rawProps, "isOnChangeTextSet", sourceProps.isOnChangeTextSet, {false})),
40
42
  androidExperimentalSynchronousEvents(convertRawProp(context, rawProps, "androidExperimentalSynchronousEvents", sourceProps.androidExperimentalSynchronousEvents, {false})) {}
41
43
 
42
44
  #ifdef RN_SERIALIZABLE_STATE
@@ -99,6 +101,10 @@ folly::dynamic EnrichedTextInputViewProps::getDiffProps(
99
101
  result["scrollEnabled"] = scrollEnabled;
100
102
  }
101
103
 
104
+ if (linkRegex != oldProps->linkRegex) {
105
+ result["linkRegex"] = toDynamic(linkRegex);
106
+ }
107
+
102
108
  if (color != oldProps->color) {
103
109
  result["color"] = *color;
104
110
  }
@@ -123,6 +129,10 @@ folly::dynamic EnrichedTextInputViewProps::getDiffProps(
123
129
  result["isOnChangeHtmlSet"] = isOnChangeHtmlSet;
124
130
  }
125
131
 
132
+ if (isOnChangeTextSet != oldProps->isOnChangeTextSet) {
133
+ result["isOnChangeTextSet"] = isOnChangeTextSet;
134
+ }
135
+
126
136
  if (androidExperimentalSynchronousEvents != oldProps->androidExperimentalSynchronousEvents) {
127
137
  result["androidExperimentalSynchronousEvents"] = androidExperimentalSynchronousEvents;
128
138
  }
@@ -135,6 +135,123 @@ static inline folly::dynamic toDynamic(const EnrichedTextInputViewHtmlStyleH3Str
135
135
  }
136
136
  #endif
137
137
 
138
+ struct EnrichedTextInputViewHtmlStyleH4Struct {
139
+ Float fontSize{0.0};
140
+ bool bold{false};
141
+
142
+ #ifdef RN_SERIALIZABLE_STATE
143
+ bool operator==(const EnrichedTextInputViewHtmlStyleH4Struct&) const = default;
144
+
145
+ folly::dynamic toDynamic() const {
146
+ folly::dynamic result = folly::dynamic::object();
147
+ result["fontSize"] = fontSize;
148
+ result["bold"] = bold;
149
+ return result;
150
+ }
151
+ #endif
152
+ };
153
+
154
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, EnrichedTextInputViewHtmlStyleH4Struct &result) {
155
+ auto map = (std::unordered_map<std::string, RawValue>)value;
156
+
157
+ auto tmp_fontSize = map.find("fontSize");
158
+ if (tmp_fontSize != map.end()) {
159
+ fromRawValue(context, tmp_fontSize->second, result.fontSize);
160
+ }
161
+ auto tmp_bold = map.find("bold");
162
+ if (tmp_bold != map.end()) {
163
+ fromRawValue(context, tmp_bold->second, result.bold);
164
+ }
165
+ }
166
+
167
+ static inline std::string toString(const EnrichedTextInputViewHtmlStyleH4Struct &value) {
168
+ return "[Object EnrichedTextInputViewHtmlStyleH4Struct]";
169
+ }
170
+
171
+ #ifdef RN_SERIALIZABLE_STATE
172
+ static inline folly::dynamic toDynamic(const EnrichedTextInputViewHtmlStyleH4Struct &value) {
173
+ return value.toDynamic();
174
+ }
175
+ #endif
176
+
177
+ struct EnrichedTextInputViewHtmlStyleH5Struct {
178
+ Float fontSize{0.0};
179
+ bool bold{false};
180
+
181
+ #ifdef RN_SERIALIZABLE_STATE
182
+ bool operator==(const EnrichedTextInputViewHtmlStyleH5Struct&) const = default;
183
+
184
+ folly::dynamic toDynamic() const {
185
+ folly::dynamic result = folly::dynamic::object();
186
+ result["fontSize"] = fontSize;
187
+ result["bold"] = bold;
188
+ return result;
189
+ }
190
+ #endif
191
+ };
192
+
193
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, EnrichedTextInputViewHtmlStyleH5Struct &result) {
194
+ auto map = (std::unordered_map<std::string, RawValue>)value;
195
+
196
+ auto tmp_fontSize = map.find("fontSize");
197
+ if (tmp_fontSize != map.end()) {
198
+ fromRawValue(context, tmp_fontSize->second, result.fontSize);
199
+ }
200
+ auto tmp_bold = map.find("bold");
201
+ if (tmp_bold != map.end()) {
202
+ fromRawValue(context, tmp_bold->second, result.bold);
203
+ }
204
+ }
205
+
206
+ static inline std::string toString(const EnrichedTextInputViewHtmlStyleH5Struct &value) {
207
+ return "[Object EnrichedTextInputViewHtmlStyleH5Struct]";
208
+ }
209
+
210
+ #ifdef RN_SERIALIZABLE_STATE
211
+ static inline folly::dynamic toDynamic(const EnrichedTextInputViewHtmlStyleH5Struct &value) {
212
+ return value.toDynamic();
213
+ }
214
+ #endif
215
+
216
+ struct EnrichedTextInputViewHtmlStyleH6Struct {
217
+ Float fontSize{0.0};
218
+ bool bold{false};
219
+
220
+ #ifdef RN_SERIALIZABLE_STATE
221
+ bool operator==(const EnrichedTextInputViewHtmlStyleH6Struct&) const = default;
222
+
223
+ folly::dynamic toDynamic() const {
224
+ folly::dynamic result = folly::dynamic::object();
225
+ result["fontSize"] = fontSize;
226
+ result["bold"] = bold;
227
+ return result;
228
+ }
229
+ #endif
230
+ };
231
+
232
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, EnrichedTextInputViewHtmlStyleH6Struct &result) {
233
+ auto map = (std::unordered_map<std::string, RawValue>)value;
234
+
235
+ auto tmp_fontSize = map.find("fontSize");
236
+ if (tmp_fontSize != map.end()) {
237
+ fromRawValue(context, tmp_fontSize->second, result.fontSize);
238
+ }
239
+ auto tmp_bold = map.find("bold");
240
+ if (tmp_bold != map.end()) {
241
+ fromRawValue(context, tmp_bold->second, result.bold);
242
+ }
243
+ }
244
+
245
+ static inline std::string toString(const EnrichedTextInputViewHtmlStyleH6Struct &value) {
246
+ return "[Object EnrichedTextInputViewHtmlStyleH6Struct]";
247
+ }
248
+
249
+ #ifdef RN_SERIALIZABLE_STATE
250
+ static inline folly::dynamic toDynamic(const EnrichedTextInputViewHtmlStyleH6Struct &value) {
251
+ return value.toDynamic();
252
+ }
253
+ #endif
254
+
138
255
  struct EnrichedTextInputViewHtmlStyleBlockquoteStruct {
139
256
  SharedColor borderColor{};
140
257
  Float borderWidth{0.0};
@@ -415,6 +532,9 @@ struct EnrichedTextInputViewHtmlStyleStruct {
415
532
  EnrichedTextInputViewHtmlStyleH1Struct h1{};
416
533
  EnrichedTextInputViewHtmlStyleH2Struct h2{};
417
534
  EnrichedTextInputViewHtmlStyleH3Struct h3{};
535
+ EnrichedTextInputViewHtmlStyleH4Struct h4{};
536
+ EnrichedTextInputViewHtmlStyleH5Struct h5{};
537
+ EnrichedTextInputViewHtmlStyleH6Struct h6{};
418
538
  EnrichedTextInputViewHtmlStyleBlockquoteStruct blockquote{};
419
539
  EnrichedTextInputViewHtmlStyleCodeblockStruct codeblock{};
420
540
  EnrichedTextInputViewHtmlStyleCodeStruct code{};
@@ -431,6 +551,9 @@ struct EnrichedTextInputViewHtmlStyleStruct {
431
551
  result["h1"] = ::facebook::react::toDynamic(h1);
432
552
  result["h2"] = ::facebook::react::toDynamic(h2);
433
553
  result["h3"] = ::facebook::react::toDynamic(h3);
554
+ result["h4"] = ::facebook::react::toDynamic(h4);
555
+ result["h5"] = ::facebook::react::toDynamic(h5);
556
+ result["h6"] = ::facebook::react::toDynamic(h6);
434
557
  result["blockquote"] = ::facebook::react::toDynamic(blockquote);
435
558
  result["codeblock"] = ::facebook::react::toDynamic(codeblock);
436
559
  result["code"] = ::facebook::react::toDynamic(code);
@@ -458,6 +581,18 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
458
581
  if (tmp_h3 != map.end()) {
459
582
  fromRawValue(context, tmp_h3->second, result.h3);
460
583
  }
584
+ auto tmp_h4 = map.find("h4");
585
+ if (tmp_h4 != map.end()) {
586
+ fromRawValue(context, tmp_h4->second, result.h4);
587
+ }
588
+ auto tmp_h5 = map.find("h5");
589
+ if (tmp_h5 != map.end()) {
590
+ fromRawValue(context, tmp_h5->second, result.h5);
591
+ }
592
+ auto tmp_h6 = map.find("h6");
593
+ if (tmp_h6 != map.end()) {
594
+ fromRawValue(context, tmp_h6->second, result.h6);
595
+ }
461
596
  auto tmp_blockquote = map.find("blockquote");
462
597
  if (tmp_blockquote != map.end()) {
463
598
  fromRawValue(context, tmp_blockquote->second, result.blockquote);
@@ -497,6 +632,63 @@ static inline folly::dynamic toDynamic(const EnrichedTextInputViewHtmlStyleStruc
497
632
  return value.toDynamic();
498
633
  }
499
634
  #endif
635
+
636
+ struct EnrichedTextInputViewLinkRegexStruct {
637
+ std::string pattern{};
638
+ bool caseInsensitive{false};
639
+ bool dotAll{false};
640
+ bool isDisabled{false};
641
+ bool isDefault{false};
642
+
643
+ #ifdef RN_SERIALIZABLE_STATE
644
+ bool operator==(const EnrichedTextInputViewLinkRegexStruct&) const = default;
645
+
646
+ folly::dynamic toDynamic() const {
647
+ folly::dynamic result = folly::dynamic::object();
648
+ result["pattern"] = pattern;
649
+ result["caseInsensitive"] = caseInsensitive;
650
+ result["dotAll"] = dotAll;
651
+ result["isDisabled"] = isDisabled;
652
+ result["isDefault"] = isDefault;
653
+ return result;
654
+ }
655
+ #endif
656
+ };
657
+
658
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, EnrichedTextInputViewLinkRegexStruct &result) {
659
+ auto map = (std::unordered_map<std::string, RawValue>)value;
660
+
661
+ auto tmp_pattern = map.find("pattern");
662
+ if (tmp_pattern != map.end()) {
663
+ fromRawValue(context, tmp_pattern->second, result.pattern);
664
+ }
665
+ auto tmp_caseInsensitive = map.find("caseInsensitive");
666
+ if (tmp_caseInsensitive != map.end()) {
667
+ fromRawValue(context, tmp_caseInsensitive->second, result.caseInsensitive);
668
+ }
669
+ auto tmp_dotAll = map.find("dotAll");
670
+ if (tmp_dotAll != map.end()) {
671
+ fromRawValue(context, tmp_dotAll->second, result.dotAll);
672
+ }
673
+ auto tmp_isDisabled = map.find("isDisabled");
674
+ if (tmp_isDisabled != map.end()) {
675
+ fromRawValue(context, tmp_isDisabled->second, result.isDisabled);
676
+ }
677
+ auto tmp_isDefault = map.find("isDefault");
678
+ if (tmp_isDefault != map.end()) {
679
+ fromRawValue(context, tmp_isDefault->second, result.isDefault);
680
+ }
681
+ }
682
+
683
+ static inline std::string toString(const EnrichedTextInputViewLinkRegexStruct &value) {
684
+ return "[Object EnrichedTextInputViewLinkRegexStruct]";
685
+ }
686
+
687
+ #ifdef RN_SERIALIZABLE_STATE
688
+ static inline folly::dynamic toDynamic(const EnrichedTextInputViewLinkRegexStruct &value) {
689
+ return value.toDynamic();
690
+ }
691
+ #endif
500
692
  class EnrichedTextInputViewProps final : public ViewProps {
501
693
  public:
502
694
  EnrichedTextInputViewProps() = default;
@@ -515,12 +707,14 @@ class EnrichedTextInputViewProps final : public ViewProps {
515
707
  std::string autoCapitalize{};
516
708
  EnrichedTextInputViewHtmlStyleStruct htmlStyle{};
517
709
  bool scrollEnabled{false};
710
+ EnrichedTextInputViewLinkRegexStruct linkRegex{};
518
711
  SharedColor color{};
519
712
  Float fontSize{0.0};
520
713
  std::string fontFamily{};
521
714
  std::string fontWeight{};
522
715
  std::string fontStyle{};
523
716
  bool isOnChangeHtmlSet{false};
717
+ bool isOnChangeTextSet{false};
524
718
  bool androidExperimentalSynchronousEvents{false};
525
719
 
526
720
  #ifdef RN_SERIALIZABLE_STATE
@@ -17,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
17
17
  - (void)focus;
18
18
  - (void)blur;
19
19
  - (void)setValue:(NSString *)text;
20
+ - (void)setSelection:(NSInteger)start end:(NSInteger)end;
20
21
  - (void)toggleBold;
21
22
  - (void)toggleItalic;
22
23
  - (void)toggleUnderline;
@@ -25,6 +26,9 @@ NS_ASSUME_NONNULL_BEGIN
25
26
  - (void)toggleH1;
26
27
  - (void)toggleH2;
27
28
  - (void)toggleH3;
29
+ - (void)toggleH4;
30
+ - (void)toggleH5;
31
+ - (void)toggleH6;
28
32
  - (void)toggleCodeBlock;
29
33
  - (void)toggleBlockQuote;
30
34
  - (void)toggleOrderedList;
@@ -33,6 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
33
37
  - (void)addImage:(NSString *)uri width:(float)width height:(float)height;
34
38
  - (void)startMention:(NSString *)indicator;
35
39
  - (void)addMention:(NSString *)indicator text:(NSString *)text payload:(NSString *)payload;
40
+ - (void)requestHTML:(NSInteger)requestId;
36
41
  @end
37
42
 
38
43
  RCT_EXTERN inline void RCTEnrichedTextInputViewHandleCommand(
@@ -88,6 +93,34 @@ if ([commandName isEqualToString:@"setValue"]) {
88
93
  return;
89
94
  }
90
95
 
96
+ if ([commandName isEqualToString:@"setSelection"]) {
97
+ #if RCT_DEBUG
98
+ if ([args count] != 2) {
99
+ RCTLogError(@"%@ command %@ received %d arguments, expected %d.", @"EnrichedTextInputView", commandName, (int)[args count], 2);
100
+ return;
101
+ }
102
+ #endif
103
+
104
+ NSObject *arg0 = args[0];
105
+ #if RCT_DEBUG
106
+ if (!RCTValidateTypeOfViewCommandArgument(arg0, [NSNumber class], @"number", @"EnrichedTextInputView", commandName, @"1st")) {
107
+ return;
108
+ }
109
+ #endif
110
+ NSInteger start = [(NSNumber *)arg0 intValue];
111
+
112
+ NSObject *arg1 = args[1];
113
+ #if RCT_DEBUG
114
+ if (!RCTValidateTypeOfViewCommandArgument(arg1, [NSNumber class], @"number", @"EnrichedTextInputView", commandName, @"2nd")) {
115
+ return;
116
+ }
117
+ #endif
118
+ NSInteger end = [(NSNumber *)arg1 intValue];
119
+
120
+ [componentView setSelection:start end:end];
121
+ return;
122
+ }
123
+
91
124
  if ([commandName isEqualToString:@"toggleBold"]) {
92
125
  #if RCT_DEBUG
93
126
  if ([args count] != 0) {
@@ -200,6 +233,48 @@ if ([commandName isEqualToString:@"toggleH3"]) {
200
233
  return;
201
234
  }
202
235
 
236
+ if ([commandName isEqualToString:@"toggleH4"]) {
237
+ #if RCT_DEBUG
238
+ if ([args count] != 0) {
239
+ RCTLogError(@"%@ command %@ received %d arguments, expected %d.", @"EnrichedTextInputView", commandName, (int)[args count], 0);
240
+ return;
241
+ }
242
+ #endif
243
+
244
+
245
+
246
+ [componentView toggleH4];
247
+ return;
248
+ }
249
+
250
+ if ([commandName isEqualToString:@"toggleH5"]) {
251
+ #if RCT_DEBUG
252
+ if ([args count] != 0) {
253
+ RCTLogError(@"%@ command %@ received %d arguments, expected %d.", @"EnrichedTextInputView", commandName, (int)[args count], 0);
254
+ return;
255
+ }
256
+ #endif
257
+
258
+
259
+
260
+ [componentView toggleH5];
261
+ return;
262
+ }
263
+
264
+ if ([commandName isEqualToString:@"toggleH6"]) {
265
+ #if RCT_DEBUG
266
+ if ([args count] != 0) {
267
+ RCTLogError(@"%@ command %@ received %d arguments, expected %d.", @"EnrichedTextInputView", commandName, (int)[args count], 0);
268
+ return;
269
+ }
270
+ #endif
271
+
272
+
273
+
274
+ [componentView toggleH6];
275
+ return;
276
+ }
277
+
203
278
  if ([commandName isEqualToString:@"toggleCodeBlock"]) {
204
279
  #if RCT_DEBUG
205
280
  if ([args count] != 0) {
@@ -392,6 +467,26 @@ NSObject *arg2 = args[2];
392
467
  return;
393
468
  }
394
469
 
470
+ if ([commandName isEqualToString:@"requestHTML"]) {
471
+ #if RCT_DEBUG
472
+ if ([args count] != 1) {
473
+ RCTLogError(@"%@ command %@ received %d arguments, expected %d.", @"EnrichedTextInputView", commandName, (int)[args count], 1);
474
+ return;
475
+ }
476
+ #endif
477
+
478
+ NSObject *arg0 = args[0];
479
+ #if RCT_DEBUG
480
+ if (!RCTValidateTypeOfViewCommandArgument(arg0, [NSNumber class], @"number", @"EnrichedTextInputView", commandName, @"1st")) {
481
+ return;
482
+ }
483
+ #endif
484
+ NSInteger requestId = [(NSNumber *)arg0 intValue];
485
+
486
+ [componentView requestHTML:requestId];
487
+ return;
488
+ }
489
+
395
490
  #if RCT_DEBUG
396
491
  RCTLogError(@"%@ received command %@, which is not a supported command.", @"EnrichedTextInputView", commandName);
397
492
  #endif
@@ -3,9 +3,9 @@
3
3
 
4
4
  @interface InputParser : NSObject
5
5
  - (instancetype _Nonnull)initWithInput:(id _Nonnull)input;
6
- - (NSString * _Nonnull)parseToHtmlFromRange:(NSRange)range;
7
- - (void)replaceWholeFromHtml:(NSString * _Nonnull)html;
8
- - (void)replaceFromHtml:(NSString * _Nonnull)html range:(NSRange)range;
9
- - (void)insertFromHtml:(NSString * _Nonnull)html location:(NSInteger)location;
10
- - (NSString * _Nullable)initiallyProcessHtml:(NSString * _Nonnull)html;
6
+ - (NSString *_Nonnull)parseToHtmlFromRange:(NSRange)range;
7
+ - (void)replaceWholeFromHtml:(NSString *_Nonnull)html;
8
+ - (void)replaceFromHtml:(NSString *_Nonnull)html range:(NSRange)range;
9
+ - (void)insertFromHtml:(NSString *_Nonnull)html location:(NSInteger)location;
10
+ - (NSString *_Nullable)initiallyProcessHtml:(NSString *_Nonnull)html;
11
11
  @end