react-native-enriched 0.2.1 → 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 (156) hide show
  1. package/README.md +15 -12
  2. package/android/build.gradle +77 -72
  3. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +18 -0
  4. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +6 -0
  5. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.cpp +146 -0
  6. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h +140 -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 +245 -116
  12. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewLayoutManager.kt +3 -1
  13. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +162 -53
  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 +20 -10
  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 +1 -2
  29. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBlockQuoteSpan.kt +21 -8
  30. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBoldSpan.kt +5 -4
  31. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedCodeBlockSpan.kt +7 -5
  32. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH1Span.kt +5 -4
  33. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH2Span.kt +5 -4
  34. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH3Span.kt +5 -4
  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 +29 -17
  39. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedInlineCodeSpan.kt +5 -4
  40. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedItalicSpan.kt +5 -4
  41. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedLinkSpan.kt +7 -7
  42. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedMentionSpan.kt +11 -14
  43. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedOrderedListSpan.kt +15 -14
  44. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedSpans.kt +167 -71
  45. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedStrikeThroughSpan.kt +5 -4
  46. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnderlineSpan.kt +5 -4
  47. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnorderedListSpan.kt +8 -8
  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 +1 -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 +78 -21
  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 +86 -26
  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 +128 -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/react/renderer/components/RNEnrichedTextInputViewSpec/conversions.h +21 -1
  73. package/ios/EnrichedTextInputView.h +1 -1
  74. package/ios/EnrichedTextInputView.mm +381 -49
  75. package/ios/config/InputConfig.h +18 -0
  76. package/ios/config/InputConfig.mm +118 -8
  77. package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.cpp +146 -0
  78. package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.h +140 -0
  79. package/ios/generated/RNEnrichedTextInputViewSpec/Props.cpp +10 -0
  80. package/ios/generated/RNEnrichedTextInputViewSpec/Props.h +194 -0
  81. package/ios/generated/RNEnrichedTextInputViewSpec/RCTComponentViewHelpers.h +74 -0
  82. package/ios/inputParser/InputParser.mm +83 -10
  83. package/ios/{attachments → interfaces}/ImageAttachment.mm +3 -1
  84. package/ios/interfaces/LinkRegexConfig.h +19 -0
  85. package/ios/interfaces/LinkRegexConfig.mm +37 -0
  86. package/ios/{utils → interfaces}/MentionStyleProps.mm +2 -2
  87. package/ios/{utils → interfaces}/StyleHeaders.h +10 -0
  88. package/ios/{utils → interfaces}/StyleTypeEnum.h +3 -0
  89. package/ios/styles/BlockQuoteStyle.mm +5 -5
  90. package/ios/styles/BoldStyle.mm +21 -6
  91. package/ios/styles/CodeBlockStyle.mm +5 -5
  92. package/ios/styles/H4Style.mm +17 -0
  93. package/ios/styles/H5Style.mm +17 -0
  94. package/ios/styles/H6Style.mm +17 -0
  95. package/ios/styles/HeadingStyleBase.mm +27 -10
  96. package/ios/styles/ImageStyle.mm +5 -5
  97. package/ios/styles/InlineCodeStyle.mm +30 -19
  98. package/ios/styles/ItalicStyle.mm +5 -5
  99. package/ios/styles/LinkStyle.mm +98 -40
  100. package/ios/styles/MentionStyle.mm +4 -4
  101. package/ios/styles/OrderedListStyle.mm +5 -5
  102. package/ios/styles/StrikethroughStyle.mm +5 -5
  103. package/ios/styles/UnderlineStyle.mm +5 -5
  104. package/ios/styles/UnorderedListStyle.mm +5 -5
  105. package/ios/utils/ParagraphAttributesUtils.h +4 -0
  106. package/ios/utils/ParagraphAttributesUtils.mm +67 -0
  107. package/ios/utils/ParagraphsUtils.mm +4 -4
  108. package/lib/module/EnrichedTextInput.js +22 -1
  109. package/lib/module/EnrichedTextInput.js.map +1 -1
  110. package/lib/module/EnrichedTextInputNativeComponent.ts +138 -12
  111. package/lib/module/{normalizeHtmlStyle.js → utils/normalizeHtmlStyle.js} +12 -0
  112. package/lib/module/utils/normalizeHtmlStyle.js.map +1 -0
  113. package/lib/module/utils/regexParser.js +46 -0
  114. package/lib/module/utils/regexParser.js.map +1 -0
  115. package/lib/typescript/src/EnrichedTextInput.d.ts +23 -14
  116. package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -1
  117. package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts +123 -12
  118. package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +1 -1
  119. package/lib/typescript/src/index.d.ts +1 -1
  120. package/lib/typescript/src/index.d.ts.map +1 -1
  121. package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts +4 -0
  122. package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts.map +1 -0
  123. package/lib/typescript/src/utils/regexParser.d.ts +3 -0
  124. package/lib/typescript/src/utils/regexParser.d.ts.map +1 -0
  125. package/package.json +10 -6
  126. package/src/EnrichedTextInput.tsx +51 -13
  127. package/src/EnrichedTextInputNativeComponent.ts +138 -12
  128. package/src/index.tsx +2 -0
  129. package/src/{normalizeHtmlStyle.ts → utils/normalizeHtmlStyle.ts} +14 -2
  130. package/src/utils/regexParser.ts +56 -0
  131. package/lib/module/normalizeHtmlStyle.js.map +0 -1
  132. package/lib/typescript/src/normalizeHtmlStyle.d.ts +0 -4
  133. package/lib/typescript/src/normalizeHtmlStyle.d.ts.map +0 -1
  134. /package/ios/{utils → extensions}/ColorExtension.h +0 -0
  135. /package/ios/{utils → extensions}/ColorExtension.mm +0 -0
  136. /package/ios/{utils → extensions}/FontExtension.h +0 -0
  137. /package/ios/{utils → extensions}/FontExtension.mm +0 -0
  138. /package/ios/{utils → extensions}/LayoutManagerExtension.h +0 -0
  139. /package/ios/{utils → extensions}/LayoutManagerExtension.mm +0 -0
  140. /package/ios/{utils → extensions}/StringExtension.h +0 -0
  141. /package/ios/{utils → extensions}/StringExtension.mm +0 -0
  142. /package/ios/{utils → interfaces}/BaseStyleProtocol.h +0 -0
  143. /package/ios/{attachments → interfaces}/ImageAttachment.h +0 -0
  144. /package/ios/{utils → interfaces}/ImageData.h +0 -0
  145. /package/ios/{utils → interfaces}/ImageData.mm +0 -0
  146. /package/ios/{utils → interfaces}/LinkData.h +0 -0
  147. /package/ios/{utils → interfaces}/LinkData.mm +0 -0
  148. /package/ios/{attachments → interfaces}/MediaAttachment.h +0 -0
  149. /package/ios/{attachments → interfaces}/MediaAttachment.mm +0 -0
  150. /package/ios/{utils → interfaces}/MentionParams.h +0 -0
  151. /package/ios/{utils → interfaces}/MentionParams.mm +0 -0
  152. /package/ios/{utils → interfaces}/MentionStyleProps.h +0 -0
  153. /package/ios/{utils → interfaces}/StylePair.h +0 -0
  154. /package/ios/{utils → interfaces}/StylePair.mm +0 -0
  155. /package/ios/{utils → interfaces}/TextDecorationLineEnum.h +0 -0
  156. /package/ios/{utils → interfaces}/TextDecorationLineEnum.mm +0 -0
