Is your feature request related to a problem? Please describe.
Currently, the Quickadd API exposes the executeChoice method but it works only with existing QuickAdd Choices through plugin.getChoiceByName(choiceName). The shortcomings that I've encountered with this are;
MAJOR This doesn't allow for creating and executing a QuickAdd Choice dynamically through user scripts.
MAJOR The current implemantation of executeChoice doesn't allow access to dynamically vary the options in the QuickAdd Choice i.e Template Path, File Name Format and etc.
MINOR Having to first create a QuickAdd Choice before being able to utilise the executeChoice API, litters the QuickAdd Settings unnecessarily.
Describe the solution you'd like
Extend QuickAdd API with executeNewChoice, that takes three arguments; choiceType, choiceOptions and variables.
EXAMPLE USAGE
// Execute a template choice with custom options and variables
await quickAdd.executeNewChoice("Template",
{
templatePath: "/path/to/template.md",
fileNameFormat: { enabled: true, format: "YYYY-MM-DD" },
// ... other options
}, { variable1: "value1", variable2: "value2" });
Possible Implementation
executeNewChoice: async (
choiceType: <string>,
choiceOptions: Record<string, unknown>,
variables?: Record<string, unknown>
) => {
const choice: IChoice;
if(choiceType = "Template") choice = new TemplateChoice("Template Choice");
if(choiceType = "Capture") choice = new CaptureChoice("Capture Choice");
if (!choice) log.logError(`You left me with no choice.`);
Object.assign(choice, choiceOptions);
if (variables) {
Object.keys(variables).forEach((key) => {
choiceExecutor.variables.set(key, variables[key]);
});
}
await choiceExecutor.execute(choice);
choiceExecutor.variables.clear();
},
I suppose it's also possible to implement it as executeTemplateChoice and executeCaptureChoice.
Additional context
This enhancement would be particularly beneficial for users who want to leverage the QuickAdd functionality without the need for predefined QuickAdd Choice objects.
The ability to dynamically create QuickAdd Choices through the QuickAdd API seems so fundamental that I'm not sure if I'm missing something here.
Is your feature request related to a problem? Please describe.
Currently, the Quickadd API exposes the
executeChoice
method but it works only with existing QuickAdd Choices throughplugin.getChoiceByName(choiceName)
. The shortcomings that I've encountered with this are;executeChoice
doesn't allow access to dynamically vary the options in the QuickAdd Choice i.e Template Path, File Name Format and etc.executeChoice
API, litters the QuickAdd Settings unnecessarily.Describe the solution you'd like
Extend QuickAdd API with
executeNewChoice
, that takes three arguments;choiceType
,choiceOptions
andvariables
.EXAMPLE USAGE
Possible Implementation
I suppose it's also possible to implement it as
executeTemplateChoice
andexecuteCaptureChoice
.Additional context
This enhancement would be particularly beneficial for users who want to leverage the QuickAdd functionality without the need for predefined QuickAdd Choice objects.
The ability to dynamically create QuickAdd Choices through the QuickAdd API seems so fundamental that I'm not sure if I'm missing something here.