Thanks for the multi-select code snippet. Very helpful. I made some small modifications: response values can differ from suggestions, and selected items can be deselected. Here’s the code, maybe somebody will find it useful.
In my case the js code is executed by the Templater plugin, but of course it can equally be used with quickadd.
<%*
// Configuration start
let suggestions = new Array ("Mb", "Test1", "Test2", "Done");
let values = new Array ("[[Information/9 Meta/habits/mb|Mb]]", "Value1", "Value2", "Done");
const question = "Your tags for today?";
const checkMark = "✅ ";
// Configuration end
const config = {
"suggestions": suggestions,
"values": values,
"responses": []
};
let response;
while (response !== "Done") {
response = await tp.system.suggester(config.suggestions, config.values, true, question);
if (response !== "Done") {
let rIndex = config.responses.indexOf(response);
if (rIndex > -1) {
config.responses.splice(rIndex, 1);
} else {
config.responses.push(response);
}
let vIndex = config.values.indexOf(response);
let suggestion = config.suggestions[vIndex];
if (suggestion.startsWith(checkMark)) {
config.suggestions[vIndex] = suggestion.replace(checkMark,"");
} else {
config.suggestions[vIndex] = checkMark + suggestion;
}
}
}
// console.log(config);
let result = config.responses.join(", ");
return result
_%>