react-native-enriched 0.4.0 → 0.5.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 +27 -2
- package/ReactNativeEnriched.podspec +5 -1
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +12 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +4 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/EventEmitters.cpp +149 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/EventEmitters.h +146 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/Props.cpp +16 -1
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/Props.h +46 -0
- package/android/src/main/java/com/swmansion/enriched/common/GumboNormalizer.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedCheckboxListSpan.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedUnorderedListSpan.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt +166 -20
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewManager.kt +32 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/MeasurementStore.kt +19 -2
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnContextMenuItemPressEvent.kt +35 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedLineHeightSpan.kt +44 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt +19 -14
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParametrizedStyles.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpanState.kt +18 -12
- package/android/src/main/new_arch/CMakeLists.txt +9 -13
- package/android/src/main/new_arch/GumboNormalizerJni.cpp +14 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/conversions.h +2 -21
- package/cpp/CMakeLists.txt +50 -0
- package/cpp/GumboParser/GumboParser.h +34043 -0
- package/cpp/README.md +59 -0
- package/cpp/parser/GumboNormalizer.c +915 -0
- package/cpp/parser/GumboParser.cpp +16 -0
- package/cpp/parser/GumboParser.hpp +23 -0
- package/cpp/tests/GumboParserTest.cpp +457 -0
- package/ios/EnrichedTextInputView.h +2 -0
- package/ios/EnrichedTextInputView.mm +160 -2
- package/ios/config/InputConfig.h +3 -0
- package/ios/config/InputConfig.mm +15 -0
- package/ios/extensions/LayoutManagerExtension.mm +34 -11
- package/ios/generated/ReactNativeEnrichedSpec/EventEmitters.cpp +149 -0
- package/ios/generated/ReactNativeEnrichedSpec/EventEmitters.h +146 -0
- package/ios/generated/ReactNativeEnrichedSpec/Props.cpp +16 -1
- package/ios/generated/ReactNativeEnrichedSpec/Props.h +46 -0
- package/ios/generated/ReactNativeEnrichedSpec/RCTComponentViewHelpers.h +29 -0
- package/ios/inputParser/InputParser.mm +27 -0
- package/ios/interfaces/ImageAttachment.mm +29 -0
- package/lib/module/EnrichedTextInput.js +43 -30
- package/lib/module/EnrichedTextInput.js.map +1 -1
- package/lib/module/spec/EnrichedTextInputNativeComponent.ts +118 -22
- package/lib/typescript/src/EnrichedTextInput.d.ts +24 -6
- package/lib/typescript/src/EnrichedTextInput.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/spec/EnrichedTextInputNativeComponent.d.ts +111 -21
- package/lib/typescript/src/spec/EnrichedTextInputNativeComponent.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/EnrichedTextInput.tsx +79 -40
- package/src/index.tsx +0 -1
- package/src/spec/EnrichedTextInputNativeComponent.ts +118 -22
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#include "GumboParser.hpp"
|
|
2
|
+
#include <jni.h>
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
extern "C" JNIEXPORT jstring JNICALL
|
|
6
|
+
Java_com_swmansion_enriched_common_GumboNormalizer_normalizeHtml(
|
|
7
|
+
JNIEnv *env, jclass /*cls*/, jstring htmlJString) {
|
|
8
|
+
const char *htmlChars = env->GetStringUTFChars(htmlJString, nullptr);
|
|
9
|
+
std::string result = GumboParser::normalizeHtml(htmlChars);
|
|
10
|
+
env->ReleaseStringUTFChars(htmlJString, htmlChars);
|
|
11
|
+
if (result.empty())
|
|
12
|
+
return nullptr;
|
|
13
|
+
return env->NewStringUTF(result.c_str());
|
|
14
|
+
}
|
package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/conversions.h
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <folly/dynamic.h>
|
|
4
|
+
#include <react/renderer/components/FBReactNativeSpec/Props.h>
|
|
4
5
|
#include <react/renderer/components/ReactNativeEnrichedSpec/Props.h>
|
|
5
6
|
#include <react/renderer/core/propsConversions.h>
|
|
6
7
|
|
|
7
|
-
#if REACT_NATIVE_MINOR_VERSION >= 81
|
|
8
|
-
#include <react/renderer/components/FBReactNativeSpec/Props.h>
|
|
9
|
-
#else
|
|
10
|
-
#include <react/renderer/components/rncore/Props.h>
|
|
11
|
-
#endif
|
|
12
|
-
|
|
13
8
|
namespace facebook::react {
|
|
14
9
|
|
|
15
10
|
#ifdef RN_SERIALIZABLE_STATE
|
|
@@ -22,25 +17,11 @@ inline folly::dynamic toDynamic(const EnrichedTextInputViewProps &props) {
|
|
|
22
17
|
serializedProps["fontWeight"] = props.fontWeight;
|
|
23
18
|
serializedProps["fontStyle"] = props.fontStyle;
|
|
24
19
|
serializedProps["fontFamily"] = props.fontFamily;
|
|
20
|
+
serializedProps["lineHeight"] = props.lineHeight;
|
|
25
21
|
serializedProps["htmlStyle"] = toDynamic(props.htmlStyle);
|
|
26
22
|
|
|
27
23
|
return serializedProps;
|
|
28
24
|
}
|
|
29
|
-
#elif REACT_NATIVE_MINOR_VERSION >= 79
|
|
30
|
-
inline folly::dynamic toDynamic(const EnrichedTextInputViewProps &props) {
|
|
31
|
-
folly::dynamic serializedProps = folly::dynamic::object();
|
|
32
|
-
serializedProps["defaultValue"] = props.defaultValue;
|
|
33
|
-
serializedProps["placeholder"] = props.placeholder;
|
|
34
|
-
serializedProps["fontSize"] = props.fontSize;
|
|
35
|
-
serializedProps["fontWeight"] = props.fontWeight;
|
|
36
|
-
serializedProps["fontStyle"] = props.fontStyle;
|
|
37
|
-
serializedProps["fontFamily"] = props.fontFamily;
|
|
38
|
-
// Ideally we should also serialize htmlStyle, but toDynamic function is not
|
|
39
|
-
// generated in this RN version
|
|
40
|
-
// As RN 0.79 and 0.80 is no longer supported, we can skip it for now
|
|
41
|
-
|
|
42
|
-
return serializedProps;
|
|
43
|
-
}
|
|
44
25
|
#endif
|
|
45
26
|
|
|
46
27
|
} // namespace facebook::react
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.14)
|
|
2
|
+
project(gumbo_parser_tests C CXX)
|
|
3
|
+
|
|
4
|
+
# ── Fetch Google Test ────────────────────────────────────────────────────────
|
|
5
|
+
include(FetchContent)
|
|
6
|
+
FetchContent_Declare(
|
|
7
|
+
googletest
|
|
8
|
+
GIT_REPOSITORY https://github.com/google/googletest.git
|
|
9
|
+
GIT_TAG v1.17.0
|
|
10
|
+
)
|
|
11
|
+
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
|
12
|
+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
13
|
+
FetchContent_MakeAvailable(googletest)
|
|
14
|
+
|
|
15
|
+
# ── Shared library: gumbo normalizer + C++ wrapper ──────────────────────────
|
|
16
|
+
add_library(gumbo_normalizer_lib SHARED
|
|
17
|
+
parser/GumboNormalizer.c
|
|
18
|
+
parser/GumboParser.cpp
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
target_include_directories(gumbo_normalizer_lib PUBLIC
|
|
22
|
+
${CMAKE_CURRENT_SOURCE_DIR}/GumboParser
|
|
23
|
+
${CMAKE_CURRENT_SOURCE_DIR}/parser
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
# Compile the C file as C99, C++ files as C++17
|
|
27
|
+
set_source_files_properties(
|
|
28
|
+
parser/GumboNormalizer.c
|
|
29
|
+
PROPERTIES LANGUAGE C
|
|
30
|
+
COMPILE_FLAGS "-std=c99"
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
target_compile_options(gumbo_normalizer_lib PRIVATE
|
|
34
|
+
$<$<COMPILE_LANGUAGE:CXX>:-std=c++17>
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# ── Test executable ──────────────────────────────────────────────────────────
|
|
38
|
+
enable_testing()
|
|
39
|
+
|
|
40
|
+
add_executable(gumbo_parser_tests
|
|
41
|
+
tests/GumboParserTest.cpp
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
target_link_libraries(gumbo_parser_tests PRIVATE
|
|
45
|
+
gumbo_normalizer_lib
|
|
46
|
+
GTest::gtest_main
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
include(GoogleTest)
|
|
50
|
+
gtest_discover_tests(gumbo_parser_tests)
|