Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/components/AppSidebar/NotesItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
<textarea ref="note__editor"
v-model="newValue"
:maxlength="100000"
@keyup.escape="setEditing(false)"
@compositionstart="compositionstart()"
@compositionend="compositionend()"
@keydown.escape="escKeyDown()"
@keydown.enter.ctrl.prevent="setValue()"
@change="setValue()" />
</div>
Expand Down Expand Up @@ -86,6 +88,7 @@ export default {
.use(Mitl)
return {
md,
compositing: false,
}
},
watch: {
Expand Down Expand Up @@ -129,6 +132,18 @@ export default {
setNotes($event) {
this.setEditing(true, $event)
},
// Inspired by https://gist.github.com/gotraveltoworld/ecbd2ddc6a0d9bcee8baf396d683e1ba
compositionstart() {
this.compositing = true
},
compositionend() {
this.compositing = false
},
escKeyDown() {
if (!this.compositing) {
this.setEditing(false)
}
},
},
}
</script>
Expand Down
22 changes: 20 additions & 2 deletions src/components/HeaderBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
:show-trailing-button="newTaskName !== ''"
:trailing-button-label="placeholder"
@trailing-button-click="addTask"
@keyup.esc="clearNewTask($event)"
@keyup.enter="addTask"
@compositionstart="compositionstart()"
@compositionend="compositionend()"
@keydown.esc="clearNewTask($event)"
@keydown.enter="addTask"
@paste.stop="addMultipleTasks">
<template #icon>
<Plus :size="20" />
Expand Down Expand Up @@ -83,6 +85,7 @@ export default {
showCreateMultipleTasksModal: false,
multipleTasks: { numberOfTasks: 0, tasks: {} },
additionalTaskProperties: {},
compositing: false,
}
},
computed: {
Expand Down Expand Up @@ -112,12 +115,27 @@ export default {
'createTask',
]),

compositionstart() {
this.compositing = true
},
compositionend() {
this.compositing = false
},

clearNewTask(event) {
if (this.compositing) {
return
}

event.target.blur()
this.newTaskName = ''
},

async addTask() {
if (this.compositing) {
return
}

const data = {
summary: this.newTaskName,
// If the task is created in the calendar view,
Expand Down
Loading