Task Toggler Action

Lately I’ve been creating a lot of checklists or just notes with tasks within Drafts. I used an action that allows to toggle the states of these tasks in the selected range (either the line where the cursor is located or multiple selected lines). This worked but was not fitting my use cases. I also wanted the possibility to make a task out of a bullet point or a line with just text in it without creating another action that I need to trigger separately.

Of course I sat down and it took me embarrassingly long to script a (so far) perfectly working action for me. Using md task toggler I only need to press one keyboard shortcut (or icon in the ActionBar) to toggle the state of the tasks in the selected range or add checkboxes to lines where they are missing.
Of course the indentation of lines remains unchanged.