diff --git a/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.cpp b/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.cpp index ee02779f8b1..85f1f849c71 100644 --- a/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.cpp +++ b/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.cpp @@ -6,6 +6,7 @@ */ #include "ParagraphShadowNode.h" +#include #include "ParagraphMeasurementCache.h" #include "ParagraphState.h" @@ -54,7 +55,8 @@ void ParagraphShadowNode::updateStateIfNeeded() { return; } - setStateData(ParagraphState{attributedString, textLayoutManager_}); + setStateData(ParagraphState{ + attributedString, getProps()->paragraphAttributes, textLayoutManager_}); } #pragma mark - LayoutableShadowNode diff --git a/ReactCommon/fabric/components/text/paragraph/ParagraphState.h b/ReactCommon/fabric/components/text/paragraph/ParagraphState.h index cb9c4c4f1cc..e9726898abd 100644 --- a/ReactCommon/fabric/components/text/paragraph/ParagraphState.h +++ b/ReactCommon/fabric/components/text/paragraph/ParagraphState.h @@ -8,6 +8,7 @@ #pragma once #include +#include #include #ifdef ANDROID @@ -28,6 +29,12 @@ class ParagraphState final { */ AttributedString attributedString; + /* + * Represents all visual attributes of a paragraph of text represented as + * a ParagraphAttributes. + */ + ParagraphAttributes paragraphAttributes; + /* * `TextLayoutManager` provides a connection to platform-specific * text rendering infrastructure which is capable to render the @@ -38,8 +45,11 @@ class ParagraphState final { #ifdef ANDROID ParagraphState( AttributedString const &attributedString, + ParagraphAttributes const ¶graphAttributes, SharedTextLayoutManager const &layoutManager) - : attributedString(attributedString), layoutManager(layoutManager) {} + : attributedString(attributedString), + paragraphAttributes(paragraphAttributes), + layoutManager(layoutManager) {} ParagraphState() = default; ParagraphState(folly::dynamic const &data) { assert(false && "Not supported"); diff --git a/ReactCommon/fabric/components/text/paragraph/conversions.h b/ReactCommon/fabric/components/text/paragraph/conversions.h index 900cea332f7..9e1f2f1f918 100644 --- a/ReactCommon/fabric/components/text/paragraph/conversions.h +++ b/ReactCommon/fabric/components/text/paragraph/conversions.h @@ -16,6 +16,8 @@ namespace react { inline folly::dynamic toDynamic(ParagraphState const ¶graphState) { folly::dynamic newState = folly::dynamic::object(); newState["attributedString"] = toDynamic(paragraphState.attributedString); + newState["paragraphAttributes"] = + toDynamic(paragraphState.paragraphAttributes); newState["hash"] = newState["attributedString"]["hash"]; return newState; }