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:
parent
a9807c949b
commit
13d7cb07c6
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user