-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da5ef73
commit 0c70884
Showing
5 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* Copyright © Magefan ([email protected]). All rights reserved. | ||
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). | ||
*/ | ||
namespace Magefan\WysiwygAdvanced\Plugin\Magento\Ui\Component\Wysiwyg; | ||
|
||
/** | ||
* Class ConfigPlugin | ||
* @package Magefan\WysiwygAdvanced\Plugin\Magento\Ui\Component\Wysiwyg | ||
*/ | ||
class ConfigPlugin | ||
{ | ||
|
||
/** | ||
* @var \Magento\Ui\Block\Wysiwyg\ActiveEditor | ||
*/ | ||
protected $activeEditor; | ||
|
||
/** | ||
* ConfigPlugin constructor. | ||
* @param \Magento\Ui\Block\Wysiwyg\ActiveEditor $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; | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "magefan/module-wysiwyg-advanced", | ||
"description": "Extend TinyMCE 4 in Magento 2", | ||
"type": "magento2-module", | ||
"version": "2.0.0", | ||
"license": [ | ||
"OSL-3.0", | ||
"AFL-3.0" | ||
], | ||
"autoload": { | ||
"files": [ | ||
"registration.php" | ||
], | ||
"psr-4": { | ||
"Magefan\\WysiwygAdvanced\\": "" | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" ?> | ||
<!-- | ||
/** | ||
* Copyright © Magefan ([email protected]). All rights reserved. | ||
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). | ||
*/ | ||
--> | ||
|
||
<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 disabled="false" name="Magefan_WysiwygAdvanced_Plugin_Magento_Ui_Component_Wysiwyg_ConfigInterface" sortOrder="10" type="Magefan\WysiwygAdvanced\Plugin\Magento\Ui\Component\Wysiwyg\ConfigPlugin"/> | ||
</type> | ||
</config> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" ?> | ||
<!-- | ||
/** | ||
* Copyright © Magefan ([email protected]). All rights reserved. | ||
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). | ||
*/ | ||
--> | ||
|
||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Magefan_WysiwygAdvanced" setup_version="2.0.0"> | ||
<sequence> | ||
<module name="Magento_Ui"/> | ||
</sequence> | ||
</module> | ||
</config> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* Copyright © Magefan ([email protected]). All rights reserved. | ||
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). | ||
*/ | ||
|
||
\Magento\Framework\Component\ComponentRegistrar::register( | ||
\Magento\Framework\Component\ComponentRegistrar::MODULE, | ||
'Magefan_WysiwygAdvanced', | ||
__DIR__ | ||
); |