diff --git a/src/Access/EmbedButtonEditorAccessCheck.php b/src/Access/EmbedButtonEditorAccessCheck.php index 01463b6..77804af 100644 --- a/src/Access/EmbedButtonEditorAccessCheck.php +++ b/src/Access/EmbedButtonEditorAccessCheck.php @@ -78,19 +78,27 @@ class EmbedButtonEditorAccessCheck implements AccessInterface { * currently only capable of detecting buttons used by CKEditor. */ protected function checkButtonEditorAccess(EmbedButtonInterface $embed_button, EditorInterface $editor) { - if ($editor->getEditor() !== 'ckeditor') { + if (!in_array($editor->getEditor(), ['ckeditor', 'ckeditor5'])) { throw new HttpException(500, 'Currently, only CKEditor is supported.'); } $has_button = FALSE; $settings = $editor->getSettings(); - foreach ($settings['toolbar']['rows'] as $row) { - foreach ($row as $group) { - if (in_array($embed_button->id(), $group['items'])) { - $has_button = TRUE; - break 2; + if ($editor->getEditor() === 'ckeditor') { + foreach ($settings['toolbar']['rows'] as $row) { + foreach ($row as $group) { + if (in_array($embed_button->id(), $group['items'])) { + $has_button = TRUE; + break 2; + } } } + }elseif ($editor->getEditor() === 'ckeditor5') { + // The schema for CKEditor5 has changed, therefore we need to check for + // the toolbar items differently. + if ($settings['toolbar']['items'] && in_array($embed_button->id(), $settings['toolbar']['items'])) { + $has_button = TRUE; + } } return AccessResult::allowedIf($has_button)