|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
6 | 6 |
|
7 |
| -/** @var \Magento\PageBuilder\Block\Adminhtml\Stage\Render $block */ |
| 7 | +/** |
| 8 | + * @var \Magento\PageBuilder\Block\Adminhtml\Stage\Render $block |
| 9 | + * @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer |
| 10 | + */ |
8 | 11 | ?>
|
9 |
| -<script> |
10 |
| - <?php |
11 |
| - /** |
12 |
| - * Override the text! plugin within the iframe to ensure we can pipe any XHR requests through to the parent window |
13 |
| - * as the same origin policy will not allow us to load the templates within this iframe. |
14 |
| - */ |
15 |
| - ?> |
16 |
| - require.config({ |
17 |
| - 'map': { |
18 |
| - '*': { |
19 |
| - 'text': 'Magento_PageBuilder/js/master-format/render/requirejs/text', |
20 |
| - 'Magento_PageBuilder/js/events': 'Magento_PageBuilder/js/master-format/render/events' |
21 |
| - } |
22 |
| - } |
23 |
| - }); |
24 | 12 |
|
25 |
| - <?php |
26 |
| - /** |
27 |
| - * To be able to override the text plugin we need the Magento template engine to be used, as the template engine |
28 |
| - * within lib has a dependency on the text! plugin we need to ensure we set the template engine before the |
29 |
| - * dependency blocks us. If we try to just override using the RequireJS config above our !text plugin will never |
30 |
| - * get overridden as our template engine cannot load. |
31 |
| - */ |
32 |
| - ?> |
| 13 | +<?php |
| 14 | +/** |
| 15 | + * Override the text! plugin within the iframe to ensure we can pipe any XHR requests through to the parent window |
| 16 | + * as the same origin policy will not allow us to load the templates within this iframe. |
| 17 | + */ |
| 18 | +?> |
| 19 | +<?php |
| 20 | +$pageBuilderConfig = $block->getPageBuilderConfig(); |
| 21 | + |
| 22 | +$script = <<<SCRIPT |
| 23 | + require.config({ |
| 24 | + 'map': { |
| 25 | + '*': { |
| 26 | + 'text': 'Magento_PageBuilder/js/master-format/render/requirejs/text', |
| 27 | + 'Magento_PageBuilder/js/events': 'Magento_PageBuilder/js/master-format/render/events' |
| 28 | + } |
| 29 | + } |
| 30 | + }); |
| 31 | +SCRIPT; |
| 32 | + |
| 33 | +/** |
| 34 | + * To be able to override the text plugin we need the Magento template engine to be used, as the template engine |
| 35 | + * within lib has a dependency on the text! plugin we need to ensure we set the template engine before the |
| 36 | + * dependency blocks us. If we try to just override using the RequireJS config above our !text plugin will never |
| 37 | + * get overridden as our template engine cannot load. |
| 38 | + */ |
| 39 | +$script .= <<<SCRIPT |
33 | 40 | require([
|
34 | 41 | 'ko',
|
35 | 42 | 'Magento_Ui/js/lib/knockout/template/engine'
|
|
39 | 46 | ko.uid = 0;
|
40 | 47 | ko.setTemplateEngine(templateEngine);
|
41 | 48 | });
|
42 |
| -</script> |
43 |
| -<script> |
| 49 | +
|
44 | 50 | require(['Magento_PageBuilder/js/master-format/render/frame'], function (listen) {
|
45 |
| - listen(<?= /* @noEscape */ $block->getPageBuilderConfig(); ?>); |
| 51 | + listen({$pageBuilderConfig}); |
46 | 52 | });
|
47 |
| -</script> |
| 53 | +SCRIPT; |
| 54 | +?> |
| 55 | +<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $script, false) ?> |
48 | 56 | <div>Page Builder Render Frame</div>
|
0 commit comments