Action
Send to DevonThink and 2Do
Export Draft to DevonThink as markdown and create any open tasks in a project in the 2Do Inbox
Steps
-
script
// See online documentation for examples // https://docs.getdrafts.com/docs/actions/scripting let clean_title = draft.processTemplate("[[safe_title]]"); var tasks = ""; let indent_level = 0; let task_indentifier = '- [ ]'; let action = "url:drafts://open?uuid=" + draft.uuid; function gatherTasks(line, index) { if (line.startsWith(task_indentifier)) { tasks += line.replace(task_indentifier, '').trim() + "\n"; } } draft.content.split("\n").forEach(gatherTasks); draft.setTemplateTag("tasks", tasks.trim()); draft.setTemplateTag("cleanedtitle", clean_title); // Create project in 2Do if (tasks.length) { var cb = CallbackURL.create(); cb.baseURL = "twodo://x-callback-url/add" cb.addParameter("task", clean_title); cb.addParameter("type", 1); cb.addParameter("forlist", "Inbox"); cb.addParameter("subtasks", tasks); cb.addParameter("action", action); var success = cb.open(); if (success) { console.log("Project created in 2Do"); } else { context.fail(); } } // URL action to follow script: // // x-devonthink://createmarkdown?title=[[cleanedtitle]]&text=[[draft]]&tags=[[tags]]
-
url
template x-devonthink://createmarkdown?title=[[cleanedtitle]]&text=[[draft]]&tags=[[tags]]
useSafari false
encodeTags true
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.