mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-01 13:18:29 +01:00
3339d088e1
* Add Prettier, with basic config and ESLint integration * Apply Prettier to all files using `yarn lint --fix` * Tell Prettier to ignore an empty text in a test output. * Run Prettier on JS files not handled by ESLint, and lint them too
39 lines
759 B
JavaScript
39 lines
759 B
JavaScript
/** @jsx h */
|
|
|
|
import React from 'react'
|
|
import h from '../helpers/h'
|
|
|
|
export const rules = [
|
|
{
|
|
serialize(obj, children) {
|
|
if (obj.object == 'block' && obj.type == 'paragraph') {
|
|
return React.createElement('p', {}, children)
|
|
}
|
|
|
|
if (obj.object == 'inline' && obj.type == 'link') {
|
|
return React.createElement('a', {}, children)
|
|
}
|
|
|
|
if (obj.object == 'inline' && obj.type == 'hashtag') {
|
|
return React.createElement('span', {}, children)
|
|
}
|
|
},
|
|
},
|
|
]
|
|
|
|
export const input = (
|
|
<value>
|
|
<document>
|
|
<paragraph>
|
|
<link>
|
|
<hashtag>one</hashtag>
|
|
</link>
|
|
</paragraph>
|
|
</document>
|
|
</value>
|
|
)
|
|
|
|
export const output = `
|
|
<p><a><span>one</span></a></p>
|
|
`.trim()
|