Commit 6549160d authored by catch's avatar catch
Browse files

fix: #3419203 ckeditor5_post_update_code_block() throws an error for format...

fix: #3419203 ckeditor5_post_update_code_block() throws an error for format using CKE5 but with CKE4 settings

By: schoenef
By: catch
By: wim leers
By: quietone
By: longwave
By: xjm
parent 9839653e
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -632,7 +632,7 @@ function ckeditor5_editor_presave(EditorInterface $editor) {
  if ($editor->getEditor() === 'ckeditor5') {
    $settings = $editor->getSettings();
    // @see ckeditor5_post_update_code_block()
    if (in_array('codeBlock', $settings['toolbar']['items'], TRUE) && !isset($settings['plugins']['ckeditor5_codeBlock'])) {
    if (in_array('codeBlock', $settings['toolbar']['items'] ?: [], TRUE) && !isset($settings['plugins']['ckeditor5_codeBlock'])) {
      // @see \Drupal\ckeditor5\Plugin\CKEditor5Plugin\CodeBlock::defaultConfiguration()
      $settings['plugins']['ckeditor5_codeBlock'] = [
        'languages' => [
@@ -664,7 +664,7 @@ function ckeditor5_editor_presave(EditorInterface $editor) {
    }

    // @see ckeditor5_post_update_list_start_reversed()
    if (in_array('numberedList', $settings['toolbar']['items'], TRUE) && array_key_exists('ckeditor5_sourceEditing', $settings['plugins'])) {
    if (in_array('numberedList', $settings['toolbar']['items'] ?: [], TRUE) && array_key_exists('ckeditor5_sourceEditing', $settings['plugins'])) {
      $source_edited = HTMLRestrictions::fromString(implode(' ', $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags']));
      $format_restrictions = HTMLRestrictions::fromTextFormat($editor->getFilterFormat());

+2 −2
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ function ckeditor5_post_update_code_block(&$sandbox = []) {
    }
    $settings = $editor->getSettings();
    // @see ckeditor5_editor_presave()
    return in_array('codeBlock', $settings['toolbar']['items'], TRUE);
    return in_array('codeBlock', $settings['toolbar']['items'] ?: [], TRUE);
  });
}

@@ -138,7 +138,7 @@ function ckeditor5_post_update_list_start_reversed(&$sandbox = []) {
    $settings = $editor->getSettings();

    // @see ckeditor5_editor_presave()
    return in_array('numberedList', $settings['toolbar']['items'], TRUE)
    return in_array('numberedList', $settings['toolbar']['items'] ?: [], TRUE)
      && array_key_exists('ckeditor5_sourceEditing', $settings['plugins']);
  });
}