Issue #3270734 by Wim Leers, longwave, andregp, bnjmnm: Update Editor + CKEditor 5 module to not use CKEditor 4 in tests
parent
3d9cd504c7
commit
f09840a74b
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Drupal\Tests\ckeditor5\FunctionalJavascript;
|
namespace Drupal\Tests\ckeditor\FunctionalJavascript;
|
||||||
|
|
||||||
use Drupal\ckeditor5\Plugin\Editor\CKEditor5;
|
use Drupal\ckeditor5\Plugin\Editor\CKEditor5;
|
||||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||||
|
@ -8,30 +8,46 @@ use Drupal\editor\Entity\Editor;
|
||||||
use Drupal\field\Entity\FieldConfig;
|
use Drupal\field\Entity\FieldConfig;
|
||||||
use Drupal\field\Entity\FieldStorageConfig;
|
use Drupal\field\Entity\FieldStorageConfig;
|
||||||
use Drupal\filter\Entity\FilterFormat;
|
use Drupal\filter\Entity\FilterFormat;
|
||||||
|
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||||
use Symfony\Component\Validator\ConstraintViolation;
|
use Symfony\Component\Validator\ConstraintViolation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that CKEditor 5 can be used on the same page with CKEditor 4.
|
* Ensures that CKEditor 5 can be used on the same page with CKEditor 4.
|
||||||
*
|
*
|
||||||
* @group ckeditor5
|
* @group ckeditor
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
class CKEditor5CKEditor4Compatibility extends CKEditor5TestBase {
|
class CKEditor5CKEditor4Compatibility extends WebDriverTestBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected static $modules = [
|
protected static $modules = [
|
||||||
'ckeditor',
|
'ckeditor',
|
||||||
|
'node',
|
||||||
|
'ckeditor5',
|
||||||
'ckeditor5_test',
|
'ckeditor5_test',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected $defaultTheme = 'stark';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function setUp(): void {
|
protected function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->drupalCreateContentType(['type' => 'page']);
|
||||||
|
|
||||||
|
$this->drupalLogin($this->drupalCreateUser([
|
||||||
|
'administer filters',
|
||||||
|
'create page content',
|
||||||
|
'edit own page content',
|
||||||
|
]));
|
||||||
|
|
||||||
$current_user_roles = $this->loggedInUser->getRoles(TRUE);
|
$current_user_roles = $this->loggedInUser->getRoles(TRUE);
|
||||||
|
|
||||||
// Create text format, text editor and text fields for CKEditor 5 and 4.
|
// Create text format, text editor and text fields for CKEditor 5 and 4.
|
|
@ -149,10 +149,13 @@ final class SmartDefaultSettings {
|
||||||
// if it exists.
|
// if it exists.
|
||||||
$old_editor = $editor->id() ? Editor::load($editor->id()) : NULL;
|
$old_editor = $editor->id() ? Editor::load($editor->id()) : NULL;
|
||||||
$old_editor_restrictions = $old_editor ? HTMLRestrictions::fromTextFormat($old_editor->getFilterFormat()) : HTMLRestrictions::emptySet();
|
$old_editor_restrictions = $old_editor ? HTMLRestrictions::fromTextFormat($old_editor->getFilterFormat()) : HTMLRestrictions::emptySet();
|
||||||
|
// @todo Remove in https://www.drupal.org/project/drupal/issues/3245351
|
||||||
|
if ($old_editor) {
|
||||||
|
$editor->setImageUploadSettings($old_editor->getImageUploadSettings());
|
||||||
|
}
|
||||||
if ($old_editor && $old_editor->getEditor() === 'ckeditor') {
|
if ($old_editor && $old_editor->getEditor() === 'ckeditor') {
|
||||||
[$upgraded_settings, $messages] = $this->createSettingsFromCKEditor4($old_editor->getSettings(), HTMLRestrictions::fromTextFormat($old_editor->getFilterFormat()));
|
[$upgraded_settings, $messages] = $this->createSettingsFromCKEditor4($old_editor->getSettings(), HTMLRestrictions::fromTextFormat($old_editor->getFilterFormat()));
|
||||||
$editor->setSettings($upgraded_settings);
|
$editor->setSettings($upgraded_settings);
|
||||||
$editor->setImageUploadSettings($old_editor->getImageUploadSettings());
|
|
||||||
// *Before* determining which elements are still needed for this text
|
// *Before* determining which elements are still needed for this text
|
||||||
// format, ensure that all already enabled plugins that are configurable
|
// format, ensure that all already enabled plugins that are configurable
|
||||||
// have valid settings.
|
// have valid settings.
|
||||||
|
|
|
@ -17,7 +17,7 @@ class AdminUiTest extends CKEditor5TestBase {
|
||||||
*/
|
*/
|
||||||
protected static $modules = [
|
protected static $modules = [
|
||||||
'media_library',
|
'media_library',
|
||||||
'ckeditor',
|
'editor_test',
|
||||||
'ckeditor5_incompatible_filter_test',
|
'ckeditor5_incompatible_filter_test',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class AdminUiTest extends CKEditor5TestBase {
|
||||||
$page = $this->getSession()->getPage();
|
$page = $this->getSession()->getPage();
|
||||||
$assert_session = $this->assertSession();
|
$assert_session = $this->assertSession();
|
||||||
$this->addNewTextFormat($page, $assert_session);
|
$this->addNewTextFormat($page, $assert_session);
|
||||||
$this->addNewTextFormat($page, $assert_session, 'ckeditor');
|
$this->addNewTextFormat($page, $assert_session, 'unicorn');
|
||||||
|
|
||||||
$this->drupalGet('admin/config/content/formats/manage/ckeditor5');
|
$this->drupalGet('admin/config/content/formats/manage/ckeditor5');
|
||||||
$number_ajax_instances_before = $this->getSession()->evaluateScript('Drupal.ajax.instances.length');
|
$number_ajax_instances_before = $this->getSession()->evaluateScript('Drupal.ajax.instances.length');
|
||||||
|
@ -47,7 +47,7 @@ class AdminUiTest extends CKEditor5TestBase {
|
||||||
|
|
||||||
// Perform the same steps as above with CKEditor, and confirm AJAX callbacks
|
// Perform the same steps as above with CKEditor, and confirm AJAX callbacks
|
||||||
// are not triggered on settings changes.
|
// are not triggered on settings changes.
|
||||||
$this->drupalGet('admin/config/content/formats/manage/ckeditor');
|
$this->drupalGet('admin/config/content/formats/manage/unicorn');
|
||||||
$number_ajax_instances_before = $this->getSession()->evaluateScript('Drupal.ajax.instances.length');
|
$number_ajax_instances_before = $this->getSession()->evaluateScript('Drupal.ajax.instances.length');
|
||||||
|
|
||||||
// Enable media embed to confirm a format not using CKEditor 5 will not
|
// Enable media embed to confirm a format not using CKEditor 5 will not
|
||||||
|
@ -105,7 +105,7 @@ class AdminUiTest extends CKEditor5TestBase {
|
||||||
public function testUnavailableFiltersHiddenWhenSwitching() {
|
public function testUnavailableFiltersHiddenWhenSwitching() {
|
||||||
$page = $this->getSession()->getPage();
|
$page = $this->getSession()->getPage();
|
||||||
$assert_session = $this->assertSession();
|
$assert_session = $this->assertSession();
|
||||||
$this->createNewTextFormat($page, $assert_session, 'ckeditor');
|
$this->createNewTextFormat($page, $assert_session, 'unicorn');
|
||||||
$assert_session->assertWaitOnAjaxRequest();
|
$assert_session->assertWaitOnAjaxRequest();
|
||||||
$assert_session->pageTextNotContains('Filter settings');
|
$assert_session->pageTextNotContains('Filter settings');
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class CKEditor5AllowedTagsTest extends CKEditor5TestBase {
|
||||||
*/
|
*/
|
||||||
protected static $modules = [
|
protected static $modules = [
|
||||||
'node',
|
'node',
|
||||||
'ckeditor',
|
'editor_test',
|
||||||
'ckeditor5',
|
'ckeditor5',
|
||||||
'media',
|
'media',
|
||||||
'media_library',
|
'media_library',
|
||||||
|
@ -37,18 +37,20 @@ class CKEditor5AllowedTagsTest extends CKEditor5TestBase {
|
||||||
protected $allowedElements = '<br> <p> <h2> <h3> <h4> <h5> <h6> <strong> <em>';
|
protected $allowedElements = '<br> <p> <h2> <h3> <h4> <h5> <h6> <strong> <em>';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default allowed elements when updating a non-CKEditor 5 editor.
|
* The default allowed elements for filter_html's "allowed_html" setting.
|
||||||
|
*
|
||||||
|
* @see \Drupal\filter\Plugin\Filter\FilterHtml
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $defaultElementsWhenUpdatingNotCkeditor5 = '<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> <img src alt data-entity-type data-entity-uuid>';
|
protected $defaultElementsWhenUpdatingNotCkeditor5 = "<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id>";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The expected allowed elements after updating to CKEditor5.
|
* The expected allowed elements after updating to CKEditor 5.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $defaultElementsAfterUpdatingToCkeditor5 = '<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <img src alt data-entity-type data-entity-uuid> <a hreflang href> <blockquote cite> <ul type> <ol type start> <strong> <em> <code> <li>';
|
protected $defaultElementsAfterUpdatingToCkeditor5 = '<br> <p> <h2 id="jump-*"> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol type="1 A I" start> <strong> <em> <code> <li>';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test enabling CKEditor 5 in a way that triggers validation.
|
* Test enabling CKEditor 5 in a way that triggers validation.
|
||||||
|
@ -60,8 +62,8 @@ class CKEditor5AllowedTagsTest extends CKEditor5TestBase {
|
||||||
$incompatible_filter_name = 'filters[filter_incompatible][status]';
|
$incompatible_filter_name = 'filters[filter_incompatible][status]';
|
||||||
$filter_warning = 'CKEditor 5 only works with HTML-based text formats. The "A TYPE_MARKUP_LANGUAGE filter incompatible with CKEditor 5" (filter_incompatible) filter implies this text format is not HTML anymore.';
|
$filter_warning = 'CKEditor 5 only works with HTML-based text formats. The "A TYPE_MARKUP_LANGUAGE filter incompatible with CKEditor 5" (filter_incompatible) filter implies this text format is not HTML anymore.';
|
||||||
|
|
||||||
$this->createNewTextFormat($page, $assert_session, 'ckeditor');
|
$this->createNewTextFormat($page, $assert_session, 'unicorn');
|
||||||
$page->selectFieldOption('editor[editor]', 'ckeditor');
|
$page->selectFieldOption('editor[editor]', 'unicorn');
|
||||||
$assert_session->assertWaitOnAjaxRequest();
|
$assert_session->assertWaitOnAjaxRequest();
|
||||||
$page->checkField('filters[filter_html][status]');
|
$page->checkField('filters[filter_html][status]');
|
||||||
$page->checkField($incompatible_filter_name);
|
$page->checkField($incompatible_filter_name);
|
||||||
|
@ -81,31 +83,16 @@ class CKEditor5AllowedTagsTest extends CKEditor5TestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that when image uploads are enabled in CKEditor 4, they remain in 5.
|
* Tests that when image uploads were enabled, they remain enabled.
|
||||||
*/
|
*/
|
||||||
public function testImageUploadsRemainEnabled(): void {
|
public function testImageUploadsRemainEnabled(): void {
|
||||||
FilterFormat::create([
|
FilterFormat::create([
|
||||||
'format' => 'cke4_image_uploads',
|
'format' => 'editor_with_image_uploads',
|
||||||
'name' => 'CKEditor 4, image uploads',
|
'name' => 'Text Editor with image uploads enabled',
|
||||||
])->save();
|
])->save();
|
||||||
Editor::create([
|
Editor::create([
|
||||||
'format' => 'cke4_image_uploads',
|
'format' => 'editor_with_image_uploads',
|
||||||
'editor' => 'ckeditor',
|
'editor' => 'unicorn',
|
||||||
'settings' => [
|
|
||||||
'toolbar' => [
|
|
||||||
'rows' => [
|
|
||||||
0 => [
|
|
||||||
[
|
|
||||||
'name' => 'Media',
|
|
||||||
'items' => [
|
|
||||||
'DrupalImage',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'plugins' => [],
|
|
||||||
],
|
|
||||||
'image_upload' => [
|
'image_upload' => [
|
||||||
'status' => TRUE,
|
'status' => TRUE,
|
||||||
'scheme' => 'public',
|
'scheme' => 'public',
|
||||||
|
@ -122,13 +109,19 @@ class CKEditor5AllowedTagsTest extends CKEditor5TestBase {
|
||||||
$assert_session = $this->assertSession();
|
$assert_session = $this->assertSession();
|
||||||
|
|
||||||
// Assert that image uploads are enabled initially.
|
// Assert that image uploads are enabled initially.
|
||||||
$this->drupalGet('admin/config/content/formats/manage/cke4_image_uploads');
|
$this->drupalGet('admin/config/content/formats/manage/editor_with_image_uploads');
|
||||||
$this->assertTrue($page->hasCheckedField('Enable image uploads'));
|
$this->assertTrue($page->hasCheckedField('Enable image uploads'));
|
||||||
|
|
||||||
// Switch the text format to CKEditor 5.
|
// Switch the text format to CKEditor 5.
|
||||||
$page->selectFieldOption('editor[editor]', 'ckeditor5');
|
$page->selectFieldOption('editor[editor]', 'ckeditor5');
|
||||||
$assert_session->assertWaitOnAjaxRequest();
|
$assert_session->assertWaitOnAjaxRequest();
|
||||||
|
|
||||||
|
// Enable the image toolbar item. This does NOT enable image uploads: it
|
||||||
|
// triggers the image upload settings form to become visible, to allow the
|
||||||
|
// image upload status to be checked.
|
||||||
|
$this->triggerKeyUp('.ckeditor5-toolbar-item-uploadImage', 'ArrowDown');
|
||||||
|
$assert_session->assertWaitOnAjaxRequest();
|
||||||
|
|
||||||
// Assert that image uploads are still enabled.
|
// Assert that image uploads are still enabled.
|
||||||
$this->assertTrue($page->hasCheckedField('Enable image uploads'));
|
$this->assertTrue($page->hasCheckedField('Enable image uploads'));
|
||||||
}
|
}
|
||||||
|
@ -140,7 +133,7 @@ class CKEditor5AllowedTagsTest extends CKEditor5TestBase {
|
||||||
$page = $this->getSession()->getPage();
|
$page = $this->getSession()->getPage();
|
||||||
$assert_session = $this->assertSession();
|
$assert_session = $this->assertSession();
|
||||||
|
|
||||||
$this->createNewTextFormat($page, $assert_session, 'ckeditor');
|
$this->createNewTextFormat($page, $assert_session, 'unicorn');
|
||||||
$assert_session->assertWaitOnAjaxRequest();
|
$assert_session->assertWaitOnAjaxRequest();
|
||||||
|
|
||||||
// Enable the HTML filter.
|
// Enable the HTML filter.
|
||||||
|
@ -148,15 +141,15 @@ class CKEditor5AllowedTagsTest extends CKEditor5TestBase {
|
||||||
$page->checkField('filters[filter_html][status]');
|
$page->checkField('filters[filter_html][status]');
|
||||||
$assert_session->assertWaitOnAjaxRequest();
|
$assert_session->assertWaitOnAjaxRequest();
|
||||||
|
|
||||||
// Confirm the allowed HTML tags are the defaults for non-Ckeditor5 editors.
|
// Confirm the allowed HTML tags are the defaults initially.
|
||||||
$this->assertHtmlEsqueFieldValueEquals('filters[filter_html][settings][allowed_html]', $this->defaultElementsWhenUpdatingNotCkeditor5);
|
$this->assertHtmlEsqueFieldValueEquals('filters[filter_html][settings][allowed_html]', $this->defaultElementsWhenUpdatingNotCkeditor5);
|
||||||
|
|
||||||
$this->saveNewTextFormat($page, $assert_session);
|
$this->saveNewTextFormat($page, $assert_session);
|
||||||
$assert_session->pageTextContains('Added text format ckeditor');
|
$assert_session->pageTextContains('Added text format unicorn');
|
||||||
|
|
||||||
// Return to the config form to confirm that switching text editors on
|
// Return to the config form to confirm that switching text editors on
|
||||||
// existing formats will properly switch allowed tags.
|
// existing formats will properly switch allowed tags.
|
||||||
$this->drupalGet('admin/config/content/formats/manage/ckeditor');
|
$this->drupalGet('admin/config/content/formats/manage/unicorn');
|
||||||
$assert_session->assertWaitOnAjaxRequest();
|
$assert_session->assertWaitOnAjaxRequest();
|
||||||
$this->assertHtmlEsqueFieldValueEquals('filters[filter_html][settings][allowed_html]', $this->defaultElementsWhenUpdatingNotCkeditor5);
|
$this->assertHtmlEsqueFieldValueEquals('filters[filter_html][settings][allowed_html]', $this->defaultElementsWhenUpdatingNotCkeditor5);
|
||||||
|
|
||||||
|
@ -167,24 +160,7 @@ class CKEditor5AllowedTagsTest extends CKEditor5TestBase {
|
||||||
|
|
||||||
$page->pressButton('Save configuration');
|
$page->pressButton('Save configuration');
|
||||||
|
|
||||||
$assert_session->pageTextContains('The Image upload toolbar item requires image uploads to be enabled.');
|
$assert_session->pageTextContains('The text format unicorn has been updated');
|
||||||
$page->clickLink('Image Upload');
|
|
||||||
$assert_session->waitForText('Enable image uploads');
|
|
||||||
$this->assertTrue($page->hasUncheckedField('editor[settings][plugins][ckeditor5_imageUpload][status]'));
|
|
||||||
$page->checkField('editor[settings][plugins][ckeditor5_imageUpload][status]');
|
|
||||||
$assert_session->assertWaitOnAjaxRequest();
|
|
||||||
$page->pressButton('Save configuration');
|
|
||||||
$this->assertSession()->pageTextContains('The following attribute(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Image (<img src alt data-entity-uuid data-entity-type>)');
|
|
||||||
|
|
||||||
$assert_session->assertWaitOnAjaxRequest();
|
|
||||||
$assert_session->waitForText('Manually editable HTML tags');
|
|
||||||
$source_edit_tags_field = $assert_session->fieldExists('editor[settings][plugins][ckeditor5_sourceEditing][allowed_tags]');
|
|
||||||
$source_edit_tags_field_value = $source_edit_tags_field->getValue();
|
|
||||||
$source_edit_tags_field->setValue(str_replace('<img src alt data-entity-type data-entity-uuid>', '', $source_edit_tags_field_value));
|
|
||||||
$assert_session->assertWaitOnAjaxRequest();
|
|
||||||
$page->pressButton('Save configuration');
|
|
||||||
|
|
||||||
$assert_session->pageTextContains('The text format ckeditor has been updated');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,17 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
use SchemaCheckTestTrait;
|
use SchemaCheckTestTrait;
|
||||||
use CKEditor5ValidationTestTrait;
|
use CKEditor5ValidationTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exempt from strict schema checking, because using CKEditor 4.
|
||||||
|
*
|
||||||
|
* The updated Text Format & Text Editors are explicitly checked.
|
||||||
|
*
|
||||||
|
* @see \Drupal\Core\Config\Development\ConfigSchemaChecker
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $strictConfigSchema = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The manager for "CKEditor 5 plugin" plugins.
|
* The manager for "CKEditor 5 plugin" plugins.
|
||||||
*
|
*
|
||||||
|
@ -55,8 +66,6 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected static $modules = [
|
protected static $modules = [
|
||||||
'ckeditor',
|
|
||||||
'ckeditor_test',
|
|
||||||
'ckeditor5',
|
'ckeditor5',
|
||||||
'editor',
|
'editor',
|
||||||
'filter',
|
'filter',
|
||||||
|
@ -90,17 +99,17 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
->save();
|
->save();
|
||||||
Editor::create(
|
Editor::create(
|
||||||
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.full_html.yml')
|
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.full_html.yml')
|
||||||
)->save();
|
)->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
$basic_html_format = Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/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();
|
FilterFormat::create($basic_html_format)->setSyncing(TRUE)->save();
|
||||||
Editor::create(
|
Editor::create(
|
||||||
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
||||||
)->save();
|
)->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
FilterFormat::create(
|
FilterFormat::create(
|
||||||
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/filter.format.restricted_html.yml')
|
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/filter.format.restricted_html.yml')
|
||||||
)->save();
|
)->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
$allowed_html_parents = ['filters', 'filter_html', 'settings', 'allowed_html'];
|
$allowed_html_parents = ['filters', 'filter_html', 'settings', 'allowed_html'];
|
||||||
$current_value = NestedArray::getValue($basic_html_format, $allowed_html_parents);
|
$current_value = NestedArray::getValue($basic_html_format, $allowed_html_parents);
|
||||||
|
@ -109,58 +118,58 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
$basic_html_format_without_h4_h6['name'] .= ' (without H4 and H6)';
|
$basic_html_format_without_h4_h6['name'] .= ' (without H4 and H6)';
|
||||||
$basic_html_format_without_h4_h6['format'] = 'basic_html_without_h4_h6';
|
$basic_html_format_without_h4_h6['format'] = 'basic_html_without_h4_h6';
|
||||||
NestedArray::setValue($basic_html_format_without_h4_h6, $allowed_html_parents, $new_value);
|
NestedArray::setValue($basic_html_format_without_h4_h6, $allowed_html_parents, $new_value);
|
||||||
FilterFormat::create($basic_html_format_without_h4_h6)->save();
|
FilterFormat::create($basic_html_format_without_h4_h6)->setSyncing(TRUE)->save();
|
||||||
Editor::create(
|
Editor::create(
|
||||||
['format' => 'basic_html_without_h4_h6']
|
['format' => 'basic_html_without_h4_h6']
|
||||||
+
|
+
|
||||||
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
||||||
)->save();
|
)->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
$new_value = str_replace(['<h2 id> ', '<h3 id> ', '<h4 id> ', '<h5 id> ', '<h6 id> '], '', $current_value);
|
$new_value = str_replace(['<h2 id> ', '<h3 id> ', '<h4 id> ', '<h5 id> ', '<h6 id> '], '', $current_value);
|
||||||
$basic_html_format_without_headings = $basic_html_format;
|
$basic_html_format_without_headings = $basic_html_format;
|
||||||
$basic_html_format_without_headings['name'] .= ' (without H*)';
|
$basic_html_format_without_headings['name'] .= ' (without H*)';
|
||||||
$basic_html_format_without_headings['format'] = 'basic_html_without_headings';
|
$basic_html_format_without_headings['format'] = 'basic_html_without_headings';
|
||||||
NestedArray::setValue($basic_html_format_without_headings, $allowed_html_parents, $new_value);
|
NestedArray::setValue($basic_html_format_without_headings, $allowed_html_parents, $new_value);
|
||||||
FilterFormat::create($basic_html_format_without_headings)->save();
|
FilterFormat::create($basic_html_format_without_headings)->setSyncing(TRUE)->save();
|
||||||
Editor::create(
|
Editor::create(
|
||||||
['format' => 'basic_html_without_headings']
|
['format' => 'basic_html_without_headings']
|
||||||
+
|
+
|
||||||
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
||||||
)->save();
|
)->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
$basic_html_format_with_pre = $basic_html_format;
|
$basic_html_format_with_pre = $basic_html_format;
|
||||||
$basic_html_format_with_pre['name'] .= ' (with <pre>)';
|
$basic_html_format_with_pre['name'] .= ' (with <pre>)';
|
||||||
$basic_html_format_with_pre['format'] = 'basic_html_with_pre';
|
$basic_html_format_with_pre['format'] = 'basic_html_with_pre';
|
||||||
NestedArray::setValue($basic_html_format_with_pre, $allowed_html_parents, $current_value . ' <pre>');
|
NestedArray::setValue($basic_html_format_with_pre, $allowed_html_parents, $current_value . ' <pre>');
|
||||||
FilterFormat::create($basic_html_format_with_pre)->save();
|
FilterFormat::create($basic_html_format_with_pre)->setSyncing(TRUE)->save();
|
||||||
Editor::create(
|
Editor::create(
|
||||||
['format' => 'basic_html_with_pre']
|
['format' => 'basic_html_with_pre']
|
||||||
+
|
+
|
||||||
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
||||||
)->save();
|
)->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
$basic_html_format_with_h1 = $basic_html_format;
|
$basic_html_format_with_h1 = $basic_html_format;
|
||||||
$basic_html_format_with_h1['name'] .= ' (with <h1>)';
|
$basic_html_format_with_h1['name'] .= ' (with <h1>)';
|
||||||
$basic_html_format_with_h1['format'] = 'basic_html_with_h1';
|
$basic_html_format_with_h1['format'] = 'basic_html_with_h1';
|
||||||
NestedArray::setValue($basic_html_format_with_h1, $allowed_html_parents, $current_value . ' <h1>');
|
NestedArray::setValue($basic_html_format_with_h1, $allowed_html_parents, $current_value . ' <h1>');
|
||||||
FilterFormat::create($basic_html_format_with_h1)->save();
|
FilterFormat::create($basic_html_format_with_h1)->setSyncing(TRUE)->save();
|
||||||
Editor::create(
|
Editor::create(
|
||||||
['format' => 'basic_html_with_h1']
|
['format' => 'basic_html_with_h1']
|
||||||
+
|
+
|
||||||
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
||||||
)->save();
|
)->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
$new_value = str_replace('<p>', '<p class="text-align-center text-align-justify">', $current_value);
|
$new_value = str_replace('<p>', '<p class="text-align-center text-align-justify">', $current_value);
|
||||||
$basic_html_format_with_alignable_p = $basic_html_format;
|
$basic_html_format_with_alignable_p = $basic_html_format;
|
||||||
$basic_html_format_with_alignable_p['name'] .= ' (with alignable paragraph support)';
|
$basic_html_format_with_alignable_p['name'] .= ' (with alignable paragraph support)';
|
||||||
$basic_html_format_with_alignable_p['format'] = 'basic_html_with_alignable_p';
|
$basic_html_format_with_alignable_p['format'] = 'basic_html_with_alignable_p';
|
||||||
NestedArray::setValue($basic_html_format_with_alignable_p, $allowed_html_parents, $new_value);
|
NestedArray::setValue($basic_html_format_with_alignable_p, $allowed_html_parents, $new_value);
|
||||||
FilterFormat::create($basic_html_format_with_alignable_p)->save();
|
FilterFormat::create($basic_html_format_with_alignable_p)->setSyncing(TRUE)->save();
|
||||||
Editor::create(
|
Editor::create(
|
||||||
['format' => 'basic_html_with_alignable_p']
|
['format' => 'basic_html_with_alignable_p']
|
||||||
+
|
+
|
||||||
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
||||||
)->save();
|
)->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
$basic_html_format_with_media_embed = $basic_html_format;
|
$basic_html_format_with_media_embed = $basic_html_format;
|
||||||
$basic_html_format_with_media_embed['name'] .= ' (with Media Embed support)';
|
$basic_html_format_with_media_embed['name'] .= ' (with Media Embed support)';
|
||||||
|
@ -169,7 +178,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
$basic_html_format_with_media_embed['filters']['media_embed'] = ['status' => TRUE];
|
$basic_html_format_with_media_embed['filters']['media_embed'] = ['status' => TRUE];
|
||||||
$new_value = $current_value . ' <drupal-media data-entity-type data-entity-uuid data-align data-caption alt>';
|
$new_value = $current_value . ' <drupal-media data-entity-type data-entity-uuid data-align data-caption alt>';
|
||||||
NestedArray::setValue($basic_html_format_with_media_embed, $allowed_html_parents, $new_value);
|
NestedArray::setValue($basic_html_format_with_media_embed, $allowed_html_parents, $new_value);
|
||||||
FilterFormat::create($basic_html_format_with_media_embed)->save();
|
FilterFormat::create($basic_html_format_with_media_embed)->setSyncing(TRUE)->save();
|
||||||
$basic_html_editor_with_media_embed = Editor::create(
|
$basic_html_editor_with_media_embed = Editor::create(
|
||||||
['format' => 'basic_html_with_media_embed']
|
['format' => 'basic_html_with_media_embed']
|
||||||
+
|
+
|
||||||
|
@ -180,7 +189,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
// pre-existing toolbar item group labeled "Media".
|
// pre-existing toolbar item group labeled "Media".
|
||||||
$settings['toolbar']['rows'][0][3]['items'][] = 'DrupalMediaLibrary';
|
$settings['toolbar']['rows'][0][3]['items'][] = 'DrupalMediaLibrary';
|
||||||
$basic_html_editor_with_media_embed->setSettings($settings);
|
$basic_html_editor_with_media_embed->setSettings($settings);
|
||||||
$basic_html_editor_with_media_embed->save();
|
$basic_html_editor_with_media_embed->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
$basic_html_format_with_media_embed_view_mode_invalid = $basic_html_format_with_media_embed;
|
$basic_html_format_with_media_embed_view_mode_invalid = $basic_html_format_with_media_embed;
|
||||||
$basic_html_format_with_media_embed_view_mode_invalid['name'] = ' (with Media Embed support, view mode enabled but no view modes configured)';
|
$basic_html_format_with_media_embed_view_mode_invalid['name'] = ' (with Media Embed support, view mode enabled but no view modes configured)';
|
||||||
|
@ -188,7 +197,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
$current_value_media_embed = NestedArray::getValue($basic_html_format_with_media_embed, $allowed_html_parents);
|
$current_value_media_embed = NestedArray::getValue($basic_html_format_with_media_embed, $allowed_html_parents);
|
||||||
$new_value = str_replace('<drupal-media data-entity-type data-entity-uuid data-align data-caption alt>', '<drupal-media data-entity-type data-entity-uuid data-align data-caption alt data-view-mode>', $current_value_media_embed);
|
$new_value = str_replace('<drupal-media data-entity-type data-entity-uuid data-align data-caption alt>', '<drupal-media data-entity-type data-entity-uuid data-align data-caption alt data-view-mode>', $current_value_media_embed);
|
||||||
NestedArray::setValue($basic_html_format_with_media_embed_view_mode_invalid, $allowed_html_parents, $new_value);
|
NestedArray::setValue($basic_html_format_with_media_embed_view_mode_invalid, $allowed_html_parents, $new_value);
|
||||||
FilterFormat::create($basic_html_format_with_media_embed_view_mode_invalid)->save();
|
FilterFormat::create($basic_html_format_with_media_embed_view_mode_invalid)->setSyncing(TRUE)->save();
|
||||||
$basic_html_editor_with_media_embed_view_mode_enabled_no_view_modes_configured = Editor::create(
|
$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']
|
['format' => 'basic_html_with_media_embed_view_mode_enabled_no_view_modes_configured']
|
||||||
+
|
+
|
||||||
|
@ -199,24 +208,24 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
// pre-existing toolbar item group labeled "Media".
|
// pre-existing toolbar item group labeled "Media".
|
||||||
$settings['toolbar']['rows'][0][3]['items'][] = 'DrupalMediaLibrary';
|
$settings['toolbar']['rows'][0][3]['items'][] = 'DrupalMediaLibrary';
|
||||||
$basic_html_editor_with_media_embed_view_mode_enabled_no_view_modes_configured->setSettings($settings);
|
$basic_html_editor_with_media_embed_view_mode_enabled_no_view_modes_configured->setSettings($settings);
|
||||||
$basic_html_editor_with_media_embed_view_mode_enabled_no_view_modes_configured->save();
|
$basic_html_editor_with_media_embed_view_mode_enabled_no_view_modes_configured->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
$new_value = str_replace('<img src alt height width data-entity-type data-entity-uuid data-align data-caption>', '<img src alt height width data-*>', $current_value);
|
$new_value = str_replace('<img src alt height width data-entity-type data-entity-uuid data-align data-caption>', '<img src alt height width data-*>', $current_value);
|
||||||
$basic_html_format_with_any_data_attr = $basic_html_format;
|
$basic_html_format_with_any_data_attr = $basic_html_format;
|
||||||
$basic_html_format_with_any_data_attr['name'] .= ' (with any data-* attribute on images)';
|
$basic_html_format_with_any_data_attr['name'] .= ' (with any data-* attribute on images)';
|
||||||
$basic_html_format_with_any_data_attr['format'] = 'basic_html_with_any_data_attr';
|
$basic_html_format_with_any_data_attr['format'] = 'basic_html_with_any_data_attr';
|
||||||
NestedArray::setValue($basic_html_format_with_any_data_attr, $allowed_html_parents, $new_value);
|
NestedArray::setValue($basic_html_format_with_any_data_attr, $allowed_html_parents, $new_value);
|
||||||
FilterFormat::create($basic_html_format_with_any_data_attr)->save();
|
FilterFormat::create($basic_html_format_with_any_data_attr)->setSyncing(TRUE)->save();
|
||||||
Editor::create(
|
Editor::create(
|
||||||
['format' => 'basic_html_with_any_data_attr']
|
['format' => 'basic_html_with_any_data_attr']
|
||||||
+
|
+
|
||||||
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
|
||||||
)->save();
|
)->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
$basic_html_format_with_media_embed_view_mode_enabled_two_view_modes_configured = $basic_html_format_with_media_embed_view_mode_invalid;
|
$basic_html_format_with_media_embed_view_mode_enabled_two_view_modes_configured = $basic_html_format_with_media_embed_view_mode_invalid;
|
||||||
$basic_html_format_with_media_embed_view_mode_enabled_two_view_modes_configured['name'] = ' (with Media Embed support, view mode enabled and two view modes configured )';
|
$basic_html_format_with_media_embed_view_mode_enabled_two_view_modes_configured['name'] = ' (with Media Embed support, view mode enabled and two view modes configured )';
|
||||||
$basic_html_format_with_media_embed_view_mode_enabled_two_view_modes_configured['format'] = 'basic_html_with_media_embed_view_mode_enabled_two_view_modes_configured';
|
$basic_html_format_with_media_embed_view_mode_enabled_two_view_modes_configured['format'] = 'basic_html_with_media_embed_view_mode_enabled_two_view_modes_configured';
|
||||||
FilterFormat::create($basic_html_format_with_media_embed_view_mode_enabled_two_view_modes_configured)->save();
|
FilterFormat::create($basic_html_format_with_media_embed_view_mode_enabled_two_view_modes_configured)->setSyncing(TRUE)->save();
|
||||||
$basic_html_editor_with_media_embed_view_mode_enabled_two_view_modes_configured = Editor::create(
|
$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']
|
['format' => 'basic_html_with_media_embed_view_mode_enabled_two_view_modes_configured']
|
||||||
+
|
+
|
||||||
|
@ -227,21 +236,21 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
// pre-existing toolbar item group labeled "Media".
|
// pre-existing toolbar item group labeled "Media".
|
||||||
$settings['toolbar']['rows'][0][3]['items'][] = 'DrupalMediaLibrary';
|
$settings['toolbar']['rows'][0][3]['items'][] = 'DrupalMediaLibrary';
|
||||||
$basic_html_editor_with_media_embed_view_mode_enabled_two_view_modes_configured->setSettings($settings);
|
$basic_html_editor_with_media_embed_view_mode_enabled_two_view_modes_configured->setSettings($settings);
|
||||||
$basic_html_editor_with_media_embed_view_mode_enabled_two_view_modes_configured->save();
|
$basic_html_editor_with_media_embed_view_mode_enabled_two_view_modes_configured->setSyncing(TRUE)->save();
|
||||||
EntityViewMode::create([
|
EntityViewMode::create([
|
||||||
'id' => 'media.view_mode_1',
|
'id' => 'media.view_mode_1',
|
||||||
'targetEntityType' => 'media',
|
'targetEntityType' => 'media',
|
||||||
'status' => TRUE,
|
'status' => TRUE,
|
||||||
'enabled' => TRUE,
|
'enabled' => TRUE,
|
||||||
'label' => 'View Mode 1',
|
'label' => 'View Mode 1',
|
||||||
])->save();
|
])->setSyncing(TRUE)->save();
|
||||||
EntityViewMode::create([
|
EntityViewMode::create([
|
||||||
'id' => 'media.view_mode_2',
|
'id' => 'media.view_mode_2',
|
||||||
'targetEntityType' => 'media',
|
'targetEntityType' => 'media',
|
||||||
'status' => TRUE,
|
'status' => TRUE,
|
||||||
'enabled' => TRUE,
|
'enabled' => TRUE,
|
||||||
'label' => 'View Mode 2',
|
'label' => 'View Mode 2',
|
||||||
])->save();
|
])->setSyncing(TRUE)->save();
|
||||||
$filter_format = FilterFormat::load('basic_html_with_media_embed_view_mode_enabled_two_view_modes_configured');
|
$filter_format = FilterFormat::load('basic_html_with_media_embed_view_mode_enabled_two_view_modes_configured');
|
||||||
$filter_format->setFilterConfig('media_embed', [
|
$filter_format->setFilterConfig('media_embed', [
|
||||||
'status' => TRUE,
|
'status' => TRUE,
|
||||||
|
@ -253,7 +262,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
'view_mode_2' => 'view_mode_2',
|
'view_mode_2' => 'view_mode_2',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
])->save();
|
])->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
$filter_plugin_manager = $this->container->get('plugin.manager.filter');
|
$filter_plugin_manager = $this->container->get('plugin.manager.filter');
|
||||||
FilterFormat::create([
|
FilterFormat::create([
|
||||||
|
@ -265,12 +274,12 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
'settings' => $filter_plugin_manager->getDefinition('filter_html')['settings'],
|
'settings' => $filter_plugin_manager->getDefinition('filter_html')['settings'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
])->save();
|
])->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
FilterFormat::create([
|
FilterFormat::create([
|
||||||
'format' => 'cke4_plugins_with_settings',
|
'format' => 'cke4_plugins_with_settings',
|
||||||
'name' => 'All CKEditor 4 core plugins with settings',
|
'name' => 'All CKEditor 4 core plugins with settings',
|
||||||
])->save();
|
])->setSyncing(TRUE)->save();
|
||||||
Editor::create([
|
Editor::create([
|
||||||
'format' => 'cke4_plugins_with_settings',
|
'format' => 'cke4_plugins_with_settings',
|
||||||
'editor' => 'ckeditor',
|
'editor' => 'ckeditor',
|
||||||
|
@ -310,7 +319,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
])->save();
|
])->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
FilterFormat::create([
|
FilterFormat::create([
|
||||||
'format' => 'cke4_stylescombo_span',
|
'format' => 'cke4_stylescombo_span',
|
||||||
|
@ -323,7 +332,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
] + $filter_plugin_manager->getDefinition('filter_html')['settings'],
|
] + $filter_plugin_manager->getDefinition('filter_html')['settings'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
])->save();
|
])->setSyncing(TRUE)->save();
|
||||||
Editor::create([
|
Editor::create([
|
||||||
'format' => 'cke4_stylescombo_span',
|
'format' => 'cke4_stylescombo_span',
|
||||||
'editor' => 'ckeditor',
|
'editor' => 'ckeditor',
|
||||||
|
@ -346,12 +355,12 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
])->save();
|
])->setSyncing(TRUE)->save();
|
||||||
|
|
||||||
FilterFormat::create([
|
FilterFormat::create([
|
||||||
'format' => 'cke4_contrib_plugins_now_in_core',
|
'format' => 'cke4_contrib_plugins_now_in_core',
|
||||||
'name' => 'All CKEditor 4 contrib plugins now in core',
|
'name' => 'All CKEditor 4 contrib plugins now in core',
|
||||||
])->save();
|
])->setSyncing(TRUE)->save();
|
||||||
Editor::create([
|
Editor::create([
|
||||||
'format' => 'cke4_contrib_plugins_now_in_core',
|
'format' => 'cke4_contrib_plugins_now_in_core',
|
||||||
'editor' => 'ckeditor',
|
'editor' => 'ckeditor',
|
||||||
|
@ -371,7 +380,7 @@ class SmartDefaultSettingsTest extends KernelTestBase {
|
||||||
],
|
],
|
||||||
'plugins' => [],
|
'plugins' => [],
|
||||||
],
|
],
|
||||||
])->save();
|
])->setSyncing(TRUE)->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Drupal\editor\Entity;
|
namespace Drupal\editor\Entity;
|
||||||
|
|
||||||
|
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
|
||||||
use Drupal\Core\Config\Entity\ConfigEntityBase;
|
use Drupal\Core\Config\Entity\ConfigEntityBase;
|
||||||
use Drupal\editor\EditorInterface;
|
use Drupal\editor\EditorInterface;
|
||||||
|
|
||||||
|
@ -90,8 +91,15 @@ class Editor extends ConfigEntityBase implements EditorInterface {
|
||||||
public function __construct(array $values, $entity_type) {
|
public function __construct(array $values, $entity_type) {
|
||||||
parent::__construct($values, $entity_type);
|
parent::__construct($values, $entity_type);
|
||||||
|
|
||||||
$plugin = $this->editorPluginManager()->createInstance($this->editor);
|
try {
|
||||||
$this->settings += $plugin->getDefaultSettings();
|
$plugin = $this->editorPluginManager()->createInstance($this->editor);
|
||||||
|
$this->settings += $plugin->getDefaultSettings();
|
||||||
|
}
|
||||||
|
catch (PluginNotFoundException $e) {
|
||||||
|
// When a Text Editor plugin has gone missing, still allow the Editor
|
||||||
|
// config entity to be constructed. The only difference is that default
|
||||||
|
// settings are not added.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,26 +4,9 @@ dependencies:
|
||||||
config:
|
config:
|
||||||
- filter.format.private_images
|
- filter.format.private_images
|
||||||
module:
|
module:
|
||||||
- ckeditor
|
- editor_test
|
||||||
format: private_images
|
format: private_images
|
||||||
editor: ckeditor
|
editor: unicorn
|
||||||
settings:
|
|
||||||
toolbar:
|
|
||||||
rows:
|
|
||||||
-
|
|
||||||
-
|
|
||||||
name: Media
|
|
||||||
items:
|
|
||||||
- DrupalImage
|
|
||||||
-
|
|
||||||
name: Tools
|
|
||||||
items:
|
|
||||||
- Source
|
|
||||||
plugins:
|
|
||||||
language:
|
|
||||||
language_list: un
|
|
||||||
stylescombo:
|
|
||||||
styles: ''
|
|
||||||
image_upload:
|
image_upload:
|
||||||
status: true
|
status: true
|
||||||
scheme: private
|
scheme: private
|
||||||
|
|
|
@ -39,9 +39,25 @@ class UnicornEditor extends EditorBase {
|
||||||
'#type' => 'checkbox',
|
'#type' => 'checkbox',
|
||||||
'#default_value' => TRUE,
|
'#default_value' => TRUE,
|
||||||
];
|
];
|
||||||
|
$form_state->loadInclude('editor', 'admin.inc');
|
||||||
|
$form['image_upload'] = editor_image_upload_settings_form($form_state->get('editor'));
|
||||||
|
$form['image_upload']['#element_validate'][] = [$this, 'validateImageUploadSettings'];
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #element_validate handler for "image_upload" in buildConfigurationForm().
|
||||||
|
*
|
||||||
|
* Moves the text editor's image upload settings into $editor->image_upload.
|
||||||
|
*
|
||||||
|
* @see editor_image_upload_settings_form()
|
||||||
|
*/
|
||||||
|
public function validateImageUploadSettings(array $element, FormStateInterface $form_state) {
|
||||||
|
$settings = &$form_state->getValue(['editor', 'settings', 'image_upload']);
|
||||||
|
$form_state->get('editor')->setImageUploadSettings($settings);
|
||||||
|
$form_state->unsetValue(['editor', 'settings', 'image_upload']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,7 +18,7 @@ class EditorDialogAccessTest extends BrowserTestBase {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $modules = ['editor', 'filter', 'ckeditor'];
|
protected static $modules = ['editor', 'filter', 'editor_test'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
@ -39,23 +39,8 @@ class EditorDialogAccessTest extends BrowserTestBase {
|
||||||
// With a text editor but without image upload settings, expect a 200, but
|
// With a text editor but without image upload settings, expect a 200, but
|
||||||
// there should not be an input[type=file].
|
// there should not be an input[type=file].
|
||||||
$editor = Editor::create([
|
$editor = Editor::create([
|
||||||
'editor' => 'ckeditor',
|
'editor' => 'unicorn',
|
||||||
'format' => 'plain_text',
|
'format' => 'plain_text',
|
||||||
'settings' => [
|
|
||||||
'toolbar' => [
|
|
||||||
'rows' => [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
'name' => 'Media',
|
|
||||||
'items' => [
|
|
||||||
'DrupalImage',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'plugins' => [],
|
|
||||||
],
|
|
||||||
'image_upload' => [
|
'image_upload' => [
|
||||||
'status' => FALSE,
|
'status' => FALSE,
|
||||||
'scheme' => 'public',
|
'scheme' => 'public',
|
||||||
|
|
|
@ -21,14 +21,12 @@ class EditorPrivateFileReferenceFilterTest extends BrowserTestBase {
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $modules = [
|
protected static $modules = [
|
||||||
// Needed for the config: this is the only module in core that utilizes the
|
'editor_test',
|
||||||
// functionality in editor.module to be tested, and depends on that.
|
|
||||||
'ckeditor',
|
|
||||||
// Depends on filter.module (indirectly).
|
// Depends on filter.module (indirectly).
|
||||||
'node',
|
'node',
|
||||||
// Pulls in the config we're using during testing which create a text format
|
// Pulls in the config we're using during testing which create a text format
|
||||||
// - with the filter_html_image_secure filter DISABLED,
|
// - with the filter_html_image_secure filter DISABLED,
|
||||||
// - with the editor set to CKEditor,
|
// - with the editor set to Unicorn editor,
|
||||||
// - with drupalimage.image_upload.scheme set to 'private',
|
// - with drupalimage.image_upload.scheme set to 'private',
|
||||||
// - with drupalimage.image_upload.directory set to ''.
|
// - with drupalimage.image_upload.directory set to ''.
|
||||||
'editor_private_test',
|
'editor_private_test',
|
||||||
|
|
|
@ -20,7 +20,7 @@ class EditorAdminTest extends WebDriverTestBase {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected static $modules = [
|
protected static $modules = [
|
||||||
'ckeditor',
|
'editor_test',
|
||||||
'ckeditor5',
|
'ckeditor5',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -53,18 +53,17 @@ class EditorAdminTest extends WebDriverTestBase {
|
||||||
$page->fillField('name', 'Sulaco');
|
$page->fillField('name', 'Sulaco');
|
||||||
// Wait for machine name to be filled in.
|
// Wait for machine name to be filled in.
|
||||||
$this->assertNotEmpty($assert_session->waitForText('sulaco'));
|
$this->assertNotEmpty($assert_session->waitForText('sulaco'));
|
||||||
$page->selectFieldOption('editor[editor]', 'ckeditor');
|
$page->selectFieldOption('editor[editor]', 'unicorn');
|
||||||
$this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', 'ul.ckeditor-toolbar-group-buttons'));
|
$this->assertNotEmpty($this->assertSession()->waitForField('editor[settings][ponies_too]'));
|
||||||
$this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', '#ckeditor-plugin-settings'));
|
|
||||||
$page->pressButton('Save configuration');
|
$page->pressButton('Save configuration');
|
||||||
|
|
||||||
// Test that toggling the editor selection off and back on works.
|
// Test that toggling the editor selection off and back on works.
|
||||||
$this->drupalGet('/admin/config/content/formats/manage/sulaco');
|
$this->drupalGet('/admin/config/content/formats/manage/sulaco');
|
||||||
// Deselect and reselect an editor.
|
// Deselect and reselect an editor.
|
||||||
$page->selectFieldOption('editor[editor]', '');
|
$page->selectFieldOption('editor[editor]', '');
|
||||||
$this->assertNotEmpty($this->assertSession()->waitForElementRemoved('css', 'ul.ckeditor-toolbar-group-buttons'));
|
$this->assertNotEmpty($this->assertSession()->waitForElementRemoved('named', ['field', 'editor[settings][ponies_too]']));
|
||||||
$page->selectFieldOption('editor[editor]', 'ckeditor');
|
$page->selectFieldOption('editor[editor]', 'unicorn');
|
||||||
$this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', 'ul.ckeditor-toolbar-group-buttons'));
|
$this->assertNotEmpty($this->assertSession()->waitForField('editor[settings][ponies_too]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,10 +83,11 @@ class EditorAdminTest extends WebDriverTestBase {
|
||||||
$this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', 'ul.ckeditor5-toolbar-available__buttons'));
|
$this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', 'ul.ckeditor5-toolbar-available__buttons'));
|
||||||
|
|
||||||
$page->selectFieldOption('editor[editor]', '');
|
$page->selectFieldOption('editor[editor]', '');
|
||||||
$assert_session->elementNotExists('css', 'ul.ckeditor-toolbar-group-buttons');
|
$this->assertNotEmpty($this->assertSession()->waitForElementRemoved('css', 'ul.ckeditor5-toolbar-available__buttons'));
|
||||||
|
$this->assertEmpty($this->assertSession()->waitForField('editor[settings][ponies_too]'));
|
||||||
|
|
||||||
$page->selectFieldOption('editor[editor]', 'ckeditor');
|
$page->selectFieldOption('editor[editor]', 'unicorn');
|
||||||
$this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', 'ul.ckeditor-toolbar-group-buttons'));
|
$this->assertNotEmpty($this->assertSession()->waitForField('editor[settings][ponies_too]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue