core/modules/editor/editor.module | 24 +++++++++++----------- .../editor/js/editor.formattedTextEditor.js | 10 ++++----- .../src/Ajax/GetUntransformedTextCommand.php | 2 +- core/modules/editor/src/EditorController.php | 8 ++++---- .../editor/src/Plugin/InPlaceEditor/Editor.php | 2 +- .../editor/src/Tests/QuickEditIntegrationTest.php | 4 ++-- .../src/Plugin/InPlaceEditor/PlainTextEditor.php | 7 ++----- .../quickedit/src/Tests/EditorSelectionTest.php | 16 +++++++-------- .../src/Plugin/InPlaceEditor/WysiwygEditor.php | 2 +- 9 files changed, 36 insertions(+), 39 deletions(-) diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 8aabbf3..07b5213 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -401,7 +401,7 @@ function editor_entity_revision_delete(EntityInterface $entity) { } /** - * Records file usage of files referenced by processed text fields. + * Records file usage of files referenced by filtered text fields. * * Every referenced file that does not yet have the FILE_STATUS_PERMANENT state, * will be given that state. @@ -423,7 +423,7 @@ function _editor_record_file_usage(array $uuids, EntityInterface $entity) { } /** - * Deletes file usage of files referenced by processed text fields. + * Deletes file usage of files referenced by filtered text fields. * * @param array $uuids * An array of file entity UUIDs. @@ -443,7 +443,7 @@ function _editor_delete_file_usage(array $uuids, EntityInterface $entity, $count } /** - * Finds all files referenced (data-editor-file-uuid) by processed text fields. + * Finds all files referenced (data-editor-file-uuid) by filtered text fields. * * @param EntityInterface $entity * An entity whose fields to analyze. @@ -454,30 +454,30 @@ function _editor_delete_file_usage(array $uuids, EntityInterface $entity, $count function _editor_get_file_uuids_by_field(EntityInterface $entity) { $uuids = array(); - $processed_text_fields = _editor_get_processed_text_fields($entity); - foreach ($processed_text_fields as $processed_text_field) { - $text = $entity->get($processed_text_field)->value; - $uuids[$processed_text_field] = _editor_parse_file_uuids($text); + $filtered_text_fields = _editor_get_filtered_text_fields($entity); + foreach ($filtered_text_fields as $filtered_text_field) { + $text = $entity->get($filtered_text_field)->value; + $uuids[$filtered_text_field] = _editor_parse_file_uuids($text); } return $uuids; } /** - * Determines the text fields on an entity that have text processing enabled. + * Determines the filtered text fields on an entity. * - * @param EntityInterface $entity + * @param ContentEntityInterface $entity * An entity whose fields to analyze. * * @return array - * The names of the fields on this entity that have text processing enabled. + * The names of the fields on this entity that support filtered text. */ -function _editor_get_processed_text_fields(ContentEntityInterface $entity) { +function _editor_get_filtered_text_fields(ContentEntityInterface $entity) { $field_definitions = $entity->getFieldDefinitions(); if (empty($field_definitions)) { return array(); } - // Only return text fields. + // Only return filtered text fields. return array_keys(array_filter($field_definitions, function (FieldDefinitionInterface $definition) { return in_array($definition->getType(), array('text', 'text_long', 'text_with_summary')); })); diff --git a/core/modules/editor/js/editor.formattedTextEditor.js b/core/modules/editor/js/editor.formattedTextEditor.js index 29d7eb3..082316a 100644 --- a/core/modules/editor/js/editor.formattedTextEditor.js +++ b/core/modules/editor/js/editor.formattedTextEditor.js @@ -1,6 +1,6 @@ /** * @file - * Text editor-based in-place editor for processed text content in Drupal. + * Text editor-based in-place editor for filtered text content in Drupal. * * Depends on editor.module. Works with any (WYSIWYG) editor that implements the * editor.js API, including the optional attachInlineEditor() and onChange() @@ -78,9 +78,9 @@ break; case 'activating': - // When transformation filters have been been applied to the processed - // text of this field, then we'll need to load a re-processed version of - // it without the transformation filters. + // When transformation filters have been been applied to the filtered + // text of this field, then we'll need to load a re-filtered version + // of it without the transformation filters. if (this.textFormatHasTransformations) { var $textElement = this.$textElement; this._getUntransformedText(function (untransformedText) { @@ -151,7 +151,7 @@ /** * Loads untransformed text for this field. * - * More accurately: it re-processes processed text to exclude transformation + * More accurately: it re-filters filtered text to exclude transformation * filters used by the text format. * * @param Function callback diff --git a/core/modules/editor/src/Ajax/GetUntransformedTextCommand.php b/core/modules/editor/src/Ajax/GetUntransformedTextCommand.php index 99f8d4e..0429aa4 100644 --- a/core/modules/editor/src/Ajax/GetUntransformedTextCommand.php +++ b/core/modules/editor/src/Ajax/GetUntransformedTextCommand.php @@ -11,7 +11,7 @@ use Drupal\quickedit\Ajax\BaseCommand; /** - * AJAX command to rerender a processed text field without any transformation + * AJAX command to rerender a filtered text field without any transformation * filters. */ class GetUntransformedTextCommand extends BaseCommand { diff --git a/core/modules/editor/src/EditorController.php b/core/modules/editor/src/EditorController.php index e5a768e..618d91a 100644 --- a/core/modules/editor/src/EditorController.php +++ b/core/modules/editor/src/EditorController.php @@ -30,14 +30,14 @@ class EditorController extends ControllerBase { * Returns an Ajax response to render a text field without transformation filters. * * @param int $entity - * The entity of which a processed text field is being rerendered. + * The entity of which a filtered text field is being rerendered. * @param string $field_name - * The name of the (processed text) field that that is being rerendered + * The name of the (filtered text) field that that is being rerendered * @param string $langcode - * The name of the language for which the processed text field is being + * The name of the language for which the filtered text field is being * rererendered. * @param string $view_mode_id - * The view mode the processed text field should be rerendered in. + * The view mode the filtered text field should be rerendered in. * * @return \Drupal\Core\Ajax\AjaxResponse * The Ajax response. diff --git a/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php b/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php index d50d6fc..bc348bd 100644 --- a/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php +++ b/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php @@ -32,7 +32,7 @@ public function isCompatible(FieldItemListInterface $items) { if ($field_definition->getFieldStorageDefinition()->getCardinality() != 1) { return FALSE; } - // This editor is compatible with processed ("rich") text fields; but only + // This editor is compatible with filtered ("rich") text fields; but only // if there is a currently active text format, that text format has an // associated editor and that editor supports inline editing. elseif (in_array($field_definition->getType(), array('text', 'text_long', 'text_with_summary'))) { diff --git a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php index 4da4162..d23baef 100644 --- a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php +++ b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php @@ -121,7 +121,7 @@ protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'defa /** * Tests editor selection when the Editor module is present. * - * Tests a textual field, with text processing, with cardinality 1 and >1, + * Tests a textual field, with text filtering, with cardinality 1 and >1, * always with a ProcessedTextEditor plug-in present, but with varying text * format compatibility. */ @@ -143,7 +143,7 @@ public function testEditorSelection() { $this->entity->save(); $this->assertEqual('editor', $this->getSelectedEditor($this->entity->id(), $this->field_name), "With cardinality 1, and the full_html text format, the 'editor' editor is selected."); - // Editor selection with text processing, cardinality >1 + // Editor selection with text filtering, cardinality >1 $this->field_textarea_field_storage->cardinality = 2; $this->field_textarea_field_storage->save(); $this->assertEqual('form', $this->getSelectedEditor($this->entity->id(), $this->field_name), "With cardinality >1, and both items using the full_html text format, the 'form' editor is selected."); diff --git a/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php b/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php index e7b40be..f62b3fa 100644 --- a/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php +++ b/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php @@ -21,9 +21,6 @@ class PlainTextEditor extends InPlaceEditorBase { /** * {@inheritdoc} - * - * @todo The processed text logic is too coupled to text fields. Figure out - * how to generalize to other textual field types. */ public function isCompatible(FieldItemListInterface $items) { $field_definition = $items->getFieldDefinition(); @@ -32,8 +29,8 @@ public function isCompatible(FieldItemListInterface $items) { if ($field_definition->getFieldStorageDefinition()->getCardinality() != 1) { return FALSE; } - // This editor is incompatible with processed ("rich") text fields. - elseif (!in_array($field_definition->getType(), array('string', 'string_long'))) { + // This editor is incompatible with filtered ("rich") text fields. + elseif (in_array($field_definition->getType(), array('text', 'text_long', 'text_with_summary'))) { return FALSE; } else { diff --git a/core/modules/quickedit/src/Tests/EditorSelectionTest.php b/core/modules/quickedit/src/Tests/EditorSelectionTest.php index c5b958a..830ac09 100644 --- a/core/modules/quickedit/src/Tests/EditorSelectionTest.php +++ b/core/modules/quickedit/src/Tests/EditorSelectionTest.php @@ -50,7 +50,7 @@ protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'defa } /** - * Tests a textual field, without/with text processing, with cardinality 1 and + * Tests a textual field, without/with text filtering, with cardinality 1 and * >1, always without a WYSIWYG editor present. */ public function testText() { @@ -72,19 +72,19 @@ public function testText() { $this->entity->{$field_name}->value = 'Hello, world!'; $this->entity->save(); - // Editor selection without text processing, with cardinality 1. - $this->assertEqual('plain_text', $this->getSelectedEditor($this->entity->id(), $field_name), "Without text processing, cardinality 1, the 'plain_text' editor is selected."); + // Editor selection without text filtering, with cardinality 1. + $this->assertEqual('plain_text', $this->getSelectedEditor($this->entity->id(), $field_name), "Without text filtering, cardinality 1, the 'plain_text' editor is selected."); - // Editor selection without text processing, cardinality >1 + // Editor selection without text filtering, cardinality >1 $this->field_text_field_storage->cardinality = 2; $this->field_text_field_storage->save(); - $this->assertEqual('form', $this->getSelectedEditor($this->entity->id(), $field_name), "Without text processing, cardinality >1, the 'form' editor is selected."); + $this->assertEqual('form', $this->getSelectedEditor($this->entity->id(), $field_name), "Without text filtering, cardinality >1, the 'form' editor is selected."); } /** - * Tests a textual field, with text processing, with cardinality 1 and >1, + * Tests a textual field, with text filtering, with cardinality 1 and >1, * always with an Editor plugin present that supports textual fields with text - * processing, but with varying text format compatibility. + * filtering, but with varying text format compatibility. */ public function testTextWysiwyg() { // Enable edit_test module so that the 'wysiwyg' editor becomes available. @@ -119,7 +119,7 @@ public function testTextWysiwyg() { $this->entity->save(); $this->assertEqual('wysiwyg', $this->getSelectedEditor($this->entity->id(), $field_name), "With cardinality 1, and the full_html text format, the 'wysiwyg' editor is selected."); - // Editor selection with text processing, cardinality >1 + // Editor selection with text filtering, cardinality >1 $this->field_textarea_field_storage->cardinality = 2; $this->field_textarea_field_storage->save(); $this->assertEqual('form', $this->getSelectedEditor($this->entity->id(), $field_name), "With cardinality >1, and both items using the full_html text format, the 'form' editor is selected."); diff --git a/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php b/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php index b916dcd..aa61515 100644 --- a/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php +++ b/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php @@ -30,7 +30,7 @@ public function isCompatible(FieldItemListInterface $items) { if ($field_definition->getFieldStorageDefinition()->getCardinality() != 1) { return FALSE; } - // This editor is compatible with processed ("rich") text fields; but only + // This editor is compatible with filtered ("rich") text fields; but only // if there is a currently active text format and that text format is the // 'full_html' text format. elseif (in_array($field_definition->getType(), array('text', 'text_long', 'text_with_summary'))) {