@@ -1,4 +1,5 @@
1
1
  #pragma once
2
+ #import "LinkRegexConfig.h"
2
3
  #import "MentionStyleProps.h"
3
4
  #import "TextDecorationLineEnum.h"
4
5
  #import <UIKit/UIKit.h>
@@ -29,6 +30,18 @@
29
30
  - (void)setH3FontSize:(CGFloat)newValue;
30
31
  - (BOOL)h3Bold;
31
32
  - (void)setH3Bold:(BOOL)newValue;
33
+ - (CGFloat)h4FontSize;
34
+ - (void)setH4FontSize:(CGFloat)newValue;
35
+ - (BOOL)h4Bold;
36
+ - (void)setH4Bold:(BOOL)newValue;
37
+ - (CGFloat)h5FontSize;
38
+ - (void)setH5FontSize:(CGFloat)newValue;
39
+ - (BOOL)h5Bold;
40
+ - (void)setH5Bold:(BOOL)newValue;
41
+ - (CGFloat)h6FontSize;
42
+ - (void)setH6FontSize:(CGFloat)newValue;
43
+ - (BOOL)h6Bold;
44
+ - (void)setH6Bold:(BOOL)newValue;
32
45
  - (UIColor *)blockquoteBorderColor;
33
46
  - (void)setBlockquoteBorderColor:(UIColor *)newValue;
34
47
  - (CGFloat)blockquoteBorderWidth;
@@ -70,4 +83,9 @@
70
83
  - (void)setCodeBlockBgColor:(UIColor *)newValue;
71
84
  - (CGFloat)codeBlockBorderRadius;
72
85
  - (void)setCodeBlockBorderRadius:(CGFloat)newValue;
86
+ - (LinkRegexConfig *)linkRegexConfig;
87
+ - (void)setLinkRegexConfig:(LinkRegexConfig *)newValue;
88
+ - (NSRegularExpression *)parsedLinkRegex;
89
+ - (void)invalidateFonts;
90
+ - (NSNumber *)scaledPrimaryFontSize;
73
91
  @end
@@ -17,6 +17,12 @@
17
17
  BOOL _h2Bold;
18
18
  CGFloat _h3FontSize;
19
19
  BOOL _h3Bold;
20
+ CGFloat _h4FontSize;
21
+ BOOL _h4Bold;
22
+ CGFloat _h5FontSize;
23
+ BOOL _h5Bold;
24
+ CGFloat _h6FontSize;
25
+ BOOL _h6Bold;
20
26
  UIColor *_blockquoteBorderColor;
21
27
  CGFloat _blockquoteBorderWidth;
22
28
  CGFloat _blockquoteGapWidth;
@@ -39,8 +45,8 @@
39
45
  UIColor *_codeBlockFgColor;
40
46
  CGFloat _codeBlockBorderRadius;
41
47
  UIColor *_codeBlockBgColor;
42
- CGFloat _imageWidth;
43
- CGFloat _imageHeight;
48
+ LinkRegexConfig *_linkRegexConfig;
49
+ NSRegularExpression *_parsedLinkRegex;
44
50
  }
45
51
 
46
52
  - (instancetype)init {
@@ -66,6 +72,12 @@
66
72
  copy->_h2Bold = _h2Bold;
67
73
  copy->_h3FontSize = _h3FontSize;
68
74
  copy->_h3Bold = _h3Bold;
75
+ copy->_h4FontSize = _h4FontSize;
76
+ copy->_h4Bold = _h4Bold;
77
+ copy->_h5FontSize = _h5FontSize;
78
+ copy->_h5Bold = _h5Bold;
79
+ copy->_h6FontSize = _h6FontSize;
80
+ copy->_h6Bold = _h6Bold;
69
81
  copy->_blockquoteBorderColor = [_blockquoteBorderColor copy];
70
82
  copy->_blockquoteBorderWidth = _blockquoteBorderWidth;
71
83
  copy->_blockquoteGapWidth = _blockquoteGapWidth;
@@ -87,6 +99,8 @@
87
99
  copy->_codeBlockFgColor = [_codeBlockFgColor copy];
88
100
  copy->_codeBlockBgColor = [_codeBlockBgColor copy];
89
101
  copy->_codeBlockBorderRadius = _codeBlockBorderRadius;
102
+ copy->_linkRegexConfig = [_linkRegexConfig copy];
103
+ copy->_parsedLinkRegex = [_parsedLinkRegex copy];
90
104
  return copy;
91
105
  }
92
106
 
@@ -146,7 +160,7 @@
146
160
 
147
161
  _primaryFont = [RCTFont updateFont:nullptr
148
162
  withFamily:[self primaryFontFamily]
149
- size:[self primaryFontSize]
163
+ size:[self scaledPrimaryFontSize]
150
164
  weight:newFontWeight
151
165
  style:nullptr
152
166
  variant:nullptr
@@ -159,7 +173,7 @@
159
173
  if (_monospacedFontNeedsRecreation) {
160
174
  _monospacedFontNeedsRecreation = NO;
161
175
  _monospacedFont = [UIFont
162
- monospacedSystemFontOfSize:[[self primaryFontSize] floatValue]
176
+ monospacedSystemFontOfSize:[[self scaledPrimaryFontSize] floatValue]
163
177
  weight:[[self primaryFontWeight] floatValue]];
164
178
  }
165
179
  return _monospacedFont;
@@ -175,7 +189,7 @@
175
189
  }
