3 namespace Drupal\ckeditor_test\Plugin\CKEditorPlugin;
5 use Drupal\ckeditor\CKEditorPluginButtonsInterface;
6 use Drupal\ckeditor\CKEditorPluginContextualInterface;
7 use Drupal\ckeditor\CKEditorPluginConfigurableInterface;
8 use Drupal\Core\Form\FormStateInterface;
9 use Drupal\editor\Entity\Editor;
12 * Defines a "LlamaContextualAndButton" plugin, with a contextually OR toolbar
13 * builder-enabled "llama" feature.
16 * id = "llama_contextual_and_button",
17 * label = @Translation("Contextual Llama With Button")
20 class LlamaContextualAndButton extends Llama implements CKEditorPluginContextualInterface, CKEditorPluginButtonsInterface, CKEditorPluginConfigurableInterface {
25 public function isEnabled(Editor $editor) {
26 // Automatically enable this plugin if the Strike button is enabled.
27 $settings = $editor->getSettings();
28 foreach ($settings['toolbar']['rows'] as $row) {
29 foreach ($row as $group) {
30 if (in_array('Strike', $group['items'])) {
41 public function getButtons() {
44 'label' => t('Insert Llama'),
52 public function getFile() {
53 return drupal_get_path('module', 'ckeditor_test') . '/js/llama_contextual_and_button.js';
59 public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
61 $config = ['ultra_llama_mode' => FALSE];
62 $settings = $editor->getSettings();
63 if (isset($settings['plugins']['llama_contextual_and_button'])) {
64 $config = $settings['plugins']['llama_contextual_and_button'];
67 $form['ultra_llama_mode'] = [
68 '#title' => t('Ultra llama mode'),
69 '#type' => 'checkbox',
70 '#default_value' => $config['ultra_llama_mode'],