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.
Files changed (123) hide show
  1. package/README.md +4 -14
  2. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +4 -1
  3. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +2 -1
  4. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.cpp +10 -0
  5. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h +7 -0
  6. package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.h +0 -45
  7. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt +111 -2
  8. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +9 -3
  9. package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewPackage.kt +2 -0
  10. package/android/src/main/java/com/swmansion/enriched/events/MentionHandler.kt +1 -1
  11. package/android/src/main/java/com/swmansion/enriched/events/OnRequestHtmlResultEvent.kt +33 -0
  12. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBlockQuoteSpan.kt +6 -0
  13. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedBoldSpan.kt +6 -0
  14. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedCodeBlockSpan.kt +42 -1
  15. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH1Span.kt +6 -0
  16. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH2Span.kt +6 -0
  17. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedH3Span.kt +6 -0
  18. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedImageSpan.kt +135 -9
  19. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedInlineCodeSpan.kt +6 -0
  20. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedItalicSpan.kt +5 -0
  21. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedLinkSpan.kt +6 -0
  22. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedMentionSpan.kt +6 -0
  23. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedOrderedListSpan.kt +6 -0
  24. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedSpans.kt +13 -3
  25. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedStrikeThroughSpan.kt +5 -0
  26. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnderlineSpan.kt +5 -0
  27. package/android/src/main/java/com/swmansion/enriched/spans/EnrichedUnorderedListSpan.kt +6 -0
  28. package/android/src/main/java/com/swmansion/enriched/spans/interfaces/EnrichedSpan.kt +4 -0
  29. package/android/src/main/java/com/swmansion/enriched/spans/utils/ForceRedrawSpan.kt +13 -0
  30. package/android/src/main/java/com/swmansion/enriched/styles/HtmlStyle.kt +80 -9
  31. package/android/src/main/java/com/swmansion/enriched/styles/InlineStyles.kt +1 -0
  32. package/android/src/main/java/com/swmansion/enriched/styles/ParagraphStyles.kt +188 -5
  33. package/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt +57 -30
  34. package/android/src/main/java/com/swmansion/enriched/utils/AsyncDrawable.kt +91 -0
  35. package/android/src/main/java/com/swmansion/enriched/utils/EnrichedParser.java +24 -13
  36. package/android/src/main/java/com/swmansion/enriched/utils/ResourceManager.kt +26 -0
  37. package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedSpanWatcher.kt +3 -0
  38. package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.cpp +6 -6
  39. package/android/src/main/new_arch/RNEnrichedTextInputViewSpec.h +6 -6
  40. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputComponentDescriptor.h +19 -19
  41. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.cpp +40 -51
  42. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.h +13 -15
  43. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.cpp +23 -21
  44. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.h +35 -36
  45. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.cpp +4 -4
  46. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputState.h +13 -14
  47. package/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/conversions.h +12 -13
  48. package/android/src/main/res/drawable/broken_image.xml +10 -0
  49. package/ios/EnrichedTextInputView.h +27 -12
  50. package/ios/EnrichedTextInputView.mm +906 -547
  51. package/ios/attachments/ImageAttachment.h +10 -0
  52. package/ios/attachments/ImageAttachment.mm +34 -0
  53. package/ios/attachments/MediaAttachment.h +23 -0
  54. package/ios/attachments/MediaAttachment.mm +31 -0
  55. package/ios/config/InputConfig.h +12 -6
  56. package/ios/config/InputConfig.mm +71 -33
  57. package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.cpp +10 -0
  58. package/ios/generated/RNEnrichedTextInputViewSpec/EventEmitters.h +7 -0
  59. package/ios/generated/RNEnrichedTextInputViewSpec/Props.h +0 -45
  60. package/ios/generated/RNEnrichedTextInputViewSpec/RCTComponentViewHelpers.h +41 -4
  61. package/ios/inputParser/InputParser.h +5 -5
  62. package/ios/inputParser/InputParser.mm +867 -333
  63. package/ios/inputTextView/InputTextView.h +1 -1
  64. package/ios/inputTextView/InputTextView.mm +100 -59
  65. package/ios/internals/EnrichedTextInputViewComponentDescriptor.h +11 -9
  66. package/ios/internals/EnrichedTextInputViewShadowNode.h +28 -24
  67. package/ios/internals/EnrichedTextInputViewShadowNode.mm +64 -47
  68. package/ios/internals/EnrichedTextInputViewState.h +3 -1
  69. package/ios/styles/BlockQuoteStyle.mm +192 -142
  70. package/ios/styles/BoldStyle.mm +96 -62
  71. package/ios/styles/CodeBlockStyle.mm +304 -0
  72. package/ios/styles/H1Style.mm +10 -3
  73. package/ios/styles/H2Style.mm +10 -3
  74. package/ios/styles/H3Style.mm +10 -3
  75. package/ios/styles/HeadingStyleBase.mm +129 -84
  76. package/ios/styles/ImageStyle.mm +160 -0
  77. package/ios/styles/InlineCodeStyle.mm +149 -84
  78. package/ios/styles/ItalicStyle.mm +77 -51
  79. package/ios/styles/LinkStyle.mm +353 -224
  80. package/ios/styles/MentionStyle.mm +434 -220
  81. package/ios/styles/OrderedListStyle.mm +172 -105
  82. package/ios/styles/StrikethroughStyle.mm +53 -34
  83. package/ios/styles/UnderlineStyle.mm +69 -45
  84. package/ios/styles/UnorderedListStyle.mm +170 -105
  85. package/ios/utils/BaseStyleProtocol.h +3 -2
  86. package/ios/utils/ColorExtension.mm +7 -5
  87. package/ios/utils/FontExtension.mm +42 -27
  88. package/ios/utils/ImageData.h +10 -0
  89. package/ios/utils/ImageData.mm +4 -0
  90. package/ios/utils/LayoutManagerExtension.h +1 -1
  91. package/ios/utils/LayoutManagerExtension.mm +334 -109
  92. package/ios/utils/MentionParams.h +0 -1
  93. package/ios/utils/MentionStyleProps.h +1 -1
  94. package/ios/utils/MentionStyleProps.mm +27 -20
  95. package/ios/utils/OccurenceUtils.h +42 -38
  96. package/ios/utils/OccurenceUtils.mm +177 -107
  97. package/ios/utils/ParagraphAttributesUtils.h +6 -1
  98. package/ios/utils/ParagraphAttributesUtils.mm +152 -41
  99. package/ios/utils/ParagraphsUtils.h +2 -1
  100. package/ios/utils/ParagraphsUtils.mm +40 -26
  101. package/ios/utils/StringExtension.h +1 -1
  102. package/ios/utils/StringExtension.mm +19 -16
  103. package/ios/utils/StyleHeaders.h +35 -11
  104. package/ios/utils/TextInsertionUtils.h +13 -2
  105. package/ios/utils/TextInsertionUtils.mm +38 -20
  106. package/ios/utils/WordsUtils.h +2 -1
  107. package/ios/utils/WordsUtils.mm +32 -22
  108. package/ios/utils/ZeroWidthSpaceUtils.h +3 -1
  109. package/ios/utils/ZeroWidthSpaceUtils.mm +153 -75
  110. package/lib/module/EnrichedTextInput.js +41 -3
  111. package/lib/module/EnrichedTextInput.js.map +1 -1
  112. package/lib/module/EnrichedTextInputNativeComponent.ts +17 -5
  113. package/lib/module/normalizeHtmlStyle.js +0 -4
  114. package/lib/module/normalizeHtmlStyle.js.map +1 -1
  115. package/lib/typescript/src/EnrichedTextInput.d.ts +2 -5
  116. package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -1
  117. package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts +7 -5
  118. package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +1 -1
  119. package/lib/typescript/src/normalizeHtmlStyle.d.ts.map +1 -1
  120. package/package.json +8 -1
  121. package/src/EnrichedTextInput.tsx +48 -7
  122. package/src/EnrichedTextInputNativeComponent.ts +17 -5
  123. package/src/normalizeHtmlStyle.ts +0 -4
@@ -8,28 +8,28 @@
8
8
  namespace facebook::react {
9
9
 
10
10
  class EnrichedTextInputComponentDescriptor final
11
- : public ConcreteComponentDescriptor<EnrichedTextInputShadowNode> {
11
+ : public ConcreteComponentDescriptor<EnrichedTextInputShadowNode> {
12
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
- }
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 =
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
- const std::shared_ptr<EnrichedTextInputMeasurementManager>
31
- measurementsManager_;
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
- Size EnrichedTextInputMeasurementManager::measure(
13
- SurfaceId surfaceId,
14
- int viewTag,
15
- const EnrichedTextInputViewProps& props,
16
- LayoutConstraints layoutConstraints) const {
17
- const jni::global_ref<jobject>& fabricUIManager =
18
- contextContainer_->at<jni::global_ref<jobject>>("FabricUIManager");
19
-
20
- static const auto measure = facebook::jni::findClassStatic(
21
- "com/facebook/react/fabric/FabricUIManager")
22
- ->getMethod<jlong(
23
- jint,
24
- jstring,
25
- ReadableMap::javaobject,
26
- ReadableMap::javaobject,
27
- ReadableMap::javaobject,
28
- jfloat,
29
- jfloat,
30
- jfloat,
31
- jfloat)>("measure");
32
-
33
- auto minimumSize = layoutConstraints.minimumSize;
34
- auto maximumSize = layoutConstraints.maximumSize;
35
-
36
- local_ref<JString> componentName = make_jstring("EnrichedTextInputView");
37
-
38
- // Prepare extraData map with viewTag
39
- folly::dynamic extraData = folly::dynamic::object();
40
- extraData["viewTag"] = viewTag;
41
- local_ref<ReadableNativeMap::javaobject> extraDataRNM = ReadableNativeMap::newObjectCxxArgs(extraData);
42
- local_ref<ReadableMap::javaobject> extraDataRM = make_local(reinterpret_cast<ReadableMap::javaobject>(extraDataRNM.get()));
43
-
44
- // Prepare layout metrics affecting props
45
- auto serializedProps = toDynamic(props);
46
- local_ref<ReadableNativeMap::javaobject> propsRNM = ReadableNativeMap::newObjectCxxArgs(serializedProps);
47
- local_ref<ReadableMap::javaobject> propsRM = make_local(reinterpret_cast<ReadableMap::javaobject>(propsRNM.get()));
48
-
49
- auto measurement = yogaMeassureToSize(measure(
50
- fabricUIManager,
51
- surfaceId,
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
- class EnrichedTextInputMeasurementManager {
12
- public:
13
- EnrichedTextInputMeasurementManager(
14
- const std::shared_ptr<const ContextContainer>& contextContainer)
15
- : contextContainer_(contextContainer) {}
11
+ class EnrichedTextInputMeasurementManager {
12
+ public:
13
+ EnrichedTextInputMeasurementManager(
14
+ const std::shared_ptr<const ContextContainer> &contextContainer)
15
+ : contextContainer_(contextContainer) {}
16
16
 
17
- Size measure(
18
- SurfaceId surfaceId,
19
- int viewTag,
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
- private:
24
- const std::shared_ptr<const ContextContainer> contextContainer_;
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
- void EnrichedTextInputShadowNode::setMeasurementsManager(
8
- const std::shared_ptr<EnrichedTextInputMeasurementManager>&
9
- measurementsManager) {
10
- ensureUnsealed();
11
- measurementsManager_ = measurementsManager;
12
- }
7
+ void EnrichedTextInputShadowNode::setMeasurementsManager(
8
+ const std::shared_ptr<EnrichedTextInputMeasurementManager>
9
+ &measurementsManager) {
10
+ ensureUnsealed();
11
+ measurementsManager_ = measurementsManager;
12
+ }
13
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();
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
- if (forceHeightRecalculationCounter_ != counter) {
21
- forceHeightRecalculationCounter_ = counter;
21
+ if (forceHeightRecalculationCounter_ != counter) {
22
+ forceHeightRecalculationCounter_ = counter;
22
23
 
23
- dirtyLayout();
24
- }
25
- }
24
+ dirtyLayout();
25
+ }
26
+ }
26
27
 
27
- Size EnrichedTextInputShadowNode::measureContent(
28
- const LayoutContext &layoutContext,
29
- const LayoutConstraints &layoutConstraints) const {
30
- return measurementsManager_->measure(getSurfaceId(), getTag(), getConcreteProps(), layoutConstraints);
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 : public ConcreteViewShadowNode<
17
- EnrichedTextInputComponentName,
18
- EnrichedTextInputViewProps,
19
- EnrichedTextInputViewEventEmitter,
20
- EnrichedTextInputState> {
16
+ class EnrichedTextInputShadowNode final
17
+ : public ConcreteViewShadowNode<
18
+ EnrichedTextInputComponentName, EnrichedTextInputViewProps,
19
+ EnrichedTextInputViewEventEmitter, EnrichedTextInputState> {
21
20
  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;
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
- int forceHeightRecalculationCounter_;
52
- std::shared_ptr<EnrichedTextInputMeasurementManager> measurementsManager_;
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
- int EnrichedTextInputState::getForceHeightRecalculationCounter() const {
6
- return forceHeightRecalculationCounter_;
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
- class EnrichedTextInputState {
8
- public:
9
- EnrichedTextInputState()
10
- : forceHeightRecalculationCounter_(0) {}
7
+ class EnrichedTextInputState {
8
+ public:
9
+ EnrichedTextInputState() : forceHeightRecalculationCounter_(0) {}
11
10
 
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
- };
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
- int getForceHeightRecalculationCounter() const;
18
+ int getForceHeightRecalculationCounter() const;
20
19
 
21
- private:
22
- const int forceHeightRecalculationCounter_{};
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
- // Serialize only metrics affecting props
14
- folly::dynamic serializedProps = folly::dynamic::object();
15
- serializedProps["defaultValue"] = props.defaultValue;
16
- serializedProps["placeholder"] = props.placeholder;
17
- serializedProps["fontSize"] = props.fontSize;
18
- serializedProps["fontWeight"] = props.fontWeight;
19
- serializedProps["fontStyle"] = props.fontStyle;
20
- serializedProps["fontFamily"] = props.fontFamily;
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
- return serializedProps;
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 <React/RCTViewComponentView.h>
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 : 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;
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 url:(NSString *)url range:(NSRange)range;
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