diff --git a/core/modules/ckeditor/ckeditor.admin.inc b/core/modules/ckeditor/ckeditor.admin.inc
index 7e3ae47..9adbe7b 100644
--- a/core/modules/ckeditor/ckeditor.admin.inc
+++ b/core/modules/ckeditor/ckeditor.admin.inc
@@ -74,9 +74,9 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) {
$button['language_direction'] = $language_direction;
// Check for the image button to be present and convert URI to URL.
- $rtl = $language_direction === 'rtl' ? '_rtl' : '';
- if (isset($button['image' . $rtl])) {
- $button['image_url'] = file_create_url($button['image' . $rtl]);
+ $suffix = $language_direction === 'rtl' ? '_rtl' : '';
+ if (isset($button['image' . $suffix])) {
+ $button['image_url'] = file_create_url($button['image' . $suffix]);
}
return $button;
};
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php
index 23f9c1c..cf7f26e 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php
@@ -53,10 +53,12 @@ public function getConfig(Editor $editor) {
* {@inheritdoc}
*/
public function getButtons() {
+ $language_direction = \Drupal::languageManager()->getCurrentLanguage()->direction;
+ $suffix = $language_direction === 'rtl' ? '_rtl' : '';
return array(
'DrupalImage' => array(
'label' => t('Image'),
- 'image' => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupalimage/image.png',
+ 'image' . $suffix => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupalimage/image.png',
),
);
}
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php
index 8ce0c7a..404dba2 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php
@@ -52,14 +52,16 @@ public function getConfig(Editor $editor) {
*/
public function getButtons() {
$path = drupal_get_path('module', 'ckeditor') . '/js/plugins/drupallink';
+ $language_direction = \Drupal::languageManager()->getCurrentLanguage()->direction;
+ $suffix = $language_direction === 'rtl' ? '_rtl' : '';
return array(
'DrupalLink' => array(
'label' => t('Link'),
- 'image' => $path . '/link.png',
+ 'image' . $suffix => $path . '/link.png',
),
'DrupalUnlink' => array(
'label' => t('Unlink'),
- 'image' => $path . '/unlink.png',
+ 'image' . $suffix => $path . '/unlink.png',
),
);
}
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
index c7450f8..60a5175 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
@@ -178,34 +178,28 @@ public function getButtons() {
'BulletedList' => array(
'label' => t('Bullet list'),
'image_alternative' => 'bulletedlist',
- 'image_alternative_rtl' => TRUE,
),
'NumberedList' => array(
'label' => t('Numbered list'),
'image_alternative' => 'numberedlist',
- 'image_alternative_rtl' => TRUE,
),
// "indent" plugin.
'Outdent' => array(
'label' => t('Outdent'),
'image_alternative' => 'outdent',
- 'image_alternative_rtl' => TRUE,
),
'Indent' => array(
'label' => t('Indent'),
'image_alternative' => 'indent',
- 'image_alternative_rtl' => TRUE,
),
// "undo" plugin.
'Undo' => array(
'label' => t('Undo'),
'image_alternative' => 'undo',
- 'image_alternative_rtl' => TRUE,
),
'Redo' => array(
'label' => t('Redo'),
'image_alternative' => 'redo',
- 'image_alternative_rtl' => TRUE,
),
// "blockquote" plugin.
'Blockquote' => array(
@@ -221,29 +215,24 @@ public function getButtons() {
'Cut' => array(
'label' => t('Cut'),
'image_alternative' => 'cut',
- 'image_alternative_rtl' => TRUE,
),
'Copy' => array(
'label' => t('Copy'),
'image_alternative' => 'copy',
- 'image_alternative_rtl' => TRUE,
),
'Paste' => array(
'label' => t('Paste'),
'image_alternative' => 'paste',
- 'image_alternative_rtl' => TRUE,
),
// "pastetext" plugin.
'PasteText' => array(
'label' => t('Paste Text'),
'image_alternative' => 'pastetext',
- 'image_alternative_rtl' => TRUE,
),
// "pastefromword" plugin.
'PasteFromWord' => array(
'label' => t('Paste from Word'),
'image_alternative' => 'pastefromword',
- 'image_alternative_rtl' => TRUE,
),
// "specialchar" plugin.
'SpecialChar' => array(
@@ -254,6 +243,7 @@ public function getButtons() {
'label' => t('HTML block format'),
'button_text' => t('Format'),
'image_alternative' => 'format',
+ 'is_dropdown' => TRUE,
),
// "table" plugin.
'Table' => array(
@@ -264,7 +254,6 @@ public function getButtons() {
'ShowBlocks' => array(
'label' => t('Show blocks'),
'image_alternative' => 'showblocks',
- 'image_alternative_rtl' => TRUE,
),
// "sourcearea" plugin.
'Source' => array(
@@ -281,6 +270,7 @@ public function getButtons() {
'label' => t('Separator'),
'image_alternative' => 'separator',
'button_text' => t('Button separator'),
+ 'is_separator' => TRUE,
'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 40fd9c4..f71d145 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php
@@ -61,6 +61,7 @@ public function getButtons() {
'label' => t('Font style'),
'button_text' => t('Styles'),
'image_alternative' => 'styles',
+ 'is_dropdown' => TRUE,
),
);
}
diff --git a/core/modules/ckeditor/templates/ckeditor-settings-toolbar.html.twig b/core/modules/ckeditor/templates/ckeditor-settings-toolbar.html.twig
index 5d85f50..e114a42 100644
--- a/core/modules/ckeditor/templates/ckeditor-settings-toolbar.html.twig
+++ b/core/modules/ckeditor/templates/ckeditor-settings-toolbar.html.twig
@@ -3,7 +3,21 @@
* @file
* Default theme implementation for the CKEditor settings toolbar.
*
+ * This template uses twig macro to create the CKEditor buttons.
+ * @see http://twig.sensiolabs.org/doc/tags/macro.html
+ *
* Available variables:
+ * - button: An array containing the CKEditor buttons.
+ * - image_alternative: HTML string representing the contents of this button.
+ * - is_dropdown: Flag for showing a dropdown type button (Optional). If the
+ * value is true then a dropdown button is generated.
+ * - is_separator: Flag for showing a separator "button" (Optional). If the
+ * value is true then a separator button is generated for the toolbar UI.
+ * - label: A human-readable, translated button name.
+ * - button_text: Same as label but this can be used as a custom button name.
+ * - language_direction: The direction, left-to-right, or right-to-left.
+ * - image_url: Image URL for the button. If the button is an image, then
+ * this has to be used.
* - multiple_buttons: A list of buttons that may be added multiple times.
* - disabled_buttons: A list of disabled buttons.
* - active_buttons: A list of active button rows.
@@ -14,30 +28,39 @@
*/
#}
{% macro button(button) %}
- {# Value of the button item. #}
+ {# Buttons with text as labels #}
{% if button.image_alternative %}
- {% if button.image_alternative in ['format', 'styles'] %}
+ {# Dropdown Buttons #}
+ {% if button.is_dropdown %}
{{ button.button_text }}
- {% elseif button.image_alternative == 'separator' %}
+ {# Separator Buttons #}
+ {% elseif button.is_separator %}
+ {# Normal Buttons #}
{% else %}
-
+
{{ button.label }}
{% endif %}
+ {# Buttons with image as labels #}
{% elseif button.image_url %}
+ {# Buttons with no text or image as labels #}
{% else %}
?
{% endif %}
{% endmacro %}
+{#
+ Reference the defined macro to be used in the same template.
+ @see http://twig.sensiolabs.org/doc/templates.html#global-variables
+#}
{% import _self as ckeditor %}
{% spaceless %}