0

In Magento 2.3 i'm trying to modify the link plugin to add a field to select a class for the link.

I had something like this in Magento1 :

enter image description here*

I wish to have the same here in Magento 2.3 :

enter image description here

I tried to follow the TinyMCE4 doc https://www.tiny.cloud/docs-4x/plugins/link/ with the "link_class_list" option with no success.

Following the M2.3 doc did not help me, https://devdocs.magento.com/guides/v2.3/ui_comp_guide/components/ui-wysiwyg.html

What is the best way to add option to an existing plugin in magento 2.3 ?

Thank you

0

So I found a way to solve my issue. I created a plugin on Magento\Cms\Model\Wysiwyg\Config

<type name="Magento\Cms\Model\Wysiwyg\Config">
    <plugin name="add_link_class_selector_to_wysiwyg" type="Vendor\Module\Plugin\WysiwygConfigPlugin" sortOrder="10" />
</type>

And my plugin file

<?php

namespace Vendor\Module\Plugin;

class WysiwygConfigPlugin {
    public function afterGetConfig(\Magento\Cms\Model\Wysiwyg\Config $subject, \Magento\Framework\DataObject $config)
    {
        $config->addData(
            [
                'settings' => [
                    'link_class_list' => [
                        ['title'=> 'None', 'value'=> '0'],
                        ['title'=> 'test', 'value'=> '1']
                    ]
                ]
            ]
        );
        return $config;
    }
}

I'm not sure this is the best way but it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.