Last active
November 5, 2023 13:14
-
-
Save dmych/d700b1d0fe457075a916cafec190bca8 to your computer and use it in GitHub Desktop.
A script for Obsidian Templater that allows you to select a checkbox value from a menu. It is recommended to assign a template to a hotkey or a button in the mobile toolbar. Save the template as .md file to your Templater scripts folder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
let lst = ['[ ] to-do', | |
'[/] incomplete', | |
'[x] done', | |
'[-] canceled', | |
'[>] forwarded', | |
'[<] scheduling', | |
'[?] question', | |
'[!] important', | |
'[*] star', | |
'["] quote', | |
'[l] location', | |
'[b] bookmark', | |
'[i] information', | |
'[S] savings', | |
'[I] idea', | |
'[p] pros', | |
'[c] cons', | |
'[f] fire', | |
'[k] key', | |
'[w] win', | |
'[u] up', | |
'[d] down']; | |
let opt = []; | |
lst.forEach(c => opt += c.charAt(1)); | |
let x = await tp.system.suggester(lst, opt); | |
if (x == null) return; | |
let re = /(^\s*|^\t*)(-\s\[ \]\s|-\s\[.\]\s|\*\s|-\s|\d*\.\s|\*\s|\b|^)([^\n\r]*)/gim; | |
let editor = app.workspace.activeLeaf.view.editor; | |
let cur = editor.getCursor("from"); | |
let text = editor.getLine(cur.line); | |
text = text.replace(re, (match, spaces, startText, sentence) => { return spaces + '- ['+x+'] ' + sentence }); | |
editor.setLine(cur.line, text); | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment