core/modules/editor/editor.api.php | 2 +- core/modules/editor/editor.info | 2 +- core/modules/editor/editor.module | 146 +++++++++++--------- core/modules/editor/js/editor.js | 79 +++++++---- .../Drupal/editor/Plugin/Core/Entity/Editor.php | 27 ++-- .../editor/lib/Drupal/editor/Plugin/EditorBase.php | 13 +- .../lib/Drupal/editor/Plugin/EditorInterface.php | 19 ++- .../lib/Drupal/editor/Plugin/EditorManager.php | 3 +- .../lib/Drupal/editor/Tests/EditorLoadingTest.php | 38 +---- .../lib/Drupal/editor/Tests/EditorManagerTest.php | 29 +--- .../Plugin/editor/editor/UnicornEditor.php | 8 +- 11 files changed, 181 insertions(+), 185 deletions(-) diff --git a/core/modules/editor/editor.api.php b/core/modules/editor/editor.api.php index 85a51f1..8d0f951 100644 --- a/core/modules/editor/editor.api.php +++ b/core/modules/editor/editor.api.php @@ -20,7 +20,7 @@ * @see \Drupal\editor\Plugin\EditorBase */ function hook_editor_info_alter(array &$editors) { - $editors['some_other_editor']['title'] = t('A different name'); + $editors['some_other_editor']['label'] = t('A different name'); $editors['some_other_editor']['library']['module'] = 'myeditoroverride'; } diff --git a/core/modules/editor/editor.info b/core/modules/editor/editor.info index 15aab7d..995d003 100644 --- a/core/modules/editor/editor.info +++ b/core/modules/editor/editor.info @@ -1,5 +1,5 @@ name = Text Editor -description = "Provides a framework for associating text formats with text editor libraries such as WYSIWYGs or toolbars." +description = "Allows to associate text formats with text editor libraries such as WYSIWYGs or toolbars." package = Core version = VERSION core = 8.x diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 2be1e42..1a7b2ea 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -41,7 +41,7 @@ function editor_help($path, $arg) { */ function editor_menu_alter(&$items) { $items['admin/config/content/formats']['title'] = 'Text formats and editors'; - $items['admin/config/content/formats']['description'] = 'Configure the processing of text, including toolbars or WYSIWYG editors used on input, and allowed HTML tags and automatic formatting used on output.'; + $items['admin/config/content/formats']['description'] = 'Configure how user-contributed content is filtered and formatted, as well as the text editor user interface (WYSIWYGs or toolbars).'; } /** @@ -55,7 +55,7 @@ function editor_menu_alter(&$items) { */ function editor_element_info() { $type['text_format'] = array( - '#process' => array('editor_process_format'), + '#pre_render' => array('editor_pre_render_format'), ); return $type; } @@ -66,10 +66,10 @@ function editor_element_info() { function editor_library_info() { $path = drupal_get_path('module', 'editor'); $libraries['drupal.editor'] = array( - 'title' => 'Editor', + 'title' => 'Text Editor', 'version' => VERSION, 'js' => array( - $path . '/js/editor.js' => array('group' => JS_LIBRARY), + $path . '/js/editor.js' => array(), ), 'dependencies' => array( array('system', 'jquery'), @@ -87,20 +87,17 @@ function editor_library_info() { */ function editor_form_filter_admin_overview_alter(&$form, $form_state) { // @todo Cleanup column injection: http://drupal.org/node/1876718 - // Splice in the column for "Associated editor" into the header. + // Splice in the column for "Text editor" into the header. $position = array_search('name', $form['formats']['#header']) + 1; - $start = array_splice($form['formats']['#header'], 0, $position, array('editor' => t('Associated editor'))); + $start = array_splice($form['formats']['#header'], 0, $position, array('editor' => t('Text editor'))); $form['formats']['#header'] = array_merge($start, $form['formats']['#header']); // Then splice in the name of each text editor for each text format. $editors = drupal_container()->get('plugin.manager.editor')->getDefinitions(); foreach (element_children($form['formats']) as $format_id) { $editor = editor_load($format_id); - $editor_name = ($editor && isset($editors[$editor->editor])) ? $editors[$editor->editor]['title'] : drupal_placeholder(t('None')); - $editor_column['editor'] = array( - '#type' => 'markup', - '#markup' => $editor_name, - ); + $editor_name = ($editor && isset($editors[$editor->editor])) ? $editors[$editor->editor]['label'] : drupal_placeholder('—'); + $editor_column['editor'] = array('#markup' => $editor_name); $position = array_search('name', array_keys($form['formats'][$format_id])) + 1; $start = array_splice($form['formats'][$format_id], 0, $position, $editor_column); $form['formats'][$format_id] = array_merge($start, $form['formats'][$format_id]); @@ -111,29 +108,19 @@ function editor_form_filter_admin_overview_alter(&$form, $form_state) { * Implements hook_form_FORM_ID_alter(). */ function editor_form_filter_admin_format_form_alter(&$form, &$form_state) { - $format = $form['#format']; - $editor = editor_load($format->format); - $manager = drupal_container()->get('plugin.manager.editor'); - - // Check if we're switching to a different text editor and load that form. - if (isset($form_state['values']['editor'])) { - if ($form_state['values']['editor'] === '') { - $editor = FALSE; - } - elseif (empty($editor) || $form_state['values']['editor'] !== $editor->editor) { - $editor = entity_create('editor', array( - 'name' => $format->name, - 'format' => $format->format, - 'editor' => $form_state['values']['editor'], - )); - } + if (!isset($form_state['editor'])) { + $format_id = $form['#format']->format; + $form_state['editor'] = editor_load($format_id); + $form_state['editor_manager'] = drupal_container()->get('plugin.manager.editor'); } + $editor = $form_state['editor']; + $manager = $form_state['editor_manager']; // Associate a text editor with this text format. $editor_options = $manager->listOptions(); $form['editor'] = array( '#type' => 'select', - '#title' => t('Editor'), + '#title' => t('Text editor'), '#options' => $editor_options, '#empty_option' => t('None'), '#default_value' => $editor ? $editor->editor : '', @@ -146,27 +133,24 @@ function editor_form_filter_admin_format_form_alter(&$form, &$form_state) { ), ); - // If there aren't any options (other than "None") disable the select list. + // If there aren't any options (other than "None"), disable the select list. if (empty($editor_options)) { $form['editor']['#disabled'] = TRUE; - $form['editor']['#description'] = t('This option is disabled because no modules that provide an editor are currently enabled.'); + $form['editor']['#description'] = t('This option is disabled because no modules that provide a text editor are currently enabled.'); } $form['editor_settings'] = array( '#tree' => TRUE, '#weight' => -8, - '#type' => 'group', - '#prefix' => '
', - '#suffix' => '
', + '#type' => 'container', + '#id' => 'editor-settings-wrapper', ); // Add per-editor validation and submit handlers. if ($editor) { $plugin = $manager->createInstance($editor->editor); - $form['editor_settings'] = array_merge($form['editor_settings'], $plugin->settingsForm($form, $form_state, $editor)); - // Place validation first since editor validation errors should appear above - // individual filter validation errors. - array_unshift($form['#validate'], array($plugin, 'settingsFormValidate')); + $form['editor_settings']['settings'] = $plugin->settingsForm($form, $form_state, $editor); + $form['editor_settings']['settings']['#element_validate'][] = array($plugin, 'settingsFormValidate'); $form['#submit'][] = array($plugin, 'settingsFormSubmit'); } @@ -174,9 +158,28 @@ function editor_form_filter_admin_format_form_alter(&$form, &$form_state) { } /** - * AJAX submit handler for filter_admin_format_form(). + * AJAX callback handler for filter_admin_format_form(). */ function editor_form_filter_admin_form_ajax($form, &$form_state) { + $editor = $form_state['editor']; + if (isset($form_state['values']['editor'])) { + if ($form_state['values']['editor'] === '') { + $form_state['editor'] = FALSE; + } + elseif (empty($editor) || $form_state['values']['editor'] !== $editor->editor) { + $format = $form['#format']; + $editor = entity_create('editor', array( + 'name' => $format->name, + 'format' => $format->format, + 'editor' => $form_state['values']['editor'], + )); + $form_state['editor'] = $editor; + } + } + + // Process the form again, so that $form['editor_settings'] is updated. + drupal_process_form($form['#form_id'], $form, $form_state); + return $form['editor_settings']; } @@ -184,33 +187,22 @@ function editor_form_filter_admin_form_ajax($form, &$form_state) { * Additional submit handler for filter_admin_format_form(). */ function editor_form_filter_admin_format_submit($form, &$form_state) { - $format = $form['#format']; - $editor = editor_load($format->format); - // Delete the existing editor if disabling or switching between editors. - if ($editor && $editor->editor != $form_state['values']['editor']) { - $editor->delete(); - $editor = FALSE; + $format_id = $form['#format']->format; + $original_editor = editor_load($format_id); + if ($original_editor && $original_editor->editor != $form_state['values']['editor']) { + $original_editor->delete(); } // Create a new editor or update the existing editor. - if ($form_state['values']['editor']) { - if (!$editor) { - $editor = entity_create('editor', array( - 'name' => $format->name, - 'format' => $format->format, - 'editor' => $form_state['values']['editor'], - )); - } - if (isset($form_state['values']['editor_settings'])) { - $editor->settings = $form_state['values']['editor_settings']; - } - $editor->save(); + if ($form_state['values']['editor'] !== '') { + $form_state['editor']->settings = $form_state['values']['editor_settings']; + $form_state['editor']->save(); } } /** - * Loads an individual configured text editor based on format ID. + * Loads an individual configured text editor based on text format ID. * * @return \Drupal\editor\Plugin\Core\Entity\Editor|FALSE * A text editor object, or FALSE. @@ -225,17 +217,43 @@ function editor_load($format_id) { } /** - * Additional #process callback for 'text_format' elements. + * Additional #pre_render callback for 'text_format' elements. */ -function editor_process_format($element) { - global $user; +function editor_pre_render_format($element) { + // Allow modules to programmatically enforce no client-side editor by setting + // the #editor property to FALSE. + if (isset($element['#editor']) && !$element['#editor']) { + return $element; + } - $manager = drupal_container()->get('plugin.manager.editor'); - $format_ids = array_keys(filter_formats($user)); + // filter_process_format() copies properties to the expanded 'value' child + // element. Skip this text format widget, if it contains no 'format' or when + // the current user does not have access to edit the value. + if (!isset($element['format']) || !empty($element['value']['#disabled'])) { + return $element; + } + $format_ids = array_keys($element['format']['format']['#options']); - if (!isset($element['#attached'])) { - $element['#attached'] = array(); + // Use a hidden element for a single text format. + if (!$element['format']['format']['#access']) { + // Use the first (and only) available text format. + $format_id = $format_ids[0]; + $element['format']['editor'] = array( + '#type' => 'hidden', + '#name' => $element['format']['format']['#name'], + '#value' => $format_id, + '#attributes' => array( + 'class' => array('editor'), + ), + ); + } + // Otherwise, attach to text format selector. + else { + $element['format']['format']['#attributes']['class'][] = 'editor'; } + + // Attach attachments for all available editors. + $manager = drupal_container()->get('plugin.manager.editor'); $element['#attached'] = NestedArray::mergeDeep($element['#attached'], $manager->getAttachments($format_ids)); return $element; diff --git a/core/modules/editor/js/editor.js b/core/modules/editor/js/editor.js index bb651c3..4301154 100644 --- a/core/modules/editor/js/editor.js +++ b/core/modules/editor/js/editor.js @@ -3,7 +3,7 @@ * Attaches behavior for the Editor module. */ -(function ($, Drupal, drupalSettings) { +(function ($, Drupal) { "use strict"; @@ -15,7 +15,7 @@ Drupal.editors = {}; /** * Enables editors on text_format elements. */ -Drupal.behaviors.editors = { +Drupal.behaviors.editor = { attach: function (context, settings) { // If there are no editor settings, there are no editors to enable. if (!settings.editor) { @@ -23,33 +23,34 @@ Drupal.behaviors.editors = { } var $context = $(context); - $context.find('.filter-list:input').once('editors', function () { + var behavior = this; + $context.find('.editor').once('editor', function () { var $this = $(this); - var activeEditor = $this.val(); - var field = $this.closest('.text-format-wrapper').find('textarea').get(-1); - - // Directly attach this editor, if the text format is enabled or there is - // only one text format at all. - if ($this.is(':input')) { - if (drupalSettings.editor.formats[activeEditor]) { - Drupal.editorAttach(field, drupalSettings.editor.formats[activeEditor]); - } + var activeFormatID = $this.val(); + var field = behavior.findFieldForFormatSelector($this); + + // Directly attach this editor, if the text format is enabled. + if (settings.editor.formats[activeFormatID]) { + Drupal.editorAttach(field, settings.editor.formats[activeFormatID]); } - // Attach onChange handlers to text format selector elements. + + // Attach onChange handler to text format selector element. if ($this.is('select')) { $this.on('change.editorAttach', function () { - // Prevent double-binding if the change event is triggered manually. - if ($this.val() === activeEditor) { + var newFormatID = $this.val(); + + // Prevent double-attaching if the change event is triggered manually. + if (newFormatID === activeFormatID) { return; } // Detach the current editor (if any) and attach a new editor. - if (drupalSettings.editor.formats[activeEditor]) { - Drupal.editorDetach(field, drupalSettings.editor.formats[activeEditor]); + if (settings.editor.formats[activeFormatID]) { + Drupal.editorDetach(field, settings.editor.formats[activeFormatID]); } - activeEditor = $this.val(); - if (drupalSettings.editor.formats[activeEditor]) { - Drupal.editorAttach(field, drupalSettings.editor.formats[activeEditor]); + activeFormatID = newFormatID; + if (settings.editor.formats[activeFormatID]) { + Drupal.editorAttach(field, settings.editor.formats[activeFormatID]); } }); } @@ -59,9 +60,39 @@ Drupal.behaviors.editors = { if (event.isDefaultPrevented()) { return; } - Drupal.editorDetach(field, drupalSettings.editor.formats[activeEditor]); + Drupal.editorDetach(field, settings.editor.formats[activeFormatID]); }); }); + }, + + detach: function (context, settings, trigger) { + var editors; + // The 'serialize' trigger indicates that we should simply update the + // underlying element with the new text, without destroying the editor. + if (trigger == 'serialize') { + // Removing the editor-processed class guarantees that the editor will + // be reattached. Only do this if we're planning to destroy the editor. + editors = $(context).find('.editor-processed'); + } + else { + editors = $(context).find('.editor').removeOnce('editor'); + } + + var behavior = this; + editors.each(function () { + var $this = $(this); + var activeFormatID = $this.val(); + var field = behavior.findFieldForFormatSelector($this); + + Drupal.editorDetach(field, settings.editor.formats[activeFormatID], trigger); + }); + }, + + findFieldForFormatSelector: function ($formatSelector) { + return $formatSelector + .closest('.text-format-wrapper') + .find('textarea, input[type=text]') + .get(-1); } }; @@ -71,10 +102,10 @@ Drupal.editorAttach = function (field, format) { } }; -Drupal.editorDetach = function (field, format) { +Drupal.editorDetach = function (field, format, trigger) { if (format.editor) { - Drupal.editors[format.editor].detach(field, format); + Drupal.editors[format.editor].detach(field, format, trigger); } }; -})(jQuery, Drupal, drupalSettings); +})(jQuery, Drupal); diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php b/core/modules/editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php index 0ed6c3a..8db1e48 100644 --- a/core/modules/editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php +++ b/core/modules/editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php @@ -22,7 +22,6 @@ * config_prefix = "editor.editor", * entity_keys = { * "id" = "format", - * "label" = "name", * "uuid" = "uuid" * } * ) @@ -30,28 +29,22 @@ class Editor extends ConfigEntityBase { /** - * The machine name of the text format to which this text editor is bound. + * The machine name of the text format with which this configured text editor + * is associated. * * @var string */ public $format; /** - * The label of the text format to which this text editor is bound. - * - * @var string - */ - public $name; - - /** - * The name of the text editor library. + * The name (plugin ID) of the text editor. * * @var string */ public $editor; /** - * The array of settings for this text editor. + * The array of settings for the text editor. * * @var array */ @@ -65,6 +58,14 @@ public function id() { } /** + * Overrides Drupal\Core\Entity\Entity::label(). + */ + public function label($langcode = NULL) { + $format = filter_format_load($this->format); + return $format->name; + } + + /** * Overrides Drupal\Core\Entity\Entity::__construct() */ public function __construct(array $values, $entity_type) { @@ -73,7 +74,9 @@ public function __construct(array $values, $entity_type) { // Initialize settings to the defaults, merging any passed in settings. $manager = drupal_container()->get('plugin.manager.editor'); $plugin = $manager->createInstance($this->editor); - $this->settings = array_merge($plugin->defaultSettings(), $this->settings); + if (empty($this->settings)) { + $this->settings = $plugin->getDefaultSettings(); + } } } diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/EditorBase.php b/core/modules/editor/lib/Drupal/editor/Plugin/EditorBase.php index 56c674a..0a7dc33 100644 --- a/core/modules/editor/lib/Drupal/editor/Plugin/EditorBase.php +++ b/core/modules/editor/lib/Drupal/editor/Plugin/EditorBase.php @@ -23,7 +23,7 @@ * * - id: The unique, system-wide identifier of the text editor. Typically named * the same as the editor library. - * - title: The human-readable name of the text editor, translated. + * - label: The human-readable name of the text editor, translated. * - library: A nested array containing key-value pairs for adding library to * the page, as done through drupal_add_library(). This array should have * two keys: @@ -36,7 +36,7 @@ * @code * @Plugin( * id = "myeditor", - * title = @Translation("My Editor"), + * label = @Translation("My Editor"), * library = { * "module" = "myeditor", * "name" = "drupal.myeditor" @@ -47,24 +47,23 @@ abstract class EditorBase extends PluginBase implements EditorInterface { /** - * Implements \Drupal\editor\Plugin\EditorInterface::defaultSettings(). + * Implements \Drupal\editor\Plugin\EditorInterface::getDefaultSettings(). */ - public function defaultSettings() { + public function getDefaultSettings() { return array(); } /** * Implements \Drupal\editor\Plugin\EditorInterface::settingsForm(). */ - public function settingsForm(array &$form, array &$form_state, Editor $editor) { - return array(); + public function settingsForm(array $form, array &$form_state, Editor $editor) { + return $form; } /** * Implements \Drupal\editor\Plugin\EditorInterface::settingsFormValidate(). */ public function settingsFormValidate(array $form, array &$form_state) { - // Use form_set_error() to declare any validation errors. } /** diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/EditorInterface.php b/core/modules/editor/lib/Drupal/editor/Plugin/EditorInterface.php index b1df816..94376c1 100644 --- a/core/modules/editor/lib/Drupal/editor/Plugin/EditorInterface.php +++ b/core/modules/editor/lib/Drupal/editor/Plugin/EditorInterface.php @@ -13,7 +13,7 @@ /** * Defines an interface for configurable text editors. * - * Modules implementing this interface should instead extend the EditorBase + * Modules implementing this interface may want to extend the EditorBase * class, which provides default implementations of each method where * appropriate. */ @@ -26,37 +26,33 @@ * An array of settings as they would be stored by a configured text editor * entity (\Drupal\editor\Plugin\Core\Entity\Editor). */ - function defaultSettings(); + function getDefaultSettings(); /** * Returns a settings form to configure this text editor. * - * Note that this form will be a subform of filter_admin_format_form(). - * Settings within this subform are validated by settingsFormValidate() and - * then saved exactly as specified in $form_state['values'] by - * editor_form_filter_admin_format_submit(). - * * If the editor's behavior depends on extensive options and/or external data, * then the implementing module can choose to provide a separate, global * configuration page rather than per-text-format settings. In that case, this * form should provide a link to the separate settings page. * * @param array $form - * The prepopulated form array of the filter administration form. + * An empty form array to be populated with a configuration form, if any. * @param array $form_state - * The state of the entire configuration form. + * The state of the entire filter administration form. * @param \Drupal\editor\Plugin\Core\Entity\Editor $editor * A configured text editor object. + * * @return array * A render array for the settings form. */ - function settingsForm(array &$form, array &$form_state, Editor $editor); + function settingsForm(array $form, array &$form_state, Editor $editor); /** * Validates the settings form for an editor. * * The contents of the editor settings are located in - * $form_state['values']['editor_settings']. Calls to form_set_error() should + * $form_state['values']['editor_settings']. Calls to form_error() should * reflect this location in the settings form. * * @param array $form @@ -89,6 +85,7 @@ function settingsFormSubmit(array $form, array &$form_state); * * @param \Drupal\editor\Plugin\Core\Entity\Editor $editor * A configured text editor object. + * * @return array * An array of settings that will be added to the page for use by this text * editor's JavaScript integration. diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php index 012462f..a2844ac 100644 --- a/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php +++ b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php @@ -39,7 +39,7 @@ public function __construct() { public function listOptions() { $options = array(); foreach ($this->getDefinitions() as $key => $definition) { - $options[$key] = $definition['title']; + $options[$key] = $definition['label']; } return $options; } @@ -49,6 +49,7 @@ public function listOptions() { * * @param array $format_ids * An array of format IDs as returned by array_keys(filter_formats()). + * * @return array * An array of library attachments, for use with #attached. * diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditorLoadingTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditorLoadingTest.php index c292242..e722716 100644 --- a/core/modules/editor/lib/Drupal/editor/Tests/EditorLoadingTest.php +++ b/core/modules/editor/lib/Drupal/editor/Tests/EditorLoadingTest.php @@ -37,28 +37,7 @@ function setUp() { 'format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, - 'filters' => array( - // URL filter. - 'filter_url' => array( - 'weight' => 0, - 'status' => 1, - ), - // HTML filter. - 'filter_html' => array( - 'weight' => 1, - 'status' => 1, - ), - // Line break filter. - 'filter_autop' => array( - 'weight' => 2, - 'status' => 1, - ), - // HTML corrector filter. - 'filter_htmlcorrector' => array( - 'weight' => 10, - 'status' => 1, - ), - ), + 'filters' => array(), ); $filtered_html_format = (object) $filtered_html_format; filter_format_save($filtered_html_format); @@ -66,9 +45,7 @@ function setUp() { 'format' => 'full_html', 'name' => 'Full HTML', 'weight' => 1, - 'filters' => array( - 'filter_htmlcorrector' => array('status' => 1), - ), + 'filters' => array(), ); $full_html_format = (object) $full_html_format; filter_format_save($full_html_format); @@ -82,7 +59,7 @@ function setUp() { $editor->save(); // Create node type. - $node_type = array( + $this->drupalCreateContentType(array( 'type' => 'article', 'name' => st('Article'), 'base' => 'node_content', @@ -90,14 +67,7 @@ function setUp() { 'custom' => 1, 'modified' => 1, 'locked' => 0, - ); - $node_type = node_type_set_defaults($node_type); - node_type_save($node_type); - node_add_body_field($node_type); - - // The newly added node type has caused some new permissions to become - // available, ensure WebTestBase::checkPermissions() knows about them. - $this->checkPermissions(array(), TRUE); + )); // Create a "normal" and a "privileged" user, only the latter has access to // the "Full HTML" text format (and associated text editor). diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php index 8302722..9c33778 100644 --- a/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php +++ b/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php @@ -49,28 +49,7 @@ function setUp() { 'format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, - 'filters' => array( - // URL filter. - 'filter_url' => array( - 'weight' => 0, - 'status' => 1, - ), - // HTML filter. - 'filter_html' => array( - 'weight' => 1, - 'status' => 1, - ), - // Line break filter. - 'filter_autop' => array( - 'weight' => 2, - 'status' => 1, - ), - // HTML corrector filter. - 'filter_htmlcorrector' => array( - 'weight' => 10, - 'status' => 1, - ), - ), + 'filters' => array(), ); $filtered_html_format = (object) $filtered_html_format; filter_format_save($filtered_html_format); @@ -78,9 +57,7 @@ function setUp() { 'format' => 'full_html', 'name' => 'Full HTML', 'weight' => 1, - 'filters' => array( - 'filter_htmlcorrector' => array('status' => 1), - ), + 'filters' => array(), ); $full_html_format = (object) $full_html_format; filter_format_save($full_html_format); @@ -111,7 +88,7 @@ function testManager() { // Case 3: a text editor available & associated (but associated only with // the 'Full HTML' text format). $unicorn_plugin = $this->editorManager->createInstance('unicorn'); - $default_editor_settings = $unicorn_plugin->defaultSettings(); + $default_editor_settings = $unicorn_plugin->getDefaultSettings(); $editor = entity_create('editor', array( 'name' => 'Full HTML', 'format' => 'full_html', diff --git a/core/modules/editor/tests/modules/lib/Drupal/editor_test/Plugin/editor/editor/UnicornEditor.php b/core/modules/editor/tests/modules/lib/Drupal/editor_test/Plugin/editor/editor/UnicornEditor.php index ed6b3bd..45165ad 100644 --- a/core/modules/editor/tests/modules/lib/Drupal/editor_test/Plugin/editor/editor/UnicornEditor.php +++ b/core/modules/editor/tests/modules/lib/Drupal/editor_test/Plugin/editor/editor/UnicornEditor.php @@ -17,7 +17,7 @@ * * @Plugin( * id = "unicorn", - * title = @Translation("Unicorn Editor"), + * label = @Translation("Unicorn Editor"), * library = { * "module" = "edit_test", * "name" = "unicorn" @@ -28,16 +28,16 @@ class UnicornEditor extends EditorBase { /** - * Implements \Drupal\editor\Plugin\EditorInterface::defaultSettings(). + * Implements \Drupal\editor\Plugin\EditorInterface::getDefaultSettings(). */ - function defaultSettings() { + function getDefaultSettings() { return array('ponies too' => TRUE); } /** * Implements \Drupal\editor\Plugin\EditorInterface::settingsForm(). */ - function settingsForm(array &$form, array &$form_state, Editor $editor) { + function settingsForm(array $form, array &$form_state, Editor $editor) { return array(); }