-
-
Save dmitrizzle/928ed016109bc74a03be18efcb8b05cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const wrapperStyle = { | |
position: 'relative' | |
} | |
const PlaceHolder = React.createClass({ | |
renderPlaceholder(){ | |
const { node, state, parent } = this.props; | |
const placeholderText = node.data.get('placeholderText'); | |
return ( | |
<Placeholder | |
firstOnly={false} | |
parent={parent} | |
node={node} | |
state={state} | |
> | |
{ placeholderText } | |
</Placeholder> | |
) | |
}, | |
render(){ | |
const { node, attributes, children } = this.props; | |
const wrapperNodeType = node.data.get('wrapperNodeType'); | |
switch (wrapperNodeType) { | |
case 'p': | |
return ( | |
<p {...attributes} style={wrapperStyle} > | |
{ this.renderPlaceholder() } | |
{children} | |
</p> | |
) | |
case 'h1': | |
return ( | |
<h1 {...attributes} style={wrapperStyle} > | |
{ this.renderPlaceholder() } | |
{children} | |
</h1> | |
) | |
case 'h2': | |
return ( | |
<h2 {...attributes} style={wrapperStyle} > | |
{ this.renderPlaceholder() } | |
{children} | |
</h2> | |
) | |
default: | |
return ( | |
<p {...attributes} style={wrapperStyle} > | |
{ this.renderPlaceholder() } | |
{children} | |
</p> | |
) | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment