2017-10-14 10:10:47 -07:00
|
|
|
/** @jsx h */
|
|
|
|
|
|
|
|
import React from 'react'
|
|
|
|
import h from '../../helpers/h'
|
|
|
|
|
2017-10-25 17:32:29 -07:00
|
|
|
function Image(props) {
|
|
|
|
return React.createElement('img', { src: props.node.data.get('src'), ...props.attributes })
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderNode(props) {
|
|
|
|
switch (props.node.type) {
|
|
|
|
case 'image': return Image(props)
|
2017-10-14 10:10:47 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const props = {
|
|
|
|
readOnly: true,
|
2017-10-25 17:32:29 -07:00
|
|
|
renderNode,
|
2017-10-14 10:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export const state = (
|
|
|
|
<state>
|
|
|
|
<document>
|
|
|
|
<image src="https://example.com/image.png" />
|
|
|
|
</document>
|
|
|
|
</state>
|
|
|
|
)
|
|
|
|
|
|
|
|
export const output = `
|
|
|
|
<div data-slate-editor="true">
|
|
|
|
<div data-slate-void="true">
|
|
|
|
<div>
|
|
|
|
<img src="https://example.com/image.png">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`.trim()
|