Action

clear tasks

Posted by dchar, Last update over 6 years ago

This action clears all completed Markdown tasks.

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

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
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.