Drupal 9-10: Limit text formats available for WYSIWYG text inputs

If you’re looking to enhance the usability of your Drupal site by limiting the text formats available for each WYSIWYG text input based on page type, the “Allowed Formats” contrib module is the perfect solution:

Allowed Formats

https://www.drupal.org/project/allowed_formats

This module allows you to specify which text formats are available for each field instance, improving usability by hiding potentially confusing options like the text format selection, the “about text formats” link, and associated guidelines. You’ll find a set of checkboxes in the field settings (note: these are not in the widget settings on the form display tab) for text fields.

To add this module to your Drupal 9.x/10.0.x application, use the following Composer command:

composer require 'drupal/allowed_formats:^2.0'

To add this module to your Drupal 10.1.x application or higher, use the following Composer command:

composer require 'drupal/allowed_formats:^3.0'

To install this module to your Drupal application, execute the following Drush command:

drush en allowed_formats

I tested this module on my own Drupal site and found it significantly improved the editing experience. Before configuring the allowed text formats for a Basic Page, all text format options were visible, which could be overwhelming for users. After configuration, only the relevant formats were displayed, streamlining the editing process and reducing potential errors.

Basic Page before I configured the allowed text formats for this page type:

To configure the allowed text formats for this page type, I went to Structure/Content Types and clicked the “Manage Fields” button next to the Basic page page type:

Click the Edit button of the desired text field:

You will find a section called “Allowed format” where you can select the desired text formats for this text field:

I saved the changes and now when I create a new Basic page I see the following available text formats:

I hope you found this review helpful and that the “Allowed Formats” module significantly enhances the editing experience for your Drupal users. Stay tuned for more insightful Drupal content!