fix: Make sure to always update card description when navigating awayfix
fix #5254 fix #2705 Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user