@@ -8,16 +8,39 @@ import ItalicIcon from '@material-ui/icons/FormatItalic'
88import LinkIcon from '@material-ui/icons/InsertLink'
99import ImageIcon from '@material-ui/icons/InsertPhoto'
1010import QuoteIcon from '@material-ui/icons/FormatQuote'
11+ import CodeIcon from '@material-ui/icons/Code'
1112// import ListIcon from '@material-ui/icons/FormatListBulleted'
1213// import StrikethroughIcon from '@material-ui/icons/StrikethroughS'
1314// import HeadingIcon from '@material-ui/icons/Title'
14- // import CodeIcon from '@material-ui/icons/Code'
1515// import NumberedListIcon from '@material-ui/icons/FormatListNumbered'
1616// import ColorIcon from '@material-ui/icons/FormatColorText'
1717// import BackgroundColorIcon from '@material-ui/icons/FormatColorFill'
1818
19- const H1 = ( ) => < b > H1</ b >
20- const H2 = ( ) => < b > H2</ b >
19+ // "icons"
20+ const B = props => (
21+ < b
22+ { ...props }
23+ css = { {
24+ paddingLeft : 2 ,
25+ paddingRight : 2 ,
26+ borderRadius : 2
27+ } }
28+ />
29+ )
30+ const H1 = ( ) => < B > H1</ B >
31+ const H2 = ( ) => < B > H2</ B >
32+ const JSX = ( ) => < B > JSX</ B >
33+
34+ const Separator = ( ) => (
35+ < div
36+ css = { css ( {
37+ width : '1px' ,
38+ mx : 2 ,
39+ height : 24 ,
40+ bg : 'gray'
41+ } ) }
42+ />
43+ )
2144
2245const Root = props => (
2346 < div
@@ -44,7 +67,7 @@ const IconButton = ({ active, ...props }) => (
4467 { ...props }
4568 css = { css ( {
4669 display : 'block' ,
47- width : 32 ,
70+ minWidth : 32 ,
4871 height : 32 ,
4972 padding : 1 ,
5073 fontSize : 16 ,
@@ -73,46 +96,60 @@ const isActive = type => editor => {
7396// config
7497const buttons = [
7598 {
76- title : 'Toggle Bold' ,
99+ title : 'Toggle Bold (⌘ B) ' ,
77100 Icon : BoldIcon ,
78101 command : 'toggleBold' ,
79102 isActive : isActive ( 'bold' )
80103 } ,
81104 {
82- title : 'Toggle Italic' ,
105+ title : 'Toggle Italic (⌘ I) ' ,
83106 Icon : ItalicIcon ,
84107 command : 'toggleItalic' ,
85108 isActive : isActive ( 'italic' )
86109 } ,
87110 {
88- title : 'Toggle Heading Level 1' ,
111+ title : 'Toggle Heading Level 1 (⌘ ⌥ 1) ' ,
89112 Icon : H1 ,
90113 command : 'toggleHeadingOne' ,
91114 isActive : isActive ( 'heading-one' )
92115 } ,
93116 {
94- title : 'Toggle Heading Level 2' ,
117+ title : 'Toggle Heading Level 2 (⌘ ⌥ 2) ' ,
95118 Icon : H2 ,
96119 command : 'toggleHeadingTwo' ,
97120 isActive : isActive ( 'heading-two' )
98121 } ,
99122 {
100- title : 'Toggle Block Quote' ,
123+ title : 'Toggle Block Quote (⌃ ⌥ Q) ' ,
101124 Icon : QuoteIcon ,
102125 command : 'toggleBlockQuote' ,
103126 isActive : isActive ( 'block-quote' )
104127 } ,
105128 {
106- title : 'Insert Link' ,
129+ title : 'Toggle Code Block' ,
130+ Icon : CodeIcon ,
131+ command : 'togglePre' ,
132+ isActive : isActive ( 'pre' )
133+ } ,
134+ { separator : true } ,
135+ {
136+ title : 'Insert Link (⌘ K)' ,
107137 Icon : LinkIcon ,
108138 command : 'toggleLink' ,
109139 isActive : isActive ( 'link' )
110140 } ,
111141 {
112- title : 'Insert Image' ,
142+ title : 'Insert Image (⌘ ⇧ I) ' ,
113143 Icon : ImageIcon ,
114144 command : 'insertImage' ,
115145 isActive : isActive ( 'image' )
146+ } ,
147+ { separator : true } ,
148+ {
149+ title : 'Insert JSX Block' ,
150+ Icon : JSX ,
151+ command : 'toggleJSX' ,
152+ isActive : isActive ( 'jsx' )
116153 }
117154]
118155
@@ -121,16 +158,20 @@ export const Toolbar = props => {
121158
122159 return (
123160 < Root >
124- { buttons . map ( ( { Icon, title, command, isActive } , i ) => (
125- < IconButton
126- key = { i }
127- title = { title }
128- active = { isActive ( editor ) }
129- onClick = { editor [ command ] }
130- >
131- < Icon size = { 20 } />
132- </ IconButton >
133- ) ) }
161+ { buttons . map ( ( { separator, Icon, title, command, isActive } , i ) =>
162+ separator ? (
163+ < Separator key = { i } />
164+ ) : (
165+ < IconButton
166+ key = { i }
167+ title = { title }
168+ active = { isActive ( editor ) }
169+ onClick = { editor [ command ] }
170+ >
171+ < Icon size = { 20 } />
172+ </ IconButton >
173+ )
174+ ) }
134175 </ Root >
135176 )
136177}
0 commit comments