Skip to content

Commit d59a109

Browse files
committed
fix: custom-render-option for entry embedded as link
1 parent 2191dd7 commit d59a109

File tree

8 files changed

+1324
-2142
lines changed

8 files changed

+1324
-2142
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Changelog
22

3+
## [1.4.0](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.4.0) (2025-04-21)
4+
- Fix: customRenderOption for entry-embedded-as-link nodes
5+
36
## [1.3.20](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.20) (2025-02-24)
47
- Fix: Added data-mtec as allowed attribute
5-
- Fix: customRenderOption for entry-embedded-as-link nodes
68

79
## [1.3.19](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.19) (2025-02-24)
810
- Fix: Added fix for html injection in keys and values of attributes

__test__/mock/json-element-mock-result.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const plainTextHtmlWithId = "<p class=\"class_p\"><em><u><span id=\"blue\">data<
2121
const htmlTextIdInAttrs = "<p id=\"id_p\"><em><u>data</u></em></p>"
2222
const classAndIdAttrsHtml = "<a class=\"class_a\" id=\"id_p\" href=\"LINK.com\">link</a><img class=\"class_img\" id=\"id_img\" src=\"https://dummyImage.url/Donald.jog.png\" /><h1 class=\"class_h1\" id=\"id_h1\">heading1</h1><h2 class=\"class_h2\" id=\"id_h2\">heading2</h2><h3 class=\"class_h3\" id=\"id_h3\">heading3</h3><h4 class=\"class_h4\" id=\"id_h4\">heading4</h4><h5 class=\"class_h5\" id=\"id_h5\">heading5</h5><h6 class=\"class_h6\" id=\"id_h6\">heading6</h6>"
2323
const styleObjHtml = "<h1 style=\"text-align:justify;\">heading1</h1><h2 style=\"text-align:left;\">heading2</h2><h3 style=\"text-align:right;\">heading3</h3><h4 style=\"text-align:justify;\">heading4</h4><h5 style=\"text-align:justify;\">heading5</h5><h6 style=\"text-align:justify;\">heading6</h6>"
24-
const referenceObjHtml = "<p></p><p></p><ul><li></li><li></li><li></li><li></li><li><a href=\"https://\" target=\"_self\"><strong><u>Link URL</u></strong></a></li><li><a href=\"https://\" target=\"_blank\"><strong><u>Open link in new tab</u></strong></a></li></ul>"
25-
const referenceObjHtmlBlock = "<p></p><p></p><ul><li></li><li></li><li></li><li></li><li><a href=\"https://\" target=\"_self\"><strong><u>Link URL</u></strong></a></li><li><a href=\"https://\" target=\"_blank\"><strong><u>Open link in new tab</u></strong></a></li></ul>"
24+
const referenceObjHtml = "<p><a class=\"embedded-entry redactor-component block-entry\" href=\"/test\" target=\"_self\">Embed entry as a link</a></p><p><a class=\"embedded-entry redactor-component block-entry\" href=\"/entry-3\" target=\"_blank\">Open entry as a link in new tab</a></p><p><a class=\"embedded-entry redactor-component block-entry\" href=\"/entry-2\" target=\"_self\">Bold entry</a></p><p><a class=\"embedded-entry redactor-component block-entry\" href=\"/entry-4\" target=\"_blank\"><strong>Bold entry open in new tab</strong></a></p>"
25+
const referenceObjHtmlBlock = "<p><a class=\"embedded-entry redactor-component block-entry\" href=\"/Test\" target=\"_self\">Embed entry as a link</a></p><p><a class=\"embedded-entry redactor-component block-entry\" href=\"undefined\" target=\"_blank\">Embed entry as a link open in new tab</a></p><ul><li><a class=\"embedded-entry redactor-component block-entry\" href=\"undefined\" target=\"_self\">Entry as a link</a></li><li><a class=\"embedded-entry redactor-component block-entry\" href=\"undefined\" target=\"_blank\">Open entry as a link in new tab</a></li><li><a class=\"embedded-entry redactor-component block-entry\" href=\"undefined\" target=\"_self\"><strong><u>Entry as a link bold</u></strong></a></li><li><a class=\"embedded-entry redactor-component block-entry\" href=\"khjgf\" target=\"_blank\"><strong><u>Open bold entry as a link in new tab </u></strong></a></li><li><a href=\"https://\" target=\"_self\"><strong><u>Link URL</u></strong></a></li><li><a href=\"https://\" target=\"_blank\"><strong><u>Open link in new tab</u></strong></a></li></ul>"
2626
const imagetags = "<figure style=\"text-align:right;max-width:137px;float:right;width:137px;max-height:257px;height:257px;\"><a href=\"https://batman.com\" target=\"_blank\"><img asset_uid=\"asset-UID\" class=\"embedded-asset\" src=\"https://images.contentstack.io/v3/assets/api-key/asset-UID/random-uid/batman.png\" alt=\"batman\" target=\"_blank\" style=\"text-align:right;max-width:137px;float:right;width:137px;max-height:257px;height:257px;\" /></a><figcaption>The Batman</figcaption></figure>"
2727
const escapeHtml = "<p>&lt;p&gt;Welcome to Contentstack! &lt;script&gt;console.log(/&quot;Hello from Contentstack!/&quot;);&lt;/script&gt; Explore our platform to create, manage, and publish content seamlessly.&lt;/p&gt;</p>"
2828

__test__/mock/json-element-mock.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,14 +1102,14 @@ const entryReferenceLinkJson = {
11021102
"uid": "7626ea98e0e95d602210",
11031103
"type": "reference",
11041104
"attrs": {
1105-
"target": "_self",
1106-
"href": "/copy-of-entry-final-02",
1107-
"display-type": "link",
1108-
"entry-uid": "entry_uid_20",
1109-
"content-type-uid": "embeddedrte",
1110-
"locale": "en-us",
1111-
"type": "entry",
1112-
"class-name": "embedded-entry"
1105+
"target": "_self",
1106+
"href": "/copy-of-entry-final-02",
1107+
"display-type": "link",
1108+
"entry-uid": "entry_uid_20",
1109+
"content-type-uid": "embeddedrte",
1110+
"locale": "en-us",
1111+
"type": "entry",
1112+
"class-name": "embedded-entry"
11131113
},
11141114
"class": "class",
11151115
"children": [

__test__/reference-to-html.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ describe('Reference Node To HTML', () => {
173173
const resultHTML = referenceToHTML(node, renderOption, (metadata: Metadata) => {
174174
return findEmbeddedItems(metadata, { uid: 'uid' })[0]
175175
})
176-
expect(resultHTML).toEqual('<a class=\"embedded-entry\" href=\"/copy-of-entry-final-02\" target=\"_self\">/copy-of-entry-final-02</a>')
176+
expect(resultHTML).toEqual('<a href=\"entry_uid_20\">/copy-of-entry-final-02</a>')
177177
done()
178178
})
179179
})

0 commit comments

Comments
 (0)