1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-24 07:52:50 +02:00

Fix rule NO_ADJACENT_TEXT_RULE

This commit is contained in:
Samy Pesse
2016-10-18 22:43:18 +02:00
parent 0246c3085b
commit 808ae3c1fb
2 changed files with 7 additions and 5 deletions

View File

@@ -98,14 +98,15 @@ const NO_ADJACENT_TEXT_RULE = {
validate: (node) => {
const { nodes } = node
const invalids = nodes
.filter((n, i) => {
const next = nodes.get(i + 1)
return n.kind == 'text' && next && next.kind == 'text'
})
.map((n, i) => {
const next = nodes.get(i + 1)
if (n.kind !== 'text' || !next || next.kind !== 'text') {
return
}
return [n, next]
})
.filter(Boolean)
return invalids.size ? invalids : null
},

View File

@@ -48,6 +48,7 @@ export function applyOperation(transform, operation) {
const { type } = operation
const fn = OPERATIONS[type]
console.log('apply op', type, operation);
if (!fn) {
throw new Error(`Unknown operation type: "${type}".`)
}