Add DONE slash command
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2020-06-01 20:01:21 +02:00
parent 35928390f1
commit bb439fcfe7
2 changed files with 8 additions and 1 deletions

View File

@ -14,6 +14,7 @@ function createTitleSearch() {
{title: 'Tomorrow', name: 'tomorrow'}, {title: 'Tomorrow', name: 'tomorrow'},
{title: 'Yesterday', name: 'yesterday'}, {title: 'Yesterday', name: 'yesterday'},
{title: 'TODO', name: 'todo'}, {title: 'TODO', name: 'todo'},
{title: 'DONE', name: 'done'},
{title: 'Page Reference', name: 'page_reference'}, {title: 'Page Reference', name: 'page_reference'},
{title: 'Code Block', name: 'code_block'}, {title: 'Code Block', name: 'code_block'},
]; ];

View File

@ -165,6 +165,7 @@ if (holder) {
} else if (resultType === 'command') { } else if (resultType === 'command') {
let start = value.lastIndexOf("/", end) let start = value.lastIndexOf("/", end)
let commandResult = "" let commandResult = ""
let replace = ""
let prefix = false let prefix = false
let adjustment = 0 let adjustment = 0
@ -180,6 +181,11 @@ if (holder) {
commandResult = "[[" + now.add(-1, 'day').format('D MMMM YYYY') + "]]" commandResult = "[[" + now.add(-1, 'day').format('D MMMM YYYY') + "]]"
} else if (linkName === "TODO") { } else if (linkName === "TODO") {
commandResult = "#[[TODO]] " commandResult = "#[[TODO]] "
replace = "#[[DONE]] "
prefix = true
} else if (linkName === "DONE") {
commandResult = "#[[DONE]] "
replace = "#[[TODO]] "
prefix = true prefix = true
} else if (linkName === "Page Reference") { } else if (linkName === "Page Reference") {
commandResult = "[[]]" commandResult = "[[]]"
@ -190,7 +196,7 @@ if (holder) {
} }
let startAndLink = prefix let startAndLink = prefix
? commandResult + value.substring(0, start) ? commandResult + value.substring(0, start).replace(replace, "")
: value.substring(0, start) + commandResult : value.substring(0, start) + commandResult
input.value = startAndLink + value.substring(end) input.value = startAndLink + value.substring(end)