Add todo highlighting
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2020-11-04 23:16:15 +01:00
parent a193436c08
commit 32fe46f285
2 changed files with 15 additions and 0 deletions

View File

@ -239,6 +239,7 @@ function Editor(holder, input) {
} }
let converted = text let converted = text
let todo;
if (converted === '{{table}}') { if (converted === '{{table}}') {
transformTable.call(this, editor, id, element); transformTable.call(this, editor, id, element);
@ -258,14 +259,20 @@ function Editor(holder, input) {
converted = '**[[' + res[1] + ']]**: ' + res[2] converted = '**[[' + res[1] + ']]**: ' + res[2]
} else if (text.match(/#\[\[TODO]]/)) { } else if (text.match(/#\[\[TODO]]/)) {
converted = converted.replace('#[[TODO]]', '<input class="checkbox" type="checkbox" />') converted = converted.replace('#[[TODO]]', '<input class="checkbox" type="checkbox" />')
todo = true;
} else if (text.match(/#\[\[DONE]]/)) { } else if (text.match(/#\[\[DONE]]/)) {
converted = converted.replace('#[[DONE]]', '<input class="checkbox" type="checkbox" checked />') converted = converted.replace('#[[DONE]]', '<input class="checkbox" type="checkbox" checked />')
todo = false;
} }
MD.options.html = true MD.options.html = true
converted = MD.renderInline(converted) converted = MD.renderInline(converted)
MD.options.html = false MD.options.html = false
} }
if (todo !== undefined) {
element.toggleClass('todo--done', todo === false)
element.toggleClass('todo--todo', todo === true)
}
element.html(converted) element.html(converted)
} }

View File

@ -457,3 +457,11 @@ input.input-line, input.input-line:active {
width: 400px; width: 400px;
} }
} }
.todo--todo {
}
.todo--done {
text-decoration: line-through;
text-decoration-skip: leading-spaces;
color: #999;
}