diff -r 1f340f3597a8 -r ea92f4fe783d client/src/HtmlSerializer.js --- a/client/src/HtmlSerializer.js Tue Oct 09 19:07:47 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -import React from 'react' -import Html from 'slate-html-serializer' - -const BLOCK_TAGS = { - p: 'paragraph', - ul: 'bulleted-list', - ol: 'numbered-list', - li: 'list-item', -} - -// Add a dictionary of mark tags. -const MARK_TAGS = { - em: 'italic', - strong: 'bold', - u: 'underlined', - category: 'span' -} - -const rules = [ - // Block rules - { - deserialize(el, next) { - const type = BLOCK_TAGS[el.tagName] - if (!type) return - return { - object: 'block', - type: type, - nodes: next(el.childNodes) - } - }, - serialize(obj, children) { - if (obj.object !== 'block') return - switch (obj.type) { - case 'numbered-list': - return
{children}
- default: return; - } - } - }, - // Mark rules - { - deserialize(el, next) { - const type = MARK_TAGS[el.tagName] - if (!type) return - return { - object: 'mark', - type: type, - nodes: next(el.childNodes) - } - }, - serialize(obj, children) { - if (obj.object !== 'mark') return - switch (obj.type) { - case 'bold': - return {children} - case 'italic': - return {children} - case 'underlined': - return {children} - case 'category': - return {children} - default: return; - } - } - } -] - -const serializer = new Html({ rules }) - -export default serializer