Skip to content

Commit de34b1d

Browse files
committed
Merge remote-tracking branch 'remotes/mainline/1.0.0-release' into MC-5410
2 parents 68d027f + fd718b1 commit de34b1d

File tree

10 files changed

+9092
-131
lines changed

10 files changed

+9092
-131
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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\Adminhtml\Html\Head;
10+
11+
use Magento\Framework\View\Element\Template;
12+
13+
/**
14+
* Babel polyfill is required for IE 11 compatibility
15+
*
16+
* @api
17+
*/
18+
class BabelPolyfill extends Template
19+
{
20+
/**
21+
* @var \Magento\PageBuilder\Model\ConfigInterface
22+
*/
23+
private $config;
24+
25+
/**
26+
* @var \Magento\Framework\HTTP\Header
27+
*/
28+
private $httpHeader;
29+
30+
/**
31+
* @param Template\Context $context
32+
* @param \Magento\PageBuilder\Model\ConfigInterface $config
33+
* @param \Magento\Framework\HTTP\Header $httpHeader
34+
* @param array $data
35+
*/
36+
public function __construct(
37+
Template\Context $context,
38+
\Magento\PageBuilder\Model\ConfigInterface $config,
39+
\Magento\Framework\HTTP\Header $httpHeader,
40+
array $data = []
41+
) {
42+
$this->config = $config;
43+
$this->httpHeader = $httpHeader;
44+
parent::__construct($context, $data);
45+
}
46+
47+
/**
48+
* Detect if Page Builder is enabled and the user is loading the website from IE 11
49+
*
50+
* @return bool
51+
*/
52+
public function shouldLoadPolyfill() : bool
53+
{
54+
return $this->config->isEnabled() && $this->isIe11();
55+
}
56+
57+
/**
58+
* Build and return the polyfill static URL
59+
*
60+
* @return string
61+
*/
62+
public function getJsUrl() : string
63+
{
64+
return $this->_assetRepo->getUrl("Magento_PageBuilder::js/resource/babel/polyfill.min.js");
65+
}
66+
67+
/**
68+
* Extend the cache keys with a IE 11 flag
69+
*
70+
* @return array
71+
*/
72+
public function getCacheKeyInfo() : array
73+
{
74+
$cacheKeys = parent::getCacheKeyInfo();
75+
$cacheKeys['is_ie11'] = $this->isIe11();
76+
return $cacheKeys;
77+
}
78+
79+
/**
80+
* Detect if the browser user agent contains the IE 11 user agent
81+
*
82+
* @return bool
83+
*/
84+
private function isIe11() : bool
85+
{
86+
return strpos($this->httpHeader->getHttpUserAgent(), 'rv:11.0') !== false
87+
&& strpos($this->httpHeader->getHttpUserAgent(), 'Trident/7.0;') !== false;
88+
}
89+
}

app/code/Magento/PageBuilder/view/adminhtml/layout/editor.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
10+
<block class="Magento\Framework\View\Element\Template" name="head.additional" as="head.additional" template="Magento_PageBuilder::html/container.phtml">
11+
<block class="Magento\PageBuilder\Block\Adminhtml\Html\Head\BabelPolyfill" name="pagebuilder.babel.polyfill" as="pagebuilder.babel.polyfill" template="Magento_PageBuilder::html/head/babel_polyfill.phtml"/>
12+
</block>
1013
<referenceContainer name="before.body.end">
1114
<uiComponent name="pagebuilder_modal_form" />
1215
</referenceContainer>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
// @codingStandardsIgnoreFile
8+
9+
?>
10+
<?= $block->getChildHtml() ?>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/* @var $block \Magento\PageBuilder\Block\Adminhtml\Html\Head\BabelPolyfill */
8+
9+
if ($block->shouldLoadPolyfill()) : ?>
10+
<script src="<?= $block->escapeUrl($block->getJsUrl()) ?>"></script>
11+
<?php endif; ?>
12+

0 commit comments

Comments
 (0)