mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-17 20:51:20 +02:00
fix styles for void, fix tests for void rendering
This commit is contained in:
@@ -21,6 +21,10 @@ class Void extends React.Component {
|
||||
style: React.PropTypes.object
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
style: {}
|
||||
}
|
||||
|
||||
shouldComponentUpdate = (props) => {
|
||||
return (
|
||||
props.node != this.props.node ||
|
||||
@@ -34,20 +38,18 @@ class Void extends React.Component {
|
||||
const Tag = node.kind == 'block' ? 'div' : 'span'
|
||||
|
||||
// Make the outer wrapper relative, so the spacer can overlay it.
|
||||
const relative = {
|
||||
const styles = {
|
||||
...style,
|
||||
position: 'relative'
|
||||
}
|
||||
|
||||
return (
|
||||
<Tag
|
||||
contentEditable={false}
|
||||
style={relative}
|
||||
>
|
||||
<Tag contentEditable={false}>
|
||||
<Tag
|
||||
contentEditable
|
||||
suppressContentEditableWarning
|
||||
className={className}
|
||||
style={style}
|
||||
style={styles}
|
||||
>
|
||||
{this.renderSpacer()}
|
||||
<Tag contentEditable={false}>{children}</Tag>
|
||||
|
@@ -1,8 +1,13 @@
|
||||
|
||||
import { Void } from '../../../..'
|
||||
import React from 'react'
|
||||
|
||||
function Image(props) {
|
||||
return <img src={props.node.data.get('src')} />
|
||||
return (
|
||||
<Void {...props}>
|
||||
<img src={props.node.data.get('src')} />
|
||||
</Void>
|
||||
)
|
||||
}
|
||||
|
||||
export function renderNode(node) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
|
||||
<div contenteditable="true">
|
||||
<div style="position:relative;">
|
||||
<div contenteditable="false">
|
||||
<div contenteditable="true" style="position:relative;">
|
||||
<span style="position:absolute;top:0px;right:0px;bottom:0px;left:0px;text-indent:-9999px;">
|
||||
<span>
|
||||
<br>
|
||||
@@ -11,3 +12,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -54,7 +54,7 @@ function clean(html) {
|
||||
$(el).removeAttr('data-offset-key')
|
||||
})
|
||||
|
||||
$('[contenteditable]').removeAttr('style')
|
||||
$.root().children().removeAttr('style')
|
||||
|
||||
return $.html()
|
||||
}
|
||||
|
Reference in New Issue
Block a user