Commit 8a68d25d authored by webchick's avatar webchick

Issue #2133907 by Wim Leers: Clean up Edit's in-place editors: consistent...

Issue #2133907 by Wim Leers: Clean up Edit's in-place editors: consistent naming, library naming and file naming.
parent d10c0519
......@@ -2,7 +2,7 @@
* @file edit.module.css
*
* Note: every class is prefixed with "edit-" to prevent collisions with modules
* or themes. In IPE-specific DOM subtrees, this is not necessary.
* or themes. In Edit module-specific DOM subtrees, this is not necessary.
*/
/**
......@@ -34,7 +34,7 @@
}
/**
* Edit mode: type=direct.
* In-place editors that don't use a popup.
*/
.edit-validation-errors {
z-index: 300;
......@@ -53,7 +53,7 @@
}
/**
* Edit mode: type=form.
* Styling specific to the 'form' in-place editor.
*/
#edit_backstage {
display: none;
......
......@@ -85,7 +85,7 @@
}
/**
* Edit mode: type=direct.
* In-place editors that don't use a popup.
*/
.edit-validation-errors .messages.error {
box-shadow: 0 0 1px 1px red, 0 0 3px 3px rgba(153, 153, 153, .5);
......@@ -93,7 +93,7 @@
}
/**
* Edit mode: type=form.
* Styling specific to the 'form' in-place editor.
*/
.edit-form {
box-shadow: 0 0 30px 4px #4f4f4f;
......
......@@ -119,7 +119,7 @@ function edit_library_info() {
array('system', 'drupal.dialog'),
),
);
$libraries['edit.editorWidget.form'] = array(
$libraries['edit.inPlaceEditor.form'] = array(
'title' => 'Form in-place editor',
'version' => \Drupal::VERSION,
'js' => array(
......@@ -129,11 +129,11 @@ function edit_library_info() {
array('edit', 'edit'),
),
);
$libraries['edit.editorWidget.direct'] = array(
'title' => 'Direct in-place editor',
$libraries['edit.inPlaceEditor.plainText'] = array(
'title' => 'Plain text in-place editor',
'version' => \Drupal::VERSION,
'js' => array(
$path . '/js/editors/directEditor.js' => $options,
$path . '/js/editors/plainTextEditor.js' => $options,
),
'dependencies' => array(
array('edit', 'edit'),
......@@ -164,12 +164,13 @@ function edit_library_info_alter(&$libraries, $module) {
*
* Edit extends the @FieldFormatter annotation with the following keys:
* - edit: currently only contains one subkey 'editor' which indicates which
* in-place editor should be used. Possible values are 'form', 'direct' or
* 'disabled'.
* in-place editor should be used. Possible values are 'form', 'plain_text',
* 'disabled' or another in-place editor other than the ones Edit module
* provides.
*/
function edit_field_formatter_info_alter(&$info) {
foreach ($info as $key => $settings) {
// Set in-place editor to form if none is supplied.
// Set in-place editor to 'form' if none is supplied.
if (empty($settings['edit'])) {
$info[$key]['edit'] = array('editor' => 'form');
}
......
......@@ -6,7 +6,7 @@
"use strict";
Drupal.edit.editors.direct = Drupal.edit.EditorView.extend({
Drupal.edit.editors.plain_text = Drupal.edit.EditorView.extend({
// Stores the textual DOM element that is being in-place edited.
$textElement: null,
......
......@@ -8,7 +8,7 @@
* Specific in-place editor implementations should subclass (extend) this View
* and override whichever method they deem necessary to override.
*
* Look at Drupal.edit.editors.form and Drupal.edit.editors.direct for
* Look at Drupal.edit.editors.form and Drupal.edit.editors.plain_text for
* examples.
*/
Drupal.edit.EditorView = Backbone.View.extend({
......@@ -24,7 +24,7 @@ Drupal.edit.EditorView = Backbone.View.extend({
* class' initialize()) first, like this:
* Drupal.edit.EditorView.prototype.initialize.call(this, options);
*
* For an example, @see Drupal.edit.editors.direct.
* For an example, @see Drupal.edit.editors.plain_text.
*
* @param Object options
* An object with the following keys:
......@@ -57,7 +57,7 @@ Drupal.edit.EditorView = Backbone.View.extend({
* e.g. using a WYSIWYG editor on a body field should happen on the DOM
* element containing the text itself, not on the field wrapper.
*
* For example, @see Drupal.edit.editors.direct.
* For example, @see Drupal.edit.editors.plain_text.
*
* @return jQuery
* A jQuery-wrapped DOM element.
......@@ -204,7 +204,7 @@ Drupal.edit.EditorView = Backbone.View.extend({
// (hence "backstage" — since the editing doesn't happen in the form, it
// happens "directly" in the content, the form is only used for saving).
var $backstage = $(Drupal.theme('editBackstage', { id: backstageId })).appendTo('body');
// Direct forms are stuffed into the backstage container for this field.
// Hidden forms are stuffed into the backstage container for this field.
var $form = $(form).appendTo($backstage);
// Disable the browser's HTML5 validation; we only care about server-
// side validation. (Not disabling this will actually cause problems
......
......@@ -70,7 +70,7 @@ public function getEditor($formatter_type, FieldDefinitionInterface $field_defin
// Check if the formatter defines an appropriate in-place editor. For
// example, text formatters displaying untrimmed text can choose to use the
// 'direct' editor. If the formatter doesn't specify, fall back to the
// 'plain_text' editor. If the formatter doesn't specify, fall back to the
// 'form' editor, since that can work for any field. Formatter definitions
// can use 'disabled' to explicitly opt out of in-place editing.
$formatter_info = $this->formatterManager->getDefinition($formatter_type);
......
......@@ -12,7 +12,7 @@
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Defines the form editor.
* Defines the form in-place editor.
*
* @InPlaceEditor(
* id = "form"
......@@ -28,12 +28,12 @@ function isCompatible(FieldDefinitionInterface $field_definition, array $items)
}
/**
* Implements \Drupal\edit\EditPluginInterface::getAttachments().
* {@inheritdoc}
*/
public function getAttachments() {
return array(
'library' => array(
array('edit', 'edit.editorWidget.form'),
array('edit', 'edit.inPlaceEditor.form'),
),
);
}
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\edit\Plugin\InPlaceEditor\DirectEditor.
* Contains \Drupal\edit\Plugin\InPlaceEditor\PlainTextEditor.
*/
namespace Drupal\edit\Plugin\InPlaceEditor;
......@@ -12,13 +12,13 @@
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Defines the direct editor.
* Defines the plain text in-place editor.
*
* @InPlaceEditor(
* id = "direct"
* id = "plain_text"
* )
*/
class DirectEditor extends EditorBase {
class PlainTextEditor extends EditorBase {
/**
* {@inheritdoc}
......@@ -41,13 +41,14 @@ function isCompatible(FieldDefinitionInterface $field_definition, array $items)
}
/**
* Implements \Drupal\edit\EditPluginInterface::getAttachments().
* {@inheritdoc}
*/
public function getAttachments() {
return array(
'library' => array(
array('edit', 'edit.editorWidget.direct'),
array('edit', 'edit.inPlaceEditor.plainText'),
),
);
}
}
......@@ -76,7 +76,7 @@ function testText() {
$items = array(array('value' => 'Hello, world!', 'format' => 'full_html'));
// Editor selection without text processing, with cardinality 1.
$this->assertEqual('direct', $this->getSelectedEditor($items, $field_name), "Without text processing, cardinality 1, the 'direct' editor is selected.");
$this->assertEqual('plain_text', $this->getSelectedEditor($items, $field_name), "Without text processing, cardinality 1, the 'plain_text' editor is selected.");
// Editor selection with text processing, cardinality 1.
$this->field_text_instance->settings['text_processing'] = 1;
......@@ -86,7 +86,7 @@ function testText() {
// Editor selection without text processing, cardinality 1 (again).
$this->field_text_instance->settings['text_processing'] = 0;
$this->field_text_instance->save();
$this->assertEqual('direct', $this->getSelectedEditor($items, $field_name), "Without text processing again, cardinality 1, the 'direct' editor is selected.");
$this->assertEqual('plain_text', $this->getSelectedEditor($items, $field_name), "Without text processing again, cardinality 1, the 'plain_text' editor is selected.");
// Editor selection without text processing, cardinality >1
$this->field_text_field->cardinality = 2;
......
......@@ -108,7 +108,7 @@ function testSimpleEntityType() {
$expected_1 = array(
'access' => TRUE,
'label' => 'Simple text field',
'editor' => 'direct',
'editor' => 'plain_text',
'aria' => 'Entity entity_test 1, field Simple text field',
);
$this->assertEqual($expected_1, $metadata_1, 'The correct metadata is generated for the first field.');
......
......@@ -12,11 +12,11 @@
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Defines the wysiwyg editor.
* Defines the 'wysiwyg' in-place editor.
*
* @InPlaceEditor(
* id = "wysiwyg",
* alternativeTo = {"direct"}
* alternativeTo = {"plain_text"}
* )
*/
class WysiwygEditor extends EditorBase {
......
......@@ -111,8 +111,8 @@ function editor_library_info() {
),
);
$libraries['edit.formattedTextEditor.editor'] = array(
'title' => 'Formatted text editor',
$libraries['edit.inPlaceEditor.formattedText'] = array(
'title' => 'Formatted text in-place editor',
'version' => \Drupal::VERSION,
'js' => array(
$path . '/js/editor.formattedTextEditor.js' => array(
......
......@@ -14,11 +14,11 @@
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Defines the formatted text editor.
* Defines the formatted text in-place editor.
*
* @InPlaceEditor(
* id = "editor",
* alternativeTo = {"direct"}
* alternativeTo = {"plain_text"}
* )
*/
class Editor extends PluginBase implements EditPluginInterface {
......@@ -65,7 +65,7 @@ protected function textFormatHasTransformationFilters($format_id) {
}
/**
* Implements \Drupal\edit\EditPluginInterface::getAttachments().
* {@inheritdoc}
*/
public function getAttachments() {
$user = \Drupal::currentUser();
......@@ -87,7 +87,7 @@ public function getAttachments() {
$attachments = $manager->getAttachments($formats);
// Also include editor.module's formatted text editor.
$attachments['library'][] = array('editor', 'edit.formattedTextEditor.editor');
$attachments['library'][] = array('editor', 'edit.inPlaceEditor.formattedText');
return $attachments;
}
......
......@@ -22,7 +22,7 @@
* "text_with_summary"
* },
* edit = {
* "editor" = "direct"
* "editor" = "plain_text"
* }
* )
*/
......
......@@ -22,7 +22,7 @@
* "text_with_summary"
* },
* edit = {
* "editor" = "direct"
* "editor" = "plain_text"
* }
* )
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment