@onekeyfe/react-native-text-input 0.2.9 → 3.0.91
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/OneKeyTextInput.podspec +18 -0
- package/README.md +10 -28
- package/android/build.gradle +3 -3
- package/android/gradle.properties +5 -5
- package/android/src/main/java/com/textinput/TextInputViewManager.kt +11 -7
- package/ios/OneKeyTextInputPasteObserver.h +11 -0
- package/ios/OneKeyTextInputPasteObserver.mm +204 -0
- package/lib/module/AndroidTextInputNativeComponent.js +111 -0
- package/lib/{commonjs → module}/Input.js +128 -156
- package/lib/module/enum.js +7 -0
- package/lib/module/index.js +11 -0
- package/lib/module/package.json +1 -0
- package/lib/module/type.js +4 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/index.d.ts +4 -4
- package/lib/typescript/src/type.d.ts +2 -2
- package/package.json +32 -117
- package/react-native.config.js +12 -0
- package/src/AndroidTextInputNativeComponent.js +77 -88
- package/src/Input.js +243 -1121
- package/src/enum.ts +1 -1
- package/src/index.tsx +5 -5
- package/src/type.ts +2 -2
- package/android/generated/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/OneKeyTextInputManagerDelegate.java +0 -26
- package/android/generated/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/OneKeyTextInputManagerInterface.java +0 -17
- package/android/generated/android/app/build/generated/source/codegen/jni/CMakeLists.txt +0 -36
- package/android/generated/android/app/build/generated/source/codegen/jni/RNTextInputViewSpec-generated.cpp +0 -22
- package/android/generated/android/app/build/generated/source/codegen/jni/RNTextInputViewSpec.h +0 -24
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/ComponentDescriptors.cpp +0 -22
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/ComponentDescriptors.h +0 -24
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/EventEmitters.cpp +0 -24
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/EventEmitters.h +0 -25
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/Props.cpp +0 -25
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/Props.h +0 -27
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/RNTextInputViewSpecJSI-generated.cpp +0 -17
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/RNTextInputViewSpecJSI.h +0 -19
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/ShadowNodes.cpp +0 -17
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/ShadowNodes.h +0 -32
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/States.cpp +0 -16
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/States.h +0 -29
- package/android/src/newarch/TextInputViewManagerSpec.kt +0 -21
- package/android/src/oldarch/TextInputViewManagerSpec.kt +0 -9
- package/ios/TextInputViewManager.mm +0 -23
- package/ios/Utils.h +0 -8
- package/ios/Utils.m +0 -26
- package/ios/generated/build/generated/ios/RNTextInputViewSpec/RNTextInputViewSpec-generated.mm +0 -16
- package/ios/generated/build/generated/ios/RNTextInputViewSpec/RNTextInputViewSpec.h +0 -38
- package/ios/generated/build/generated/ios/RNTextInputViewSpecJSI-generated.cpp +0 -17
- package/ios/generated/build/generated/ios/RNTextInputViewSpecJSI.h +0 -19
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/ComponentDescriptors.cpp +0 -22
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/ComponentDescriptors.h +0 -24
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/EventEmitters.cpp +0 -24
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/EventEmitters.h +0 -25
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/Props.cpp +0 -25
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/Props.h +0 -27
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/RCTComponentViewHelpers.h +0 -20
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/ShadowNodes.cpp +0 -17
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/ShadowNodes.h +0 -32
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/States.cpp +0 -16
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/States.h +0 -29
- package/lib/commonjs/AndroidTextInputNativeComponent.js +0 -152
- package/lib/commonjs/AndroidTextInputNativeComponent.js.map +0 -1
- package/lib/commonjs/Input.js.map +0 -1
- package/lib/commonjs/TextInputViewNativeComponent.ts +0 -9
- package/lib/commonjs/enum.js +0 -11
- package/lib/commonjs/enum.js.map +0 -1
- package/lib/commonjs/index.js +0 -28
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/package.json +0 -1
- package/lib/commonjs/type.js +0 -6
- package/lib/commonjs/type.js.map +0 -1
- package/lib/typescript/src/TextInputViewNativeComponent.d.ts +0 -8
- package/lib/typescript/src/TextInputViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/enum.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/type.d.ts.map +0 -1
- package/src/TextInputViewNativeComponent.ts +0 -9
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "OneKeyTextInput"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
s.platforms = { :ios => "15.5" }
|
|
13
|
+
s.source = { :git => "https://github.com/OneKeyHQ/app-modules.git", :tag => "#{s.version}" }
|
|
14
|
+
s.source_files = "ios/**/*.{h,m,mm}"
|
|
15
|
+
s.frameworks = "UIKit", "UniformTypeIdentifiers"
|
|
16
|
+
|
|
17
|
+
s.dependency "React-Core"
|
|
18
|
+
end
|
package/README.md
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
1
|
-
# react-native-text-input
|
|
1
|
+
# @onekeyfe/react-native-text-input
|
|
2
2
|
|
|
3
|
-
text
|
|
3
|
+
React Native TextInput with paste events for text and images on Android and iOS.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```tsx
|
|
6
|
+
import TextInput from '@onekeyfe/react-native-text-input';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
<TextInput
|
|
9
|
+
onPaste={({ nativeEvent }) => {
|
|
10
|
+
console.log(nativeEvent.items);
|
|
11
|
+
}}
|
|
12
|
+
/>
|
|
9
13
|
```
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
```js
|
|
15
|
-
import { TextInputView } from "react-native-text-input";
|
|
16
|
-
|
|
17
|
-
// ...
|
|
18
|
-
|
|
19
|
-
<TextInputView color="tomato" />
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## Contributing
|
|
24
|
-
|
|
25
|
-
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
26
|
-
|
|
27
|
-
## License
|
|
28
|
-
|
|
29
|
-
MIT
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
15
|
+
Image paste items contain a MIME type and a temporary local file URL. Text paste items use `text/plain`.
|
package/android/build.gradle
CHANGED
|
@@ -8,7 +8,7 @@ buildscript {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
dependencies {
|
|
11
|
-
classpath "com.android.tools.build:gradle:7.2
|
|
11
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
12
12
|
// noinspection DifferentKotlinGradleVersion
|
|
13
13
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
14
|
}
|
|
@@ -113,14 +113,14 @@ dependencies {
|
|
|
113
113
|
// For < 0.71, this will be from the local maven repo
|
|
114
114
|
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
115
115
|
//noinspection GradleDynamicVersion
|
|
116
|
-
implementation "com.facebook.react:react-
|
|
116
|
+
implementation "com.facebook.react:react-android"
|
|
117
117
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
if (isNewArchitectureEnabled()) {
|
|
121
121
|
react {
|
|
122
122
|
jsRootDir = file("../src/")
|
|
123
|
-
libraryName = "
|
|
123
|
+
libraryName = "RNTextInputViewSpec"
|
|
124
124
|
codegenJavaPackageName = "com.textinput"
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
TextInput_kotlinVersion=1.
|
|
2
|
-
TextInput_minSdkVersion=
|
|
3
|
-
TextInput_targetSdkVersion=
|
|
4
|
-
TextInput_compileSdkVersion=
|
|
5
|
-
TextInput_ndkversion=
|
|
1
|
+
TextInput_kotlinVersion=2.1.20
|
|
2
|
+
TextInput_minSdkVersion=24
|
|
3
|
+
TextInput_targetSdkVersion=36
|
|
4
|
+
TextInput_compileSdkVersion=36
|
|
5
|
+
TextInput_ndkversion=27.1.12297006
|
|
@@ -12,10 +12,10 @@ import com.facebook.react.views.textinput.ReactEditText
|
|
|
12
12
|
import com.facebook.react.views.textinput.ReactTextInputManager
|
|
13
13
|
import so.onekey.app.wallet.pasteinput.PasteWatcher
|
|
14
14
|
|
|
15
|
-
@ReactModule(name =
|
|
16
|
-
class TextInputViewManager
|
|
15
|
+
@ReactModule(name = TextInputViewManager.REACT_CLASS)
|
|
16
|
+
class TextInputViewManager : ReactTextInputManager() {
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
companion object {
|
|
19
19
|
const val REACT_CLASS = "OneKeyTextInput"
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -33,9 +33,12 @@ class TextInputViewManager() : ReactTextInputManager() {
|
|
|
33
33
|
return editText
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
baseEventTypeConstants
|
|
36
|
+
// Fix return type to match ReactTextInputManager's definition, which is Map<String, Any>
|
|
37
|
+
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> {
|
|
38
|
+
val baseEventTypeConstants =
|
|
39
|
+
(super.getExportedCustomDirectEventTypeConstants() as? MutableMap<String, Any>)
|
|
40
|
+
?: mutableMapOf()
|
|
41
|
+
baseEventTypeConstants["topPaste"] = MapBuilder.of("registrationName", "onPaste")
|
|
39
42
|
return baseEventTypeConstants
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -55,7 +58,8 @@ class TextInputViewManager() : ReactTextInputManager() {
|
|
|
55
58
|
|
|
56
59
|
init {
|
|
57
60
|
val reactContext = UIManagerHelper.getReactContext(editText)
|
|
58
|
-
mEventDispatcher =
|
|
61
|
+
mEventDispatcher =
|
|
62
|
+
UIManagerHelper.getEventDispatcherForReactTag(reactContext, editText.id)!!
|
|
59
63
|
mSurfaceId = UIManagerHelper.getSurfaceId(reactContext)
|
|
60
64
|
}
|
|
61
65
|
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#import "OneKeyTextInputPasteObserver.h"
|
|
2
|
+
|
|
3
|
+
#import <React/RCTBridgeModule.h>
|
|
4
|
+
#import <React/RCTUITextField.h>
|
|
5
|
+
#import <React/RCTUITextView.h>
|
|
6
|
+
#import <React/UIView+React.h>
|
|
7
|
+
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
|
|
8
|
+
#import <objc/runtime.h>
|
|
9
|
+
|
|
10
|
+
static NSString *const OneKeyTextInputPasteEvent = @"OneKeyTextInputPaste";
|
|
11
|
+
static __weak OneKeyTextInputPasteObserver *OneKeyPasteObserver = nil;
|
|
12
|
+
static BOOL OneKeyPasteObserverHasListeners = NO;
|
|
13
|
+
static const void *OneKeyPasteInFlightKey = &OneKeyPasteInFlightKey;
|
|
14
|
+
|
|
15
|
+
@implementation OneKeyTextInputPasteObserver
|
|
16
|
+
|
|
17
|
+
RCT_EXPORT_MODULE(OneKeyTextInputPasteObserver)
|
|
18
|
+
|
|
19
|
+
+ (BOOL)requiresMainQueueSetup
|
|
20
|
+
{
|
|
21
|
+
return YES;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
- (instancetype)init
|
|
25
|
+
{
|
|
26
|
+
if (self = [super init]) {
|
|
27
|
+
OneKeyPasteObserver = self;
|
|
28
|
+
}
|
|
29
|
+
return self;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
- (NSArray<NSString *> *)supportedEvents
|
|
33
|
+
{
|
|
34
|
+
return @[ OneKeyTextInputPasteEvent ];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
- (void)startObserving
|
|
38
|
+
{
|
|
39
|
+
OneKeyPasteObserverHasListeners = YES;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (void)stopObserving
|
|
43
|
+
{
|
|
44
|
+
OneKeyPasteObserverHasListeners = NO;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
+ (void)emitPasteForTarget:(NSInteger)target type:(NSString *)type data:(NSString *)data
|
|
48
|
+
{
|
|
49
|
+
NSCharacterSet *whitespace = NSCharacterSet.whitespaceAndNewlineCharacterSet;
|
|
50
|
+
if (target <= 0 ||
|
|
51
|
+
[type stringByTrimmingCharactersInSet:whitespace].length == 0 ||
|
|
52
|
+
[data stringByTrimmingCharactersInSet:whitespace].length == 0) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
56
|
+
if (!OneKeyPasteObserverHasListeners || OneKeyPasteObserver == nil) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
[OneKeyPasteObserver sendEventWithName:OneKeyTextInputPasteEvent
|
|
60
|
+
body:@{
|
|
61
|
+
@"target" : @(target),
|
|
62
|
+
@"items" : @[ @{ @"type" : type, @"data" : data } ],
|
|
63
|
+
}];
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@end
|
|
68
|
+
|
|
69
|
+
static NSInteger OneKeyReactTagForBackedTextInput(UIView *view)
|
|
70
|
+
{
|
|
71
|
+
for (UIView *candidate = view; candidate != nil; candidate = candidate.superview) {
|
|
72
|
+
if (candidate.reactTag != nil) {
|
|
73
|
+
return candidate.reactTag.integerValue;
|
|
74
|
+
}
|
|
75
|
+
if (candidate.tag > 0 && [NSStringFromClass(candidate.class) containsString:@"TextInputComponentView"]) {
|
|
76
|
+
return candidate.tag;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static void OneKeyEmitPaste(UIView *view, NSString *type, NSString *data)
|
|
83
|
+
{
|
|
84
|
+
[OneKeyTextInputPasteObserver emitPasteForTarget:OneKeyReactTagForBackedTextInput(view) type:type data:data];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static BOOL OneKeyProcessImagePaste(UIView *view, UIPasteboard *pasteboard, dispatch_block_t fallbackPaste)
|
|
88
|
+
{
|
|
89
|
+
if ([objc_getAssociatedObject(view, OneKeyPasteInFlightKey) boolValue]) {
|
|
90
|
+
return YES;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (NSItemProvider *itemProvider in pasteboard.itemProviders) {
|
|
94
|
+
for (NSString *identifier in itemProvider.registeredTypeIdentifiers) {
|
|
95
|
+
UTType *type = [UTType typeWithIdentifier:identifier];
|
|
96
|
+
if (type == nil || ![type conformsToType:UTTypeImage]) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
objc_setAssociatedObject(view, OneKeyPasteInFlightKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
101
|
+
NSString *clipboardString = pasteboard.hasStrings ? pasteboard.string : nil;
|
|
102
|
+
NSInteger target = OneKeyReactTagForBackedTextInput(view);
|
|
103
|
+
[itemProvider loadDataRepresentationForTypeIdentifier:identifier
|
|
104
|
+
completionHandler:^(NSData *data, NSError *error) {
|
|
105
|
+
NSString *mimeType = type.preferredMIMEType ?: @"application/octet-stream";
|
|
106
|
+
NSString *fileExtension = type.preferredFilenameExtension ?: @"bin";
|
|
107
|
+
NSString *fileName = [NSString stringWithFormat:@"%@.%@", NSUUID.UUID.UUIDString, fileExtension];
|
|
108
|
+
NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
|
|
109
|
+
BOOL writeSucceeded = error == nil && data != nil && [data writeToFile:filePath atomically:YES];
|
|
110
|
+
|
|
111
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
112
|
+
objc_setAssociatedObject(view, OneKeyPasteInFlightKey, @NO, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
113
|
+
if (writeSucceeded) {
|
|
114
|
+
[OneKeyTextInputPasteObserver emitPasteForTarget:target
|
|
115
|
+
type:mimeType
|
|
116
|
+
data:[NSURL fileURLWithPath:filePath].absoluteString];
|
|
117
|
+
} else {
|
|
118
|
+
if (clipboardString.length > 0) {
|
|
119
|
+
[OneKeyTextInputPasteObserver emitPasteForTarget:target type:@"text/plain" data:clipboardString];
|
|
120
|
+
}
|
|
121
|
+
fallbackPaste();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}];
|
|
125
|
+
return YES;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return NO;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
static void OneKeySwizzle(Class cls, SEL originalSelector, SEL replacementSelector)
|
|
132
|
+
{
|
|
133
|
+
Method originalMethod = class_getInstanceMethod(cls, originalSelector);
|
|
134
|
+
Method replacementMethod = class_getInstanceMethod(cls, replacementSelector);
|
|
135
|
+
if (originalMethod != nil && replacementMethod != nil) {
|
|
136
|
+
method_exchangeImplementations(originalMethod, replacementMethod);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@implementation RCTUITextField (OneKeyPaste)
|
|
141
|
+
|
|
142
|
+
+ (void)load
|
|
143
|
+
{
|
|
144
|
+
static dispatch_once_t onceToken;
|
|
145
|
+
dispatch_once(&onceToken, ^{
|
|
146
|
+
OneKeySwizzle(self, @selector(paste:), @selector(onekey_paste:));
|
|
147
|
+
OneKeySwizzle(self, @selector(canPerformAction:withSender:), @selector(onekey_canPerformAction:withSender:));
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
- (void)onekey_paste:(id)sender
|
|
152
|
+
{
|
|
153
|
+
UIPasteboard *pasteboard = UIPasteboard.generalPasteboard;
|
|
154
|
+
if (pasteboard.hasImages && OneKeyProcessImagePaste(self, pasteboard, ^{ [self onekey_paste:nil]; })) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (pasteboard.hasStrings) {
|
|
158
|
+
OneKeyEmitPaste(self, @"text/plain", pasteboard.string);
|
|
159
|
+
}
|
|
160
|
+
[self onekey_paste:sender];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
- (BOOL)onekey_canPerformAction:(SEL)action withSender:(id)sender
|
|
164
|
+
{
|
|
165
|
+
if (action == @selector(paste:) && UIPasteboard.generalPasteboard.hasImages) {
|
|
166
|
+
return YES;
|
|
167
|
+
}
|
|
168
|
+
return [self onekey_canPerformAction:action withSender:sender];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@end
|
|
172
|
+
|
|
173
|
+
@implementation RCTUITextView (OneKeyPaste)
|
|
174
|
+
|
|
175
|
+
+ (void)load
|
|
176
|
+
{
|
|
177
|
+
static dispatch_once_t onceToken;
|
|
178
|
+
dispatch_once(&onceToken, ^{
|
|
179
|
+
OneKeySwizzle(self, @selector(paste:), @selector(onekey_paste:));
|
|
180
|
+
OneKeySwizzle(self, @selector(canPerformAction:withSender:), @selector(onekey_canPerformAction:withSender:));
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
- (void)onekey_paste:(id)sender
|
|
185
|
+
{
|
|
186
|
+
UIPasteboard *pasteboard = UIPasteboard.generalPasteboard;
|
|
187
|
+
if (pasteboard.hasImages && OneKeyProcessImagePaste(self, pasteboard, ^{ [self onekey_paste:nil]; })) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (pasteboard.hasStrings) {
|
|
191
|
+
OneKeyEmitPaste(self, @"text/plain", pasteboard.string);
|
|
192
|
+
}
|
|
193
|
+
[self onekey_paste:sender];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
- (BOOL)onekey_canPerformAction:(SEL)action withSender:(id)sender
|
|
197
|
+
{
|
|
198
|
+
if (action == @selector(paste:) && UIPasteboard.generalPasteboard.hasImages) {
|
|
199
|
+
return YES;
|
|
200
|
+
}
|
|
201
|
+
return [self onekey_canPerformAction:action withSender:sender];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as NativeComponentRegistry from 'react-native/Libraries/NativeComponent/NativeComponentRegistry';
|
|
4
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
5
|
+
import { colorAttribute } from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes';
|
|
6
|
+
export const Commands = codegenNativeCommands({
|
|
7
|
+
supportedCommands: ['focus', 'blur', 'setTextAndSelection']
|
|
8
|
+
});
|
|
9
|
+
export const __INTERNAL_VIEW_CONFIG = {
|
|
10
|
+
uiViewClassName: 'OneKeyTextInput',
|
|
11
|
+
bubblingEventTypes: {
|
|
12
|
+
topEndEditing: {
|
|
13
|
+
phasedRegistrationNames: {
|
|
14
|
+
bubbled: 'onEndEditing',
|
|
15
|
+
captured: 'onEndEditingCapture'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
topKeyPress: {
|
|
19
|
+
phasedRegistrationNames: {
|
|
20
|
+
bubbled: 'onKeyPress',
|
|
21
|
+
captured: 'onKeyPressCapture'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
topSubmitEditing: {
|
|
25
|
+
phasedRegistrationNames: {
|
|
26
|
+
bubbled: 'onSubmitEditing',
|
|
27
|
+
captured: 'onSubmitEditingCapture'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
directEventTypes: {
|
|
32
|
+
topScroll: {
|
|
33
|
+
registrationName: 'onScroll'
|
|
34
|
+
},
|
|
35
|
+
topPaste: {
|
|
36
|
+
registrationName: 'onPaste'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
validAttributes: {
|
|
40
|
+
acceptDragAndDropTypes: true,
|
|
41
|
+
maxFontSizeMultiplier: true,
|
|
42
|
+
adjustsFontSizeToFit: true,
|
|
43
|
+
minimumFontScale: true,
|
|
44
|
+
autoFocus: true,
|
|
45
|
+
placeholder: true,
|
|
46
|
+
inlineImagePadding: true,
|
|
47
|
+
contextMenuHidden: true,
|
|
48
|
+
textShadowColor: colorAttribute,
|
|
49
|
+
maxLength: true,
|
|
50
|
+
selectTextOnFocus: true,
|
|
51
|
+
textShadowRadius: true,
|
|
52
|
+
underlineColorAndroid: colorAttribute,
|
|
53
|
+
textDecorationLine: true,
|
|
54
|
+
submitBehavior: true,
|
|
55
|
+
textAlignVertical: true,
|
|
56
|
+
fontStyle: true,
|
|
57
|
+
textShadowOffset: true,
|
|
58
|
+
selectionColor: colorAttribute,
|
|
59
|
+
selectionHandleColor: colorAttribute,
|
|
60
|
+
placeholderTextColor: colorAttribute,
|
|
61
|
+
importantForAutofill: true,
|
|
62
|
+
lineHeight: true,
|
|
63
|
+
textTransform: true,
|
|
64
|
+
returnKeyType: true,
|
|
65
|
+
keyboardType: true,
|
|
66
|
+
multiline: true,
|
|
67
|
+
color: colorAttribute,
|
|
68
|
+
autoComplete: true,
|
|
69
|
+
numberOfLines: true,
|
|
70
|
+
letterSpacing: true,
|
|
71
|
+
returnKeyLabel: true,
|
|
72
|
+
fontSize: true,
|
|
73
|
+
onKeyPress: true,
|
|
74
|
+
cursorColor: colorAttribute,
|
|
75
|
+
text: true,
|
|
76
|
+
showSoftInputOnFocus: true,
|
|
77
|
+
textAlign: true,
|
|
78
|
+
autoCapitalize: true,
|
|
79
|
+
autoCorrect: true,
|
|
80
|
+
caretHidden: true,
|
|
81
|
+
secureTextEntry: true,
|
|
82
|
+
textBreakStrategy: true,
|
|
83
|
+
onScroll: true,
|
|
84
|
+
onPaste: true,
|
|
85
|
+
onContentSizeChange: true,
|
|
86
|
+
disableFullscreenUI: true,
|
|
87
|
+
includeFontPadding: true,
|
|
88
|
+
fontWeight: true,
|
|
89
|
+
fontFamily: true,
|
|
90
|
+
allowFontScaling: true,
|
|
91
|
+
onSelectionChange: true,
|
|
92
|
+
mostRecentEventCount: true,
|
|
93
|
+
inlineImageLeft: true,
|
|
94
|
+
editable: true,
|
|
95
|
+
fontVariant: true,
|
|
96
|
+
borderBottomRightRadius: true,
|
|
97
|
+
borderBottomColor: colorAttribute,
|
|
98
|
+
borderRadius: true,
|
|
99
|
+
borderRightColor: colorAttribute,
|
|
100
|
+
borderColor: colorAttribute,
|
|
101
|
+
borderTopRightRadius: true,
|
|
102
|
+
borderStyle: true,
|
|
103
|
+
borderBottomLeftRadius: true,
|
|
104
|
+
borderLeftColor: colorAttribute,
|
|
105
|
+
borderTopLeftRadius: true,
|
|
106
|
+
borderTopColor: colorAttribute
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
let AndroidTextInputNativeComponent = NativeComponentRegistry.get('OneKeyTextInput', () => __INTERNAL_VIEW_CONFIG);
|
|
110
|
+
export default AndroidTextInputNativeComponent;
|
|
111
|
+
//# sourceMappingURL=AndroidTextInputNativeComponent.js.map
|