1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-04-21 13:51:59 +02:00

Improve unicity of uid used to generate keys

This commit is contained in:
Samy Pessé 2016-11-02 15:52:34 +01:00
parent a9807c949b
commit 13d7cb07c6
2 changed files with 6 additions and 4 deletions

View File

@ -202,13 +202,13 @@ const NO_ADJACENT_TEXT_RULE = {
validate: (node) => {
const { nodes } = node
const invalids = nodes
.map((n, i) => {
.map((child, i) => {
const next = nodes.get(i + 1)
if (n.kind !== 'text' || !next || next.kind !== 'text') {
if (child.kind !== 'text' || !next || next.kind !== 'text') {
return
}
return [n, next]
return [child, next]
})
.filter(Boolean)

View File

@ -1,6 +1,8 @@
import generate from 'uid'
let N = 0
/**
* Create a unique identifier.
*
@ -8,7 +10,7 @@ import generate from 'uid'
*/
function uid() {
return generate(4)
return (N++) + generate(4)
}
/**