Issue #2911527 by harsha012, b_sharpe, Chris Burge, Manav, jibran, Waldoswndrwrld, christinlepson, vacho, mttsmmrssprks, nicholasThompson, Wim Leers, othermachines, Sutharsan: Allow dashes in Styles dropdown's element names

merge-requests/2/head
Alex Pott 2020-07-31 18:22:24 +01:00
parent e72c88fce4
commit 0c9c57f14c
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
3 changed files with 17 additions and 4 deletions

View File

@ -141,7 +141,7 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
}
// Validate syntax: element[.class...]|label pattern expected.
if (!preg_match('@^ *[a-zA-Z0-9]+ *(\\.[a-zA-Z0-9_-]+ *)*\\| *.+ *$@', $style)) {
if (!preg_match('@^ *[a-zA-Z0-9-]+ *(\\.[a-zA-Z0-9_-]+ *)*\\| *.+ *$@', $style)) {
return FALSE;
}

View File

@ -80,10 +80,10 @@ class CKEditorStylesComboAdminTest extends BrowserTestBase {
// and ensure the updated settings are saved.
$this->drupalGet('admin/config/content/formats/manage/' . $this->format);
$edit = [
'editor[settings][plugins][stylescombo][styles]' => "h1.title|Title\np.callout|Callout\n\n",
'editor[settings][plugins][stylescombo][styles]' => "h1.title|Title\np.callout|Callout\ndrupal-entity.has-dashes|Allowing Dashes\n\n",
];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\n\n";
$expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\ndrupal-entity.has-dashes|Allowing Dashes\n\n";
$editor = Editor::load($this->format);
$this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
@ -96,7 +96,6 @@ class CKEditorStylesComboAdminTest extends BrowserTestBase {
];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->assertRaw(t('Each style must have a unique label.'));
$expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\n\n";
$editor = Editor::load($this->format);
$this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
}

View File

@ -369,6 +369,20 @@ class CKEditorTest extends KernelTestBase {
$editor->save();
$expected['stylesSet'] = FALSE;
$this->assertIdentical($expected, $stylescombo_plugin->getConfig($editor), '"StylesCombo" plugin configuration built correctly for customized toolbar.');
// Configuration that includes a dash in either the element or class name.
$settings['plugins']['stylescombo']['styles'] = "drupal-entity.has-dashes|Allowing Dashes";
$editor->setSettings($settings);
$editor->save();
$expected['stylesSet'] = [
[
'name' => 'Allowing Dashes',
'element' => 'drupal-entity',
'attributes' => ['class' => 'has-dashes'],
],
];
$this->assertIdentical($expected, $stylescombo_plugin->getConfig($editor), '"StylesCombo" plugin configuration built correctly for customized toolbar.');
}
/**