function CKEditor::buildToolbarJSSetting

Same name in other branches
  1. 8.9.x core/modules/ckeditor/src/Plugin/Editor/CKEditor.php \Drupal\ckeditor\Plugin\Editor\CKEditor::buildToolbarJSSetting()

Builds the "toolbar" configuration part of the CKEditor JS settings.

Parameters

\Drupal\editor\Entity\Editor $editor: A configured text editor object.

Return value

array An array containing the "toolbar" configuration.

See also

getJSSettings()

1 call to CKEditor::buildToolbarJSSetting()
CKEditor::getJSSettings in core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
Returns JavaScript settings to be attached.

File

core/modules/ckeditor/src/Plugin/Editor/CKEditor.php, line 453

Class

CKEditor
Defines a CKEditor-based text editor for Drupal.

Namespace

Drupal\ckeditor\Plugin\Editor

Code

public function buildToolbarJSSetting(Editor $editor) {
    $toolbar = [];
    $settings = $editor->getSettings();
    foreach ($settings['toolbar']['rows'] as $row) {
        foreach ($row as $group) {
            $toolbar[] = $group;
        }
        $toolbar[] = '/';
    }
    return $toolbar;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.