Issue #1872206 by jessebeach, quicksketch, Wim Leers, mgifford: Fixed Improve CKEditor toolbar configuration accessibility.
parent
a6efca1da2
commit
5fd14ba7e3
|
@ -30,18 +30,29 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) {
|
|||
$buttons[$button_name] = $button;
|
||||
}
|
||||
}
|
||||
$button_groups = array();
|
||||
$variables['active_buttons'] = array();
|
||||
foreach ($editor->settings['toolbar']['buttons'] as $row_number => $row) {
|
||||
foreach ($row as $button_name) {
|
||||
if (isset($buttons[$button_name])) {
|
||||
$variables['active_buttons'][$row_number][] = $buttons[$button_name];
|
||||
if (empty($buttons[$button_name]['multiple'])) {
|
||||
unset($buttons[$button_name]);
|
||||
foreach ($editor->settings['toolbar']['rows'] as $row_number => $row) {
|
||||
$button_groups[$row_number] = array();
|
||||
foreach ($row as $group) {
|
||||
foreach ($group['items'] as $button_name) {
|
||||
if (isset($buttons[$button_name])) {
|
||||
// Save a reference to the button's configured toolbar group.
|
||||
$buttons[$button_name]['group'] = $group['name'];
|
||||
$variables['active_buttons'][$row_number][] = $buttons[$button_name];
|
||||
if (empty($buttons[$button_name]['multiple'])) {
|
||||
unset($buttons[$button_name]);
|
||||
}
|
||||
// Create a list of all the toolbar button groups.
|
||||
if (!in_array($group['name'], $button_groups[$row_number])) {
|
||||
array_push($button_groups[$row_number], $group['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$variables['disabled_buttons'] = array_diff_key($buttons, $variables['multiple_buttons']);
|
||||
$variables['button_groups'] = $button_groups;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +77,7 @@ function theme_ckeditor_settings_toolbar($variables) {
|
|||
'#uri' => $button['image' . $rtl],
|
||||
'#title' => $button['label'],
|
||||
);
|
||||
$value = '<a href="#" class="cke_button" role="button" title="' . $button['label'] . '" aria-label="' . $button['label'] . '"><span class="cke_button_icon">' . drupal_render($image) . '</span></a>';
|
||||
$value = '<a href="#" role="button" title="' . $button['label'] . '" aria-label="' . $button['label'] . '"><span class="cke_button_icon">' . drupal_render($image) . '</span></a>';
|
||||
}
|
||||
else {
|
||||
$value = '?';
|
||||
|
@ -80,8 +91,13 @@ function theme_ckeditor_settings_toolbar($variables) {
|
|||
// Build the button item.
|
||||
$button_item = array(
|
||||
'value' => $value,
|
||||
'data-button-name' => $button['name'],
|
||||
'data-drupal-ckeditor-button-name' => $button['name'],
|
||||
'class' => array('ckeditor-button'),
|
||||
);
|
||||
// If this button has group information, add it to the attributes.
|
||||
if (!empty($button['group'])) {
|
||||
$button_item['group'] = $button['group'];
|
||||
}
|
||||
if (!empty($button['attributes'])) {
|
||||
$button_item = array_merge($button_item, $button['attributes']);
|
||||
}
|
||||
|
@ -110,6 +126,7 @@ function theme_ckeditor_settings_toolbar($variables) {
|
|||
$print_buttons = function($buttons) {
|
||||
$output = '';
|
||||
foreach ($buttons as $button) {
|
||||
unset($button['group']);
|
||||
$value = $button['value'];
|
||||
unset($button['value']);
|
||||
$attributes = (string) new Attribute($button);
|
||||
|
@ -118,6 +135,19 @@ function theme_ckeditor_settings_toolbar($variables) {
|
|||
return $output;
|
||||
};
|
||||
|
||||
$print_button_group = function($buttons, $group_name, $print_buttons) {
|
||||
$group = drupal_html_class($group_name);
|
||||
|
||||
$output = '';
|
||||
$output .= "<li class=\"ckeditor-toolbar-group\" role=\"presentation\" data-drupal-ckeditor-type=\"group\" data-drupal-ckeditor-toolbar-group-name=\"{$group_name}\" tabindex=\"0\">";
|
||||
$output .= "<h3 class=\"ckeditor-toolbar-group-name\" id=\"ckeditor-toolbar-group-aria-label-for-{$group}\">{$group_name}</h3>";
|
||||
$output .= "<ul class=\"ckeditor-buttons ckeditor-toolbar-group-buttons\" role=\"toolbar\" data-drupal-ckeditor-button-sorting=\"target\" aria-labelledby=\"ckeditor-toolbar-group-aria-label-for-{$group}\">";
|
||||
$output .= $print_buttons($buttons);
|
||||
$output .= "</ul></li>";
|
||||
|
||||
return $output;
|
||||
};
|
||||
|
||||
// We don't use theme_item_list() below in case there are no buttons in the
|
||||
// active or disabled list, as theme_item_list() will not print an empty UL.
|
||||
$output = '';
|
||||
|
@ -125,43 +155,45 @@ function theme_ckeditor_settings_toolbar($variables) {
|
|||
$output .= '<legend id="ckeditor-button-configuration">' . t('Toolbar configuration') . '</legend>';
|
||||
$output .= '<div class="fieldset-wrapper">';
|
||||
|
||||
// aria-live region for outputing aural information about the state of the
|
||||
// configuration.
|
||||
$output .= '<div id="ckeditor-button-configuration-aria-live" class="visually-hidden" aria-live="polite"></div>';
|
||||
|
||||
$output .= '<div id="ckeditor-button-description" class="fieldset-description">' . t('Move a button into the <em>Active toolbar</em> to enable it, or into the list of <em>Available buttons</em> to disable it. Use dividers to create button groups. Buttons may be moved with the mouse or keyboard arrow keys.') . '</div>';
|
||||
$output .= '<div id="ckeditor-button-description" class="fieldset-description">' . t('Move a button into the <em>Active toolbar</em> to enable it, or into the list of <em>Available buttons</em> to disable it. Buttons may be moved with the mouse or keyboard arrow keys. Toolbar group names are provided to support screen reader users. Empty toolbar groups will be removed upon save.') . '</div>';
|
||||
|
||||
$output .= '<div class="ckeditor-toolbar-disabled clearfix">';
|
||||
$output .= '<div class="ckeditor-toolbar-dividers">';
|
||||
$output .= '<label id="ckeditor-multiple-label">' . t('Dividers') . '</label>';
|
||||
$output .= '<ul class="ckeditor-multiple-buttons" role="form" aria-labelledby="ckeditor-multiple-label">';
|
||||
$output .= $print_buttons($multiple_buttons);
|
||||
$output .= '</ul>';
|
||||
$output .= '</div>';
|
||||
$output .= '<label id="ckeditor-available-buttons">' . t('Available buttons') . '</label>';
|
||||
$output .= '<ul class="ckeditor-buttons" role="form" aria-labelledby="ckeditor-available-buttons">';
|
||||
// Available buttons.
|
||||
$output .= '<div class="ckeditor-toolbar-available">';
|
||||
$output .= '<label for="ckeditor-available-buttons">' . t('Available buttons') . '</label>';
|
||||
$output .= '<ul id="ckeditor-available-buttons" class="ckeditor-buttons" role="form" data-drupal-ckeditor-button-sorting="source">';
|
||||
$output .= $print_buttons($disabled_buttons);
|
||||
$output .= '</ul>';
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '<label id="ckeditor-active-toolbar">' . t('Active toolbar') . '</label>';
|
||||
|
||||
$output .= '<div data-toolbar="active" class="ckeditor-toolbar-active clearfix">';
|
||||
foreach ($active_buttons as $button_row) {
|
||||
$output .= '<ul class="ckeditor-buttons" role="form" aria-labelledby="ckeditor-active-toolbar">';
|
||||
$output .= $print_buttons($button_row);
|
||||
// Dividers.
|
||||
$output .= '<div class="ckeditor-toolbar-dividers">';
|
||||
$output .= '<label for="ckeditor-multiple-buttons">' . t('Button divider') . '</label>';
|
||||
$output .= '<ul id="ckeditor-multiple-buttons" class="ckeditor-multiple-buttons" role="form" data-drupal-ckeditor-button-sorting="dividers">';
|
||||
$output .= $print_buttons($multiple_buttons);
|
||||
$output .= '</ul>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
// Active toolbar.
|
||||
$output .= '<div class="clearfix"><label id="ckeditor-active-toolbar">' . t('Active toolbar') . '</label></div>';
|
||||
$output .= '<div data-toolbar="active" role="form" class="ckeditor-toolbar ckeditor-toolbar-active clearfix">';
|
||||
$output .= '<ul class="ckeditor-active-toolbar-configuration" role="presentation" aria-label="' . t('CKEditor toolbar and button configuration.') . '">';
|
||||
foreach ($active_buttons as $row_number => $button_row) {
|
||||
$output .= '<li class="ckeditor-row" role="group" aria-labelledby="ckeditor-active-toolbar">';
|
||||
$output .= '<ul class="ckeditor-toolbar-groups clearfix">';
|
||||
foreach ($variables['button_groups'][$row_number] as $group_name) {
|
||||
$buttons = array_filter($button_row, function ($button) use ($group_name) {
|
||||
return $button['group'] === $group_name;
|
||||
});
|
||||
$output .= $print_button_group($buttons, $group_name, $print_buttons);
|
||||
}
|
||||
$output .= '</ul>';
|
||||
$output .= '</li>';
|
||||
}
|
||||
if (empty($active_buttons)) {
|
||||
$output .= '<ul class="ckeditor-buttons">';
|
||||
$output .= '</ul>';
|
||||
}
|
||||
|
||||
$output .= '<div class="ckeditor-row-controls">';
|
||||
$output .= '<a href="#" role="button" aria-label="' . t('Remove last button row') . '" class="ckeditor-row-remove" title="' . t('Remove row') . '">-</a>';
|
||||
$output .= '<a href="#" role="button" aria-label="' . t('Add additional button row') . '" class="ckeditor-row-add" title="' . t('Add row') . '">+</a>';
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
|
|
@ -76,9 +76,11 @@ function ckeditor_library_info() {
|
|||
array('system', 'jquery.ui.sortable'),
|
||||
array('system', 'jquery.ui.draggable'),
|
||||
array('system', 'jquery.ui.touch-punch'),
|
||||
array('system', 'backbone'),
|
||||
array('system', 'drupal.dialog'),
|
||||
array('system', 'drupal.announce'),
|
||||
array('ckeditor', 'ckeditor'),
|
||||
array('editor', 'drupal.editor.admin'),
|
||||
array('system', 'underscore'),
|
||||
// Depend on Vertical Tabs, so that Vertical Tabs' JavaScript is executed
|
||||
// first, which ensures its behavior runs first.
|
||||
array('system', 'drupal.vertical-tabs'),
|
||||
|
|
|
@ -8,15 +8,25 @@ editor.settings.ckeditor:
|
|||
type: mapping
|
||||
label: 'Toolbar configuration'
|
||||
mapping:
|
||||
buttons:
|
||||
rows:
|
||||
type: sequence
|
||||
label: 'Rows'
|
||||
sequence:
|
||||
- type: sequence
|
||||
label: 'Buttons'
|
||||
label: 'Button groups'
|
||||
sequence:
|
||||
- type: string
|
||||
label: 'Button'
|
||||
- type: mapping
|
||||
label: 'Button group'
|
||||
mapping:
|
||||
name:
|
||||
type: string
|
||||
label: 'Button group name'
|
||||
items:
|
||||
type: sequence
|
||||
label: 'Buttons'
|
||||
sequence:
|
||||
- type: string
|
||||
label: 'Button'
|
||||
plugins:
|
||||
type: sequence
|
||||
label: 'Plugins'
|
||||
|
|
|
@ -6,151 +6,252 @@
|
|||
* "moono".
|
||||
*/
|
||||
|
||||
.ckeditor-toolbar-active {
|
||||
|
||||
|
||||
.ckeditor-toolbar {
|
||||
border: 1px solid #b6b6b6;
|
||||
padding: 6px 8px 2px;
|
||||
padding: 0.1667em 0.1667em 0.08em;
|
||||
box-shadow: 0 1px 0 white inset;
|
||||
background: #cfd1cf;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(whiteSmoke), to(#cfd1cf));
|
||||
background-image: -webkit-linear-gradient(top, whiteSmoke, #cfd1cf);
|
||||
background-image: -moz-linear-gradient(top, whiteSmoke, #cfd1cf);
|
||||
background-image: -o-linear-gradient(top, whiteSmoke, #cfd1cf);
|
||||
background-image: -ms-linear-gradient(top, whiteSmoke, #cfd1cf);
|
||||
background-image: linear-gradient(top, whiteSmoke, #cfd1cf);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#fff5f5f5', endColorstr='#ffcfd1cf');
|
||||
margin: 5px 0;
|
||||
overflow: nowrap;
|
||||
/* Disallow any user selections in the drag-and-drop toolbar config UI. */
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
.ckeditor-toolbar-active > ul {
|
||||
clear: left; /* LTR */
|
||||
.ckeditor-toolbar-active {
|
||||
margin-top: 0.25em;
|
||||
}
|
||||
.ckeditor-toolbar-disabled {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.ckeditor-toolbar ul,
|
||||
.ckeditor-toolbar-disabled ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.ckeditor-row {
|
||||
padding: 2px 0px 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.ckeditor-group-names-are-visible .ckeditor-row {
|
||||
border: 1px solid whitesmoke;
|
||||
}
|
||||
.ckeditor-row + .ckeditor-row {
|
||||
margin-top: 0.25em;
|
||||
}
|
||||
.ckeditor-toolbar-group,
|
||||
.ckeditor-toolbar-group-placeholder,
|
||||
.ckeditor-add-new-group {
|
||||
display: inline-block;
|
||||
float: left; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .ckeditor-toolbar-active > ul {
|
||||
clear: right;
|
||||
[dir="rtl"] .ckeditor-toolbar-group,
|
||||
[dir="rtl"] .ckeditor-toolbar-group-placeholder,
|
||||
[dir="rtl"] .ckeditor-add-new-group {
|
||||
display: inline-block;
|
||||
float: right;
|
||||
}
|
||||
.ckeditor-toolbar-groups {
|
||||
min-height: 2em;
|
||||
}
|
||||
.ckeditor-toolbar-group {
|
||||
margin: 0 0.3333em;
|
||||
cursor: move;
|
||||
}
|
||||
.ckeditor-group-names-are-visible .ckeditor-toolbar-group,
|
||||
.ckeditor-add-new-group {
|
||||
border: 1px dotted #a6a6a6;
|
||||
border-radius: 3px;
|
||||
padding: 0.2em 0.4em;
|
||||
}
|
||||
.ckeditor-toolbar-group.placeholder,
|
||||
.ckeditor-toolbar-group.placeholder .ckeditor-toolbar-group-name {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.ckeditor-toolbar-group.placeholder .ckeditor-toolbar-group-name {
|
||||
font-style: italic;
|
||||
}
|
||||
.ckeditor-toolbar-group-name {
|
||||
display: none;
|
||||
font-size: 1em;
|
||||
font-weight: normal;
|
||||
margin: 0.25em 0;
|
||||
}
|
||||
.ckeditor-group-names-are-visible .ckeditor-toolbar-group-name {
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
}
|
||||
.ckeditor-toolbar-active .placeholder,
|
||||
.ckeditor-toolbar-active .ckeditor-add-new-group {
|
||||
display: none;
|
||||
}
|
||||
.ckeditor-group-names-are-visible .placeholder,
|
||||
.ckeditor-group-names-are-visible .ckeditor-add-new-group {
|
||||
display: block;
|
||||
}
|
||||
.ckeditor-toolbar-group-buttons {
|
||||
float: left; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .ckeditor-toolbar-group-buttons {
|
||||
float: right;
|
||||
}
|
||||
.ckeditor-groupnames-toggle {
|
||||
cursor: pointer;
|
||||
float: right; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .ckeditor-groupnames-toggle {
|
||||
float: left;
|
||||
}
|
||||
.ckeditor-toolbar .ckeditor-toolbar-group > li {
|
||||
border: 1px solid white;
|
||||
border-radius: 5px;
|
||||
background-image: -webkit-linear-gradient(transparent 60%, rgba(0, 0, 0, 0.1));
|
||||
background-image: -moz-linear-gradient(transparent 60%, rgba(0, 0, 0, 0.1));
|
||||
background-image: linear-gradient(transparent 60%, rgba(0, 0, 0, 0.1));
|
||||
margin: 3px 6px;
|
||||
padding: 3px;
|
||||
}
|
||||
#ckeditor-button-description {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.ckeditor-toolbar-disabled .ckeditor-toolbar-available,
|
||||
.ckeditor-toolbar-disabled .ckeditor-toolbar-dividers {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.ckeditor-toolbar-disabled .ckeditor-toolbar-available {
|
||||
float: left;
|
||||
width: 80%;
|
||||
}
|
||||
.ckeditor-toolbar-disabled .ckeditor-toolbar-dividers {
|
||||
float: right;
|
||||
width: 20%;
|
||||
}
|
||||
.ckeditor-toolbar-disabled .ckeditor-buttons li a,
|
||||
.ckeditor-toolbar .ckeditor-buttons,
|
||||
.ckeditor-add-new-group button {
|
||||
border: 1px solid #a6a6a6;
|
||||
border-bottom-color: #979797;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5), 0 0 2px rgba(255, 255, 255, 0.15) inset, 0 1px 0 rgba(255, 255, 255, 0.15) inset;
|
||||
}
|
||||
.ckeditor-toolbar-disabled .ckeditor-buttons {
|
||||
border: 0;
|
||||
}
|
||||
.ckeditor-toolbar-disabled .ckeditor-buttons li {
|
||||
margin: 2px;
|
||||
}
|
||||
.ckeditor-buttons {
|
||||
min-height: 26px;
|
||||
min-width: 26px;
|
||||
}
|
||||
.ckeditor-buttons li {
|
||||
display: inline-block;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
float: left; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .ckeditor-buttons li {
|
||||
float: right;
|
||||
}
|
||||
.ckeditor-buttons li a,
|
||||
.ckeditor-add-new-group button {
|
||||
background: #e4e4e4;
|
||||
background-image: -moz-linear-gradient(top, white, #e4e4e4);
|
||||
background-image: -webkit-linear-gradient(top, white, #e4e4e4);
|
||||
background-image: linear-gradient(top, white, #e4e4e4);
|
||||
color: #474747;
|
||||
}
|
||||
.ckeditor-buttons li a {
|
||||
border: 0;
|
||||
cursor: move;
|
||||
display: block;
|
||||
height: 18px;
|
||||
padding: 4px 6px;
|
||||
position: relative;
|
||||
text-decoration: none;
|
||||
text-shadow: 0 1px 0 rgba(255,255,255,.5);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.ckeditor-toolbar-dividers {
|
||||
float: right; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .ckeditor-toolbar-dividers {
|
||||
float: left;
|
||||
}
|
||||
.ckeditor-toolbar-disabled ul.ckeditor-buttons {
|
||||
border: 0;
|
||||
}
|
||||
.ckeditor-toolbar-disabled ul.ckeditor-buttons li {
|
||||
margin: 2px;
|
||||
}
|
||||
.ckeditor-toolbar-disabled ul.ckeditor-buttons li a,
|
||||
ul.ckeditor-buttons {
|
||||
border: 1px solid #a6a6a6;
|
||||
border-bottom-color: #979797;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 1px 0 rgba(255, 255, 255, .5), 0 0 2px rgba(255, 255, 255, .15) inset, 0 1px 0 rgba(255, 255, 255, .15) inset;
|
||||
}
|
||||
|
||||
ul.ckeditor-buttons {
|
||||
min-height: 26px;
|
||||
min-width: 26px;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0 6px 5px 0;
|
||||
border: 1px solid #a6a6a6;
|
||||
border-bottom-color: #979797;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 1px 0 rgba(255, 255, 255, .5), 0 0 2px rgba(255, 255, 255, .15) inset, 0 1px 0 rgba(255, 255, 255, .15) inset;
|
||||
}
|
||||
ul.ckeditor-buttons li {
|
||||
display: inline-block;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
float: left; /* LTR */
|
||||
}
|
||||
[dir="rtl"] ul.ckeditor-buttons li {
|
||||
float: right;
|
||||
}
|
||||
ul.ckeditor-buttons li a {
|
||||
position: relative;
|
||||
display: block;
|
||||
height: 18px;
|
||||
padding: 4px 6px;
|
||||
cursor: move;
|
||||
border: 0;
|
||||
white-space: nowrap;
|
||||
text-decoration: none;
|
||||
text-shadow: 0 1px 0 rgba(255,255,255,.5);
|
||||
color: #474747;
|
||||
background: #e4e4e4;
|
||||
background-image: -webkit-gradient(linear,left top,left bottom,from(white),to(#e4e4e4));
|
||||
background-image: -moz-linear-gradient(top,white,#e4e4e4);
|
||||
background-image: -webkit-linear-gradient(top,white,#e4e4e4);
|
||||
background-image: -o-linear-gradient(top,white,#e4e4e4);
|
||||
background-image: -ms-linear-gradient(top,white,#e4e4e4);
|
||||
background-image: linear-gradient(top,white,#e4e4e4);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0,startColorstr='#ffffffff',endColorstr='#ffe4e4e4');
|
||||
}
|
||||
ul.ckeditor-buttons li .cke-icon-only {
|
||||
.ckeditor-buttons li .cke-icon-only {
|
||||
text-indent: -9999px;
|
||||
width: 16px;
|
||||
/* Firefox includes the offscreen text in the focus indicator, resulting in a
|
||||
far too wide focus indicator. This fixes that. */
|
||||
overflow: hidden;
|
||||
}
|
||||
ul.ckeditor-buttons li a:focus,
|
||||
ul.ckeditor-multiple-buttons li a:focus {
|
||||
.ckeditor-buttons li a:focus,
|
||||
.ckeditor-buttons li a:active,
|
||||
.ckeditor-multiple-buttons li a:focus {
|
||||
z-index: 11; /* Ensure focused buttons show their outline on all sides. */
|
||||
outline: 1px dotted #333;
|
||||
}
|
||||
ul.ckeditor-buttons li:first-child a {
|
||||
.ckeditor-buttons li:first-child a {
|
||||
border-top-left-radius: 2px; /* LTR */
|
||||
border-bottom-left-radius: 2px; /* LTR */
|
||||
}
|
||||
[dir="rtl"] ul.ckeditor-buttons li:first-child a {
|
||||
[dir="rtl"] .ckeditor-buttons li:first-child a {
|
||||
border-top-right-radius: 2px;
|
||||
border-bottom-right-radius: 2px;
|
||||
}
|
||||
ul.ckeditor-buttons li:last-child a {
|
||||
.ckeditor-buttons li:last-child a {
|
||||
border-top-right-radius: 2px; /* LTR */
|
||||
border-bottom-right-radius: 2px; /* LTR */
|
||||
}
|
||||
[dir="rtl"] ul.ckeditor-buttons li:last-child a {
|
||||
[dir="rtl"] .ckeditor-buttons li:last-child a {
|
||||
border-top-left-radius: 2px;
|
||||
border-bottom-left-radius: 2px;
|
||||
}
|
||||
ul.ckeditor-buttons li.ckeditor-button-placeholder a {
|
||||
background: #333;
|
||||
opacity: 0.3;
|
||||
.ckeditor-button-placeholder,
|
||||
.ckeditor-toolbar-group-placeholder {
|
||||
background: #9dcae7;
|
||||
}
|
||||
ul.ckeditor-multiple-buttons {
|
||||
.ckeditor-toolbar-group-placeholder {
|
||||
border-radius: 4px;
|
||||
}
|
||||
.ckeditor-multiple-buttons {
|
||||
padding: 1px 2px;
|
||||
margin: 5px;
|
||||
list-style: none;
|
||||
float: left; /* LTR */
|
||||
}
|
||||
[dir="rtl"] ul.ckeditor-multiple-buttons {
|
||||
[dir="rtl"] .ckeditor-multiple-buttons {
|
||||
float: right;
|
||||
}
|
||||
ul.ckeditor-multiple-buttons li {
|
||||
.ckeditor-multiple-buttons li {
|
||||
display: inline-block;
|
||||
float: left; /* LTR */
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
[dir="rtl"] ul.ckeditor-multiple-buttons li {
|
||||
[dir="rtl"] .ckeditor-multiple-buttons li {
|
||||
float: right;
|
||||
}
|
||||
ul.ckeditor-multiple-buttons li a {
|
||||
.ckeditor-multiple-buttons li a {
|
||||
cursor: move;
|
||||
display: inline-block;
|
||||
height: 18px;
|
||||
margin: 0;
|
||||
padding: 2px 0;
|
||||
}
|
||||
ul.ckeditor-buttons li.ckeditor-group-button-separator,
|
||||
ul.ckeditor-multiple-buttons li.ckeditor-group-button-separator {
|
||||
.ckeditor-buttons .ckeditor-group-button-separator,
|
||||
.ckeditor-multiple-buttons .ckeditor-group-button-separator {
|
||||
margin: -1px -3px -2px;
|
||||
}
|
||||
ul.ckeditor-buttons li.ckeditor-group-button-separator a,
|
||||
ul.ckeditor-multiple-buttons li.ckeditor-group-button-separator a {
|
||||
.ckeditor-buttons .ckeditor-group-button-separator a,
|
||||
.ckeditor-multiple-buttons .ckeditor-group-button-separator a {
|
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAdCAMAAABG4xbVAAAAhFBMVEUAAACmpqampqampqb////l5eX////5+fmmpqatra2urq6vr6+1tbW2tra4uLi6urq8vLzb29ve3t7i4uLl5eXn5+fo6Ojp6enq6urr6+vs7Ozt7e3u7u7v7+/w8PDx8fHy8vLz8/P09PT19fX29vb39/f4+Pj5+fn6+vr7+/v8/Pz+/v7qIQO+AAAACHRSTlMATVmAi8XM29MuWToAAABjSURBVBiVrc5BCoAwDETRMKhtRBduev9LKm1xjItWRBBE6Nt9QkIwOTcUzk0Imi8aoMssxbgoTHMtqsFMLta0vPh2N49HyfdelPg6k9uvX/a+Bmggt1qJRNzQFVgjEnkUZDoBmH57VSypjg4AAAAASUVORK5CYII=) no-repeat center center;
|
||||
width: 13px;
|
||||
padding: 0;
|
||||
|
@ -161,6 +262,7 @@ ul.ckeditor-multiple-buttons li.ckeditor-group-button-separator a {
|
|||
ul.ckeditor-buttons li.ckeditor-button-separator a {
|
||||
background: #e4e4e4;
|
||||
background-image: -webkit-linear-gradient(#e4e4e4, #b4b4b4);
|
||||
background-image: -moz-linear-gradient(#e4e4e4, #b4b4b4);
|
||||
background-image: linear-gradient(#e4e4e4, #b4b4b4);
|
||||
height: 24px;
|
||||
margin: 1px 0 0;
|
||||
|
@ -169,7 +271,7 @@ ul.ckeditor-buttons li.ckeditor-button-separator a {
|
|||
width: 1px;
|
||||
z-index: 10;
|
||||
}
|
||||
ul.ckeditor-multiple-buttons li.ckeditor-button-separator a {
|
||||
.ckeditor-multiple-buttons .ckeditor-button-separator a {
|
||||
width: 2px;
|
||||
padding: 0;
|
||||
height: 26px;
|
||||
|
@ -177,12 +279,12 @@ ul.ckeditor-multiple-buttons li.ckeditor-button-separator a {
|
|||
}
|
||||
.ckeditor-separator {
|
||||
background-color: silver;
|
||||
background-color: rgba(0, 0, 0, .2);
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
margin: 5px 0;
|
||||
height: 18px;
|
||||
width: 1px;
|
||||
display: block;
|
||||
box-shadow: 1px 0 1px rgba(255, 255, 255, .5)
|
||||
box-shadow: 1px 0 1px rgba(255, 255, 255, 0.5)
|
||||
}
|
||||
.ckeditor-button-arrow {
|
||||
width: 0;
|
||||
|
@ -193,7 +295,6 @@ ul.ckeditor-multiple-buttons li.ckeditor-button-separator a {
|
|||
display: inline-block;
|
||||
margin: 0 4px 2px;
|
||||
}
|
||||
|
||||
.ckeditor-row-controls {
|
||||
float: right; /* LTR */
|
||||
font-size: 18px;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -65,7 +65,14 @@ class CKEditorPluginManager extends DefaultPluginManager {
|
|||
*/
|
||||
public function getEnabledPluginFiles(Editor $editor, $include_internal_plugins = FALSE) {
|
||||
$plugins = array_keys($this->getDefinitions());
|
||||
$toolbar_buttons = array_unique(NestedArray::mergeDeepArray($editor->settings['toolbar']['buttons']));
|
||||
// Flatten each row.
|
||||
$toolbar_rows = array();
|
||||
foreach ($editor->settings['toolbar']['rows'] as $row_number => $row) {
|
||||
$toolbar_rows[] = array_reduce($editor->settings['toolbar']['rows'][$row_number], function (&$result, $button_group) {
|
||||
return array_merge($result, $button_group['items']);
|
||||
}, array());
|
||||
}
|
||||
$toolbar_buttons = array_unique(NestedArray::mergeDeepArray($toolbar_rows));
|
||||
$enabled_plugins = array();
|
||||
$additional_plugins = array();
|
||||
|
||||
|
|
|
@ -77,11 +77,17 @@ class DrupalImageCaption extends PluginBase implements CKEditorPluginInterface,
|
|||
// text editor uses the filter_caption filter and the DrupalImage button is
|
||||
// enabled.
|
||||
if (isset($filters['filter_caption']) && $filters['filter_caption']->status) {
|
||||
foreach ($editor->settings['toolbar']['buttons'] as $row) {
|
||||
if (in_array('DrupalImage', $row)) {
|
||||
return TRUE;
|
||||
$enabled = FALSE;
|
||||
foreach ($editor->settings['toolbar']['rows'] as $row) {
|
||||
foreach ($row as $group) {
|
||||
foreach ($group['items'] as $button) {
|
||||
if ($button === 'DrupalImage') {
|
||||
$enabled = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $enabled;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
|
@ -55,7 +55,13 @@ class Internal extends CKEditorPluginBase {
|
|||
$config['allowedContent'] = $this->generateAllowedContentSetting($editor);
|
||||
|
||||
// Add the format_tags setting, if its button is enabled.
|
||||
$toolbar_buttons = array_unique(NestedArray::mergeDeepArray($editor->settings['toolbar']['buttons']));
|
||||
$toolbar_rows = array();
|
||||
foreach ($editor->settings['toolbar']['rows'] as $row_number => $row) {
|
||||
$toolbar_rows[] = array_reduce($editor->settings['toolbar']['rows'][$row_number], function (&$result, $button_group) {
|
||||
return array_merge($result, $button_group['items']);
|
||||
}, array());
|
||||
}
|
||||
$toolbar_buttons = array_unique(NestedArray::mergeDeepArray($toolbar_rows));
|
||||
if (in_array('Format', $toolbar_buttons)) {
|
||||
$config['format_tags'] = $this->generateFormatTagsSetting($editor);
|
||||
}
|
||||
|
@ -220,17 +226,14 @@ class Internal extends CKEditorPluginBase {
|
|||
'label' => t('Maximize'),
|
||||
'image_alternative' => $button('maximize'),
|
||||
),
|
||||
// No plugin, separator "buttons" for toolbar builder UI use only.
|
||||
'|' => array(
|
||||
'label' => t('Group separator'),
|
||||
'image_alternative' => '<a href="#" role="button" aria-label="' . t('Button group separator') . '" class="ckeditor-group-separator"></a>',
|
||||
'attributes' => array('class' => array('ckeditor-group-button-separator')),
|
||||
'multiple' => TRUE,
|
||||
),
|
||||
// No plugin, separator "button" for toolbar builder UI use only.
|
||||
'-' => array(
|
||||
'label' => t('Separator'),
|
||||
'image_alternative' => '<a href="#" role="button" aria-label="' . t('Button separator') . '" class="ckeditor-separator"></a>',
|
||||
'attributes' => array('class' => array('ckeditor-button-separator')),
|
||||
'attributes' => array(
|
||||
'class' => array('ckeditor-button-separator'),
|
||||
'data-drupal-ckeditor-type' => 'separator',
|
||||
),
|
||||
'multiple' => TRUE,
|
||||
),
|
||||
);
|
||||
|
|
|
@ -94,13 +94,29 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
public function getDefaultSettings() {
|
||||
return array(
|
||||
'toolbar' => array(
|
||||
'buttons' => array(
|
||||
'rows' => array(
|
||||
// Button groups.
|
||||
array(
|
||||
'Bold', 'Italic',
|
||||
'|', 'DrupalLink', 'DrupalUnlink',
|
||||
'|', 'BulletedList', 'NumberedList',
|
||||
'|', 'Blockquote', 'DrupalImage',
|
||||
'|', 'Source',
|
||||
array(
|
||||
'name' => t('Formatting'),
|
||||
'items' => array('Bold', 'Italic',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Links'),
|
||||
'items' => array('DrupalLink', 'DrupalUnlink',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Lists'),
|
||||
'items' => array('BulletedList', 'NumberedList',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Media'),
|
||||
'items' => array('Blockquote', 'DrupalImage',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Tools'),
|
||||
'items' => array('Source',),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -132,10 +148,11 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
),
|
||||
'#attributes' => array('class' => array('ckeditor-toolbar-configuration')),
|
||||
);
|
||||
$form['toolbar']['buttons'] = array(
|
||||
|
||||
$form['toolbar']['button_groups'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Toolbar buttons'),
|
||||
'#default_value' => json_encode($editor->settings['toolbar']['buttons']),
|
||||
'#default_value' => json_encode($editor->settings['toolbar']['rows']),
|
||||
'#attributes' => array('class' => array('ckeditor-toolbar-textarea')),
|
||||
);
|
||||
|
||||
|
@ -177,8 +194,17 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
'format' => $editor->id(),
|
||||
'editor' => 'ckeditor',
|
||||
'settings' => array(
|
||||
// Single toolbar row that contains all existing buttons.
|
||||
'toolbar' => array('buttons' => array(0 => $all_buttons)),
|
||||
// Single toolbar row, single button group, all existing buttons.
|
||||
'toolbar' => array(
|
||||
'rows' => array(
|
||||
0 => array(
|
||||
0 => array(
|
||||
'name' => 'All existing buttons',
|
||||
'items' => $all_buttons,
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
'plugins' => $editor->settings['plugins'],
|
||||
),
|
||||
));
|
||||
|
@ -212,7 +238,10 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
// editor_form_filter_admin_format_submit().
|
||||
$toolbar_settings = &$form_state['values']['editor']['settings']['toolbar'];
|
||||
|
||||
$toolbar_settings['buttons'] = json_decode($toolbar_settings['buttons'], FALSE);
|
||||
// The rows key is not built into the form structure, so decode the button
|
||||
// groups data into this new key and remove the button_groups key.
|
||||
$toolbar_settings['rows'] = json_decode($toolbar_settings['button_groups'], TRUE);
|
||||
unset($toolbar_settings['button_groups']);
|
||||
|
||||
// Remove the plugin settings' vertical tabs state; no need to save that.
|
||||
if (isset($form_state['values']['editor']['settings']['plugins'])) {
|
||||
|
@ -352,22 +381,12 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
*/
|
||||
public function buildToolbarJSSetting(EditorEntity $editor) {
|
||||
$toolbar = array();
|
||||
foreach ($editor->settings['toolbar']['buttons'] as $row) {
|
||||
$button_group = array();
|
||||
foreach ($row as $button_name) {
|
||||
// Change the toolbar separators into groups.
|
||||
if ($button_name === '|') {
|
||||
$toolbar[] = $button_group;
|
||||
$button_group = array();
|
||||
}
|
||||
else {
|
||||
$button_group['items'][] = $button_name;
|
||||
}
|
||||
foreach ($editor->settings['toolbar']['rows'] as $row) {
|
||||
foreach ($row as $group) {
|
||||
$toolbar[] = $group;
|
||||
}
|
||||
$toolbar[] = $button_group;
|
||||
$toolbar[] = '/';
|
||||
}
|
||||
|
||||
return $toolbar;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,13 +77,29 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
// Ensure the CKEditor editor returns the expected default settings.
|
||||
$expected_default_settings = array(
|
||||
'toolbar' => array(
|
||||
'buttons' => array(
|
||||
'rows' => array(
|
||||
// Button groups
|
||||
array(
|
||||
'Bold', 'Italic',
|
||||
'|', 'DrupalLink', 'DrupalUnlink',
|
||||
'|', 'BulletedList', 'NumberedList',
|
||||
'|', 'Blockquote', 'DrupalImage',
|
||||
'|', 'Source',
|
||||
array(
|
||||
'name' => t('Formatting'),
|
||||
'items' => array('Bold', 'Italic',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Links'),
|
||||
'items' => array('DrupalLink', 'DrupalUnlink',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Lists'),
|
||||
'items' => array('BulletedList', 'NumberedList',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Media'),
|
||||
'items' => array('Blockquote', 'DrupalImage',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Tools'),
|
||||
'items' => array('Source',),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -98,8 +114,8 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
|
||||
// Ensure the toolbar buttons configuration value is initialized to the
|
||||
// expected default value.
|
||||
$expected_buttons_value = json_encode($expected_default_settings['toolbar']['buttons']);
|
||||
$this->assertFieldByName('editor[settings][toolbar][buttons]', $expected_buttons_value);
|
||||
$expected_buttons_value = json_encode($expected_default_settings['toolbar']['rows']);
|
||||
$this->assertFieldByName('editor[settings][toolbar][button_groups]', $expected_buttons_value);
|
||||
|
||||
// Ensure the styles textarea exists and is initialized empty.
|
||||
$styles_textarea = $this->xpath('//textarea[@name="editor[settings][plugins][stylescombo][styles]"]');
|
||||
|
@ -131,12 +147,13 @@ class CKEditorAdminTest extends WebTestBase {
|
|||
// done via drag and drop, but here we can only emulate the end result of
|
||||
// that interaction). Test multiple toolbar rows and a divider within a row.
|
||||
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
|
||||
$expected_settings['toolbar']['buttons'] = array(
|
||||
array('Undo', '|', 'Redo'),
|
||||
array('JustifyCenter'),
|
||||
$expected_settings['toolbar']['rows'][0][] = array(
|
||||
'name' => 'Action history',
|
||||
'items' => array('Undo', '|', 'Redo'),
|
||||
array('JustifyCenter')
|
||||
);
|
||||
$edit = array(
|
||||
'editor[settings][toolbar][buttons]' => json_encode($expected_settings['toolbar']['buttons']),
|
||||
'editor[settings][toolbar][button_groups]' => json_encode($expected_settings['toolbar']['rows']),
|
||||
);
|
||||
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
|
||||
$editor = entity_load('editor', 'filtered_html');
|
||||
|
|
|
@ -103,8 +103,8 @@ class CKEditorPluginManagerTest extends DrupalUnitTestBase {
|
|||
// cause the LlamaContextual and LlamaContextualAndButton plugins to be
|
||||
// enabled. Finally, we will add the "Strike" button back again, which would
|
||||
// cause all three plugins to be enabled.
|
||||
$original_toolbar = $editor->settings['toolbar']['buttons'][0];
|
||||
$editor->settings['toolbar']['buttons'][0][] = 'Llama';
|
||||
$original_toolbar = $editor->settings['toolbar'];
|
||||
$editor->settings['toolbar']['rows'][0][0]['items'][] = 'Llama';
|
||||
$editor->save();
|
||||
$file = array();
|
||||
$file['b'] = 'core/modules/ckeditor/tests/modules/js/llama_button.js';
|
||||
|
@ -113,13 +113,13 @@ class CKEditorPluginManagerTest extends DrupalUnitTestBase {
|
|||
$expected = $enabled_plugins + array('llama_button' => $file['b'], 'llama_contextual_and_button' => $file['cb']);
|
||||
$this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LlamaButton and LlamaContextualAndButton plugins are enabled.');
|
||||
$this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LlamaButton and LlamaContextualAndButton plugins are enabled.');
|
||||
$editor->settings['toolbar']['buttons'][0] = $original_toolbar;
|
||||
$editor->settings['toolbar']['buttons'][0][] = 'Strike';
|
||||
$editor->settings['toolbar'] = $original_toolbar;
|
||||
$editor->settings['toolbar']['rows'][0][0]['items'][] = 'Strike';
|
||||
$editor->save();
|
||||
$expected = $enabled_plugins + array('llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb']);
|
||||
$this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LLamaContextual and LlamaContextualAndButton plugins are enabled.');
|
||||
$this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LlamaContextual and LlamaContextualAndButton plugins are enabled.');
|
||||
$editor->settings['toolbar']['buttons'][0][] = 'Llama';
|
||||
$editor->settings['toolbar']['rows'][0][0]['items'][] = 'Llama';
|
||||
$editor->save();
|
||||
$expected = $enabled_plugins + array('llama_button' => $file['b'], 'llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb']);
|
||||
$this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LlamaButton, LlamaContextual and LlamaContextualAndButton plugins are enabled.');
|
||||
|
|
|
@ -109,12 +109,11 @@ class CKEditorTest extends DrupalUnitTestBase {
|
|||
$this->container->get('plugin.manager.editor')->clearCachedDefinitions();
|
||||
$this->ckeditor = $this->container->get('plugin.manager.editor')->createInstance('ckeditor');
|
||||
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
|
||||
$editor->settings['toolbar']['buttons'][0][] = 'Strike';
|
||||
$editor->settings['toolbar']['buttons'][1][] = 'Format';
|
||||
$editor->settings['toolbar']['rows'][0][0]['items'][] = 'Strike';
|
||||
$editor->settings['toolbar']['rows'][0][0]['items'][] = 'Format';
|
||||
$editor->save();
|
||||
$expected_config['toolbar'][count($expected_config['toolbar'])-2]['items'][] = 'Strike';
|
||||
$expected_config['toolbar'][]['items'][] = 'Format';
|
||||
$expected_config['toolbar'][] = '/';
|
||||
$expected_config['toolbar'][0]['items'][] = 'Strike';
|
||||
$expected_config['toolbar'][0]['items'][] = 'Format';
|
||||
$expected_config['format_tags'] = 'p;h4;h5;h6';
|
||||
$expected_config['extraPlugins'] .= ',llama_contextual,llama_contextual_and_button';
|
||||
$expected_config['drupalExternalPlugins']['llama_contextual'] = file_create_url('core/modules/ckeditor/tests/modules/js/llama_contextual.js');
|
||||
|
@ -208,17 +207,20 @@ class CKEditorTest extends DrupalUnitTestBase {
|
|||
$this->assertIdentical($expected, $this->ckeditor->buildToolbarJSSetting($editor), '"toolbar" configuration part of JS settings built correctly for default toolbar.');
|
||||
|
||||
// Customize the configuration.
|
||||
$editor->settings['toolbar']['buttons'][0][] = 'Strike';
|
||||
$editor->settings['toolbar']['rows'][0][0]['items'][] = 'Strike';
|
||||
$editor->save();
|
||||
$expected[count($expected)-2]['items'][] = 'Strike';
|
||||
$expected[0]['items'][] = 'Strike';
|
||||
$this->assertIdentical($expected, $this->ckeditor->buildToolbarJSSetting($editor), '"toolbar" configuration part of JS settings built correctly for customized toolbar.');
|
||||
|
||||
// Enable the editor_test module, customize further.
|
||||
$this->enableModules(array('ckeditor_test'));
|
||||
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
|
||||
$editor->settings['toolbar']['buttons'][0][] = 'Llama';
|
||||
// Override the label of a toolbar component.
|
||||
$editor->settings['toolbar']['rows'][0][0]['name'] = 'JunkScience';
|
||||
$editor->settings['toolbar']['rows'][0][0]['items'][] = 'Llama';
|
||||
$editor->save();
|
||||
$expected[count($expected)-2]['items'][] = 'Llama';
|
||||
$expected[0]['name'] = 'JunkScience';
|
||||
$expected[0]['items'][] = 'Llama';
|
||||
$this->assertIdentical($expected, $this->ckeditor->buildToolbarJSSetting($editor), '"toolbar" configuration part of JS settings built correctly for customized toolbar with contrib module-provided CKEditor plugin.');
|
||||
}
|
||||
|
||||
|
@ -253,7 +255,7 @@ class CKEditorTest extends DrupalUnitTestBase {
|
|||
$this->assertIdentical($expected, $internal_plugin->getConfig($editor), '"Internal" plugin configuration built correctly for default toolbar.');
|
||||
|
||||
// Format dropdown/button enabled: new setting should be present.
|
||||
$editor->settings['toolbar']['buttons'][0][] = 'Format';
|
||||
$editor->settings['toolbar']['rows'][0][0]['items'][] = 'Format';
|
||||
$expected['format_tags'] = 'p;h4;h5;h6';
|
||||
$this->assertIdentical($expected, $internal_plugin->getConfig($editor), '"Internal" plugin configuration built correctly for customized toolbar.');
|
||||
}
|
||||
|
@ -266,7 +268,7 @@ class CKEditorTest extends DrupalUnitTestBase {
|
|||
$stylescombo_plugin = $this->container->get('plugin.manager.ckeditor.plugin')->createInstance('stylescombo');
|
||||
|
||||
// Styles dropdown/button enabled: new setting should be present.
|
||||
$editor->settings['toolbar']['buttons'][0][] = 'Styles';
|
||||
$editor->settings['toolbar']['rows'][0][0]['items'][] = 'Styles';
|
||||
$editor->settings['plugins']['stylescombo']['styles'] = '';
|
||||
$editor->save();
|
||||
$expected['stylesSet'] = array();
|
||||
|
@ -367,12 +369,27 @@ class CKEditorTest extends DrupalUnitTestBase {
|
|||
|
||||
protected function getDefaultToolbarConfig() {
|
||||
return array(
|
||||
0 => array('items' => array('Bold', 'Italic')),
|
||||
1 => array('items' => array('DrupalLink', 'DrupalUnlink')),
|
||||
2 => array('items' => array('BulletedList', 'NumberedList')),
|
||||
3 => array('items' => array('Blockquote', 'DrupalImage')),
|
||||
4 => array('items' => array('Source')),
|
||||
5 => '/'
|
||||
array(
|
||||
'name' => t('Formatting'),
|
||||
'items' => array('Bold', 'Italic',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Links'),
|
||||
'items' => array('DrupalLink', 'DrupalUnlink',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Lists'),
|
||||
'items' => array('BulletedList', 'NumberedList',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Media'),
|
||||
'items' => array('Blockquote', 'DrupalImage',),
|
||||
),
|
||||
array(
|
||||
'name' => t('Tools'),
|
||||
'items' => array('Source',),
|
||||
),
|
||||
'/',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,11 @@ class LlamaContextual extends Llama implements CKEditorPluginContextualInterface
|
|||
*/
|
||||
function isEnabled(Editor $editor) {
|
||||
// Automatically enable this plugin if the Underline button is enabled.
|
||||
foreach ($editor->settings['toolbar']['buttons'] as $row) {
|
||||
if (in_array('Strike', $row)) {
|
||||
return TRUE;
|
||||
foreach ($editor->settings['toolbar']['rows'] as $row) {
|
||||
foreach ($row as $group) {
|
||||
if (in_array('Strike', $group['items'])) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
|
|
@ -31,9 +31,11 @@ class LlamaContextualAndButton extends Llama implements CKEditorPluginContextual
|
|||
*/
|
||||
function isEnabled(Editor $editor) {
|
||||
// Automatically enable this plugin if the Strike button is enabled.
|
||||
foreach ($editor->settings['toolbar']['buttons'] as $row) {
|
||||
if (in_array('Strike', $row)) {
|
||||
return TRUE;
|
||||
foreach ($editor->settings['toolbar']['rows'] as $row) {
|
||||
foreach ($row as $group) {
|
||||
if (in_array('Strike', $group['items'])) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
|
|
@ -2,21 +2,32 @@ format: basic_html
|
|||
editor: ckeditor
|
||||
settings:
|
||||
toolbar:
|
||||
buttons:
|
||||
rows:
|
||||
-
|
||||
- Bold
|
||||
- Italic
|
||||
- '|'
|
||||
- DrupalLink
|
||||
- DrupalUnlink
|
||||
- '|'
|
||||
- BulletedList
|
||||
- NumberedList
|
||||
- '|'
|
||||
- Blockquote
|
||||
- DrupalImage
|
||||
- '|'
|
||||
- Source
|
||||
-
|
||||
name: Formatting
|
||||
items:
|
||||
- Bold
|
||||
- Italic
|
||||
-
|
||||
name: Linking
|
||||
items:
|
||||
- DrupalLink
|
||||
- DrupalUnlink
|
||||
-
|
||||
name: Lists
|
||||
items:
|
||||
- BulletedList
|
||||
- NumberedList
|
||||
-
|
||||
name: Media
|
||||
items:
|
||||
- Blockquote
|
||||
- DrupalImage
|
||||
-
|
||||
name: Tools
|
||||
items:
|
||||
- Source
|
||||
plugins:
|
||||
stylescombo:
|
||||
styles: ''
|
||||
|
@ -29,4 +40,4 @@ image_upload:
|
|||
width: ''
|
||||
height: ''
|
||||
status: '1'
|
||||
langcode: und
|
||||
langcode: en
|
||||
|
|
|
@ -2,31 +2,45 @@ format: full_html
|
|||
editor: ckeditor
|
||||
settings:
|
||||
toolbar:
|
||||
buttons:
|
||||
rows:
|
||||
-
|
||||
- Bold
|
||||
- Italic
|
||||
- Strike
|
||||
- Superscript
|
||||
- Subscript
|
||||
- -
|
||||
- RemoveFormat
|
||||
- '|'
|
||||
- DrupalLink
|
||||
- DrupalUnlink
|
||||
- '|'
|
||||
- BulletedList
|
||||
- NumberedList
|
||||
- '|'
|
||||
- Blockquote
|
||||
- DrupalImage
|
||||
- Table
|
||||
- HorizontalRule
|
||||
- '|'
|
||||
- Format
|
||||
- '|'
|
||||
- ShowBlocks
|
||||
- Source
|
||||
-
|
||||
name: Formatting
|
||||
items:
|
||||
- Bold
|
||||
- Italic
|
||||
- Strike
|
||||
- Superscript
|
||||
- Subscript
|
||||
- -
|
||||
- RemoveFormat
|
||||
-
|
||||
name: Linking
|
||||
items:
|
||||
- DrupalLink
|
||||
- DrupalUnlink
|
||||
-
|
||||
name: Lists
|
||||
items:
|
||||
- BulletedList
|
||||
- NumberedList
|
||||
-
|
||||
name: Media
|
||||
items:
|
||||
- Blockquote
|
||||
- DrupalImage
|
||||
- Table
|
||||
- HorizontalRule
|
||||
-
|
||||
name: Block Formatting
|
||||
items:
|
||||
- Format
|
||||
-
|
||||
name: Tools
|
||||
items:
|
||||
- ShowBlocks
|
||||
- Source
|
||||
|
||||
plugins:
|
||||
stylescombo:
|
||||
styles: ''
|
||||
|
@ -39,4 +53,4 @@ image_upload:
|
|||
width: ''
|
||||
height: ''
|
||||
status: '1'
|
||||
langcode: und
|
||||
langcode: en
|
||||
|
|
Loading…
Reference in New Issue