mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 05:01:17 +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 = {
|
const INLINE_NO_EMPTY = {
|
||||||
match: (object) => {
|
match: (object) => {
|
||||||
return object.kind == 'inline'
|
return object.kind == 'block'
|
||||||
},
|
},
|
||||||
validate: (inline) => {
|
validate: (block) => {
|
||||||
return inline.text == ''
|
return block.nodes.some((child) => {
|
||||||
|
return child.kind == 'inline' && child.text == ''
|
||||||
|
})
|
||||||
},
|
},
|
||||||
normalize: (transform, node) => {
|
normalize: (transform, block) => {
|
||||||
return transform.removeNodeByKey(node.key, { normalize: false })
|
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