mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-19 21:51:51 +02:00
Accept legacy "ranges" additionally to "leaves" (#1990)
* Accept ranges additionally to leaves For compatibility with older slate JSON documents, additionally to the new "leaves" property, also accept "ranges" with a deprecation warning. * Fix accepting JSON arrays for "ranges" compatibility
This commit is contained in:
committed by
Ian Storm Taylor
parent
c64c2ff025
commit
d01c441f68
@@ -86,7 +86,20 @@ class Text extends Record(DEFAULTS) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { key = KeyUtils.create() } = object
|
const { key = KeyUtils.create() } = object
|
||||||
let { leaves = List() } = object
|
let { leaves } = object
|
||||||
|
|
||||||
|
if (!leaves) {
|
||||||
|
if (object.ranges) {
|
||||||
|
logger.deprecate(
|
||||||
|
'slate@0.27.0',
|
||||||
|
'The `ranges` property of Slate objects has been renamed to `leaves`.'
|
||||||
|
)
|
||||||
|
|
||||||
|
leaves = object.ranges
|
||||||
|
} else {
|
||||||
|
leaves = List()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Array.isArray(leaves)) {
|
if (Array.isArray(leaves)) {
|
||||||
leaves = List(leaves.map(x => Leaf.create(x)))
|
leaves = List(leaves.map(x => Leaf.create(x)))
|
||||||
|
Reference in New Issue
Block a user