mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-17 20:51:20 +02:00
Fix rule INLINE_NO_EMPTY to act on parent block
This commit is contained in:
@@ -96,13 +96,23 @@ const INLINE_CHILDREN_RULE = {
|
||||
|
||||
const INLINE_NO_EMPTY = {
|
||||
match: (object) => {
|
||||
return object.kind == 'inline'
|
||||
return object.kind == 'block'
|
||||
},
|
||||
validate: (inline) => {
|
||||
return inline.text == ''
|
||||
validate: (block) => {
|
||||
return block.nodes.some((child) => {
|
||||
return child.kind == 'inline' && child.text == ''
|
||||
})
|
||||
},
|
||||
normalize: (transform, node) => {
|
||||
return transform.removeNodeByKey(node.key, { normalize: false })
|
||||
normalize: (transform, block) => {
|
||||
return block.nodes.reduce((tr, child, index) => {
|
||||
if (child.kind == 'inline' && child.text == '') {
|
||||
return transform
|
||||
.removeNodeByKey(child.key, { normalize: false })
|
||||
.insertNodeByKey(block.key, index, Text.createFromString(''), { normalize: false })
|
||||
} else {
|
||||
return tr
|
||||
}
|
||||
}, transform)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user