Action
Move Tasks to Things
Send text on selected lines to Things as new tasks in the Inbox, removing the lines from draft. I use to this migrate tasks I created in Drafts to Things for further processing.
If there is no text selection, the current line is moved to Things. If multiple lines are selected, they are all moved as individual tasks.
Steps
-
script
// CONFIGURE const list = "Inbox" // get information const [st,len] = editor.getSelectedLineRange() let selectedText = editor.getTextInRange(st, len) let lines = selectedText.split("\n") let todos = [] // loop over lines, adding non-blank lines as todos // also clean up line, removing any list/task prefix for (line of lines) { let trimmedLine = line.trim() // remove whitespace trimmedLine = trimmedLine.replace(/^[-\* \[\]x]+/, "") if (trimmedLine.length == 0) { // skip blank lines continue } let todo = TJSTodo.create() todo.title = trimmedLine todo.list = list todos.push(todo) } if (todos.length > 0) { // create Things object to create URL const container = TJSContainer.create(todos) var cb = CallbackURL.create() cb.baseURL = container.url if (cb.open()) { console.log("Todos created in Things") editor.setTextInRange(st, len, "") editor.setSelectedRange(st, 0) } else { console.fail() } } else { // no todos to create alert("No todos found") context.fail() }
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.