diff --git a/docs/source/content/flows/flow_json.rst b/docs/source/content/flows/flow_json.rst index 9992619..ed892a4 100644 --- a/docs/source/content/flows/flow_json.rst +++ b/docs/source/content/flows/flow_json.rst @@ -25,6 +25,8 @@ Here you will find all the components that make up a Flow JSON object. .. autoclass:: TextCaption() +.. autoclass:: RichText() + .. autoclass:: FontWeight() .. autoclass:: TextInput() diff --git a/pywa/types/flows.py b/pywa/types/flows.py index 0573ee6..0e51ca2 100644 --- a/pywa/types/flows.py +++ b/pywa/types/flows.py @@ -54,6 +54,7 @@ "TextSubheading", "TextBody", "TextCaption", + "RichText", "FontWeight", "TextInput", "InputType", @@ -1479,7 +1480,7 @@ class TextHeading(TextComponent): >>> TextHeading(text='Heading', visible=True) Attributes: - text: The text of the heading. Limited to 4096 characters. Can be dynamic. + text: The text of the heading. Limited to 80 characters. Can be dynamic. visible: Whether the heading is visible or not. Default to ``True``, Can be dynamic. """ @@ -1502,7 +1503,7 @@ class TextSubheading(TextComponent): >>> TextSubheading(text='Subheading', visible=True) Attributes: - text: The text of the subheading. Limited to 60 characters. Can be dynamic. + text: The text of the subheading. Limited to 80 characters. Can be dynamic. visible: Whether the subheading is visible or not. Default to ``True``, Can be dynamic. """ @@ -1530,7 +1531,8 @@ class TextBody(TextComponent): ... ) Attributes: - text: The text of the body. Limited to 80 characters. Can be dynamic. + text: The text of the body. Limited to 4096 characters. Can be dynamic. + markdown: Whether the text is markdown or not (Added in v5.1). font_weight: The weight of the text. Can be dynamic. strikethrough: Whether the text is strikethrough or not. Can be dynamic. visible: Whether the body is visible or not. Default to ``True``, Can be dynamic. @@ -1539,8 +1541,8 @@ class TextBody(TextComponent): type: ComponentType = dataclasses.field( default=ComponentType.TEXT_BODY, init=False, repr=False ) - text: str | list[str] | DataKey | FormRef - markdown: bool | str | DataKey | FormRef | None = None + text: str | Iterable[str] | DataKey | FormRef + markdown: bool | None = None font_weight: FontWeight | str | DataKey | FormRef | None = None strikethrough: bool | str | DataKey | FormRef | None = None visible: bool | str | DataKey | FormRef | None = None @@ -1563,7 +1565,8 @@ class TextCaption(TextComponent): Attributes: - text: The text of the caption. Limited to 4096 characters. Can be dynamic. + text: The text of the caption (array of strings supported since v5.1). Limited to 4096 characters. Can be dynamic. + markdown: Whether the text is markdown or not (Added in v5.1). font_weight: The weight of the text. Can be dynamic. strikethrough: Whether to strike through the text or not. Can be dynamic. visible: Whether the caption is visible or not. Default to ``True``, Can be dynamic. @@ -1572,8 +1575,8 @@ class TextCaption(TextComponent): type: ComponentType = dataclasses.field( default=ComponentType.TEXT_CAPTION, init=False, repr=False ) - text: str | list[str] | DataKey | FormRef - markdown: bool | str | DataKey | FormRef | None = None + text: str | Iterable[str] | DataKey | FormRef + markdown: bool | None = None font_weight: FontWeight | str | DataKey | FormRef | None = None strikethrough: bool | str | DataKey | FormRef | None = None visible: bool | str | DataKey | FormRef | None = None @@ -1585,23 +1588,45 @@ class RichText(TextComponent): Represents text that is displayed as a rich text. - Read more at `developers.facebook.com `_. + - The goal of the component is to provide a rich formatting capabilities and introduce the way to render large texts (Terms of Condition, Policy Documents, User Agreement and etc) without facing limitations of basic text components (TextHeading, TextSubheading, TextBody and etc) + - RichText component utilizes a select subset of the Markdown specification. It adheres strictly to standard Markdown syntax without introducing any custom modifications. Content created for the RichText component is fully compatible with standard Markdown documents. + - Added in v5.1. Example: >>> RichText( - ... text=['**bold**'], + ... text=[ + ... "# Heading 1", + ... "## Heading 2", + ... "Let’s make a **bold** statement", + ... "Let's make this text *italic*", + ... "Let's make this text ~~Strikethrough~~", + ... "This text is ~~***really important***~~", + ... "This is a [pywa docs](https://pywa.readthedocs.io/)", + ... "This is a ordered list:", + ... "1. Item 1", + ... "2. Item 2", + ... "This is a unordered list:", + ... "- Item 1", + ... "- Item 2", + ... "![image](data:image/png;base64,)", + ... "| Tables | Are | Cool |", + ... "| ------------- | ------------- | ----- |", + ... "| col 3 is | right-aligned | $1600 |", + ... "| col 2 is | centered | $12 |", + ... ], ... ) Attributes: - text: + text: The markdown text (array of strings supported). Limited to 4096 characters. Can be dynamic. visible: Whether the caption is visible or not. Default to ``True``, Can be dynamic. """ type: ComponentType = dataclasses.field( default=ComponentType.RICH_TEXT, init=False, repr=False ) - text: str | list[str] | DataKey | FormRef + text: str | Iterable[str] | DataKey | FormRef visible: bool | str | DataKey | FormRef | None = None diff --git a/pywa_async/types/flows.py b/pywa_async/types/flows.py index 9d32adc..d4691f9 100644 --- a/pywa_async/types/flows.py +++ b/pywa_async/types/flows.py @@ -30,6 +30,7 @@ "TextSubheading", "TextBody", "TextCaption", + "RichText", "FontWeight", "TextInput", "InputType", @@ -51,9 +52,9 @@ "DataSource", "Action", "FlowActionType", + "FlowRequestActionType", "ActionNext", "ActionNextType", - "RichText" ] from pywa.types.flows import * # noqa MUST BE IMPORTED FIRST