/* * << * 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, { useContext } from 'react' import { Select } from 'antd' const { Option } = Select import { OptionProps } from 'antd/lib/select' import { EditorContext } from '../context' import { HeadingElementTypes } from '../Element/constants' const Heading: React.FC = () => { const { isElementActive, toggleElement } = useContext(EditorContext) const activeValue = HeadingSelectOptions.find(({ value }) => isElementActive(value))?.value || HeadingElementTypes.HeadingNone return ( ) } export default Heading interface HeadingOptionProps extends OptionProps { value: HeadingElementTypes } const HeadingSelectOptions: HeadingOptionProps[] = [ { value: HeadingElementTypes.HeadingOne, label:

一级标题

}, { value: HeadingElementTypes.HeadingTwo, label:

二级标题

}, { value: HeadingElementTypes.HeadingThree, label:

三级标题

}, { value: HeadingElementTypes.HeadingFour, label:

四级标题

}, { value: HeadingElementTypes.HeadingFive, label:
五级标题
}, { value: HeadingElementTypes.HeadingSix, label:
六级标题
}, { value: HeadingElementTypes.HeadingNone, label: 无标题 } ]