Insert callout by type

Use case or problem

Remember all the available callout types.

Proposed solution

Include an additional level at the top menu bar under Insert/Callout (like Folding has), where the available callout types are listed and can be directly inserted.

Related feature requests

1 Like

This could be a useful feature request. In the meantime, if you like, you can use this template with templater, replacing the callout names with the ones you want to use, with this syntaxe: type name: 'infos about this type'

<%*
//get selection
noteContent = tp.file.selection();
// list callouts
const callouts = {
   note:     '🔵 ✏ Note',
   info:     '🟢 ℹ Info',
   todo:     '🟢 ✔️ Todo',
   tip:      '🌐 🔥 Tip / Hint / Important',
   abstract: '🌐 📋 Abstract / Summary / TLDR',
   question: '🟡 ❓ Question / Help / FAQ',
   quote:    '🔘 💬 Quote / Cite',
   example:  '🟣 📑 Example',
   success:  '🟢 ✔ Success / Check / Done',
   warning:  '🟠 ⚠ Warning / Caution / Attention',
   failure:  '🔴 ❌ Failure / Fail / Missing',
   danger:   '🔴 ⚡ Danger / Error',
   bug:      '🔴 🐞 Bug',
};
// return callout
const type = await tp.system.suggester(Object.values(callouts), Object.keys(callouts), true, 'Select callout type.');
//return fold
const fold = await tp.system.suggester(['None', 'Expanded', 'Collapsed'], ['', '+', '-'], true, 'Select callout fold option.');

//return title
const title = await tp.system.prompt('Title:', '', true);
// const calloutHead = `> [!${type}]${fold} ${title}\n`;

//get array of lines
lines = noteContent.split('\n')
//make a new string with > prepended to each line
let newContent = "";
lines.forEach(l => {
	newContent += '> ' + l + "\n";
})
//remove the last newline character
newContent = newContent.replace(/\n$/, "");
//define callout header
header = ">[!"+type+"]"+fold + " " + title +"\n"
// Return the complete callout block
return header + newContent;
%>
1 Like