react-native-typerich 1.1.1 → 2.2.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/README.md +2 -0
- package/ReactNativeTypeRich.podspec +41 -0
- package/android/src/main/java/com/typerich/TypeRichTextInputView.kt +32 -10
- package/android/src/main/java/com/typerich/TypeRichTextInputViewManager.kt +5 -0
- package/ios/TypeRichTextInputView.h +27 -7
- package/ios/TypeRichTextInputView.mm +809 -26
- package/ios/cpp/TypeRichTextInputViewComponentDescriptor.h +19 -0
- package/ios/cpp/TypeRichTextInputViewShadowNode.h +44 -0
- package/ios/cpp/TypeRichTextInputViewShadowNode.mm +110 -0
- package/ios/cpp/TypeRichTextInputViewState.cpp +10 -0
- package/ios/cpp/TypeRichTextInputViewState.h +22 -0
- package/ios/inputTextView/TypeRichUITextView.h +14 -0
- package/ios/inputTextView/TypeRichUITextView.mm +100 -0
- package/ios/modules/commands/TypeRichTextInputCommands.h +24 -0
- package/ios/modules/commands/TypeRichTextInputCommands.mm +392 -0
- package/ios/utils/StringUtils.h +19 -0
- package/ios/utils/StringUtils.mm +15 -0
- package/ios/utils/TextInputUtils.h +26 -0
- package/ios/utils/TextInputUtils.mm +58 -0
- package/lib/module/TypeRichTextInput.js +13 -36
- package/lib/module/TypeRichTextInput.js.map +1 -1
- package/lib/module/TypeRichTextInputNativeComponent.ts +266 -52
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/TypeRichTextInput.js +4 -0
- package/lib/module/types/TypeRichTextInput.js.map +1 -0
- package/lib/typescript/src/TypeRichTextInput.d.ts +2 -22
- package/lib/typescript/src/TypeRichTextInput.d.ts.map +1 -1
- package/lib/typescript/src/TypeRichTextInputNativeComponent.d.ts +200 -14
- package/lib/typescript/src/TypeRichTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/TypeRichTextInput.d.ts +95 -0
- package/lib/typescript/src/types/TypeRichTextInput.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/TypeRichTextInput.tsx +20 -70
- package/src/TypeRichTextInputNativeComponent.ts +266 -52
- package/src/index.tsx +1 -5
- package/src/types/TypeRichTextInput.tsx +116 -0
- package/TypeRichTextInput.podspec +0 -20
- package/ios/TypeRichTextInputViewManager.mm +0 -27
package/README.md
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
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 = "ReactNativeTypeRich"
|
|
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
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/divyanshu-patil/react-native-typerich.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
# s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm,cpp}"
|
|
18
|
+
s.private_header_files = "ios/**/*.h"
|
|
19
|
+
|
|
20
|
+
s.public_header_files = [
|
|
21
|
+
"ios/**/*.h",
|
|
22
|
+
"ios/cpp/**/*.h"
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
s.header_mappings_dir = "ios"
|
|
26
|
+
|
|
27
|
+
s.pod_target_xcconfig = {
|
|
28
|
+
"HEADER_SEARCH_PATHS" => '"$(PODS_TARGET_SRCROOT)/ios"',
|
|
29
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
33
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
34
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
35
|
+
install_modules_dependencies(s)
|
|
36
|
+
else
|
|
37
|
+
s.dependency "React-Core"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
@@ -64,6 +64,7 @@ class TypeRichTextInputView : AppCompatEditText {
|
|
|
64
64
|
private var lineHeightPx: Int? = null
|
|
65
65
|
private var isSettingTextFromJS = false
|
|
66
66
|
private var isInitialized = false
|
|
67
|
+
private var disableImagePasting = false
|
|
67
68
|
|
|
68
69
|
constructor(context: Context) : super(context) {
|
|
69
70
|
prepareComponent()
|
|
@@ -140,23 +141,34 @@ class TypeRichTextInputView : AppCompatEditText {
|
|
|
140
141
|
override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection? {
|
|
141
142
|
val ic = super.onCreateInputConnection(outAttrs) ?: return null
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
if (!disableImagePasting) {
|
|
145
|
+
EditorInfoCompat.setContentMimeTypes(
|
|
146
|
+
outAttrs,
|
|
147
|
+
arrayOf("image/png", "image/jpg", "image/jpeg", "image/gif", "image/webp")
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
return InputConnectionCompat.createWrapper(ic, outAttrs, onCommitContent)
|
|
151
|
+
}
|
|
147
152
|
|
|
148
|
-
return
|
|
153
|
+
return ic
|
|
149
154
|
}
|
|
150
155
|
|
|
151
156
|
private val onCommitContent = InputConnectionCompat.OnCommitContentListener { info, flags, _ ->
|
|
152
157
|
try {
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
val hasPermission =
|
|
159
|
+
(flags and InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0
|
|
160
|
+
|
|
161
|
+
if (hasPermission) {
|
|
155
162
|
try {
|
|
156
163
|
info.requestPermission()
|
|
157
|
-
} catch (
|
|
158
|
-
|
|
164
|
+
} catch (_: Exception) {}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (disableImagePasting) {
|
|
168
|
+
if (hasPermission) {
|
|
169
|
+
try { info.releasePermission() } catch (_: Exception) {}
|
|
159
170
|
}
|
|
171
|
+
return@OnCommitContentListener false
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
val uri = info.contentUri
|
|
@@ -189,7 +201,7 @@ class TypeRichTextInputView : AppCompatEditText {
|
|
|
189
201
|
}
|
|
190
202
|
}
|
|
191
203
|
|
|
192
|
-
// paste handler
|
|
204
|
+
// context menu paste handler
|
|
193
205
|
override fun onTextContextMenuItem(id: Int): Boolean {
|
|
194
206
|
if (id == android.R.id.paste || id == android.R.id.pasteAsPlainText) {
|
|
195
207
|
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
|
@@ -198,6 +210,12 @@ class TypeRichTextInputView : AppCompatEditText {
|
|
|
198
210
|
val clip = clipboard.primaryClip ?: return super.onTextContextMenuItem(id)
|
|
199
211
|
val item = clip.getItemAt(0)
|
|
200
212
|
|
|
213
|
+
if (disableImagePasting) {
|
|
214
|
+
if (item.uri != null || item.intent?.data != null) {
|
|
215
|
+
return true
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
201
219
|
// uri
|
|
202
220
|
item.uri?.let { uri ->
|
|
203
221
|
val source = EnumPasteSource.CLIPBOARD.value
|
|
@@ -577,6 +595,10 @@ class TypeRichTextInputView : AppCompatEditText {
|
|
|
577
595
|
}
|
|
578
596
|
}
|
|
579
597
|
|
|
598
|
+
fun setDisableImagePasting(disabled: Boolean){
|
|
599
|
+
this.disableImagePasting = disabled
|
|
600
|
+
}
|
|
601
|
+
|
|
580
602
|
override fun isLayoutRequested(): Boolean {
|
|
581
603
|
return false
|
|
582
604
|
}
|
|
@@ -145,6 +145,11 @@ class TypeRichTextInputViewManager :
|
|
|
145
145
|
view?.setLineHeightReact(lineHeight)
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
@ReactProp(name = "disableImagePasting")
|
|
149
|
+
override fun setDisableImagePasting(view: TypeRichTextInputView?, value: Boolean) {
|
|
150
|
+
view?.setDisableImagePasting(value)
|
|
151
|
+
}
|
|
152
|
+
|
|
148
153
|
override fun onAfterUpdateTransaction(view: TypeRichTextInputView) {
|
|
149
154
|
super.onAfterUpdateTransaction(view)
|
|
150
155
|
view.afterUpdateTransaction()
|
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
#import <React/RCTViewComponentView.h>
|
|
2
|
+
#import <react/renderer/core/State.h>
|
|
2
3
|
#import <UIKit/UIKit.h>
|
|
3
4
|
|
|
4
|
-
#ifndef TypeRichTextInputViewNativeComponent_h
|
|
5
|
-
#define TypeRichTextInputViewNativeComponent_h
|
|
6
|
-
|
|
7
5
|
NS_ASSUME_NONNULL_BEGIN
|
|
8
6
|
|
|
9
|
-
@interface TypeRichTextInputView : RCTViewComponentView
|
|
10
|
-
@end
|
|
7
|
+
@interface TypeRichTextInputView : RCTViewComponentView <UITextViewDelegate>
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
@property(nonatomic, assign) BOOL blockEmitting;
|
|
10
|
+
@property (atomic, assign) BOOL isUserTyping;
|
|
11
|
+
@property (atomic, assign) CFTimeInterval lastTypingTime;
|
|
12
|
+
|
|
13
|
+
- (CGSize)measureSize:(CGFloat)maxWidth;
|
|
14
|
+
|
|
15
|
+
// events
|
|
16
|
+
- (void)emitPasteImageEventWith:(NSString *)uri
|
|
17
|
+
type:(NSString *)type
|
|
18
|
+
fileName:(NSString *)fileName
|
|
19
|
+
fileSize:(NSUInteger)fileSize;
|
|
13
20
|
|
|
14
|
-
|
|
21
|
+
// commands
|
|
22
|
+
- (void)handleCommand:(NSString *)commandName
|
|
23
|
+
args:(NSArray *)args;
|
|
24
|
+
|
|
25
|
+
// helpers used by commands
|
|
26
|
+
- (BOOL)isTouchInProgress;
|
|
27
|
+
//- (BOOL)isHandlingUserInput;
|
|
28
|
+
- (void)invalidateTextLayoutFromCommand;
|
|
29
|
+
- (void)updatePlaceholderVisibilityFromCommand;
|
|
30
|
+
- (void)dispatchSelectionChangeIfNeeded;
|
|
31
|
+
- (BOOL)isDisableImagePasting;
|
|
32
|
+
|
|
33
|
+
@end
|
|
34
|
+
NS_ASSUME_NONNULL_END
|