application/components/common/simple-editor/format-style-controls.js
import React from 'react';
import StyleButton from './style-button';
const FORMAT_TYPES = [
{label: 'H1', style: 'header-one'},
{label: 'H2', style: 'header-two'},
{label: 'H3', style: 'header-three'},
{label: 'H4', style: 'header-four'},
{label: 'H5', style: 'header-five'},
{label: 'H6', style: 'header-six'},
{label: 'Normal', style: 'unstyled'}
];
/**
* Render block styling buttons
*/
const FormatStyleControls = (props) => {
const {editorState} = props;
const selection = editorState.getSelection();
const blockType = editorState
.getCurrentContent()
.getBlockForKey(selection.getStartKey())
.getType();
return (
<div className="simple-editor-controls">
{FORMAT_TYPES.map((type) =>
<StyleButton
key={type.label}
active={type.style === blockType}
label={type.label}
icon={type.icon}
onToggle={props.onToggle}
style={type.style}
/>
)}
{props.children}
</div>
);
};
export default FormatStyleControls;