Skip to content

Commit a7732a1

Browse files
committed
Merge branch 'MC-3945-tab-height' into team3-bugs
2 parents 5df1b29 + 1715db6 commit a7732a1

File tree

712 files changed

+35445
-20018
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

712 files changed

+35445
-20018
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageBuilder\Block\Catalog\Block\Product\View;
9+
10+
class Attributes extends \Magento\Catalog\Block\Product\View\Attributes
11+
{
12+
const DISPLAY_ATTRIBUTES_NON_PAGEBUILDER = 'non_pagebuilder';
13+
14+
const DISPLAY_ATTRIBUTES_PAGEBUILDER_ONLY = 'pagebuilder_only';
15+
16+
/**
17+
* Determine if we should display the attribute on the front-end, add support for exclude page builder & page
18+
* builder only options on class.
19+
*
20+
* display_attributes can be set to determine whether to include just Page Builder attributes or to exclude
21+
* them.
22+
*
23+
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
24+
* @param array $excludeAttr
25+
* @return bool
26+
* @throws \Magento\Framework\Exception\LocalizedException
27+
*/
28+
protected function isVisibleOnFrontend(
29+
\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute,
30+
array $excludeAttr
31+
) : bool {
32+
return parent::isVisibleOnFrontend($attribute, $excludeAttr)
33+
&& (($this->getDisplayAttributes() == self::DISPLAY_ATTRIBUTES_NON_PAGEBUILDER
34+
&& !$attribute->getIsPagebuilderEnabled())
35+
|| ($this->getDisplayAttributes() == self::DISPLAY_ATTRIBUTES_PAGEBUILDER_ONLY
36+
&& $attribute->getIsPagebuilderEnabled()));
37+
}
38+
}

app/code/Magento/PageBuilder/Block/WidgetInitializer.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,26 @@ class WidgetInitializer extends Template
2222
*/
2323
private $jsonSerializer;
2424

25+
/**
26+
* @var \Magento\PageBuilder\Model\WidgetInitializerConfig
27+
*/
28+
private $config;
29+
2530
/**
2631
* WidgetInitializer constructor.
2732
* @param Template\Context $context
2833
* @param \Magento\Framework\Serialize\Serializer\Json $jsonEncoder
34+
* @param \Magento\PageBuilder\Model\WidgetInitializerConfig $config
2935
* @param array $data
3036
*/
3137
public function __construct(
3238
\Magento\Framework\View\Element\Template\Context $context,
3339
\Magento\Framework\Serialize\Serializer\Json $jsonEncoder,
40+
\Magento\PageBuilder\Model\WidgetInitializerConfig $config,
3441
array $data = []
3542
) {
3643
$this->jsonSerializer = $jsonEncoder;
44+
$this->config = $config;
3745
parent::__construct($context, $data);
3846
}
3947

