add list and code toolbar buttons

This commit is contained in:
Shawn Erquhart 2017-07-09 00:17:10 -04:00
parent ae56ef6dda
commit 24caeadfa4
2 changed files with 13 additions and 5 deletions

View File

@ -57,10 +57,14 @@ export default class Toolbar extends React.Component {
const { activePlugin } = this.state;
const buttonsConfig = [
{ label: 'Header 1', icon: 'h1', state: buttons.h1 },
{ label: 'Header 2', icon: 'h2', state: buttons.h2 },
{ label: 'Bold', icon: 'bold', state: buttons.bold },
{ label: 'Italic', icon: 'italic', state: buttons.italic },
{ label: 'Code', icon: 'code-alt', state: buttons.code },
{ label: 'Header 1', icon: 'h1', state: buttons.h1 },
{ label: 'Header 2', icon: 'h2', state: buttons.h2 },
{ label: 'Bullet List', icon: 'list-bullet', state: buttons.list },
{ label: 'Numbered List', icon: 'list-numbered', state: buttons.listNumbered },
{ label: 'Code Block', icon: 'code', state: buttons.codeBlock },
{ label: 'Link', icon: 'link', state: buttons.link },
];

View File

@ -242,7 +242,7 @@ const RULES = [
},
{
serialize(entity, children) {
if (!['bulleted-list', 'unordered-list'].includes(entity.type)) {
if (!['bulleted-list', 'numbered-list'].includes(entity.type)) {
return;
}
return NODE_COMPONENTS[entity.type]({ children });
@ -455,11 +455,15 @@ export default class Editor extends Component {
<Toolbar
selectionPosition={selectionPosition}
buttons={{
h1: this.getButtonProps('heading-one', true),
h2: this.getButtonProps('heading-two', true),
bold: this.getButtonProps('bold'),
italic: this.getButtonProps('italic'),
code: this.getButtonProps('code'),
link: this.getButtonProps('link'),
h1: this.getButtonProps('heading-one', true),
h2: this.getButtonProps('heading-two', true),
list: this.getButtonProps('bulleted-list', true),
listNumbered: this.getButtonProps('numbered-list', true),
codeBlock: this.getButtonProps('code', true),
}}
onToggleMode={this.handleToggle}
plugins={plugins}