diff --git a/composer.lock b/composer.lock index fdef57dabe..f61110aceb 100644 --- a/composer.lock +++ b/composer.lock @@ -534,7 +534,7 @@ "dist": { "type": "path", "url": "core", - "reference": "107b1d4f65408eb2844facd227005517de15343b" + "reference": "1878827866afdec864cb4652a3d8b813d970f710" }, "require": { "asm89/stack-cors": "^1.1", @@ -597,6 +597,7 @@ "drupal/book": "self.version", "drupal/breakpoint": "self.version", "drupal/ckeditor": "self.version", + "drupal/ckeditor5": "self.version", "drupal/claro": "self.version", "drupal/classy": "self.version", "drupal/color": "self.version", diff --git a/core/core.libraries.yml b/core/core.libraries.yml index e2b2c4d3d5..a8e554104b 100644 --- a/core/core.libraries.yml +++ b/core/core.libraries.yml @@ -49,6 +49,7 @@ ckeditor5.editorDecoupled: assets/vendor/ckeditor5/build/editor-decoupled.js: { preprocess: false, minified: true } dependencies: - core/ckeditor5 + - core/ckeditor5.htmlSupport ckeditor5.internal: remote: *ckeditor5Remote @@ -163,9 +164,6 @@ ckeditor5.language: remote: *ckeditor5Remote version: *ckeditor5Version license: *ckeditor5License - css: - component: - css/language.css: {} js: assets/vendor/ckeditor5/build/language.js: { preprocess: false, minified: true } dependencies: diff --git a/core/modules/ckeditor5/ckeditor5.module b/core/modules/ckeditor5/ckeditor5.module index 0ac517bc19..0d7b8bf82f 100644 --- a/core/modules/ckeditor5/ckeditor5.module +++ b/core/modules/ckeditor5/ckeditor5.module @@ -26,7 +26,7 @@ function ckeditor5_help($route_name, RouteMatchInterface $route_match) { case 'help.page.ckeditor5': $output = ''; $output .= '

' . t('About') . '

'; - $output .= '

' . t('The CKEditor 5 module provides the CKEditor 5 text editor for WYSIWYG HTML editing in text fields. The CKEditor 5 module uses the framework provided by the Text Editor module.', [':cke_url' => 'https://ckeditor.com/ckeditor-5/', ':text_editor' => Url::fromRoute('help.page', ['name' => 'editor'])->toString()]) . '

'; + $output .= '

' . t('The CKEditor 5 module provides a highly-accessible, highly-usable visual text editor and adds a toolbar to text fields. Users can use buttons to format content and to create semantically correct and valid HTML. The CKEditor module uses the framework provided by the Text Editor module. It requires JavaScript to be enabled in the browser. For more information, see the online documentation for the CKEditor 5 module and the CKEditor 5 website.', [':doc_url' => 'https://www.drupal.org/docs/contributed-modules/ckeditor-5', ':cke5_url' => 'https://ckeditor.com/ckeditor-5/', ':text_editor' => Url::fromRoute('help.page', ['name' => 'editor'])->toString()]) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Enabling CKEditor 5 for individual text formats') . '
'; @@ -364,6 +364,11 @@ function ckeditor5_validation_constraint_alter(array &$definitions) { * Implements hook_config_schema_info_alter(). */ function ckeditor5_config_schema_info_alter(&$definitions) { + // In \Drupal\Tests\config\Functional\ConfigImportAllTest, this hook may be + // called without ckeditor5.pair.schema.yml being active. + if (!isset($definitions['ckeditor5_valid_pair__format_and_editor'])) { + return; + } // @see filter.format.*.filters $definitions['ckeditor5_valid_pair__format_and_editor']['mapping']['filters'] = $definitions['filter.format.*']['mapping']['filters']; // @see @see editor.editor.*.image_upload diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php index 0e189d074e..4e8a41b963 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php @@ -320,6 +320,11 @@ public function testAllowedTags() { $page->pressButton('Save configuration'); $assert_session->pageTextContains('The text format ckeditor5 has been updated'); $assert_session->pageTextNotContains('The following tag(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Bold ()'); + + // Ensure that CKEditor can be initialized with Source Editing. + // @see https://www.drupal.org/i/3231427 + $this->drupalGet('node/add'); + $this->assertNotEmpty($assert_session->waitForElement('css', '.ck-editor')); } /** diff --git a/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php b/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php index 1bca03aac4..88ffa0191c 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php @@ -333,10 +333,10 @@ public function testEnabledPlugins() { ]; $this->assertSame($default_plugins, $definitions, 'No CKEditor 5 plugins found besides the built-in ones.'); $default_libraries = [ - 'ckeditor5/ckeditor5.basic', - 'ckeditor5/ckeditor5.internal', 'ckeditor5/drupal.ckeditor5', - 'ckeditor5/drupal.ckeditor5.emphasis', + 'core/ckeditor5.basic', + 'core/ckeditor5.internal', + 'core/drupal.ckeditor5.emphasis', ]; $this->assertSame($default_libraries, $this->manager->getEnabledLibraries($editor)); @@ -362,9 +362,9 @@ public function testEnabledPlugins() { // Sort on plugin id. asort($default_plugins_with_layercake); $this->assertSame(array_values($default_plugins_with_layercake), $plugin_ids); - $this->assertSame(array_merge($default_libraries, [ - 'ckeditor5_test/layercake', - ]), $this->manager->getEnabledLibraries($editor)); + $default_libraries_with_layercake = array_merge($default_libraries, ['ckeditor5_test/layercake']); + sort($default_libraries_with_layercake); + $this->assertSame($default_libraries_with_layercake, $this->manager->getEnabledLibraries($editor)); // Enable media embed filter which the CKEditor 5 media plugin requires. $editor->getFilterFormat()->setFilterConfig('media_embed', ['status' => TRUE])->save(); @@ -378,10 +378,12 @@ public function testEnabledPlugins() { ]); sort($expected_plugins); $this->assertSame($expected_plugins, $plugin_ids); - $this->assertSame(array_merge($default_libraries, [ + $expected_libraries = array_merge($default_libraries, [ 'ckeditor5/drupal.ckeditor5.media', 'ckeditor5_test/layercake', - ]), $this->manager->getEnabledLibraries($editor)); + ]); + sort($expected_libraries); + $this->assertSame($expected_libraries, $this->manager->getEnabledLibraries($editor)); // Case 5: GHS is only enabled for Full HTML (or any other text format that // has no TYPE_HTML_RESTRICTOR filters). @@ -397,11 +399,11 @@ public function testEnabledPlugins() { ]; $this->assertSame($default_plugins, $definitions, 'No CKEditor 5 plugins found besides the built-in ones.'); $default_libraries = [ - 'ckeditor5/ckeditor5.basic', - 'ckeditor5/ckeditor5.htmlSupport', - 'ckeditor5/ckeditor5.internal', 'ckeditor5/drupal.ckeditor5', - 'ckeditor5/drupal.ckeditor5.emphasis', + 'core/ckeditor5.basic', + 'core/ckeditor5.htmlSupport', + 'core/ckeditor5.internal', + 'core/drupal.ckeditor5.emphasis', ]; $this->assertSame($default_libraries, $this->manager->getEnabledLibraries($editor)); } diff --git a/core/modules/ckeditor5/tests/src/Kernel/StarterTemplateTest.php b/core/modules/ckeditor5/tests/src/Kernel/StarterTemplateTest.php deleted file mode 100644 index 4f1edacaba..0000000000 --- a/core/modules/ckeditor5/tests/src/Kernel/StarterTemplateTest.php +++ /dev/null @@ -1,74 +0,0 @@ -container->get('extension.list.module')->getPath('ckeditor5'); - - $package_json_template = "$module_path/ckeditor5_plugin_starter_template/js/package.json"; - $package_json = "$module_path/package.json"; - $this->assertFileExists($package_json); - $this->assertFileExists($package_json_template); - - // Ensure that crucial parts of the package.json files match. - $this->assertSame($this->getCrucialPackageJsonSubsets($package_json), $this->getCrucialPackageJsonSubsets($package_json_template)); - - $webpack_config = "$module_path/ckeditor5_plugin_starter_template/js/webpack.config.js"; - $webpack_config_template = "$module_path/webpack.config.js"; - $this->assertFileExists($webpack_config); - $this->assertFileExists($webpack_config_template); - - $webpack_config_hash = md5_file($webpack_config); - $webpack_config_template_hash = md5_file($webpack_config_template); - - $this->assertSame('551c9cb2dc1a3615d6c142c2c76067b3', $webpack_config_hash, "This test has detected changes in $webpack_config. Please see if any of the changes made in this file should also be made in $webpack_config_template, an equivalent version of this file provided to module developers. Once it's confirmed these two files are current with one another, change the first argument in this test to $webpack_config_hash so it will pass."); - $this->assertSame('b28c2ee0b82e3cd154be4c6e20252210', $webpack_config_template_hash, "This test has detected changes in $webpack_config_template. Please see if any of the changes made in this file should also be made in $webpack_config, the file this template is based on. Once it's confirmed these two files are current with one another, change the first argument in this test to $webpack_config_template_hash so it will pass."); - - $manifest = "$module_path/js/drupal/scripts/manifest.js"; - $manifest_template = "$module_path/ckeditor5_plugin_starter_template/js/scripts/manifest.js"; - $this->assertFileExists($manifest); - $this->assertFileExists($manifest_template); - - $manifest_hash = md5_file($manifest); - $manifest_template_hash = md5_file($manifest_template); - - $this->assertSame('87964f6830ef1416c9da898659fc3adf', $manifest_hash, "This test has detected changes in $manifest. Please see if any of the changes made in this file should also be made in $manifest_template, an equivalent version of this file provided to module developers. Once it's confirmed these two files are current with one another, change the first argument in this test to $manifest_hash so it will pass."); - $this->assertSame('b83d7c7d1b882db654755020df7dfe6e', $manifest_template_hash, "This test has detected changes in $manifest_template. Please see if any of the changes made in this file should also be made in $manifest, the file this template is based on. Once it's confirmed these two files are current with one another, change the first argument in this test to $manifest_template_hash so it will pass."); - } - - /** - * Get crucial package.json subsets. - * - * @param string $package_json_path - * Path for a package.json file. - * - * @return array - * An array that include crucial parts of the package.json. - */ - protected static function getCrucialPackageJsonSubsets(string $package_json_path): array { - $safe_to_be_out_of_sync = ['name', 'version', 'description', 'author', 'license', 'scripts']; - $json = JSON::decode(file_get_contents($package_json_path)); - return array_diff_key($json, array_flip($safe_to_be_out_of_sync)); - } - -} diff --git a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php index 32040acacc..bdab04e2e9 100644 --- a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php +++ b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php @@ -74,6 +74,8 @@ class ResolvedLibraryDefinitionsFilesMatchTest extends KernelTestBase { protected $librariesToSkip = [ // Locale has a "dummy" library that does not actually exist. 'locale/translations', + // The "CKEditor 5 Dev tools" module has an external asset library. + 'ckeditor5_dev/ckeditor5_dev', ]; /**