Skip to content

Commit 4accce3

Browse files
committed
Merge branch 'master' into jsx-block-parsing
2 parents 68f4090 + 3186d89 commit 4accce3

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

packages/editor/src/plugins/toolbar/Toolbar.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import ImageIcon from '@material-ui/icons/InsertPhoto'
1010
import QuoteIcon from '@material-ui/icons/FormatQuote'
1111
import CodeIcon from '@material-ui/icons/Code'
1212
import 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,

packages/editor/src/plugins/toolbar/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
2337
const 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
},

0 commit comments

Comments
 (0)