- if (enabled) {
- message = Drupal.t('The "@name" button is currently enabled.', {
- '@name': $link.attr('aria-label'),
- });
- message += `\n${Drupal.t('Use the keyboard arrow keys to change the position of this button.')}`;
- message += `\n${Drupal.t('Press the up arrow key on the top row to disable the button.')}`;
- }
- else {
- message = Drupal.t('The "@name" button is currently disabled.', {
- '@name': $link.attr('aria-label'),
- });
- message += `\n${Drupal.t('Use the down arrow key to move this button into the active toolbar.')}`;
- }
- Drupal.announce(message);
- event.preventDefault();
- },
+ Drupal.announce(text, 'assertive');
+ }
+ // The button is in the active toolbar.
+ else if ($group.not('.placeholder').length === 1) {
+ text = Drupal.t(
+ '@name @type in position @position of @positionCount in @groupName button group in row @row of @rowCount.',
+ {
+ '@name': $button.children().attr('aria-label'),
+ '@type': type,
+ '@position': position,
+ '@positionCount': positionCount,
+ '@groupName': $group.attr(
+ 'data-drupal-ckeditor-toolbar-group-name',
+ ),
+ '@row': row,
+ '@rowCount': rowCount,
+ },
+ );
+ // If this position is the first in the last row then tell the user that
+ // pressing the down arrow key will create a new row.
+ if (groupPosition === 1 && position === 1 && row === rowCount) {
+ text += '\n';
+ text += Drupal.t(
+ 'Press the down arrow key to create a new button group in a new row.',
+ );
+ }
+ // If this position is the last one in this row then tell the user that
+ // moving the button to the next group will create a new group.
+ if (
+ groupPosition === groupPositionCount &&
+ position === positionCount
+ ) {
+ text += '\n';
+ text += Drupal.t(
+ 'This is the last group. Move the button forward to create a new group.',
+ );
+ }
+ Drupal.announce(text, 'assertive');
+ }
+ },
+
+ /**
+ * Provides help information when a button is clicked.
+ *
+ * @param {jQuery.Event} event
+ * The click event for the button click.
+ */
+ announceButtonHelp(event) {
+ const $link = $(event.currentTarget);
+ const $button = $link.parent();
+ const enabled = $button.closest('.ckeditor-toolbar-active').length > 0;
+ let message;