Issue #3271097 by bnjmnm, xjm, Wim Leers, phenaproxima: Replace CKEditor 4 with CKEditor 5 in the Standard profile and StandardTest

(cherry picked from commit 9ca6256b8a)
(cherry picked from commit c61a652139)
merge-requests/2574/merge
Lauri Eskola 2022-08-25 23:37:53 +03:00
parent 790b8a6c57
commit 9600a0b13a
No known key found for this signature in database
GPG Key ID: 382FC0F5B0DF53F8
12 changed files with 350 additions and 92 deletions

View File

@ -0,0 +1,50 @@
langcode: en
status: true
dependencies:
config:
- filter.format.basic_html
module:
- ckeditor
format: basic_html
editor: ckeditor
settings:
toolbar:
rows:
-
-
name: Formatting
items:
- Bold
- Italic
-
name: Linking
items:
- DrupalLink
- DrupalUnlink
-
name: Lists
items:
- BulletedList
- NumberedList
-
name: Media
items:
- Blockquote
- DrupalImage
-
name: 'Block Formatting'
items:
- Format
-
name: Tools
items:
- Source
plugins: {}
image_upload:
status: true
scheme: public
directory: inline-images
max_size: ''
max_dimensions:
width: 0
height: 0

View File

@ -0,0 +1,58 @@
langcode: en
status: true
dependencies:
config:
- filter.format.full_html
module:
- ckeditor
format: full_html
editor: ckeditor
settings:
toolbar:
rows:
-
-
name: Formatting
items:
- Bold
- Italic
- Strike
- Superscript
- Subscript
- '-'
- RemoveFormat
-
name: Linking
items:
- DrupalLink
- DrupalUnlink
-
name: Lists
items:
- BulletedList
- NumberedList
-
name: Media
items:
- Blockquote
- DrupalImage
- Table
- HorizontalRule
-
name: 'Block Formatting'
items:
- Format
-
name: Tools
items:
- ShowBlocks
- Source
plugins: {}
image_upload:
status: true
scheme: public
directory: inline-images
max_size: ''
max_dimensions:
width: 0
height: 0

View File

@ -0,0 +1,44 @@
langcode: en
status: true
dependencies:
module:
- editor
name: 'Basic HTML'
format: basic_html
weight: 0
roles:
- authenticated
filters:
filter_html:
id: filter_html
provider: filter
status: true
weight: -10
settings:
allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <p> <br> <span> <img src alt height width data-entity-type data-entity-uuid data-align data-caption>'
filter_html_help: false
filter_html_nofollow: false
filter_align:
id: filter_align
provider: filter
status: true
weight: 7
settings: { }
filter_caption:
id: filter_caption
provider: filter
status: true
weight: 8
settings: { }
filter_html_image_secure:
id: filter_html_image_secure
provider: filter
status: true
weight: 9
settings: { }
editor_file_reference:
id: editor_file_reference
provider: editor
status: true
weight: 11
settings: { }

View File

@ -0,0 +1,35 @@
langcode: en
status: true
dependencies:
module:
- editor
name: 'Full HTML'
format: full_html
weight: 2
roles:
- administrator
filters:
filter_align:
id: filter_align
provider: filter
status: true
weight: 8
settings: { }
filter_caption:
id: filter_caption
provider: filter
status: true
weight: 9
settings: { }
filter_htmlcorrector:
id: filter_htmlcorrector
provider: filter
status: true
weight: 10
settings: { }
editor_file_reference:
id: editor_file_reference
provider: editor
status: true
weight: 11
settings: { }

View File

@ -0,0 +1,31 @@
langcode: en
status: true
dependencies: { }
name: 'Restricted HTML'
format: restricted_html
weight: 1
roles:
- anonymous
filters:
filter_html:
id: filter_html
provider: filter
status: true
weight: -10
settings:
allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>'
filter_html_help: true
filter_html_nofollow: false
filter_autop:
id: filter_autop
provider: filter
status: true
weight: 0
settings: { }
filter_url:
id: filter_url
provider: filter
status: true
weight: 0
settings:
filter_url_length: 72

View File

