diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module
index 917248cd..392da9d2 100644
--- a/core/modules/block_content/block_content.module
+++ b/core/modules/block_content/block_content.module
@@ -87,7 +87,10 @@ function block_content_add_body_field($block_type_id, $label = 'Body') {
       'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'),
       'bundle' => $block_type_id,
       'label' => $label,
-      'settings' => ['display_summary' => FALSE],
+      'settings' => [
+        'display_summary' => FALSE,
+        'allowed_formats' => [],
+      ],
     ]);
     $field->save();
 
diff --git a/core/modules/block_content/migrations/block_content_body_field.yml b/core/modules/block_content/migrations/block_content_body_field.yml
index 9ed884f9..bc30e0ff 100644
--- a/core/modules/block_content/migrations/block_content_body_field.yml
+++ b/core/modules/block_content/migrations/block_content_body_field.yml
@@ -13,6 +13,7 @@ source:
       field_name: body
       label: Body
       display_summary: false
+      allowed_formats: {  }
   ids:
     entity_type:
       type: string
diff --git a/core/modules/book/config/optional/field.field.node.book.body.yml b/core/modules/book/config/optional/field.field.node.book.body.yml
index 7cf998dc..e45dcc27 100644
--- a/core/modules/book/config/optional/field.field.node.book.body.yml
+++ b/core/modules/book/config/optional/field.field.node.book.body.yml
@@ -19,4 +19,5 @@ default_value_callback: ''
 settings:
   display_summary: true
   required_summary: false
+  allowed_formats: {  }
 field_type: text_with_summary
diff --git a/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
index 90d60e40..3d692652 100644
--- a/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
+++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
@@ -73,7 +73,10 @@ class CKEditorIntegrationTest extends WebDriverTestBase {
       'field_storage' => $field_storage,
       'bundle' => 'page',
       'label' => 'Body',
-      'settings' => ['display_summary' => TRUE],
+      'settings' => [
+        'display_summary' => TRUE,
+        'allowed_formats' => [],
+      ],
       'required' => TRUE,
     ])->save();
 
diff --git a/core/modules/ckeditor/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php b/core/modules/ckeditor/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php
index 3500ef1a..7dbdc4c4 100644
--- a/core/modules/ckeditor/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php
+++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php
@@ -61,7 +61,10 @@ class FormErrorHandlerCKEditorTest extends WebDriverTestBase {
       'field_storage' => $field_storage,
       'bundle' => 'page',
       'label' => 'Body',
-      'settings' => ['display_summary' => TRUE],
+      'settings' => [
+        'display_summary' => TRUE,
+        'allowed_formats' => [],
+      ],
       'required' => TRUE,
     ])->save();
 
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
index c44ecb25..a3f60e22 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
@@ -411,7 +411,10 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
       'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'),
       'bundle' => $block_content_type->id(),
       'label' => 'Body',
-      'settings' => ['display_summary' => FALSE],
+      'settings' => [
+        'display_summary' => FALSE,
+        'allowed_formats' => [],
+      ],
     ]);
     $field->save();
 
diff --git a/core/modules/editor/tests/modules/config/schema/editor_test.schema.yml b/core/modules/editor/tests/modules/config/schema/editor_test.schema.yml
index 4e013162..326f8d3a 100644
--- a/core/modules/editor/tests/modules/config/schema/editor_test.schema.yml
+++ b/core/modules/editor/tests/modules/config/schema/editor_test.schema.yml
@@ -15,3 +15,7 @@ editor.settings.trex:
     stumpy_arms:
       type: boolean
       label: 'Stumpy arms'
+
+field.field_settings.editor_test_text_long:
+  label: 'Filter test text (formatted, long) settings'
+  type: field.field_settings.text
diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml
index 3e9c0a4c..6de8ad82 100644
--- a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml
+++ b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml
@@ -11,5 +11,6 @@ description: ''
 required: false
 default_value: {  }
 default_value_callback: ''
-settings: {  }
+settings:
+  allowed_formats: {  }
 field_type: text
diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import_2.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import_2.yml
index faf99c3a..a7212511 100644
--- a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import_2.yml
+++ b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import_2.yml
@@ -11,5 +11,6 @@ description: ''
 required: false
 default_value: {  }
 default_value_callback: ''
-settings: {  }
+settings:
+  allowed_formats: {  }
 field_type: text
diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.test_bundle.field_test_import_2.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.test_bundle.field_test_import_2.yml
index 95a19af3..cfa151f4 100644
--- a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.test_bundle.field_test_import_2.yml
+++ b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.test_bundle.field_test_import_2.yml
@@ -11,5 +11,6 @@ description: ''
 required: false
 default_value: {  }
 default_value_callback: ''
-settings: {  }
+settings:
+  allowed_formats: {  }
 field_type: text
diff --git a/core/modules/field/tests/modules/field_test_config/sync/field.field.entity_test.entity_test.field_test_import_sync.yml b/core/modules/field/tests/modules/field_test_config/sync/field.field.entity_test.entity_test.field_test_import_sync.yml
index 678c9fa1..b8af4db0 100644
--- a/core/modules/field/tests/modules/field_test_config/sync/field.field.entity_test.entity_test.field_test_import_sync.yml
+++ b/core/modules/field/tests/modules/field_test_config/sync/field.field.entity_test.entity_test.field_test_import_sync.yml
@@ -9,7 +9,8 @@ description: ''
 required: '0'
 default_value: {  }
 default_value_callback: ''
-settings: { }
+settings:
+  allowed_formats: {  }
 field_type: text
 dependencies:
   config:
diff --git a/core/modules/field/tests/modules/field_test_config/sync/field.field.entity_test.test_bundle.field_test_import_sync_2.yml b/core/modules/field/tests/modules/field_test_config/sync/field.field.entity_test.test_bundle.field_test_import_sync_2.yml
index e483418f..1f8f54fc 100644
--- a/core/modules/field/tests/modules/field_test_config/sync/field.field.entity_test.test_bundle.field_test_import_sync_2.yml
+++ b/core/modules/field/tests/modules/field_test_config/sync/field.field.entity_test.test_bundle.field_test_import_sync_2.yml
@@ -9,7 +9,8 @@ description: ''
 required: '0'
 default_value: {  }
 default_value_callback: ''
-settings: { }
+settings:
+  allowed_formats: {  }
 field_type: text
 dependencies:
   config:
diff --git a/core/modules/field/tests/modules/field_test_config/sync/field.field.entity_test.test_bundle_2.field_test_import_sync_2.yml b/core/modules/field/tests/modules/field_test_config/sync/field.field.entity_test.test_bundle_2.field_test_import_sync_2.yml
index 3afd2e25..bc68be63 100644
--- a/core/modules/field/tests/modules/field_test_config/sync/field.field.entity_test.test_bundle_2.field_test_import_sync_2.yml
+++ b/core/modules/field/tests/modules/field_test_config/sync/field.field.entity_test.test_bundle_2.field_test_import_sync_2.yml
@@ -9,7 +9,8 @@ description: ''
 required: '0'
 default_value: {  }
 default_value_callback: ''
-settings: { }
+settings:
+  allowed_formats: {  }
 field_type: text
 dependencies:
   config:
diff --git a/core/modules/field/tests/src/Functional/Rest/FieldConfigResourceTestBase.php b/core/modules/field/tests/src/Functional/Rest/FieldConfigResourceTestBase.php
index 025b820d..f13eb986 100644
--- a/core/modules/field/tests/src/Functional/Rest/FieldConfigResourceTestBase.php
+++ b/core/modules/field/tests/src/Functional/Rest/FieldConfigResourceTestBase.php
@@ -82,7 +82,9 @@ abstract class FieldConfigResourceTestBase extends ConfigEntityResourceTestBase
       'label' => 'field_llama',
       'langcode' => 'en',
       'required' => FALSE,
-      'settings' => [],
+      'settings' => [
+        'allowed_formats' => [],
+      ],
       'status' => TRUE,
       'translatable' => TRUE,
       'uuid' => $this->entity->uuid(),
