Skip to content
Snippets Groups Projects
Verified Commit c84ae09d authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3421011 by sorlov, Wim Leers, quietone, kalpanajaiswal, mstrelan,...

Issue #3421011 by sorlov, Wim Leers, quietone, kalpanajaiswal, mstrelan, Ruturaj Chaubey, smustgrave, larowlan: Convert Editor plugin discovery to attributes

(cherry picked from commit e7159707)
parent cca3f394
No related branches found
No related tags found
27 merge requests!11958Issue #3490507 by alexpott, smustgrave: Fix bogus mocking in...,!11769Issue #3517987: Add option to contextual filters to encode slashes in query parameter.,!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9944Issue #3483353: Consider making the createCopy config action optionally fail...,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!8738Issue #3424162 by camilledavis, dineshkumarbollu, smustgrave: Claro...,!8704Make greek characters available in ckeditor5,!8597Draft: Issue #3442259 by catch, quietone, dww: Reduce time of Migrate Upgrade tests...,!8533Issue #3446962 by kim.pepper: Remove incorrectly added...,!8517Issue #3443748 by NexusNovaz, smustgrave: Testcase creates false positive,!8325Update file Sort.php,!8095Expose document root on install,!7930Resolve #3427374 "Taxonomytid viewsargumentdefault plugin",!7627Issue #3439440 by nicxvan, Binoli Lalani, longwave: Remove country support from DateFormatter,!7445Issue #3440169: When using drupalGet(), provide an associative array for $headers,!7401#3271894 Fix documented StreamWrapperInterface return types for realpath() and dirname(),!7384Add constraints to system.advisories,!6622Issue #2559833 by piggito, mohit_aghera, larowlan, guptahemant, vakulrai,...,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #124005 passed
Pipeline: drupal

