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:
@@ -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)
|
||||||
|
|
||||||
|
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user