diff --git a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php
index 47edfd6d..489ef4af 100644
--- a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php
+++ b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php
@@ -33,7 +33,7 @@ class MigrateFieldInstanceTest extends MigrateDrupal6TestBase {
     $field = FieldConfig::load('node.story.field_test');
     $this->assertSame('Text Field', $field->label());
     // field_test is a text_long field, which have no settings.
-    $this->assertSame([], $field->getSettings());
+    $this->assertSame(['allowed_formats' => []], $field->getSettings());
     $this->assertSame('text for default value', $entity->field_test->value);
 
     // Test a number field.
diff --git a/core/modules/forum/config/optional/field.field.comment.comment_forum.comment_body.yml b/core/modules/forum/config/optional/field.field.comment.comment_forum.comment_body.yml
index 215199cc..8c6fa4c5 100644
--- a/core/modules/forum/config/optional/field.field.comment.comment_forum.comment_body.yml
+++ b/core/modules/forum/config/optional/field.field.comment.comment_forum.comment_body.yml
@@ -16,5 +16,6 @@ required: true
 translatable: true
 default_value: {  }
 default_value_callback: ''
-settings: {  }
+settings:
+  allowed_formats: {  }
 field_type: text_long
diff --git a/core/modules/forum/config/optional/field.field.node.forum.body.yml b/core/modules/forum/config/optional/field.field.node.forum.body.yml
index 4289cdb2..ac1fa82a 100644
--- a/core/modules/forum/config/optional/field.field.node.forum.body.yml
+++ b/core/modules/forum/config/optional/field.field.node.forum.body.yml
@@ -19,4 +19,5 @@ default_value_callback: ''
 settings:
   display_summary: true
   required_summary: false
+  allowed_formats: {  }
 field_type: text_with_summary
diff --git a/core/modules/jsonapi/tests/src/Functional/FieldConfigTest.php b/core/modules/jsonapi/tests/src/Functional/FieldConfigTest.php
index eb81f509..d5ed11be 100644
--- a/core/modules/jsonapi/tests/src/Functional/FieldConfigTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/FieldConfigTest.php
@@ -119,7 +119,7 @@ class FieldConfigTest extends ConfigEntityResourceTestBase {
           'label' => 'field_llama',
           'langcode' => 'en',
           'required' => FALSE,
-          'settings' => [],
+          'settings' => ['allowed_formats' => []],
           'status' => TRUE,
           'translatable' => TRUE,
           'drupal_internal__id' => 'node.camelids.field_llama',
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 7e194d91..13cdf1f5 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -266,7 +266,10 @@ function node_add_body_field(NodeTypeInterface $type, $label = 'Body') {
       'field_storage' => $field_storage,
       'bundle' => $type->id(),
       'label' => $label,
-      'settings' => ['display_summary' => TRUE],
+      'settings' => [
+        'display_summary' => TRUE,
+        'allowed_formats' => [],
+      ],
     ]);
     $field->save();
 
diff --git a/core/modules/options/tests/options_config_install_test/config/install/field.field.node.options_install_test.body.yml b/core/modules/options/tests/options_config_install_test/config/install/field.field.node.options_install_test.body.yml
index 8e21dfb0..70a99165 100644
--- a/core/modules/options/tests/options_config_install_test/config/install/field.field.node.options_install_test.body.yml
+++ b/core/modules/options/tests/options_config_install_test/config/install/field.field.node.options_install_test.body.yml
@@ -17,4 +17,5 @@ default_value: {  }
 default_value_callback: ''
 settings:
   display_summary: true
+  allowed_formats: {  }
 field_type: text_with_summary
diff --git a/core/modules/text/config/schema/text.schema.yml b/core/modules/text/config/schema/text.schema.yml
index 08bc9aad..e0fa5d3d 100644
--- a/core/modules/text/config/schema/text.schema.yml
+++ b/core/modules/text/config/schema/text.schema.yml
@@ -19,6 +19,12 @@ field.storage_settings.text:
 field.field_settings.text:
   type: mapping
   label: 'Text (formatted) settings'
+  mapping:
+    allowed_formats:
+      type: sequence
+      label: 'Allowed text formats'
+      sequence:
+        type: string
 
 field.value.text:
   type: mapping
@@ -33,11 +39,17 @@ field.value.text:
 
 field.storage_settings.text_long:
   label: 'Text (formatted, long) settings'
-  type: mapping
+  type: field.field_settings.text
 
 field.field_settings.text_long:
   label: 'Text (formatted, long) settings'
   type: mapping
+  mapping:
+    allowed_formats:
+      type: sequence
+      label: 'Allowed text formats'
+      sequence:
+        type: string
 
 field.value.text_long:
   type: mapping
@@ -64,6 +76,11 @@ field.field_settings.text_with_summary:
     required_summary:
       type: boolean
       label: 'Require summary'
+    allowed_formats:
+      type: sequence
+      label: 'Allowed text formats'
+      sequence:
+        type: string
 
 field.value.text_with_summary:
   type: mapping
diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextItem.php
index dcee5834..fa201b12 100644
--- a/core/modules/text/src/Plugin/Field/FieldType/TextItem.php
+++ b/core/modules/text/src/Plugin/Field/FieldType/TextItem.php
@@ -14,7 +14,8 @@ use Drupal\Core\Form\FormStateInterface;
  *   description = @Translation("This field stores a text with a text format."),
  *   category = @Translation("Text"),
  *   default_widget = "text_textfield",
- *   default_formatter = "text_default"
+ *   default_formatter = "text_default",
+ *   list_class = "\Drupal\text\Plugin\Field\FieldType\TextFieldItemList"
  * )
  */
 class TextItem extends TextItemBase {
diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php
index 3fdd385d..d3593e70 100644
--- a/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php
+++ b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php
@@ -6,6 +6,7 @@ use Drupal\Component\Utility\Random;
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\FieldItemBase;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\TypedData\DataDefinition;
 
 /**
@@ -13,6 +14,64 @@ use Drupal\Core\TypedData\DataDefinition;
  */
 abstract class TextItemBase extends FieldItemBase {
 
+  /**
+   * {@inheritdoc}
+   */
+  public static function defaultFieldSettings() {
+    return ['allowed_formats' => []] + parent::defaultFieldSettings();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
+    $element = parent::fieldSettingsForm($form, $form_state);
+    $settings = $this->getSettings();
+
+    $element['allowed_formats'] = [
+      '#type' => 'checkboxes',
+      '#title' => $this->t('Allowed text formats'),
+      '#options' => $this->get('format')->getPossibleOptions(),
+      '#default_value' => !empty($settings['allowed_formats']) ? $settings['allowed_formats'] : [],
+      '#description' => $this->t('Select the allowed text formats. If no formats are selected, all available text formats will be displayed to the user.'),
+      '#element_validate' => [[static::class, 'validateAllowedFormats']],
+    ];
+
+    return $element;
+  }
+
+  /**
+   * Render API callback: Processes the allowed formats value.
+   *
+   * Ensure the element's value is an indexed array of selected format IDs.
+   * This function is assigned as an #element_validate callback.
+   *
+   * @see static::fieldSettingsForm()
+   */
+  public static function validateAllowedFormats(array &$element, FormStateInterface $form_state) {
+    $value = array_values(array_filter($element['#value']));
+    $form_state->setValueForElement($element, $value);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function calculateDependencies(FieldDefinitionInterface $field_definition) {
+    // Add explicitly allowed formats as config dependencies.
+    $dependencies = parent::calculateDependencies($field_definition);
+    if (!is_null($field_definition->getSetting('allowed_formats'))) {
+      $format_dependencies = array_map(function (string $format_id) {
+        return 'filter.format.' . $format_id;
+      }, $field_definition->getSetting('allowed_formats'));
+    }
+    else {
+      $format_dependencies = [];
+    }
+    $config = $dependencies['config'] ?? [];
+    $dependencies['config'] = array_merge($config, $format_dependencies);
+    return $dependencies;
+  }
+
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php
index 15e4eb6a..ce358733 100644
--- a/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php
+++ b/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php
@@ -13,7 +13,8 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
  *   description = @Translation("This field stores a long text with a text format."),
  *   category = @Translation("Text"),
  *   default_widget = "text_textarea",
- *   default_formatter = "text_default"
+ *   default_formatter = "text_default",
+ *   list_class = "\Drupal\text\Plugin\Field\FieldType\TextFieldItemList"
  * )
  */
 class TextLongItem extends TextItemBase {
diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php
index 9c9a160e..060dae25 100644
--- a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php
+++ b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php
@@ -15,7 +15,8 @@ use Drupal\Core\TypedData\DataDefinition;
  *   description = @Translation("This field stores long text with a format and an optional summary."),
  *   category = @Translation("Text"),
  *   default_widget = "text_textarea_with_summary",
- *   default_formatter = "text_default"
+ *   default_formatter = "text_default",
+ *   list_class = "\Drupal\text\Plugin\Field\FieldType\TextFieldItemList"
  * )
  */
 class TextWithSummaryItem extends TextItemBase {
@@ -86,7 +87,7 @@ class TextWithSummaryItem extends TextItemBase {
    * {@inheritdoc}
    */
   public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
-    $element = [];
+    $element = parent::fieldSettingsForm($form, $form_state);
     $settings = $this->getSettings();
 
     $element['display_summary'] = [
diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php
index 11e84f1c..1c3a224e 100644
--- a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php
+++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php
@@ -34,11 +34,17 @@ class TextareaWidget extends StringTextareaWidget {
    */
   public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
     $main_widget = parent::formElement($items, $delta, $element, $form, $form_state);
+    $allowed_formats = $this->getFieldSetting('allowed_formats');
 
     $element = $main_widget['value'];
     $element['#type'] = 'text_format';
     $element['#format'] = $items[$delta]->format;
     $element['#base_type'] = $main_widget['value']['#type'];
+
+    if ($allowed_formats && !$this->isDefaultValueWidget($form_state)) {
+      $element['#allowed_formats'] = $allowed_formats;
+    }
+
     return $element;
   }
 
diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php
index e6954cc1..a26f7c37 100644
--- a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php
+++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php
@@ -25,11 +25,17 @@ class TextfieldWidget extends StringTextfieldWidget {
    */
   public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
     $main_widget = parent::formElement($items, $delta, $element, $form, $form_state);
+    $allowed_formats = $this->getFieldSetting('allowed_formats');
 
     $element = $main_widget['value'];
     $element['#type'] = 'text_format';
     $element['#format'] = $items[$delta]->format ?? NULL;
     $element['#base_type'] = $main_widget['value']['#type'];
+
+    if ($allowed_formats && !$this->isDefaultValueWidget($form_state)) {
+      $element['#allowed_formats'] = $allowed_formats;
+    }
+
     return $element;
   }
 
diff --git a/core/modules/text/tests/src/Functional/TextFieldTest.php b/core/modules/text/tests/src/Functional/TextFieldTest.php
index 00d687fe..17c72441 100644
--- a/core/modules/text/tests/src/Functional/TextFieldTest.php
+++ b/core/modules/text/tests/src/Functional/TextFieldTest.php
@@ -21,6 +21,13 @@ class TextFieldTest extends StringFieldTest {
     getTestFiles as drupalGetTestFiles;
   }
 
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  protected static $modules = ['entity_test', 'file', 'field_ui'];
+
   /**
    * A user with relevant administrative privileges.
    *
@@ -36,7 +43,10 @@ class TextFieldTest extends StringFieldTest {
   protected function setUp(): void {
     parent::setUp();
 
-    $this->adminUser = $this->drupalCreateUser(['administer filters']);
+    $this->adminUser = $this->drupalCreateUser([
+      'administer filters',
+      'administer entity_test fields',
+    ]);
   }
 
   // Test fields.
@@ -154,14 +164,108 @@ class TextFieldTest extends StringFieldTest {
     $this->_testTextfieldWidgetsFormatted('text_long', 'text_textarea');
   }
 
+  /**
+   * Test widgets for fields with selected allowed formats.
+   */
+  public function testTextfieldWidgetsAllowedFormats() {
+    // Create one text format.
+    $this->drupalLogin($this->adminUser);
+    $edit = [
+      'format' => mb_strtolower($this->randomMachineName()),
+      'name' => $this->randomMachineName(),
+    ];
+    $this->drupalGet('admin/config/content/formats/add');
+    $this->submitForm($edit, 'Save configuration');
+    filter_formats_reset();
+    /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
+    $entity_type_manager = $this->container->get('entity_type.manager');
+    $filter_format_storage = $entity_type_manager
+      ->getStorage('filter_format');
+    /** @var \Drupal\filter\Entity\FilterFormat $format1 */
+    $format1 = $filter_format_storage->load($edit['format']);
+    $format1_id = $format1->id();
+
+    // Create a second text format.
+    $edit = [
+      'format' => mb_strtolower($this->randomMachineName()),
+      'name' => $this->randomMachineName(),
+    ];
+    $this->drupalGet('admin/config/content/formats/add');
+    $this->submitForm($edit, 'Save configuration');
+    filter_formats_reset();
+    /** @var \Drupal\filter\Entity\FilterFormat $format2 */
+    $format2 = $filter_format_storage->load($edit['format']);
+
+    // Grant access to both formats to the user.
+    $roles = $this->webUser->getRoles();
+    $rid = $roles[0];
+    user_role_grant_permissions($rid, [
+      $format1->getPermissionName(),
+      $format2->getPermissionName(),
+    ]);
+
+    // Create a field with multiple formats allowed.
+    $field_name = mb_strtolower($this->randomMachineName());
+    $field_storage = FieldStorageConfig::create([
+      'field_name' => $field_name,
+      'entity_type' => 'entity_test',
+      'type' => 'text',
+    ]);
+    $field_storage->save();
+    $field = FieldConfig::create([
+      'field_storage' => $field_storage,
+      'bundle' => 'entity_test',
+      'label' => $this->randomMachineName() . '_label',
+      'settings' => ['allowed_formats' => []],
+    ]);
+    $field->save();
+
+    /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository */
+    $entity_display_repository = $this->container->get('entity_display.repository');
+    $entity_display_repository->getFormDisplay('entity_test', 'entity_test', 'default')
+      ->setComponent($field_name, [
+        'type' => 'text_textfield',
+      ])
+      ->save();
+    $entity_display_repository->getViewDisplay('entity_test', 'entity_test', 'full')
+      ->setComponent($field_name)
+      ->save();
+
+    // Display the creation form.
+    $this->drupalLogin($this->webUser);
+    $this->drupalGet('entity_test/add');
+    $this->assertSession()->fieldExists("{$field_name}[0][value]", NULL);
+    $this->assertSession()->optionExists("{$field_name}[0][format]", $format1->id());
+    $this->assertSession()->optionExists("{$field_name}[0][format]", $format2->id());
+    // Log back in as admin.
+    $this->drupalLogin($this->adminUser);
+    // Change field to allow only one format.
+    $path = "entity_test/structure/entity_test/fields/entity_test.entity_test.$field_name";
+    $this->drupalGet($path);
+    $this->submitForm(["settings[allowed_formats][$format1_id]" => $format1_id], 'Save settings');
+    $this->drupalGet($path);
+    // Display the creation form.
+    $this->drupalLogin($this->webUser);
+    // We shouldn't have the 'format' selector since only one format is allowed.
+    $this->drupalGet('entity_test/add');
+    $this->assertSession()->fieldExists("{$field_name}[0][value]", NULL);
+    $this->assertSession()->fieldNotExists("{$field_name}[0][format]");
+
+    // Change field to allow all formats by configuring none as allowed.
+    $field->setSetting('allowed_formats', []);
+    $field->save();
+    $this->drupalGet('entity_test/add');
+    // We should see the 'format' selector again.
+    $this->assertSession()->fieldExists("{$field_name}[0][value]", NULL);
+    $this->assertSession()->optionExists("{$field_name}[0][format]", $format1->id());
+    $this->assertSession()->optionExists("{$field_name}[0][format]", $format2->id());
+  }
+
   /**
    * Helper function for testTextfieldWidgetsFormatted().
    */
   public function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
-    /** @var \Drupal\Core\Render\RendererInterface $renderer */
-    $renderer = $this->container->get('renderer');
-
-    // Create a field.
+     // Create a field.
     $field_name = mb_strtolower($this->randomMachineName());
     $field_storage = FieldStorageConfig::create([
       'field_name' => $field_name,
@@ -198,7 +302,7 @@ class TextFieldTest extends StringFieldTest {
     // Display the creation form. Since the user only has access to one format,
     // no format selector will be displayed.
     $this->drupalGet('entity_test/add');
-    $this->assertSession()->fieldValueEquals("{$field_name}[0][value]", '');
+    $this->assertSession()->fieldValueEquals("{$field_name}[0][value]", NULL);
     $this->assertSession()->fieldNotExists("{$field_name}[0][format]");
 
     // Submit with data that should be filtered.
diff --git a/core/modules/text/tests/src/Kernel/TextItemBaseTest.php b/core/modules/text/tests/src/Kernel/TextItemBaseTest.php
index 50abbc26..3087cb7f 100644
--- a/core/modules/text/tests/src/Kernel/TextItemBaseTest.php
+++ b/core/modules/text/tests/src/Kernel/TextItemBaseTest.php
@@ -3,6 +3,9 @@
 namespace Drupal\Tests\text\Kernel;
 
 use Drupal\Core\Field\BaseFieldDefinition;
+use Drupal\field\Entity\FieldConfig;
+use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\filter\Entity\FilterFormat;
 use Drupal\KernelTests\KernelTestBase;
 use Drupal\text\Plugin\Field\FieldType\TextItemBase;
 
@@ -16,7 +19,7 @@ class TextItemBaseTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  protected static $modules = ['filter', 'text'];
+  protected static $modules = ['filter', 'text', 'entity_test', 'field'];
 
   /**
    * Tests creation of sample values.
@@ -57,4 +60,42 @@ class TextItemBaseTest extends KernelTestBase {
     ];
   }
 
+  /**
+   * @covers ::calculateDependencies
+   */
+  public function testCalculateDependencies() {
+    $format = FilterFormat::create([
+      'format' => 'test_format',
+      'name' => 'Test format',
+    ]);
+    $fieldName = mb_strtolower($this->randomMachineName());
+    $field_storage = FieldStorageConfig::create([
+      'field_name' => $fieldName,
+      'entity_type' => 'entity_test',
+      'type' => 'text',
+    ]);
+    $field_storage->save();
+    $field = FieldConfig::create([
+      'field_name' => $fieldName,
+      'entity_type' => 'entity_test',
+      'bundle' => 'entity_test',
+      'settings' => [
+        'allowed_formats' => [$format->id()],
+      ],
+    ]);
+    $field->save();
+
+    $field->calculateDependencies();
+    $this->assertEquals([
+      'module' => [
+        'entity_test',
+        'text',
+      ],
+      'config' => [
+        "field.storage.entity_test.$fieldName",
+        'filter.format.test_format',
+      ],
+    ], $field->getDependencies());
+  }
+
 }
diff --git a/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php b/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php
index 8bf1de11..dd248e21 100644
--- a/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php
+++ b/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php
@@ -80,7 +80,10 @@ class ViewEntityDependenciesTest extends ViewsKernelTestBase {
       'field_storage' => FieldStorageConfig::loadByName('node', 'body'),
       'bundle' => $content_type->id(),
       'label' => $this->randomMachineName() . '_body',
-      'settings' => ['display_summary' => TRUE],
+      'settings' => [
+        'display_summary' => TRUE,
+        'allowed_formats' => [],
+      ],
     ])->save();
 
     ViewTestData::createTestViews(static::class, ['views_test_config']);
diff --git a/core/profiles/demo_umami/config/install/field.field.block_content.basic.body.yml b/core/profiles/demo_umami/config/install/field.field.block_content.basic.body.yml
index dab4f981..40968daa 100644
--- a/core/profiles/demo_umami/config/install/field.field.block_content.basic.body.yml
+++ b/core/profiles/demo_umami/config/install/field.field.block_content.basic.body.yml
@@ -19,4 +19,5 @@ default_value_callback: ''
 settings:
   display_summary: false
   required_summary: false
+  allowed_formats: {  }
 field_type: text_with_summary
diff --git a/core/profiles/demo_umami/config/install/field.field.block_content.disclaimer_block.field_copyright.yml b/core/profiles/demo_umami/config/install/field.field.block_content.disclaimer_block.field_copyright.yml
index 964a8888..30cbbdbb 100644
--- a/core/profiles/demo_umami/config/install/field.field.block_content.disclaimer_block.field_copyright.yml
+++ b/core/profiles/demo_umami/config/install/field.field.block_content.disclaimer_block.field_copyright.yml
@@ -16,5 +16,6 @@ required: false
 translatable: true
 default_value: {  }
 default_value_callback: ''
-settings: {  }
+settings:
+  allowed_formats: {  }
 field_type: text_long
diff --git a/core/profiles/demo_umami/config/install/field.field.block_content.disclaimer_block.field_disclaimer.yml b/core/profiles/demo_umami/config/install/field.field.block_content.disclaimer_block.field_disclaimer.yml
index d2d3c918..1aab2902 100644
--- a/core/profiles/demo_umami/config/install/field.field.block_content.disclaimer_block.field_disclaimer.yml
+++ b/core/profiles/demo_umami/config/install/field.field.block_content.disclaimer_block.field_disclaimer.yml
@@ -16,5 +16,6 @@ required: false
 translatable: true
 default_value: {  }
 default_value_callback: ''
-settings: {  }
+settings:
+  allowed_formats: {  }
 field_type: text_long
diff --git a/core/profiles/demo_umami/config/install/field.field.node.article.body.yml b/core/profiles/demo_umami/config/install/field.field.node.article.body.yml
index b36fbd58..66f00ac4 100644
--- a/core/profiles/demo_umami/config/install/field.field.node.article.body.yml
+++ b/core/profiles/demo_umami/config/install/field.field.node.article.body.yml
@@ -19,4 +19,5 @@ default_value_callback: ''
 settings:
   display_summary: true
   required_summary: false
+  allowed_formats: {  }
 field_type: text_with_summary
diff --git a/core/profiles/demo_umami/config/install/field.field.node.page.body.yml b/core/profiles/demo_umami/config/install/field.field.node.page.body.yml
index 4ff17d0e..c81d7034 100644
--- a/core/profiles/demo_umami/config/install/field.field.node.page.body.yml
+++ b/core/profiles/demo_umami/config/install/field.field.node.page.body.yml
@@ -19,4 +19,5 @@ default_value_callback: ''
 settings:
   display_summary: true
   required_summary: false
+  allowed_formats: {  }
 field_type: text_with_summary
diff --git a/core/profiles/demo_umami/config/install/field.field.node.recipe.field_recipe_instruction.yml b/core/profiles/demo_umami/config/install/field.field.node.recipe.field_recipe_instruction.yml
index ff090cac..788f56d1 100644
--- a/core/profiles/demo_umami/config/install/field.field.node.recipe.field_recipe_instruction.yml
+++ b/core/profiles/demo_umami/config/install/field.field.node.recipe.field_recipe_instruction.yml
@@ -16,5 +16,6 @@ required: true
 translatable: true
 default_value: {  }
 default_value_callback: ''
-settings: {  }
+settings:
+  allowed_formats: {  }
 field_type: text_long
diff --git a/core/profiles/demo_umami/config/install/field.field.node.recipe.field_summary.yml b/core/profiles/demo_umami/config/install/field.field.node.recipe.field_summary.yml
index b648b978..7ea393bc 100644
--- a/core/profiles/demo_umami/config/install/field.field.node.recipe.field_summary.yml
+++ b/core/profiles/demo_umami/config/install/field.field.node.recipe.field_summary.yml
@@ -16,5 +16,6 @@ required: true
 translatable: true
 default_value: {  }
 default_value_callback: ''
-settings: {  }
+settings:
+  allowed_formats: {  }
 field_type: text_long
diff --git a/core/profiles/standard/config/install/field.field.block_content.basic.body.yml b/core/profiles/standard/config/install/field.field.block_content.basic.body.yml
index dab4f981..40968daa 100644
--- a/core/profiles/standard/config/install/field.field.block_content.basic.body.yml
+++ b/core/profiles/standard/config/install/field.field.block_content.basic.body.yml
@@ -19,4 +19,5 @@ default_value_callback: ''
 settings:
   display_summary: false
   required_summary: false
+  allowed_formats: {  }
 field_type: text_with_summary
diff --git a/core/profiles/standard/config/install/field.field.comment.comment.comment_body.yml b/core/profiles/standard/config/install/field.field.comment.comment.comment_body.yml
index 1337070d..8d97e035 100644
--- a/core/profiles/standard/config/install/field.field.comment.comment.comment_body.yml
+++ b/core/profiles/standard/config/install/field.field.comment.comment.comment_body.yml
@@ -16,5 +16,6 @@ required: true
 translatable: true
 default_value: {  }
 default_value_callback: ''
-settings: {  }
+settings:
+  allowed_formats: {  }
 field_type: text_long
diff --git a/core/profiles/standard/config/install/field.field.node.article.body.yml b/core/profiles/standard/config/install/field.field.node.article.body.yml
index b36fbd58..66f00ac4 100644
--- a/core/profiles/standard/config/install/field.field.node.article.body.yml
+++ b/core/profiles/standard/config/install/field.field.node.article.body.yml
@@ -19,4 +19,5 @@ default_value_callback: ''
 settings:
   display_summary: true
   required_summary: false
+  allowed_formats: {  }
 field_type: text_with_summary
diff --git a/core/profiles/standard/config/install/field.field.node.page.body.yml b/core/profiles/standard/config/install/field.field.node.page.body.yml
index 4ff17d0e..c81d7034 100644
--- a/core/profiles/standard/config/install/field.field.node.page.body.yml
+++ b/core/profiles/standard/config/install/field.field.node.page.body.yml
@@ -19,4 +19,5 @@ default_value_callback: ''
 settings:
   display_summary: true
   required_summary: false
+  allowed_formats: {  }
 field_type: text_with_summary
