Action

Move Tasks to Reminders

Posted by agiletortoise, Last update about 1 month ago

Move the current line, or selected lines to Appleā€™s Reminders as tasks. If the lines have Markdown list or [ ] task prefixes, they will be stripped out.

The lines will be removed from the current draft.

Steps

  • script

    // setup values
    const list = ReminderList.default() 
    const listPrefixRegex = /^([-\*])? ?([\[\{][\s\-x])?([\]\}]\s)?/
    
    function getLines() {
    	const [st,len] = editor.getSelectedLineRange()
    	let s = editor.getTextInRange(st, len)
    	return s.split("\n").map(ln => ln.replace(listPrefixRegex, "").trim()).filter(ln => ln.length > 0)
    }
    
    function removeLines() {
    	const [st,len] = editor.getSelectedLineRange()
    	editor.setTextInRange(st, len, "")
    	editor.setSelectedRange(st, 0)
    }
    
    const lines = getLines() 
    if (lines.length > 0) {
    	for (let ln of lines) {
    		let reminder = list.createReminder()
    	 	reminder.title = ln
    		reminder.update()
    	}
    	removeLines()
    }
    else {
    	context.fail()
    }
    

Options

  • After Success Nothing
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.