moved liftListItem and wrapInList methods in conditional block
this makes more sense because both functions are only called once and can't be chained as I initially thought.
This commit is contained in:
@@ -10,8 +10,6 @@ function isList(node, schema) {
|
|||||||
export default function toggleList(listType, itemType) {
|
export default function toggleList(listType, itemType) {
|
||||||
return (state, dispatch, view) => {
|
return (state, dispatch, view) => {
|
||||||
const { schema, selection } = state
|
const { schema, selection } = state
|
||||||
const lift = liftListItem(itemType)
|
|
||||||
const wrap = wrapInList(listType)
|
|
||||||
const { $from, $to } = selection
|
const { $from, $to } = selection
|
||||||
const range = $from.blockRange($to)
|
const range = $from.blockRange($to)
|
||||||
if (!range) {
|
if (!range) {
|
||||||
@@ -22,7 +20,7 @@ export default function toggleList(listType, itemType) {
|
|||||||
|
|
||||||
if (range.depth >= 1 && parentList) {
|
if (range.depth >= 1 && parentList) {
|
||||||
if (parentList.node.type === listType) {
|
if (parentList.node.type === listType) {
|
||||||
return lift(state, dispatch, view)
|
return liftListItem(itemType)(state, dispatch, view)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isList(parentList.node, schema)) {
|
if (isList(parentList.node, schema)) {
|
||||||
@@ -33,6 +31,6 @@ export default function toggleList(listType, itemType) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return wrap(state, dispatch, view)
|
return wrapInList(listType)(state, dispatch, view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user