Action

Quick Access

Posted by FlohGro, Last update 11 months ago

created by @FlohGro / more on my Blog

Quick Access

This Action is used to quickly access drafts with one or more specific tags.
By default it filters for the tag bookmark and displays a prompt if more than one drafts with that tag(s) is found.
When a draft is selected, it will be loaded into the editor.
If only one single draft with the specified tag(s) is found, it will directly be loaded and no prompt will be displayed

[Configuration]

You can change the tag that the action should use by editing the Define Template Tag step. Change bookmark to the tag you want to use. If you want to search for multiple tags, you have to separate them with a comma (e.g. bookmark,favorite)

[Usage]

use this action to quickly access drafts you often want to open by giving them a specific tag.
You can also duplicate this action and use it with different tags in each version.


If you find this useful and want to support me you can donate or buy me a coffe

Buy Me A Coffee

Steps

  • defineTemplateTag

    name
    tag-to-use
    template
    bookmark, favorite
  • script

    // quick open draft with tag
    
    let tagsToUse = draft.processTemplate("[[tag-to-use]]").split(",")
    tagsToUse = tagsToUse.map((tag) => {return tag.trim()})
    
    let foundDrafts = Draft.query("","all",tagsToUse,[],"accessed", true, false)
    
    if(foundDrafts.length > 0){
    if(foundDrafts.length == 1){
    editor.load(foundDrafts[0])
    app.displayInfoMessage("loaded the only draft with tag(s) \"" + tagsToUse.join(", ") + "\"")
    } else {
    let p = new Prompt()
    p.title = "select draft"
    for(let d of foundDrafts){
    p.addButton(d.displayTitle,d)
    }
    if(p.show()){
    editor.load(p.buttonPressed)
    } else {
    app.displayInfoMessage("no draft selected")
    }
    
    }
    } else {
        app.displayInfoMessage("no drafts found with tag(s) \"" + tagsToUse.join(", ") + "\"")
    }

Options

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