Drafts help: extract actions from meeting note

Hi all!

I’d like to create a Drafts action that pulls out all of the actions from a note (starting with - [ ]) and then paste them at the bottom, under a header called Actions.

Is this possible? If so, how would you do it?

Example:

Meeting A

Notes 1

  • [ ] Action 1
  • [ ] Action 2

Notes 2

  • [ ] Action 3

Actions

  • Action 1
  • Action 2
  • Action 3

Thanks!

This action is a good start:

I just need copy instead of cut and paste, and then change the “- [ ]” to just “-“ so it doesn’t get picked up as a duplicate task.

If you’re wondering what the point is, I’d like to be able to share actions with other people, without having to type into a dedicated Action section of the note (as the notes around it may give context to the action)

Okay, I’ll take a shot at this, but someone is going to have to correct my mangling of this code.

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

var text = editor.getText();
var lines = text.split("\n");
// var begin = ''; don't need this
var end = ''; 
var c ="- [ ]";

for (var line of lines) {
  //if line contains "- [x]"… 
  if (line.includes(c)) {
  //add it to var end
    end += line.replace("- [ ] ","") + "\n";
  }
}
// begin = begin.slice(0,-1);
end = end.slice(0,-1);
editor.setText(begin + "\n" + "# Actions\n" + end);

Thanks @oldblueday !

It doesn’t work because you commented out the begin variable but it is required at the end.

I’ve uncommented it, but the result is all text except the actions are deleted, and it looks like carriage returns are removed too as everything is on one line.

Sorry, what if we try this. I changed the “begin” at the end to be “text.”

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

var text = editor.getText();
var lines = text.split("\n");
// var begin = ''; don't need this
var end = ''; 
var c ="- [ ]";

for (var line of lines) {
  //if line contains "- [ ]"… 
  if (line.includes(c)) {
  //add it to var end
    end += line.replace("- [ ] ","- ") + "\n";
  }
}
// begin = begin.slice(0,-1);
end = end.slice(0,-1);
editor.setText(text + "\n" + "# Actions\n" + end);
1 Like

This works perfectly! Thanks so much :pray::pray:

1 Like