Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New line issue fix #81

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@ export default function draftToHtml(
}
}
}
return html.join('');
const cleanedHtml = html.map((htmlBlock) =>
htmlBlock === "<p></p>\n" ? "<br>\n" : htmlBlock
);
return cleanedHtml.join("");
}
8 changes: 7 additions & 1 deletion lib/draftjs-to-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
(global = global || self, global.draftjsToHtml = factory());
}(this, (function () { 'use strict';

/* @flow */

/**
* Utility function to execute callback for eack key->value pair.
*/
Expand Down Expand Up @@ -676,6 +678,7 @@
return listHtml.join('');
}

/* @flow */
/**
* The function will generate html markup for given draftjs editorContent.
*/
Expand Down Expand Up @@ -714,7 +717,10 @@
}
}

return html.join('');
var cleanedHtml = html.map(function (htmlBlock) {
return htmlBlock === "<p></p>\n" ? "<br>\n" : htmlBlock;
});
return cleanedHtml.join("");
}

return draftToHtml;
Expand Down