mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-08 06:00:40 +02:00
add more rendering tests
This commit is contained in:
10
test/rendering/fixtures/custom-block-void/index.js
Normal file
10
test/rendering/fixtures/custom-block-void/index.js
Normal 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
|
||||||
|
}
|
11
test/rendering/fixtures/custom-block-void/input.yaml
Normal file
11
test/rendering/fixtures/custom-block-void/input.yaml
Normal 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
|
13
test/rendering/fixtures/custom-block-void/output.html
Normal file
13
test/rendering/fixtures/custom-block-void/output.html
Normal 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>
|
10
test/rendering/fixtures/custom-mark/index.js
Normal file
10
test/rendering/fixtures/custom-mark/index.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
const BOLD = {
|
||||||
|
fontWeight: 'bold'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function renderMark(mark) {
|
||||||
|
if (mark.type == 'bold') return BOLD
|
||||||
|
}
|
12
test/rendering/fixtures/custom-mark/input.yaml
Normal file
12
test/rendering/fixtures/custom-mark/input.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
nodes:
|
||||||
|
- kind: block
|
||||||
|
type: default
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
ranges:
|
||||||
|
- text: one
|
||||||
|
- text: two
|
||||||
|
marks:
|
||||||
|
- type: bold
|
||||||
|
- text: three
|
10
test/rendering/fixtures/custom-mark/output.html
Normal file
10
test/rendering/fixtures/custom-mark/output.html
Normal 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>
|
4
test/rendering/fixtures/empty-text/index.js
Normal file
4
test/rendering/fixtures/empty-text/index.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* Nothing, pure defaults.
|
||||||
|
*/
|
8
test/rendering/fixtures/empty-text/input.yaml
Normal file
8
test/rendering/fixtures/empty-text/input.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
nodes:
|
||||||
|
- kind: block
|
||||||
|
type: default
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
ranges:
|
||||||
|
- text: ""
|
8
test/rendering/fixtures/empty-text/output.html
Normal file
8
test/rendering/fixtures/empty-text/output.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
<div contenteditable="true">
|
||||||
|
<div>
|
||||||
|
<span>
|
||||||
|
<span><br></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
@@ -52,8 +52,9 @@ function clean(html) {
|
|||||||
$('*').each((i, el) => {
|
$('*').each((i, el) => {
|
||||||
$(el).removeAttr('data-key')
|
$(el).removeAttr('data-key')
|
||||||
$(el).removeAttr('data-offset-key')
|
$(el).removeAttr('data-offset-key')
|
||||||
$(el).removeAttr('style')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$('[contenteditable]').removeAttr('style')
|
||||||
|
|
||||||
return $.html()
|
return $.html()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user