You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,6 +162,12 @@ On the other hand, the `customTextWrapper` parser function provides the followin
162
162
-`value`: The value passed against the child element
163
163
164
164
165
+
You can pass an object to `allowedEmptyAttributes` to retain empty attribute values for specific element types during HTML conversion.
166
+
167
+
**Note:**
168
+
By default, if nothing is passed to `allowedEmptyAttributes`, we retain the `alt` attribute for `<img>` and `reference` (asset) element types, even when its value is empty, during HTML conversion.
169
+
170
+
165
171
You can use the following customized JSON RTE Serializer code to convert your JSON RTE field data into HTML format.
"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>",
Copy file name to clipboardExpand all lines: test/toRedactor.test.ts
+26-2Lines changed: 26 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,8 @@
1
1
import{toRedactor}from"../src/toRedactor"
2
-
importisEqualfrom"lodash.isequal"
3
-
4
2
importexpectedValuefrom"./expectedJson"
5
3
import{imageAssetData}from"./testingData"
6
4
5
+
7
6
describe("Testing json to html conversion",()=>{
8
7
it("heading conversion",()=>{
9
8
letjsonValue=expectedValue["2"].json
@@ -292,5 +291,30 @@ describe("Testing json to html conversion", () => {
292
291
consthtml=toRedactor(json);
293
292
expect(html).toBe(`<img alt="Infographic showing 3 results from Forrester study of Contentstack CMS: $3M increase in profit, $507.3K productivity savings and $2.0M savings due to reduced time to publish." src="https://images.contentstack.io/v3/assets/blt7359e2a55efae483/bltea2a11144a2c68b5/63c08b7f438f80612c397994/CS_Infographics_ForresterReport_Data_3_1200x628_(1).png" position="center" width="641" style="width: 641; height: auto;" />`)
294
293
})
294
+
295
+
describe("RT-268",()=>{
296
+
it(' should retain empty string value for alt attribute for img type',()=>{
0 commit comments