Action

Open Draft from selected Task

Posted by FlohGro, Last update over 1 year ago - Unlisted

created by @FlohGro / more on my Blog

Open Draft from selected Task

Action searches tasks (lines with „-[ ]“) in all drafts and shows all of them in a prompt.
When a task is selected, the action will open the draft of the selected task

[Configuration]

You can add tags to omit in the search by adding each tag to exclude as string to the array at the beginning of the script


If you find this useful and want to support me you can

Buy Me A Coffee

Steps

  • script

    // open draft from selecte md task
    
    let excludeTags = []
    let drafts = Draft.query(" [ ] ","all",[],excludeTags,"modified",false,true)
    let ds = []
    let tasks = []
    let massivePrompt = new Prompt()
    for(d of drafts){
    	let curTasks = []
       let lines = d.content.split("\n")
    	for(line of lines){
    		if(line.includes("[ ]")){
    			curTasks.push(line)
    		}
    	}
    	if(curTasks.length>0){
    		tasks.push(d.title)
    		//massivePrompt.addButton(d.title,d)
    		tasks = tasks.concat(curTasks)
    		for(task of curTasks){
    			massivePrompt.addButton(task.replace("- [ ]", ""),d)
    		}
    	}
    }
    //alert(ds.join("\n"))
    //alert(tasks.length + "\n" + tasks.join("\n"))
    if(massivePrompt.show()){
    	editor.load(massivePrompt.buttonPressed)
    }
    

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.