Add C-; toggleTodo key and actions
All checks were successful
continuous-integration/drone/push Build is passing

Toggles between [ ] -> [x] -> none
This commit is contained in:
Peter Stuifzand 2021-08-07 20:18:38 +02:00
parent 0cd50f7766
commit 5d9b412973

View File

@ -59,6 +59,7 @@ function editor(root, inputData, options) {
normalKeymap.mapKey('Tab', 'indentBlock')
normalKeymap.mapKey('S-Tab', 'indentBlock')
normalKeymap.mapKey('C-.', 'toggleBlock')
normalKeymap.mapKey('C-;', 'toggleTodo')
function createStore(inputData) {
let data = [
@ -195,7 +196,9 @@ function editor(root, inputData, options) {
expandBlock,
collapseBlock,
toggleBlock
toggleBlock,
toggleTodo
};
root.classList.add('root')
@ -659,6 +662,24 @@ function editor(root, inputData, options) {
return toggleBlock(event, false)
}
function toggleTodo(event) {
store.update(cursor.getId(store), function (item) {
const res = item.text.match(/^#\[\[(TODO|DONE)\]\]/)
if (res) {
if (res[1] === 'TODO') {
item.text = item.text.replace(/#\[\[TODO\]\]\s*/, '#[[DONE]] ')
} else {
item.text = item.text.replace(/#\[\[DONE\]\]\s*/, '')
}
} else {
item.text = '#[[TODO]] ' + item.text
}
return item
})
trigger('change')
return false
}
function countBraces(sset, as) {
let set = _(sset).chain().split('').value()
let defaults = {}