client/src/HtmlSerializer.js
changeset 21 284e866f55c7
parent 19 f1b125b95fe9
child 25 e04714a1d4eb
equal deleted inserted replaced
20:a8300ef1876e 21:284e866f55c7
     9 const MARK_TAGS = {
     9 const MARK_TAGS = {
    10   em: 'italic',
    10   em: 'italic',
    11   strong: 'bold',
    11   strong: 'bold',
    12   u: 'underline',
    12   u: 'underline',
    13   annotation: 'span'
    13   annotation: 'span'
    14 }
       
    15 
       
    16 const annotationStyle = {
       
    17   textDecoration: 'underline',
       
    18   textDecorationStyle: 'dotted',
       
    19   backgroundColor: 'yellow'
       
    20 }
    14 }
    21 
    15 
    22 const rules = [
    16 const rules = [
    23   // Block rules
    17   // Block rules
    24   {
    18   {
    55       if (object.kind !== 'mark') return
    49       if (object.kind !== 'mark') return
    56       switch (object.type) {
    50       switch (object.type) {
    57         case 'bold': return <strong>{children}</strong>
    51         case 'bold': return <strong>{children}</strong>
    58         case 'italic': return <em>{children}</em>
    52         case 'italic': return <em>{children}</em>
    59         case 'underline': return <u>{children}</u>
    53         case 'underline': return <u>{children}</u>
    60         case 'annotation': return <span style={annotationStyle}>{children}</span>
    54         case 'annotation': return <span style={{ backgroundColor: object.data.get('color') }}>{children}</span>
    61         default: return;
    55         default: return;
    62       }
    56       }
    63     }
    57     }
    64   }
    58   }
    65 ]
    59 ]