/* * << * Davinci * == * Copyright (C) 2016 - 2017 EDP * == * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * >> */ import React from 'react' import { RenderElementProps } from 'slate-react' import { ElementTypes, BlockProperties } from './constants' import ImageElement from './ImageElement' import MarqueeElement from './MarqueeElement' const ElementPropertyList = [BlockProperties.TextAlign] const Element: React.FC = (props) => { const { attributes, children, element } = props const cssStyle: React.CSSProperties = ElementPropertyList.reduce( (obj, propertyName) => { if (element[propertyName]) { obj[propertyName] = element[propertyName] } return obj }, {} ) switch (element.type) { case ElementTypes.BlockQuote: return (
{children}
) case ElementTypes.Code: return (
          {children}
        
) // List Elements case ElementTypes.BulletedList: return ( ) case ElementTypes.NumberedList: return (
    {children}
) case ElementTypes.ListItem: return (
  • {children}
  • ) // Headings Elements case ElementTypes.HeadingOne: return (

    {children}

    ) case ElementTypes.HeadingTwo: return (

    {children}

    ) case ElementTypes.HeadingThree: return (

    {children}

    ) case ElementTypes.HeadingFour: return (

    {children}

    ) case ElementTypes.HeadingFive: return (
    {children}
    ) case ElementTypes.HeadingSix: return (
    {children}
    ) case ElementTypes.Link: return ( {children} ) case ElementTypes.Image: return // Table Elements case ElementTypes.Table: return ( {children}
    ) case ElementTypes.TableRow: return ( {children} ) case ElementTypes.TableCell: return ( {children} ) case ElementTypes.Marquee: return default: return (

    {children}

    ) } } export default Element