@ -84,22 +84,22 @@ class SmartDefaultSettingsTest extends KernelTestBase {
$this->installSchema('dblog', ['watchdog']);
FilterFormat::create(
Yaml::parseFile('core/profiles/standard/config/install/filter.format.full_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/filter.format.full_html.yml')
)
->setSyncing(TRUE)
->save();
Editor::create(
Yaml::parseFile('core/profiles/standard/config/install/editor.editor.full_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.full_html.yml')
)->save();
$basic_html_format = Yaml::parseFile('core/profiles/standard/config/install/filter.format.basic_html.yml');
$basic_html_format = Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/filter.format.basic_html.yml');
FilterFormat::create($basic_html_format)->save();
Editor::create(
Yaml::parseFile('core/profiles/standard/config/install/editor.editor.basic_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
)->save();
FilterFormat::create(
Yaml::parseFile('core/profiles/standard/config/install/filter.format.restricted_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/filter.format.restricted_html.yml')
)->save();
$allowed_html_parents = ['filters', 'filter_html', 'settings', 'allowed_html'];
@ -113,7 +113,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
Editor::create(
['format' => 'basic_html_without_h4_h6']
+
Yaml::parseFile('core/profiles/standard/config/install/editor.editor.basic_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
)->save();
$new_value = str_replace(['<h2 id> ', '<h3 id> ', '<h4 id> ', '<h5 id> ', '<h6 id> '], '', $current_value);
@ -125,7 +125,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
Editor::create(
['format' => 'basic_html_without_headings']
+
Yaml::parseFile('core/profiles/standard/config/install/editor.editor.basic_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
)->save();
$basic_html_format_with_pre = $basic_html_format;
@ -136,7 +136,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
Editor::create(
['format' => 'basic_html_with_pre']
+
Yaml::parseFile('core/profiles/standard/config/install/editor.editor.basic_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
)->save();
$basic_html_format_with_h1 = $basic_html_format;
@ -147,7 +147,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
Editor::create(
['format' => 'basic_html_with_h1']
+
Yaml::parseFile('core/profiles/standard/config/install/editor.editor.basic_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
)->save();
$new_value = str_replace('<p>', '<p class="text-align-center text-align-justify">', $current_value);
@ -159,7 +159,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
Editor::create(
['format' => 'basic_html_with_alignable_p']
+
Yaml::parseFile('core/profiles/standard/config/install/editor.editor.basic_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
)->save();
$basic_html_format_with_media_embed = $basic_html_format;
@ -173,7 +173,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
$basic_html_editor_with_media_embed = Editor::create(
['format' => 'basic_html_with_media_embed']
+
Yaml::parseFile('core/profiles/standard/config/install/editor.editor.basic_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
);
$settings = $basic_html_editor_with_media_embed->getSettings();
// Add "insert media from library" button to CKEditor 4 configuration, the
@ -192,7 +192,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
$basic_html_editor_with_media_embed_view_mode_enabled_no_view_modes_configured = Editor::create(
['format' => 'basic_html_with_media_embed_view_mode_enabled_no_view_modes_configured']
+
Yaml::parseFile('core/profiles/standard/config/install/editor.editor.basic_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
);
$settings = $basic_html_editor_with_media_embed_view_mode_enabled_no_view_modes_configured->getSettings();
// Add "insert media from library" button to CKEditor 4 configuration, the
@ -210,7 +210,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
Editor::create(
['format' => 'basic_html_with_any_data_attr']
+
Yaml::parseFile('core/profiles/standard/config/install/editor.editor.basic_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
)->save();
$basic_html_format_with_media_embed_view_mode_enabled_two_view_modes_configured = $basic_html_format_with_media_embed_view_mode_invalid;
@ -220,7 +220,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
$basic_html_editor_with_media_embed_view_mode_enabled_two_view_modes_configured = Editor::create(
['format' => 'basic_html_with_media_embed_view_mode_enabled_two_view_modes_configured']
+
Yaml::parseFile('core/profiles/standard/config/install/editor.editor.basic_html.yml')
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
);
$settings = $basic_html_editor_with_media_embed_view_mode_enabled_two_view_modes_configured->getSettings();
// Add "insert media from library" button to CKEditor 4 configuration, the

View File

@ -149,6 +149,12 @@ class HelpTest extends BrowserTestBase {
// Ensure there are no double escaped '&' or '<' characters.
$this->assertSession()->assertNoEscaped('&amp;');
$this->assertSession()->assertNoEscaped('&lt;');
// The help for CKEditor 5 intentionally has escaped '<' so leave this
// iteration before the assertion below.
if ($module === 'ckeditor5') {
continue;
}
// Ensure there are no escaped '<' characters.
$this->assertSession()->assertNoEscaped('<');
}

View File

@ -4,42 +4,56 @@ dependencies:
config:
- filter.format.basic_html
module:
- ckeditor
- ckeditor5
format: basic_html
editor: ckeditor
editor: ckeditor5
settings:
toolbar:
rows:
-
-
name: Formatting
items:
- Bold
- Italic
-
name: Linking
items:
- DrupalLink
- DrupalUnlink
-
name: Lists
items:
- BulletedList
- NumberedList
-
name: Media
items:
- Blockquote
- DrupalImage
-
name: 'Block Formatting'
items:
- Format
-
name: Tools
items:
- Source
plugins: {}
items:
- bold
- italic
- '|'
- link
- '|'
- bulletedList
- numberedList
- '|'
- blockQuote
- uploadImage
- '|'
- heading
- code
- '|'
- sourceEditing
plugins:
ckeditor5_heading:
enabled_headings:
- heading2
- heading3
- heading4
- heading5
- heading6
ckeditor5_sourceEditing:
allowed_tags:
- '<cite>'
- '<dl>'
- '<dt>'
- '<dd>'
- '<a hreflang>'
- '<blockquote cite>'
- '<ul type>'
- '<ol start type>'
- '<h2 id>'
- '<h3 id>'
- '<h4 id>'
- '<h5 id>'
- '<h6 id>'
- '<span>'
ckeditor5_list:
reversed: false
startIndex: true
ckeditor5_imageResize:
allow_resize: true
image_upload:
status: true
scheme: public

View File

@ -4,50 +4,48 @@ dependencies:
config:
- filter.format.full_html
module:
- ckeditor
- ckeditor5
format: full_html
editor: ckeditor
editor: ckeditor5
settings:
toolbar:
rows:
-
-
name: Formatting
items:
- Bold
- Italic
- Strike
- Superscript
- Subscript
- '-'
- RemoveFormat
-
name: Linking
items:
- DrupalLink
- DrupalUnlink
-
name: Lists
items:
- BulletedList
- NumberedList
-
name: Media
items:
- Blockquote
- DrupalImage
- Table
- HorizontalRule
-
name: 'Block Formatting'
items:
- Format
-
name: Tools
items:
- ShowBlocks
- Source
plugins: {}
items:
- bold
- italic
- strikethrough
- superscript
- subscript
- removeFormat
- '|'
- link
- '|'
- bulletedList
- numberedList
- '|'
- blockQuote
- uploadImage
- insertTable
- horizontalLine
- '|'
- heading
- codeBlock
- '|'
- sourceEditing
plugins:
ckeditor5_heading:
enabled_headings:
- heading2
- heading3
- heading4
- heading5
- heading6
ckeditor5_sourceEditing:
allowed_tags: { }
ckeditor5_list:
reversed: true
startIndex: true
ckeditor5_imageResize:
allow_resize: true
image_upload:
status: true
scheme: public

View File

@ -15,7 +15,7 @@ filters:
status: true
weight: -10
settings:
allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <p> <br> <span> <img src alt height width data-entity-type data-entity-uuid data-align data-caption>'
allowed_html: '<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <strong> <em> <code> <li> <span> <img src alt data-entity-uuid data-entity-type height width data-caption data-align>'
filter_html_help: false
filter_html_nofollow: false
filter_align:

View File

@ -7,7 +7,7 @@ install:
- history
- block
- breakpoint
- ckeditor
- ckeditor5
- config
- comment
- contextual

View File

@ -2,7 +2,9 @@
namespace Drupal\Tests\standard\Functional;
use Drupal\ckeditor5\Plugin\Editor\CKEditor5;
use Drupal\Component\Utility\Html;
use Drupal\editor\Entity\Editor;
use Drupal\media\Entity\MediaType;
use Drupal\media\Plugin\media\Source\Image;
use Drupal\Tests\SchemaCheckTestTrait;
@ -13,6 +15,7 @@ use Drupal\filter\Entity\FilterFormat;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\RequirementsPageTrait;
use Drupal\user\Entity\Role;
use Symfony\Component\Validator\ConstraintViolation;
/**
* Tests Standard installation profile expectations.
@ -106,10 +109,29 @@ class StandardTest extends BrowserTestBase {
$this->assertConfigSchema($typed_config, $name, $config->get());
}
// Validate all configuration.
// @todo Generalize in https://www.drupal.org/project/drupal/issues/2164373
foreach (Editor::loadMultiple() as $editor) {
// Currently only text editors using CKEditor 5 can be validated.
if ($editor->getEditor() !== 'ckeditor5') {
continue;
}
$this->assertSame([], array_map(
function (ConstraintViolation $v) {
return (string) $v->getMessage();
},
iterator_to_array(CKEditor5::validatePair(
$editor,
$editor->getFilterFormat()
))
));
}
// Ensure that configuration from the Standard profile is not reused when
// enabling a module again since it contains configuration that can not be
// installed. For example, editor.editor.basic_html is editor configuration
// that depends on the ckeditor module. The ckeditor module can not be
// that depends on the CKEditor 5 module. The CKEditor 5 module can not be
// installed before the editor module since it depends on the editor module.
// The installer does not have this limitation since it ensures that all of
// the install profiles dependencies are installed before creating the
@ -122,7 +144,7 @@ class StandardTest extends BrowserTestBase {
$filter->removeFilter('editor_file_reference');
$filter->save();
}
\Drupal::service('module_installer')->uninstall(['editor', 'ckeditor']);
\Drupal::service('module_installer')->uninstall(['editor', 'ckeditor5']);
$this->rebuildContainer();
\Drupal::service('module_installer')->install(['editor']);
/** @var \Drupal\contact\ContactFormInterface $contact_form */