Skip to content

Commit 37044f9

Browse files
committed
Merge branch 'master' into toolbar-plugin
2 parents 2d30962 + a0902f3 commit 37044f9

7 files changed

Lines changed: 183 additions & 268 deletions

File tree

packages/editor/src/components/CheckList.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

packages/editor/src/components/Editor.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ import theme from './theme'
1111

1212
import NodesPlugin from '../plugins/nodes'
1313
import MarksPlugin from '../plugins/marks'
14-
import ChecklistPlugin from '../plugins/checklist'
1514
import CodePlugin from '../plugins/code'
1615
import LiveJSXPlugin from '../plugins/live-jsx'
1716
import TablePlugin from '../plugins/table'
1817
import ImagePlugin from '../plugins/image'
1918
import LinkPlugin from '../plugins/link'
2019
import ToolbarPlugin from '../plugins/toolbar'
21-
import MarkdownShortcutsPlugin from '../plugins/markdown-shortcuts'
20+
import ListsPlugin from '../plugins/lists'
2221
import ThemeEditorPlugin from '../plugins/theme-editor'
22+
import MarkdownShortcutsPlugin from '../plugins/markdown-shortcuts'
2323

2424
const plugins = [
2525
NodesPlugin(),
2626
MarksPlugin(),
27-
ChecklistPlugin(),
2827
CodePlugin(),
2928
LiveJSXPlugin(),
3029
TablePlugin(),
3130
DeepTable(),
3231
ImagePlugin(),
3332
LinkPlugin(),
33+
ListsPlugin(),
3434
MarkdownShortcutsPlugin(),
3535
ToolbarPlugin(),
3636
ThemeEditorPlugin({ theme })

packages/editor/src/lib/mdx-serializer.js

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@ export const stringifyMDX = mdast =>
2626
const paragraph = {
2727
match: node => node.object === 'block' && node.type === 'paragraph',
2828
matchMdast: node => node.type === 'paragraph',
29-
fromMdast: (node, index, parent, { visitChildren }) => ({
30-
object: 'block',
31-
type: 'paragraph',
32-
nodes: visitChildren(node)
33-
}),
34-
toMdast: (object, index, parent, { visitChildren }) => ({
35-
type: 'paragraph',
36-
children: visitChildren(object)
37-
})
29+
fromMdast: (node, _index, _parent, { visitChildren }) => {
30+
return {
31+
object: 'block',
32+
type: 'paragraph',
33+
nodes: visitChildren(node)
34+
}
35+
},
36+
toMdast: (object, _index, _parent, { visitChildren }) => {
37+
return {
38+
type: 'paragraph',
39+
children: visitChildren(object)
40+
}
41+
}
3842
}
3943

4044
const image = {
@@ -75,6 +79,41 @@ const blockQuote = {
7579
})
7680
}
7781

82+
const bulletedList = {
83+
match: node => node.object === 'block' && node.type === 'bulleted-list',
84+
matchMdast: node => node.type === 'list' && !node.ordered,
85+
fromMdast: (node, _index, _parent, { visitChildren }) => ({
86+
object: 'block',
87+
type: 'bulleted-list',
88+
nodes: visitChildren(node)
89+
}),
90+
toMdast: (object, _index, _parent, { visitChildren }) => {
91+
return {
92+
type: 'list',
93+
ordered: false,
94+
children: visitChildren(object)
95+
}
96+
}
97+
}
98+
99+
const listItem = {
100+
match: node => node.object === 'block' && node.type === 'list-item',
101+
matchMdast: node => node.type === 'listItem',
102+
fromMdast: (node, index, parent, { visitChildren }) => {
103+
return {
104+
object: 'block',
105+
type: 'list-item',
106+
nodes: visitChildren(node)
107+
}
108+
},
109+
toMdast: (object, _index, _parent, { visitChildren }) => {
110+
return {
111+
type: 'listItem',
112+
children: visitChildren(object)
113+
}
114+
}
115+
}
116+
78117
const headings = [
79118
'heading-one',
80119
'heading-two',
@@ -111,10 +150,12 @@ const bold = {
111150
nodes: visitChildren(node)
112151
}
113152
},
114-
toMdast: (mark, index, parent, { visitChildren }) => ({
115-
type: 'strong',
116-
children: visitChildren(mark)
117-
})
153+
toMdast: (mark, index, parent, { visitChildren }) => {
154+
return {
155+
type: 'strong',
156+
children: visitChildren(mark)
157+
}
158+
}
118159
}
119160

120161
const codeBlock = {
@@ -288,6 +329,8 @@ export const serializer = new MarkdownSerializer({
288329
jsxBlock,
289330
codeBlock,
290331
image,
291-
link
332+
link,
333+
bulletedList,
334+
listItem
292335
].concat(headings)
293336
})

packages/editor/src/lib/slate-schema-to-mdx.js

Lines changed: 0 additions & 132 deletions
This file was deleted.

packages/editor/src/plugins/checklist.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)