diff --git a/composer.json b/composer.json index eb2df1e8f825283906a85f7df677d1d063945b11..407701fe0499a8e821cc09e49cbdc5b483242302 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,9 @@ "php": ">=5.5.9", "composer/semver": "^1.0 || ^2.0 || ^3.0" }, + "require-dev": { + "league/commonmark": "^1.6" + }, "suggest": { "league/commonmark": "The PHP CommonMark parser is a robust, highly-extensible Markdown parser for PHP based on the CommonMark and Github-Flavored Markdown specifications." }, diff --git a/tests/src/Functional/FilterAdminTest.php b/tests/src/Functional/FilterAdminTest.php index 3059f5bac31fd85755ed2676a4c41517a0ffd2bb..f888f4202c6a96776f8ab22a80323cdeb41f280e 100644 --- a/tests/src/Functional/FilterAdminTest.php +++ b/tests/src/Functional/FilterAdminTest.php @@ -2,6 +2,8 @@ namespace Drupal\Tests\markdown\Functional; +use Drupal\editor\EditorInterface; +use Drupal\editor\Entity\Editor; use Drupal\filter\Entity\FilterFormat; use Drupal\filter\FilterFormatInterface; use Drupal\markdown\Plugin\Filter\FilterMarkdownInterface; @@ -60,4 +62,40 @@ class FilterAdminTest extends MarkdownBrowserTestBase { $this->assertTrue($markdown->isEnabled()); } + /** + * Tests creating a text format using CKEditor without the markdown filter. + */ + public function testCreateTextFormatWithoutMarkdownFilter() { + // Enable the CKEditor5 module. + $this->container->get('module_installer')->install(['ckeditor5']); + + // Add text format. + $this->drupalGet('admin/config/content/formats/add'); + + $format_id = $this->randomMachineName(); + $edit = [ + 'format' => $format_id, + 'name' => $this->randomMachineName(), + 'editor[editor]' => 'ckeditor5', + ]; + $this->submitForm($edit, 'Configure'); + + // Workaround for https://www.drupal.org/project/drupal/issues/3457717. + $edit = [ + 'editor[settings][toolbar][items]' => '["heading","bold","italic","drupalInsertImage"]', + ]; + $this->submitForm($edit, 'Configure'); + $this->submitForm([], 'Save configuration'); + $this->assertSession()->statusCodeEquals(200); + + // Check that the filter has been created. + $format = FilterFormat::load($format_id); + $this->assertInstanceof(FilterFormatInterface::class, $format); + + // Check that CKEditor5 is enabled for this format. + $editor = Editor::load($format_id); + $this->assertInstanceof(EditorInterface::class, $editor); + $this->assertEquals('ckeditor5', $editor->getEditor()); + } + }