1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-02 19:52:32 +02:00

add more rendering tests

This commit is contained in:
Ian Storm Taylor
2016-07-14 15:06:44 -07:00
parent 5bc15948f6
commit 68e87ebfb8
10 changed files with 88 additions and 1 deletions

View File

@@ -0,0 +1,10 @@
import React from 'react'
function Image(props) {
return <img src={props.node.data.get('src')} />
}
export function renderNode(node) {
if (node.type == 'image') return Image
}

View File

@@ -0,0 +1,11 @@
nodes:
- kind: block
type: image
isVoid: true
data:
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
nodes:
- kind: text
ranges:
- text: another

View File

@@ -0,0 +1,13 @@
<div contenteditable="true">
<div style="position:relative;">
<span style="position:absolute;top:0px;right:0px;bottom:0px;left:0px;text-indent:-9999px;">
<span>
<br>
</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>
</div>
</div>

View File

@@ -0,0 +1,10 @@
import React from 'react'
const BOLD = {
fontWeight: 'bold'
}
export function renderMark(mark) {
if (mark.type == 'bold') return BOLD
}

View File

@@ -0,0 +1,12 @@
nodes:
- kind: block
type: default
nodes:
- kind: text
ranges:
- text: one
- text: two
marks:
- type: bold
- text: three

View File

@@ -0,0 +1,10 @@
<div contenteditable="true">
<div>
<span>
<span>one</span>
<span style="font-weight:bold;">two</span>
<span>three</span>
</span>
</div>
</div>

View File

@@ -0,0 +1,4 @@
/**
* Nothing, pure defaults.
*/

View File

@@ -0,0 +1,8 @@
nodes:
- kind: block
type: default
nodes:
- kind: text
ranges:
- text: ""

View File

@@ -0,0 +1,8 @@
<div contenteditable="true">
<div>
<span>
<span><br></span>
</span>
</div>
</div>

View File

@@ -52,8 +52,9 @@ function clean(html) {
$('*').each((i, el) => {
$(el).removeAttr('data-key')
$(el).removeAttr('data-offset-key')
$(el).removeAttr('style')
})
$('[contenteditable]').removeAttr('style')
return $.html()
}