Quickly Edit Checkbox Types (SLRvb Checkboxes)

Language:: Plugin - Templater
Program:: Obsidian
Link::

Summary

Use this script to select and update checkbox types, ie change a regular - [ ] into - [i] for an "Idea" type. Use hotkey opt + shift + t to trigger.opt + shift + t` to trigger.

Code

<%*
const slrvbCheckboxes = [[
"Unchecked",
"Regular", 
"Checked", 
"Dropped", 
"Forward", 
"Defer", 
"Question", 
"Half Done", 
"Add", 
"Research", 
"Important", 
"Idea", 
"Brainstorm", 
"Pro", 
"Con", 
"Quote", 
"Note", 
"Bookmark", 
"Information"
], [
" ",
"x", 
"X", 
"-", 
">", 
"D", 
"?", 
"/", 
"+", 
"R", 
"!", 
"i", 
"B", 
"P", 
"C", 
"Q", 
"N", 
"b", 
"I"
]];

const sanctumCheckboxes = [[
"Unchecked",
"Star",
"Alarm / Reminder / Notification",
"Favourite",
"Savings / Piggy bank",
"Savings alternative / Piggy bank",
"Cancelled",
"Rescheduled / Forwarded",
"Scheduled",
"Location",
"Bug / Debug",
"Failure",
"Note / Annotation",
"Pros",
"Cons",
"Win / Success / Reward",
"Bookmark / References",
"Idea / Tip",
"Important / Attention",
"Question / Cue",
"Info"
], [
" ",
"โญ",
"a",
"โค",
"s",
"S",
"-",
">",
"<",
"l",
"B",
"X",
"n",
"p",
"c",
"W",
"b",
"I",
"!",
"?",
"i"
]];

const selection = tp.file.selection();
const checkboxType = slrvbCheckboxes; //Change this
const check = await tp.system.suggester(checkboxType[0], checkboxType[1], true);

//Check Replacement
if (selection) {
    const replace = selection.split("\n").map(select => {
    if (select.match(/- \[.\]/)) {
        select = select.replace(/\[.\]/, `[${check}]`);
    }
    return select;
    }).join("\n");
    tR += replace;
} else {
    new Notice("Text must be selected");
};

%>

Explanation

  1. Select a line if a task
  2. I use a hotkey to trigger the template Task Changer with it selected

Additionally

Use this code to get these custom checkboxes

TASK 
FROM #log  
WHERE contains(status, "i")

Result

Obsidian_NVA9eSfNIr.gif
Obsidian_GRw3CAvq99.gif---
up:: ๐Ÿงช Code Diary