diff --git a/client/src/components/Editor.vue b/client/src/components/Editor.vue index 140b533..2a8622c 100644 --- a/client/src/components/Editor.vue +++ b/client/src/components/Editor.vue @@ -95,8 +95,8 @@ export default class Editor extends Vue { generateTaskList() { // Get task list for today const data = this.editor.getValue(); - const regex = /\s+?- \[( |x)\] (.+)/gm; - let m; + const regex = /- \[( |x)\] (.+)/gm; + let m: any; let completed = false; this.global.taskList.splice(0) while ((m = regex.exec(data)) !== null) { @@ -107,8 +107,6 @@ export default class Editor extends Vue { completed = m[1] === "x"; this.global.taskList.push({ completed, name: m[2], index: m['index'] }); } - console.log(this.global.taskList); - this.global.taskTrigger += 1; } created() { @@ -165,6 +163,19 @@ export default class Editor extends Vue { this.editor.setCursor(cursor); }); } + + @Watch('global.taskList') + onTaskListChanged() { + const data = this.editor.getValue(); + let newData = data + this.global.taskList.forEach((task: any) => { + let c = task.completed ? 'x' : ' '; + newData = newData.substr(0, task.index + 3) + c + newData.substr(task.index + 4); + }) + if (newData !== data) { + this.editor.setValue(newData); + } + } } diff --git a/client/src/components/Header.vue b/client/src/components/Header.vue index 85c6d5d..69cd27b 100644 --- a/client/src/components/Header.vue +++ b/client/src/components/Header.vue @@ -3,10 +3,18 @@
- + +
- + +
@@ -15,17 +23,7 @@
- - +
@@ -76,14 +74,10 @@ v-model="sidebar.autoSave" @input="sidebar.toggleAutoSave" > - {{ - sidebar.autoSave ? "Disable Auto-Save" : "Enable Auto-Save" - }} + {{ sidebar.autoSave ? 'Disable Auto-Save' : 'Enable Auto-Save' }} - Export Notes + Export Notes Logout
@@ -93,35 +87,31 @@ diff --git a/client/src/components/TaskItem.vue b/client/src/components/TaskItem.vue index 1d1c0d3..030cdc5 100644 --- a/client/src/components/TaskItem.vue +++ b/client/src/components/TaskItem.vue @@ -1,6 +1,6 @@