diff --git a/src/components/card/Description.vue b/src/components/card/Description.vue index 9e42f1790..09caf774f 100644 --- a/src/components/card/Description.vue +++ b/src/components/card/Description.vue @@ -7,8 +7,8 @@
{{ t('deck', 'Description') }} - {{ t('deck', '(Unsaved)') }} - {{ t('deck', '(Saving…)') }} + {{ t('deck', '(Unsaved)') }} + {{ t('deck', '(Saving…)') }} { const url = OC.MimeType.getIconUrl(mimetype) @@ -194,7 +200,7 @@ export default { watch: { card(newCard) { - if (this.textAppAvailable) { + if (this.collaborative) { return } if (newCard.description !== this.descriptionOld) { @@ -209,6 +215,10 @@ export default { }, mounted() { + if (!this.collaborative) { + this.descriptionOld = this.card.description + this.description = this.card.description + } if (this.textAppAvailable) { this.setupEditor() } @@ -226,16 +236,31 @@ export default { ...mapActions(useSettingsStore, ['setHasCardSaveError']), async setupEditor() { await this.destroyEditor() - this.editor = await window.OCA.Text.createCollaborativeEditor({ - context: { type: 'deck_card', id: this.card.id }, + if (this.collaborative) { + this.editor = await window.OCA.Text.createCollaborativeEditor({ + context: { type: 'deck_card', id: this.card.id }, + el: this.$refs.editor, + readOnly: !this.canEdit, + }) + return + } + this.editor = await window.OCA.Text.createMarkdownContentEditor({ el: this.$refs.editor, + content: this.card.description, readOnly: !this.canEdit, + onUpdate: ({ markdown }) => { + if (this.description === markdown) { + return + } + this.description = markdown + this.updateDescription() + }, }) }, async destroyEditor() { clearTimeout(this.descriptionSaveTimeout) - if (!this.textAppAvailable) { + if (!this.collaborative) { await this.saveDescription() } try {