draft-js-utils
draft-js-utils copied to clipboard
Support for HR
Hey there,
Been diving deep into stateFromMarkdown and stateFromElement, and I noticed that the parser picks up the markdown for HR tags (---, ___, ***), but the final contentState does not seem to contain any blocks or entities that contain the HR.
As I have time, I will investigate further, but I figured I would open an issue about it in case anyone else had run into this themselves.
@Casen have you managed to conduct any investigation on this issue?
You can use a custom Block parser like this:
stateFromMarkdown(value, { customBlockFn: (node) => {
if (
node.tagName === 'P' &&
node.childNodes &&
node.childNodes.length === 1 &&
smartypantsu(node.childNodes[0].toString(), -1).match(/^\s*[-]{3,}\s*$/)
) {
return { type: 'horizontal-ruler' };
}
})