Created
March 18, 2021 10:15
-
-
Save FredericMartinez/1d669682fd6ca607f3528d538f6a8ec2 to your computer and use it in GitHub Desktop.
Remove <p> WYSIWYG Magento2, plugin edition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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="mynamespace_tinymce_settings" | |
type="Namespace\Backend\Plugins\TinyMCEPlugin" | |
sortOrder="10"/> | |
</type> | |
</config> | |
class TinyMCEPlugin | |
{ | |
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( | |
ConfigInterface $configInterface, | |
DataObject $result | |
) { | |
// Get current wysiwyg adapter's path | |
$editor = $this->activeEditor->getWysiwygAdapterPath(); | |
// Is the current wysiwyg tinymce v4? | |
if (strpos($editor, 'tinymce4Adapter')) { | |
$settings = $result->getData('settings'); | |
if (!is_array($settings)) { | |
$settings = []; | |
} | |
// configure tinymce settings | |
$settings['forced_root_block'] = false; | |
$result->setData('settings', $settings); | |
} | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment