react-native-typerich 0.1.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.
- package/LICENSE +28 -0
- package/README.md +37 -0
- package/TypeRichTextInput.podspec +20 -0
- package/android/build.gradle +99 -0
- package/android/generated/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/TypeRichTextInputViewManagerDelegate.java +100 -0
- package/android/generated/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/TypeRichTextInputViewManagerInterface.java +38 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/TypeRichTextInputViewSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/TypeRichTextInputViewSpec/ComponentDescriptors.h +24 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/TypeRichTextInputViewSpec/EventEmitters.cpp +70 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/TypeRichTextInputViewSpec/EventEmitters.h +59 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/TypeRichTextInputViewSpec/Props.cpp +132 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/TypeRichTextInputViewSpec/Props.h +51 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/TypeRichTextInputViewSpec/ShadowNodes.cpp +17 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/TypeRichTextInputViewSpec/ShadowNodes.h +23 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/TypeRichTextInputViewSpec/States.cpp +16 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/TypeRichTextInputViewSpec/States.h +20 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/typerich/MeasurementStore.kt +148 -0
- package/android/src/main/java/com/typerich/TypeRichTextInputView.kt +503 -0
- package/android/src/main/java/com/typerich/TypeRichTextInputViewLayoutManager.kt +30 -0
- package/android/src/main/java/com/typerich/TypeRichTextInputViewManager.kt +188 -0
- package/android/src/main/java/com/typerich/TypeRichTextInputViewPackage.kt +19 -0
- package/android/src/main/java/com/typerich/events/OnChangeSelectionEvent.kt +29 -0
- package/android/src/main/java/com/typerich/events/OnChangeTextEvent.kt +35 -0
- package/android/src/main/java/com/typerich/events/OnInputBlurEvent.kt +27 -0
- package/android/src/main/java/com/typerich/events/OnInputFocusEvent.kt +27 -0
- package/android/src/main/java/com/typerich/events/OnPasteImageEvent.kt +45 -0
- package/android/src/main/new_arch/CMakeLists.txt +73 -0
- package/android/src/main/new_arch/TypeRichTextInputViewSpec.cpp +22 -0
- package/android/src/main/new_arch/TypeRichTextInputViewSpec.h +26 -0
- package/android/src/main/new_arch/react/renderer/components/TypeRichTextInputView/TypeRichTextInputViewComponentDescriptor.h +36 -0
- package/android/src/main/new_arch/react/renderer/components/TypeRichTextInputView/TypeRichTextInputViewMeasurementManager.cpp +83 -0
- package/android/src/main/new_arch/react/renderer/components/TypeRichTextInputView/TypeRichTextInputViewMeasurementManager.h +25 -0
- package/android/src/main/new_arch/react/renderer/components/TypeRichTextInputView/TypeRichTextInputViewShadowNode.cpp +132 -0
- package/android/src/main/new_arch/react/renderer/components/TypeRichTextInputView/TypeRichTextInputViewShadowNode.h +54 -0
- package/android/src/main/new_arch/react/renderer/components/TypeRichTextInputView/TypeRichTextInputViewState.cpp +9 -0
- package/android/src/main/new_arch/react/renderer/components/TypeRichTextInputView/TypeRichTextInputViewState.h +28 -0
- package/android/src/main/new_arch/react/renderer/components/TypeRichTextInputView/conversions.h +21 -0
- package/ios/TypeRichTextInputView.h +14 -0
- package/ios/TypeRichTextInputView.mm +71 -0
- package/ios/generated/build/generated/ios/react/renderer/components/TypeRichTextInputViewSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/build/generated/ios/react/renderer/components/TypeRichTextInputViewSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/build/generated/ios/react/renderer/components/TypeRichTextInputViewSpec/EventEmitters.cpp +70 -0
- package/ios/generated/build/generated/ios/react/renderer/components/TypeRichTextInputViewSpec/EventEmitters.h +59 -0
- package/ios/generated/build/generated/ios/react/renderer/components/TypeRichTextInputViewSpec/Props.cpp +132 -0
- package/ios/generated/build/generated/ios/react/renderer/components/TypeRichTextInputViewSpec/Props.h +51 -0
- package/ios/generated/build/generated/ios/react/renderer/components/TypeRichTextInputViewSpec/RCTComponentViewHelpers.h +80 -0
- package/ios/generated/build/generated/ios/react/renderer/components/TypeRichTextInputViewSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/build/generated/ios/react/renderer/components/TypeRichTextInputViewSpec/ShadowNodes.h +23 -0
- package/ios/generated/build/generated/ios/react/renderer/components/TypeRichTextInputViewSpec/States.cpp +16 -0
- package/ios/generated/build/generated/ios/react/renderer/components/TypeRichTextInputViewSpec/States.h +20 -0
- package/lib/module/TypeRichTextInput.js +50 -0
- package/lib/module/TypeRichTextInput.js.map +1 -0
- package/lib/module/TypeRichTextInputNativeComponent.ts +92 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types/react-native-codegen.d.js +2 -0
- package/lib/module/types/react-native-codegen.d.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/TypeRichTextInput.d.ts +35 -0
- package/lib/typescript/src/TypeRichTextInput.d.ts.map +1 -0
- package/lib/typescript/src/TypeRichTextInputNativeComponent.d.ts +57 -0
- package/lib/typescript/src/TypeRichTextInputNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +180 -0
- package/react-native.config.js +13 -0
- package/src/TypeRichTextInput.tsx +115 -0
- package/src/TypeRichTextInputNativeComponent.ts +92 -0
- package/src/index.tsx +6 -0
- package/src/types/react-native-codegen.d.ts +11 -0
package/android/src/main/new_arch/react/renderer/components/TypeRichTextInputView/conversions.h
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <folly/dynamic.h>
|
|
4
|
+
#include <react/renderer/components/TypeRichTextInputViewSpec/Props.h>
|
|
5
|
+
|
|
6
|
+
namespace facebook::react {
|
|
7
|
+
|
|
8
|
+
inline folly::dynamic toDynamic(const TypeRichTextInputViewProps &props) {
|
|
9
|
+
folly::dynamic d = folly::dynamic::object();
|
|
10
|
+
d["defaultValue"] = props.defaultValue;
|
|
11
|
+
d["placeholder"] = props.placeholder;
|
|
12
|
+
d["fontSize"] = props.fontSize;
|
|
13
|
+
d["fontWeight"] = props.fontWeight;
|
|
14
|
+
d["fontStyle"] = props.fontStyle;
|
|
15
|
+
d["fontFamily"] = props.fontFamily;
|
|
16
|
+
d["multiline"] = props.multiline;
|
|
17
|
+
d["numberOfLines"] = props.numberOfLines;
|
|
18
|
+
return d;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#import <React/RCTViewComponentView.h>
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
#ifndef TypeRichTextInputViewNativeComponent_h
|
|
5
|
+
#define TypeRichTextInputViewNativeComponent_h
|
|
6
|
+
|
|
7
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
8
|
+
|
|
9
|
+
@interface TypeRichTextInputView : RCTViewComponentView
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
NS_ASSUME_NONNULL_END
|
|
13
|
+
|
|
14
|
+
#endif /* TypeRichTextInputViewNativeComponent_h */
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#import "TypeRichTextInputView.h"
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/TypeRichTextInputViewSpec/ComponentDescriptors.h>
|
|
4
|
+
#import <react/renderer/components/TypeRichTextInputViewSpec/EventEmitters.h>
|
|
5
|
+
#import <react/renderer/components/TypeRichTextInputViewSpec/Props.h>
|
|
6
|
+
#import <react/renderer/components/TypeRichTextInputViewSpec/RCTComponentViewHelpers.h>
|
|
7
|
+
|
|
8
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
9
|
+
|
|
10
|
+
using namespace facebook::react;
|
|
11
|
+
|
|
12
|
+
@interface TypeRichTextInputView () <RCTTypeRichTextInputViewViewProtocol>
|
|
13
|
+
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
@implementation TypeRichTextInputView {
|
|
17
|
+
UIView * _view;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
21
|
+
{
|
|
22
|
+
return concreteComponentDescriptorProvider<TypeRichTextInputViewComponentDescriptor>();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
26
|
+
{
|
|
27
|
+
if (self = [super initWithFrame:frame]) {
|
|
28
|
+
static const auto defaultProps = std::make_shared<const TypeRichTextInputViewProps>();
|
|
29
|
+
_props = defaultProps;
|
|
30
|
+
|
|
31
|
+
_view = [[UIView alloc] init];
|
|
32
|
+
|
|
33
|
+
self.contentView = _view;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return self;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
40
|
+
{
|
|
41
|
+
const auto &oldViewProps = *std::static_pointer_cast<TypeRichTextInputViewProps const>(_props);
|
|
42
|
+
const auto &newViewProps = *std::static_pointer_cast<TypeRichTextInputViewProps const>(props);
|
|
43
|
+
|
|
44
|
+
if (oldViewProps.color != newViewProps.color) {
|
|
45
|
+
NSString * colorToConvert = [[NSString alloc] initWithUTF8String: newViewProps.color.c_str()];
|
|
46
|
+
[_view setBackgroundColor:[self hexStringToColor:colorToConvert]];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[super updateProps:props oldProps:oldProps];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
Class<RCTComponentViewProtocol> TypeRichTextInputViewCls(void)
|
|
53
|
+
{
|
|
54
|
+
return TypeRichTextInputView.class;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
- hexStringToColor:(NSString *)stringToConvert
|
|
58
|
+
{
|
|
59
|
+
NSString *noHashString = [stringToConvert stringByReplacingOccurrencesOfString:@"#" withString:@""];
|
|
60
|
+
NSScanner *stringScanner = [NSScanner scannerWithString:noHashString];
|
|
61
|
+
|
|
62
|
+
unsigned hex;
|
|
63
|
+
if (![stringScanner scanHexInt:&hex]) return nil;
|
|
64
|
+
int r = (hex >> 16) & 0xFF;
|
|
65
|
+
int g = (hex >> 8) & 0xFF;
|
|
66
|
+
int b = (hex) & 0xFF;
|
|
67
|
+
|
|
68
|
+
return [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:1.0f];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateComponentDescriptorCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include <react/renderer/components/TypeRichTextInputViewSpec/ComponentDescriptors.h>
|
|
12
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
13
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
void TypeRichTextInputViewSpec_registerComponentDescriptorsFromCodegen(
|
|
18
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateComponentDescriptorH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <react/renderer/components/TypeRichTextInputViewSpec/ShadowNodes.h>
|
|
14
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
void TypeRichTextInputViewSpec_registerComponentDescriptorsFromCodegen(
|
|
22
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
|
|
23
|
+
|
|
24
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include <react/renderer/components/TypeRichTextInputViewSpec/EventEmitters.h>
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace facebook::react {
|
|
15
|
+
|
|
16
|
+
void TypeRichTextInputViewEventEmitter::onInputFocus(OnInputFocus event) const {
|
|
17
|
+
dispatchEvent("inputFocus", [](jsi::Runtime &runtime) {
|
|
18
|
+
auto payload = jsi::Object(runtime);
|
|
19
|
+
|
|
20
|
+
return payload;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
void TypeRichTextInputViewEventEmitter::onInputBlur(OnInputBlur event) const {
|
|
26
|
+
dispatchEvent("inputBlur", [](jsi::Runtime &runtime) {
|
|
27
|
+
auto payload = jsi::Object(runtime);
|
|
28
|
+
|
|
29
|
+
return payload;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
void TypeRichTextInputViewEventEmitter::onChangeText(OnChangeText event) const {
|
|
35
|
+
dispatchEvent("changeText", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
36
|
+
auto payload = jsi::Object(runtime);
|
|
37
|
+
payload.setProperty(runtime, "value", event.value);
|
|
38
|
+
return payload;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
void TypeRichTextInputViewEventEmitter::onChangeSelection(OnChangeSelection event) const {
|
|
44
|
+
dispatchEvent("changeSelection", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
45
|
+
auto payload = jsi::Object(runtime);
|
|
46
|
+
payload.setProperty(runtime, "start", event.start);
|
|
47
|
+
payload.setProperty(runtime, "end", event.end);
|
|
48
|
+
payload.setProperty(runtime, "text", event.text);
|
|
49
|
+
return payload;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
void TypeRichTextInputViewEventEmitter::onPasteImage(OnPasteImage event) const {
|
|
55
|
+
dispatchEvent("pasteImage", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
56
|
+
auto payload = jsi::Object(runtime);
|
|
57
|
+
payload.setProperty(runtime, "uri", event.uri);
|
|
58
|
+
payload.setProperty(runtime, "type", event.type);
|
|
59
|
+
payload.setProperty(runtime, "fileName", event.fileName);
|
|
60
|
+
payload.setProperty(runtime, "fileSize", event.fileSize);
|
|
61
|
+
{
|
|
62
|
+
auto error = jsi::Object(runtime);
|
|
63
|
+
error.setProperty(runtime, "message", event.error.message);
|
|
64
|
+
payload.setProperty(runtime, "error", error);
|
|
65
|
+
}
|
|
66
|
+
return payload;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
class TypeRichTextInputViewEventEmitter : public ViewEventEmitter {
|
|
17
|
+
public:
|
|
18
|
+
using ViewEventEmitter::ViewEventEmitter;
|
|
19
|
+
|
|
20
|
+
struct OnInputFocus {
|
|
21
|
+
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
struct OnInputBlur {
|
|
25
|
+
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
struct OnChangeText {
|
|
29
|
+
std::string value;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
struct OnChangeSelection {
|
|
33
|
+
int start;
|
|
34
|
+
int end;
|
|
35
|
+
std::string text;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
struct OnPasteImageError {
|
|
39
|
+
std::string message;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
struct OnPasteImage {
|
|
43
|
+
std::string uri;
|
|
44
|
+
std::string type;
|
|
45
|
+
std::string fileName;
|
|
46
|
+
double fileSize;
|
|
47
|
+
OnPasteImageError error;
|
|
48
|
+
};
|
|
49
|
+
void onInputFocus(OnInputFocus value) const;
|
|
50
|
+
|
|
51
|
+
void onInputBlur(OnInputBlur value) const;
|
|
52
|
+
|
|
53
|
+
void onChangeText(OnChangeText value) const;
|
|
54
|
+
|
|
55
|
+
void onChangeSelection(OnChangeSelection value) const;
|
|
56
|
+
|
|
57
|
+
void onPasteImage(OnPasteImage value) const;
|
|
58
|
+
};
|
|
59
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include <react/renderer/components/TypeRichTextInputViewSpec/Props.h>
|
|
12
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
13
|
+
#include <react/renderer/core/propsConversions.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
TypeRichTextInputViewProps::TypeRichTextInputViewProps(
|
|
18
|
+
const PropsParserContext &context,
|
|
19
|
+
const TypeRichTextInputViewProps &sourceProps,
|
|
20
|
+
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
|
21
|
+
|
|
22
|
+
autoFocus(convertRawProp(context, rawProps, "autoFocus", sourceProps.autoFocus, {false})),
|
|
23
|
+
editable(convertRawProp(context, rawProps, "editable", sourceProps.editable, {false})),
|
|
24
|
+
defaultValue(convertRawProp(context, rawProps, "defaultValue", sourceProps.defaultValue, {})),
|
|
25
|
+
placeholder(convertRawProp(context, rawProps, "placeholder", sourceProps.placeholder, {})),
|
|
26
|
+
placeholderTextColor(convertRawProp(context, rawProps, "placeholderTextColor", sourceProps.placeholderTextColor, {})),
|
|
27
|
+
cursorColor(convertRawProp(context, rawProps, "cursorColor", sourceProps.cursorColor, {})),
|
|
28
|
+
selectionColor(convertRawProp(context, rawProps, "selectionColor", sourceProps.selectionColor, {})),
|
|
29
|
+
autoCapitalize(convertRawProp(context, rawProps, "autoCapitalize", sourceProps.autoCapitalize, {})),
|
|
30
|
+
scrollEnabled(convertRawProp(context, rawProps, "scrollEnabled", sourceProps.scrollEnabled, {false})),
|
|
31
|
+
multiline(convertRawProp(context, rawProps, "multiline", sourceProps.multiline, {false})),
|
|
32
|
+
numberOfLines(convertRawProp(context, rawProps, "numberOfLines", sourceProps.numberOfLines, {0})),
|
|
33
|
+
secureTextEntry(convertRawProp(context, rawProps, "secureTextEntry", sourceProps.secureTextEntry, {false})),
|
|
34
|
+
color(convertRawProp(context, rawProps, "color", sourceProps.color, {})),
|
|
35
|
+
fontSize(convertRawProp(context, rawProps, "fontSize", sourceProps.fontSize, {0.0})),
|
|
36
|
+
fontFamily(convertRawProp(context, rawProps, "fontFamily", sourceProps.fontFamily, {})),
|
|
37
|
+
fontWeight(convertRawProp(context, rawProps, "fontWeight", sourceProps.fontWeight, {})),
|
|
38
|
+
fontStyle(convertRawProp(context, rawProps, "fontStyle", sourceProps.fontStyle, {})),
|
|
39
|
+
androidExperimentalSynchronousEvents(convertRawProp(context, rawProps, "androidExperimentalSynchronousEvents", sourceProps.androidExperimentalSynchronousEvents, {false})) {}
|
|
40
|
+
|
|
41
|
+
#ifdef RN_SERIALIZABLE_STATE
|
|
42
|
+
ComponentName TypeRichTextInputViewProps::getDiffPropsImplementationTarget() const {
|
|
43
|
+
return "TypeRichTextInputView";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
folly::dynamic TypeRichTextInputViewProps::getDiffProps(
|
|
47
|
+
const Props* prevProps) const {
|
|
48
|
+
static const auto defaultProps = TypeRichTextInputViewProps();
|
|
49
|
+
const TypeRichTextInputViewProps* oldProps = prevProps == nullptr
|
|
50
|
+
? &defaultProps
|
|
51
|
+
: static_cast<const TypeRichTextInputViewProps*>(prevProps);
|
|
52
|
+
if (this == oldProps) {
|
|
53
|
+
return folly::dynamic::object();
|
|
54
|
+
}
|
|
55
|
+
folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps);
|
|
56
|
+
|
|
57
|
+
if (autoFocus != oldProps->autoFocus) {
|
|
58
|
+
result["autoFocus"] = autoFocus;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (editable != oldProps->editable) {
|
|
62
|
+
result["editable"] = editable;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (defaultValue != oldProps->defaultValue) {
|
|
66
|
+
result["defaultValue"] = defaultValue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (placeholder != oldProps->placeholder) {
|
|
70
|
+
result["placeholder"] = placeholder;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (placeholderTextColor != oldProps->placeholderTextColor) {
|
|
74
|
+
result["placeholderTextColor"] = *placeholderTextColor;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (cursorColor != oldProps->cursorColor) {
|
|
78
|
+
result["cursorColor"] = *cursorColor;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (selectionColor != oldProps->selectionColor) {
|
|
82
|
+
result["selectionColor"] = *selectionColor;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (autoCapitalize != oldProps->autoCapitalize) {
|
|
86
|
+
result["autoCapitalize"] = autoCapitalize;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (scrollEnabled != oldProps->scrollEnabled) {
|
|
90
|
+
result["scrollEnabled"] = scrollEnabled;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (multiline != oldProps->multiline) {
|
|
94
|
+
result["multiline"] = multiline;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (numberOfLines != oldProps->numberOfLines) {
|
|
98
|
+
result["numberOfLines"] = numberOfLines;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (secureTextEntry != oldProps->secureTextEntry) {
|
|
102
|
+
result["secureTextEntry"] = secureTextEntry;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (color != oldProps->color) {
|
|
106
|
+
result["color"] = *color;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if ((fontSize != oldProps->fontSize) && !(std::isnan(fontSize) && std::isnan(oldProps->fontSize))) {
|
|
110
|
+
result["fontSize"] = fontSize;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (fontFamily != oldProps->fontFamily) {
|
|
114
|
+
result["fontFamily"] = fontFamily;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (fontWeight != oldProps->fontWeight) {
|
|
118
|
+
result["fontWeight"] = fontWeight;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (fontStyle != oldProps->fontStyle) {
|
|
122
|
+
result["fontStyle"] = fontStyle;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (androidExperimentalSynchronousEvents != oldProps->androidExperimentalSynchronousEvents) {
|
|
126
|
+
result["androidExperimentalSynchronousEvents"] = androidExperimentalSynchronousEvents;
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
#endif
|
|
131
|
+
|
|
132
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
13
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
14
|
+
#include <react/renderer/graphics/Color.h>
|
|
15
|
+
|
|
16
|
+
namespace facebook::react {
|
|
17
|
+
|
|
18
|
+
class TypeRichTextInputViewProps final : public ViewProps {
|
|
19
|
+
public:
|
|
20
|
+
TypeRichTextInputViewProps() = default;
|
|
21
|
+
TypeRichTextInputViewProps(const PropsParserContext& context, const TypeRichTextInputViewProps &sourceProps, const RawProps &rawProps);
|
|
22
|
+
|
|
23
|
+
#pragma mark - Props
|
|
24
|
+
|
|
25
|
+
bool autoFocus{false};
|
|
26
|
+
bool editable{false};
|
|
27
|
+
std::string defaultValue{};
|
|
28
|
+
std::string placeholder{};
|
|
29
|
+
SharedColor placeholderTextColor{};
|
|
30
|
+
SharedColor cursorColor{};
|
|
31
|
+
SharedColor selectionColor{};
|
|
32
|
+
std::string autoCapitalize{};
|
|
33
|
+
bool scrollEnabled{false};
|
|
34
|
+
bool multiline{false};
|
|
35
|
+
int numberOfLines{0};
|
|
36
|
+
bool secureTextEntry{false};
|
|
37
|
+
SharedColor color{};
|
|
38
|
+
Float fontSize{0.0};
|
|
39
|
+
std::string fontFamily{};
|
|
40
|
+
std::string fontWeight{};
|
|
41
|
+
std::string fontStyle{};
|
|
42
|
+
bool androidExperimentalSynchronousEvents{false};
|
|
43
|
+
|
|
44
|
+
#ifdef RN_SERIALIZABLE_STATE
|
|
45
|
+
ComponentName getDiffPropsImplementationTarget() const override;
|
|
46
|
+
|
|
47
|
+
folly::dynamic getDiffProps(const Props* prevProps) const override;
|
|
48
|
+
#endif
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateComponentHObjCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#import <Foundation/Foundation.h>
|
|
11
|
+
#import <React/RCTDefines.h>
|
|
12
|
+
#import <React/RCTLog.h>
|
|
13
|
+
|
|
14
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
15
|
+
|
|
16
|
+
@protocol RCTTypeRichTextInputViewViewProtocol <NSObject>
|
|
17
|
+
- (void)focus;
|
|
18
|
+
- (void)blur;
|
|
19
|
+
- (void)setValue:(NSString *)text;
|
|
20
|
+
@end
|
|
21
|
+
|
|
22
|
+
RCT_EXTERN inline void RCTTypeRichTextInputViewHandleCommand(
|
|
23
|
+
id<RCTTypeRichTextInputViewViewProtocol> componentView,
|
|
24
|
+
NSString const *commandName,
|
|
25
|
+
NSArray const *args)
|
|
26
|
+
{
|
|
27
|
+
if ([commandName isEqualToString:@"focus"]) {
|
|
28
|
+
#if RCT_DEBUG
|
|
29
|
+
if ([args count] != 0) {
|
|
30
|
+
RCTLogError(@"%@ command %@ received %d arguments, expected %d.", @"TypeRichTextInputView", commandName, (int)[args count], 0);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
[componentView focus];
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if ([commandName isEqualToString:@"blur"]) {
|
|
42
|
+
#if RCT_DEBUG
|
|
43
|
+
if ([args count] != 0) {
|
|
44
|
+
RCTLogError(@"%@ command %@ received %d arguments, expected %d.", @"TypeRichTextInputView", commandName, (int)[args count], 0);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
#endif
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
[componentView blur];
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if ([commandName isEqualToString:@"setValue"]) {
|
|
56
|
+
#if RCT_DEBUG
|
|
57
|
+
if ([args count] != 1) {
|
|
58
|
+
RCTLogError(@"%@ command %@ received %d arguments, expected %d.", @"TypeRichTextInputView", commandName, (int)[args count], 1);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
#endif
|
|
62
|
+
|
|
63
|
+
NSObject *arg0 = args[0];
|
|
64
|
+
#if RCT_DEBUG
|
|
65
|
+
if (!RCTValidateTypeOfViewCommandArgument(arg0, [NSString class], @"string", @"TypeRichTextInputView", commandName, @"1st")) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
#endif
|
|
69
|
+
NSString * text = (NSString *)arg0;
|
|
70
|
+
|
|
71
|
+
[componentView setValue:text];
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#if RCT_DEBUG
|
|
76
|
+
RCTLogError(@"%@ received command %@, which is not a supported command.", @"TypeRichTextInputView", commandName);
|
|
77
|
+
#endif
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include <react/renderer/components/TypeRichTextInputViewSpec/ShadowNodes.h>
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <react/renderer/components/TypeRichTextInputViewSpec/EventEmitters.h>
|
|
14
|
+
#include <react/renderer/components/TypeRichTextInputViewSpec/Props.h>
|
|
15
|
+
#include <react/renderer/components/TypeRichTextInputViewSpec/States.h>
|
|
16
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
+
#include <jsi/jsi.h>
|
|
18
|
+
|
|
19
|
+
namespace facebook::react {
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateStateCpp.js
|
|
9
|
+
*/
|
|
10
|
+
#include <react/renderer/components/TypeRichTextInputViewSpec/States.h>
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateStateH.js
|
|
8
|
+
*/
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#include <react/renderer/core/StateData.h>
|
|
12
|
+
#ifdef RN_SERIALIZABLE_STATE
|
|
13
|
+
#include <folly/dynamic.h>
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
namespace facebook::react {
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
4
|
+
import NativeTypeRichTextInput, { Commands } from './TypeRichTextInputNativeComponent';
|
|
5
|
+
|
|
6
|
+
// Public facing props (same as NativeProps but events normalized)
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
const TypeRichTextInput = /*#__PURE__*/forwardRef((props, ref) => {
|
|
9
|
+
const nativeRef = useRef(null);
|
|
10
|
+
useImperativeHandle(ref, () => ({
|
|
11
|
+
focus: () => {
|
|
12
|
+
if (nativeRef.current) {
|
|
13
|
+
Commands.focus(nativeRef.current);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
blur: () => {
|
|
17
|
+
if (nativeRef.current) {
|
|
18
|
+
Commands.blur(nativeRef.current);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
setValue: text => {
|
|
22
|
+
if (nativeRef.current) {
|
|
23
|
+
Commands.setValue(nativeRef.current, text);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
todo: make this only for NativeSyntheticEvent
|
|
30
|
+
*/
|
|
31
|
+
function handlePasteImage(event) {
|
|
32
|
+
// always getting nativeevent but will refactor later
|
|
33
|
+
const data = event && typeof event === 'object' ? event.nativeEvent ?? event : undefined;
|
|
34
|
+
if (data) {
|
|
35
|
+
props.onPasteImageData?.(data);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return /*#__PURE__*/_jsx(NativeTypeRichTextInput, {
|
|
39
|
+
androidExperimentalSynchronousEvents: props.androidExperimentalSynchronousEvents,
|
|
40
|
+
ref: nativeRef,
|
|
41
|
+
...props,
|
|
42
|
+
onInputFocus: () => props.onFocus?.(),
|
|
43
|
+
onInputBlur: () => props.onBlur?.(),
|
|
44
|
+
onChangeText: event => props.onChangeText?.(event.nativeEvent.value),
|
|
45
|
+
onChangeSelection: event => props.onChangeSelection?.(event.nativeEvent.start, event.nativeEvent.end, event.nativeEvent.text),
|
|
46
|
+
onPasteImage: handlePasteImage
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
export default TypeRichTextInput;
|
|
50
|
+
//# sourceMappingURL=TypeRichTextInput.js.map
|