Action
Things & Bear
This action takes all of the incompleted tasks in a Draft, and adds them to Things:
- [ ] task 1
- [ ] task 2
- [x] task 3
Task1 and task2 would be added here.
These are then grouped at the bottom of the note, and the whole note is added to Bear.
Steps
-
script
// check to see if draft is blank var content = editor.getText(); var check = content.length; var taskList = ""; if (content.length == 0) { alert("Draft is blank"); context.cancel("Draft was blank"); } // Call API for each line in a draft // split draft and loop over lines var lines = content.split("\n"); var thingsTask = Array(); for (var line of lines) { if (line.startsWith("- [ ]")) { task = line.replace("- [ ]", "").trim(); temp = TJSTodo.create(); temp.title = task; thingsTask.push(temp); taskList += task + "\n"; content = content.replace(line + "\n", ""); } } if (thingsTask.length) { var container = TJSContainer.create(thingsTask); var cb = CallbackURL.create(); cb.baseURL = container.url; var success = cb.open(); if (success) { console.log("Tasks created in Things"); content = content + "\n\nTasks collected:\n" + taskList; editor.setText(content); } else { context.fail(); } }
-
callbackUrl
template bear://x-callback-url/create?text=[[draft]]
waitForResponse true
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.