Skip to content

Commit 51d026f

Browse files
authored
Merge pull request #113 from contentstack/staging
DX | 14-11-2024 | Release
2 parents 8860e26 + 3a146e3 commit 51d026f

10 files changed

+2886
-4198
lines changed

CHANGELOG.md

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

3+
## [1.3.14](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.14) (2024-11-12)
4+
- Fix: Add data-type attr to inlineCode
5+
36
## [1.3.13](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.13) (2024-10-22)
47
- Enh: Node version bump
58

__test__/default-node-options.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,17 @@ describe('Default node render options', () => {
218218
expect(renderString).toEqual('<strike>text</strike>')
219219
done()
220220
})
221-
it('Should return bold string', done => {
221+
it('Should return inline code string', done => {
222222
const renderString = (defaultNodeOption[MarkType.INLINE_CODE] as RenderMark)(text)
223-
expect(renderString).toEqual('<span>text</span>')
223+
expect(renderString).toEqual(`<span data-type='inlineCode'>text</span>`)
224224
done()
225225
})
226-
it('Should return bold string', done => {
226+
it('Should return subscript string', done => {
227227
const renderString = (defaultNodeOption[MarkType.SUBSCRIPT] as RenderMark)(text)
228228
expect(renderString).toEqual('<sub>text</sub>')
229229
done()
230230
})
231-
it('Should return bold string', done => {
231+
it('Should return superscript string', done => {
232232
const renderString = (defaultNodeOption[MarkType.SUPERSCRIPT] as RenderMark)(text)
233233
expect(renderString).toEqual('<sup>text</sup>')
234234
done()

__test__/json-to-html.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ describe('Node parser reference content', () => {
174174
rte_data: {...embeddedAssetAsLinkJsonEntry},
175175
}
176176
const paths = ["rte_data"]
177-
const result = `<p>asda<a class="embedded-entry redactor-component undefined-entry" href="https://images.contentstack.io/v3/assets/***REMOVED***/bltbcfce09569234229/657304603ed4d5773c01feed/Screenshot_2023-03-01_at_1.09.39_PM.png" target="_self" content-type-uid="sys_assets" data-sys-asset-uid="bltbcfce09569234229" sys-style-type="download">s<strong>das</strong></a><strong>d</strong>as</p>`
177+
const result = `<p>asda<a class="embedded-entry redactor-component undefined-entry" href="https://images.contentstack.io/v3/assets/***REMOVED***/***REMOVED***/657304603ed4d5773c01feed/Screenshot_2023-03-01_at_1.09.39_PM.png" target="_self" content-type-uid="sys_assets" data-sys-asset-uid="***REMOVED***" sys-style-type="download">s<strong>das</strong></a><strong>d</strong>as</p>`
178178
jsonToHTML({ entry: entry, paths })
179179

180180
expect(entry.rte_data).toBe(result)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const plainTextHtml = "<strong>Aliquam sit amet libero dapibus, eleifend ligula at, varius justo</strong><strong><em>Lorem ipsum</em></strong><strong><em><u>dolor sit amet</u></em></strong><strong><em><u><strike><br />consectetur adipiscing elit.</strike></u></em></strong><strong><em><u><span>Sed condimentum iaculis magna in vehicula. </span></u></em></strong><strong><em><u><sup> Vestibulum vitae convallis </sup></u></em></strong><strong><em><u><sub> lacus. </sub></u></em></strong>"
1+
const plainTextHtml = "<strong>Aliquam sit amet libero dapibus, eleifend ligula at, varius justo</strong><strong><em>Lorem ipsum</em></strong><strong><em><u>dolor sit amet</u></em></strong><strong><em><u><strike><br />consectetur adipiscing elit.</strike></u></em></strong><strong><em><u><span data-type='inlineCode'>Sed condimentum iaculis magna in vehicula. </span></u></em></strong><strong><em><u><sup> Vestibulum vitae convallis </sup></u></em></strong><strong><em><u><sub> lacus. </sub></u></em></strong>"
22
const paragraphHtml = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed condimentum iaculis magna in vehicula. Vestibulum vitae convallis lacus. Praesent a diam iaculis turpis rhoncus faucibus. Aliquam sed pulvinar sem.</p>"
33
const h1Html = "<h1><strong><em><u><sub>Lorem ipsum dolor sit amet.</sub></u></em></strong></h1>"
44
const h2Html = "<h2><strong><em><u><sub>Vestibulum a ligula eget massa sagittis aliquam sit amet quis tortor. </sub></u></em></strong></h2>"
@@ -14,7 +14,7 @@ const blockquoteHtml = "<blockquote>Praesent eu ex sed nibh venenatis pretium.</
1414
const codeHtml = "<code>Code template.</code>"
1515
const linkInPHtml = "<strong><em><u><sub></sub></u></em></strong><a href=\"LINK.com\">LINK</a>"
1616
const linkInPURLHtml = "<strong><em><u><sub></sub></u></em></strong><a href=\"LINK.com\" target=\"_blank\">LINK</a>"
17-
const styleinPHtml = "<p style=\"text-align:right;\">This is <span>second</span> <u>JSON</u> entry</p><p style=\"text-align:left;\"><a class=\"class\" href=\"example.com\" target=\"_blank\">Example</a></p>"
17+
const styleinPHtml = "<p style=\"text-align:right;\">This is <span data-type='inlineCode'>second</span> <u>JSON</u> entry</p><p style=\"text-align:left;\"><a class=\"class\" href=\"example.com\" target=\"_blank\">Example</a></p>"
1818
const plainTextHtmlWithClass = "<p class=\"class_p\"><span class=\"yellow\">abc</span><u><span class=\"blue\">ghi</span></u><strong><em><u><span class=\"orange\" id=\"blue\">Basic</span></u></em></strong><h1><span class=\"purple\">abc</span></h1></p>"
1919
const plainTextHtmlWithId = "<p class=\"class_p\"><em><u><span id=\"blue\">data</span></u></em></p>"
2020
const htmlTextIdInAttrs = "<p id=\"id_p\"><em><u>data</u></em></p>"

__test__/mock/json-element-mock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,10 +1158,10 @@ const embeddedAssetAsLinkJsonEntry = {
11581158
"display-type": "link",
11591159
"type": "asset",
11601160
"class-name": "embedded-entry redactor-component undefined-entry",
1161-
"asset-uid": "bltbcfce09569234229",
1161+
"asset-uid": "***REMOVED***",
11621162
"content-type-uid": "sys_assets",
11631163
"target": "_self",
1164-
"href": "https://images.contentstack.io/v3/assets/***REMOVED***/bltbcfce09569234229/657304603ed4d5773c01feed/Screenshot_2023-03-01_at_1.09.39_PM.png"
1164+
"href": "https://images.contentstack.io/v3/assets/***REMOVED***/***REMOVED***/657304603ed4d5773c01feed/Screenshot_2023-03-01_at_1.09.39_PM.png"
11651165
},
11661166
"children": [
11671167
{

__test__/reference-to-html.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ import { defaultOptions } from '../src/options/default-options'
1010
import { assetReferenceJson, embeddedAssetJsonEntry, embeddedEntryJsonEntry, entryReferenceBlockJson, entryReferenceInlineJson, entryReferenceLinkJson } from './mock/json-element-mock'
1111
import { embeddedAssetWithRenderOption, embeddedObjectDefaultRender, embeddedObjectWithRenderOption } from './mock/render-options'
1212
describe('Reference Node To HTML', () => {
13-
it.skip('Should return blank for undefined entry', done => {
13+
it('Should return blank for undefined entry', done => {
1414
const node = assetReferenceJson.children[0] as unknown as Node
15-
console.log('Node attributes:', node.attrs);
1615
const renderOption = {}
1716

1817
const resultHTML = referenceToHTML(node, renderOption)
@@ -49,7 +48,7 @@ describe('Reference Node To HTML', () => {
4948
done()
5049
})
5150

52-
it.skip('Should return HTML for embedded asset', done => {
51+
it('Should return HTML for embedded asset', done => {
5352
const node = assetReferenceJson.children[0] as unknown as Node
5453
const renderOption = {}
5554

@@ -95,7 +94,7 @@ describe('Reference Node To HTML', () => {
9594
})
9695

9796
// Custom render option
98-
it.skip('Should return custom HTML for embedded asset', done => {
97+
it('Should return custom HTML for embedded asset', done => {
9998
const node = assetReferenceJson.children[0] as unknown as Node
10099
const renderOption = embeddedAssetWithRenderOption.renderOption as RenderOption
101100

__test__/text-node-to-html.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('Text Node To HTML', () => {
7373
...defaultNodeOption
7474
})
7575

76-
expect(resultHtml).toEqual(`<span>${textNode.text}</span>`)
76+
expect(resultHtml).toEqual(`<span data-type='inlineCode'>${textNode.text}</span>`)
7777
done()
7878
})
7979
it('Should return Subscript string text', done => {
@@ -119,7 +119,7 @@ describe('Text Node To HTML', () => {
119119
...defaultNodeOption
120120
})
121121

122-
expect(resultHtml).toEqual(`<strong><em><u><strike><span><sub><sup>${textNode.text}</sup></sub></span></strike></u></em></strong>`)
122+
expect(resultHtml).toEqual(`<strong><em><u><strike><span data-type='inlineCode'><sub><sup>${textNode.text}</sup></sub></span></strike></u></em></strong>`)
123123
done()
124124
})
125125
})

0 commit comments

Comments
 (0)