Drafts Action Directory

clear tasks

Posted by dchar, Last update 3 months ago

This action clears all completed Markdown tasks.

it’s useful if you want to start over or reuse a task list.

Install

Steps

  • script

    // clear todos
    
    (() => {
    
        const hasSelection = () => editor.getSelectedRange()[1] > 0;
      
        const getText = () => {
          const e = editor;
          return hasSelection() ? 
            e.getTextInRange(...e.getSelectedLineRange()) :
            e.getText();
        };
      
        const setText = (t) => {
          const e = editor;
          if (hasSelection()) {
            const sel = e.getSelectedLineRange();
            e.setTextInRange(...sel, t);
            e.setSelectedRange(sel[0], t.length);
          } else {
            e.setText(t);
          }
        };
      
        let re = /\[x\]/gi;
        let s = getText().replace(re, '[ ]');
        setText(s);
      
      })();

Options

  • After Success Default
    Notification Info
    Log Level Info

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.