diff --git a/packages/slate-react-placeholder/src/index.js b/packages/slate-react-placeholder/src/index.js index b35617a5f..0a04583fd 100644 --- a/packages/slate-react-placeholder/src/index.js +++ b/packages/slate-react-placeholder/src/index.js @@ -16,11 +16,6 @@ let instanceCounter = 0 function SlateReactPlaceholder(options = {}) { const instanceId = instanceCounter++ - const placeholderMark = { - type: 'placeholder', - data: { key: instanceId }, - } - const { placeholder, when, style = {} } = options invariant( @@ -53,13 +48,14 @@ function SlateReactPlaceholder(options = {}) { const [firstNode, firstPath] = first const [lastNode, lastPath] = last const decoration = { + type: 'placeholder', + data: { key: instanceId }, anchor: { key: firstNode.key, offset: 0, path: firstPath }, focus: { key: lastNode.key, offset: lastNode.text.length, path: lastPath, }, - mark: placeholderMark, } return [...others, decoration] diff --git a/packages/slate/src/models/decoration.js b/packages/slate/src/models/decoration.js index 9adeef27c..d0983bfab 100644 --- a/packages/slate/src/models/decoration.js +++ b/packages/slate/src/models/decoration.js @@ -1,4 +1,5 @@ import isPlainObject from 'is-plain-object' +import warning from 'tiny-warning' import { List, Record } from 'immutable' import Mark from './mark' @@ -109,7 +110,18 @@ class Decoration extends Record(DEFAULTS) { */ static fromJSON(object) { - const { type, data, anchor, focus } = object + const { anchor, focus } = object + let { type, data } = object + + if (object.mark && !type) { + warning( + false, + 'As of slate@0.47 the `decoration.mark` property has been changed to `decoration.type` and `decoration.data` directly.' + ) + + type = object.mark.type + data = object.mark.data + } if (!type) { throw new Error(