core/modules/editor/editor.module | 15 +++++---------- core/modules/editor/src/Plugin/InPlaceEditor/Editor.php | 14 ++++++-------- .../src/Plugin/InPlaceEditor/PlainTextEditor.php | 2 +- .../modules/quickedit/tests/modules/quickedit_test.module | 12 ++++++++++++ .../modules/src/Plugin/InPlaceEditor/WysiwygEditor.php | 7 +------ 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index b785947..d615562 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -70,17 +70,12 @@ function editor_element_info_alter(&$types) { * @see quickedit_field_formatter_info_alter() */ function editor_field_formatter_info_alter(&$info) { - foreach ($info as $key => $settings) { - // Update \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter's - // annotation to indicate that it supports the 'editor' in-place editor - // provided by this module. - if ($key === 'text_default') { - if (empty($settings['quickedit'])) { - $info[$key]['quickedit'] = ['editor' => 'editor']; - } - } - } + // Update \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter's + // annotation to indicate that it supports the 'editor' in-place editor + // provided by this module. + $info['text_default']['quickedit'] = ['editor' => 'editor']; } + /** * Implements hook_form_FORM_ID_alter(). */ diff --git a/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php b/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php index 60cf7b5..508b3e7 100644 --- a/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php +++ b/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php @@ -34,16 +34,14 @@ public function isCompatible(FieldItemListInterface $items) { // This editor is compatible with formatted ("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'), TRUE)) { - if ($editor = editor_load($items[0]->format)) { - $definition = \Drupal::service('plugin.manager.editor')->getDefinition($editor->getEditor()); - if ($definition['supports_inline_editing'] === TRUE) { - return TRUE; - } + elseif ($editor = editor_load($items[0]->format)) { + $definition = \Drupal::service('plugin.manager.editor')->getDefinition($editor->getEditor()); + if ($definition['supports_inline_editing'] === TRUE) { + return TRUE; } - - return FALSE; } + + return FALSE; } /** diff --git a/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php b/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php index a3a8e73..b01d700 100644 --- a/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php +++ b/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php @@ -26,7 +26,7 @@ public function isCompatible(FieldItemListInterface $items) { $field_definition = $items->getFieldDefinition(); // This editor is incompatible with multivalued fields. - return $field_definition->getFieldStorageDefinition()->getCardinality() != 1; + return $field_definition->getFieldStorageDefinition()->getCardinality() == 1; } /** diff --git a/core/modules/quickedit/tests/modules/quickedit_test.module b/core/modules/quickedit/tests/modules/quickedit_test.module index 4a1a2ef..5b6b3f7 100644 --- a/core/modules/quickedit/tests/modules/quickedit_test.module +++ b/core/modules/quickedit/tests/modules/quickedit_test.module @@ -21,3 +21,15 @@ function quickedit_test_quickedit_render_field(EntityInterface $entity, $field_n ); } +/** + * Implements hook_field_formatter_info_alter(). + * + * @see quickedit_field_formatter_info_alter() + * @see editor_field_formatter_info_alter() + */ +function quickedit_test_field_formatter_info_alter(&$info) { + // Update \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter's + // annotation to indicate that it supports the 'wysiwyg' in-place editor + // provided by this module. + $info['text_default']['quickedit'] = ['editor' => 'wysiwyg']; +} 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 64cbfad..8e3a227 100644 --- a/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php +++ b/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php @@ -32,12 +32,7 @@ public function isCompatible(FieldItemListInterface $items) { // This editor is compatible with formatted ("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'), TRUE)) { - if ($items[0]->format === 'full_html') { - return TRUE; - } - return FALSE; - } + return $items[0]->format === 'full_html'; } /**