react-native-enriched 0.0.0 → 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.
Files changed (169) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +869 -0
  3. package/ReactNativeEnriched.podspec +27 -0
  4. package/android/build.gradle +101 -0
  5. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +146 -0
  6. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +55 -0
  7. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/ComponentDescriptors.cpp +22 -0
  8. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/ComponentDescriptors.h +24 -0
  9. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.cpp +118 -0
  10. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h +95 -0
  11. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.cpp +128 -0
  12. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.h +577 -0
  13. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/ShadowNodes.cpp +17 -0
  14. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/ShadowNodes.h +23 -0
  15. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/States.cpp +16 -0
  16. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/States.h +20 -0
  17. package/android/gradle.properties +5 -0
  18. package/android/src/main/AndroidManifest.xml +3 -0
  19. package/android/src/main/AndroidManifestNew.xml +2 -0
  20. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt +535 -0
  21. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewLayoutManager.kt +64 -0
  22. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +292 -0
  23. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewPackage.kt +19 -0
  24. package/android/src/main/java/com/swmansion/enriched/events/MentionHandler.kt +40 -0
  25. package/android/src/main/java/com/swmansion/enriched/events/OnChangeHtmlEvent.kt +28 -0
  26. package/android/src/main/java/com/swmansion/enriched/events/OnChangeSelectionEvent.kt +29 -0
  27. package/android/src/main/java/com/swmansion/enriched/events/OnChangeStateEvent.kt +24 -0
  28. package/android/src/main/java/com/swmansion/enriched/events/OnChangeTextEvent.kt +30 -0
  29. package/android/src/main/java/com/swmansion/enriched/events/OnInputBlurEvent.kt +27 -0
  30. package/android/src/main/java/com/swmansion/enriched/events/OnInputFocusEvent.kt +27 -0
  31. package/android/src/main/java/com/swmansion/enriched/events/OnLinkDetectedEvent.kt +30 -0
  32. package/android/src/main/java/com/swmansion/enriched/events/OnMentionDetectedEvent.kt +29 -0
  33. package/android/src/main/java/com/swmansion/enriched/events/OnMentionEvent.kt +33 -0
  34. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBlockQuoteSpan.kt +34 -0
  35. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBoldSpan.kt +10 -0
  36. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedCodeBlockSpan.kt +38 -0
  37. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH1Span.kt +17 -0
  38. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH2Span.kt +17 -0
  39. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH3Span.kt +17 -0
  40. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedImageSpan.kt +41 -0
  41. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedInlineCodeSpan.kt +16 -0
  42. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedItalicSpan.kt +10 -0
  43. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedLinkSpan.kt +24 -0
  44. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedMentionSpan.kt +36 -0
  45. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedOrderedListSpan.kt +71 -0
  46. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedSpans.kt +111 -0
  47. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedStrikeThroughSpan.kt +9 -0
  48. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnderlineSpan.kt +9 -0
  49. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnorderedListSpan.kt +49 -0
  50. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedBlockSpan.kt +4 -0
  51. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedHeadingSpan.kt +4 -0
  52. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedInlineSpan.kt +4 -0
  53. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedParagraphSpan.kt +4 -0
  54. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedSpan.kt +4 -0
  55. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedZeroWidthSpaceSpan.kt +5 -0
  56. package/android/src/main/java/com/swmansion/enriched/styles/HtmlStyle.kt +227 -0
  57. package/android/src/main/java/com/swmansion/enriched/styles/InlineStyles.kt +146 -0
  58. package/android/src/main/java/com/swmansion/enriched/styles/ListStyles.kt +173 -0
  59. package/android/src/main/java/com/swmansion/enriched/styles/ParagraphStyles.kt +186 -0
  60. package/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt +223 -0
  61. package/android/src/main/java/com/swmansion/enriched/utils/EnrichedParser.java +857 -0
  62. package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSelection.kt +285 -0
  63. package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSpanState.kt +204 -0
  64. package/android/src/main/java/com/swmansion/enriched/utils/Utils.kt +91 -0
  65. package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedSpanWatcher.kt +73 -0
  66. package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedTextWatcher.kt +51 -0
  67. package/android/src/main/new_arch/CMakeLists.txt +56 -0
  68. package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.cpp +22 -0
  69. package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.h +26 -0
  70. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputComponentDescriptor.h +35 -0
  71. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.cpp +51 -0
  72. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.h +26 -0
  73. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.cpp +34 -0
  74. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.h +54 -0
  75. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.cpp +9 -0
  76. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.h +25 -0
  77. package/ios/EnrichedTextInputView.h +33 -0
  78. package/ios/EnrichedTextInputView.mm +1190 -0
  79. package/ios/EnrichedTextInputViewManager.mm +13 -0
  80. package/ios/config/InputConfig.h +67 -0
  81. package/ios/config/InputConfig.mm +382 -0
  82. package/ios/generated/RNEnrichedTextInputViewSpec/ComponentDescriptors.cpp +22 -0
  83. package/ios/generated/RNEnrichedTextInputViewSpec/ComponentDescriptors.h +24 -0
  84. package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.cpp +118 -0
  85. package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.h +95 -0
  86. package/ios/generated/RNEnrichedTextInputViewSpec/Props.cpp +128 -0
  87. package/ios/generated/RNEnrichedTextInputViewSpec/Props.h +577 -0
  88. package/ios/generated/RNEnrichedTextInputViewSpec/RCTComponentViewHelpers.h +384 -0
  89. package/ios/generated/RNEnrichedTextInputViewSpec/ShadowNodes.cpp +17 -0
  90. package/ios/generated/RNEnrichedTextInputViewSpec/ShadowNodes.h +23 -0
  91. package/ios/generated/RNEnrichedTextInputViewSpec/States.cpp +16 -0
  92. package/ios/generated/RNEnrichedTextInputViewSpec/States.h +20 -0
  93. package/ios/inputParser/InputParser.h +11 -0
  94. package/ios/inputParser/InputParser.mm +669 -0
  95. package/ios/inputTextView/InputTextView.h +6 -0
  96. package/ios/inputTextView/InputTextView.mm +115 -0
  97. package/ios/internals/EnrichedTextInputViewComponentDescriptor.h +17 -0
  98. package/ios/internals/EnrichedTextInputViewShadowNode.h +40 -0
  99. package/ios/internals/EnrichedTextInputViewShadowNode.mm +83 -0
  100. package/ios/internals/EnrichedTextInputViewState.cpp +10 -0
  101. package/ios/internals/EnrichedTextInputViewState.h +20 -0
  102. package/ios/styles/BlockQuoteStyle.mm +248 -0
  103. package/ios/styles/BoldStyle.mm +122 -0
  104. package/ios/styles/H1Style.mm +10 -0
  105. package/ios/styles/H2Style.mm +10 -0
  106. package/ios/styles/H3Style.mm +10 -0
  107. package/ios/styles/HeadingStyleBase.mm +144 -0
  108. package/ios/styles/InlineCodeStyle.mm +163 -0
  109. package/ios/styles/ItalicStyle.mm +110 -0
  110. package/ios/styles/LinkStyle.mm +463 -0
  111. package/ios/styles/MentionStyle.mm +476 -0
  112. package/ios/styles/OrderedListStyle.mm +225 -0
  113. package/ios/styles/StrikethroughStyle.mm +80 -0
  114. package/ios/styles/UnderlineStyle.mm +112 -0
  115. package/ios/styles/UnorderedListStyle.mm +225 -0
  116. package/ios/utils/BaseStyleProtocol.h +16 -0
  117. package/ios/utils/ColorExtension.h +6 -0
  118. package/ios/utils/ColorExtension.mm +27 -0
  119. package/ios/utils/FontExtension.h +13 -0
  120. package/ios/utils/FontExtension.mm +91 -0
  121. package/ios/utils/LayoutManagerExtension.h +6 -0
  122. package/ios/utils/LayoutManagerExtension.mm +171 -0
  123. package/ios/utils/LinkData.h +9 -0
  124. package/ios/utils/LinkData.mm +4 -0
  125. package/ios/utils/MentionParams.h +9 -0
  126. package/ios/utils/MentionParams.mm +4 -0
  127. package/ios/utils/MentionStyleProps.h +13 -0
  128. package/ios/utils/MentionStyleProps.mm +56 -0
  129. package/ios/utils/OccurenceUtils.h +37 -0
  130. package/ios/utils/OccurenceUtils.mm +124 -0
  131. package/ios/utils/ParagraphsUtils.h +7 -0
  132. package/ios/utils/ParagraphsUtils.mm +54 -0
  133. package/ios/utils/StringExtension.h +15 -0
  134. package/ios/utils/StringExtension.mm +57 -0
  135. package/ios/utils/StyleHeaders.h +74 -0
  136. package/ios/utils/StylePair.h +9 -0
  137. package/ios/utils/StylePair.mm +4 -0
  138. package/ios/utils/StyleTypeEnum.h +22 -0
  139. package/ios/utils/TextDecorationLineEnum.h +6 -0
  140. package/ios/utils/TextDecorationLineEnum.mm +4 -0
  141. package/ios/utils/TextInsertionUtils.h +6 -0
  142. package/ios/utils/TextInsertionUtils.mm +48 -0
  143. package/ios/utils/WordsUtils.h +6 -0
  144. package/ios/utils/WordsUtils.mm +88 -0
  145. package/ios/utils/ZeroWidthSpaceUtils.h +7 -0
  146. package/ios/utils/ZeroWidthSpaceUtils.mm +164 -0
  147. package/lib/module/EnrichedTextInput.js +191 -0
  148. package/lib/module/EnrichedTextInput.js.map +1 -0
  149. package/lib/module/EnrichedTextInputNativeComponent.ts +235 -0
  150. package/lib/module/index.js +4 -0
  151. package/lib/module/index.js.map +1 -0
  152. package/lib/module/normalizeHtmlStyle.js +141 -0
  153. package/lib/module/normalizeHtmlStyle.js.map +1 -0
  154. package/lib/module/package.json +1 -0
  155. package/lib/typescript/package.json +1 -0
  156. package/lib/typescript/src/EnrichedTextInput.d.ts +113 -0
  157. package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -0
  158. package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts +160 -0
  159. package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +1 -0
  160. package/lib/typescript/src/index.d.ts +3 -0
  161. package/lib/typescript/src/index.d.ts.map +1 -0
  162. package/lib/typescript/src/normalizeHtmlStyle.d.ts +4 -0
  163. package/lib/typescript/src/normalizeHtmlStyle.d.ts.map +1 -0
  164. package/package.json +172 -1
  165. package/react-native.config.js +13 -0
  166. package/src/EnrichedTextInput.tsx +358 -0
  167. package/src/EnrichedTextInputNativeComponent.ts +235 -0
  168. package/src/index.tsx +9 -0
  169. package/src/normalizeHtmlStyle.ts +188 -0
