react-native-enriched 0.0.0 → 0.1.1
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 +20 -0
- package/README.md +875 -0
- package/ReactNativeEnriched.podspec +27 -0
- package/android/build.gradle +101 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +146 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +55 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.cpp +118 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h +95 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.cpp +128 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.h +577 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/ShadowNodes.h +23 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/States.h +20 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt +535 -0
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewLayoutManager.kt +64 -0
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +292 -0
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewPackage.kt +19 -0
- package/android/src/main/java/com/swmansion/enriched/events/MentionHandler.kt +40 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeHtmlEvent.kt +28 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeSelectionEvent.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeStateEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnChangeTextEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnInputBlurEvent.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnInputFocusEvent.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnLinkDetectedEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnMentionDetectedEvent.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/events/OnMentionEvent.kt +33 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBlockQuoteSpan.kt +34 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBoldSpan.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedCodeBlockSpan.kt +38 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH1Span.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH2Span.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH3Span.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedImageSpan.kt +41 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedInlineCodeSpan.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedItalicSpan.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedLinkSpan.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedMentionSpan.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedOrderedListSpan.kt +71 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedSpans.kt +111 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedStrikeThroughSpan.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnderlineSpan.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnorderedListSpan.kt +49 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedBlockSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedHeadingSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedInlineSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedParagraphSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedZeroWidthSpaceSpan.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/styles/HtmlStyle.kt +227 -0
- package/android/src/main/java/com/swmansion/enriched/styles/InlineStyles.kt +146 -0
- package/android/src/main/java/com/swmansion/enriched/styles/ListStyles.kt +173 -0
- package/android/src/main/java/com/swmansion/enriched/styles/ParagraphStyles.kt +186 -0
- package/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt +223 -0
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedParser.java +857 -0
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSelection.kt +285 -0
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedSpanState.kt +204 -0
- package/android/src/main/java/com/swmansion/enriched/utils/Utils.kt +91 -0
- package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedSpanWatcher.kt +73 -0
- package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedTextWatcher.kt +51 -0
- package/android/src/main/new_arch/CMakeLists.txt +56 -0
- package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.cpp +22 -0
- package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.h +26 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputComponentDescriptor.h +35 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.cpp +51 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.h +26 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.cpp +34 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.h +54 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.cpp +9 -0
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.h +25 -0
- package/ios/EnrichedTextInputView.h +33 -0
- package/ios/EnrichedTextInputView.mm +1190 -0
- package/ios/EnrichedTextInputViewManager.mm +13 -0
- package/ios/config/InputConfig.h +67 -0
- package/ios/config/InputConfig.mm +382 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.cpp +118 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.h +95 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/Props.cpp +128 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/Props.h +577 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/RCTComponentViewHelpers.h +384 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/ShadowNodes.h +23 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/States.cpp +16 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/States.h +20 -0
- package/ios/inputParser/InputParser.h +11 -0
- package/ios/inputParser/InputParser.mm +659 -0
- package/ios/inputTextView/InputTextView.h +6 -0
- package/ios/inputTextView/InputTextView.mm +115 -0
- package/ios/internals/EnrichedTextInputViewComponentDescriptor.h +17 -0
- package/ios/internals/EnrichedTextInputViewShadowNode.h +40 -0
- package/ios/internals/EnrichedTextInputViewShadowNode.mm +83 -0
- package/ios/internals/EnrichedTextInputViewState.cpp +10 -0
- package/ios/internals/EnrichedTextInputViewState.h +20 -0
- package/ios/styles/BlockQuoteStyle.mm +248 -0
- package/ios/styles/BoldStyle.mm +122 -0
- package/ios/styles/H1Style.mm +10 -0
- package/ios/styles/H2Style.mm +10 -0
- package/ios/styles/H3Style.mm +10 -0
- package/ios/styles/HeadingStyleBase.mm +144 -0
- package/ios/styles/InlineCodeStyle.mm +163 -0
- package/ios/styles/ItalicStyle.mm +110 -0
- package/ios/styles/LinkStyle.mm +463 -0
- package/ios/styles/MentionStyle.mm +476 -0
- package/ios/styles/OrderedListStyle.mm +225 -0
- package/ios/styles/StrikethroughStyle.mm +80 -0
- package/ios/styles/UnderlineStyle.mm +112 -0
- package/ios/styles/UnorderedListStyle.mm +225 -0
- package/ios/utils/BaseStyleProtocol.h +16 -0
- package/ios/utils/ColorExtension.h +6 -0
- package/ios/utils/ColorExtension.mm +27 -0
- package/ios/utils/FontExtension.h +13 -0
- package/ios/utils/FontExtension.mm +91 -0
- package/ios/utils/LayoutManagerExtension.h +6 -0
- package/ios/utils/LayoutManagerExtension.mm +171 -0
- package/ios/utils/LinkData.h +9 -0
- package/ios/utils/LinkData.mm +4 -0
- package/ios/utils/MentionParams.h +9 -0
- package/ios/utils/MentionParams.mm +4 -0
- package/ios/utils/MentionStyleProps.h +13 -0
- package/ios/utils/MentionStyleProps.mm +56 -0
- package/ios/utils/OccurenceUtils.h +37 -0
- package/ios/utils/OccurenceUtils.mm +124 -0
- package/ios/utils/ParagraphsUtils.h +7 -0
- package/ios/utils/ParagraphsUtils.mm +54 -0
- package/ios/utils/StringExtension.h +15 -0
- package/ios/utils/StringExtension.mm +57 -0
- package/ios/utils/StyleHeaders.h +74 -0
- package/ios/utils/StylePair.h +9 -0
- package/ios/utils/StylePair.mm +4 -0
- package/ios/utils/StyleTypeEnum.h +22 -0
- package/ios/utils/TextDecorationLineEnum.h +6 -0
- package/ios/utils/TextDecorationLineEnum.mm +4 -0
- package/ios/utils/TextInsertionUtils.h +6 -0
- package/ios/utils/TextInsertionUtils.mm +48 -0
- package/ios/utils/WordsUtils.h +6 -0
- package/ios/utils/WordsUtils.mm +88 -0
- package/ios/utils/ZeroWidthSpaceUtils.h +7 -0
- package/ios/utils/ZeroWidthSpaceUtils.mm +164 -0
- package/lib/module/EnrichedTextInput.js +191 -0
- package/lib/module/EnrichedTextInput.js.map +1 -0
- package/lib/module/EnrichedTextInputNativeComponent.ts +235 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/normalizeHtmlStyle.js +141 -0
- package/lib/module/normalizeHtmlStyle.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/EnrichedTextInput.d.ts +113 -0
- package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -0
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts +160 -0
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/normalizeHtmlStyle.d.ts +4 -0
- package/lib/typescript/src/normalizeHtmlStyle.d.ts.map +1 -0
- package/package.json +172 -1
- package/react-native.config.js +13 -0
- package/src/EnrichedTextInput.tsx +358 -0
- package/src/EnrichedTextInputNativeComponent.ts +235 -0
- package/src/index.tsx +9 -0
- 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 ¶ms) {
|
|
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 ¶ms);
|
|
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,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 */
|