Action
open tagged draft
Posted by FlohGro,
Last update
3 months ago
created by @FlohGro / more on my Blog
Easily open Drafts from a selected tag.
The Action displays a prompt with all your tags.
If you select a tag it will filter the drafts in your library and you can select the draft to open (if only one draft with that tag is found, it will be opened immediately).
If you find this useful and want to support me you can donate or buy me a coffee
Steps
-
script
// open tagged draft 1.0 // created by @FlohGro@social.lol let tags = Tag.query("").sort() // prompt to select tag scope / nest let p = new Prompt(); p.title = "select tag"; tags.map(t => { p.addButton(t) }); if (p.show()) { let selectedTag = p.buttonPressed; let foundDrafts = Draft.query("", "all", [selectedTag], [], "modified", true, true); let selectedDraft = selectDraft(foundDrafts) if (selectedDraft) { editor.load(selectedDraft) } else { app.displayInfoMessage("no draft selected") } } else { app.displayInfoMessage("no tag selected") } function selectDraft(draftsList) { if (draftsList.length == 1) { app.displayInfoMessage("open the only draft with the selected tag") return draftsList[0] } let p = new Prompt() p.title = "select draft" draftsList.map(d => { p.addButton((d.isFlagged ? "🚩 " : "") + d.displayTitle, d) }) if (p.show()) { return p.buttonPressed } else { return undefined } }
Options
-
After Success Nothing Notification Error Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.