Version 1
[yaffs-website] / web / core / modules / editor / tests / modules / src / Plugin / Editor / TRexEditor.php
1 <?php
2
3 namespace Drupal\editor_test\Plugin\Editor;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\editor\Entity\Editor;
7 use Drupal\editor\Plugin\EditorBase;
8
9 /**
10  * Defines a Tyrannosaurus-Rex powered text editor for testing purposes.
11  *
12  * @Editor(
13  *   id = "trex",
14  *   label = @Translation("TRex Editor"),
15  *   supports_content_filtering = TRUE,
16  *   supports_inline_editing = TRUE,
17  *   is_xss_safe = FALSE,
18  *   supported_element_types = {
19  *     "textarea",
20  *   }
21  * )
22  */
23 class TRexEditor extends EditorBase {
24
25   /**
26    * {@inheritdoc}
27    */
28   public function getDefaultSettings() {
29     return ['stumpy_arms' => TRUE];
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
36     $form['stumpy_arms'] = [
37       '#title' => t('Stumpy arms'),
38       '#type' => 'checkbox',
39       '#default_value' => TRUE,
40     ];
41     return $form;
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function getJSSettings(Editor $editor) {
48     $js_settings = [];
49     $settings = $editor->getSettings();
50     if ($settings['stumpy_arms']) {
51       $js_settings['doMyArmsLookStumpy'] = TRUE;
52     }
53     return $js_settings;
54   }
55
56   /**
57    * {@inheritdoc}
58    */
59   public function getLibraries(Editor $editor) {
60     return [
61       'editor_test/trex',
62     ];
63   }
64
65 }