Skip to content

Commit 0b58a17

Browse files
committed
Merge remote-tracking branch 'trigger/MC-1416' into MC-3308
2 parents 088d534 + 769f94c commit 0b58a17

File tree

9 files changed

+225
-138
lines changed

9 files changed

+225
-138
lines changed

app/code/Magento/PageBuilder/Model/Wysiwyg/InlineEditing.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,26 @@
1313
*/
1414
class InlineEditing
1515
{
16+
/**
17+
* @var \Magento\Cms\Model\Wysiwyg\Config
18+
*/
19+
private $wysiwygConfig;
20+
1621
/**
1722
* @var array
1823
*/
1924
private $wysiwygAdaptersSupportingInlineEditing;
2025

2126
/**
2227
* InlineEditing constructor.
28+
* @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig
2329
* @param array $wysiwygAdaptersSupportingInlineEditing
2430
*/
25-
public function __construct($wysiwygAdaptersSupportingInlineEditing = [])
26-
{
31+
public function __construct(
32+
\Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
33+
array $wysiwygAdaptersSupportingInlineEditing
34+
) {
35+
$this->wysiwygConfig = $wysiwygConfig;
2736
$this->wysiwygAdaptersSupportingInlineEditing = $wysiwygAdaptersSupportingInlineEditing;
2837
}
2938

@@ -34,6 +43,7 @@ public function __construct($wysiwygAdaptersSupportingInlineEditing = [])
3443
*/
3544
public function isAvailable(string $editorPath) : bool
3645
{
37-
return $this->wysiwygAdaptersSupportingInlineEditing[$editorPath] ?? false;
46+
47+
return $this->wysiwygAdaptersSupportingInlineEditing[$editorPath] && $this->wysiwygConfig->isEnabled() ?? false;
3848
}
3949
}

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/content-type/text/_default.less

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
margin-bottom: 0;
2323
padding-bottom: @margin;
2424
}
25-
~ .mce-tinymce-inline {
26-
transform: translateX(-1px);
25+
.mce-tinymce-inline {
26+
left: -2px;
27+
right: -2px;
28+
top: -1px;
2729
}
2830
.placeholder-text {
2931
left: 5px;

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/text/preview.js

Lines changed: 2 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/wysiwyg.js

Lines changed: 88 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/drag-drop/sortable.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/text/preview.ts

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
import $ from "jquery";
7-
import events from "Magento_PageBuilder/js/events";
8-
import _ from "underscore";
96
import Config from "../../config";
107
import BasePreview from "../preview";
118
import Wysiwyg from "../wysiwyg";
@@ -14,7 +11,6 @@ import Wysiwyg from "../wysiwyg";
1411
* @api
1512
*/
1613
export default class Preview extends BasePreview {
17-
1814
/**
1915
* Wysiwyg instance
2016
*/
@@ -28,52 +24,11 @@ export default class Preview extends BasePreview {
2824
return;
2925
}
3026

31-
let inlineWysiwygConfig = this.config.additional_data.inlineWysiwygConfig;
32-
33-
if (inlineWysiwygConfig.encapsulateSelectorConfigKeys) {
34-
inlineWysiwygConfig = $.extend(true, {}, this.config.additional_data.inlineWysiwygConfig);
35-
_.each(inlineWysiwygConfig.encapsulateSelectorConfigKeys, (isEnabled, configKey) => {
36-
const configValue = inlineWysiwygConfig.wysiwygConfig.settings[configKey];
37-
38-
if (!isEnabled) {
39-
return;
40-
}
41-
42-
inlineWysiwygConfig.wysiwygConfig.settings[configKey] = (
43-
"#" + this.parent.id + (configValue ? " " + configValue : "")
44-
);
45-
});
46-
}
47-
4827
this.wysiwyg = new Wysiwyg(
28+
this.parent.id,
4929
element.id,
50-
inlineWysiwygConfig.wysiwygConfig,
51-
inlineWysiwygConfig.mode,
52-
);
53-
54-
// Update content in our data store after our stage preview wysiwyg gets updated
55-
this.wysiwyg.onEdited(this.saveContentFromWysiwygToDataStore.bind(this));
56-
57-
// Update content in our stage preview wysiwyg after its slideout counterpart gets updated
58-
events.on(`form:${this.parent.id}:saveAfter`, this.setContentFromDataStoreToWysiwyg.bind(this));
59-
}
60-
61-
/**
62-
* Update content in our data store after our stage preview wysiwyg gets updated
63-
*/
64-
private saveContentFromWysiwygToDataStore() {
65-
this.parent.dataStore.update(
66-
this.wysiwyg.getAdapter().getContent(),
67-
this.config.additional_data.inlineWysiwygConfig.contentDataStoreKey,
68-
);
69-
}
70-
71-
/**
72-
* Update content in our stage wysiwyg after our data store gets updated
73-
*/
74-
private setContentFromDataStoreToWysiwyg() {
75-
this.wysiwyg.getAdapter().setContent(
76-
this.parent.dataStore.get(this.config.additional_data.inlineWysiwygConfig.contentDataStoreKey) as string,
30+
this.config.additional_data.wysiwygConfig,
31+
this.parent.dataStore,
7732
);
7833
}
7934
}

0 commit comments

Comments
 (0)