Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

Commit

Permalink
chore: update slate api schema object #50
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielrtakeda committed Nov 28, 2017
1 parent 8569b19 commit 6e39582
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 45 deletions.
25 changes: 25 additions & 0 deletions src/package/SlateEditor/SlateContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@ import React from 'react'
import classnames from 'classnames'
import { Editor } from 'slate-react'

import { AlignmentNode } from '../plugins/slate-alignment-plugin'
import { EmbedNode } from '../plugins/slate-embed-plugin'
import { GridNode, GridRowNode, GridCellNode } from '../plugins/slate-grid-plugin'
import { ImageNode, ImageLinkNode } from '../plugins/slate-image-plugin'
import { LinkNode } from '../plugins/slate-link-plugin'
import { UnorderedListNode, OrderedListNode, ListItemNode } from '../plugins/slate-list-plugin'

/* eslint-disable default-case */
export const renderNode = (props) => {
switch (props.node.type) {
case 'alignment': return <AlignmentNode {...props} />
case 'embed': return <EmbedNode {...props} />
case 'grid': return <GridNode {...props} />
case 'grid-row': return <GridRowNode {...props} />
case 'grid-cell': return <GridCellNode {...props} />
case 'image': return <ImageNode {...props} />
case 'image-link': return <ImageLinkNode {...props} />
case 'link': return <LinkNode {...props} />
case 'unordered-list': return <UnorderedListNode {...props} />
case 'ordered-list': return <OrderedListNode {...props} />
case 'list-item': return <ListItemNode {...props} />
}
}
/* eslint-disable default-case */

export default ({
className,
wrapperStyle,
Expand Down
9 changes: 3 additions & 6 deletions src/package/plugins/slate-alignment-plugin/AlignmentSchema.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import AlignmentNode from './AlignmentNode'


const AlignmentSchema = {
nodes: {
alignment: AlignmentNode,
},
document: {
nodes: [{ types: ['alignment'] }]
}
}

export default AlignmentSchema
9 changes: 3 additions & 6 deletions src/package/plugins/slate-embed-plugin/EmbedSchema.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import EmbedNode from './EmbedNode'


const EmbedSchema = {
nodes: {
embed: EmbedNode,
},
document: {
nodes: [{ types: ['embed'] }]
}
}

export default EmbedSchema
13 changes: 3 additions & 10 deletions src/package/plugins/slate-grid-plugin/GridSchema.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import GridNode from './GridNode'
import GridRowNode from './GridRowNode'
import GridCellNode from './GridCellNode'


const GridSchema = {
nodes: {
'grid': GridNode,
'grid-row': GridRowNode,
'grid-cell': GridCellNode,
},
document: {
nodes: [{ types: ['grid', 'grid-row', 'grid-cell'] }]
}
}

export default GridSchema
11 changes: 3 additions & 8 deletions src/package/plugins/slate-image-plugin/ImageSchema.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import ImageNode from './ImageNode'
import ImageLinkNode from './ImageLinkNode'


const ImageSchema = {
nodes: {
image: ImageNode,
imageLink: ImageLinkNode,
},
document: {
nodes: [{ types: ['image', 'imageLink'] }]
}
}

export default ImageSchema
9 changes: 3 additions & 6 deletions src/package/plugins/slate-link-plugin/LinkSchema.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import LinkNode from './LinkNode'


const LinkSchema = {
nodes: {
link: LinkNode,
},
document: {
nodes: [{ types: ['link'] }]
}
}
export default LinkSchema
12 changes: 3 additions & 9 deletions src/package/plugins/slate-list-plugin/ListSchema.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import UnorderedListNode from './UnorderedListNode'
import OrderedListNode from './OrderedListNode'
import ListItemNode from './ListItemNode'

const ListSchema = {
nodes: {
'unordered-list': UnorderedListNode,
'list-item': ListItemNode,
'ordered-list': OrderedListNode,
},
document: {
nodes: [{ types: ['unordered-list', 'list-item', 'ordered-list'] }]
}
}

export default ListSchema

0 comments on commit 6e39582

Please sign in to comment.