# Rich text input element

Allows users to enter formatted text in a WYSIWYG editor, much like the Repzo Chat composer.

| | |
|---|---|
| **Type** | `rich_text_input` |
| **Available in** | Modals, Home tab |
| **Works in blocks** | [Input block](https://workstation.repzo.com/docs/developers/block-kit/blocks/input-block) |

## Usage

Use the rich text input inside an [input block](https://workstation.repzo.com/docs/developers/block-kit/blocks/input-block). When the person submits the modal, your app receives the text as a [rich text block](https://workstation.repzo.com/docs/developers/block-kit/blocks/rich-text-block) under `view.state.values[block_id][action_id]`:

```json
{
  "type": "rich_text_input",
  "rich_text_value": {
    "type": "rich_text",
    "elements": [
      { "type": "rich_text_section", "elements": [{ "type": "text", "text": "Next steps", "style": { "bold": true } }] },
      { "type": "rich_text_list", "style": "bullet", "elements": [
        { "type": "rich_text_section", "elements": [{ "type": "text", "text": "Send the pilot agreement" }] }
      ] }
    ]
  }
}
```

A required rich text input must contain some non-blank text. With `dispatch_action: true` on the input block, the element also sends a `block_actions` payload with the same `rich_text_value` on ⌘/Ctrl+Enter, or as the person types, depending on `dispatch_action_config`.

The web editor offers bold, italic, strikethrough, inline code, links, bulleted and numbered lists, quotes and code blocks.

## Fields

| Field | Type | Description | Required? |
|---|---|---|---|
| `type` | String | The type of element. In this case `type` is always `rich_text_input`. | Required |
| `action_id` | String | An identifier for the input value when the parent view is submitted. You can use this when you receive a `view_submission` payload to identify the value of the input element (`view.state.values[block_id][action_id]`). Should be unique among all other `action_id`s in the containing block. Maximum length is 255 characters. If you leave it out, Repzo generates one. | Optional |
| `initial_value` | [Rich text block](https://workstation.repzo.com/docs/developers/block-kit/blocks/rich-text-block) | The initial value in the rich text input when it is loaded. | Optional |
| `dispatch_action_config` | [Dispatch action configuration object](https://workstation.repzo.com/docs/developers/block-kit/objects/dispatch-action-configuration-object) | A dispatch configuration object that determines when during text input the element returns a `block_actions` payload. Only used when the parent input block sets `dispatch_action: true`. Defaults to `on_enter_pressed`. | Optional |
| `focus_on_load` | Boolean | Indicates whether the element will be set to auto focus within the view. Only one element can be set to `true`. Defaults to `false`. | Optional |
| `placeholder` | [Text object](https://workstation.repzo.com/docs/developers/block-kit/objects/text-object) | A `plain_text` only text object that defines the placeholder text shown in the rich text input. Maximum length for the `text` in this field is 150 characters. | Optional |

> **How Repzo Chat differs from Slack**
>
> - In the mobile app the field is a plain multi-line text box. The value is still a `rich_text` block: paragraphs become sections and lines starting with `- ` or `1. ` become lists, with no other formatting.
> - Mentions and emoji pickers aren't available in the editor.
> - `min_lines` and `max_lines` aren't supported, and the element can't be used in table blocks.
> - Works in the Home tab as well as in modals.
> - In a message, an input block is shown as a disabled stand-in and the API returns a warning instead of refusing the message.
> - `focus_on_load` is applied on the web; the mobile app ignores it.

## Examples

### A rich text input in a form

This example belongs in a modal view — the screenshot shows it in a modal.

```json
{
  "blocks": [
    {
      "type": "input",
      "block_id": "meeting_notes",
      "label": {
        "type": "plain_text",
        "text": "Meeting notes"
      },
      "element": {
        "type": "rich_text_input",
        "action_id": "notes",
        "placeholder": {
          "type": "plain_text",
          "text": "Decisions, objections, next steps…"
        },
        "initial_value": {
          "type": "rich_text",
          "elements": [
            {
              "type": "rich_text_section",
              "elements": [
                {
                  "type": "text",
                  "text": "Next steps",
                  "style": {
                    "bold": true
                  }
                }
              ]
            },
            {
              "type": "rich_text_list",
              "style": "bullet",
              "elements": [
                {
                  "type": "rich_text_section",
                  "elements": [
                    {
                      "type": "text",
                      "text": "Send the pilot agreement"
                    }
                  ]
                }
              ]
            }
          ]
        }
      }
    }
  ]
}
```

## Related

- [Block elements](https://workstation.repzo.com/docs/developers/block-kit/elements)
- [Block Kit overview](https://workstation.repzo.com/docs/developers/block-kit)
