Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
# Schema for the configuration files of the Editor test module.
|
||||
|
||||
editor.settings.unicorn:
|
||||
type: mapping
|
||||
label: 'Unicorn settings'
|
||||
mapping:
|
||||
ponies_too:
|
||||
type: boolean
|
||||
label: 'Ponies too'
|
||||
|
||||
editor.settings.trex:
|
||||
type: mapping
|
||||
label: 'T-Rex settings'
|
||||
mapping:
|
||||
stumpy_arms:
|
||||
type: boolean
|
||||
label: 'Stumpy arms'
|
||||
6
core/modules/editor/tests/modules/editor_test.info.yml
Normal file
6
core/modules/editor/tests/modules/editor_test.info.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Text Editor test'
|
||||
type: module
|
||||
description: 'Support module for the Text Editor module tests.'
|
||||
core: 8.x
|
||||
package: Testing
|
||||
version: VERSION
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
unicorn:
|
||||
version: VERSION
|
||||
js:
|
||||
unicorn.js: {}
|
||||
trex:
|
||||
version: VERSION
|
||||
js:
|
||||
trex.js: {}
|
||||
46
core/modules/editor/tests/modules/editor_test.module
Normal file
46
core/modules/editor/tests/modules/editor_test.module
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Helper module for the Text Editor tests.
|
||||
*/
|
||||
|
||||
use Drupal\filter\FilterFormatInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_editor_js_settings_alter().
|
||||
*/
|
||||
function editor_test_editor_js_settings_alter(&$settings) {
|
||||
// Allow tests to enable or disable this alter hook.
|
||||
if (!\Drupal::state()->get('editor_test_js_settings_alter_enabled', FALSE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($settings['editor']['formats']['full_html'])) {
|
||||
$settings['editor']['formats']['full_html']['editorSettings']['ponyModeEnabled'] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_editor_xss_filter_alter().
|
||||
*/
|
||||
function editor_test_editor_xss_filter_alter(&$editor_xss_filter_class, FilterFormatInterface $format, FilterFormatInterface $original_format = NULL) {
|
||||
// Allow tests to enable or disable this alter hook.
|
||||
if (!\Drupal::state()->get('editor_test_editor_xss_filter_alter_enabled', FALSE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$filters = $format->filters()->getAll();
|
||||
if (isset($filters['filter_html']) && $filters['filter_html']->status) {
|
||||
$editor_xss_filter_class = '\Drupal\editor_test\EditorXssFilter\Insecure';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_editor_info_alter().
|
||||
*/
|
||||
function editor_test_editor_info_alter(&$items) {
|
||||
if (!\Drupal::state()->get('editor_test_give_me_a_trex_thanks', FALSE)) {
|
||||
unset($items['trex']);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\editor_test\EditorXssFilter\Insecure.
|
||||
*/
|
||||
|
||||
namespace Drupal\editor_test\EditorXssFilter;
|
||||
|
||||
use Drupal\filter\FilterFormatInterface;
|
||||
use Drupal\editor\EditorXssFilterInterface;
|
||||
|
||||
/**
|
||||
* Defines an insecure text editor XSS filter (for testing purposes).
|
||||
*/
|
||||
class Insecure implements EditorXssFilterInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function filterXss($html, FilterFormatInterface $format, FilterFormatInterface $original_format = NULL) {
|
||||
// Don't apply any XSS filtering, just return the string we received.
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\editor_test\Plugin\Editor\TRexEditor.
|
||||
*/
|
||||
|
||||
namespace Drupal\editor_test\Plugin\Editor;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\editor\Plugin\EditorBase;
|
||||
use Drupal\editor\Entity\Editor as EditorEntity;
|
||||
|
||||
/**
|
||||
* Defines a Tyrannosaurus-Rex powered text editor for testing purposes.
|
||||
*
|
||||
* @Editor(
|
||||
* id = "trex",
|
||||
* label = @Translation("TRex Editor"),
|
||||
* supports_content_filtering = TRUE,
|
||||
* supports_inline_editing = TRUE,
|
||||
* is_xss_safe = FALSE,
|
||||
* supported_element_types = {
|
||||
* "textarea",
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class TRexEditor extends EditorBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultSettings() {
|
||||
return array('stumpy_arms' => TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settingsForm(array $form, FormStateInterface $form_state, EditorEntity $editor) {
|
||||
$form['stumpy_arms'] = array(
|
||||
'#title' => t('Stumpy arms'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => TRUE,
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getJSSettings(EditorEntity $editor) {
|
||||
$js_settings = array();
|
||||
$settings = $editor->getSettings();
|
||||
if ($settings['stumpy_arms']) {
|
||||
$js_settings['doMyArmsLookStumpy'] = TRUE;
|
||||
}
|
||||
return $js_settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLibraries(EditorEntity $editor) {
|
||||
return array(
|
||||
'editor_test/trex',
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\editor_test\Plugin\Editor\UnicornEditor.
|
||||
*/
|
||||
|
||||
namespace Drupal\editor_test\Plugin\Editor;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\editor\Plugin\EditorBase;
|
||||
use Drupal\editor\Entity\Editor as EditorEntity;
|
||||
|
||||
/**
|
||||
* Defines a Unicorn-powered text editor for Drupal (for testing purposes).
|
||||
*
|
||||
* @Editor(
|
||||
* id = "unicorn",
|
||||
* label = @Translation("Unicorn Editor"),
|
||||
* supports_content_filtering = TRUE,
|
||||
* supports_inline_editing = TRUE,
|
||||
* is_xss_safe = FALSE,
|
||||
* supported_element_types = {
|
||||
* "textarea",
|
||||
* "textfield",
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class UnicornEditor extends EditorBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function getDefaultSettings() {
|
||||
return array('ponies_too' => TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function settingsForm(array $form, FormStateInterface $form_state, EditorEntity $editor) {
|
||||
$form['ponies_too'] = array(
|
||||
'#title' => t('Pony mode'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => TRUE,
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function getJSSettings(EditorEntity $editor) {
|
||||
$js_settings = array();
|
||||
$settings = $editor->getSettings();
|
||||
if ($settings['ponies_too']) {
|
||||
$js_settings['ponyModeEnabled'] = TRUE;
|
||||
}
|
||||
return $js_settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLibraries(EditorEntity $editor) {
|
||||
return array(
|
||||
'editor_test/unicorn',
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue