I want to use Ckeditor instead of tinymce text editor in admin part.
Solved! Go to Solution.
Hi @punithluxe0e42
You need to do customisation with custom module for this changes.
You can try below code :
1) Create the directory [app/code/vendor/module]: app/code/Vendor/Module
2) Create app/code/Vendor/Module/etc/di.xml:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Ui\Component\Wysiwyg\ConfigInterface">
<plugin name="vendor_module_config"
type="Vendor\Module\Plugin\Config"
sortOrder="10"/>
</type>
</config>3) Create app/code/Vendor/Module/etc/module.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Project_Customtinymce" setup_version="0.1.0"/>
</config>4) Create app/code/Project/Customtinymce/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Vendor_Module',
__DIR__
);5) Create the after plugin app/code/Vendor/Module/Plugin/Config.php:
<?php
namespace Vendor\Module\Plugin;
class Config
{
protected $activeEditor;
public function __construct(\Magento\Ui\Block\Wysiwyg\ActiveEditor $activeEditor)
{
$this->activeEditor = $activeEditor;
}
/**
* Return WYSIWYG configuration
*
* @param \Magento\Ui\Component\Wysiwyg\ConfigInterface $configInterface
* @param \Magento\Framework\DataObject $result
* @return \Magento\Framework\DataObject
*/
public function afterGetConfig(
\Magento\Ui\Component\Wysiwyg\ConfigInterface $configInterface,
\Magento\Framework\DataObject $result
) {
// Get current wysiwyg adapter's path
$editor = $this->activeEditor->getWysiwygAdapterPath();
// Is the current wysiwyg tinymce v4?
if(strpos($editor,'tinymce4Adapter')){
if (($result->getDataByPath('settings/menubar')) || ($result->getDataByPath('settings/toolbar')) || ($result->getDataByPath('settings/plugins'))){
// do not override ui_element config (unsure if this is needed)
return $result;
}
$settings = $result->getData('settings');
if (!is_array($settings)) {
$settings = [];
}
// configure tinymce settings
$settings['menubar'] = true;
$settings['toolbar'] = 'undo redo | styleselect | fontsizeselect | forecolor backcolor | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table | image | code';
$settings['plugins'] = 'textcolor image code';
$result->setData('settings', $settings);
return $result;
}
else{ // don't make any changes if the current wysiwyg editor is not tinymce 4
return $result;
}
}
}It may help you to do customisation for editor.
If issue resolve, please click on 'Kudos' & Accept as Solution!
Hi @punithluxe0e42
You need to do customisation with custom module for this changes.
You can try below code :
1) Create the directory [app/code/vendor/module]: app/code/Vendor/Module
2) Create app/code/Vendor/Module/etc/di.xml:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Ui\Component\Wysiwyg\ConfigInterface">
<plugin name="vendor_module_config"
type="Vendor\Module\Plugin\Config"
sortOrder="10"/>
</type>
</config>3) Create app/code/Vendor/Module/etc/module.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Project_Customtinymce" setup_version="0.1.0"/>
</config>4) Create app/code/Project/Customtinymce/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Vendor_Module',
__DIR__
);5) Create the after plugin app/code/Vendor/Module/Plugin/Config.php:
<?php
namespace Vendor\Module\Plugin;
class Config
{
protected $activeEditor;
public function __construct(\Magento\Ui\Block\Wysiwyg\ActiveEditor $activeEditor)
{
$this->activeEditor = $activeEditor;
}
/**
* Return WYSIWYG configuration
*
* @param \Magento\Ui\Component\Wysiwyg\ConfigInterface $configInterface
* @param \Magento\Framework\DataObject $result
* @return \Magento\Framework\DataObject
*/
public function afterGetConfig(
\Magento\Ui\Component\Wysiwyg\ConfigInterface $configInterface,
\Magento\Framework\DataObject $result
) {
// Get current wysiwyg adapter's path
$editor = $this->activeEditor->getWysiwygAdapterPath();
// Is the current wysiwyg tinymce v4?
if(strpos($editor,'tinymce4Adapter')){
if (($result->getDataByPath('settings/menubar')) || ($result->getDataByPath('settings/toolbar')) || ($result->getDataByPath('settings/plugins'))){
// do not override ui_element config (unsure if this is needed)
return $result;
}
$settings = $result->getData('settings');
if (!is_array($settings)) {
$settings = [];
}
// configure tinymce settings
$settings['menubar'] = true;
$settings['toolbar'] = 'undo redo | styleselect | fontsizeselect | forecolor backcolor | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table | image | code';
$settings['plugins'] = 'textcolor image code';
$result->setData('settings', $settings);
return $result;
}
else{ // don't make any changes if the current wysiwyg editor is not tinymce 4
return $result;
}
}
}It may help you to do customisation for editor.
If issue resolve, please click on 'Kudos' & Accept as Solution!
Thank yu..