Skip to content

Commit 804c823

Browse files
author
Hwashiang Yu
committed
MC-5386: Anchors Under Each Div if TinyMCE link Is Added to Banner/Slide (Add Notification for When Link Attribute Is Entered)
- Updated content of nesting link dialogs dialog - Updated translation file for above change - Updated nesting link dialog logic to check for wysiwyg, correctly fix inline editor content, and blur inline editor on modal
1 parent 7c34446 commit 804c823

File tree

5 files changed

+27
-19
lines changed

5 files changed

+27
-19
lines changed

app/code/Magento/PageBuilder/Test/Mftf/Data/BannerData.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<data key="section">contents</data>
8181
<data key="fieldName">message</data>
8282
<data key="errorMessage">Adding link in both content and outer element is not allowed.</data>
83-
<data key="stageErrorMessage">Adding link in content and outer element is not allowed. Remove the link from the element before adding links to the content.</data>
83+
<data key="stageErrorMessage">We are unable to support links within the content field whilst having a link set on the content type. Please remove the content type link if you'd like to set a link within the content. We will automatically remove the links within the content field.</data>
8484
</entity>
8585
<!-- Background Color -->
8686
<entity name="PageBuilderBannerBackgroundColor_Empty" type="pagebuilder_banner_background_color_property">

app/code/Magento/PageBuilder/Test/Mftf/Data/SlideData.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,6 @@
246246
<data key="section">general</data>
247247
<data key="fieldName">content</data>
248248
<data key="errorMessage">Adding link in both content and outer element is not allowed.</data>
249-
<data key="stageErrorMessage">Adding link in content and outer element is not allowed. Remove the link from the element before adding links to the content.</data>
249+
<data key="stageErrorMessage">We are unable to support links within the content field whilst having a link set on the content type. Please remove the content type link if you'd like to set a link within the content. We will automatically remove the links within the content field.</data>
250250
</entity>
251251
</entities>

app/code/Magento/PageBuilder/i18n/en_US.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,5 +288,5 @@ Add,Add
288288
"You must provide a valid <a href="%s">Google Maps API key</a> to use a map.","You must provide a valid <a href="%s">Google Maps API key</a> to use a map."
289289
OK,OK
290290
"Adding link in both content and outer element is not allowed","Adding link in both content and outer element is not allowed"
291-
"Adding link in content and outer element is not allowed. Remove the link from the element before adding links to the content.","Adding link in content and outer element is not allowed. Remove the link from the element before adding links to the content."
292-
"Nesting links are not allowed","Nesting links are not allowed"
291+
"We are unable to support links within the content field whilst having a link set on the content type. Please remove the content type link if you'd like to set a link within the content. We will automatically remove the links within the content field.","We are unable to support links within the content field whilst having a link set on the content type. Please remove the content type link if you'd like to set a link within the content. We will automatically remove the links within the content field."
292+
"Nested links are not allowed","Nested links are not allowed"

app/code/Magento/PageBuilder/view/adminhtml/web/js/utils/nesting-link-dialog.js

Lines changed: 10 additions & 7 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/utils/nesting-link-dialog.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,30 @@ export default function nestingLinkDialog(
2525
inlineMessageField: string,
2626
linkUrlField: string,
2727
) {
28-
const dataStoreContent = dataStore.get() as DataObject;
28+
const dataStoreContent = dataStore.getState() as DataObject;
2929
const inlineMessage = dataStoreContent[inlineMessageField] as string;
3030
const linkUrl = dataStoreContent[linkUrlField] as FieldDefaultsInterface;
3131
const aLinkRegex = /<a[\s]+([^>]+)>|<a>|<\/a>/igm;
32-
if (inlineMessage.match(aLinkRegex) &&
32+
if (wysiwyg &&
33+
inlineMessage.match(aLinkRegex) &&
3334
linkUrl &&
3435
["page", "product", "category", "default"].indexOf(linkUrl.type) !== -1 &&
3536
linkUrl[linkUrl.type] &&
36-
linkUrl[linkUrl.type].length !== 0) {
37+
linkUrl[linkUrl.type].length !== 0
38+
) {
39+
const inlineEditor = $("#" + wysiwyg.elementId);
40+
inlineEditor.blur();
3741
confirmationDialog({
3842
actions: {
3943
always: () => {
40-
const anchorLessInlineMessage = inlineMessage.replace(aLinkRegex, "");
41-
dataStore.update(anchorLessInlineMessage, inlineMessageField);
42-
$("#" + wysiwyg.elementId).html(anchorLessInlineMessage);
44+
const anchorLessDataStoreMessage = inlineMessage.replace(aLinkRegex, "");
45+
const anchorLessInlineMessage = inlineEditor.html().replace(aLinkRegex, "");
46+
dataStore.update(anchorLessDataStoreMessage, inlineMessageField);
47+
inlineEditor.html(anchorLessInlineMessage);
4348
},
4449
},
45-
content: $t("Adding link in content and outer element is not allowed. Remove the link from the element before adding links to the content."), // tslint:disable-line:max-line-length
46-
title: $t("Nesting links are not allowed"),
50+
content: $t("We are unable to support links within the content field whilst having a link set on the content type. Please remove the content type link if you'd like to set a link within the content. We will automatically remove the links within the content field."), // tslint:disable-line:max-line-length
51+
title: $t("Nested links are not allowed"),
4752
haveCancelButton: false,
4853
});
4954
}

0 commit comments

Comments
 (0)