Skip to content

Commit

Permalink
Merge pull request #1181 from Nazar65/ASI-support_tiny_mce_3
Browse files Browse the repository at this point in the history
Enable MediaGallery to tinyMCE3
  • Loading branch information
sivaschenko authored Apr 14, 2020
2 parents 8cdc297 + 0b6fd71 commit 15a67a1
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
59 changes: 59 additions & 0 deletions MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\MediaGalleryIntegration\Plugin;

use Magento\Framework\UrlInterface;
use Magento\Framework\DataObject;
use Magento\MediaGalleryUiApi\Api\ConfigInterface;
use Magento\Tinymce3\Model\Config\Gallery\Config;

/**
* Plugin to update open media gallery dialog URL for tinyMCE3
*/
class UpdateWysiwygDialogUrlTinyMce
{
/**
* @var UrlInterface
*/
private $url;

/**
* @var ConfigInterface
*/
private $config;

/**
* @param UrlInterface $url
* @param ConfigInterface $config
*/
public function __construct(
UrlInterface $url,
ConfigInterface $config
) {
$this->url = $url;
$this->config = $config;
}

/**
* Update open media gallery dialog URL for wysiwyg instance
*
* @param Config $subject
* @param DataObject $config
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetConfig(Config $subject, DataObject $config): DataObject
{
if (!$this->config->isEnabled()) {
return $config;
}

$config->setData('files_browser_window_url', $this->url->getUrl('media_gallery/index/index'));

return $config;
}
}
3 changes: 2 additions & 1 deletion MediaGalleryIntegration/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"magento/module-ui": "*",
"magento/module-media-gallery-ui-api": "*",
"magento/module-media-gallery-ui": "*",
"magento/module-cms": "*"
"magento/module-cms": "*",
"magento/module-tinymce-3": "*"
},
"type": "magento2-module",
"license": [
Expand Down
3 changes: 3 additions & 0 deletions MediaGalleryIntegration/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
<type name="Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Provider\Uploader\OpenDialogUrl">
<plugin name="updateOpenDialogUrlPageBuilder" type="Magento\MediaGalleryIntegration\Plugin\UpdateOpenDialogUrlPageBuilder"/>
</type>
<type name="Magento\Tinymce3\Model\Config\Gallery\Config">
<plugin name="updateWysiwygOpendialogurlTinyMce3" type="Magento\MediaGalleryIntegration\Plugin\UpdateWysiwygDialogUrlTinyMce"/>
</type>
</config>

0 comments on commit 15a67a1

Please sign in to comment.