Skip to content

Commit b3e5964

Browse files
committed
MC-3908: Dragging a text content block into the stage causes global styles to be changed and fonts to flash
- Fix issue with place holder position with padding & margin
1 parent c8a2eeb commit b3e5964

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

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

Lines changed: 14 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/template/content-type/text/default/preview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<div class="pagebuilder-content-type pagebuilder-text" event="{ mouseover: onMouseOver, mouseout: onMouseOut }, mouseoverBubble: false">
99
<div if="isWysiwygSupported()" class="inline-wysiwyg" ko-style="data.main.style" css="data.main.css" attr="data.main.attributes" afterRender="initWysiwyg" />
10-
<div if="isWysiwygSupported()" class="placeholder-text" ifnot="data.main.html" translate="'Edit Text'"></div>
10+
<div if="isWysiwygSupported()" class="placeholder-text" ifnot="data.main.html" ko-style="getPlaceholderStyle()" translate="'Edit Text'"></div>
1111

1212
<div ifnot="isWysiwygSupported()">
1313
<textarea

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import $ from "jquery";
77
import events from "Magento_PageBuilder/js/events";
8+
import _ from "underscore";
89
import Config from "../../config";
910
import BasePreview from "../preview";
1011
import WysiwygFactory from "../wysiwyg/factory";
@@ -108,6 +109,28 @@ export default class Preview extends BasePreview {
108109
events.trigger("stage:interactionStop");
109110
}
110111

112+
/**
113+
* Retrieve the margin & padding styles for the placeholder
114+
*
115+
* @returns {any}
116+
*/
117+
public getPlaceholderStyle()
118+
{
119+
const keys = [
120+
"marginBottom",
121+
"marginLeft",
122+
"marginRight",
123+
"marginTop",
124+
"paddingBottom",
125+
"paddingLeft",
126+
"paddingRight",
127+
"paddingTop",
128+
];
129+
return _.pick(this.data.main.style(), (style: string, key: string) => {
130+
return keys.indexOf(key) !== -1;
131+
});
132+
}
133+
111134
/**
112135
* Adjust textarea's height based on scrollHeight
113136
*/

0 commit comments

Comments
 (0)