Skip to content

Commit

Permalink
Merge pull request #60 from contentstack/RT-334
Browse files Browse the repository at this point in the history
feat: add quotes for inline properties
  • Loading branch information
Jayesh2812 authored Oct 24, 2024
2 parents 1936865 + bbcce97 commit 25f73c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/toRedactor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ export const toRedactor = (jsonValue: any,options?:IJsonToHtmlOptions) : string
}
if(jsonValue['classname'] || jsonValue['id']){
if(jsonValue['classname'] && jsonValue['id']){
text = `<span class=${jsonValue['classname']} id=${jsonValue['id']}>${text}</span>`
text = `<span class="${jsonValue['classname']}" id="${jsonValue['id']}">${text}</span>`
}
else if(jsonValue['classname'] && !jsonValue['id']){
text = `<span class=${jsonValue['classname']}>${text}</span>`
text = `<span class="${jsonValue['classname']}">${text}</span>`
}
else if(jsonValue['id'] && !jsonValue['classname']){
text = `<span id=${jsonValue['id']}>${text}</span>`
text = `<span id="${jsonValue['id']}">${text}</span>`
}
}
if (jsonValue.text.includes('\n') && !jsonValue['break']) {
Expand Down
2 changes: 1 addition & 1 deletion test/expectedJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,7 @@ export default {
]
},
"inline-classname-and-id": {
"html": '<p><span>This is test for adding inline <span class=class>class</span> and <span id=id>id</span></span></p>',
"html": '<p><span>This is test for adding inline <span class="class">class</span> and <span id="id">id</span></span></p>',
"json": [
{
"type": "p",
Expand Down

0 comments on commit 25f73c6

Please sign in to comment.