fixed todo_lists in toggleList method

This commit is contained in:
Chrissi2812
2019-05-20 14:54:25 +02:00
parent 6cb1c0436b
commit a6baa66e89

View File

@@ -2,13 +2,15 @@ import { wrapInList, liftListItem } from 'prosemirror-schema-list'
import { findParentNode } from 'prosemirror-utils'
function isList(node, schema) {
return (node.type === schema.nodes.bullet_list || node.type === schema.nodes.ordered_list)
return (node.type === schema.nodes.bullet_list
|| node.type === schema.nodes.ordered_list
|| node.type === schema.nodes.todo_list)
}
export default function toggleList(listType) {
return (state, dispatch) => {
export default function toggleList(listType, itemType) {
return (state, dispatch, view) => {
const { schema, selection } = state
const lift = liftListItem(schema.nodes.list_item)
const lift = liftListItem(itemType)
const wrap = wrapInList(listType)
const { $from, $to } = selection
const range = $from.blockRange($to)
@@ -20,7 +22,7 @@ export default function toggleList(listType) {
if (range.depth >= 1 && parentList) {
if (parentList.node.type === listType) {
return lift(state, dispatch)
return lift(state, dispatch, view)
}
if (isList(parentList.node, schema)) {
@@ -31,6 +33,6 @@ export default function toggleList(listType) {
}
}
return wrap(state, dispatch)
return wrap(state, dispatch, view)
}
}