diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml
index a754455..4f827b7 100644
--- a/.github/workflows/npm-publish.yml
+++ b/.github/workflows/npm-publish.yml
@@ -26,7 +26,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: '12.x'
- registry-url: 'https://registry.npmjs.org'
+ registry-url: 'https://npm.pkg.github.com'
scope: '@contentstack'
- run: npm ci
- run: npm publish
diff --git a/__test__/json-to-html.test.ts b/__test__/json-to-html.test.ts
index e7733ee..e789ddb 100644
--- a/__test__/json-to-html.test.ts
+++ b/__test__/json-to-html.test.ts
@@ -31,6 +31,7 @@ import {
h6Html,
imgHtml,
linkInPHtml,
+ linkInPURLHtml,
orderListHtml,
paragraphHtml,
plainTextHtml,
@@ -488,7 +489,7 @@ describe('Node parse link in paragraph content', () => {
jsonToHTML({ entry, paths})
- expect(entry.supercharged_rte).toEqual([linkInPHtml])
+ expect(entry.supercharged_rte).toEqual([linkInPURLHtml])
done()
})
})
diff --git a/__test__/mock/json-element-mock-result.ts b/__test__/mock/json-element-mock-result.ts
index db42c4f..4b87d6f 100644
--- a/__test__/mock/json-element-mock-result.ts
+++ b/__test__/mock/json-element-mock-result.ts
@@ -1,4 +1,4 @@
-const plainTextHtml = "Aliquam sit amet libero dapibus, eleifend ligula at, varius justoLorem ipsumdolor sit ametconsectetur adipiscing elit.Sed condimentum iaculis magna in vehicula. Vestibulum vitae convallis lacus. "
+const plainTextHtml = "Aliquam sit amet libero dapibus, eleifend ligula at, varius justoLorem ipsumdolor sit ametSed condimentum iaculis magna in vehicula. Vestibulum vitae convallis lacus. "
const paragraphHtml = "
consectetur adipiscing elit.
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.
" const h1Html = "Header 1 | Header 2 const blockquoteHtml = "Praesent eu ex sed nibh venenatis pretium." const codeHtml = " Code template."
const linkInPHtml = "LINK"
+const linkInPURLHtml = "LINK"
export {
h1Html,
@@ -28,6 +29,7 @@ export {
orderListHtml,
paragraphHtml,
plainTextHtml,
+ linkInPURLHtml,
blockquoteHtml,
unorderListHtml,
}
\ No newline at end of file
diff --git a/__test__/mock/json-element-mock.ts b/__test__/mock/json-element-mock.ts
index 7e1ea16..4b00c99 100644
--- a/__test__/mock/json-element-mock.ts
+++ b/__test__/mock/json-element-mock.ts
@@ -24,7 +24,8 @@ const plainTextJson = {
"bold": true,
"italic": true,
"underline": true,
- "strikethrough": true
+ "strikethrough": true,
+ "break": true
},
{
"text": "Sed condimentum iaculis magna in vehicula. ",
@@ -618,8 +619,7 @@ const linkInPJson = {
"uid": "0d06598201aa8b47",
"type": "a",
"attrs": {
- "href": "LINK.com",
- "target": "_self"
+ "href": "LINK.com"
},
"children": [
{
diff --git a/__test__/reference-to-html.test.ts b/__test__/reference-to-html.test.ts
index 4f4117a..8f786dc 100644
--- a/__test__/reference-to-html.test.ts
+++ b/__test__/reference-to-html.test.ts
@@ -5,6 +5,7 @@ import { Metadata } from '../src/Models/metadata-model'
import Node from '../src/nodes/node'
import NodeType from '../src/nodes/node-type'
import { Next, RenderOption } from '../src/options'
+import { defaultNodeOption } from '../src/options/default-node-options'
import { defaultOptions } from '../src/options/default-options'
import { assetReferenceJson, embeddedAssetJsonEntry, embeddedEntryJsonEntry, entryReferenceBlockJson, entryReferenceInlineJson, entryReferenceLinkJson } from './mock/json-element-mock'
import { embeddedAssetWithRenderOption, embeddedObjectDefaultRender, embeddedObjectWithRenderOption } from './mock/render-options'
@@ -152,6 +153,13 @@ describe('Reference Node To HTML', () => {
expect(resultHTML).toEqual(' ')
done()
})
+ it('Should return image for undefined node asset from default node option', done => {
+ const node = assetReferenceJson.children[0] as unknown as Node
+
+ const resultHTML = referenceToHTML(node, defaultNodeOption)
+ expect(resultHTML).toEqual(' ')
+ done()
+ })
it('Should return HTML for embedded link entry', done => {
const node = entryReferenceLinkJson.children[0] as unknown as Node
diff --git a/package-lock.json b/package-lock.json
index 2bdfa7d..4901084 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "@contentstack/utils",
- "version": "1.2.0",
+ "version": "1.3.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 5e71bc7..f7e5b55 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@contentstack/utils",
- "version": "1.2.0",
+ "version": "1.3.0",
"description": "Contentstack utilities for Javascript",
"main": "dist/index.es.js",
"types": "dist/types/index.d.ts",
diff --git a/src/helper/enumerate-entries.ts b/src/helper/enumerate-entries.ts
index e8fdbaa..32e95f9 100644
--- a/src/helper/enumerate-entries.ts
+++ b/src/helper/enumerate-entries.ts
@@ -43,6 +43,9 @@ export function enumerateContents(
export function textNodeToHTML(node: TextNode, renderOption: RenderOption): string {
let text = node.text
+ if (node.break) {
+ text = (renderOption[MarkType.BREAK] as RenderMark)(text)
+ }
if (node.superscript) {
text = (renderOption[MarkType.SUPERSCRIPT] as RenderMark)(text)
}
diff --git a/src/nodes/mark-type.ts b/src/nodes/mark-type.ts
index c581d77..58cfe0f 100644
--- a/src/nodes/mark-type.ts
+++ b/src/nodes/mark-type.ts
@@ -8,7 +8,8 @@ enum MarkType {
SUBSCRIPT = 'subscript',
- SUPERSCRIPT = 'superscript'
+ SUPERSCRIPT = 'superscript',
+ BREAK = 'break'
}
export default MarkType
\ No newline at end of file
diff --git a/src/nodes/text-node.ts b/src/nodes/text-node.ts
index 5df949c..800e026 100644
--- a/src/nodes/text-node.ts
+++ b/src/nodes/text-node.ts
@@ -8,6 +8,7 @@ export default class TextNode extends Node {
inlineCode?: boolean
superscript?: boolean
subscript?: boolean
+ break?: boolean
text: string
diff --git a/src/options/default-node-options.ts b/src/options/default-node-options.ts
index 4249a4a..87fff23 100644
--- a/src/options/default-node-options.ts
+++ b/src/options/default-node-options.ts
@@ -11,6 +11,9 @@ export const defaultNodeOption: RenderOption = {
return `${next(node.children)} ` }, [NodeType.LINK]:(node: Node, next: Next) => { + if (node.attrs.target) { + return `${next(node.children)}` + } return `${next(node.children)}` }, [NodeType.IMAGE]:(node: Node, next: Next) => { @@ -78,6 +81,9 @@ export const defaultNodeOption: RenderOption = { }, ['reference']:(node: Node, next: Next) => { + if (node.attrs['type'] === 'asset') { + return `${text}` + }, } \ No newline at end of file |
|---|