This commit is contained in:
Ran Luo 2019-09-25 02:24:38 +08:00 committed by Felix Häusler
parent 20220f6b5f
commit d9b77366e8

View File

@ -387,7 +387,30 @@ const enterCtrl = ContentState => {
newBlock.bulletMarkerOrDelimiter = block.bulletMarkerOrDelimiter
}
newBlock.isLooseListItem = block.isLooseListItem
} else if (block.type === 'hr') {
const preText = text.substring(0, left)
const postText = text.substring(left)
// Degrade thematice break to paragraph
if (preText.replace(/ /g, '').length < 3) {
block.type = 'p'
block.children[0].functionType = 'paragraphContent'
}
if (postText.replace(/ /g, '').length >= 3) {
newBlock = this.createBlock('hr')
const content = this.createBlock('span', {
functionType: 'thematicBreakLine',
text: postText
})
this.appendChild(newBlock, content)
} else {
newBlock = this.createBlockP(postText)
}
block.children[0].text = preText
}
this.insertAfter(newBlock, block)
break
}