@@ -44,21 +52,6 @@ public function __construct(
4452
*/
4553
public function getConfig() : string
4654
{
47-
$widgetsConfig = $this->getData('config');
48-
$resultConfig = [];
49-
foreach ($widgetsConfig as $contentTypeName => $config) {
50-
$selector = sprintf('div[data-role="%s"]', $contentTypeName);
51-
foreach ($config as $item) {
52-
if (!isset($item['component'])) {
53-
continue;
54-
}
55-
if (isset($item['appearance'])) {
56-
$selector .= sprintf('[data-appearance="%s"]', $item['appearance']);
57-
}
58-
$componentConfig = isset($item['config']) ? $item['config'] : '{}';
59-
$resultConfig[$selector] = [$item['component'] => $componentConfig];
60-
}
61-
}
62-
return $this->jsonSerializer->serialize($resultConfig);
55+
return $this->jsonSerializer->serialize($this->config->getConfig());
6356
}
6457
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageBuilder\Block;
10+
11+
use Magento\Framework\View\Element\Template;
12+
use Magento\Framework\DataObject;
13+
14+
/**
15+
* @api
16+
*/
17+
class WysiwygSetup extends Template
18+
{
19+
/**
20+
* @var \Magento\Ui\Component\Wysiwyg\ConfigInterface
21+
*/
22+
private $config;
23+
24+
/**
25+
* @param Template\Context $context
26+
* @param \Magento\Ui\Component\Wysiwyg\ConfigInterface $config
27+
* @param array $data
28+
*/
29+
public function __construct(
30+
\Magento\Framework\View\Element\Template\Context $context,
31+
\Magento\Ui\Component\Wysiwyg\ConfigInterface $config,
32+
array $data = []
33+
) {
34+
$this->config = $config;
35+
parent::__construct($context, $data);
36+
}
37+
38+
/**
39+
* Get config for wysiwyg initialization
40+
*
41+
* @return string
42+
*/
43+
public function getConfigJson() : string
44+
{
45+
$config = $this->config->getConfig();
46+
47+
if (is_array($config)) {
48+
$config = new DataObject($config);
49+
}
50+
51+
return $config->toJson();
52+
}
53+
}

app/code/Magento/PageBuilder/Controller/Adminhtml/ContentType/Image/Upload.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ class Upload extends \Magento\Backend\App\Action
3636
*/
3737
private $storeManager;
3838

39+
/**
40+
* @var \Magento\Cms\Helper\Wysiwyg\Images
41+
*/
42+
private $cmsWysiwygImages;
43+
3944
/**
4045
* Constructor
4146
*
@@ -44,19 +49,22 @@ class Upload extends \Magento\Backend\App\Action
4449
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
4550
* @param \Magento\Framework\File\UploaderFactory $uploaderFactory
4651
* @param \Magento\Framework\Filesystem\DirectoryList $directoryList
52+
* @param \Magento\Cms\Helper\Wysiwyg\Images $cmsWysiwygImages
4753
*/
4854
public function __construct(
4955
\Magento\Backend\App\Action\Context $context,
5056
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
5157
\Magento\Store\Model\StoreManagerInterface $storeManager,
5258
\Magento\Framework\File\UploaderFactory $uploaderFactory,
53-
\Magento\Framework\Filesystem\DirectoryList $directoryList
59+
\Magento\Framework\Filesystem\DirectoryList $directoryList,
60+
\Magento\Cms\Helper\Wysiwyg\Images $cmsWysiwygImages
5461
) {
5562
parent::__construct($context);
5663
$this->resultJsonFactory = $resultJsonFactory;
5764
$this->storeManager = $storeManager;
5865
$this->uploaderFactory = $uploaderFactory;
5966
$this->directoryList = $directoryList;
67+
$this->cmsWysiwygImages = $cmsWysiwygImages;
6068
}
6169

6270
/**
@@ -89,6 +97,7 @@ public function execute()
8997
try {
9098
$result = $fileUploader->save($this->getUploadDir());
9199
$baseUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
100+
$result['id'] = $this->cmsWysiwygImages->idEncode($result['file']);
92101
$result['url'] = $baseUrl . $this->getFilePath(self::UPLOAD_DIR, $result['file']);
93102
} catch (\Exception $e) {
94103
$result = [

app/code/Magento/PageBuilder/Model/Config/ContentType/AdditionalData/Provider/Uploader/MaxFileSize.php

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Provider\Wysiwyg;
9+
10+
use Magento\PageBuilder\Model\Config\ContentType\AdditionalData\ProviderInterface;
11+
12+
/**
13+
* Returns adapter config based on active editor path
14+
*/
15+
class Config implements ProviderInterface
16+
{
17+
/**
18+
* @var \Magento\Cms\Model\Wysiwyg\Config
19+
*/
20+
private $wysiwygConfig;
21+
22+
/**
23+
* @var \Magento\PageBuilder\Model\Wysiwyg\InlineEditingSupportedAdapterList
24+
*/
25+
private $inlineEditingChecker;
26+
27+
/**
28+
* @var \Magento\Ui\Block\Wysiwyg\ActiveEditor
29+
*/
30+
private $activeEditor;
31+
32+
/**
33+
* @var array
34+
*/
35+
private $editors;
36+
37+
/**
38+
* Config constructor.
39+
* @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig
40+
* @param \Magento\PageBuilder\Model\Wysiwyg\InlineEditingSupportedAdapterList $inlineEditingChecker
41+
* @param \Magento\Ui\Block\Wysiwyg\ActiveEditor $activeEditor
42+
* @param array $editors
43+
*/
44+
public function __construct(
45+
\Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
46+
\Magento\PageBuilder\Model\Wysiwyg\InlineEditingSupportedAdapterList $inlineEditingChecker,
47+
\Magento\Ui\Block\Wysiwyg\ActiveEditor $activeEditor,
48+
$editors = []
49+
) {
50+
$this->wysiwygConfig = $wysiwygConfig;
51+
$this->inlineEditingChecker = $inlineEditingChecker;
52+
$this->activeEditor = $activeEditor;
53+
$this->editors = $editors;
54+
}
55+
56+
/**
57+
* @inheritdoc
58+
*/
59+
public function getData(string $itemName) : array
60+
{
61+
$config = [];
62+
$activeEditorPath = $this->activeEditor->getWysiwygAdapterPath();
63+
if ($this->inlineEditingChecker->isSupported($activeEditorPath)) {
64+
$config['adapter'] = $this->wysiwygConfig->getConfig()->getData();
65+
if (isset($this->editors[$activeEditorPath])) {
66+
$config['adapter_config'] = $this->editors[$activeEditorPath];
67+
}
68+
}
69+
return [$itemName => $config,];
70+
}
71+
}

0 commit comments

Comments
 (0)