Skip to content
Open
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
18 changes: 18 additions & 0 deletions src/components/card/Description.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
id="description-preview"
dir="auto"
@click="clickedPreview"
v-html="renderedDescription" />

Check warning on line 43 in src/components/card/Description.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'v-html' directive can lead to XSS attack
<p v-else-if="!descriptionEditing" class="placeholder" @click="showEditor()">
{{ t('deck', 'Write a description …') }}
</p>
Expand Down Expand Up @@ -118,6 +118,7 @@
textAppAvailable: !!window.OCA?.Text?.createEditor,
editor: null,
keyExitState: 0,
descriptionOld: '',
description: '',
markdownIt: null,
descriptionEditing: false,
Expand Down Expand Up @@ -172,6 +173,21 @@
return this.card?.description?.trim?.() !== ''
},
},
watch: {
card(newCard) {
if (newCard.description !== this.descriptionOld) {
clearTimeout(this.descriptionSaveTimeout)
this.descriptionLastEdit = 0

this.descriptionOld = newCard.description
this.description = newCard.description
if (this.editor) {
this.editor.setContent(this.description)
}
showWarning(t('deck', 'The description has been changed by another user.'), { timeout: 3000 })
}
},
},
mounted() {
this.setupEditor()
},
Expand All @@ -182,6 +198,7 @@
async setupEditor() {
await this.destroyEditor()
this.descriptionLastEdit = 0
this.descriptionOld = this.card.description
this.description = this.card.description
this.editor = await window.OCA.Text.createEditor({
el: this.$refs.editor,
Expand Down Expand Up @@ -296,6 +313,7 @@
}
this.$emit('change', this.description)
this.descriptionLastEdit = 0
this.descriptionOld = this.description
this.$store.commit('setHasCardSaveError', false)
} catch (e) {
this.$store.commit('setHasCardSaveError', true)
Expand Down
Loading