How to use wysiwyg text editor (text_format) in a system configuration form I couldn't find any documentation or examples about this. The implementation is very problematic. Do you a means to do this?

Problems

While trying to create a system settings form with text_format input, I get following errors while displaying the form. The form is being submitted normally and the values are being saved but when the page refreshes the text editor is not populated with the saved values and the errors are always there.


  User error: "value" is an invalid render array key in
  Drupal\Core\Render\Element::children() (line 97 of
  core/lib/Drupal/Core/Render/Element.php).
  
  User error: "format" is an invalid render array key in
  Drupal\Core\Render\Element::children() (line 97 of
  core/lib/Drupal/Core/Render/Element.php).


The code in buildForm() is as follows:

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this-&gt;config('commerce_distance_terms.distanceterms');
    $form['title'] = [
      '#type' =&gt; 'textfield',
      '#title' =&gt; $this-&gt;t('Title'),
      '#description' =&gt; $this-&gt;t('Title for the terms'),
      '#maxlength' =&gt; 64,
      '#size' =&gt; 64,
      '#default_value' =&gt; $config-&gt;get('title'),
    ];
    $form['distance_selling_terms'] = [
      '#type' =&gt; 'text_format',
      '#title' =&gt; $this-&gt;t('Distance Selling Terms'),
      '#description' =&gt; $this-&gt;t('Enter Distance Selling terms'),
      '#default_value' =&gt; [
        'value' =&gt; $config-&gt;get('distance_selling_terms.value'),
        'format' =&gt; $config-&gt;get('distance_selling_terms.format'),
//         '#tree' =&gt; FALSE,
        '#printed' =&gt; TRUE,
      ],
    ];
    return parent::buildForm($form, $form_state);
  }


Background information


This is the error as it links from the code.
The errors are thrown because of the #default_value part of the array. Adding a #value =&gt; array() reduces the errors. But nothing changes. 
What I got from the stacktrace is that the form is being rendered, then the textarea is being rendered, and then the source of the error is being rendered (There are small elements inbetween). So I think the source of the error is the #default_value element of the textarea which is copied and pasted from the above array part while the compound text editor is being created.
In one of the rendering iterations, the Element::children() thinks that it should render the value and the format elements of the above array. Since they don't start with #.
There is a word here that system settings form doesn't support text_area input from Drupal 7. Also that and some linked issues tell that there are some automatic defaults for system_settings_form but I couldn't find the equal.
The text_format input is a compound element that includes a textarea (to hold and populate the actual value), a dropdown format element to select from, etc. The textarea element comes with the exact #default_value that I put above (as an array). I tried to preprocess this textarea and change that value to the related string to populate the field but whatever I do textarea comes always empty.
The #printed and #tree elements of the array don't change anything. I also put them inside the textarea array in the preprocess function but nothing changed.
The textarea's data-editor-value-original property comes with the above array flattened even tough I change the #default_value and #value in the preprocess.
The text editor not being able to be populated may not be related to above errors. I know nothing.
$form['distance_selling_terms'] = [
  '#type' =&gt; 'text_format',
  '#title' =&gt; $this-&gt;t('Distance Selling Terms'),
  '#description' =&gt; $this-&gt;t('Enter Distance Selling terms'),
  '#default_value' =&gt; config-&gt;get('distance_selling_terms.value'),
  '#format' =&gt; $config-&gt;get('distance_selling_terms.format'),
];


And if you want to limit the wysiwyg editor to only the one format, add #allowed_formats as in:

$form['distance_selling_terms'] = [
  '#type' =&gt; 'text_format',
  '#title' =&gt; $this-&gt;t('Distance Selling Terms'),
  '#description' =&gt; $this-&gt;t('Enter Distance Selling terms'),
  '#default_value' =&gt; config-&gt;get('distance_selling_terms.value'),
  '#format' =&gt; $config-&gt;get('distance_selling_terms.format'),
  '#allowed_formats' =&gt; [
    $config-&gt;get('distance_selling_terms.format') =&gt; 'Description of format'
  ],
];