Skip to content

Commit c7a4996

Browse files
committed
Merge branch 'MC-14970-html-code-catalog' into cms-team-1-delivery
2 parents 0eedb70 + b9aab94 commit c7a4996

File tree

8 files changed

+98
-10
lines changed

8 files changed

+98
-10
lines changed

app/code/Magento/PageBuilder/Plugin/Filter/TemplatePlugin.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
*/
1313
class TemplatePlugin
1414
{
15-
const DATA_BACKGROUND_IMAGE = 'data-background-images';
15+
const BACKGROUND_IMAGE_PATTERN = '/data-background-images/si';
16+
17+
const HTML_CONTENT_TYPE_PATTERN = '/data-content-type="html"/si';
1618

1719
/**
1820
* @var \Magento\Framework\View\ConfigInterface
@@ -55,13 +57,13 @@ public function afterFilter(\Magento\Framework\Filter\Template $subject, string
5557
$this->domDocument = false;
5658

5759
// Validate if the filtered result requires background image processing
58-
if (strpos($result, self::DATA_BACKGROUND_IMAGE) !== false) {
60+
if (preg_match(self::BACKGROUND_IMAGE_PATTERN, $result)) {
5961
$document = $this->getDomDocument($result);
6062
$this->generateBackgroundImageStyles($document);
6163
}
6264

6365
// Process any HTML content types, they need to be decoded on the front-end
64-
if (strpos($result, 'data-content-type="html"') !== false) {
66+
if (preg_match(self::HTML_CONTENT_TYPE_PATTERN, $result)) {
6567
$document = $this->getDomDocument($result);
6668
$this->decodeHtmlContentTypes($document);
6769
}
@@ -164,10 +166,10 @@ private function decodeHtmlContentTypes(\DOMDocument $document): void
164166
private function generateBackgroundImageStyles(\DOMDocument $document) : void
165167
{
166168
$xpath = new \DOMXPath($document);
167-
$nodes = $xpath->query('//*[@' . self:: DATA_BACKGROUND_IMAGE . ']');
169+
$nodes = $xpath->query('//*[@data-background-images]');
168170
foreach ($nodes as $node) {
169171
/* @var \DOMElement $node */
170-
$backgroundImages = $node->attributes->getNamedItem(self:: DATA_BACKGROUND_IMAGE);
172+
$backgroundImages = $node->attributes->getNamedItem('data-background-images');
171173
if ($backgroundImages->nodeValue !== '') {
172174
$elementClass = uniqid('background-image-');
173175
$images = json_decode(stripslashes($backgroundImages->nodeValue), true);

app/code/Magento/PageBuilder/Test/Mftf/Test/AdminCatalogProductPageBuilder.xml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,4 +1298,75 @@
12981298
<seeElement selector="{{HeadingOnStorefront.headingType(PageBuilderHeadingTypeProperty_H1.value, '1')}}" stepKey="seeHeadingStyleStorefront"/>
12991299
<seeElement selector="{{HeadingOnStorefront.headingText(PageBuilderHeadingTypeProperty_H1.value, PageBuilderHeadingTextProperty.value, '1')}}" stepKey="seeHeadingTextStorefront"/>
13001300
</test>
1301+
<test name="HtmlAddToCatalogProduct">
1302+
<annotations>
1303+
<features value="PageBuilder"/>
1304+
<stories value="Catalog Products"/>
1305+
<title value="HTML code add to catalog product"/>
1306+
<description value="Verify adding HTML code to catalog product is rendered correctly"/>
1307+
<severity value="CRITICAL"/>
1308+
<useCaseId value="MC-14970"/>
1309+
<testCaseId value="MC-14976"/>
1310+
<group value="pagebuilder"/>
1311+
<group value="pagebuilder-html"/>
1312+
<group value="pagebuilder-column"/>
1313+
<group value="pagebuilder-catalog-product"/>
1314+
</annotations>
1315+
<before>
1316+
<createData entity="_defaultCategory" stepKey="createPreReqCategory"/>
1317+
<createData entity="_defaultProduct" stepKey="createProduct">
1318+
<requiredEntity createDataKey="createPreReqCategory"/>
1319+
</createData>
1320+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
1321+
<actionGroup ref="navigateToCreatedProductEditPage" stepKey="navigateToCreatedProductEditPage">
1322+
<argument name="product" value="$$createProduct$$"/>
1323+
</actionGroup>
1324+
<actionGroup ref="expandAdminProductSection" stepKey="expandAdminProductSection"/>
1325+
<actionGroup ref="openPageBuilderForAttribute" stepKey="openPageBuilderForDescription"/>
1326+
</before>
1327+
<after>
1328+
<deleteData createDataKey="createProduct" stepKey="deleteCreatedProduct"/>
1329+
<deleteData createDataKey="createPreReqCategory" stepKey="deleteCreatedCategory"/>
1330+
<actionGroup ref="NavigateToAndResetProductGridToDefaultView" stepKey="NavigateToAndResetProductGridToDefaultView"/>
1331+
<actionGroup ref="logout" stepKey="logout"/>
1332+
</after>
1333+
<actionGroup ref="expandPageBuilderPanelMenuSection" stepKey="expandMenuSectionMedia">
1334+
<argument name="contentType" value="PageBuilderHtmlContentType"/>
1335+
</actionGroup>
1336+
<actionGroup ref="dragContentTypeToStage" stepKey="dragHtmlIntoStage">
1337+
<argument name="contentType" value="PageBuilderHtmlContentType"/>
1338+
</actionGroup>
1339+
<actionGroup ref="openPageBuilderEditPanel" stepKey="openEditAfterDrop">
1340+
<argument name="contentType" value="PageBuilderHtmlContentType"/>
1341+
</actionGroup>
1342+
<!-- Update Edit Panel -->
1343+
<comment userInput="Update Edit Panel" stepKey="commentEdit"/>
1344+
<actionGroup ref="fillSlideOutPanelTextArea" stepKey="enterHtmlContent">
1345+
<argument name="property" value="PageBuilderHtmlPropertyButton"/>
1346+
</actionGroup>
1347+
<actionGroup ref="saveEditPanelSettingsFullScreen" stepKey="saveEditFormForSlide"/>
1348+
<!-- Validate Stage -->
1349+
<comment userInput="Validate Stage" stepKey="commentValidateStage"/>
1350+
<waitForElementVisible selector="{{HtmlOnStage.base('1')}}" stepKey="waitForHtmlBaseStage"/>
1351+
<seeElement selector="{{HtmlOnStage.html('1', PageBuilderHtmlPropertyButton.selector)}}" stepKey="seeHtmlOnStage"/>
1352+
<!-- Save Product -->
1353+
<comment userInput="Save Product" stepKey="commentSaveProduct"/>
1354+
<actionGroup ref="exitPageBuilderFullScreen" stepKey="exitPageBuilderFullScreen"/>
1355+
<actionGroup ref="saveProductForm" stepKey="saveProduct"/>
1356+
<waitForPageLoad stepKey="waitForPageLoadSaveProduct"/>
1357+
<actionGroup ref="expandAdminProductSection" stepKey="expandAdminProductSection"/>
1358+
<actionGroup ref="openPageBuilderForAttribute" stepKey="openPageBuilderForDescription"/>
1359+
<!-- Validate Stage After Save -->
1360+
<comment userInput="Validate Stage After Save" stepKey="commentValidateStageAfterSave"/>
1361+
<waitForElementVisible selector="{{HtmlOnStage.base('1')}}" stepKey="waitForHtmlBaseStageAfterSave"/>
1362+
<seeElement selector="{{HtmlOnStage.html('1', PageBuilderHtmlPropertyButton.selector)}}" stepKey="seeHtmlOnStageAfterSave"/>
1363+
<!-- Validate Storefront -->
1364+
<comment userInput="Validate Storefront" stepKey="commentValidateStorefront"/>
1365+
<actionGroup ref="navigateToStorefrontForCreatedPage" stepKey="navigateToProductStorefront">
1366+
<argument name="page" value="$$createProduct.name$$.html"/>
1367+
</actionGroup>
1368+
<scrollTo selector="{{StorefrontProductInfoMainSection.productDescription}}" stepKey="scrollToProductDescription"/>
1369+
<waitForElementVisible selector="{{HtmlOnStorefront.base('1')}}" stepKey="waitForHtmlBaseStageStorefront"/>
1370+
<seeElement selector="{{HtmlOnStorefront.html('1', PageBuilderHtmlPropertyButton.selectorOnFrontend)}}" stepKey="seeHtmlOnStorefront"/>
1371+
</test>
13011372
</tests>

app/code/Magento/PageBuilder/etc/di.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,12 @@
132132
<argument name="productCollectionFactory" xsi:type="object">pageBuilderProductCollectionFactory</argument>
133133
</arguments>
134134
</type>
135+
<type name="Magento\Catalog\Helper\Output">
136+
<arguments>
137+
<argument name="directivePatterns" xsi:type="array">
138+
<item name="backgroundImage" xsi:type="const">\Magento\PageBuilder\Plugin\Filter\TemplatePlugin::BACKGROUND_IMAGE_PATTERN</item>
139+
<item name="htmlContentType" xsi:type="const">\Magento\PageBuilder\Plugin\Filter\TemplatePlugin::HTML_CONTENT_TYPE_PATTERN</item>
140+
</argument>
141+
</arguments>
142+
</type>
135143
</config>

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/_drag-drop.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
.pagebuilder-content-type.ui-draggable-dragging {
5050
opacity: .7;
5151

52+
> .pagebuilder-options,
5253
> .pagebuilder-content-type > .pagebuilder-options {
5354
.pagebuilder-options-visible;
5455
}

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/content-type/row/_contained.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@
1212
margin-right: auto;
1313
max-width: @layout__max-width;
1414
}
15+
16+
.pagebuilder-content-type-wrapper.ui-sortable-helper > [data-content-type='row'] > .pagebuilder-content-type > .pagebuilder-options {
17+
.pagebuilder-options-visible;
18+
}

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

Lines changed: 2 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/js/converter/attribute/preview/store-id.js

Lines changed: 3 additions & 3 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/ts/js/content-type/column-group/preview.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ export default class Preview extends PreviewCollection {
333333
column.preview.element.draggable({
334334
appendTo: "body",
335335
containment: "body",
336+
cursor: "-webkit-grabbing",
336337
handle: ".move-column",
337338
revertDuration: 250,
338339
helper() {
@@ -343,7 +344,7 @@ export default class Preview extends PreviewCollection {
343344
opacity: 0.5,
344345
pointerEvents: "none",
345346
width: $(this).outerWidth() + "px",
346-
zIndex: 100,
347+
zIndex: 5000,
347348
});
348349
return helper;
349350
},

0 commit comments

Comments
 (0)