1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-11 01:33:58 +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) => { validate: (node) => {
const { nodes } = node const { nodes } = node
const invalids = nodes const invalids = nodes
.map((n, i) => { .map((child, i) => {
const next = nodes.get(i + 1) const next = nodes.get(i + 1)
if (n.kind !== 'text' || !next || next.kind !== 'text') { if (child.kind !== 'text' || !next || next.kind !== 'text') {
return return
} }
return [n, next] return [child, next]
}) })
.filter(Boolean) .filter(Boolean)

View File

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