@tbvjaos510/react-native-paste-input 0.9.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.
Files changed (108) hide show
  1. package/.circleci/config.yml +130 -0
  2. package/LICENSE +21 -0
  3. package/README.md +73 -0
  4. package/android/.project +17 -0
  5. package/android/.settings/org.eclipse.buildship.core.prefs +13 -0
  6. package/android/build.gradle +94 -0
  7. package/android/generated/java/com/facebook/react/viewmanagers/PasteTextInputManagerDelegate.java +236 -0
  8. package/android/generated/java/com/facebook/react/viewmanagers/PasteTextInputManagerInterface.java +84 -0
  9. package/android/generated/jni/CMakeLists.txt +36 -0
  10. package/android/generated/jni/PasteTextInputSpecs-generated.cpp +27 -0
  11. package/android/generated/jni/PasteTextInputSpecs.h +28 -0
  12. package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/ComponentDescriptors.cpp +22 -0
  13. package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/ComponentDescriptors.h +166 -0
  14. package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/EventEmitters.cpp +183 -0
  15. package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/EventEmitters.h +148 -0
  16. package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/PasteTextInputSpecsJSI-generated.cpp +17 -0
  17. package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/PasteTextInputSpecsJSI.h +19 -0
  18. package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/Props.cpp +640 -0
  19. package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/Props.h +144 -0
  20. package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/ShadowNodes.cpp +247 -0
  21. package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/ShadowNodes.h +95 -0
  22. package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/States.cpp +14 -0
  23. package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/States.h +19 -0
  24. package/android/gradle.properties +6 -0
  25. package/android/src/main/java/com/mattermost/pasteinputtext/IPasteInputListener.kt +8 -0
  26. package/android/src/main/java/com/mattermost/pasteinputtext/PasteInputActionCallback.kt +72 -0
  27. package/android/src/main/java/com/mattermost/pasteinputtext/PasteInputEditText.kt +60 -0
  28. package/android/src/main/java/com/mattermost/pasteinputtext/PasteInputFileFromUrl.kt +50 -0
  29. package/android/src/main/java/com/mattermost/pasteinputtext/PasteInputListener.kt +84 -0
  30. package/android/src/main/java/com/mattermost/pasteinputtext/PasteTextInputManager.kt +72 -0
  31. package/android/src/main/java/com/mattermost/pasteinputtext/PasteTextInputPackage.kt +14 -0
  32. package/android/src/main/java/com/mattermost/pasteinputtext/PasteTextInputPasteEvent.java +41 -0
  33. package/android/src/main/java/com/mattermost/pasteinputtext/RealPathUtil.kt +174 -0
  34. package/ios/NSData+MimeType.h +20 -0
  35. package/ios/NSData+MimeType.m +59 -0
  36. package/ios/PasteInput-Bridging-Header.h +1 -0
  37. package/ios/PasteInput.xcodeproj/project.pbxproj +319 -0
  38. package/ios/PasteInputTextView.h +20 -0
  39. package/ios/PasteInputTextView.m +68 -0
  40. package/ios/PasteInputView.h +18 -0
  41. package/ios/PasteInputView.m +96 -0
  42. package/ios/PasteTextInput.h +13 -0
  43. package/ios/PasteTextInput.mm +726 -0
  44. package/ios/PasteTextInputManager.mm +171 -0
  45. package/ios/Swime/MimeType.h +70 -0
  46. package/ios/Swime/MimeType.m +701 -0
  47. package/ios/Swime/Swime.h +14 -0
  48. package/ios/Swime/Swime.m +28 -0
  49. package/ios/Swime/SwimeProxy.h +18 -0
  50. package/ios/Swime/SwimeProxy.m +66 -0
  51. package/ios/Swime/SwimeUtils.h +12 -0
  52. package/ios/Swime/SwimeUtils.m +23 -0
  53. package/ios/UIImage+ImageEffects.h +112 -0
  54. package/ios/UIImage+ImageEffects.m +310 -0
  55. package/ios/UIImage+vImageScaling.h +16 -0
  56. package/ios/UIImage+vImageScaling.m +48 -0
  57. package/ios/UIPasteboard+GetImageInfo.h +19 -0
  58. package/ios/UIPasteboard+GetImageInfo.m +98 -0
  59. package/ios/generated/PasteTextInputSpecs/ComponentDescriptors.cpp +22 -0
  60. package/ios/generated/PasteTextInputSpecs/ComponentDescriptors.h +42 -0
  61. package/ios/generated/PasteTextInputSpecs/EventEmitters.cpp +41 -0
  62. package/ios/generated/PasteTextInputSpecs/EventEmitters.h +37 -0
  63. package/ios/generated/PasteTextInputSpecs/PasteTextInputSpecs-generated.mm +16 -0
  64. package/ios/generated/PasteTextInputSpecs/PasteTextInputSpecs.h +38 -0
  65. package/ios/generated/PasteTextInputSpecs/Props.cpp +142 -0
  66. package/ios/generated/PasteTextInputSpecs/Props.h +81 -0
  67. package/ios/generated/PasteTextInputSpecs/RCTComponentViewHelpers.h +106 -0
  68. package/ios/generated/PasteTextInputSpecs/ShadowNodes.cpp +127 -0
  69. package/ios/generated/PasteTextInputSpecs/ShadowNodes.h +85 -0
  70. package/ios/generated/PasteTextInputSpecs/States.cpp +16 -0
  71. package/ios/generated/PasteTextInputSpecs/States.h +53 -0
  72. package/ios/generated/PasteTextInputSpecsJSI-generated.cpp +17 -0
  73. package/ios/generated/PasteTextInputSpecsJSI.h +19 -0
  74. package/lib/commonjs/PasteTextInput.js +446 -0
  75. package/lib/commonjs/PasteTextInput.js.map +1 -0
  76. package/lib/commonjs/PasteTextInputNativeComponent.ts +277 -0
  77. package/lib/commonjs/index.js +25 -0
  78. package/lib/commonjs/index.js.map +1 -0
  79. package/lib/commonjs/module.d.js +2 -0
  80. package/lib/commonjs/module.d.js.map +1 -0
  81. package/lib/commonjs/package.json +1 -0
  82. package/lib/commonjs/types.js +6 -0
  83. package/lib/commonjs/types.js.map +1 -0
  84. package/lib/module/PasteTextInput.js +440 -0
  85. package/lib/module/PasteTextInput.js.map +1 -0
  86. package/lib/module/PasteTextInputNativeComponent.ts +277 -0
  87. package/lib/module/index.js +9 -0
  88. package/lib/module/index.js.map +1 -0
  89. package/lib/module/module.d.js +2 -0
  90. package/lib/module/module.d.js.map +1 -0
  91. package/lib/module/types.js +4 -0
  92. package/lib/module/types.js.map +1 -0
  93. package/lib/typescript/src/PasteTextInput.d.ts +5 -0
  94. package/lib/typescript/src/PasteTextInput.d.ts.map +1 -0
  95. package/lib/typescript/src/PasteTextInputNativeComponent.d.ts +168 -0
  96. package/lib/typescript/src/PasteTextInputNativeComponent.d.ts.map +1 -0
  97. package/lib/typescript/src/index.d.ts +6 -0
  98. package/lib/typescript/src/index.d.ts.map +1 -0
  99. package/lib/typescript/src/types.d.ts +56 -0
  100. package/lib/typescript/src/types.d.ts.map +1 -0
  101. package/package.json +140 -0
  102. package/react-native-paste-input.podspec +20 -0
  103. package/react-native.config.js +13 -0
  104. package/src/PasteTextInput.tsx +615 -0
  105. package/src/PasteTextInputNativeComponent.ts +277 -0
  106. package/src/index.ts +13 -0
  107. package/src/module.d.ts +4 -0
  108. package/src/types.ts +71 -0
