File tree Expand file tree Collapse file tree
packages/editor/src/plugins/toolbar Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import ImageIcon from '@material-ui/icons/InsertPhoto'
1010import QuoteIcon from '@material-ui/icons/FormatQuote'
1111import CodeIcon from '@material-ui/icons/Code'
1212import VideoIcon from '@material-ui/icons/Slideshow'
13+ import ListIcon from '@material-ui/icons/List'
1314// import ListIcon from '@material-ui/icons/FormatListBulleted'
1415// import StrikethroughIcon from '@material-ui/icons/StrikethroughS'
1516// import HeadingIcon from '@material-ui/icons/Title'
@@ -146,6 +147,12 @@ const buttons = [
146147 isActive : isActive ( 'image' )
147148 } ,
148149 { separator : true } ,
150+ {
151+ title : 'Insert Bulleted List' ,
152+ Icon : ListIcon ,
153+ command : 'toggleBulletedList' ,
154+ isActive : isActive ( 'list-item' )
155+ } ,
149156 {
150157 title : 'Insert JSX Block' ,
151158 Icon : JSX ,
Original file line number Diff line number Diff line change @@ -20,6 +20,20 @@ const hasBlock = (editor, type) => {
2020 return editor . value . blocks . some ( node => node . type === type )
2121}
2222
23+ const toggleBulletedList = editor => {
24+ const {
25+ value : { startBlock, document }
26+ } = editor
27+ const parent = document . getParent ( startBlock . key )
28+
29+ const isList =
30+ parent && ( parent . type === 'list-item-child' || parent . type === 'list-item' )
31+
32+ return isList
33+ ? editor . unwrapList ( )
34+ : editor . wrapList ( { type : 'bulleted-list' } )
35+ }
36+
2337const toggleBlock = ( editor , type ) => {
2438 if ( editor . hasBlock ( type ) ) {
2539 editor . setBlocks ( DEFAULT_BLOCK )
@@ -69,6 +83,7 @@ export default (opts = {}) => ({
6983 toggleBlockQuote,
7084 toggleHeadingOne,
7185 toggleHeadingTwo,
86+ toggleBulletedList,
7287 toggleJSX,
7388 togglePre
7489 } ,
You can’t perform that action at this time.
0 commit comments