Clearing all checklists from the current page.

I love checklists, so one feature I wanted is the ability to "clear all" the check boxes with one button.

Here's a short snippet that basically modifies the current page text to accomplish that:

chklist = chklist or {}

function chklist.clear_checklists()
  return widget.html(dom.button {
    "Clear Checklists",
    class = "clear-checklists-button",
    onclick = function()
      local text = editor.getText()
      local newText = string.gsub(text, "%[[xX]%]", "[ ]")
      editor.setText(newText)
    end,
  })
end

Then, just place the button anywhere in your checklist page (${chklist.clear_checklists()}) and you're done!

I did try to modify this to change the attribute directly for tasks with custom task states, but didn't get very far. If that's actually possible, let me know!

This also comes built in: Task: Remove Completed

Remove completed will just remove the item though, this will keep the item but "uncheck" the task.
I mainly wrote this since I have things like packing lists or procedures that I reuse, but can't be bothered to individually uncheck each box.

Ah sorry! Yes different thing :+1: