Move sub-done todos to done
This commit is contained in:
parent
6f98a458b5
commit
527ecf6146
|
|
@ -130,10 +130,9 @@ const moveToDone = (view: EditorView) => {
|
|||
const doneTodos: Todo[] = []
|
||||
todoList.forEach((header) => {
|
||||
header.todos = header.todos.filter((todo) => {
|
||||
if (typeof todo === "string" || !todo.done) return true
|
||||
|
||||
doneTodos.push(todo)
|
||||
return false
|
||||
if (typeof todo === "string") return true
|
||||
doneTodos.push(...collectDoneTodos(todo))
|
||||
return !todo.done
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -147,6 +146,24 @@ const moveToDone = (view: EditorView) => {
|
|||
})
|
||||
}
|
||||
|
||||
const collectDoneTodos = (todo: Todo | string): Todo[] => {
|
||||
if (typeof todo === "string") return []
|
||||
|
||||
const doneTodos: Todo[] = []
|
||||
if (todo.done) {
|
||||
todo.indent = ""
|
||||
doneTodos.push(todo)
|
||||
} else {
|
||||
todo.children = todo.children.filter((child) => {
|
||||
if (typeof child === "string") return true
|
||||
doneTodos.push(...collectDoneTodos(child))
|
||||
return !child.done
|
||||
})
|
||||
}
|
||||
|
||||
return doneTodos
|
||||
}
|
||||
|
||||
const toggleDone = (view: EditorView) => {
|
||||
const { state } = view
|
||||
const { head } = state.selection.main
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user