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) {
|
2018-02-06 23:12:00 +00:00
|
|
|
return React.createElement('img', {
|
|
|
|
src: props.node.data.get('src'),
|
|
|
|
...props.attributes,
|
|
|
|
})
|
2017-10-25 17:32:29 -07:00
|
|
|
}
|
|
|
|
|
2018-10-09 18:43:47 -07:00
|
|
|
function renderNode(props, next) {
|
2017-10-25 17:32:29 -07:00
|
|
|
switch (props.node.type) {
|
2018-02-06 23:12:00 +00:00
|
|
|
case 'image':
|
|
|
|
return Image(props)
|
2018-10-09 18:43:47 -07:00
|
|
|
default:
|
|
|
|
return next()
|
2017-10-14 10:10:47 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const props = {
|
|
|
|
readOnly: true,
|
2017-10-25 17:32:29 -07:00
|
|
|
renderNode,
|
2018-08-22 18:22:40 -07:00
|
|
|
schema: {
|
|
|
|
blocks: {
|
|
|
|
image: {
|
|
|
|
isVoid: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2017-10-14 10:10:47 -07:00
|
|
|
}
|
|
|
|
|
2017-10-27 13:39:06 -07:00
|
|
|
export const value = (
|
|
|
|
<value>
|
2017-10-14 10:10:47 -07:00
|
|
|
<document>
|
2018-10-09 14:03:27 -07:00
|
|
|
<image src="https://example.com/image.png">
|
|
|
|
<text />
|
|
|
|
</image>
|
2017-10-14 10:10:47 -07:00
|
|
|
</document>
|
2017-10-27 13:39:06 -07:00
|
|
|
</value>
|
2017-10-14 10:10:47 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
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()
|