1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-07-31 04:20:26 +02:00

Fix renderBlockButton of rich text example (#2412)

By checking if there are blocks in the selection
This commit is contained in:
Dundercover
2018-11-15 17:06:59 +01:00
committed by Ian Storm Taylor
parent 0c94ccebce
commit 518c7e0a51

View File

@@ -144,9 +144,12 @@ class RichTextExample extends React.Component {
let isActive = this.hasBlock(type)
if (['numbered-list', 'bulleted-list'].includes(type)) {
const { value } = this.state
const parent = value.document.getParent(value.blocks.first().key)
isActive = this.hasBlock('list-item') && parent && parent.type === type
const { value: { document, blocks } } = this.state
if (blocks.size > 0) {
const parent = document.getParent(blocks.first().key)
isActive = this.hasBlock('list-item') && parent && parent.type === type
}
}
return (