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
parent
e72c88fce4
commit
0c9c57f14c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.');
|
||||
}
|
||||
|
|
|
@ -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.');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue