react-native-enriched 0.2.0 → 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 +1 -5
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +1 -0
- 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/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt +92 -0
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +6 -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 +6 -0
- 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 +5 -0
- 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 +9 -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/styles/HtmlStyle.kt +78 -0
- package/android/src/main/java/com/swmansion/enriched/styles/ParagraphStyles.kt +80 -4
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedParser.java +8 -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/ios/EnrichedTextInputView.h +25 -13
- package/ios/EnrichedTextInputView.mm +872 -581
- 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 +6 -6
- package/ios/config/InputConfig.mm +39 -33
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.cpp +10 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.h +7 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/RCTComponentViewHelpers.h +21 -0
- package/ios/inputParser/InputParser.h +5 -5
- package/ios/inputParser/InputParser.mm +789 -378
- 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 -25
- package/ios/internals/EnrichedTextInputViewShadowNode.mm +45 -40
- package/ios/internals/EnrichedTextInputViewState.h +3 -1
- package/ios/styles/BlockQuoteStyle.mm +189 -118
- package/ios/styles/BoldStyle.mm +95 -63
- package/ios/styles/CodeBlockStyle.mm +204 -128
- package/ios/styles/H1Style.mm +10 -4
- package/ios/styles/H2Style.mm +10 -4
- package/ios/styles/H3Style.mm +10 -4
- package/ios/styles/HeadingStyleBase.mm +129 -84
- package/ios/styles/ImageStyle.mm +75 -73
- package/ios/styles/InlineCodeStyle.mm +148 -85
- package/ios/styles/ItalicStyle.mm +76 -52
- package/ios/styles/LinkStyle.mm +348 -227
- package/ios/styles/MentionStyle.mm +363 -246
- package/ios/styles/OrderedListStyle.mm +171 -106
- package/ios/styles/StrikethroughStyle.mm +52 -35
- package/ios/styles/UnderlineStyle.mm +68 -46
- package/ios/styles/UnorderedListStyle.mm +169 -106
- package/ios/utils/BaseStyleProtocol.h +2 -2
- package/ios/utils/ColorExtension.mm +7 -5
- package/ios/utils/FontExtension.mm +42 -27
- package/ios/utils/LayoutManagerExtension.h +1 -1
- package/ios/utils/LayoutManagerExtension.mm +280 -170
- 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 -42
- package/ios/utils/OccurenceUtils.mm +142 -119
- package/ios/utils/ParagraphAttributesUtils.h +6 -2
- package/ios/utils/ParagraphAttributesUtils.mm +115 -71
- 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 +27 -15
- 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 +145 -79
- package/lib/module/EnrichedTextInput.js +39 -1
- package/lib/module/EnrichedTextInput.js.map +1 -1
- package/lib/module/EnrichedTextInputNativeComponent.ts +11 -0
- package/lib/typescript/src/EnrichedTextInput.d.ts +1 -0
- package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts +6 -0
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +1 -1
- package/package.json +8 -1
- package/src/EnrichedTextInput.tsx +45 -0
- package/src/EnrichedTextInputNativeComponent.ts +11 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#import "ImageAttachment.h"
|
|
2
|
+
|
|
3
|
+
@implementation ImageAttachment
|
|
4
|
+
|
|
5
|
+
- (instancetype)initWithImageData:(ImageData *)data {
|
|
6
|
+
self = [super initWithURI:data.uri width:data.width height:data.height];
|
|
7
|
+
if (!self)
|
|
8
|
+
return nil;
|
|
9
|
+
|
|
10
|
+
_imageData = data;
|
|
11
|
+
self.image = [UIImage new];
|
|
12
|
+
|
|
13
|
+
[self loadAsync];
|
|
14
|
+
return self;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
- (void)loadAsync {
|
|
18
|
+
NSURL *url = [NSURL URLWithString:self.uri];
|
|
19
|
+
if (!url)
|
|
20
|
+
return;
|
|
21
|
+
|
|
22
|
+
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
|
|
23
|
+
NSData *bytes = [NSData dataWithContentsOfURL:url];
|
|
24
|
+
UIImage *img = bytes ? [UIImage imageWithData:bytes]
|
|
25
|
+
: [UIImage systemImageNamed:@"file"];
|
|
26
|
+
|
|
27
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
28
|
+
self.image = img;
|
|
29
|
+
[self notifyUpdate];
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
|
|
3
|
+
@class MediaAttachment;
|
|
4
|
+
|
|
5
|
+
@protocol MediaAttachmentDelegate <NSObject>
|
|
6
|
+
- (void)mediaAttachmentDidUpdate:(MediaAttachment *)attachment;
|
|
7
|
+
@end
|
|
8
|
+
|
|
9
|
+
@interface MediaAttachment : NSTextAttachment
|
|
10
|
+
|
|
11
|
+
@property(nonatomic, weak) id<MediaAttachmentDelegate> delegate;
|
|
12
|
+
@property(nonatomic, strong) NSString *uri;
|
|
13
|
+
@property(nonatomic, assign) CGFloat width;
|
|
14
|
+
@property(nonatomic, assign) CGFloat height;
|
|
15
|
+
|
|
16
|
+
- (instancetype)initWithURI:(NSString *)uri
|
|
17
|
+
width:(CGFloat)width
|
|
18
|
+
height:(CGFloat)height;
|
|
19
|
+
|
|
20
|
+
- (void)loadAsync;
|
|
21
|
+
- (void)notifyUpdate;
|
|
22
|
+
|
|
23
|
+
@end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#import "MediaAttachment.h"
|
|
2
|
+
|
|
3
|
+
@implementation MediaAttachment
|
|
4
|
+
|
|
5
|
+
- (instancetype)initWithURI:(NSString *)uri
|
|
6
|
+
width:(CGFloat)width
|
|
7
|
+
height:(CGFloat)height {
|
|
8
|
+
self = [super init];
|
|
9
|
+
if (!self)
|
|
10
|
+
return nil;
|
|
11
|
+
|
|
12
|
+
_uri = uri;
|
|
13
|
+
_width = width;
|
|
14
|
+
_height = height;
|
|
15
|
+
|
|
16
|
+
self.bounds = CGRectMake(0, 0, width, height);
|
|
17
|
+
|
|
18
|
+
return self;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
- (void)loadAsync {
|
|
22
|
+
// no-op for base
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (void)notifyUpdate {
|
|
26
|
+
if ([self.delegate respondsToSelector:@selector(mediaAttachmentDidUpdate:)]) {
|
|
27
|
+
[self.delegate mediaAttachmentDidUpdate:self];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@end
|
package/ios/config/InputConfig.h
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#pragma once
|
|
2
|
-
#import <UIKit/UIKit.h>
|
|
3
|
-
#import "TextDecorationLineEnum.h"
|
|
4
2
|
#import "MentionStyleProps.h"
|
|
3
|
+
#import "TextDecorationLineEnum.h"
|
|
4
|
+
#import <UIKit/UIKit.h>
|
|
5
5
|
|
|
6
|
-
@interface InputConfig: NSObject<NSCopying>
|
|
7
|
-
- (instancetype)
|
|
6
|
+
@interface InputConfig : NSObject <NSCopying>
|
|
7
|
+
- (instancetype)init;
|
|
8
8
|
- (UIColor *)primaryColor;
|
|
9
9
|
- (void)setPrimaryColor:(UIColor *)newValue;
|
|
10
10
|
- (NSNumber *)primaryFontSize;
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
- (void)setPrimaryFontFamily:(NSString *)newValue;
|
|
16
16
|
- (UIFont *)primaryFont;
|
|
17
17
|
- (UIFont *)monospacedFont;
|
|
18
|
-
- (NSSet<NSNumber
|
|
19
|
-
- (void)setMentionIndicators:(NSSet<NSNumber
|
|
18
|
+
- (NSSet<NSNumber *> *)mentionIndicators;
|
|
19
|
+
- (void)setMentionIndicators:(NSSet<NSNumber *> *)newValue;
|
|
20
20
|
- (CGFloat)h1FontSize;
|
|
21
21
|
- (void)setH1FontSize:(CGFloat)newValue;
|
|
22
22
|
- (BOOL)h1Bold;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
UIFont *_monospacedFont;
|
|
11
11
|
BOOL _primaryFontNeedsRecreation;
|
|
12
12
|
BOOL _monospacedFontNeedsRecreation;
|
|
13
|
-
NSSet<NSNumber*> *_mentionIndicators;
|
|
13
|
+
NSSet<NSNumber *> *_mentionIndicators;
|
|
14
14
|
CGFloat _h1FontSize;
|
|
15
15
|
BOOL _h1Bold;
|
|
16
16
|
CGFloat _h2FontSize;
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
CGFloat _imageHeight;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
- (instancetype)
|
|
46
|
+
- (instancetype)init {
|
|
47
47
|
self = [super init];
|
|
48
48
|
_primaryFontNeedsRecreation = YES;
|
|
49
49
|
_monospacedFontNeedsRecreation = YES;
|
|
@@ -110,7 +110,9 @@
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
- (NSString *)primaryFontWeight {
|
|
113
|
-
return _primaryFontWeight != nullptr
|
|
113
|
+
return _primaryFontWeight != nullptr
|
|
114
|
+
? _primaryFontWeight
|
|
115
|
+
: [NSString stringWithFormat:@"%@", @(UIFontWeightRegular)];
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
- (void)setPrimaryFontWeight:(NSString *)newValue {
|
|
@@ -130,41 +132,45 @@
|
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
- (UIFont *)primaryFont {
|
|
133
|
-
if(_primaryFontNeedsRecreation) {
|
|
135
|
+
if (_primaryFontNeedsRecreation) {
|
|
134
136
|
_primaryFontNeedsRecreation = NO;
|
|
135
|
-
|
|
137
|
+
|
|
136
138
|
NSString *newFontWeight = [self primaryFontWeight];
|
|
137
139
|
// fix RCTFontWeight conversion warnings:
|
|
138
140
|
// sometimes changing font family comes with weight '0' if not specified
|
|
139
|
-
// RCTConvert doesn't recognize this value so we just nullify it and it gets
|
|
140
|
-
|
|
141
|
+
// RCTConvert doesn't recognize this value so we just nullify it and it gets
|
|
142
|
+
// a default value
|
|
143
|
+
if ([newFontWeight isEqualToString:@"0"]) {
|
|
141
144
|
newFontWeight = nullptr;
|
|
142
145
|
}
|
|
143
|
-
|
|
146
|
+
|
|
144
147
|
_primaryFont = [RCTFont updateFont:nullptr
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
withFamily:[self primaryFontFamily]
|
|
149
|
+
size:[self primaryFontSize]
|
|
150
|
+
weight:newFontWeight
|
|
151
|
+
style:nullptr
|
|
152
|
+
variant:nullptr
|
|
153
|
+
scaleMultiplier:1];
|
|
151
154
|
}
|
|
152
155
|
return _primaryFont;
|
|
153
156
|
}
|
|
154
157
|
|
|
155
158
|
- (UIFont *)monospacedFont {
|
|
156
|
-
if(_monospacedFontNeedsRecreation) {
|
|
159
|
+
if (_monospacedFontNeedsRecreation) {
|
|
157
160
|
_monospacedFontNeedsRecreation = NO;
|
|
158
|
-
_monospacedFont = [UIFont
|
|
161
|
+
_monospacedFont = [UIFont
|
|
162
|
+
monospacedSystemFontOfSize:[[self primaryFontSize] floatValue]
|
|
163
|
+
weight:[[self primaryFontWeight] floatValue]];
|
|
159
164
|
}
|
|
160
165
|
return _monospacedFont;
|
|
161
166
|
}
|
|
162
167
|
|
|
163
|
-
- (NSSet<NSNumber
|
|
164
|
-
return _mentionIndicators != nullptr ? _mentionIndicators
|
|
168
|
+
- (NSSet<NSNumber *> *)mentionIndicators {
|
|
169
|
+
return _mentionIndicators != nullptr ? _mentionIndicators
|
|
170
|
+
: [[NSSet alloc] init];
|
|
165
171
|
}
|
|
166
172
|
|
|
167
|
-
- (void)setMentionIndicators:(NSSet<NSNumber
|
|
173
|
+
- (void)setMentionIndicators:(NSSet<NSNumber *> *)newValue {
|
|
168
174
|
_mentionIndicators = newValue;
|
|
169
175
|
}
|
|
170
176
|
|
|
@@ -232,7 +238,6 @@
|
|
|
232
238
|
_blockquoteBorderWidth = newValue;
|
|
233
239
|
}
|
|
234
240
|
|
|
235
|
-
|
|
236
241
|
- (CGFloat)blockquoteGapWidth {
|
|
237
242
|
return _blockquoteGapWidth;
|
|
238
243
|
}
|
|
@@ -299,24 +304,25 @@
|
|
|
299
304
|
}
|
|
300
305
|
|
|
301
306
|
- (UIFont *)orderedListMarkerFont {
|
|
302
|
-
if(_olMarkerFontNeedsRecreation) {
|
|
307
|
+
if (_olMarkerFontNeedsRecreation) {
|
|
303
308
|
_olMarkerFontNeedsRecreation = NO;
|
|
304
|
-
|
|
309
|
+
|
|
305
310
|
NSString *newFontWeight = [self orderedListMarkerFontWeight];
|
|
306
311
|
// fix RCTFontWeight conversion warnings:
|
|
307
312
|
// sometimes changing font family comes with weight '0' if not specified
|
|
308
|
-
// RCTConvert doesn't recognize this value so we just nullify it and it gets
|
|
309
|
-
|
|
313
|
+
// RCTConvert doesn't recognize this value so we just nullify it and it gets
|
|
314
|
+
// a default value
|
|
315
|
+
if ([newFontWeight isEqualToString:@"0"]) {
|
|
310
316
|
newFontWeight = nullptr;
|
|
311
317
|
}
|
|
312
|
-
|
|
318
|
+
|
|
313
319
|
_orderedListMarkerFont = [RCTFont updateFont:nullptr
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
+
withFamily:[self primaryFontFamily]
|
|
321
|
+
size:[self primaryFontSize]
|
|
322
|
+
weight:newFontWeight
|
|
323
|
+
style:nullptr
|
|
324
|
+
variant:nullptr
|
|
325
|
+
scaleMultiplier:1];
|
|
320
326
|
}
|
|
321
327
|
return _orderedListMarkerFont;
|
|
322
328
|
}
|
|
@@ -374,10 +380,10 @@
|
|
|
374
380
|
}
|
|
375
381
|
|
|
376
382
|
- (MentionStyleProps *)mentionStylePropsForIndicator:(NSString *)indicator {
|
|
377
|
-
if(_mentionProperties.count == 1 && _mentionProperties[@"all"] != nullptr) {
|
|
383
|
+
if (_mentionProperties.count == 1 && _mentionProperties[@"all"] != nullptr) {
|
|
378
384
|
// single props for all the indicators
|
|
379
385
|
return _mentionProperties[@"all"];
|
|
380
|
-
} else if(_mentionProperties[indicator] != nullptr) {
|
|
386
|
+
} else if (_mentionProperties[indicator] != nullptr) {
|
|
381
387
|
return _mentionProperties[indicator];
|
|
382
388
|
}
|
|
383
389
|
MentionStyleProps *fallbackProps = [[MentionStyleProps alloc] init];
|
|
@@ -115,4 +115,14 @@ payload.setProperty(runtime, "text", event.text);
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
|
|
119
|
+
void EnrichedTextInputViewEventEmitter::onRequestHtmlResult(OnRequestHtmlResult event) const {
|
|
120
|
+
dispatchEvent("requestHtmlResult", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
121
|
+
auto payload = jsi::Object(runtime);
|
|
122
|
+
payload.setProperty(runtime, "requestId", event.requestId);
|
|
123
|
+
payload.setProperty(runtime, "html", jsi::valueFromDynamic(runtime, event.html));
|
|
124
|
+
return payload;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
118
128
|
} // namespace facebook::react
|
|
@@ -74,6 +74,11 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
|
|
|
74
74
|
int end;
|
|
75
75
|
std::string text;
|
|
76
76
|
};
|
|
77
|
+
|
|
78
|
+
struct OnRequestHtmlResult {
|
|
79
|
+
int requestId;
|
|
80
|
+
folly::dynamic html;
|
|
81
|
+
};
|
|
77
82
|
void onInputFocus(OnInputFocus value) const;
|
|
78
83
|
|
|
79
84
|
void onInputBlur(OnInputBlur value) const;
|
|
@@ -91,5 +96,7 @@ class EnrichedTextInputViewEventEmitter : public ViewEventEmitter {
|
|
|
91
96
|
void onMention(OnMention value) const;
|
|
92
97
|
|
|
93
98
|
void onChangeSelection(OnChangeSelection value) const;
|
|
99
|
+
|
|
100
|
+
void onRequestHtmlResult(OnRequestHtmlResult value) const;
|
|
94
101
|
};
|
|
95
102
|
} // namespace facebook::react
|
|
@@ -33,6 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
33
33
|
- (void)addImage:(NSString *)uri width:(float)width height:(float)height;
|
|
34
34
|
- (void)startMention:(NSString *)indicator;
|
|
35
35
|
- (void)addMention:(NSString *)indicator text:(NSString *)text payload:(NSString *)payload;
|
|
36
|
+
- (void)requestHTML:(NSInteger)requestId;
|
|
36
37
|
@end
|
|
37
38
|
|
|
38
39
|
RCT_EXTERN inline void RCTEnrichedTextInputViewHandleCommand(
|
|
@@ -392,6 +393,26 @@ NSObject *arg2 = args[2];
|
|
|
392
393
|
return;
|
|
393
394
|
}
|
|
394
395
|
|
|
396
|
+
if ([commandName isEqualToString:@"requestHTML"]) {
|
|
397
|
+
#if RCT_DEBUG
|
|
398
|
+
if ([args count] != 1) {
|
|
399
|
+
RCTLogError(@"%@ command %@ received %d arguments, expected %d.", @"EnrichedTextInputView", commandName, (int)[args count], 1);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
#endif
|
|
403
|
+
|
|
404
|
+
NSObject *arg0 = args[0];
|
|
405
|
+
#if RCT_DEBUG
|
|
406
|
+
if (!RCTValidateTypeOfViewCommandArgument(arg0, [NSNumber class], @"number", @"EnrichedTextInputView", commandName, @"1st")) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
#endif
|
|
410
|
+
NSInteger requestId = [(NSNumber *)arg0 intValue];
|
|
411
|
+
|
|
412
|
+
[componentView requestHTML:requestId];
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
|
|
395
416
|
#if RCT_DEBUG
|
|
396
417
|
RCTLogError(@"%@ received command %@, which is not a supported command.", @"EnrichedTextInputView", commandName);
|
|
397
418
|
#endif
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
@interface InputParser : NSObject
|
|
5
5
|
- (instancetype _Nonnull)initWithInput:(id _Nonnull)input;
|
|
6
|
-
- (NSString *
|
|
7
|
-
- (void)replaceWholeFromHtml:(NSString *
|
|
8
|
-
- (void)replaceFromHtml:(NSString *
|
|
9
|
-
- (void)insertFromHtml:(NSString *
|
|
10
|
-
- (NSString *
|
|
6
|
+
- (NSString *_Nonnull)parseToHtmlFromRange:(NSRange)range;
|
|
7
|
+
- (void)replaceWholeFromHtml:(NSString *_Nonnull)html;
|
|
8
|
+
- (void)replaceFromHtml:(NSString *_Nonnull)html range:(NSRange)range;
|
|
9
|
+
- (void)insertFromHtml:(NSString *_Nonnull)html location:(NSInteger)location;
|
|
10
|
+
- (NSString *_Nullable)initiallyProcessHtml:(NSString *_Nonnull)html;
|
|
11
11
|
@end
|