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
@@ -8,6 +8,16 @@ import type {
8
8
  import type { ColorValue, HostComponent, ViewProps } from 'react-native';
9
9
  import React from 'react';
10
10
 
11
+ export interface LinkNativeRegex {
12
+ pattern: string;
13
+ caseInsensitive: boolean;
14
+ dotAll: boolean;
15
+ // Link detection will be disabled
16
+ isDisabled: boolean;
17
+ // Use default native link regex
18
+ isDefault: boolean;
19
+ }
20
+
11
21
  export interface OnChangeTextEvent {
12
22
  value: string;
13
23
  }
@@ -17,6 +27,99 @@ export interface OnChangeHtmlEvent {
17
27
  }
18
28
 
19
29
  export interface OnChangeStateEvent {
30
+ bold: {
31
+ isActive: boolean;
32
+ isConflicting: boolean;
33
+ isBlocking: boolean;
34
+ };
35
+ italic: {
36
+ isActive: boolean;
37
+ isConflicting: boolean;
38
+ isBlocking: boolean;
39
+ };
40
+ underline: {
41
+ isActive: boolean;
42
+ isConflicting: boolean;
43
+ isBlocking: boolean;
44
+ };
45
+ strikeThrough: {
46
+ isActive: boolean;
47
+ isConflicting: boolean;
48
+ isBlocking: boolean;
49
+ };
50
+ inlineCode: {
51
+ isActive: boolean;
52
+ isConflicting: boolean;
53
+ isBlocking: boolean;
54
+ };
55
+ h1: {
56
+ isActive: boolean;
57
+ isConflicting: boolean;
58
+ isBlocking: boolean;
59
+ };
60
+ h2: {
61
+ isActive: boolean;
62
+ isConflicting: boolean;
63
+ isBlocking: boolean;
64
+ };
65
+ h3: {
66
+ isActive: boolean;
67
+ isConflicting: boolean;
68
+ isBlocking: boolean;
69
+ };
70
+ h4: {
71
+ isActive: boolean;
72
+ isConflicting: boolean;
73
+ isBlocking: boolean;
74
+ };
75
+ h5: {
76
+ isActive: boolean;
77
+ isConflicting: boolean;
78
+ isBlocking: boolean;
79
+ };
80
+ h6: {
81
+ isActive: boolean;
82
+ isConflicting: boolean;
83
+ isBlocking: boolean;
84
+ };
85
+ codeBlock: {
86
+ isActive: boolean;
87
+ isConflicting: boolean;
88
+ isBlocking: boolean;
89
+ };
90
+ blockQuote: {
91
+ isActive: boolean;
92
+ isConflicting: boolean;
93
+ isBlocking: boolean;
94
+ };
95
+ orderedList: {
96
+ isActive: boolean;
97
+ isConflicting: boolean;
98
+ isBlocking: boolean;
99
+ };
100
+ unorderedList: {
101
+ isActive: boolean;
102
+ isConflicting: boolean;
103
+ isBlocking: boolean;
104
+ };
105
+ link: {
106
+ isActive: boolean;
107
+ isConflicting: boolean;
108
+ isBlocking: boolean;
109
+ };
110
+ image: {
111
+ isActive: boolean;
112
+ isConflicting: boolean;
113
+ isBlocking: boolean;
114
+ };
115
+ mention: {
116
+ isActive: boolean;
117
+ isConflicting: boolean;
118
+ isBlocking: boolean;
119
+ };
120
+ }
121
+
122
+ export interface OnChangeStateDeprecatedEvent {
20
123
  isBold: boolean;
21
124
  isItalic: boolean;
22
125
  isUnderline: boolean;
@@ -25,6 +128,9 @@ export interface OnChangeStateEvent {
25
128
  isH1: boolean;
26
129
  isH2: boolean;
27
130
  isH3: boolean;
131
+ isH4: boolean;
132
+ isH5: boolean;
133
+ isH6: boolean;
28
134
  isCodeBlock: boolean;
29
135
  isBlockQuote: boolean;
30
136
  isOrderedList: boolean;
@@ -75,19 +181,22 @@ export interface MentionStyleProperties {
75
181
  textDecorationLine?: 'underline' | 'none';
76
182
  }
77
183
 
184
+ export interface OnKeyPressEvent {
185
+ key: string;
186
+ }
187
+
188
+ type Heading = {
189
+ fontSize?: Float;
190
+ bold?: boolean;
191
+ };
192
+
78
193
  export interface HtmlStyleInternal {
79
- h1?: {
80
- fontSize?: Float;
81
- bold?: boolean;
82
- };
83
- h2?: {
84
- fontSize?: Float;
85
- bold?: boolean;
86
- };
87
- h3?: {
88
- fontSize?: Float;
89
- bold?: boolean;
90
- };
194
+ h1?: Heading;
195
+ h2?: Heading;
196
+ h3?: Heading;
197
+ h4?: Heading;
198
+ h5?: Heading;
199
+ h6?: Heading;
91
200
  blockquote?: {
92
201
  borderColor?: ColorValue;
93
202
  borderWidth?: Float;
@@ -137,6 +246,7 @@ export interface NativeProps extends ViewProps {
137
246
  autoCapitalize?: string;
138
247
  htmlStyle?: HtmlStyleInternal;
139
248
  scrollEnabled?: boolean;
249
+ linkRegex?: LinkNativeRegex;
140
250
 
141
251
  // event callbacks
142
252
  onInputFocus?: DirectEventHandler<null>;
@@ -144,11 +254,13 @@ export interface NativeProps extends ViewProps {
144
254
  onChangeText?: DirectEventHandler<OnChangeTextEvent>;
145
255
  onChangeHtml?: DirectEventHandler<OnChangeHtmlEvent>;
146
256
  onChangeState?: DirectEventHandler<OnChangeStateEvent>;
257
+ onChangeStateDeprecated?: DirectEventHandler<OnChangeStateDeprecatedEvent>;
147
258
  onLinkDetected?: DirectEventHandler<OnLinkDetected>;
148
259
  onMentionDetected?: DirectEventHandler<OnMentionDetectedInternal>;
149
260
  onMention?: DirectEventHandler<OnMentionEvent>;
150
261
  onChangeSelection?: DirectEventHandler<OnChangeSelectionEvent>;
151
262
  onRequestHtmlResult?: DirectEventHandler<OnRequestHtmlResultEvent>;
263
+ onInputKeyPress?: DirectEventHandler<OnKeyPressEvent>;
152
264
 
153
265
  // Style related props - used for generating proper setters in component's manager
154
266
  // These should not be passed as regular props
@@ -160,6 +272,8 @@ export interface NativeProps extends ViewProps {
160
272
 
161
273
  // Used for onChangeHtml event performance optimization
162
274
  isOnChangeHtmlSet: boolean;
275
+ // Used for onChangeText event performance optimization
276
+ isOnChangeTextSet: boolean;
163
277
 
164
278
  // Experimental
165
279
  androidExperimentalSynchronousEvents: boolean;
@@ -172,6 +286,11 @@ interface NativeCommands {
172
286
  focus: (viewRef: React.ElementRef<ComponentType>) => void;
173
287
  blur: (viewRef: React.ElementRef<ComponentType>) => void;
174
288
  setValue: (viewRef: React.ElementRef<ComponentType>, text: string) => void;
289
+ setSelection: (
290
+ viewRef: React.ElementRef<ComponentType>,
291
+ start: Int32,
292
+ end: Int32
293
+ ) => void;
175
294
 
176
295
  // Text formatting commands
177
296
  toggleBold: (viewRef: React.ElementRef<ComponentType>) => void;
@@ -182,6 +301,9 @@ interface NativeCommands {
182
301
  toggleH1: (viewRef: React.ElementRef<ComponentType>) => void;
183
302
  toggleH2: (viewRef: React.ElementRef<ComponentType>) => void;
184
303
  toggleH3: (viewRef: React.ElementRef<ComponentType>) => void;
304
+ toggleH4: (viewRef: React.ElementRef<ComponentType>) => void;
305
+ toggleH5: (viewRef: React.ElementRef<ComponentType>) => void;
306
+ toggleH6: (viewRef: React.ElementRef<ComponentType>) => void;
185
307
  toggleCodeBlock: (viewRef: React.ElementRef<ComponentType>) => void;
186
308
  toggleBlockQuote: (viewRef: React.ElementRef<ComponentType>) => void;
187
309
  toggleOrderedList: (viewRef: React.ElementRef<ComponentType>) => void;
@@ -221,6 +343,7 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
221
343
  'focus',
222
344
  'blur',
223
345
  'setValue',
346
+ 'setSelection',
224
347
 
225
348
  // Text formatting commands
226
349
  'toggleBold',
@@ -231,6 +354,9 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
231
354
  'toggleH1',
232
355
  'toggleH2',
233
356
  'toggleH3',
357
+ 'toggleH4',
358
+ 'toggleH5',
359
+ 'toggleH6',
234
360
  'toggleCodeBlock',
235
361
  'toggleBlockQuote',
236
362
  'toggleOrderedList',
package/src/index.tsx CHANGED
@@ -3,7 +3,9 @@ export type {
3
3
  OnChangeTextEvent,
4
4
  OnChangeHtmlEvent,
5
5
  OnChangeStateEvent,
6
+ OnChangeStateDeprecatedEvent,
6
7
  OnLinkDetected,
7
8
  OnMentionDetected,
8
9
  OnChangeSelectionEvent,
10
+ OnKeyPressEvent,
9
11
  } from './EnrichedTextInputNativeComponent';
@@ -1,9 +1,9 @@
1
- import type { HtmlStyle } from './EnrichedTextInput';
1
+ import type { HtmlStyle } from '../EnrichedTextInput';
2
2
  import { type ColorValue, processColor } from 'react-native';
3
3
  import type {
4
4
  MentionStyleProperties,
5
5
  HtmlStyleInternal,
6
- } from './EnrichedTextInputNativeComponent';
6
+ } from '../EnrichedTextInputNativeComponent';
7
7
 
8
8
  const defaultStyle: Required<HtmlStyle> = {
9
9
  h1: {
@@ -18,6 +18,18 @@ const defaultStyle: Required<HtmlStyle> = {
18
18
  fontSize: 20,
19
19
  bold: false,
20
20
  },
21
+ h4: {
22
+ fontSize: 16,
23
+ bold: false,
24
+ },
25
+ h5: {
26
+ fontSize: 14,
27
+ bold: false,
28
+ },
29
+ h6: {
30
+ fontSize: 12,
31
+ bold: false,
32
+ },
21
33
  blockquote: {
22
34
  borderColor: 'darkgray',
23
35
  borderWidth: 4,
@@ -0,0 +1,56 @@
1
+ import type { LinkNativeRegex } from '../EnrichedTextInputNativeComponent';
2
+
3
+ const DISABLED_REGEX: LinkNativeRegex = {
4
+ pattern: '',
5
+ caseInsensitive: false,
6
+ dotAll: false,
7
+ isDisabled: true,
8
+ isDefault: false,
9
+ };
10
+
11
+ const DEFAULT_REGEX: LinkNativeRegex = {
12
+ pattern: '',
13
+ caseInsensitive: false,
14
+ dotAll: false,
15
+ isDisabled: false,
16
+ isDefault: true,
17
+ };
18
+
19
+ export const toNativeRegexConfig = (
20
+ regex: RegExp | undefined | null
21
+ ): LinkNativeRegex => {
22
+ if (regex === null) {
23
+ return DISABLED_REGEX;
24
+ }
25
+
26
+ if (regex === undefined) {
27
+ return DEFAULT_REGEX;
28
+ }
29
+
30
+ const source = regex.source;
31
+
32
+ // iOS fails on variable-width lookbehinds like (?<=a+)
33
+ const hasLookbehind = source.includes('(?<=') || source.includes('(?<!');
34
+
35
+ if (hasLookbehind) {
36
+ // Basic detection for quantifiers inside a group
37
+ const lookbehindContent = source.match(/\(\?<[=!](.*?)\)/)?.[1] || '';
38
+ if (/[*+{]/.test(lookbehindContent)) {
39
+ if (__DEV__) {
40
+ console.error(
41
+ 'Variable-width lookbehinds are not supported. Using default link regex.'
42
+ );
43
+ }
44
+
45
+ return DEFAULT_REGEX;
46
+ }
47
+ }
48
+
49
+ return {
50
+ pattern: source,
51
+ caseInsensitive: regex.ignoreCase,
52
+ dotAll: regex.dotAll,
53
+ isDisabled: false,
54
+ isDefault: false,
55
+ };
56
+ };
@@ -1 +0,0 @@
1
- {"version":3,"names":["processColor","defaultStyle","h1","fontSize","bold","h2","h3","blockquote","borderColor","borderWidth","gapWidth","color","undefined","codeblock","borderRadius","backgroundColor","code","a","textDecorationLine","mention","ol","marginLeft","markerFontWeight","markerColor","ul","bulletColor","bulletSize","isMentionStyleRecord","mentionStyle","Array","isArray","keys","Object","length","every","key","convertToHtmlStyleInternal","style","mentionIndicators","mentionStyles","forEach","indicator","default","String","olStyles","assignDefaultValues","merged","parseStyle","name","value","endsWith","parseColors","finalStyle","tagName","tagStyle","entries","tagStyles","styleName","styleValue","normalizeHtmlStyle","converted","withDefaults"],"sourceRoot":"../../src","sources":["normalizeHtmlStyle.ts"],"mappings":";;AACA,SAA0BA,YAAY,QAAQ,cAAc;AAM5D,MAAMC,YAAiC,GAAG;EACxCC,EAAE,EAAE;IACFC,QAAQ,EAAE,EAAE;IACZC,IAAI,EAAE;EACR,CAAC;EACDC,EAAE,EAAE;IACFF,QAAQ,EAAE,EAAE;IACZC,IAAI,EAAE;EACR,CAAC;EACDE,EAAE,EAAE;IACFH,QAAQ,EAAE,EAAE;IACZC,IAAI,EAAE;EACR,CAAC;EACDG,UAAU,EAAE;IACVC,WAAW,EAAE,UAAU;IACvBC,WAAW,EAAE,CAAC;IACdC,QAAQ,EAAE,EAAE;IACZC,KAAK,EAAEC;EACT,CAAC;EACDC,SAAS,EAAE;IACTF,KAAK,EAAE,OAAO;IACdG,YAAY,EAAE,CAAC;IACfC,eAAe,EAAE;EACnB,CAAC;EACDC,IAAI,EAAE;IACJL,KAAK,EAAE,KAAK;IACZI,eAAe,EAAE;EACnB,CAAC;EACDE,CAAC,EAAE;IACDN,KAAK,EAAE,MAAM;IACbO,kBAAkB,EAAE;EACtB,CAAC;EACDC,OAAO,EAAE;IACPR,KAAK,EAAE,MAAM;IACbI,eAAe,EAAE,QAAQ;IACzBG,kBAAkB,EAAE;EACtB,CAAC;EACDE,EAAE,EAAE;IACFV,QAAQ,EAAE,EAAE;IACZW,UAAU,EAAE,EAAE;IACdC,gB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AG,CAAC,CAAC;IAEzC,IAAIH,OAAO,KAAK,SAAS,EAAE;MACzB,KAAK,MAAM,CAACZ,SAAS,EAAEb,YAAY,CAAC,IAAII,MAAM,CAACuB,OAAO,CAACD,QAAQ,CAAC,EAAE;QAChEE,SAAS,CAACf,SAAS,CAAC,GAAG,CAAC,CAAC;QAEzB,KAAK,MAAM,CAACgB,SAAS,EAAEC,UAAU,CAAC,IAAI1B,MAAM,CAACuB,OAAO,CAClD3B,YACF,CAAC,EAAE;UACD4B,SAAS,CAACf,SAAS,CAAC,CAACgB,SAAS,CAAC,GAAGV,UAAU,CAACU,SAAS,EAAEC,UAAU,CAAC;QACrE;MACF;MAEAN,UAAU,CAACC,OAAO,CAAC,GAAGG,SAAS;MAC/B;IACF;IAEA,KAAK,MAAM,CAACC,SAAS,EAAEC,UAAU,CAAC,IAAI1B,MAAM,CAACuB,OAAO,CAACD,QAAQ,CAAC,EAAE;MAC9DE,SAAS,CAACC,SAAS,CAAC,GAAGV,UAAU,CAACU,SAAS,EAAEC,UAAU,CAAC;IAC1D;IAEAN,UAAU,CAACC,OAAO,CAAC,GAAGG,SAAS;EACjC;EAEA,OAAOJ,UAAU;AACnB,CAAC;AAED,OAAO,MAAMO,kBAAkB,GAAGA,CAChCtB,KAAgB,EAChBC,iBAA2B,KACL;EACtB,MAAMsB,SAAS,GAAGxB,0BAA0B,CAACC,KAAK,EAAEC,iBAAiB,CAAC;EACtE,MAAMuB,YAAY,GAAGhB,mBAAmB,CAACe,SAAS,CAAC;EACnD,OAAOT,WAAW,CAACU,YAAY,CAAC;AAClC,CAAC","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- import type { HtmlStyle } from './EnrichedTextInput';
2
- import type { HtmlStyleInternal } from './EnrichedTextInputNativeComponent';
3
- export declare const normalizeHtmlStyle: (style: HtmlStyle, mentionIndicators: string[]) => HtmlStyleInternal;
4
- //# sourceMappingURL=normalizeHtmlStyle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeHtmlStyle.d.ts","sourceRoot":"","sources":["../../../src/normalizeHtmlStyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,oCAAoC,CAAC;AA2K5C,eAAO,MAAM,kBAAkB,GAC7B,OAAO,SAAS,EAChB,mBAAmB,MAAM,EAAE,KAC1B,iBAIF,CAAC"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes