react-native-enriched 0.1.6 → 0.2.1
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.
- package/README.md +4 -14
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +4 -1
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +2 -1
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.cpp +10 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h +7 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.h +0 -45
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt +111 -2
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +9 -3
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewPackage.kt +2 -0
- package/android/src/main/java/com/swmansion/enriched/events/MentionHandler.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/events/OnRequestHtmlResultEvent.kt +33 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBlockQuoteSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBoldSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedCodeBlockSpan.kt +42 -1
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH1Span.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH2Span.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH3Span.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedImageSpan.kt +135 -9
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedInlineCodeSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedItalicSpan.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedLinkSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedMentionSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedOrderedListSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedSpans.kt +13 -3
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedStrikeThroughSpan.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnderlineSpan.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnorderedListSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/utils/ForceRedrawSpan.kt +13 -0
- package/android/src/main/java/com/swmansion/enriched/styles/HtmlStyle.kt +80 -9
- package/android/src/main/java/com/swmansion/enriched/styles/InlineStyles.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/styles/ParagraphStyles.kt +188 -5
- package/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt +57 -30
- package/android/src/main/java/com/swmansion/enriched/utils/AsyncDrawable.kt +91 -0
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedParser.java +24 -13
- package/android/src/main/java/com/swmansion/enriched/utils/ResourceManager.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedSpanWatcher.kt +3 -0
- package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.cpp +6 -6
- package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.h +6 -6
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputComponentDescriptor.h +19 -19
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.cpp +40 -51
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.h +13 -15
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.cpp +23 -21
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.h +35 -36
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.cpp +4 -4
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.h +13 -14
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/conversions.h +12 -13
- package/android/src/main/res/drawable/broken_image.xml +10 -0
- package/ios/EnrichedTextInputView.h +27 -12
- package/ios/EnrichedTextInputView.mm +906 -547
- package/ios/attachments/ImageAttachment.h +10 -0
- package/ios/attachments/ImageAttachment.mm +34 -0
- package/ios/attachments/MediaAttachment.h +23 -0
- package/ios/attachments/MediaAttachment.mm +31 -0
- package/ios/config/InputConfig.h +12 -6
- package/ios/config/InputConfig.mm +71 -33
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.cpp +10 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.h +7 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/Props.h +0 -45
- package/ios/generated/RNEnrichedTextInputViewSpec/RCTComponentViewHelpers.h +41 -4
- package/ios/inputParser/InputParser.h +5 -5
- package/ios/inputParser/InputParser.mm +867 -333
- package/ios/inputTextView/InputTextView.h +1 -1
- package/ios/inputTextView/InputTextView.mm +100 -59
- package/ios/internals/EnrichedTextInputViewComponentDescriptor.h +11 -9
- package/ios/internals/EnrichedTextInputViewShadowNode.h +28 -24
- package/ios/internals/EnrichedTextInputViewShadowNode.mm +64 -47
- package/ios/internals/EnrichedTextInputViewState.h +3 -1
- package/ios/styles/BlockQuoteStyle.mm +192 -142
- package/ios/styles/BoldStyle.mm +96 -62
- package/ios/styles/CodeBlockStyle.mm +304 -0
- package/ios/styles/H1Style.mm +10 -3
- package/ios/styles/H2Style.mm +10 -3
- package/ios/styles/H3Style.mm +10 -3
- package/ios/styles/HeadingStyleBase.mm +129 -84
- package/ios/styles/ImageStyle.mm +160 -0
- package/ios/styles/InlineCodeStyle.mm +149 -84
- package/ios/styles/ItalicStyle.mm +77 -51
- package/ios/styles/LinkStyle.mm +353 -224
- package/ios/styles/MentionStyle.mm +434 -220
- package/ios/styles/OrderedListStyle.mm +172 -105
- package/ios/styles/StrikethroughStyle.mm +53 -34
- package/ios/styles/UnderlineStyle.mm +69 -45
- package/ios/styles/UnorderedListStyle.mm +170 -105
- package/ios/utils/BaseStyleProtocol.h +3 -2
- package/ios/utils/ColorExtension.mm +7 -5
- package/ios/utils/FontExtension.mm +42 -27
- package/ios/utils/ImageData.h +10 -0
- package/ios/utils/ImageData.mm +4 -0
- package/ios/utils/LayoutManagerExtension.h +1 -1
- package/ios/utils/LayoutManagerExtension.mm +334 -109
- package/ios/utils/MentionParams.h +0 -1
- package/ios/utils/MentionStyleProps.h +1 -1
- package/ios/utils/MentionStyleProps.mm +27 -20
- package/ios/utils/OccurenceUtils.h +42 -38
- package/ios/utils/OccurenceUtils.mm +177 -107
- package/ios/utils/ParagraphAttributesUtils.h +6 -1
- package/ios/utils/ParagraphAttributesUtils.mm +152 -41
- package/ios/utils/ParagraphsUtils.h +2 -1
- package/ios/utils/ParagraphsUtils.mm +40 -26
- package/ios/utils/StringExtension.h +1 -1
- package/ios/utils/StringExtension.mm +19 -16
- package/ios/utils/StyleHeaders.h +35 -11
- package/ios/utils/TextInsertionUtils.h +13 -2
- package/ios/utils/TextInsertionUtils.mm +38 -20
- package/ios/utils/WordsUtils.h +2 -1
- package/ios/utils/WordsUtils.mm +32 -22
- package/ios/utils/ZeroWidthSpaceUtils.h +3 -1
- package/ios/utils/ZeroWidthSpaceUtils.mm +153 -75
- package/lib/module/EnrichedTextInput.js +41 -3
- package/lib/module/EnrichedTextInput.js.map +1 -1
- package/lib/module/EnrichedTextInputNativeComponent.ts +17 -5
- package/lib/module/normalizeHtmlStyle.js +0 -4
- package/lib/module/normalizeHtmlStyle.js.map +1 -1
- package/lib/typescript/src/EnrichedTextInput.d.ts +2 -5
- package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts +7 -5
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/normalizeHtmlStyle.d.ts.map +1 -1
- package/package.json +8 -1
- package/src/EnrichedTextInput.tsx +48 -7
- package/src/EnrichedTextInputNativeComponent.ts +17 -5
- package/src/normalizeHtmlStyle.ts +0 -4
package/ios/utils/WordsUtils.mm
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
@implementation WordsUtils
|
|
4
4
|
|
|
5
|
-
+ (NSArray<NSDictionary *> *)getAffectedWordsFromText:(NSString *)text
|
|
6
|
-
|
|
5
|
+
+ (NSArray<NSDictionary *> *)getAffectedWordsFromText:(NSString *)text
|
|
6
|
+
modificationRange:(NSRange)range {
|
|
7
|
+
if (text.length == 0) {
|
|
7
8
|
return [[NSArray alloc] init];
|
|
8
9
|
}
|
|
9
10
|
|
|
@@ -12,7 +13,8 @@
|
|
|
12
13
|
if (leftIt > 0) {
|
|
13
14
|
while (leftIt >= 0) {
|
|
14
15
|
unichar charAtIndex = [text characterAtIndex:leftIt];
|
|
15
|
-
if ([[NSCharacterSet whitespaceAndNewlineCharacterSet]
|
|
16
|
+
if ([[NSCharacterSet whitespaceAndNewlineCharacterSet]
|
|
17
|
+
characterIsMember:charAtIndex]) {
|
|
16
18
|
leftIt += 1;
|
|
17
19
|
break;
|
|
18
20
|
}
|
|
@@ -21,12 +23,13 @@
|
|
|
21
23
|
}
|
|
22
24
|
leftIt = MAX(0, leftIt);
|
|
23
25
|
leftIt = MIN(NSInteger(text.length - 1), leftIt);
|
|
24
|
-
|
|
26
|
+
|
|
25
27
|
NSInteger rightIt = range.location + range.length;
|
|
26
28
|
if (rightIt < text.length - 1) {
|
|
27
29
|
while (rightIt <= text.length - 1) {
|
|
28
30
|
unichar charAtIndex = [text characterAtIndex:rightIt];
|
|
29
|
-
if ([[NSCharacterSet whitespaceAndNewlineCharacterSet]
|
|
31
|
+
if ([[NSCharacterSet whitespaceAndNewlineCharacterSet]
|
|
32
|
+
characterIsMember:charAtIndex]) {
|
|
30
33
|
rightIt -= 1;
|
|
31
34
|
break;
|
|
32
35
|
}
|
|
@@ -34,23 +37,26 @@
|
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
rightIt = MIN(NSInteger(text.length - 1), rightIt);
|
|
37
|
-
|
|
38
|
-
if(leftIt > rightIt) {
|
|
40
|
+
|
|
41
|
+
if (leftIt > rightIt) {
|
|
39
42
|
return [[NSArray alloc] init];
|
|
40
43
|
}
|
|
41
|
-
|
|
42
|
-
NSMutableArray<NSDictionary *> *separatedWords =
|
|
44
|
+
|
|
45
|
+
NSMutableArray<NSDictionary *> *separatedWords =
|
|
46
|
+
[[NSMutableArray<NSDictionary *> alloc] init];
|
|
43
47
|
NSMutableString *currentWord = [[NSMutableString alloc] init];
|
|
44
48
|
NSInteger currentRangeStart = leftIt;
|
|
45
49
|
NSInteger currentIdx = leftIt;
|
|
46
|
-
|
|
50
|
+
|
|
47
51
|
while (currentIdx <= rightIt) {
|
|
48
52
|
unichar charAtIndex = [text characterAtIndex:currentIdx];
|
|
49
|
-
if ([[NSCharacterSet whitespaceAndNewlineCharacterSet]
|
|
53
|
+
if ([[NSCharacterSet whitespaceAndNewlineCharacterSet]
|
|
54
|
+
characterIsMember:charAtIndex]) {
|
|
50
55
|
if (currentWord.length > 0) {
|
|
51
56
|
[separatedWords addObject:@{
|
|
52
|
-
@"word": [currentWord copy],
|
|
53
|
-
@"range": [NSValue
|
|
57
|
+
@"word" : [currentWord copy],
|
|
58
|
+
@"range" : [NSValue
|
|
59
|
+
valueWithRange:NSMakeRange(currentRangeStart, currentWord.length)]
|
|
54
60
|
}];
|
|
55
61
|
[currentWord setString:@""];
|
|
56
62
|
}
|
|
@@ -60,28 +66,32 @@
|
|
|
60
66
|
}
|
|
61
67
|
currentIdx += 1;
|
|
62
68
|
}
|
|
63
|
-
|
|
69
|
+
|
|
64
70
|
if (currentWord.length > 0) {
|
|
65
71
|
[separatedWords addObject:@{
|
|
66
|
-
@"word": [currentWord copy],
|
|
67
|
-
@"range"
|
|
72
|
+
@"word" : [currentWord copy],
|
|
73
|
+
@"range" :
|
|
74
|
+
[NSValue valueWithRange:NSMakeRange(currentRangeStart,
|
|
75
|
+
rightIt - currentRangeStart + 1)]
|
|
68
76
|
}];
|
|
69
77
|
}
|
|
70
|
-
|
|
78
|
+
|
|
71
79
|
return separatedWords;
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
+ (NSDictionary *)getCurrentWord:(NSString *)text range:(NSRange)range {
|
|
75
83
|
// we just get current word at the cursor
|
|
76
|
-
if(range.length > 0) {
|
|
84
|
+
if (range.length > 0) {
|
|
77
85
|
return nullptr;
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
NSArray<NSDictionary *> *words = [WordsUtils getAffectedWordsFromText:text
|
|
81
|
-
|
|
87
|
+
|
|
88
|
+
NSArray<NSDictionary *> *words = [WordsUtils getAffectedWordsFromText:text
|
|
89
|
+
modificationRange:range];
|
|
90
|
+
if (words != nullptr && [words count] == 1 &&
|
|
91
|
+
[words firstObject] != nullptr) {
|
|
82
92
|
return [words firstObject];
|
|
83
93
|
}
|
|
84
|
-
|
|
94
|
+
|
|
85
95
|
return nullptr;
|
|
86
96
|
}
|
|
87
97
|
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
@interface ZeroWidthSpaceUtils : NSObject
|
|
5
5
|
+ (void)handleZeroWidthSpacesInInput:(id)input;
|
|
6
|
-
+ (BOOL)handleBackspaceInRange:(NSRange)range
|
|
6
|
+
+ (BOOL)handleBackspaceInRange:(NSRange)range
|
|
7
|
+
replacementText:(NSString *)text
|
|
8
|
+
input:(id)input;
|
|
7
9
|
@end
|
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
@implementation ZeroWidthSpaceUtils
|
|
8
8
|
+ (void)handleZeroWidthSpacesInInput:(id)input {
|
|
9
9
|
EnrichedTextInputView *typedInput = (EnrichedTextInputView *)input;
|
|
10
|
-
if(typedInput == nullptr) {
|
|
11
|
-
|
|
10
|
+
if (typedInput == nullptr) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
12
14
|
[self removeSpacesIfNeededinInput:typedInput];
|
|
13
15
|
[self addSpacesIfNeededinInput:typedInput];
|
|
14
16
|
}
|
|
@@ -17,154 +19,230 @@
|
|
|
17
19
|
NSMutableArray *indexesToBeRemoved = [[NSMutableArray alloc] init];
|
|
18
20
|
NSRange preRemoveSelection = input->textView.selectedRange;
|
|
19
21
|
|
|
20
|
-
for(int i = 0; i < input->textView.textStorage.string.length; i++) {
|
|
22
|
+
for (int i = 0; i < input->textView.textStorage.string.length; i++) {
|
|
21
23
|
unichar character = [input->textView.textStorage.string characterAtIndex:i];
|
|
22
|
-
if(character == 0x200B) {
|
|
24
|
+
if (character == 0x200B) {
|
|
23
25
|
NSRange characterRange = NSMakeRange(i, 1);
|
|
24
|
-
|
|
25
|
-
NSRange paragraphRange = [input->textView.textStorage.string
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
NSRange paragraphRange = [input->textView.textStorage.string
|
|
28
|
+
paragraphRangeForRange:characterRange];
|
|
29
|
+
// having paragraph longer than 1 character means someone most likely
|
|
30
|
+
// added something and we probably can remove the space
|
|
27
31
|
BOOL removeSpace = paragraphRange.length > 1;
|
|
28
32
|
// exception; 2 characters paragraph with zero width space + newline
|
|
29
33
|
// here, we still need zero width space to keep the empty list items
|
|
30
|
-
if(paragraphRange.length == 2 &&
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
if (paragraphRange.length == 2 && paragraphRange.location == i &&
|
|
35
|
+
[[NSCharacterSet newlineCharacterSet]
|
|
36
|
+
characterIsMember:[input->textView.textStorage.string
|
|
37
|
+
characterAtIndex:i + 1]]) {
|
|
34
38
|
removeSpace = NO;
|
|
35
39
|
}
|
|
36
|
-
|
|
37
|
-
if(removeSpace) {
|
|
40
|
+
|
|
41
|
+
if (removeSpace) {
|
|
38
42
|
[indexesToBeRemoved addObject:@(characterRange.location)];
|
|
39
43
|
continue;
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
UnorderedListStyle *ulStyle =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
|
|
46
|
+
UnorderedListStyle *ulStyle =
|
|
47
|
+
input->stylesDict[@([UnorderedListStyle getStyleType])];
|
|
48
|
+
OrderedListStyle *olStyle =
|
|
49
|
+
input->stylesDict[@([OrderedListStyle getStyleType])];
|
|
50
|
+
BlockQuoteStyle *bqStyle =
|
|
51
|
+
input->stylesDict[@([BlockQuoteStyle getStyleType])];
|
|
52
|
+
CodeBlockStyle *cbStyle =
|
|
53
|
+
input->stylesDict[@([CodeBlockStyle getStyleType])];
|
|
54
|
+
|
|
55
|
+
// zero width spaces with no lists/blockquotes/codeblocks on them get
|
|
56
|
+
// removed
|
|
57
|
+
if (![ulStyle detectStyle:characterRange] &&
|
|
58
|
+
![olStyle detectStyle:characterRange] &&
|
|
59
|
+
![bqStyle detectStyle:characterRange] &&
|
|
60
|
+
![cbStyle detectStyle:characterRange]) {
|
|
48
61
|
[indexesToBeRemoved addObject:@(characterRange.location)];
|
|
49
62
|
}
|
|
50
63
|
}
|
|
51
64
|
}
|
|
52
|
-
|
|
65
|
+
|
|
53
66
|
// do the removing
|
|
54
67
|
NSInteger offset = 0;
|
|
55
68
|
NSInteger postRemoveLocationOffset = 0;
|
|
56
69
|
NSInteger postRemoveLengthOffset = 0;
|
|
57
|
-
for(NSNumber *index in indexesToBeRemoved) {
|
|
70
|
+
for (NSNumber *index in indexesToBeRemoved) {
|
|
58
71
|
NSRange replaceRange = NSMakeRange([index integerValue] + offset, 1);
|
|
59
|
-
[TextInsertionUtils replaceText:@""
|
|
72
|
+
[TextInsertionUtils replaceText:@""
|
|
73
|
+
at:replaceRange
|
|
74
|
+
additionalAttributes:nullptr
|
|
75
|
+
input:input
|
|
76
|
+
withSelection:NO];
|
|
60
77
|
offset -= 1;
|
|
61
|
-
if([index integerValue] < preRemoveSelection.location) {
|
|
78
|
+
if ([index integerValue] < preRemoveSelection.location) {
|
|
62
79
|
postRemoveLocationOffset -= 1;
|
|
63
80
|
}
|
|
64
|
-
if([index integerValue] >= preRemoveSelection.location &&
|
|
81
|
+
if ([index integerValue] >= preRemoveSelection.location &&
|
|
82
|
+
[index integerValue] < NSMaxRange(preRemoveSelection)) {
|
|
65
83
|
postRemoveLengthOffset -= 1;
|
|
66
84
|
}
|
|
67
85
|
}
|
|
68
|
-
|
|
86
|
+
|
|
69
87
|
// fix the selection if needed
|
|
70
|
-
if([input->textView isFirstResponder]) {
|
|
71
|
-
input->textView.selectedRange =
|
|
88
|
+
if ([input->textView isFirstResponder]) {
|
|
89
|
+
input->textView.selectedRange =
|
|
90
|
+
NSMakeRange(preRemoveSelection.location + postRemoveLocationOffset,
|
|
91
|
+
preRemoveSelection.length + postRemoveLengthOffset);
|
|
72
92
|
}
|
|
73
93
|
}
|
|
74
94
|
|
|
75
95
|
+ (void)addSpacesIfNeededinInput:(EnrichedTextInputView *)input {
|
|
76
|
-
UnorderedListStyle *ulStyle =
|
|
77
|
-
|
|
78
|
-
|
|
96
|
+
UnorderedListStyle *ulStyle =
|
|
97
|
+
input->stylesDict[@([UnorderedListStyle getStyleType])];
|
|
98
|
+
OrderedListStyle *olStyle =
|
|
99
|
+
input->stylesDict[@([OrderedListStyle getStyleType])];
|
|
100
|
+
BlockQuoteStyle *bqStyle =
|
|
101
|
+
input->stylesDict[@([BlockQuoteStyle getStyleType])];
|
|
102
|
+
CodeBlockStyle *cbStyle = input->stylesDict[@([CodeBlockStyle getStyleType])];
|
|
79
103
|
NSMutableArray *indexesToBeInserted = [[NSMutableArray alloc] init];
|
|
80
104
|
NSRange preAddSelection = input->textView.selectedRange;
|
|
81
|
-
|
|
82
|
-
for(int i = 0; i < input->textView.textStorage.string.length; i++) {
|
|
105
|
+
|
|
106
|
+
for (int i = 0; i < input->textView.textStorage.string.length; i++) {
|
|
83
107
|
unichar character = [input->textView.textStorage.string characterAtIndex:i];
|
|
84
|
-
|
|
85
|
-
if([[NSCharacterSet newlineCharacterSet] characterIsMember:character]) {
|
|
108
|
+
|
|
109
|
+
if ([[NSCharacterSet newlineCharacterSet] characterIsMember:character]) {
|
|
86
110
|
NSRange characterRange = NSMakeRange(i, 1);
|
|
87
|
-
NSRange paragraphRange = [input->textView.textStorage.string
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
111
|
+
NSRange paragraphRange = [input->textView.textStorage.string
|
|
112
|
+
paragraphRangeForRange:characterRange];
|
|
113
|
+
|
|
114
|
+
if (paragraphRange.length == 1) {
|
|
115
|
+
if ([ulStyle detectStyle:characterRange] ||
|
|
116
|
+
[olStyle detectStyle:characterRange] ||
|
|
117
|
+
[bqStyle detectStyle:characterRange] ||
|
|
118
|
+
[cbStyle detectStyle:characterRange]) {
|
|
91
119
|
// we have an empty list or quote item with no space: add it!
|
|
92
120
|
[indexesToBeInserted addObject:@(paragraphRange.location)];
|
|
93
121
|
}
|
|
94
122
|
}
|
|
95
123
|
}
|
|
96
124
|
}
|
|
97
|
-
|
|
125
|
+
|
|
98
126
|
// do the replacing
|
|
99
127
|
NSInteger offset = 0;
|
|
100
128
|
NSInteger postAddLocationOffset = 0;
|
|
101
129
|
NSInteger postAddLengthOffset = 0;
|
|
102
|
-
for(NSNumber *index in indexesToBeInserted) {
|
|
130
|
+
for (NSNumber *index in indexesToBeInserted) {
|
|
103
131
|
NSRange replaceRange = NSMakeRange([index integerValue] + offset, 1);
|
|
104
|
-
[TextInsertionUtils replaceText:@"\u200B\n"
|
|
132
|
+
[TextInsertionUtils replaceText:@"\u200B\n"
|
|
133
|
+
at:replaceRange
|
|
134
|
+
additionalAttributes:nullptr
|
|
135
|
+
input:input
|
|
136
|
+
withSelection:NO];
|
|
105
137
|
offset += 1;
|
|
106
|
-
if([index integerValue] < preAddSelection.location) {
|
|
138
|
+
if ([index integerValue] < preAddSelection.location) {
|
|
107
139
|
postAddLocationOffset += 1;
|
|
108
140
|
}
|
|
109
|
-
if([index integerValue] >= preAddSelection.location &&
|
|
141
|
+
if ([index integerValue] >= preAddSelection.location &&
|
|
142
|
+
[index integerValue] < NSMaxRange(preAddSelection)) {
|
|
110
143
|
postAddLengthOffset += 1;
|
|
111
144
|
}
|
|
112
145
|
}
|
|
113
|
-
|
|
146
|
+
|
|
114
147
|
// additional check for last index of the input
|
|
115
148
|
NSRange lastRange = NSMakeRange(input->textView.textStorage.string.length, 0);
|
|
116
|
-
NSRange lastParagraphRange =
|
|
117
|
-
|
|
118
|
-
|
|
149
|
+
NSRange lastParagraphRange =
|
|
150
|
+
[input->textView.textStorage.string paragraphRangeForRange:lastRange];
|
|
151
|
+
if (lastParagraphRange.length == 0 &&
|
|
152
|
+
([ulStyle detectStyle:lastRange] || [olStyle detectStyle:lastRange] ||
|
|
153
|
+
[bqStyle detectStyle:lastRange] || [cbStyle detectStyle:lastRange])) {
|
|
154
|
+
[TextInsertionUtils insertText:@"\u200B"
|
|
155
|
+
at:lastRange.location
|
|
156
|
+
additionalAttributes:nullptr
|
|
157
|
+
input:input
|
|
158
|
+
withSelection:NO];
|
|
119
159
|
}
|
|
120
|
-
|
|
160
|
+
|
|
121
161
|
// fix the selection if needed
|
|
122
|
-
if([input->textView isFirstResponder]) {
|
|
123
|
-
input->textView.selectedRange =
|
|
162
|
+
if ([input->textView isFirstResponder]) {
|
|
163
|
+
input->textView.selectedRange =
|
|
164
|
+
NSMakeRange(preAddSelection.location + postAddLocationOffset,
|
|
165
|
+
preAddSelection.length + postAddLengthOffset);
|
|
124
166
|
}
|
|
125
167
|
}
|
|
126
168
|
|
|
127
|
-
+ (BOOL)handleBackspaceInRange:(NSRange)range
|
|
128
|
-
|
|
169
|
+
+ (BOOL)handleBackspaceInRange:(NSRange)range
|
|
170
|
+
replacementText:(NSString *)text
|
|
171
|
+
input:(id)input {
|
|
172
|
+
if (range.length != 1 || ![text isEqualToString:@""]) {
|
|
173
|
+
return NO;
|
|
174
|
+
}
|
|
129
175
|
EnrichedTextInputView *typedInput = (EnrichedTextInputView *)input;
|
|
130
|
-
if(typedInput == nullptr) {
|
|
131
|
-
|
|
132
|
-
|
|
176
|
+
if (typedInput == nullptr) {
|
|
177
|
+
return NO;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
unichar character =
|
|
181
|
+
[typedInput->textView.textStorage.string characterAtIndex:range.location];
|
|
133
182
|
// zero-width space got backspaced
|
|
134
|
-
if(character == 0x200B) {
|
|
183
|
+
if (character == 0x200B) {
|
|
135
184
|
// in such case: remove the whole line without the endline if there is one
|
|
136
|
-
|
|
137
|
-
NSRange paragraphRange =
|
|
185
|
+
|
|
186
|
+
NSRange paragraphRange =
|
|
187
|
+
[typedInput->textView.textStorage.string paragraphRangeForRange:range];
|
|
138
188
|
NSRange removalRange = paragraphRange;
|
|
139
189
|
// if whole paragraph gets removed then 0 length for style removal
|
|
140
190
|
NSRange styleRemovalRange = NSMakeRange(paragraphRange.location, 0);
|
|
141
|
-
|
|
142
|
-
if([[NSCharacterSet newlineCharacterSet]
|
|
191
|
+
|
|
192
|
+
if ([[NSCharacterSet newlineCharacterSet]
|
|
193
|
+
characterIsMember:[typedInput->textView.textStorage.string
|
|
194
|
+
characterAtIndex:NSMaxRange(paragraphRange) -
|
|
195
|
+
1]]) {
|
|
143
196
|
// if endline is there, don't remove it
|
|
144
|
-
removalRange =
|
|
197
|
+
removalRange =
|
|
198
|
+
NSMakeRange(paragraphRange.location, paragraphRange.length - 1);
|
|
145
199
|
// if endline is left then 1 length for style removal
|
|
146
200
|
styleRemovalRange = NSMakeRange(paragraphRange.location, 1);
|
|
147
201
|
}
|
|
148
|
-
|
|
149
|
-
[TextInsertionUtils replaceText:@"" at:removalRange additionalAttributes:nullptr input:typedInput withSelection:YES];
|
|
150
|
-
|
|
202
|
+
|
|
151
203
|
// and then remove associated styling
|
|
152
|
-
|
|
153
|
-
UnorderedListStyle *ulStyle =
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
204
|
+
|
|
205
|
+
UnorderedListStyle *ulStyle =
|
|
206
|
+
typedInput->stylesDict[@([UnorderedListStyle getStyleType])];
|
|
207
|
+
OrderedListStyle *olStyle =
|
|
208
|
+
typedInput->stylesDict[@([OrderedListStyle getStyleType])];
|
|
209
|
+
BlockQuoteStyle *bqStyle =
|
|
210
|
+
typedInput->stylesDict[@([BlockQuoteStyle getStyleType])];
|
|
211
|
+
CodeBlockStyle *cbStyle =
|
|
212
|
+
typedInput->stylesDict[@([CodeBlockStyle getStyleType])];
|
|
213
|
+
|
|
214
|
+
if ([cbStyle detectStyle:removalRange]) {
|
|
215
|
+
// code blocks are being handled differently; we want to remove previous
|
|
216
|
+
// newline if there is a one
|
|
217
|
+
if (range.location > 0) {
|
|
218
|
+
removalRange =
|
|
219
|
+
NSMakeRange(removalRange.location - 1, removalRange.length + 1);
|
|
220
|
+
}
|
|
221
|
+
[TextInsertionUtils replaceText:@""
|
|
222
|
+
at:removalRange
|
|
223
|
+
additionalAttributes:nullptr
|
|
224
|
+
input:typedInput
|
|
225
|
+
withSelection:YES];
|
|
226
|
+
return YES;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
[TextInsertionUtils replaceText:@""
|
|
230
|
+
at:removalRange
|
|
231
|
+
additionalAttributes:nullptr
|
|
232
|
+
input:typedInput
|
|
233
|
+
withSelection:YES];
|
|
234
|
+
|
|
235
|
+
if ([ulStyle detectStyle:styleRemovalRange]) {
|
|
158
236
|
[ulStyle removeAttributes:styleRemovalRange];
|
|
159
|
-
} else if([olStyle detectStyle:styleRemovalRange]) {
|
|
237
|
+
} else if ([olStyle detectStyle:styleRemovalRange]) {
|
|
160
238
|
[olStyle removeAttributes:styleRemovalRange];
|
|
161
|
-
} else if([bqStyle detectStyle:styleRemovalRange]) {
|
|
239
|
+
} else if ([bqStyle detectStyle:styleRemovalRange]) {
|
|
162
240
|
[bqStyle removeAttributes:styleRemovalRange];
|
|
163
241
|
}
|
|
164
|
-
|
|
242
|
+
|
|
165
243
|
return YES;
|
|
166
244
|
}
|
|
167
245
|
return NO;
|
|
168
246
|
}
|
|
169
|
-
@end
|
|
170
247
|
|
|
248
|
+
@end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { useImperativeHandle, useMemo, useRef } from 'react';
|
|
3
|
+
import { useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
4
4
|
import EnrichedTextInputNativeComponent, { Commands } from './EnrichedTextInputNativeComponent';
|
|
5
5
|
import { normalizeHtmlStyle } from "./normalizeHtmlStyle.js";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -42,6 +42,19 @@ export const EnrichedTextInput = ({
|
|
|
42
42
|
...rest
|
|
43
43
|
}) => {
|
|
44
44
|
const nativeRef = useRef(null);
|
|
45
|
+
const nextHtmlRequestId = useRef(1);
|
|
46
|
+
const pendingHtmlRequests = useRef(new Map());
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const pendingRequests = pendingHtmlRequests.current;
|
|
49
|
+
return () => {
|
|
50
|
+
pendingRequests.forEach(({
|
|
51
|
+
reject
|
|
52
|
+
}) => {
|
|
53
|
+
reject(new Error('Component unmounted'));
|
|
54
|
+
});
|
|
55
|
+
pendingRequests.clear();
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
45
58
|
const normalizedHtmlStyle = useMemo(() => normalizeHtmlStyle(htmlStyle, mentionIndicators), [htmlStyle, mentionIndicators]);
|
|
46
59
|
useImperativeHandle(ref, () => ({
|
|
47
60
|
measureInWindow: callback => {
|
|
@@ -65,6 +78,16 @@ export const EnrichedTextInput = ({
|
|
|
65
78
|
setValue: value => {
|
|
66
79
|
Commands.setValue(nullthrows(nativeRef.current), value);
|
|
67
80
|
},
|
|
81
|
+
getHTML: () => {
|
|
82
|
+
return new Promise((resolve, reject) => {
|
|
83
|
+
const requestId = nextHtmlRequestId.current++;
|
|
84
|
+
pendingHtmlRequests.current.set(requestId, {
|
|
85
|
+
resolve,
|
|
86
|
+
reject
|
|
87
|
+
});
|
|
88
|
+
Commands.requestHTML(nullthrows(nativeRef.current), requestId);
|
|
89
|
+
});
|
|
90
|
+
},
|
|
68
91
|
toggleBold: () => {
|
|
69
92
|
Commands.toggleBold(nullthrows(nativeRef.current));
|
|
70
93
|
},
|
|
@@ -104,8 +127,8 @@ export const EnrichedTextInput = ({
|
|
|
104
127
|
setLink: (start, end, text, url) => {
|
|
105
128
|
Commands.addLink(nullthrows(nativeRef.current), start, end, text, url);
|
|
106
129
|
},
|
|
107
|
-
setImage: uri => {
|
|
108
|
-
Commands.addImage(nullthrows(nativeRef.current), uri);
|
|
130
|
+
setImage: (uri, width, height) => {
|
|
131
|
+
Commands.addImage(nullthrows(nativeRef.current), uri, width, height);
|
|
109
132
|
},
|
|
110
133
|
setMention: (indicator, text, attributes) => {
|
|
111
134
|
// Codegen does not support objects as Commands parameters, so we stringify attributes
|
|
@@ -162,6 +185,20 @@ export const EnrichedTextInput = ({
|
|
|
162
185
|
attributes
|
|
163
186
|
});
|
|
164
187
|
};
|
|
188
|
+
const handleRequestHtmlResult = e => {
|
|
189
|
+
const {
|
|
190
|
+
requestId,
|
|
191
|
+
html
|
|
192
|
+
} = e.nativeEvent;
|
|
193
|
+
const pending = pendingHtmlRequests.current.get(requestId);
|
|
194
|
+
if (!pending) return;
|
|
195
|
+
if (html === null || typeof html !== 'string') {
|
|
196
|
+
pending.reject(new Error('Failed to parse HTML'));
|
|
197
|
+
} else {
|
|
198
|
+
pending.resolve(html);
|
|
199
|
+
}
|
|
200
|
+
pendingHtmlRequests.current.delete(requestId);
|
|
201
|
+
};
|
|
165
202
|
return /*#__PURE__*/_jsx(EnrichedTextInputNativeComponent, {
|
|
166
203
|
ref: nativeRef,
|
|
167
204
|
mentionIndicators: mentionIndicators,
|
|
@@ -185,6 +222,7 @@ export const EnrichedTextInput = ({
|
|
|
185
222
|
onMentionDetected: handleMentionDetected,
|
|
186
223
|
onMention: handleMentionEvent,
|
|
187
224
|
onChangeSelection: onChangeSelection,
|
|
225
|
+
onRequestHtmlResult: handleRequestHtmlResult,
|
|
188
226
|
androidExperimentalSynchronousEvents: androidExperimentalSynchronousEvents,
|
|
189
227
|
scrollEnabled: scrollEnabled,
|
|
190
228
|
...rest
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useImperativeHandle","useMemo","useRef","EnrichedTextInputNativeComponent","Commands","normalizeHtmlStyle","jsx","_jsx","nullthrows","value","Error","warnAboutMissconfiguredMentions","indicator","console","warn","EnrichedTextInput","ref","autoFocus","editable","mentionIndicators","defaultValue","placeholder","placeholderTextColor","cursorColor","selectionColor","style","autoCapitalize","htmlStyle","onFocus","onBlur","onChangeText","onChangeHtml","onChangeState","onLinkDetected","onMentionDetected","onStartMention","onChangeMention","onEndMention","onChangeSelection","androidExperimentalSynchronousEvents","scrollEnabled","rest","nativeRef","
|
|
1
|
+
{"version":3,"names":["useEffect","useImperativeHandle","useMemo","useRef","EnrichedTextInputNativeComponent","Commands","normalizeHtmlStyle","jsx","_jsx","nullthrows","value","Error","warnAboutMissconfiguredMentions","indicator","console","warn","EnrichedTextInput","ref","autoFocus","editable","mentionIndicators","defaultValue","placeholder","placeholderTextColor","cursorColor","selectionColor","style","autoCapitalize","htmlStyle","onFocus","onBlur","onChangeText","onChangeHtml","onChangeState","onLinkDetected","onMentionDetected","onStartMention","onChangeMention","onEndMention","onChangeSelection","androidExperimentalSynchronousEvents","scrollEnabled","rest","nativeRef","nextHtmlRequestId","pendingHtmlRequests","Map","pendingRequests","current","forEach","reject","clear","normalizedHtmlStyle","measureInWindow","callback","measure","measureLayout","relativeToNativeComponentRef","onSuccess","onFail","setNativeProps","nativeProps","focus","blur","setValue","getHTML","Promise","resolve","requestId","set","requestHTML","toggleBold","toggleItalic","toggleUnderline","toggleStrikeThrough","toggleInlineCode","toggleH1","toggleH2","toggleH3","toggleCodeBlock","toggleBlockQuote","toggleOrderedList","toggleUnorderedList","setLink","start","end","text","url","addLink","setImage","uri","width","height","addImage","setMention","attributes","parsedAttributes","JSON","stringify","addMention","startMention","includes","handleMentionEvent","e","mentionText","nativeEvent","mentionIndicator","handleLinkDetected","handleMentionDetected","payload","parse","handleRequestHtmlResult","html","pending","get","delete","onInputFocus","onInputBlur","isOnChangeHtmlSet","undefined","onMention","onRequestHtmlResult"],"sourceRoot":"../../src","sources":["EnrichedTextInput.tsx"],"mappings":";;AAAA,SAGEA,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,QACD,OAAO;AACd,OAAOC,gCAAgC,IACrCC,QAAQ,QAYH,oCAAoC;AAa3C,SAASC,kBAAkB,QAAQ,yBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAuH1D,MAAMC,UAAU,GAAQC,KAA2B,IAAQ;EACzD,IAAIA,KAAK,IAAI,IAAI,EAAE;IACjB,MAAM,IAAIC,KAAK,CAAC,oCAAoC,CAAC;EACvD;EAEA,OAAOD,KAAK;AACd,CAAC;AAED,MAAME,+BAA+B,GAAIC,SAAiB,IAAK;EAC7DC,OAAO,CAACC,IAAI,CACV,uCAAuCF,SAAS,8CAClD,CAAC;AACH,CAAC;AASD,OAAO,MAAMG,iBAAiB,GAAGA,CAAC;EAChCC,GAAG;EACHC,SAAS;EACTC,QAAQ,GAAG,IAAI;EACfC,iBAAiB,GAAG,CAAC,GAAG,CAAC;EACzBC,YAAY;EACZC,WAAW;EACXC,oBAAoB;EACpBC,WAAW;EACXC,cAAc;EACdC,KAAK;EACLC,cAAc,GAAG,WAAW;EAC5BC,SAAS,GAAG,CAAC,CAAC;EACdC,OAAO;EACPC,MAAM;EACNC,YAAY;EACZC,YAAY;EACZC,aAAa;EACbC,cAAc;EACdC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mE,MAAM,CAAC/C,SAAS,CAAC;EAC/C,CAAC;EAED,oBACE5D,IAAA,CAACJ,gCAAgC;IAC/Ba,GAAG,EAAE0B,SAAU;IACfvB,iBAAiB,EAAEA,iBAAkB;IACrCD,QAAQ,EAAEA,QAAS;IACnBD,SAAS,EAAEA,SAAU;IACrBG,YAAY,EAAEA,YAAa;IAC3BC,WAAW,EAAEA,WAAY;IACzBC,oBAAoB,EAAEA,oBAAqB;IAC3CC,WAAW,EAAEA,WAAY;IACzBC,cAAc,EAAEA,cAAe;IAC/BC,KAAK,EAAEA,KAAM;IACbC,cAAc,EAAEA,cAAe;IAC/BC,SAAS,EAAEwB,mBAAoB;IAC/BgE,YAAY,EAAEvF,OAAQ;IACtBwF,WAAW,EAAEvF,MAAO;IACpBC,YAAY,EAAEA,YAAa;IAC3BC,YAAY,EAAEA,YAAa;IAC3BsF,iBAAiB,EAAEtF,YAAY,KAAKuF,SAAU;IAC9CtF,aAAa,EAAEA,aAAc;IAC7BC,cAAc,EAAEyE,kBAAmB;IACnCxE,iBAAiB,EAAEyE,qBAAsB;IACzCY,SAAS,EAAElB,kBAAmB;IAC9B/D,iBAAiB,EAAEA,iBAAkB;IACrCkF,mBAAmB,EAAEV,uBAAwB;IAC7CvE,oCAAoC,EAClCA,oCACD;IACDC,aAAa,EAAEA,aAAc;IAAA,GACzBC;EAAI,CACT,CAAC;AAEN,CAAC","ignoreList":[]}
|
|
@@ -64,6 +64,11 @@ export interface OnChangeSelectionEvent {
|
|
|
64
64
|
text: string;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
export interface OnRequestHtmlResultEvent {
|
|
68
|
+
requestId: Int32;
|
|
69
|
+
html: UnsafeMixed;
|
|
70
|
+
}
|
|
71
|
+
|
|
67
72
|
export interface MentionStyleProperties {
|
|
68
73
|
color?: ColorValue;
|
|
69
74
|
backgroundColor?: ColorValue;
|
|
@@ -105,10 +110,6 @@ export interface HtmlStyleInternal {
|
|
|
105
110
|
// This is a workaround for the fact that codegen does not support Records.
|
|
106
111
|
// On native Android side this will become a ReadableMap, on native iOS we can work with a folly::dynamic object.
|
|
107
112
|
mention?: UnsafeMixed;
|
|
108
|
-
img?: {
|
|
109
|
-
width?: Float;
|
|
110
|
-
height?: Float;
|
|
111
|
-
};
|
|
112
113
|
ol?: {
|
|
113
114
|
gapWidth?: Float;
|
|
114
115
|
marginLeft?: Float;
|
|
@@ -147,6 +148,7 @@ export interface NativeProps extends ViewProps {
|
|
|
147
148
|
onMentionDetected?: DirectEventHandler<OnMentionDetectedInternal>;
|
|
148
149
|
onMention?: DirectEventHandler<OnMentionEvent>;
|
|
149
150
|
onChangeSelection?: DirectEventHandler<OnChangeSelectionEvent>;
|
|
151
|
+
onRequestHtmlResult?: DirectEventHandler<OnRequestHtmlResultEvent>;
|
|
150
152
|
|
|
151
153
|
// Style related props - used for generating proper setters in component's manager
|
|
152
154
|
// These should not be passed as regular props
|
|
@@ -191,7 +193,12 @@ interface NativeCommands {
|
|
|
191
193
|
text: string,
|
|
192
194
|
url: string
|
|
193
195
|
) => void;
|
|
194
|
-
addImage: (
|
|
196
|
+
addImage: (
|
|
197
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
198
|
+
uri: string,
|
|
199
|
+
width: Float,
|
|
200
|
+
height: Float
|
|
201
|
+
) => void;
|
|
195
202
|
startMention: (
|
|
196
203
|
viewRef: React.ElementRef<ComponentType>,
|
|
197
204
|
indicator: string
|
|
@@ -202,6 +209,10 @@ interface NativeCommands {
|
|
|
202
209
|
text: string,
|
|
203
210
|
payload: string
|
|
204
211
|
) => void;
|
|
212
|
+
requestHTML: (
|
|
213
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
214
|
+
requestId: Int32
|
|
215
|
+
) => void;
|
|
205
216
|
}
|
|
206
217
|
|
|
207
218
|
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
@@ -228,6 +239,7 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
|
228
239
|
'addImage',
|
|
229
240
|
'startMention',
|
|
230
241
|
'addMention',
|
|
242
|
+
'requestHTML',
|
|
231
243
|
],
|
|
232
244
|
});
|
|
233
245
|
|