176
190
 
177
191
  - (CGFloat)h1FontSize {
178
- return _h1FontSize;
192
+ return [[UIFontMetrics defaultMetrics] scaledValueForValue:_h1FontSize];
179
193
  }
180
194
 
181
195
  - (void)setH1FontSize:(CGFloat)newValue {
@@ -191,7 +205,7 @@
191
205
  }
192
206
 
193
207
  - (CGFloat)h2FontSize {
194
- return _h2FontSize;
208
+ return [[UIFontMetrics defaultMetrics] scaledValueForValue:_h2FontSize];
195
209
  }
196
210
 
197
211
  - (void)setH2FontSize:(CGFloat)newValue {
@@ -207,7 +221,7 @@
207
221
  }
208
222
 
209
223
  - (CGFloat)h3FontSize {
210
- return _h3FontSize;
224
+ return [[UIFontMetrics defaultMetrics] scaledValueForValue:_h3FontSize];
211
225
  }
212
226
 
213
227
  - (void)setH3FontSize:(CGFloat)newValue {
@@ -222,6 +236,54 @@
222
236
  _h3Bold = newValue;
223
237
  }
224
238
 
239
+ - (CGFloat)h4FontSize {
240
+ return [[UIFontMetrics defaultMetrics] scaledValueForValue:_h4FontSize];
241
+ }
242
+
243
+ - (void)setH4FontSize:(CGFloat)newValue {
244
+ _h4FontSize = newValue;
245
+ }
246
+
247
+ - (BOOL)h4Bold {
248
+ return _h4Bold;
249
+ }
250
+
251
+ - (void)setH4Bold:(BOOL)newValue {
252
+ _h4Bold = newValue;
253
+ }
254
+
255
+ - (CGFloat)h5FontSize {
256
+ return [[UIFontMetrics defaultMetrics] scaledValueForValue:_h5FontSize];
257
+ }
258
+
259
+ - (void)setH5FontSize:(CGFloat)newValue {
260
+ _h5FontSize = newValue;
261
+ }
262
+
263
+ - (BOOL)h5Bold {
264
+ return _h5Bold;
265
+ }
266
+
267
+ - (void)setH5Bold:(BOOL)newValue {
268
+ _h5Bold = newValue;
269
+ }
270
+
271
+ - (CGFloat)h6FontSize {
272
+ return [[UIFontMetrics defaultMetrics] scaledValueForValue:_h6FontSize];
273
+ }
274
+
275
+ - (void)setH6FontSize:(CGFloat)newValue {
276
+ _h6FontSize = newValue;
277
+ }
278
+
279
+ - (BOOL)h6Bold {
280
+ return _h6Bold;
281
+ }
282
+
283
+ - (void)setH6Bold:(BOOL)newValue {
284
+ _h6Bold = newValue;
285
+ }
286
+
225
287
  - (UIColor *)blockquoteBorderColor {
226
288
  return _blockquoteBorderColor;
227
289
  }
@@ -318,7 +380,7 @@
318
380
 
319
381
  _orderedListMarkerFont = [RCTFont updateFont:nullptr
320
382
  withFamily:[self primaryFontFamily]
321
- size:[self primaryFontSize]
383
+ size:[self scaledPrimaryFontSize]
322
384
  weight:newFontWeight
323
385
  style:nullptr
324
386
  variant:nullptr
@@ -417,4 +479,52 @@
417
479
  _codeBlockBorderRadius = newValue;
418
480
  }
419
481
 
