Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.contentstack.sdk</groupId>
<artifactId>utils</artifactId>
<version>1.2.6</version>
<version>1.2.7</version>
<packaging>jar</packaging>
<name>Contentstack-utils</name>
<description>Java Utils SDK for Contentstack Content Delivery API, Contentstack is a headless CMS</description>
Expand All @@ -28,7 +28,7 @@
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
<validation-version>2.0.1.Final</validation-version>
<json-version>20231013</json-version>
<spring-web-version>6.0.13</spring-web-version>
<spring-web-version>6.0.18</spring-web-version>
<org.apache.commons-text>1.10.0</org.apache.commons-text>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public String renderNode(String nodeType, JSONObject nodeObject, NodeCallback ca
return "<code" + strAttrs + ">" + children + "</code>";
case "reference":
return "";
case "fragment":
return "<fragment" + strAttrs + ">" + children + "</fragment>";
default:
return children;
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/com/contentstack/utils/RTEResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ public class RTEResult {
public static String kWFSFeesHtml = "<p redactor-attributes=\"{}\" style=\"\" dir=\"ltr\">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <br /><br /><br />\t\t\t\tUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. <br />Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <br />\tExcepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>";

public static String kONEHtml = "<p redactor-attributes=\"{}\" style=\"\" dir=\"ltr\"><br />A paragraph with break set as trueA paragraph with line break <br /> and \t tab</p>";

public static String kFragment = "<ul redactor-attributes=\"{}\" style=\"\" dir=\"ltr\"><li redactor-attributes=\"{}\" style=\"\" dir=\"ltr\"><fragment><strong>One</strong></fragment><ul style=\"\"><li redactor-attributes=\"{}\" style=\"\" dir=\"ltr\">nested one </li><li redactor-attributes=\"{}\" style=\"\" dir=\"ltr\">nested two </li></ul></li><li redactor-attributes=\"{}\" style=\"\" dir=\"ltr\">Two</li></ul>";
}
9 changes: 9 additions & 0 deletions src/test/java/com/contentstack/utils/TestRte.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,14 @@ public void testIssueOct() throws IOException {
// Assert.assertEquals(kONEHtml, result);
}

@Test
public void testFragment() throws IOException {
final String rte = "src/test/resources/reports/fragment.json";
JSONObject rteFragment = new ReadResource().readJson(rte);
String[] keyPath = {"json_rte"};
Utils.jsonToHTML(rteFragment, keyPath, new DefaultOption());
Assert.assertEquals(kFragment, rteFragment.get("json_rte"));
}


}
132 changes: 132 additions & 0 deletions src/test/resources/reports/fragment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"title": "",
"json_rte":
{
"type": "doc",
"attrs":
{},
"uid": "71ff5918b9434999b97c97629aecc32e",
"children":
[
{
"uid": "6b80a5ead10445bf939d39c1f033bed9",
"type": "ul",
"children":
[
{
"uid": "bf242d94ca4847b6a7144c57c03d0c84",
"type": "li",
"attrs":
{
"style":
{},
"redactor-attributes":
{},
"dir": "ltr"
},
"children":
[
{
"type": "fragment",
"children":
[
{
"text": "One",
"bold": true
}
],
"uid": "cc6c5b25a77f443ba7b7cc1c1a92e7cb"
},
{
"uid": "388cdd29331e46859cb78806c30aab52",
"type": "ul",
"attrs":
{
"style":
{}
},
"children":
[
{
"type": "li",
"attrs":
{
"style":
{},
"redactor-attributes":
{},
"dir": "ltr"
},
"uid": "5e35c7de876e463a80d5b7e7bb3dbb46",
"children":
[
{
"text": "nested one "
}
]
},
{
"type": "li",
"attrs":
{
"style":
{},
"redactor-attributes":
{},
"dir": "ltr"
},
"uid": "23015f6106ad47db9142a01fa6e5465c",
"children":
[
{
"text": "nested two "
}
]
}
]
}
]
},
{
"type": "li",
"attrs":
{
"style":
{},
"redactor-attributes":
{},
"dir": "ltr"
},
"uid": "6c3fe490f18347b896d3ac2ec982d389",
"children":
[
{
"text": "Two"
}
]
}
],
"id": "10b11adfd2be427bb20f9e24122a6b48",
"attrs":
{
"style":
{},
"redactor-attributes":
{},
"dir": "ltr"
}
}
],
"_version": 1
},
"tags":
[],
"locale": "en-us",
"uid": "blt9a8011fa3669348b",
"created_by": "blta7bacfb988d2bf5c",
"updated_by": "blt734e8a0a85290dd1",
"created_at": "2024-02-08T10:58:07.835Z",
"updated_at": "2024-02-13T10:59:49.357Z",
"_version": 9,
"_in_progress": true
}