|
132 | 132 | href="https://deck.readthedocs.io/en/latest/Markdown/" |
133 | 133 | target="_blank" |
134 | 134 | class="icon icon-info" /> |
135 | | - <Actions v-if="canEdit"> |
136 | | - <ActionButton v-if="descriptionEditing" icon="icon-attach" @click="showAttachmentModal()"> |
137 | | - {{ t('deck', 'Add Attachment') }} |
138 | | - </ActionButton> |
139 | | - </Actions> |
140 | 135 | <Actions v-if="canEdit"> |
141 | 136 | <ActionButton v-if="!descriptionEditing" icon="icon-rename" @click="showEditor()"> |
142 | 137 | {{ t('deck', 'Edit description') }} |
|
145 | 140 | {{ t('deck', 'View description') }} |
146 | 141 | </ActionButton> |
147 | 142 | </Actions> |
| 143 | + <Actions v-if="canEdit"> |
| 144 | + <ActionButton v-if="descriptionEditing" icon="icon-attach" @click="showAttachmentModal()"> |
| 145 | + {{ t('deck', 'Add Attachment') }} |
| 146 | + </ActionButton> |
| 147 | + </Actions> |
148 | 148 | </h5> |
149 | 149 |
|
150 | 150 | <div v-if="!descriptionEditing" |
151 | 151 | id="description-preview" |
152 | 152 | @click="clickedPreview" |
153 | 153 | v-html="renderedDescription" /> |
154 | 154 | <VueEasymde v-else |
| 155 | + :key="copiedCard.id" |
155 | 156 | ref="markdownEditor" |
156 | | - :value="copiedCard.description" |
| 157 | + v-model="copiedCard.description" |
157 | 158 | :configs="mdeConfig" |
158 | | - @input="updateDescription" /> |
| 159 | + @input="updateDescription" |
| 160 | + @blur="saveDescription" /> |
159 | 161 | </AppSidebarTab> |
160 | 162 |
|
161 | 163 | <AppSidebarTab id="attachments" |
@@ -356,11 +358,15 @@ export default { |
356 | 358 | this.initialize() |
357 | 359 | }, |
358 | 360 | methods: { |
359 | | - initialize() { |
| 361 | + async initialize() { |
360 | 362 | if (!this.currentCard) { |
361 | 363 | return |
362 | 364 | } |
363 | 365 |
|
| 366 | + if (this.copiedCard) { |
| 367 | + await this.saveDescription() |
| 368 | + } |
| 369 | +
|
364 | 370 | this.copiedCard = JSON.parse(JSON.stringify(this.currentCard)) |
365 | 371 | this.allLabels = this.currentCard.labels |
366 | 372 |
|
@@ -431,20 +437,21 @@ export default { |
431 | 437 | this.copiedCard.duedate = null |
432 | 438 | this.$store.dispatch('updateCardDue', this.copiedCard) |
433 | 439 | }, |
| 440 | + async saveDescription() { |
| 441 | + if (!Object.prototype.hasOwnProperty.call(this.copiedCard, 'descriptionLastEdit') || this.descriptionSaving) { |
| 442 | + return |
| 443 | + } |
| 444 | + this.descriptionSaving = true |
| 445 | + await this.$store.dispatch('updateCardDesc', this.copiedCard) |
| 446 | + delete this.copiedCard.descriptionLastEdit |
| 447 | + this.descriptionSaving = false |
| 448 | + }, |
434 | 449 | updateDescription(text) { |
435 | | - this.copiedCard.description = text |
436 | 450 | this.copiedCard.descriptionLastEdit = Date.now() |
437 | 451 | clearTimeout(this.descriptionSaveTimeout) |
438 | 452 | this.descriptionSaveTimeout = setTimeout(async() => { |
439 | | - if (!Object.prototype.hasOwnProperty.call(this.copiedCard, 'descriptionLastEdit') || this.descriptionSaving) { |
440 | | - return |
441 | | - } |
442 | | - this.descriptionSaving = true |
443 | | - await this.$store.dispatch('updateCardDesc', this.copiedCard) |
444 | | - delete this.copiedCard.descriptionLastEdit |
445 | | - this.descriptionSaving = false |
| 453 | + await this.saveDescription() |
446 | 454 | }, 2500) |
447 | | -
|
448 | 455 | }, |
449 | 456 |
|
450 | 457 | closeSidebar() { |
|
0 commit comments