mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-25 08:11:53 +02:00
Fix rule NO_ADJACENT_TEXT_RULE
This commit is contained in:
@@ -98,14 +98,15 @@ const NO_ADJACENT_TEXT_RULE = {
|
|||||||
validate: (node) => {
|
validate: (node) => {
|
||||||
const { nodes } = node
|
const { nodes } = node
|
||||||
const invalids = nodes
|
const invalids = nodes
|
||||||
.filter((n, i) => {
|
|
||||||
const next = nodes.get(i + 1)
|
|
||||||
return n.kind == 'text' && next && next.kind == 'text'
|
|
||||||
})
|
|
||||||
.map((n, i) => {
|
.map((n, i) => {
|
||||||
const next = nodes.get(i + 1)
|
const next = nodes.get(i + 1)
|
||||||
|
if (n.kind !== 'text' || !next || next.kind !== 'text') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
return [n, next]
|
return [n, next]
|
||||||
})
|
})
|
||||||
|
.filter(Boolean)
|
||||||
|
|
||||||
return invalids.size ? invalids : null
|
return invalids.size ? invalids : null
|
||||||
},
|
},
|
||||||
|
@@ -48,6 +48,7 @@ export function applyOperation(transform, operation) {
|
|||||||
const { type } = operation
|
const { type } = operation
|
||||||
const fn = OPERATIONS[type]
|
const fn = OPERATIONS[type]
|
||||||
|
|
||||||
|
console.log('apply op', type, operation);
|
||||||
if (!fn) {
|
if (!fn) {
|
||||||
throw new Error(`Unknown operation type: "${type}".`)
|
throw new Error(`Unknown operation type: "${type}".`)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user