Skip to main content

Overview

Formats

This module doesn't define any new formats.

Filters

rich_text

This filter adds support for rendering and validation of Drupal editor formats.

Supported types

  • object

$vars

default_format

The Drupal machine name of the default editor format for the field.

"$vars":{
"default_format":"format_1",
}
allowed_formats

An array of Drupal editor machine names allowed for the field.

"$vars":{
"allowed_formats":[
"format_1",
"format_2",
"format_3"
]
}

Widgets

This module doesn't define any new widgets.

Fields

rich_text

To use this field in the uiSchema set the field rich_text and add the rich_text $filter to your field's schema definition.

It is HIGHLY encouraged to make use of the allowed_formats value in the rich_text filter and that users have permission to use all the allowed formats. Without a list of allowed formats the field has to deal with a large amount of edge cases around users without permission to use a selected filter which it does currently handle but not with the best UX.

Examples

Rich text field

{
"schema":{
"type":"object",
"properties":{
"example":{
"title":"Example",
"description":"Example description",
"type":"object",
"properties":{
"format":{
"type":"string"
},
"value":{
"type":"string"
}
},
"$filters":{
"$func":"rich_text",
"$vars":{
"default_format":"format_1",
"allowed_formats":[
"format_1",
"format_2",
"format_3"
]
}
}
}
}
},
"uiSchema":{
"example":{
"ui:field":"rich_text"
}
}
}

Drupal functionality not implemented

  • Graceful handling of updating a form without permission to edit the rich_text filter selected. Current state the form shows an error message telling the user they lack permission to edit the field and if they try to submit the rest of the form the backend validation throws an error since the user can't submit data with the chosen format.
  • Summary field
  • Fallback format
  • Plain text? Not thoroughly tested, if you want a textarea without an editor use the RJSF textarea widget for that.