I think I figured it out.
I used this thread to work out which parts to edit from the “New Draft from Template” action - Using prompt results in New Draft with Template
After looking at that, I commented (added “//“ before each like) out the code to be disabled like that person suggested. The script now looks like the below. I’m sure this looks terrible to anyone with experience, but I’m pleased it’s working! I guess I can now delete all the commented code.
Here’s the script:
//modified from New Draft with Template Action
// defaults
let omitFirstLineDefault = false;
// select from a list of drafts tagged “template” and create new draft based on selection.
let f = () => {
// create temp workspace to query drafts
// let workspace = Workspace.create();
// if (!workspace) {
// return false;
// }
// workspace.tagFilter = “template”;
// workspace.setAllSort(“name”, false, true);
// get list of drafts in workspace
// let drafts = workspace.query(“all”);
// check if we found any valid templates
// if (drafts.length == 0) {
// alert(“No templates found. To make templates available to this action, create a draft with the template content and assign it the tag “template”.”);
// return false;
// }
// prompt to select
// let p = Prompt.create();
// p.title = “New Draft with Template”;
// p.message = “Select a template. A new draft will be created based the template selected.”;
// p.addSwitch(“omitTitle”, “Omit First Line in New Draft”, omitFirstLineDefault);
// let ix = 0
// for (let d of drafts) {
// p.addButton(d.displayTitle, ix);
// ix++;
// }
// if (!p.show()) {
// return false;
// }
// get the selected template draft
// let selectedIndex = p.buttonPressed;
// Add the UUID of the Draft to the brackets after Drafts.find
let template = Draft.find('Inserted the UUID here');
let content = template.content;
// let omitTitle = omitFirstLineDefault;
// if (omitTitle) {
// let lines = content.split(’\n’);
// if (lines.length > 0) {
// lines.shift();
// content = lines.join(’\n’).replace(/^\s+/,"");
// }
// }
// create new draft and assign content/tags/syntax
let d = Draft.create();
for (let tag of template.tags) {
if (tag != "template") {
d.addTag(tag);
}
}
d.languageGrammar = template.languageGrammar;
d.content = d.processTemplate(content);
d.update();
// load new draft
editor.load(d);
editor.activate();
// look for <|> to set cursor location
let loc = d.content.search("<|>");
// if (p != -1) {
editor.setText(editor.getText().replace("<|>", “”));
editor.setSelectedRange(loc, 0);
// }
return true;
}
if (app.isPro) {
if (!f()) {
context.cancel();
}
}
else {
alert(“Drafts Pro features required to use this action.”)
}