src/Plugin/CKEditor4To5Upgrade/Imce.php | 62 +++++++++ tests/src/Kernel/CKE4to5UpgradePathTest.php | 193 ++++++++++++++++++++++++++++ 2 files changed, 255 insertions(+) diff --git a/src/Plugin/CKEditor4To5Upgrade/Imce.php b/src/Plugin/CKEditor4To5Upgrade/Imce.php new file mode 100644 index 0000000..9373b41 --- /dev/null +++ b/src/Plugin/CKEditor4To5Upgrade/Imce.php @@ -0,0 +1,62 @@ + 'both', + 'name' => 'Both IMCE buttons', + 'filters' => [ + 'filter_html' => [ + 'status' => 1, + 'settings' => [ + 'allowed_html' => '


', + ], + ], + ], + ])->setSyncing(TRUE)->save(); + FilterFormat::create([ + 'format' => 'image_only', + 'name' => 'Only the IMCE image button', + 'filters' => [ + 'filter_html' => [ + 'status' => 1, + 'settings' => [ + 'allowed_html' => '


', + ], + ], + ], + ])->setSyncing(TRUE)->save(); + FilterFormat::create([ + 'format' => 'link_only', + 'name' => 'Only the IMCE link button', + 'filters' => [ + 'filter_html' => [ + 'status' => 1, + 'settings' => [ + 'allowed_html' => '


', + ], + ], + ], + ])->setSyncing(TRUE)->save(); + + $generate_editor_settings = function (array $imce_buttons) { + return [ + 'toolbar' => [ + 'rows' => [ + 0 => [ + [ + 'name' => 'Basic Formatting', + 'items' => [ + 'Bold', + 'Format', + ], + ], + [ + 'name' => 'IMCE buttons', + 'items' => $imce_buttons, + ], + ], + ], + ], + 'plugins' => [ + // The CKEditor 4 plugin functionality has no settings. + ], + ]; + }; + + Editor::create([ + 'format' => 'both', + 'editor' => 'ckeditor', + 'settings' => $generate_editor_settings([ + 'ImceImage', + 'ImceLink', + ]), + ])->setSyncing(TRUE)->save(); + Editor::create([ + 'format' => 'image_only', + 'editor' => 'ckeditor', + 'settings' => $generate_editor_settings([ + 'ImceImage', + ]), + ])->setSyncing(TRUE)->save(); + Editor::create([ + 'format' => 'link_only', + 'editor' => 'ckeditor', + 'settings' => $generate_editor_settings([ + 'ImceLink', + ]), + ])->setSyncing(TRUE)->save(); + } + + /** + * {@inheritdoc} + */ + public function provider() { + parent::provider(); + + $expected_ckeditor5_plugin_settings = [ + 'plugins' => [ + 'ckeditor5_heading' => [ + 'enabled_headings' => [ + 'heading2', + 'heading3', + ], + ], + ], + ]; + + yield "both IMCE buttons" => [ + 'format_id' => 'both', + 'filters_to_drop' => [], + 'expected_ckeditor5_settings' => [ + 'toolbar' => [ + 'items' => [ + 'bold', + 'heading', + '|', + 'imce_image', + 'imce_link', + ], + ], + ] + $expected_ckeditor5_plugin_settings, + 'expected_superset' => '', + 'expected_fundamental_compatibility_violations' => [], + 'expected_db_logs' => [], + 'expected_messages' => [], + ]; + yield "IMCE image button only" => [ + 'format_id' => 'image_only', + 'filters_to_drop' => [], + 'expected_ckeditor5_settings' => [ + 'toolbar' => [ + 'items' => [ + 'bold', + 'heading', + '|', + 'imce_image', + ], + ], + ] + $expected_ckeditor5_plugin_settings, + 'expected_superset' => '', + 'expected_fundamental_compatibility_violations' => [], + 'expected_db_logs' => [], + 'expected_messages' => [], + ]; + yield "IMCE link button only" => [ + 'format_id' => 'link_only', + 'filters_to_drop' => [], + 'expected_ckeditor5_settings' => [ + 'toolbar' => [ + 'items' => [ + 'bold', + 'heading', + '|', + 'imce_link', + ], + ], + ] + $expected_ckeditor5_plugin_settings, + 'expected_superset' => '', + 'expected_fundamental_compatibility_violations' => [], + 'expected_db_logs' => [], + 'expected_messages' => [], + ]; + } + +}