client/src/HtmlSerializer.js
changeset 19 f1b125b95fe9
parent 17 877d8796b86d
child 21 284e866f55c7
--- a/client/src/HtmlSerializer.js	Thu Jun 01 19:01:03 2017 +0200
+++ b/client/src/HtmlSerializer.js	Tue Jun 06 15:56:41 2017 +0200
@@ -2,9 +2,7 @@
 import { Html } from 'slate'
 
 const BLOCK_TAGS = {
-  blockquote: 'quote',
   p: 'paragraph',
-  pre: 'code'
 }
 
 // Add a dictionary of mark tags.
@@ -12,6 +10,13 @@
   em: 'italic',
   strong: 'bold',
   u: 'underline',
+  annotation: 'span'
+}
+
+const annotationStyle = {
+  textDecoration: 'underline',
+  textDecorationStyle: 'dotted',
+  backgroundColor: 'yellow'
 }
 
 const rules = [
@@ -27,12 +32,11 @@
       }
     },
     serialize(object, children) {
-      if (object.kind != 'block') return
+      if (object.kind !== 'block') return
       switch (object.type) {
-        case 'code': return <pre><code>{children}</code></pre>
         case 'paragraph':
         case 'line': return <p>{children}</p>
-        case 'quote': return <blockquote>{children}</blockquote>
+        default: return;
       }
     }
   },
@@ -48,11 +52,13 @@
       }
     },
     serialize(object, children) {
-      if (object.kind != 'mark') return
+      if (object.kind !== 'mark') return
       switch (object.type) {
         case 'bold': return <strong>{children}</strong>
         case 'italic': return <em>{children}</em>
         case 'underline': return <u>{children}</u>
+        case 'annotation': return <span style={annotationStyle}>{children}</span>
+        default: return;
       }
     }
   }