482
+ - (LinkRegexConfig *)linkRegexConfig {
483
+ return _linkRegexConfig;
484
+ }
485
+
486
+ - (void)setLinkRegexConfig:(LinkRegexConfig *)newValue {
487
+ _linkRegexConfig = newValue;
488
+
489
+ // try initializing the native regular expression if it applies
490
+ if (_linkRegexConfig.isDefault || _linkRegexConfig.isDisabled) {
491
+ return;
492
+ }
493
+
494
+ NSError *regexInitError;
495
+ NSRegularExpressionOptions options =
496
+ (_linkRegexConfig.caseInsensitive ? NSRegularExpressionCaseInsensitive
497
+ : 0) |
498
+ (_linkRegexConfig.dotAll ? NSRegularExpressionDotMatchesLineSeparators
499
+ : 0);
500
+ NSRegularExpression *userRegex =
501
+ [NSRegularExpression regularExpressionWithPattern:_linkRegexConfig.pattern
502
+ options:options
503
+ error:&regexInitError];
504
+
505
+ if (regexInitError) {
506
+ RCTLogWarn(@"[EnrichedTextInput]: Couldn't parse the user-defined link "
507
+ @"regex, falling back to a default regex.");
508
+ _parsedLinkRegex = nullptr;
509
+ } else {
510
+ _parsedLinkRegex = userRegex;
511
+ }
512
+ }
513
+
514
+ - (NSRegularExpression *)parsedLinkRegex {
515
+ return _parsedLinkRegex;
516
+ }
517
+
518
+ - (void)invalidateFonts {
519
+ _primaryFontNeedsRecreation = YES;
520
+ _monospacedFontNeedsRecreation = YES;
521
+ _olMarkerFontNeedsRecreation = YES;
522
+ }
523
+
524
+ - (NSNumber *)scaledPrimaryFontSize {
525
+ CGFloat scaledSize = [[UIFontMetrics defaultMetrics]
526
+ scaledValueForValue:[[self primaryFontSize] floatValue]];
527
+ return @(scaledSize);
528
+ }
529
+
420
530
  @end
