You are here

function CKEditor::settingsForm in CKEditor for WYSIWYG Module 8

Implements \Drupal\editor\Plugin\EditorInterface::settingsForm().

File

lib/Drupal/ckeditor/Plugin/editor/editor/CKEditor.php, line 49
Definition of \Drupal\ckeditor\Plugin\editor\editor\CKEditor.

Class

CKEditor
Defines a CKEditor-based text editor for Drupal.

Namespace

Drupal\ckeditor\Plugin\editor\editor

Code

function settingsForm(array $form, array &$form_state, Editor $editor) {
  $module_path = drupal_get_path('module', 'ckeditor');
  $plugins = ckeditor_plugins();
  $form['toolbar'] = array(
    '#type' => 'fieldset',
    '#title' => t('Toolbar'),
    '#attached' => array(
      'library' => array(
        array(
          'ckeditor',
          'drupal.ckeditor.admin',
        ),
      ),
      'js' => array(
        array(
          'data' => array(
            'ckeditor' => array(
              'toolbarAdmin' => theme('ckeditor_settings_toolbar', array(
                'editor' => $editor,
                'plugins' => $plugins,
              )),
            ),
          ),
          'type' => 'setting',
        ),
      ),
    ),
    '#attributes' => array(
      'class' => array(
        'ckeditor-toolbar-configuration',
      ),
    ),
  );
  $form['toolbar']['buttons'] = array(
    '#type' => 'textarea',
    '#title' => t('Toolbar buttons'),
    '#default_value' => json_encode($editor->settings['toolbar']['buttons']),
    '#attributes' => array(
      'class' => array(
        'ckeditor-toolbar-textarea',
      ),
    ),
  );
  $form['toolbar']['format_list'] = array(
    '#type' => 'textfield',
    '#title' => t('Format list'),
    '#default_value' => implode(', ', $editor->settings['toolbar']['format_list']),
    '#description' => t('A list of tags that will be provided in the "Format" dropdown, separated by commas.'),
  );
  $form['toolbar']['style_list'] = array(
    '#type' => 'textarea',
    '#title' => t('Style list'),
    '#rows' => 4,
    '#default_value' => implode("\n", $editor->settings['toolbar']['style_list']),
    '#description' => t('A list of classes that will be provided in the "Styles" dropdown, each on a separate line. These styles should be available in your theme\'s editor.css as well as in your theme\'s main CSS file.'),
  );
  return $form;
}