Skip to content

Commit 2979273

Browse files
Merge pull request #80 from contentstack/RT-411
feat: hr as a tag not data type
2 parents db47a9e + 78b8f26 commit 2979273

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/toRedactor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const ELEMENT_TYPES: IJsonToHtmlElementTags = {
105105
return `<div${attrs}>${child}</div>`
106106
},
107107
hr: (attrs: any, child: any) => {
108-
return `<div data-type='hr' style='border-top: 3px solid #bbb'></div>`
108+
return `<hr>`
109109
},
110110
span: (attrs: any, child: any) => {
111111
return `<span${attrs}>${child}</span>`

test/expectedJson.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ export default {
618618
"htmlUpdated": "<p></p><img asset_uid=\"blt5523ee02703e39f5\" src=\"https://images.com/captain_pardip.jpg\" width=\"24.193548387096776\" height=\"auto\" style=\"width: 24.193548387096776; height: auto;height: auto;\" type=\"asset\" sys-style-type=\"download\"/><p></p><iframe src=\"https://www.***REMOVED***.com/embed/CSvFpBOe8eY\"></iframe><img asset_uid=\"blta2aad0332073026c\" src=\"https://images.com/logo_1.jpg\" height=\"auto\" type=\"asset\" sys-style-type=\"download\"/>"
619619
},
620620
"7": {
621-
"html": "<p>this is <a href=\"link.com\" target=\"_self\">link</a></p><p></p><div data-type='hr' style='border-top: 3px solid #bbb'></div><p></p><p class=\"className\">paragraph with class</p><p id=\"id\">paragraph with id</p>",
621+
"html": "<p>this is <a href=\"link.com\" target=\"_self\">link</a></p><p></p><hr><p></p><p class=\"className\">paragraph with class</p><p id=\"id\">paragraph with id</p>",
622622
"json": [
623623
{
624624
"type": "p",
@@ -660,6 +660,7 @@ export default {
660660
},
661661
{
662662
"type": "hr",
663+
"attrs": {},
663664
"uid": "699946dbb6b84ef583914eb92dcac44b",
664665
"children": [
665666
{

test/fromRedactor.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe("Testing html to json conversion", () => {
6666
let htmlDoc = dom.window.document.querySelector('body')
6767
let jsonValue = fromRedactor(htmlDoc)
6868
let testResult = isEqual(omitdeep(jsonValue, "uid"), omitdeep(docWrapper(expectedValue[7].json), "uid"))
69-
expect(testResult).toBe(true)
69+
expect(omitdeep(jsonValue, "uid")).toStrictEqual(omitdeep(docWrapper(expectedValue[7].json), "uid"))
7070
})
7171

7272
it("Embedded entry as link", () => {

0 commit comments

Comments
 (0)