diff --git a/core/modules/ckeditor/ckeditor.admin.inc b/core/modules/ckeditor/ckeditor.admin.inc
index 4ee12bb..21be21d 100644
--- a/core/modules/ckeditor/ckeditor.admin.inc
+++ b/core/modules/ckeditor/ckeditor.admin.inc
@@ -7,7 +7,6 @@
use Drupal\Component\Utility\Html;
use Drupal\Core\Template\Attribute;
-use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Language\LanguageInterface;
/**
@@ -66,10 +65,10 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) {
$build_button_item = function($button, $rtl) {
// Value of the button item.
if (isset($button['image_alternative' . $rtl])) {
- $value = SafeMarkup::set($button['image_alternative' . $rtl]);
+ $value = $button['image_alternative' . $rtl];
}
elseif (isset($button['image_alternative'])) {
- $value = SafeMarkup::set($button['image_alternative']);
+ $value = $button['image_alternative'];
}
elseif (isset($button['image'])) {
$value = array(
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
index c405c7f..2385511 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
@@ -127,7 +127,18 @@ public function getConfig(Editor $editor) {
*/
public function getButtons() {
$button = function($name, $direction = 'ltr') {
- return '' . $name . '';
+ // In the markup below, we mostly use the name (which may include spaces),
+ // but in one spot we use it as a CSS class, so strip spaces.
+ $class_name = str_replace(' ', '', $name);
+ return [
+ '#type' => 'inline_template',
+ '#template' => '{{ name }}',
+ '#context' => [
+ 'direction' => $direction,
+ 'name' => $name,
+ 'classname' => $class_name,
+ ],
+ ];
};
return array(
@@ -256,7 +267,13 @@ public function getButtons() {
),
'Format' => array(
'label' => t('HTML block format'),
- 'image_alternative' => '' . t('Format') . '',
+ 'image_alternative' => [
+ '#type' => 'inline_template',
+ '#template' => '{{ format_text }}',
+ '#context' => [
+ 'format_text' => t('Format'),
+ ],
+ ],
),
// "table" plugin.
'Table' => array(
@@ -282,7 +299,13 @@ public function getButtons() {
// No plugin, separator "button" for toolbar builder UI use only.
'-' => array(
'label' => t('Separator'),
- 'image_alternative' => '',
+ 'image_alternative' => [
+ '#type' => 'inline_template',
+ '#template' => '',
+ '#context' => [
+ 'button_separator_text' => t('Button separator'),
+ ],
+ ],
'attributes' => array(
'class' => array('ckeditor-button-separator'),
'data-drupal-ckeditor-type' => 'separator',
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php
index d569930..d3eb49f 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php
@@ -59,7 +59,13 @@ public function getButtons() {
return array(
'Styles' => array(
'label' => t('Font style'),
- 'image_alternative' => '' . t('Styles') . '',
+ 'image_alternative' => [
+ '#type' => 'inline_template',
+ '#template' => '{{ styles_text }}',
+ '#context' => [
+ 'styles_text' => t('Styles'),
+ ],
+ ],
),
);
}
diff --git a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
index 3ce8271..58a5b07 100644
--- a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
+++ b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
@@ -176,6 +176,19 @@ function testExistingFormat() {
$this->assertTrue($editor instanceof Editor, 'An Editor config entity exists.');
$this->assertIdentical($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
+ // Check that the markup we're setting for the toolbar buttons (actually in
+ // JavaScript's drupalSettings, and Unicode-escaped) is correctly rendered.
+ $this->drupalGet('admin/config/content/formats/manage/filtered_html');
+ $this->verbose($this->content);
+ // Check the Button separator.
+ $this->assertRaw('\u003Cli data-drupal-ckeditor-button-name=\u0022-\u0022 class=\u0022ckeditor-button-separator ckeditor-multiple-button\u0022 data-drupal-ckeditor-type=\u0022separator\u0022\u003E\u003Ca href=\u0022#\u0022 role=\u0022button\u0022 aria-label=\u0022Button separator\u0022 class=\u0022ckeditor-separator\u0022\u003E\u003C\/a\u003E\u003C\/li\u003E');
+ // Check the Format dropdown.
+ $this->assertRaw('\u003Cli data-drupal-ckeditor-button-name=\u0022Format\u0022 class=\u0022ckeditor-button\u0022\u003E\u003Ca href=\u0022#\u0022 role=\u0022button\u0022 aria-label=\u0022Format\u0022\u003E\u003Cspan class=\u0022ckeditor-button-dropdown\u0022\u003EFormat\u003Cspan class=\u0022ckeditor-button-arrow\u0022\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/a\u003E\u003C\/li\u003E');
+ // Check the Styles dropdown.
+ $this->assertRaw('\u003Cli data-drupal-ckeditor-button-name=\u0022Styles\u0022 class=\u0022ckeditor-button\u0022\u003E\u003Ca href=\u0022#\u0022 role=\u0022button\u0022 aria-label=\u0022Styles\u0022\u003E\u003Cspan class=\u0022ckeditor-button-dropdown\u0022\u003EStyles\u003Cspan class=\u0022ckeditor-button-arrow\u0022\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/a\u003E\u003C\/li\u003E');
+ // Check strikethrough.
+ $this->assertRaw('\u003Cli data-drupal-ckeditor-button-name=\u0022Strike\u0022 class=\u0022ckeditor-button\u0022\u003E\u003Ca href=\u0022#\u0022 class=\u0022cke-icon-only cke_ltr\u0022 role=\u0022button\u0022 title=\u0022strike\u0022 aria-label=\u0022strike\u0022\u003E\u003Cspan class=\u0022cke_button_icon cke_button__strike_icon\u0022\u003Estrike\u003C\/span\u003E\u003C\/a\u003E\u003C\/li\u003E');
+
// Now enable the ckeditor_test module, which provides one configurable
// CKEditor plugin — this should not affect the Editor config entity.
\Drupal::service('module_installer')->install(array('ckeditor_test'));