mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-01 05:16:10 +01: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:
parent
c64c2ff025
commit
d01c441f68
@ -86,7 +86,20 @@ class Text extends Record(DEFAULTS) {
|
||||
}
|
||||
|
||||
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)) {
|
||||
leaves = List(leaves.map(x => Leaf.create(x)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user