1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-12 10:14:02 +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,10 +144,13 @@ class RichTextExample extends React.Component {
let isActive = this.hasBlock(type) let isActive = this.hasBlock(type)
if (['numbered-list', 'bulleted-list'].includes(type)) { if (['numbered-list', 'bulleted-list'].includes(type)) {
const { value } = this.state const { value: { document, blocks } } = this.state
const parent = value.document.getParent(value.blocks.first().key)
if (blocks.size > 0) {
const parent = document.getParent(blocks.first().key)
isActive = this.hasBlock('list-item') && parent && parent.type === type isActive = this.hasBlock('list-item') && parent && parent.type === type
} }
}
return ( return (
<Button <Button