@@ -0,0 +1,56 @@
1
+ cmake_minimum_required(VERSION 3.13)
2
+ set(CMAKE_VERBOSE_MAKEFILE on)
3
+
4
+ set(LIB_LITERAL RNEnrichedTextInputViewSpec)
5
+ set(LIB_TARGET_NAME react_codegen_${LIB_LITERAL})
6
+
7
+ set(LIB_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
8
+ set(LIB_ANDROID_GENERATED_JNI_DIR ${LIB_ANDROID_DIR}/generated/jni)
9
+ set(LIB_ANDROID_GENERATED_COMPONENTS_DIR ${LIB_ANDROID_GENERATED_JNI_DIR}/react/renderer/components/${LIB_LITERAL})
10
+
11
+ file(GLOB LIB_MODULE_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/${LIB_LITERAL}/*.cpp)
12
+ file(GLOB LIB_CODEGEN_SRCS CONFIGURE_DEPENDS ${LIB_ANDROID_GENERATED_COMPONENTS_DIR}/*.cpp)
13
+
14
+ add_library(
15
+ ${LIB_TARGET_NAME}
16
+ SHARED
17
+ ${LIB_MODULE_SRCS}
18
+ ${LIB_CUSTOM_SRCS}
19
+ ${LIB_CODEGEN_SRCS}
20
+ )
21
+
22
+ target_include_directories(
23
+ ${LIB_TARGET_NAME}
24
+ PUBLIC
25
+ .
26
+ ./react/renderer/components/${LIB_LITERAL}
27
+ ${LIB_ANDROID_GENERATED_JNI_DIR}
28
+ ${LIB_ANDROID_GENERATED_COMPONENTS_DIR}
29
+ ${LIB_CPP_DIR}
30
+ )
31
+
32
+ find_package(fbjni REQUIRED CONFIG)
33
+ find_package(ReactAndroid REQUIRED CONFIG)
34
+
35
+ target_link_libraries(
36
+ ${LIB_TARGET_NAME}
37
+ fbjni::fbjni
38
+ ReactAndroid::jsi
39
+ ReactAndroid::reactnative
40
+ )
41
+
42
+ target_compile_options(
43
+ ${LIB_TARGET_NAME}
44
+ PRIVATE
45
+ -DLOG_TAG=\"ReactNative\"
46
+ -fexceptions
47
+ -frtti
48
+ -Wall
49
+ -std=c++20
50
+ )
51
+
52
+ target_include_directories(
53
+ ${CMAKE_PROJECT_NAME}
54
+ PUBLIC
55
+ ${CMAKE_CURRENT_SOURCE_DIR}
56
+ )
@@ -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: GenerateModuleJniCpp.js
9
+ */
10
+
11
+ #include "RNEnrichedTextInputViewSpec.h"
12
+
13
+ namespace facebook::react {
14
+
15
+
16
+
17
+ std::shared_ptr<TurboModule> RNEnrichedTextInputViewSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
18
+
19
+ return nullptr;
20
+ }
21
+
22
+ } // namespace facebook::react
@@ -0,0 +1,26 @@
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: GenerateModuleJniH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <ReactCommon/JavaTurboModule.h>
14
+ #include <ReactCommon/TurboModule.h>
15
+ #include <jsi/jsi.h>
16
+
17
+ #include <react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputComponentDescriptor.h>
18
+
19
+ namespace facebook::react {
20
+
21
+
22
+
23
+ JSI_EXPORT
24
+ std::shared_ptr<TurboModule> RNEnrichedTextInputViewSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
25
+
26
+ } // namespace facebook::react
@@ -0,0 +1,35 @@
1
+ #pragma once
2
+
3
+ #include "EnrichedTextInputMeasurementManager.h"
4
+ #include "EnrichedTextInputShadowNode.h"
5
+
6
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
7
+
8
+ namespace facebook::react {
9
+
10
+ class EnrichedTextInputComponentDescriptor final
11
+ : public ConcreteComponentDescriptor<EnrichedTextInputShadowNode> {
12
+ public:
13
+ EnrichedTextInputComponentDescriptor(
14
+ const ComponentDescriptorParameters& parameters)
15
+ : ConcreteComponentDescriptor(parameters),
16
+ measurementsManager_(
17
+ std::make_shared<EnrichedTextInputMeasurementManager>(
18
+ contextContainer_)) {}
19
+
20
+ void adopt(ShadowNode& shadowNode) const override {
21
+ ConcreteComponentDescriptor::adopt(shadowNode);
22
+ auto& editorShadowNode = static_cast<EnrichedTextInputShadowNode&>(shadowNode);
23
+
24
+ // `EnrichedTextInputShadowNode` uses
25
+ // `EnrichedTextInputMeasurementManager` to provide measurements to Yoga.
26
+ editorShadowNode.setMeasurementsManager(measurementsManager_);
27
+ }
28
+
29
+ private:
30
+ const std::shared_ptr<EnrichedTextInputMeasurementManager>
31
+ measurementsManager_;
32
+ };
33
+
34
+ } // namespace facebook::react
35
+
@@ -0,0 +1,51 @@
1
+ #include "EnrichedTextInputMeasurementManager.h"
2
+
3
+ #include <fbjni/fbjni.h>
4
+ #include <react/jni/ReadableNativeMap.h>
5
+ #include <react/renderer/core/conversions.h>
6
+
7
+ using namespace facebook::jni;
8
+
9
+ namespace facebook::react {
10
+
11
+ Size EnrichedTextInputMeasurementManager::measure(
12
+ SurfaceId surfaceId,
13
+ const EnrichedTextInputViewProps& props,
14
+ LayoutConstraints layoutConstraints) const {
15
+ const jni::global_ref<jobject>& fabricUIManager =
16
+ contextContainer_->at<jni::global_ref<jobject>>("FabricUIManager");
17
+
18
+ static const auto measure = facebook::jni::findClassStatic(
19
+ "com/facebook/react/fabric/FabricUIManager")
20
+ ->getMethod<jlong(
21
+ jint,
22
+ jstring,
23
+ ReadableMap::javaobject,
24
+ ReadableMap::javaobject,
25
+ ReadableMap::javaobject,
26
+ jfloat,
27
+ jfloat,
28
+ jfloat,
29
+ jfloat)>("measure");
30
+
31
+ auto minimumSize = layoutConstraints.minimumSize;
32
+ auto maximumSize = layoutConstraints.maximumSize;
33
+
34
+ local_ref<JString> componentName = make_jstring("EnrichedTextInputView");
35
+
36
+ auto measurement = yogaMeassureToSize(measure(
37
+ fabricUIManager,
38
+ surfaceId,
39
+ componentName.get(),
40
+ nullptr,
41
+ nullptr,
42
+ nullptr,
43
+ minimumSize.width,
44
+ maximumSize.width,
45
+ minimumSize.height,
46
+ maximumSize.height));
47
+
48
+ return measurement;
49
+ }
50
+
51
+ } // namespace facebook::react
@@ -0,0 +1,26 @@
1
+ #pragma once
2
+
3
+ #include "ComponentDescriptors.h"
4
+
5
+ #include <react/utils/ContextContainer.h>
6
+ #include <react/renderer/core/LayoutConstraints.h>
7
+ #include <react/renderer/components/RNEnrichedTextInputViewSpec/Props.h>
8
+
9
+ namespace facebook::react {
10
+
11
+ class EnrichedTextInputMeasurementManager {
12
+ public:
13
+ EnrichedTextInputMeasurementManager(
14
+ const ContextContainer::Shared& contextContainer)
15
+ : contextContainer_(contextContainer) {}
16
+
17
+ Size measure(
18
+ SurfaceId surfaceId,
19
+ const EnrichedTextInputViewProps& props,
20
+ LayoutConstraints layoutConstraints) const;
21
+
22
+ private:
23
+ const ContextContainer::Shared contextContainer_;
24
+ };
25
+
26
+ } // namespace facebook::react
@@ -0,0 +1,34 @@
1
+ #include "EnrichedTextInputShadowNode.h"
2
+
3
+ #include <react/renderer/core/LayoutContext.h>
4
+
5
+ namespace facebook::react {
6
+ extern const char EnrichedTextInputComponentName[] = "EnrichedTextInputView";
7
+ void EnrichedTextInputShadowNode::setMeasurementsManager(
8
+ const std::shared_ptr<EnrichedTextInputMeasurementManager>&
9
+ measurementsManager) {
10
+ ensureUnsealed();
11
+ measurementsManager_ = measurementsManager;
12
+ }
13
+
14
+ // Mark layout as dirty after state has been updated
15
+ // Once layout is marked as dirty, `measureContent` will be called in order to recalculate layout
16
+ void EnrichedTextInputShadowNode::dirtyLayoutIfNeeded() {
17
+ const auto state = this->getStateData();
18
+ const auto counter = state.getForceHeightRecalculationCounter();
19
+
20
+ if (forceHeightRecalculationCounter_ != counter) {
21
+ forceHeightRecalculationCounter_ = counter;
22
+
23
+ dirtyLayout();
24
+ }
25
+ }
26
+
27
+ Size EnrichedTextInputShadowNode::measureContent(
28
+ const LayoutContext &layoutContext,
29
+ const LayoutConstraints &layoutConstraints) const {
30
+
31
+ return measurementsManager_->measure(getSurfaceId(), getConcreteProps(), layoutConstraints);
32
+ }
33
+
34
+ } // namespace facebook::react
@@ -0,0 +1,54 @@
1
+ #pragma once
2
+
3
+ #include "EnrichedTextInputMeasurementManager.h"
4
+ #include "EnrichedTextInputState.h"
5
+
6
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
7
+ #include <react/renderer/components/RNEnrichedTextInputViewSpec/Props.h>
8
+ #include <react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h>
9
+
10
+ namespace facebook::react {
11
+
12
+ JSI_EXPORT extern const char EnrichedTextInputComponentName[];
13
+ /*
14
+ * `ShadowNode` for <EnrichedTextInputView> component.
15
+ */
16
+ class EnrichedTextInputShadowNode final : public ConcreteViewShadowNode<
17
+ EnrichedTextInputComponentName,
18
+ EnrichedTextInputViewProps,
19
+ EnrichedTextInputViewEventEmitter,
20
+ EnrichedTextInputState> {
21
+ public:
22
+ using ConcreteViewShadowNode::ConcreteViewShadowNode;
23
+
24
+ // This constructor is called when we "update" shadow node, e.g. after updating shadow node's state
25
+ EnrichedTextInputShadowNode(
26
+ ShadowNode const &sourceShadowNode,
27
+ ShadowNodeFragment const &fragment)
28
+ : ConcreteViewShadowNode(sourceShadowNode, fragment) {
29
+ dirtyLayoutIfNeeded();
30
+ }
31
+
32
+ static ShadowNodeTraits BaseTraits() {
33
+ auto traits = ConcreteViewShadowNode::BaseTraits();
34
+ traits.set(ShadowNodeTraits::Trait::LeafYogaNode);
35
+ traits.set(ShadowNodeTraits::Trait::MeasurableYogaNode);
36
+ return traits;
37
+ }
38
+
39
+ // Associates a shared `EnrichedTextInputMeasurementManager` with the node.
40
+ void setMeasurementsManager(
41
+ const std::shared_ptr<EnrichedTextInputMeasurementManager>&
42
+ measurementsManager);
43
+
44
+ void dirtyLayoutIfNeeded();
45
+
46
+ Size measureContent(
47
+ const LayoutContext& layoutContext,
48
+ const LayoutConstraints& layoutConstraints) const override;
49
+
50
+ private:
51
+ int forceHeightRecalculationCounter_;
52
+ std::shared_ptr<EnrichedTextInputMeasurementManager> measurementsManager_;
53
+ };
54
+ } // namespace facebook::react
@@ -0,0 +1,9 @@
1
+ #include "EnrichedTextInputState.h"
2
+
3
+ namespace facebook::react {
4
+
5
+ int EnrichedTextInputState::getForceHeightRecalculationCounter() const {
6
+ return forceHeightRecalculationCounter_;
7
+ }
8
+
9
+ }
@@ -0,0 +1,25 @@
1
+ #pragma once
2
+
3
+ #include <folly/dynamic.h>
4
+
5
+ namespace facebook::react {
6
+
7
+ class EnrichedTextInputState {
8
+ public:
9
+ EnrichedTextInputState()
10
+ : forceHeightRecalculationCounter_(0) {}
11
+
12
+ // Used by Kotlin to set current text value
13
+ EnrichedTextInputState(EnrichedTextInputState const &previousState, folly::dynamic data)
14
+ : forceHeightRecalculationCounter_((int)data["forceHeightRecalculationCounter"].getInt()){};
15
+ folly::dynamic getDynamic() const {
16
+ return {};
17
+ };
18
+
19
+ int getForceHeightRecalculationCounter() const;
20
+
21
+ private:
22
+ const int forceHeightRecalculationCounter_{};
23
+ };
24
+
25
+ } // namespace facebook::react
@@ -0,0 +1,33 @@
1
+ #pragma once
2
+ #import <React/RCTViewComponentView.h>
3
+ #import <UIKit/UIKit.h>
4
+ #import "InputConfig.h"
5
+ #import "InputParser.h"
6
+ #import "BaseStyleProtocol.h"
7
+ #import "InputTextView.h"
8
+
9
+ #ifndef EnrichedTextInputViewNativeComponent_h
10
+ #define EnrichedTextInputViewNativeComponent_h
11
+
12
+ NS_ASSUME_NONNULL_BEGIN
13
+
14
+ @interface EnrichedTextInputView : RCTViewComponentView {
15
+ @public InputTextView *textView;
16
+ @public NSRange recentlyChangedRange;
17
+ @public InputConfig *config;
18
+ @public InputParser *parser;
19
+ @public NSMutableDictionary<NSAttributedStringKey, id> *defaultTypingAttributes;
20
+ @public NSDictionary<NSNumber *, id<BaseStyleProtocol>> *stylesDict;
21
+ @public BOOL blockEmitting;
22
+ @public BOOL emitHtml;
23
+ }
24
+ - (CGSize)measureSize:(CGFloat)maxWidth;
25
+ - (void)emitOnLinkDetectedEvent:(NSString *)text url:(NSString *)url range:(NSRange)range;
26
+ - (void)emitOnMentionEvent:(NSString *)indicator text:(nullable NSString *)text;
27
+ - (void)anyTextMayHaveBeenModified;
28
+ - (BOOL)handleStyleBlocksAndConflicts:(StyleType)type range:(NSRange)range;
29
+ @end
30
+
31
+ NS_ASSUME_NONNULL_END
32
+
33
+ #endif /* EnrichedTextInputViewNativeComponent_h */