TRexEditor.php in Drupal 9
File
core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php
View source
<?php
namespace Drupal\editor_test\Plugin\Editor;
use Drupal\Core\Form\FormStateInterface;
use Drupal\editor\Entity\Editor;
use Drupal\editor\Plugin\EditorBase;
class TRexEditor extends EditorBase {
public function getDefaultSettings() {
return [
'stumpy_arms' => TRUE,
];
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['stumpy_arms'] = [
'#title' => t('Stumpy arms'),
'#type' => 'checkbox',
'#default_value' => TRUE,
];
return $form;
}
public function getJSSettings(Editor $editor) {
$js_settings = [];
$settings = $editor
->getSettings();
if ($settings['stumpy_arms']) {
$js_settings['doMyArmsLookStumpy'] = TRUE;
}
return $js_settings;
}
public function getLibraries(Editor $editor) {
return [
'editor_test/trex',
];
}
}
Classes
Name |
Description |
TRexEditor |
Defines a Tyrannosaurus-Rex powered text editor for testing purposes. |