7
7
8
8
namespace Magento \PageBuilder \Component \Form \Element ;
9
9
10
+ use Magento \Framework \App \ObjectManager ;
10
11
use Magento \Framework \Data \FormFactory ;
11
12
use Magento \Framework \View \Element \UiComponent \ContextInterface ;
13
+ use Magento \PageBuilder \Model \View \File \Collector \PageBuilder ;
12
14
use Magento \Ui \Component \Wysiwyg \ConfigInterface ;
13
15
use Magento \Catalog \Api \CategoryAttributeRepositoryInterface ;
14
16
use Magento \Framework \Exception \NoSuchEntityException ;
17
+ use Magento \PageBuilder \Model \Config as PageBuilderConfig ;
15
18
use Magento \PageBuilder \Model \State as PageBuilderState ;
16
19
use \Magento \PageBuilder \Model \Stage \Config as Config ;
17
20
@@ -34,6 +37,8 @@ class Wysiwyg extends \Magento\Ui\Component\Form\Element\Wysiwyg
34
37
* @param array $components
35
38
* @param array $data
36
39
* @param array $config
40
+ * @param PageBuilderConfig $pageBuilderConfig
41
+ * @param bool $overrideSnapshot
37
42
*/
38
43
public function __construct (
39
44
ContextInterface $ context ,
@@ -44,7 +49,9 @@ public function __construct(
44
49
Config $ stageConfig ,
45
50
array $ components = [],
46
51
array $ data = [],
47
- array $ config = []
52
+ array $ config = [],
53
+ PageBuilderConfig $ pageBuilderConfig = null ,
54
+ bool $ overrideSnapshot = false
48
55
) {
49
56
$ wysiwygConfigData = isset ($ config ['wysiwygConfigData ' ]) ? $ config ['wysiwygConfigData ' ] : [];
50
57
// If a dataType is present we're dealing with an attribute
@@ -69,12 +76,24 @@ public function __construct(
69
76
$ data ['config ' ]['template ' ] = 'Magento_PageBuilder/form/element/wysiwyg ' ;
70
77
$ data ['config ' ]['elementTmpl ' ] = 'Magento_PageBuilder/form/element/wysiwyg ' ;
71
78
$ wysiwygConfigData = $ stageConfig ->getConfig ();
79
+
80
+ if ($ overrideSnapshot ) {
81
+ $ pageBuilderConfig = $ pageBuilderConfig ?: ObjectManager::getInstance ()->get (PageBuilderConfig::class);
82
+ $ wysiwygConfigData ['pagebuilder_content_snapshot ' ] = $ pageBuilderConfig ->isContentPreviewEnabled ();
83
+ }
84
+
85
+ // Add Classes for Page Builder Stage
86
+ if (isset ($ wysiwygConfigData ['pagebuilder_content_snapshot ' ])
87
+ && $ wysiwygConfigData ['pagebuilder_content_snapshot ' ]) {
88
+ $ data ['config ' ]['additionalClasses ' ] = 'admin__field-wide admin__field-page-builder ' ;
89
+ }
90
+
72
91
$ data ['config ' ]['wysiwygConfigData ' ] = isset ($ config ['wysiwygConfigData ' ]) ?
73
92
array_replace_recursive ($ config ['wysiwygConfigData ' ], $ wysiwygConfigData ) :
74
93
$ wysiwygConfigData ;
75
94
$ wysiwygConfigData ['activeEditorPath ' ] = 'Magento_PageBuilder/pageBuilderAdapter ' ;
95
+
76
96
$ config ['wysiwygConfigData ' ] = $ wysiwygConfigData ;
77
- $ wysiwygConfigData ['activeEditorPath ' ] = 'Magento_PageBuilder/pageBuilderAdapter ' ;
78
97
}
79
98
80
99
parent ::__construct ($ context , $ formFactory , $ wysiwygConfig , $ components , $ data , $ config );
0 commit comments