Action
@due(date)
Insert a “@due(date)”, where date is selected via a date prompt. If text is selected, wrap the selection in “@due(selection)”
Steps
-
script
// Insert @due(date) var d = new Date(); // Insert @due tag for use with taskpaper // If no text is selected, inserts the "@due()" tag and prompts for a date to insert between the parentheses. // If text is selected, inserts the "@due()" tag with the selected text inbetween the parentheses. var sel = editor.getSelectedText(); var selRange = editor.getSelectedRange(); if (!sel || sel.length == 0) { // Prompt for date var p = Prompt.create(); p.title = "Pick a due date"; p.addDatePicker("date", "Date", d, {"mode": "date"}); p.addButton("OK"); if (p.show()) { var s = p.fieldValues["date"]; s = s.toString("yyyy-MM-dd") var e = "@due("+s+")"; editor.setSelectedText(e); editor.setSelectedRange(selRange[0]+e.length,0); editor.focus(); } else { context.cancel(); } } else { editor.setSelectedText("@due("+sel+")"); editor.setSelectedRange(selRange[0]+sel.length+6,0); editor.focus(); }
Options
-
After Success Default Notification Error Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.