How to handle <br> tags? #305
-
I currently have filter running which works but it strips out <br> tags. I want to allow <br> tags but I don't know how to implement this. Is it a block type ? Or is it an entity type ? I cannot find this information anywhere. My current filter code is below. Is there some way I can add the humble <br> tag to the allowed types or entities? (fingers crossed). const filteredState = filterEditorState(
{
blocks: ["header-four", "header-five", "header-six", "unordered-list-item", "ordered-list-item", "blockquote"],
styles: ["BOLD", "ITALIC", "UNDERLINE", "SUPERSCRIPT", "SUBSCRIPT"],
entities: [
{
type: "IMAGE",
attributes: ["src"],
whitelist: {
src: "^http"
}
},
{
type: "LINK"
}
],
maxNesting: 1,
whitespacedCharacters: ["\n", "\t", "📷"]
},
editorState
);` |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hey @Hereward 👋 Draft.js stores |
Beta Was this translation helpful? Give feedback.
-
Hi thanks for your feedback. I figured this out myself after banging my head against the wall for a while - but thanks for confirming :) |
Beta Was this translation helpful? Give feedback.
-
👍glad you figured it out! |
Beta Was this translation helpful? Give feedback.
Hey @Hereward 👋 Draft.js stores
br
tags as line breaks (\n
). Here you have these configured to be transformed into spaces:whitespacedCharacters: ["\n", "\t", "📷"]
. I think this would work as you expect if you remove the\n
from that list.