draft-js-utils icon indicating copy to clipboard operation
draft-js-utils copied to clipboard

Support for HR

Open Casen opened this issue 8 years ago • 2 comments

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 avatar Feb 02 '18 21:02 Casen

@Casen have you managed to conduct any investigation on this issue?

Deadarius avatar Jul 03 '18 22:07 Deadarius

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' };
	}
})

MrLoh avatar Jan 12 '19 22:01 MrLoh