Action That Copies and Deletes the First Line of Text in a Draft

Hi all,
I am a relatively new Drafts user and I have minimal coding experience and no JavaScript experience. I have a personal workflow where I regurgitate thoughts with one thought per line. I then want to take each line and put do different things with it e.g. create a trello card, add a task to MS to do, insert a note to Evernote. To accomplish this, I am building an action that will copy and remove the first line of text from a draft to the clipboard. How would I do that?

This, from the action directory, may get you somewhere close to where you want to be. Admittedly, not exactly as specified.

This script would do what you describe:

let lines = draft.content.split("\n"); // split into lines
app.setClipboard(lines[0]); // put first line in clipboard
lines.shift(); // array function to remove first line
draft.content = lines.join("\n"); // put remaining lines back together
draft.update(); // save changes to draft.

Hope this helps!

1 Like