@@ -0,0 +1,127 @@
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 "ShadowNodes.h"
12
+
13
+ #include <react/debug/react_native_assert.h>
14
+ #include <react/renderer/attributedstring/AttributedStringBox.h>
15
+ #include <react/renderer/attributedstring/TextAttributes.h>
16
+ #include <react/renderer/core/LayoutConstraints.h>
17
+ #include <react/renderer/core/LayoutContext.h>
18
+ #include <react/renderer/core/conversions.h>
19
+ #include <react/renderer/textlayoutmanager/TextLayoutContext.h>
20
+
21
+ namespace facebook::react {
22
+
23
+ extern const char PasteTextInputComponentName[] = "PasteTextInput";
24
+
25
+
26
+ AttributedStringBox PasteTextInputShadowNode::attributedStringBoxToMeasure(
27
+ const LayoutContext& layoutContext) const {
28
+ bool hasMeaningfulState =
29
+ getState() && getState()->getRevision() != State::initialRevisionValue;
30
+
31
+ if (hasMeaningfulState) {
32
+ auto attributedStringBox = getStateData().attributedStringBox;
33
+ if (attributedStringBox.getMode() ==
34
+ AttributedStringBox::Mode::OpaquePointer ||
35
+ !attributedStringBox.getValue().isEmpty()) {
36
+ return getStateData().attributedStringBox;
37
+ }
38
+ }
39
+
40
+ auto attributedString = hasMeaningfulState
41
+ ? AttributedString{}
42
+ : getAttributedString(layoutContext);
43
+
44
+ if (attributedString.isEmpty()) {
45
+ auto placeholder = getConcreteProps().placeholder;
46
+ // Note: `zero-width space` is insufficient in some cases (e.g. when we need
47
+ // to measure the "hight" of the font).
48
+ // TODO T67606511: We will redefine the measurement of empty strings as part
49
+ // of T67606511
50
+ if (!placeholder.empty()) {
51
+ auto textAttributes = getConcreteProps().getEffectiveTextAttributes(
52
+ layoutContext.fontSizeMultiplier);
53
+ attributedString.appendFragment({placeholder, textAttributes, {}});
54
+ }
55
+ }
56
+
57
+ return AttributedStringBox{attributedString};
58
+ }
59
+
60
+ AttributedString PasteTextInputShadowNode::getAttributedString(
61
+ const LayoutContext& layoutContext) const {
62
+ auto textAttributes = getConcreteProps().getEffectiveTextAttributes(
63
+ layoutContext.fontSizeMultiplier);
64
+ auto attributedString = AttributedString{};
65
+
66
+ attributedString.appendFragment(AttributedString::Fragment{
67
+ .string = getConcreteProps().text,
68
+ .textAttributes = textAttributes,
69
+ // TODO: Is this really meant to be by value?
70
+ .parentShadowView = ShadowView{}});
71
+
72
+ auto attachments = Attachments{};
73
+ BaseTextShadowNode::buildAttributedString(
74
+ textAttributes, *this, attributedString, attachments);
75
+
76
+ return attributedString;
77
+ }
78
+
79
+ void PasteTextInputShadowNode::setTextLayoutManager(
80
+ std::shared_ptr<const TextLayoutManager> textLayoutManager) {
81
+ ensureUnsealed();
82
+ textLayoutManager_ = std::move(textLayoutManager);
83
+ }
84
+
85
+ void PasteTextInputShadowNode::updateStateIfNeeded(
86
+ const LayoutContext& layoutContext) {
87
+ ensureUnsealed();
88
+
89
+ auto reactTreeAttributedString = getAttributedString(layoutContext);
90
+ const auto& state = getStateData();
91
+
92
+ react_native_assert(textLayoutManager_);
93
+
94
+ if (state.reactTreeAttributedString == reactTreeAttributedString) {
95
+ return;
96
+ }
97
+
98
+ auto newState = TextInputState{};
99
+ newState.attributedStringBox = AttributedStringBox{reactTreeAttributedString};
100
+ newState.paragraphAttributes = getConcreteProps().paragraphAttributes;
101
+ newState.reactTreeAttributedString = reactTreeAttributedString;
102
+ newState.mostRecentEventCount = getConcreteProps().mostRecentEventCount;
103
+ setStateData(std::move(newState));
104
+ }
105
+
106
+ #pragma mark - LayoutableShadowNode
107
+
108
+ Size PasteTextInputShadowNode::measureContent(
109
+ const LayoutContext& layoutContext,
110
+ const LayoutConstraints& layoutConstraints) const {
111
+ TextLayoutContext textLayoutContext{};
112
+ textLayoutContext.pointScaleFactor = layoutContext.pointScaleFactor;
113
+ return textLayoutManager_
114
+ ->measure(
115
+ attributedStringBoxToMeasure(layoutContext),
116
+ getConcreteProps().getEffectiveParagraphAttributes(),
117
+ textLayoutContext,
118
+ layoutConstraints)
119
+ .size;
120
+ }
121
+
122
+ void PasteTextInputShadowNode::layout(LayoutContext layoutContext) {
123
+ updateStateIfNeeded(layoutContext);
124
+ ConcreteViewShadowNode::layout(layoutContext);
125
+ }
126
+
127
+ } // namespace facebook::react
@@ -0,0 +1,85 @@
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 "EventEmitters.h"
14
+ #include "Props.h"
15
+ #include "States.h"
16
+ #include <react/renderer/attributedstring/AttributedString.h>
17
+ #include <react/renderer/components/iostextinput/TextInputState.h>
18
+ #include <react/renderer/components/text/BaseTextShadowNode.h>
19
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
20
+ #include <react/renderer/textlayoutmanager/TextLayoutManager.h>
21
+ #include <react/utils/ContextContainer.h>
22
+ #include <jsi/jsi.h>
23
+
24
+ namespace facebook::react {
25
+
26
+ JSI_EXPORT extern const char PasteTextInputComponentName[];
27
+
28
+ /*
29
+ * `ShadowNode` for <PasteTextInput> component.
30
+ */
31
+ class PasteTextInputShadowNode final : public ConcreteViewShadowNode<
32
+ PasteTextInputComponentName,
33
+ PasteTextInputProps,
34
+ PasteTextInputEventEmitter,
35
+ TextInputState>,
36
+ public BaseTextShadowNode {
37
+ public:
38
+ using ConcreteViewShadowNode::ConcreteViewShadowNode;
39
+
40
+ static ShadowNodeTraits BaseTraits() {
41
+ auto traits = ConcreteViewShadowNode::BaseTraits();
42
+ traits.set(ShadowNodeTraits::Trait::LeafYogaNode);
43
+ traits.set(ShadowNodeTraits::Trait::MeasurableYogaNode);
44
+ return traits;
45
+ }
46
+
47
+ /*
48
+ * Associates a shared `TextLayoutManager` with the node.
49
+ * `TextInputShadowNode` uses the manager to measure text content
50
+ * and construct `TextInputState` objects.
51
+ */
52
+ void setTextLayoutManager(
53
+ std::shared_ptr<const TextLayoutManager> textLayoutManager);
54
+
55
+ #pragma mark - LayoutableShadowNode
56
+
57
+ Size measureContent(
58
+ const LayoutContext& layoutContext,
59
+ const LayoutConstraints& layoutConstraints) const override;
60
+ void layout(LayoutContext layoutContext) override;
61
+
62
+ private:
63
+ /*
64
+ * Creates a `State` object if needed.
65
+ */
66
+ void updateStateIfNeeded(const LayoutContext& layoutContext);
67
+
68
+ /*
69
+ * Returns a `AttributedString` which represents text content of the node.
70
+ */
71
+ AttributedString getAttributedString(
72
+ const LayoutContext& layoutContext) const;
73
+
74
+ /*
75
+ * Returns an `AttributedStringBox` which represents text content that should
76
+ * be used for measuring purposes. It might contain actual text value,
77
+ * placeholder value or some character that represents the size of the font.
78
+ */
79
+ AttributedStringBox attributedStringBoxToMeasure(
80
+ const LayoutContext& layoutContext) const;
81
+
82
+ std::shared_ptr<const TextLayoutManager> textLayoutManager_;
83
+ };
84
+
85
+ } // 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 "States.h"
11
+
12
+ namespace facebook::react {
13
+
14
+
15
+
16
+ } // namespace facebook::react
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <react/renderer/attributedstring/AttributedStringBox.h>
11
+ #include <react/renderer/attributedstring/ParagraphAttributes.h>
12
+ #include <react/renderer/textlayoutmanager/TextLayoutManager.h>
13
+
14
+ namespace facebook::react {
15
+
16
+ /*
17
+ * State for <TextInput> component.
18
+ */
19
+ class PasteTextInputState final {
20
+ public:
21
+ PasteTextInputState() = default;
22
+
23
+ /*
24
+ * All content of <TextInput> component.
25
+ */
26
+ AttributedStringBox attributedStringBox;
27
+
28
+ /*
29
+ * All content of <TextInput> component represented as an `AttributedString`.
30
+ * This stores the previous computed *from the React tree*. This usually
31
+ * doesn't change as the TextInput contents are being updated. If it does
32
+ * change, we need to wipe out current contents of the TextInput and replace
33
+ * with the new value from the tree.
34
+ */
35
+ AttributedString reactTreeAttributedString{};
36
+
37
+ /*
38
+ * Represents all visual attributes of a paragraph of text represented as
39
+ * a ParagraphAttributes.
40
+ */
41
+ ParagraphAttributes paragraphAttributes;
42
+
43
+ /*
44
+ * `TextLayoutManager` provides a connection to platform-specific
45
+ * text rendering infrastructure which is capable to render the
46
+ * `AttributedString`.
47
+ */
48
+ std::shared_ptr<const TextLayoutManager> layoutManager;
49
+
50
+ size_t mostRecentEventCount{0};
51
+ };
52
+
53
+ } // namespace facebook::react
@@ -0,0 +1,17 @@
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: GenerateModuleCpp.js
8
+ */
9
+
10
+ #include "PasteTextInputSpecsJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+
15
+
16
+
17
+ } // namespace facebook::react
@@ -0,0 +1,19 @@
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: GenerateModuleH.js
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include <ReactCommon/TurboModule.h>
13
+ #include <react/bridging/Bridging.h>
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+
19
+ } // namespace facebook::react