1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-28 17:39:57 +02:00

Allow custom placeholder styles (#2667)

* Allow custom placeholder styles

* lint fixes

* review feedback

* lint
This commit is contained in:
Hanna Greaves
2019-04-02 14:23:50 +01:00
committed by Ian Storm Taylor
parent 2380aa094f
commit c688ad7c72
5 changed files with 63 additions and 4 deletions

View File

@@ -21,7 +21,7 @@ function SlateReactPlaceholder(options = {}) {
data: { key: instanceId },
}
const { placeholder, when } = options
const { placeholder, when, style = {} } = options
invariant(
placeholder,
@@ -72,18 +72,19 @@ function SlateReactPlaceholder(options = {}) {
const { children, mark } = props
if (mark.type === 'placeholder' && mark.data.get('key') === instanceId) {
const style = {
const placeHolderStyle = {
pointerEvents: 'none',
display: 'inline-block',
width: '0',
maxWidth: '100%',
whiteSpace: 'nowrap',
opacity: '0.333',
...style,
}
return (
<span>
<span contentEditable={false} style={style}>
<span contentEditable={false} style={placeHolderStyle}>
{placeholder}
</span>
{children}