diff --git a/packages/slate-react-placeholder/src/index.js b/packages/slate-react-placeholder/src/index.js index 0a04583fd..a4331ebcd 100644 --- a/packages/slate-react-placeholder/src/index.js +++ b/packages/slate-react-placeholder/src/index.js @@ -70,10 +70,10 @@ function SlateReactPlaceholder(options = {}) { * @return {Element} */ - function renderMark(props, editor, next) { - const { children, mark } = props + function renderDecoration(props, editor, next) { + const { children, decoration: deco } = props - if (mark.type === 'placeholder' && mark.data.get('key') === instanceId) { + if (deco.type === 'placeholder' && deco.data.get('key') === instanceId) { const placeHolderStyle = { pointerEvents: 'none', display: 'inline-block', @@ -103,7 +103,7 @@ function SlateReactPlaceholder(options = {}) { * @return {Object} */ - return { decorateNode, renderMark } + return { decorateNode, renderDecoration } } /** diff --git a/packages/slate/src/models/text.js b/packages/slate/src/models/text.js index f9875ba8c..7ffde0818 100644 --- a/packages/slate/src/models/text.js +++ b/packages/slate/src/models/text.js @@ -186,15 +186,15 @@ class Text extends Record(DEFAULTS) { const offset = o o += length - // If the range starts after the leaf, or ends before it, continue. - if (start.offset > offset + length || end.offset <= offset) { + // If the range encompases the entire leaf, add the format. + if (start.offset <= offset && end.offset >= offset + length) { + leaf[kind].push(format) next.push(leaf) continue } - // If the range encompases the entire leaf, add the format. - if (start.offset <= offset && end.offset >= offset + length) { - leaf[kind].push(format) + // If the range starts after the leaf, or ends before it, continue. + if (start.offset > offset + length || end.offset <= offset) { next.push(leaf) continue }