#pragma once #include #include #include #include #include #include #include #include namespace facebook::react { extern const char T3MarkdownTextComponentName[]; struct T3MarkdownTextParagraphStyleRange { size_t location; size_t length; Float firstLineHeadIndent; Float headIndent; Float paragraphSpacing; }; struct T3MarkdownTextAttachmentRange { size_t location; size_t length; std::string imageUri; }; inline Float T3MarkdownTextAttachmentSize(const T3MarkdownTextAttachmentRange &) { return 14; } inline Float T3MarkdownTextAttachmentBaselineOffset( const T3MarkdownTextAttachmentRange &) { return -2; } class T3MarkdownTextStateReal final { public: AttributedString attributedString; std::vector paragraphStyleRanges; std::vector attachmentRanges; }; class T3MarkdownTextShadowNode final : public ConcreteViewShadowNode< T3MarkdownTextComponentName, T3MarkdownTextProps, T3MarkdownTextEventEmitter, T3MarkdownTextStateReal> { public: using ConcreteViewShadowNode::ConcreteViewShadowNode; T3MarkdownTextShadowNode( const ShadowNode& sourceShadowNode, const ShadowNodeFragment& fragment ); static ShadowNodeTraits BaseTraits() { auto traits = ConcreteViewShadowNode::BaseTraits(); traits.set(ShadowNodeTraits::Trait::LeafYogaNode); traits.set(ShadowNodeTraits::Trait::MeasurableYogaNode); return traits; } void layout(LayoutContext layoutContext) override; Size measureContent( const LayoutContext& layoutContext, const LayoutConstraints& layoutConstraints) const override; private: mutable AttributedString _attributedString; mutable std::vector _paragraphStyleRanges; mutable std::vector _attachmentRanges; }; } // namespace facebook::React