#124031

    Pipeline: drupal

    #124022

      Pipeline: drupal

      #124018

        +1
        ......@@ -20,9 +20,11 @@
        use Drupal\Core\Messenger\MessengerInterface;
        use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
        use Drupal\ckeditor5\SmartDefaultSettings;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint;
        use Drupal\editor\Attribute\Editor;
        use Drupal\editor\EditorInterface;
        use Drupal\editor\Entity\Editor;
        use Drupal\editor\Entity\Editor as EditorEntity;
        use Drupal\editor\Plugin\EditorBase;
        use Drupal\filter\FilterFormatInterface;
        use Psr\Log\LoggerInterface;
        ......@@ -33,20 +35,19 @@
        /**
        * Defines a CKEditor 5-based text editor for Drupal.
        *
        * @Editor(
        * id = "ckeditor5",
        * label = @Translation("CKEditor 5"),
        * supports_content_filtering = TRUE,
        * supports_inline_editing = TRUE,
        * is_xss_safe = FALSE,
        * supported_element_types = {
        * "textarea"
        * }
        * )
        *
        * @internal
        * Plugin classes are internal.
        */
        #[Editor(
        id: 'ckeditor5',
        label: new TranslatableMarkup('CKEditor 5'),
        supports_content_filtering: TRUE,
        supports_inline_editing: TRUE,
        is_xss_safe: FALSE,
        supported_element_types: [
        'textarea',
        ]
        )]
        class CKEditor5 extends EditorBase implements ContainerFactoryPluginInterface {
        /**
        ......@@ -532,7 +533,7 @@ public static function assessActiveTextEditorAfterBuild(array $element, FormStat
        */
        public static function validateSwitchingToCKEditor5(array $form, FormStateInterface $form_state): void {
        if (!$form_state->get('ckeditor5_is_active') && $form_state->get('ckeditor5_is_selected')) {
        $minimal_ckeditor5_editor = Editor::create([
        $minimal_ckeditor5_editor = EditorEntity::create([
        'format' => NULL,
        'editor' => 'ckeditor5',
        ]);
        ......@@ -943,7 +944,7 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s
        /**
        * {@inheritdoc}
        */
        public function getJSSettings(Editor $editor) {
        public function getJSSettings(EditorEntity $editor) {
        $toolbar_items = $editor->getSettings()['toolbar']['items'];
        $plugin_config = $this->ckeditor5PluginManager->getCKEditor5PluginConfig($editor);
        ......@@ -965,7 +966,7 @@ public function getJSSettings(Editor $editor) {
        /**
        * {@inheritdoc}
        */
        public function getLibraries(Editor $editor) {
        public function getLibraries(EditorEntity $editor) {
        $plugin_libraries = $this->ckeditor5PluginManager->getEnabledLibraries($editor);
        if ($this->moduleHandler->moduleExists('locale')) {
        ......
        <?php
        namespace Drupal\editor\Attribute;
        use Drupal\Component\Plugin\Attribute\Plugin;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        /**
        * Defines an Editor attribute object.
        *
        * Plugin Namespace: Plugin\Editor
        *
        * For a working example, see \Drupal\ckeditor5\Plugin\Editor\CKEditor5
        *
        * @see \Drupal\editor\Plugin\EditorPluginInterface
        * @see \Drupal\editor\Plugin\EditorBase
        * @see \Drupal\editor\Plugin\EditorManager
        * @see hook_editor_info_alter()
        * @see plugin_api
        */
        #[\Attribute(\Attribute::TARGET_CLASS)]
        class Editor extends Plugin {
        /**
        * Constructs an Editor object.
        *
        * @param string $id
        * The plugin ID.
        * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
        * The human-readable name of the text editor, translated
        * @param bool $supports_content_filtering
        * Whether the editor supports "allowed content only" filtering.
        * @param bool $supports_inline_editing
        * Whether the editor supports the inline editing provided by the Edit
        * module.
        * @param bool $is_xss_safe
        * Whether this text editor is not vulnerable to XSS attacks.
        * @param string[] $supported_element_types
        * On which form element #types this text editor is capable of working.
        * @param class-string|null $deriver
        * (optional) The deriver class.
        */
        public function __construct(
        public readonly string $id,
        public readonly TranslatableMarkup $label,
        public readonly bool $supports_content_filtering,
        public readonly bool $supports_inline_editing,
        public readonly bool $is_xss_safe,
        public readonly array $supported_element_types,
        public readonly ?string $deriver = NULL,
        ) {}
        }
        ......@@ -5,6 +5,7 @@
        use Drupal\Core\Plugin\DefaultPluginManager;
        use Drupal\Core\Cache\CacheBackendInterface;
        use Drupal\Core\Extension\ModuleHandlerInterface;
        use Drupal\editor\Attribute\Editor;
        /**
        * Configurable text editor manager.
        ......@@ -28,7 +29,7 @@ class EditorManager extends DefaultPluginManager {
        * The module handler to invoke the alter hook with.
        */
        public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
        parent::__construct('Plugin/Editor', $namespaces, $module_handler, 'Drupal\editor\Plugin\EditorPluginInterface', 'Drupal\editor\Annotation\Editor');
        parent::__construct('Plugin/Editor', $namespaces, $module_handler, 'Drupal\editor\Plugin\EditorPluginInterface', Editor::class, 'Drupal\editor\Annotation\Editor');
        $this->alterInfo('editor_info');
        $this->setCacheBackend($cache_backend, 'editor_plugins');
        }
        ......
        ......@@ -3,23 +3,24 @@
        namespace Drupal\editor_test\Plugin\Editor;
        use Drupal\Core\Form\FormStateInterface;
        use Drupal\editor\Entity\Editor;
        use Drupal\editor\Attribute\Editor;
        use Drupal\editor\Entity\Editor as EditorEntity;
        use Drupal\editor\Plugin\EditorBase;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        /**
        * Defines a Tyrannosaurus-Rex powered text editor for testing purposes.
        *
        * @Editor(
        * id = "trex",
        * label = @Translation("TRex Editor"),
        * supports_content_filtering = TRUE,
        * supports_inline_editing = TRUE,
        * is_xss_safe = FALSE,
        * supported_element_types = {
        * "textarea",
        * }
        * )
        */
        #[Editor(
        id: 'trex',
        label: new TranslatableMarkup('TRex Editor'),
        supports_content_filtering: TRUE,
        supports_inline_editing: TRUE,
        is_xss_safe: FALSE,
        supported_element_types: [
        'textarea',
        ]
        )]
        class TRexEditor extends EditorBase {
        /**
        ......@@ -44,7 +45,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
        /**
        * {@inheritdoc}
        */
        public function getJSSettings(Editor $editor) {
        public function getJSSettings(EditorEntity $editor) {
        $js_settings = [];
        $settings = $editor->getSettings();
        if ($settings['stumpy_arms']) {
        ......@@ -56,7 +57,7 @@ public function getJSSettings(Editor $editor) {
        /**
        * {@inheritdoc}
        */
        public function getLibraries(Editor $editor) {
        public function getLibraries(EditorEntity $editor) {
        return [
        'editor_test/trex',
        ];
        ......
        ......@@ -3,24 +3,25 @@
        namespace Drupal\editor_test\Plugin\Editor;
        use Drupal\Core\Form\FormStateInterface;
        use Drupal\editor\Entity\Editor;
        use Drupal\editor\Attribute\Editor;
        use Drupal\editor\Entity\Editor as EditorEntity;
        use Drupal\editor\Plugin\EditorBase;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        /**
        * Defines a Unicorn-powered text editor for Drupal (for testing purposes).
        *
        * @Editor(
        * id = "unicorn",
        * label = @Translation("Unicorn Editor"),
        * supports_content_filtering = TRUE,
        * supports_inline_editing = TRUE,
        * is_xss_safe = FALSE,
        * supported_element_types = {
        * "textarea",
        * "textfield",
        * }
        * )
        */
        #[Editor(
        id: 'unicorn',
        label: new TranslatableMarkup('Unicorn Editor'),
        supports_content_filtering: TRUE,
        supports_inline_editing: TRUE,
        is_xss_safe: FALSE,
        supported_element_types: [
        'textarea',
        'textfield',
        ]
        )]
        class UnicornEditor extends EditorBase {
        /**
        ......@@ -61,7 +62,7 @@ public function validateImageUploadSettings(array $element, FormStateInterface $
        /**
        * {@inheritdoc}
        */
        public function getJSSettings(Editor $editor) {
        public function getJSSettings(EditorEntity $editor) {
        $js_settings = [];
        $settings = $editor->getSettings();
        if ($settings['ponies_too']) {
        ......@@ -73,7 +74,7 @@ public function getJSSettings(Editor $editor) {
        /**
        * {@inheritdoc}
        */
        public function getLibraries(Editor $editor) {
        public function getLibraries(EditorEntity $editor) {
        return [
        'editor_test/unicorn',
        ];
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment