Expose ParagraphAttributes into ParagraphState
Summary: This diff extends ParagraphState to expose not only the AttributedString associated to Text components, but also ParagraphAttributes that describes the visual high level props of the Paragraph Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D18101407 fbshipit-source-id: 5f5d5ca35cc03e4bf983fd24654be9506d1901a1
This commit is contained in:
Родитель
34816f4d47
Коммит
13db6cb731
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "ParagraphShadowNode.h"
|
||||
#include <Glog/logging.h>
|
||||
#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
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <react/attributedstring/AttributedString.h>
|
||||
#include <react/attributedstring/ParagraphAttributes.h>
|
||||
#include <react/textlayoutmanager/TextLayoutManager.h>
|
||||
|
||||
#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");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче