1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-16 12:14:14 +02:00

fix styles for void, fix tests for void rendering

This commit is contained in:
Ian Storm Taylor
2016-07-22 13:39:02 -07:00
parent 5212a47fa2
commit 1784f25caa
4 changed files with 24 additions and 15 deletions

View File

@@ -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>

View File

@@ -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) {

View File

@@ -1,13 +1,15 @@
<div contenteditable="true">
<div style="position:relative;">
<span style="position:absolute;top:0px;right:0px;bottom:0px;left:0px;text-indent:-9999px;">
<span>
<br>
<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>
</span>
</span>
</span>
<div contenteditable="false">
<img src="https://img.washingtonpost.com/wp-apps/imrs.php?src=https://img.washingtonpost.com/news/speaking-of-science/wp-content/uploads/sites/36/2015/10/as12-49-7278-1024x1024.jpg&w=1484">
<div contenteditable="false">
<img src="https://img.washingtonpost.com/wp-apps/imrs.php?src=https://img.washingtonpost.com/news/speaking-of-science/wp-content/uploads/sites/36/2015/10/as12-49-7278-1024x1024.jpg&w=1484">
</div>
</div>
</div>
</div>

View File

@@ -54,7 +54,7 @@ function clean(html) {
$(el).removeAttr('data-offset-key')
})
$('[contenteditable]').removeAttr('style')
$.root().children().removeAttr('style')
return $.html()
}