From b5675ef2ff4a7edb53cc184e96421d04e08f26dc Mon Sep 17 00:00:00 2001 From: Ashwini-Rathod Date: Tue, 9 Jan 2024 13:35:35 +0530 Subject: [PATCH] fix: Duplicate br tags added in html when there is a line break in json --- package-lock.json | 4 ++-- src/toRedactor.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1d47fa4..2e2cfc8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/json-rte-serializer", - "version": "2.0.5", + "version": "2.0.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@contentstack/json-rte-serializer", - "version": "2.0.5", + "version": "2.0.6", "license": "MIT", "dependencies": { "array-flat-polyfill": "^1.0.1", diff --git a/src/toRedactor.tsx b/src/toRedactor.tsx index bde7045..96c5135 100644 --- a/src/toRedactor.tsx +++ b/src/toRedactor.tsx @@ -229,7 +229,7 @@ export const toRedactor = (jsonValue: any,options?:IJsonToHtmlOptions) : string text = `${text}` } } - if (jsonValue.text.includes('\n')) { + if (jsonValue.text.includes('\n') && !jsonValue['break']) { text = text.replace(/\n/g, '
') } Object.entries(jsonValue).forEach(([key, value]) => {