You are here

public function DrupalSpecialChars::isEnabled in CKEditor Special Characters 8

Checks if this plugin should be enabled based on the editor configuration.

The editor's settings can be retrieved via $editor->getSettings().

Parameters

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

Return value

bool

Overrides CKEditorPluginContextualInterface::isEnabled

File

src/Plugin/CKEditorPlugin/DrupalSpecialChars.php, line 64

Class

DrupalSpecialChars
Defines the "specialChars" plugin.

Namespace

Drupal\ckeditor_specialchars\Plugin\CKEditorPlugin

Code

public function isEnabled(Editor $editor) {
  $settings = $editor
    ->getSettings();
  foreach ($settings['toolbar']['rows'] as $row) {
    foreach ($row as $group) {
      foreach ($group['items'] as $button) {
        if ($button === 'SpecialChar') {
          return TRUE;
        }
      }
    }
  }
  return FALSE;
}