From a6baa66e89954fa6f4cf1a71b4c98c8de6ed611d Mon Sep 17 00:00:00 2001 From: Chrissi2812 Date: Mon, 20 May 2019 14:54:25 +0200 Subject: [PATCH] fixed todo_lists in toggleList method --- .../tiptap-commands/src/commands/toggleList.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/tiptap-commands/src/commands/toggleList.js b/packages/tiptap-commands/src/commands/toggleList.js index 23529fdf..587644c9 100644 --- a/packages/tiptap-commands/src/commands/toggleList.js +++ b/packages/tiptap-commands/src/commands/toggleList.js @@ -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) } }