@@ -51,6 +51,140 @@ void EnrichedTextInputViewEventEmitter::onChangeHtml(OnChangeHtml event) const {
51
51
 
52
52
  void EnrichedTextInputViewEventEmitter::onChangeState(OnChangeState event) const {
53
53
  dispatchEvent("changeState", [event=std::move(event)](jsi::Runtime &runtime) {
54
+ auto payload = jsi::Object(runtime);
55
+ {
56
+ auto bold = jsi::Object(runtime);
57
+ bold.setProperty(runtime, "isActive", event.bold.isActive);
58
+ bold.setProperty(runtime, "isConflicting", event.bold.isConflicting);
59
+ bold.setProperty(runtime, "isBlocking", event.bold.isBlocking);
60
+ payload.setProperty(runtime, "bold", bold);
61
+ }
62
+ {
63
+ auto italic = jsi::Object(runtime);
64
+ italic.setProperty(runtime, "isActive", event.italic.isActive);
65
+ italic.setProperty(runtime, "isConflicting", event.italic.isConflicting);
66
+ italic.setProperty(runtime, "isBlocking", event.italic.isBlocking);
67
+ payload.setProperty(runtime, "italic", italic);
68
+ }
69
+ {
70
+ auto underline = jsi::Object(runtime);
71
+ underline.setProperty(runtime, "isActive", event.underline.isActive);
72
+ underline.setProperty(runtime, "isConflicting", event.underline.isConflicting);
73
+ underline.setProperty(runtime, "isBlocking", event.underline.isBlocking);
74
+ payload.setProperty(runtime, "underline", underline);
75
+ }
76
+ {
77
+ auto strikeThrough = jsi::Object(runtime);
78
+ strikeThrough.setProperty(runtime, "isActive", event.strikeThrough.isActive);
79
+ strikeThrough.setProperty(runtime, "isConflicting", event.strikeThrough.isConflicting);
80
+ strikeThrough.setProperty(runtime, "isBlocking", event.strikeThrough.isBlocking);
81
+ payload.setProperty(runtime, "strikeThrough", strikeThrough);
82
+ }
83
+ {
84
+ auto inlineCode = jsi::Object(runtime);
85
+ inlineCode.setProperty(runtime, "isActive", event.inlineCode.isActive);
86
+ inlineCode.setProperty(runtime, "isConflicting", event.inlineCode.isConflicting);
87
+ inlineCode.setProperty(runtime, "isBlocking", event.inlineCode.isBlocking);
88
+ payload.setProperty(runtime, "inlineCode", inlineCode);
89
+ }
90
+ {
91
+ auto h1 = jsi::Object(runtime);
92
+ h1.setProperty(runtime, "isActive", event.h1.isActive);
93
+ h1.setProperty(runtime, "isConflicting", event.h1.isConflicting);
94
+ h1.setProperty(runtime, "isBlocking", event.h1.isBlocking);
95
+ payload.setProperty(runtime, "h1", h1);
96
+ }
97
+ {
98
+ auto h2 = jsi::Object(runtime);
99
+ h2.setProperty(runtime, "isActive", event.h2.isActive);
100
+ h2.setProperty(runtime, "isConflicting", event.h2.isConflicting);
101
+ h2.setProperty(runtime, "isBlocking", event.h2.isBlocking);
102
+ payload.setProperty(runtime, "h2", h2);
103
+ }
104
+ {
105
+ auto h3 = jsi::Object(runtime);
106
+ h3.setProperty(runtime, "isActive", event.h3.isActive);
107
+ h3.setProperty(runtime, "isConflicting", event.h3.isConflicting);
108
+ h3.setProperty(runtime, "isBlocking", event.h3.isBlocking);
109
+ payload.setProperty(runtime, "h3", h3);
110
+ }
111
+ {
112
+ auto h4 = jsi::Object(runtime);
113
+ h4.setProperty(runtime, "isActive", event.h4.isActive);
114
+ h4.setProperty(runtime, "isConflicting", event.h4.isConflicting);
115
+ h4.setProperty(runtime, "isBlocking", event.h4.isBlocking);
116
+ payload.setProperty(runtime, "h4", h4);
117
+ }
118
+ {
119
+ auto h5 = jsi::Object(runtime);
120
+ h5.setProperty(runtime, "isActive", event.h5.isActive);
121
+ h5.setProperty(runtime, "isConflicting", event.h5.isConflicting);
122
+ h5.setProperty(runtime, "isBlocking", event.h5.isBlocking);
123
+ payload.setProperty(runtime, "h5", h5);
124
+ }
125
+ {
126
+ auto h6 = jsi::Object(runtime);
127
+ h6.setProperty(runtime, "isActive", event.h6.isActive);
128
+ h6.setProperty(runtime, "isConflicting", event.h6.isConflicting);
129
+ h6.setProperty(runtime, "isBlocking", event.h6.isBlocking);
130
+ payload.setProperty(runtime, "h6", h6);
131
+ }
132
+ {
133
+ auto codeBlock = jsi::Object(runtime);
134
+ codeBlock.setProperty(runtime, "isActive", event.codeBlock.isActive);
135
+ codeBlock.setProperty(runtime, "isConflicting", event.codeBlock.isConflicting);
136
+ codeBlock.setProperty(runtime, "isBlocking", event.codeBlock.isBlocking);
137
+ payload.setProperty(runtime, "codeBlock", codeBlock);
138
+ }
139
+ {
140
+ auto blockQuote = jsi::Object(runtime);
141
+ blockQuote.setProperty(runtime, "isActive", event.blockQuote.isActive);
142
+ blockQuote.setProperty(runtime, "isConflicting", event.blockQuote.isConflicting);
143
+ blockQuote.setProperty(runtime, "isBlocking", event.blockQuote.isBlocking);
144
+ payload.setProperty(runtime, "blockQuote", blockQuote);
145
+ }
146
+ {
147
+ auto orderedList = jsi::Object(runtime);
148
+ orderedList.setProperty(runtime, "isActive", event.orderedList.isActive);
149
+ orderedList.setProperty(runtime, "isConflicting", event.orderedList.isConflicting);
150
+ orderedList.setProperty(runtime, "isBlocking", event.orderedList.isBlocking);
151
+ payload.setProperty(runtime, "orderedList", orderedList);
152
+ }
153
+ {
154
+ auto unorderedList = jsi::Object(runtime);
155
+ unorderedList.setProperty(runtime, "isActive", event.unorderedList.isActive);
156
+ unorderedList.setProperty(runtime, "isConflicting", event.unorderedList.isConflicting);
157
+ unorderedList.setProperty(runtime, "isBlocking", event.unorderedList.isBlocking);
158
+ payload.setProperty(runtime, "unorderedList", unorderedList);
159
+ }
160
+ {
161
+ auto link = jsi::Object(runtime);
162
+ link.setProperty(runtime, "isActive", event.link.isActive);
163
+ link.setProperty(runtime, "isConflicting", event.link.isConflicting);
164
+ link.setProperty(runtime, "isBlocking", event.link.isBlocking);
165
+ payload.setProperty(runtime, "link", link);
166
+ }
167
+ {
168
+ auto image = jsi::Object(runtime);
169
+ image.setProperty(runtime, "isActive", event.image.isActive);
170
+ image.setProperty(runtime, "isConflicting", event.image.isConflicting);
171
+ image.setProperty(runtime, "isBlocking", event.image.isBlocking);
172
+ payload.setProperty(runtime, "image", image);
173
+ }
174
+ {
175
+ auto mention = jsi::Object(runtime);
176
+ mention.setProperty(runtime, "isActive", event.mention.isActive);
177
+ mention.setProperty(runtime, "isConflicting", event.mention.isConflicting);
178
+ mention.setProperty(runtime, "isBlocking", event.mention.isBlocking);
179
+ payload.setProperty(runtime, "mention", mention);
180
+ }
181
+ return payload;
182
+ });
183
+ }
184
+
185
+
186
+ void EnrichedTextInputViewEventEmitter::onChangeStateDeprecated(OnChangeStateDeprecated event) const {
187
+ dispatchEvent("changeStateDeprecated", [event=std::move(event)](jsi::Runtime &runtime) {
54
188
  auto payload = jsi::Object(runtime);
55
189
  payload.setProperty(runtime, "isBold", event.isBold);
56
190
  payload.setProperty(runtime, "isItalic", event.isItalic);
@@ -60,6 +194,9 @@ payload.setProperty(runtime, "isInlineCode", event.isInlineCode);
60
194
  payload.setProperty(runtime, "isH1", event.isH1);
61
195
  payload.setProperty(runtime, "isH2", event.isH2);
62
196
  payload.setProperty(runtime, "isH3", event.isH3);
197
+ payload.setProperty(runtime, "isH4", event.isH4);
198
+ payload.setProperty(runtime, "isH5", event.isH5);
199
+ payload.setProperty(runtime, "isH6", event.isH6);
63
200
  payload.setProperty(runtime, "isCodeBlock", event.isCodeBlock);
64
201
  payload.setProperty(runtime, "isBlockQuote", event.isBlockQuote);
65
202
  payload.setProperty(runtime, "isOrderedList", event.isOrderedList);
@@ -125,4 +262,13 @@ payload.setProperty(runtime, "html", jsi::valueFromDynamic(runtime, event.html))
125
262
  });
126
263
  }
127
264
 
265
+
266
+ void EnrichedTextInputViewEventEmitter::onInputKeyPress(OnInputKeyPress event) const {
267
+ dispatchEvent("inputKeyPress", [event=std::move(event)](jsi::Runtime &runtime) {
268
+ auto payload = jsi::Object(runtime);
269
+ payload.setProperty(runtime, "key", event.key);
270
+ return payload;
271
+ });
272
+ }
273
+
128
274
  } // namespace facebook::react
@@ -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;
@@ -79,6 +211,10 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
79
211
  int requestId;
80
212
  folly::dynamic html;
81
213
  };
214
+
215
+ struct OnInputKeyPress {
216
+ std::string key;
217
+ };
82
218
  void onInputFocus(OnInputFocus value) const;
83
219
 
84
220
  void onInputBlur(OnInputBlur value) const;
@@ -89,6 +225,8 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
89
225
 
90
226
  void onChangeState(OnChangeState value) const;
91
227
 
228
+ void onChangeStateDeprecated(OnChangeStateDeprecated value) const;
229
+
92
230
  void onLinkDetected(OnLinkDetected value) const;
93
231
 
94
232
  void onMentionDetected(OnMentionDetected value) const;
@@ -98,5 +236,7 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
98
236
  void onChangeSelection(OnChangeSelection value) const;
99
237
 
100
238
  void onRequestHtmlResult(OnRequestHtmlResult value) const;
239
+
240
+ void onInputKeyPress(OnInputKeyPress value) const;
101
241
  };
102
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
  }