Callouts - Templater Script

Source

This comes from GitHub user SilentVoid13. It is a templater script, that makes it really fast and easy to add callouts.

Setup

The template

For this to work, we need to create a new template in our designated templates folder. For example, Template - Callouts. Then we need to copy/paste the templater code into it.

The hotkey

Now we need to define a hotkey for this template. As always, we go to the Obsidian Settings, Templater, and Add new hotkey for template. We select the Callouts template and click on the plus icon next to it.

In the hotkey settings, search for callouts, click the plus symbol and pick any shortcut you like that does not interfere with existing settings. For this demo, I will choose CTRL + SHIFT + C.

Result

Create a new note and press CTRL + SHIFT + C (or whatever hotkey you defined) and the script asks you several things:

Then hit Enter or click the Submit button and your callout is ready.

What I like most about this, is that it's superfast and gives me a list of callout types to choose from. Combined with the Callout Manager plugin, this gives me full flexibility and makes the use of callouts very efficient.

Code

<%_* let calloutType = await tp.system.suggester(["Abstract", "Attention", "Bug", "Caution", "Check", "Cite", "Danger", "Done", "Error", "Example", "Fail", "Failure", "FAQ", "Help", "Hint", "Important", "Info", "Missing","Note", "Question", "Quote", "Success", "Summary", "Tip", "TLDR", "Todo", "Warning"], ["abstract", "attention", "bug", "caution", "check", "cite", "danger", "done", "error", "example", "fail", "failure", "faq", "help", "hint", "important", "info", "missing","note", "question", "quote", "success", "summary", "tip", "tldr", "todo", "warning"], false, "Which type of callout do you want to insert?")%>

<%_* let foldState = await tp.system.suggester(["Not Foldable", "Default Expanded", "Default Collapsed"], ["", "+", "-"], false, "Folding state of callout?")%>

<%_*
  let title = await tp.system.prompt("Optional Title Text", "")
%>

<%_*
  let calloutContent = await tp.system.prompt("Optional Content Text (Shift Enter to Insert New Line)", "", false, true)
  calloutContent = calloutContent.replaceAll("\n", "\n> ")
%>

<%-*
if (calloutType != null) {
  let content = '> [!' + calloutType + ']' + foldState + ' ' + title + '\n> ' + calloutContent + '\n'
  tR+=content
}
%>