react-native-enriched 0.1.6 → 0.2.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/README.md +4 -14
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +4 -1
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +2 -1
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.cpp +10 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h +7 -0
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.h +0 -45
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt +111 -2
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +9 -3
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewPackage.kt +2 -0
- package/android/src/main/java/com/swmansion/enriched/events/MentionHandler.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/events/OnRequestHtmlResultEvent.kt +33 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBlockQuoteSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBoldSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedCodeBlockSpan.kt +42 -1
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH1Span.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH2Span.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH3Span.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedImageSpan.kt +135 -9
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedInlineCodeSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedItalicSpan.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedLinkSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedMentionSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedOrderedListSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedSpans.kt +13 -3
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedStrikeThroughSpan.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnderlineSpan.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnorderedListSpan.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/utils/ForceRedrawSpan.kt +13 -0
- package/android/src/main/java/com/swmansion/enriched/styles/HtmlStyle.kt +80 -9
- package/android/src/main/java/com/swmansion/enriched/styles/InlineStyles.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/styles/ParagraphStyles.kt +188 -5
- package/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt +57 -30
- package/android/src/main/java/com/swmansion/enriched/utils/AsyncDrawable.kt +91 -0
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedParser.java +24 -13
- package/android/src/main/java/com/swmansion/enriched/utils/ResourceManager.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedSpanWatcher.kt +3 -0
- package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.cpp +6 -6
- package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.h +6 -6
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputComponentDescriptor.h +19 -19
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.cpp +40 -51
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.h +13 -15
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.cpp +23 -21
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.h +35 -36
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.cpp +4 -4
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.h +13 -14
- package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/conversions.h +12 -13
- package/android/src/main/res/drawable/broken_image.xml +10 -0
- package/ios/EnrichedTextInputView.h +27 -12
- package/ios/EnrichedTextInputView.mm +906 -547
- package/ios/attachments/ImageAttachment.h +10 -0
- package/ios/attachments/ImageAttachment.mm +34 -0
- package/ios/attachments/MediaAttachment.h +23 -0
- package/ios/attachments/MediaAttachment.mm +31 -0
- package/ios/config/InputConfig.h +12 -6
- package/ios/config/InputConfig.mm +71 -33
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.cpp +10 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.h +7 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/Props.h +0 -45
- package/ios/generated/RNEnrichedTextInputViewSpec/RCTComponentViewHelpers.h +41 -4
- package/ios/inputParser/InputParser.h +5 -5
- package/ios/inputParser/InputParser.mm +867 -333
- package/ios/inputTextView/InputTextView.h +1 -1
- package/ios/inputTextView/InputTextView.mm +100 -59
- package/ios/internals/EnrichedTextInputViewComponentDescriptor.h +11 -9
- package/ios/internals/EnrichedTextInputViewShadowNode.h +28 -24
- package/ios/internals/EnrichedTextInputViewShadowNode.mm +64 -47
- package/ios/internals/EnrichedTextInputViewState.h +3 -1
- package/ios/styles/BlockQuoteStyle.mm +192 -142
- package/ios/styles/BoldStyle.mm +96 -62
- package/ios/styles/CodeBlockStyle.mm +304 -0
- package/ios/styles/H1Style.mm +10 -3
- package/ios/styles/H2Style.mm +10 -3
- package/ios/styles/H3Style.mm +10 -3
- package/ios/styles/HeadingStyleBase.mm +129 -84
- package/ios/styles/ImageStyle.mm +160 -0
- package/ios/styles/InlineCodeStyle.mm +149 -84
- package/ios/styles/ItalicStyle.mm +77 -51
- package/ios/styles/LinkStyle.mm +353 -224
- package/ios/styles/MentionStyle.mm +434 -220
- package/ios/styles/OrderedListStyle.mm +172 -105
- package/ios/styles/StrikethroughStyle.mm +53 -34
- package/ios/styles/UnderlineStyle.mm +69 -45
- package/ios/styles/UnorderedListStyle.mm +170 -105
- package/ios/utils/BaseStyleProtocol.h +3 -2
- package/ios/utils/ColorExtension.mm +7 -5
- package/ios/utils/FontExtension.mm +42 -27
- package/ios/utils/ImageData.h +10 -0
- package/ios/utils/ImageData.mm +4 -0
- package/ios/utils/LayoutManagerExtension.h +1 -1
- package/ios/utils/LayoutManagerExtension.mm +334 -109
- package/ios/utils/MentionParams.h +0 -1
- package/ios/utils/MentionStyleProps.h +1 -1
- package/ios/utils/MentionStyleProps.mm +27 -20
- package/ios/utils/OccurenceUtils.h +42 -38
- package/ios/utils/OccurenceUtils.mm +177 -107
- package/ios/utils/ParagraphAttributesUtils.h +6 -1
- package/ios/utils/ParagraphAttributesUtils.mm +152 -41
- package/ios/utils/ParagraphsUtils.h +2 -1
- package/ios/utils/ParagraphsUtils.mm +40 -26
- package/ios/utils/StringExtension.h +1 -1
- package/ios/utils/StringExtension.mm +19 -16
- package/ios/utils/StyleHeaders.h +35 -11
- package/ios/utils/TextInsertionUtils.h +13 -2
- package/ios/utils/TextInsertionUtils.mm +38 -20
- package/ios/utils/WordsUtils.h +2 -1
- package/ios/utils/WordsUtils.mm +32 -22
- package/ios/utils/ZeroWidthSpaceUtils.h +3 -1
- package/ios/utils/ZeroWidthSpaceUtils.mm +153 -75
- package/lib/module/EnrichedTextInput.js +41 -3
- package/lib/module/EnrichedTextInput.js.map +1 -1
- package/lib/module/EnrichedTextInputNativeComponent.ts +17 -5
- package/lib/module/normalizeHtmlStyle.js +0 -4
- package/lib/module/normalizeHtmlStyle.js.map +1 -1
- package/lib/typescript/src/EnrichedTextInput.d.ts +2 -5
- package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts +7 -5
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/normalizeHtmlStyle.d.ts.map +1 -1
- package/package.json +8 -1
- package/src/EnrichedTextInput.tsx +48 -7
- package/src/EnrichedTextInputNativeComponent.ts +17 -5
- package/src/normalizeHtmlStyle.ts +0 -4
|
@@ -8,28 +8,28 @@
|
|
|
8
8
|
namespace facebook::react {
|
|
9
9
|
|
|
10
10
|
class EnrichedTextInputComponentDescriptor final
|
|
11
|
-
|
|
11
|
+
: public ConcreteComponentDescriptor<EnrichedTextInputShadowNode> {
|
|
12
12
|
public:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
EnrichedTextInputComponentDescriptor(
|
|
14
|
+
const ComponentDescriptorParameters ¶meters)
|
|
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 =
|
|
23
|
+
static_cast<EnrichedTextInputShadowNode &>(shadowNode);
|
|
24
|
+
|
|
25
|
+
// `EnrichedTextInputShadowNode` uses
|
|
26
|
+
// `EnrichedTextInputMeasurementManager` to provide measurements to Yoga.
|
|
27
|
+
editorShadowNode.setMeasurementsManager(measurementsManager_);
|
|
28
|
+
}
|
|
28
29
|
|
|
29
30
|
private:
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const std::shared_ptr<EnrichedTextInputMeasurementManager>
|
|
32
|
+
measurementsManager_;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
} // namespace facebook::react
|
|
35
|
-
|
|
@@ -9,56 +9,45 @@ using namespace facebook::jni;
|
|
|
9
9
|
|
|
10
10
|
namespace facebook::react {
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
componentName.get(),
|
|
53
|
-
extraDataRM.get(),
|
|
54
|
-
propsRM.get(),
|
|
55
|
-
nullptr,
|
|
56
|
-
minimumSize.width,
|
|
57
|
-
maximumSize.width,
|
|
58
|
-
minimumSize.height,
|
|
59
|
-
maximumSize.height));
|
|
60
|
-
|
|
61
|
-
return measurement;
|
|
62
|
-
}
|
|
12
|
+
Size EnrichedTextInputMeasurementManager::measure(
|
|
13
|
+
SurfaceId surfaceId, int viewTag, 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 =
|
|
19
|
+
facebook::jni::findClassStatic(
|
|
20
|
+
"com/facebook/react/fabric/FabricUIManager")
|
|
21
|
+
->getMethod<jlong(jint, jstring, ReadableMap::javaobject,
|
|
22
|
+
ReadableMap::javaobject, ReadableMap::javaobject,
|
|
23
|
+
jfloat, jfloat, jfloat, jfloat)>("measure");
|
|
24
|
+
|
|
25
|
+
auto minimumSize = layoutConstraints.minimumSize;
|
|
26
|
+
auto maximumSize = layoutConstraints.maximumSize;
|
|
27
|
+
|
|
28
|
+
local_ref<JString> componentName = make_jstring("EnrichedTextInputView");
|
|
29
|
+
|
|
30
|
+
// Prepare extraData map with viewTag
|
|
31
|
+
folly::dynamic extraData = folly::dynamic::object();
|
|
32
|
+
extraData["viewTag"] = viewTag;
|
|
33
|
+
local_ref<ReadableNativeMap::javaobject> extraDataRNM =
|
|
34
|
+
ReadableNativeMap::newObjectCxxArgs(extraData);
|
|
35
|
+
local_ref<ReadableMap::javaobject> extraDataRM =
|
|
36
|
+
make_local(reinterpret_cast<ReadableMap::javaobject>(extraDataRNM.get()));
|
|
37
|
+
|
|
38
|
+
// Prepare layout metrics affecting props
|
|
39
|
+
auto serializedProps = toDynamic(props);
|
|
40
|
+
local_ref<ReadableNativeMap::javaobject> propsRNM =
|
|
41
|
+
ReadableNativeMap::newObjectCxxArgs(serializedProps);
|
|
42
|
+
local_ref<ReadableMap::javaobject> propsRM =
|
|
43
|
+
make_local(reinterpret_cast<ReadableMap::javaobject>(propsRNM.get()));
|
|
44
|
+
|
|
45
|
+
auto measurement = yogaMeassureToSize(
|
|
46
|
+
measure(fabricUIManager, surfaceId, componentName.get(),
|
|
47
|
+
extraDataRM.get(), propsRM.get(), nullptr, minimumSize.width,
|
|
48
|
+
maximumSize.width, minimumSize.height, maximumSize.height));
|
|
49
|
+
|
|
50
|
+
return measurement;
|
|
51
|
+
}
|
|
63
52
|
|
|
64
53
|
} // namespace facebook::react
|
|
@@ -2,26 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
#include "ComponentDescriptors.h"
|
|
4
4
|
|
|
5
|
-
#include <react/utils/ContextContainer.h>
|
|
6
|
-
#include <react/renderer/core/LayoutConstraints.h>
|
|
7
5
|
#include <react/renderer/components/RNEnrichedTextInputViewSpec/Props.h>
|
|
6
|
+
#include <react/renderer/core/LayoutConstraints.h>
|
|
7
|
+
#include <react/utils/ContextContainer.h>
|
|
8
8
|
|
|
9
9
|
namespace facebook::react {
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
class EnrichedTextInputMeasurementManager {
|
|
12
|
+
public:
|
|
13
|
+
EnrichedTextInputMeasurementManager(
|
|
14
|
+
const std::shared_ptr<const ContextContainer> &contextContainer)
|
|
15
|
+
: contextContainer_(contextContainer) {}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const EnrichedTextInputViewProps& props,
|
|
21
|
-
LayoutConstraints layoutConstraints) const;
|
|
17
|
+
Size measure(SurfaceId surfaceId, int viewTag,
|
|
18
|
+
const EnrichedTextInputViewProps &props,
|
|
19
|
+
LayoutConstraints layoutConstraints) const;
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
private:
|
|
22
|
+
const std::shared_ptr<const ContextContainer> contextContainer_;
|
|
23
|
+
};
|
|
26
24
|
|
|
27
25
|
} // namespace facebook::react
|
|
@@ -4,30 +4,32 @@
|
|
|
4
4
|
|
|
5
5
|
namespace facebook::react {
|
|
6
6
|
extern const char EnrichedTextInputComponentName[] = "EnrichedTextInputView";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
void EnrichedTextInputShadowNode::setMeasurementsManager(
|
|
8
|
+
const std::shared_ptr<EnrichedTextInputMeasurementManager>
|
|
9
|
+
&measurementsManager) {
|
|
10
|
+
ensureUnsealed();
|
|
11
|
+
measurementsManager_ = measurementsManager;
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
// Mark layout as dirty after state has been updated
|
|
15
|
+
// Once layout is marked as dirty, `measureContent` will be called in order to
|
|
16
|
+
// recalculate layout
|
|
17
|
+
void EnrichedTextInputShadowNode::dirtyLayoutIfNeeded() {
|
|
18
|
+
const auto state = this->getStateData();
|
|
19
|
+
const auto counter = state.getForceHeightRecalculationCounter();
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
if (forceHeightRecalculationCounter_ != counter) {
|
|
22
|
+
forceHeightRecalculationCounter_ = counter;
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
dirtyLayout();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
Size EnrichedTextInputShadowNode::measureContent(
|
|
29
|
+
const LayoutContext &layoutContext,
|
|
30
|
+
const LayoutConstraints &layoutConstraints) const {
|
|
31
|
+
return measurementsManager_->measure(getSurfaceId(), getTag(),
|
|
32
|
+
getConcreteProps(), layoutConstraints);
|
|
33
|
+
}
|
|
32
34
|
|
|
33
35
|
} // namespace facebook::react
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
#include "EnrichedTextInputMeasurementManager.h"
|
|
4
4
|
#include "EnrichedTextInputState.h"
|
|
5
5
|
|
|
6
|
-
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
7
|
-
#include <react/renderer/components/RNEnrichedTextInputViewSpec/Props.h>
|
|
8
6
|
#include <react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h>
|
|
7
|
+
#include <react/renderer/components/RNEnrichedTextInputViewSpec/Props.h>
|
|
8
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
9
9
|
|
|
10
10
|
namespace facebook::react {
|
|
11
11
|
|
|
@@ -13,42 +13,41 @@ JSI_EXPORT extern const char EnrichedTextInputComponentName[];
|
|
|
13
13
|
/*
|
|
14
14
|
* `ShadowNode` for <EnrichedTextInputView> component.
|
|
15
15
|
*/
|
|
16
|
-
class EnrichedTextInputShadowNode final
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
EnrichedTextInputState> {
|
|
16
|
+
class EnrichedTextInputShadowNode final
|
|
17
|
+
: public ConcreteViewShadowNode<
|
|
18
|
+
EnrichedTextInputComponentName, EnrichedTextInputViewProps,
|
|
19
|
+
EnrichedTextInputViewEventEmitter, EnrichedTextInputState> {
|
|
21
20
|
public:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
21
|
+
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
|
22
|
+
|
|
23
|
+
// This constructor is called when we "update" shadow node, e.g. after
|
|
24
|
+
// updating shadow node's state
|
|
25
|
+
EnrichedTextInputShadowNode(ShadowNode const &sourceShadowNode,
|
|
26
|
+
ShadowNodeFragment const &fragment)
|
|
27
|
+
: ConcreteViewShadowNode(sourceShadowNode, fragment) {
|
|
28
|
+
dirtyLayoutIfNeeded();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static ShadowNodeTraits BaseTraits() {
|
|
32
|
+
auto traits = ConcreteViewShadowNode::BaseTraits();
|
|
33
|
+
traits.set(ShadowNodeTraits::Trait::LeafYogaNode);
|
|
34
|
+
traits.set(ShadowNodeTraits::Trait::MeasurableYogaNode);
|
|
35
|
+
return traits;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Associates a shared `EnrichedTextInputMeasurementManager` with the node.
|
|
39
|
+
void setMeasurementsManager(
|
|
40
|
+
const std::shared_ptr<EnrichedTextInputMeasurementManager>
|
|
41
|
+
&measurementsManager);
|
|
42
|
+
|
|
43
|
+
void dirtyLayoutIfNeeded();
|
|
44
|
+
|
|
45
|
+
Size
|
|
46
|
+
measureContent(const LayoutContext &layoutContext,
|
|
47
|
+
const LayoutConstraints &layoutConstraints) const override;
|
|
49
48
|
|
|
50
49
|
private:
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
int forceHeightRecalculationCounter_;
|
|
51
|
+
std::shared_ptr<EnrichedTextInputMeasurementManager> measurementsManager_;
|
|
53
52
|
};
|
|
54
53
|
} // namespace facebook::react
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
namespace facebook::react {
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
5
|
+
int EnrichedTextInputState::getForceHeightRecalculationCounter() const {
|
|
6
|
+
return forceHeightRecalculationCounter_;
|
|
9
7
|
}
|
|
8
|
+
|
|
9
|
+
} // namespace facebook::react
|
|
@@ -4,22 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
namespace facebook::react {
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
: forceHeightRecalculationCounter_(0) {}
|
|
7
|
+
class EnrichedTextInputState {
|
|
8
|
+
public:
|
|
9
|
+
EnrichedTextInputState() : forceHeightRecalculationCounter_(0) {}
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
// Used by Kotlin to set current text value
|
|
12
|
+
EnrichedTextInputState(EnrichedTextInputState const &previousState,
|
|
13
|
+
folly::dynamic data)
|
|
14
|
+
: forceHeightRecalculationCounter_(
|
|
15
|
+
(int)data["forceHeightRecalculationCounter"].getInt()){};
|
|
16
|
+
folly::dynamic getDynamic() const { return {}; };
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
int getForceHeightRecalculationCounter() const;
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
private:
|
|
21
|
+
const int forceHeightRecalculationCounter_{};
|
|
22
|
+
};
|
|
24
23
|
|
|
25
24
|
} // namespace facebook::react
|
|
@@ -2,25 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
#include <folly/dynamic.h>
|
|
4
4
|
#include <react/renderer/components/FBReactNativeSpec/Props.h>
|
|
5
|
-
#include <react/renderer/core/propsConversions.h>
|
|
6
5
|
#include <react/renderer/components/RNEnrichedTextInputViewSpec/Props.h>
|
|
6
|
+
#include <react/renderer/core/propsConversions.h>
|
|
7
7
|
|
|
8
8
|
namespace facebook::react {
|
|
9
9
|
|
|
10
10
|
#ifdef RN_SERIALIZABLE_STATE
|
|
11
|
-
inline folly::dynamic toDynamic(const EnrichedTextInputViewProps &props)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
serializedProps["htmlStyle"] = toDynamic(props.htmlStyle);
|
|
11
|
+
inline folly::dynamic toDynamic(const EnrichedTextInputViewProps &props) {
|
|
12
|
+
// Serialize only metrics affecting props
|
|
13
|
+
folly::dynamic serializedProps = folly::dynamic::object();
|
|
14
|
+
serializedProps["defaultValue"] = props.defaultValue;
|
|
15
|
+
serializedProps["placeholder"] = props.placeholder;
|
|
16
|
+
serializedProps["fontSize"] = props.fontSize;
|
|
17
|
+
serializedProps["fontWeight"] = props.fontWeight;
|
|
18
|
+
serializedProps["fontStyle"] = props.fontStyle;
|
|
19
|
+
serializedProps["fontFamily"] = props.fontFamily;
|
|
20
|
+
serializedProps["htmlStyle"] = toDynamic(props.htmlStyle);
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
return serializedProps;
|
|
24
23
|
}
|
|
25
24
|
#endif
|
|
26
25
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
android:width="24dp"
|
|
3
|
+
android:height="24dp"
|
|
4
|
+
android:viewportWidth="960"
|
|
5
|
+
android:viewportHeight="960"
|
|
6
|
+
android:tint="?attr/colorControlNormal">
|
|
7
|
+
<path
|
|
8
|
+
android:fillColor="@android:color/white"
|
|
9
|
+
android:pathData="M200,840Q167,840 143.5,816.5Q120,793 120,760L120,200Q120,167 143.5,143.5Q167,120 200,120L760,120Q793,120 816.5,143.5Q840,167 840,200L840,760Q840,793 816.5,816.5Q793,840 760,840L200,840ZM240,503L400,343L560,503L720,343L760,383L760,200Q760,200 760,200Q760,200 760,200L200,200Q200,200 200,200Q200,200 200,200L200,463L240,503ZM200,760L760,760Q760,760 760,760Q760,760 760,760L760,496L720,456L560,616L400,456L240,616L200,576L200,760Q200,760 200,760Q200,760 200,760ZM200,760L200,760Q200,760 200,760Q200,760 200,760L200,496L200,576L200,463L200,383L200,200Q200,200 200,200Q200,200 200,200L200,200Q200,200 200,200Q200,200 200,200L200,463L200,463L200,576L200,576L200,760Q200,760 200,760Q200,760 200,760Z"/>
|
|
10
|
+
</vector>
|
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
#pragma once
|
|
2
|
-
#import
|
|
3
|
-
#import <UIKit/UIKit.h>
|
|
2
|
+
#import "BaseStyleProtocol.h"
|
|
4
3
|
#import "InputConfig.h"
|
|
5
4
|
#import "InputParser.h"
|
|
6
|
-
#import "BaseStyleProtocol.h"
|
|
7
5
|
#import "InputTextView.h"
|
|
6
|
+
#import "MediaAttachment.h"
|
|
7
|
+
#import <React/RCTViewComponentView.h>
|
|
8
|
+
#import <UIKit/UIKit.h>
|
|
8
9
|
|
|
9
10
|
#ifndef EnrichedTextInputViewNativeComponent_h
|
|
10
11
|
#define EnrichedTextInputViewNativeComponent_h
|
|
11
12
|
|
|
12
13
|
NS_ASSUME_NONNULL_BEGIN
|
|
13
14
|
|
|
14
|
-
@interface EnrichedTextInputView
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
@interface EnrichedTextInputView
|
|
16
|
+
: RCTViewComponentView <MediaAttachmentDelegate> {
|
|
17
|
+
@public
|
|
18
|
+
InputTextView *textView;
|
|
19
|
+
@public
|
|
20
|
+
NSRange recentlyChangedRange;
|
|
21
|
+
@public
|
|
22
|
+
InputConfig *config;
|
|
23
|
+
@public
|
|
24
|
+
InputParser *parser;
|
|
25
|
+
@public
|
|
26
|
+
NSMutableDictionary<NSAttributedStringKey, id> *defaultTypingAttributes;
|
|
27
|
+
@public
|
|
28
|
+
NSDictionary<NSNumber *, id<BaseStyleProtocol>> *stylesDict;
|
|
29
|
+
NSDictionary<NSNumber *, NSArray<NSNumber *> *> *conflictingStyles;
|
|
30
|
+
NSDictionary<NSNumber *, NSArray<NSNumber *> *> *blockingStyles;
|
|
31
|
+
@public
|
|
32
|
+
BOOL blockEmitting;
|
|
22
33
|
}
|
|
23
34
|
- (CGSize)measureSize:(CGFloat)maxWidth;
|
|
24
|
-
- (void)emitOnLinkDetectedEvent:(NSString *)text
|
|
35
|
+
- (void)emitOnLinkDetectedEvent:(NSString *)text
|
|
36
|
+
url:(NSString *)url
|
|
37
|
+
range:(NSRange)range;
|
|
25
38
|
- (void)emitOnMentionEvent:(NSString *)indicator text:(nullable NSString *)text;
|
|
26
39
|
- (void)anyTextMayHaveBeenModified;
|
|
27
40
|
- (BOOL)handleStyleBlocksAndConflicts:(StyleType)type range:(NSRange)range;
|
|
41
|
+
- (NSArray<NSNumber *> *)getPresentStyleTypesFrom:(NSArray<NSNumber *> *)types
|
|
42
|
+
range:(NSRange)range;
|
|
28
43
|
@end
|
|
29
44
|
|
|
30
45
|
NS_ASSUME_NONNULL_END
|