diff --git a/src/components/card/CardSidebarTabDetails.vue b/src/components/card/CardSidebarTabDetails.vue index c34eab09d..387298cfa 100644 --- a/src/components/card/CardSidebarTabDetails.vue +++ b/src/components/card/CardSidebarTabDetails.vue @@ -119,8 +119,10 @@ export default { this.initialize() }, methods: { - descriptionChanged(newDesc) { - this.$store.dispatch('updateCardDesc', { ...this.card, description: newDesc }) + async descriptionChanged(newDesc) { + if (newDesc === this.copiedCard.description) { + return + } this.copiedCard.description = newDesc }, async initialize() { diff --git a/src/components/card/Description.vue b/src/components/card/Description.vue index 42a76c095..76c5fbdfe 100644 --- a/src/components/card/Description.vue +++ b/src/components/card/Description.vue @@ -187,17 +187,26 @@ export default { mounted() { this.setupEditor() }, - beforeDestroy() { - this?.editor?.destroy() + async beforeDestroy() { + await this.destroyEditor() }, methods: { async setupEditor() { - this?.editor?.destroy() + await this.destroyEditor() + this.descriptionLastEdit = 0 + this.description = this.card.description this.editor = await window.OCA.Text.createEditor({ el: this.$refs.editor, content: this.card.description, readOnly: !this.canEdit, + onLoaded: () => { + this.descriptionLastEdit = 0 + }, onUpdate: ({ markdown }) => { + if (this.description === markdown) { + this.descriptionLastEdit = 0 + return + } this.description = markdown this.updateDescription() }, @@ -207,6 +216,10 @@ export default { }) }, + async destroyEditor() { + await this.saveDescription() + this?.editor?.destroy() + }, addKeyListeners() { this.$refs.markdownEditor.easymde.codemirror.on('keydown', (a, b) => { if (this.keyExitState === 0 && (b.key === 'Meta' || b.key === 'Alt')) { @@ -287,6 +300,7 @@ export default { return } this.descriptionSaving = true + await this.$store.dispatch('updateCardDesc', { ...this.card, description: this.description }) this.$emit('change', this.description) this.descriptionLastEdit = 0 this.descriptionSaving = false