Skip to content
Snippets Groups Projects
Unverified Commit 0c9c57f1 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2911527 by harsha012, b_sharpe, Chris Burge, Manav, jibran,...

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 e72c88fc
No related branches found
No related tags found
No related merge requests found
......@@ -141,7 +141,7 @@ protected function generateStylesSetSetting($styles) {
}
// 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 @@ public function testExistingFormat() {
// 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 @@ public function testExistingFormat() {
];
$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 @@ public function testStylesComboGetConfig() {
$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.');
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment