mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-30 18:39:51 +02:00
Fix placeholder not rendering (#2819)
This commit is contained in:
committed by
Ian Storm Taylor
parent
1639e8da49
commit
d7b37a8dca
@@ -70,10 +70,10 @@ function SlateReactPlaceholder(options = {}) {
|
|||||||
* @return {Element}
|
* @return {Element}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function renderMark(props, editor, next) {
|
function renderDecoration(props, editor, next) {
|
||||||
const { children, mark } = props
|
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 = {
|
const placeHolderStyle = {
|
||||||
pointerEvents: 'none',
|
pointerEvents: 'none',
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
@@ -103,7 +103,7 @@ function SlateReactPlaceholder(options = {}) {
|
|||||||
* @return {Object}
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return { decorateNode, renderMark }
|
return { decorateNode, renderDecoration }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -186,15 +186,15 @@ class Text extends Record(DEFAULTS) {
|
|||||||
const offset = o
|
const offset = o
|
||||||
o += length
|
o += length
|
||||||
|
|
||||||
// If the range starts after the leaf, or ends before it, continue.
|
// If the range encompases the entire leaf, add the format.
|
||||||
if (start.offset > offset + length || end.offset <= offset) {
|
if (start.offset <= offset && end.offset >= offset + length) {
|
||||||
|
leaf[kind].push(format)
|
||||||
next.push(leaf)
|
next.push(leaf)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the range encompases the entire leaf, add the format.
|
// If the range starts after the leaf, or ends before it, continue.
|
||||||
if (start.offset <= offset && end.offset >= offset + length) {
|
if (start.offset > offset + length || end.offset <= offset) {
|
||||||
leaf[kind].push(format)
|
|
||||||
next.push(leaf)
|
next.push(leaf)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user