Action
Select Back Links
Navigate to drafts with link to the current draft via [[Title of Draft]]
style links.
If only one draft with links to the current draft is found, navigate directly to that draft - if more than one is found, offer selection prompt to choose which to open.
Steps
-
script
let open = (d) => { editor.load(d); } let f = () => { let title = draft.displayTitle; if (title.length == 0) { return; } // query for other drafts with the link to this one... let pattern = `"[[${title}]]"`; let drafts = Draft.query(pattern, "all", [], [], "modified", true); // didn't find any! if (drafts.length == 0) { app.displayWarningMessage("No linked drafts found."); return; } // found just 1, open it if (drafts.length == 1) { open(drafts[0]); return; } // more than one, allow use to choose... let p = Prompt.create(); p.title = "Select Draft"; p.message = "The following drafts link to this draft. Select one to open it."; let map = {}; for (let d of drafts) { let title = d.title; map[title] = d; p.addButton(title); } if (!p.show()) { return; } // picked one, load it in the editor let selected = map[p.buttonPressed]; open(selected); } f();
Options
-
After Success Nothing Notification None Log Level None
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.