File tree Expand file tree Collapse file tree 4 files changed +47
-19
lines changed
app/code/Magento/PageBuilder Expand file tree Collapse file tree 4 files changed +47
-19
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright 2024 Adobe
4
+ * All Rights Reserved.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \PageBuilder \ViewModel ;
9
+
10
+ use Magento \Backend \ViewModel \RequireJsConfigModifierInterface ;
11
+ use Magento \Framework \View \Element \Block \ArgumentInterface ;
12
+
13
+ /**
14
+ * Modifies requirejs configuration for the stage render frame
15
+ *
16
+ * Override the text! plugin within the iframe to ensure we can pipe any XHR requests through to the parent window
17
+ * as the same origin policy will not allow us to load the templates within this iframe.
18
+ * It is important that this mapping is configured before requirejs-config.js to ensure the text! plugin is overridden
19
+ * for all requests.
20
+ */
21
+ class StageRenderFrameRequireJsConfigModifier implements ArgumentInterface, RequireJsConfigModifierInterface
22
+ {
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ public function modify (array $ config ): array
27
+ {
28
+ $ config ['map ' ]['* ' ] = array_merge (
29
+ $ config ['map ' ]['* ' ] ?? [],
30
+ [
31
+ 'text ' => 'Magento_PageBuilder/js/master-format/render/requirejs/text ' ,
32
+ 'Magento_PageBuilder/js/events ' => 'Magento_PageBuilder/js/master-format/render/events '
33
+ ]
34
+ );
35
+ return $ config ;
36
+ }
37
+ }
Original file line number Diff line number Diff line change 14
14
<remove src =" css/styles.css" />
15
15
</head >
16
16
<body >
17
+ <referenceBlock name =" require.js" >
18
+ <arguments >
19
+ <argument name =" config_modifier" xsi : type =" object" >
20
+ Magento\PageBuilder\ViewModel\StageRenderFrameRequireJsConfigModifier
21
+ </argument >
22
+ </arguments >
23
+ </referenceBlock >
17
24
<referenceContainer name =" backend.page" remove =" true" />
18
25
<referenceContainer name =" menu.wrapper" remove =" true" />
19
26
<referenceContainer name =" root" >
Original file line number Diff line number Diff line change 10
10
*/
11
11
?>
12
12
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
13
<?php
20
14
$ pageBuilderConfig = $ block ->getPageBuilderConfig ();
21
15
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
16
/**
34
17
* To be able to override the text plugin we need the Magento template engine to be used, as the template engine
35
18
* within lib has a dependency on the text! plugin we need to ensure we set the template engine before the
36
19
* dependency blocks us. If we try to just override using the RequireJS config above our !text plugin will never
37
20
* get overridden as our template engine cannot load.
38
21
*/
39
- $ script . = <<<SCRIPT
22
+ $ script = <<<SCRIPT
40
23
require([
41
24
'ko',
42
25
'Magento_Ui/js/lib/knockout/template/engine'
Original file line number Diff line number Diff line change 31
31
< with args ="stage ">
32
32
< render > </ render >
33
33
</ with >
34
- < iframe attr ="id: 'render_frame_' + id " sandbox ="allow-scripts allow-same-origin " style ="position: absolute; width:0; height:0; border: none; "> </ iframe >
34
+ <!-- Do not modify the "sandbox" attribute without approval from a security engineer -->
35
+ < iframe attr ="id: 'render_frame_' + id " sandbox ="allow-scripts " style ="position: absolute; width:0; height:0; border: none; "> </ iframe >
35
36
</ if >
36
37
</ div >
You can’t perform that action at this time.
0 commit comments