Drafts Action Directory

Move Completed Tasks

Posted by @nahumck, Last update 5 months ago

Move lines containing a completed markdown task (“- [x]”) to the bottom of the current draft.

Install

Steps

  • script

    // Move lines containing a completed markdown task (“- [x]”) to the bottom of the current draft.
    
    var lines = draft.content.split("\n");
    var begin = '';
    var end = '';
    var c ="- [x]";
    
    for (var line of lines) {
      //if line contains "- [x]"… 
      if (line.includes(c)) {
      //add it to var end
        end += line + "\n";
      }
      else {
        begin += line + "\n";
      }
    }
    begin = begin.slice(0,-1);
    end = end.slice(0,-1);
    editor.setText(begin + "\n" + end);
    draft.update;
    editor.focus(draft);

Options

  • After Success Default
    Notification Error
    Log Level Error

Comments

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