From 32fe46f2856acd8fa9c8332edf84fdd6c8c2b81c Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Wed, 4 Nov 2020 23:16:15 +0100 Subject: [PATCH] Add todo highlighting --- editor/src/editor.js | 7 +++++++ editor/src/styles.scss | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/editor/src/editor.js b/editor/src/editor.js index 11efa59..fbf8a8d 100644 --- a/editor/src/editor.js +++ b/editor/src/editor.js @@ -239,6 +239,7 @@ function Editor(holder, input) { } let converted = text + let todo; if (converted === '{{table}}') { transformTable.call(this, editor, id, element); @@ -258,14 +259,20 @@ function Editor(holder, input) { converted = '**[[' + res[1] + ']]**: ' + res[2] } else if (text.match(/#\[\[TODO]]/)) { converted = converted.replace('#[[TODO]]', '') + todo = true; } else if (text.match(/#\[\[DONE]]/)) { converted = converted.replace('#[[DONE]]', '') + todo = false; } MD.options.html = true converted = MD.renderInline(converted) MD.options.html = false } + if (todo !== undefined) { + element.toggleClass('todo--done', todo === false) + element.toggleClass('todo--todo', todo === true) + } element.html(converted) } diff --git a/editor/src/styles.scss b/editor/src/styles.scss index b47db94..28035e2 100644 --- a/editor/src/styles.scss +++ b/editor/src/styles.scss @@ -457,3 +457,11 @@ input.input-line, input.input-line:active { width: 400px; } } + +.todo--todo { +} +.todo--done { + text-decoration: line-through; + text-decoration-skip: leading-spaces; + color: #999; +}