diff --git a/core/modules/ckeditor/ckeditor.admin.inc b/core/modules/ckeditor/ckeditor.admin.inc index e99518a..68ab8a4 100644 --- a/core/modules/ckeditor/ckeditor.admin.inc +++ b/core/modules/ckeditor/ckeditor.admin.inc @@ -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; } /** @@ -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['data-drupal-ckeditor-toolbar-group'] = $button['group']; + } if (!empty($button['attributes'])) { $button_item = array_merge($button_item, $button['attributes']); } @@ -118,6 +134,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 .= "
  • {$group_name}"; + $output .= "
  • "; + + 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,32 +154,38 @@ function theme_ckeditor_settings_toolbar($variables) { $output .= '' . t('Toolbar configuration') . ''; $output .= '
    '; - // aria-live region for outputing aural information about the state of the - // configuration. - $output .= '
    '; - $output .= '
    ' . t('Move a button into the Active toolbar to enable it, or into the list of Available buttons to disable it. Use dividers to create button groups. Buttons may be moved with the mouse or keyboard arrow keys.') . '
    '; $output .= '
    '; $output .= '
    '; + // Dividers. $output .= ''; $output .= '
      '; $output .= $print_buttons($multiple_buttons); $output .= '
    '; $output .= '
    '; + // Available buttons. $output .= ''; $output .= ''; $output .= '
    '; - + // Active toolbar. $output .= ''; - $output .= '
    '; - foreach ($active_buttons as $button_row) { - $output .= '