class Editor
Same name in this branch
- 9 core/modules/quickedit/src/Plugin/InPlaceEditor/Editor.php \Drupal\quickedit\Plugin\InPlaceEditor\Editor
- 9 core/modules/editor/src/Entity/Editor.php \Drupal\editor\Entity\Editor
- 9 core/modules/editor/src/Annotation/Editor.php \Drupal\editor\Annotation\Editor
Same name in other branches
- 8.9.x core/modules/editor/src/Entity/Editor.php \Drupal\editor\Entity\Editor
- 8.9.x core/modules/editor/src/Annotation/Editor.php \Drupal\editor\Annotation\Editor
- 8.9.x core/modules/editor/src/Plugin/InPlaceEditor/Editor.php \Drupal\editor\Plugin\InPlaceEditor\Editor
- 10 core/modules/editor/src/Entity/Editor.php \Drupal\editor\Entity\Editor
- 10 core/modules/editor/src/Annotation/Editor.php \Drupal\editor\Annotation\Editor
- 11.x core/modules/editor/src/Entity/Editor.php \Drupal\editor\Entity\Editor
- 11.x core/modules/editor/src/Annotation/Editor.php \Drupal\editor\Annotation\Editor
- 11.x core/modules/editor/src/Attribute/Editor.php \Drupal\editor\Attribute\Editor
- 10 core/modules/editor/src/Attribute/Editor.php \Drupal\editor\Attribute\Editor
Defines the formatted text in-place editor.
Plugin annotation
@InPlaceEditor(
id = "editor"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\editor\Plugin\InPlaceEditor\Editor extends \Drupal\Component\Plugin\PluginBase implements \Drupal\quickedit\Plugin\InPlaceEditorInterface
Expanded class hierarchy of Editor
Deprecated
in drupal:9.5.0 and is removed from drupal:10.0.0. There is no replacement.
See also
https://www.drupal.org/node/3271653
56 string references to 'Editor'
- CKEditor5::assessActiveTextEditorAfterBuild in core/
modules/ ckeditor5/ src/ Plugin/ Editor/ CKEditor5.php - Form #after_build callback: provides text editor state changes.
- CKEditor5::buildConfigurationForm in core/
modules/ ckeditor5/ src/ Plugin/ Editor/ CKEditor5.php - Form constructor.
- CKEditor5::submitConfigurationForm in core/
modules/ ckeditor5/ src/ Plugin/ Editor/ CKEditor5.php - Form submission handler.
- CKEditor5::validateConfigurationForm in core/
modules/ ckeditor5/ src/ Plugin/ Editor/ CKEditor5.php - Form validation handler.
- CKEditor5ImageController::upload in core/
modules/ ckeditor5/ src/ Controller/ CKEditor5ImageController.php - Uploads and saves an image from a CKEditor 5 POST.
File
-
core/
modules/ editor/ src/ Plugin/ InPlaceEditor/ Editor.php, line 23
Namespace
Drupal\editor\Plugin\InPlaceEditorView source
class Editor extends PluginBase implements InPlaceEditorInterface {
/**
* Constructs an Editor object.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
@trigger_error('Drupal\\editor\\InPlaceEditor\\Editor is deprecated in drupal:9.5.0 and is removed from drupal:10.0.0. There is no replacement. See https://www.drupal.org/node/3271653', E_USER_DEPRECATED);
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public function isCompatible(FieldItemListInterface $items) {
$field_definition = $items->getFieldDefinition();
// This editor is incompatible with multivalued fields.
if ($field_definition->getFieldStorageDefinition()
->getCardinality() != 1) {
return FALSE;
}
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;
}
/**
* {@inheritdoc}
*/
public function getMetadata(FieldItemListInterface $items) {
$format_id = $items[0]->format;
$metadata['format'] = $format_id;
$metadata['formatHasTransformations'] = $this->textFormatHasTransformationFilters($format_id);
return $metadata;
}
/**
* Returns whether the text format has transformation filters.
*
* @param int $format_id
* A text format ID.
*
* @return bool
*/
protected function textFormatHasTransformationFilters($format_id) {
$format = FilterFormat::load($format_id);
return (bool) count(array_intersect([
FilterInterface::TYPE_TRANSFORM_REVERSIBLE,
FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE,
], $format->getFiltertypes()));
}
/**
* {@inheritdoc}
*/
public function getAttachments() {
$user = \Drupal::currentUser();
$user_format_ids = array_keys(filter_formats($user));
$manager = \Drupal::service('plugin.manager.editor');
$definitions = $manager->getDefinitions();
// Filter the current user's formats to those that support inline editing.
$formats = [];
foreach ($user_format_ids as $format_id) {
if ($editor = editor_load($format_id)) {
$editor_id = $editor->getEditor();
if (isset($definitions[$editor_id]['supports_inline_editing']) && $definitions[$editor_id]['supports_inline_editing'] === TRUE) {
$formats[] = $format_id;
}
}
}
// Get the attachments for all text editors that the user might use.
$attachments = $manager->getAttachments($formats);
// Also include editor.module's formatted text editor.
$attachments['library'][] = 'quickedit/quickedit.inPlaceEditor.formattedText';
return $attachments;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
Editor::getAttachments | public | function | Returns the attachments for this editor. | Overrides InPlaceEditorInterface::getAttachments |
Editor::getMetadata | public | function | Generates metadata that is needed specifically for this editor. | Overrides InPlaceEditorInterface::getMetadata |
Editor::isCompatible | public | function | Checks whether this in-place editor is compatible with a given field. | Overrides InPlaceEditorInterface::isCompatible |
Editor::textFormatHasTransformationFilters | protected | function | Returns whether the text format has transformation filters. | |
Editor::__construct | public | function | Constructs an Editor object. | Overrides PluginBase::__construct |
PluginBase::$configuration | protected | property | Configuration information passed into the plugin. | |
PluginBase::$pluginDefinition | protected | property | The plugin implementation definition. | |
PluginBase::$pluginId | protected | property | The plugin_id. | |
PluginBase::DERIVATIVE_SEPARATOR | constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase::getBaseId | public | function | Gets the base_plugin_id of the plugin instance. | Overrides DerivativeInspectionInterface::getBaseId |
PluginBase::getDerivativeId | public | function | Gets the derivative_id of the plugin instance. | Overrides DerivativeInspectionInterface::getDerivativeId |
PluginBase::getPluginDefinition | public | function | Gets the definition of the plugin implementation. | Overrides PluginInspectionInterface::getPluginDefinition |
PluginBase::getPluginId | public | function | Gets the plugin_id of the plugin instance. | Overrides PluginInspectionInterface::getPluginId |
PluginBase::isConfigurable | public | function | Determines if the plugin is configurable. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.