-
-
+
+
-
@@ -59,14 +53,16 @@
-
{{ t('deck', 'Write a description …') }}
-
{{ t('deck', 'Choose attachment') }}
-
@@ -90,6 +87,7 @@ import MarkdownIt from 'markdown-it'
import MarkdownItTaskCheckbox from 'markdown-it-task-checkbox'
import MarkdownItLinkAttributes from 'markdown-it-link-attributes'
import AttachmentList from './AttachmentList'
+import AttachmentUploadProgress from './AttachmentUploadProgress'
import { Actions, ActionButton, Modal } from '@nextcloud/vue'
import { formatFileSize } from '@nextcloud/files'
import { generateUrl } from '@nextcloud/router'
@@ -118,6 +116,7 @@ export default {
Modal,
AttachmentList,
PaperclipIcon,
+ AttachmentUploadProgress,
},
mixins: [attachmentUpload],
@@ -145,7 +144,6 @@ export default {
descriptionSaving: false,
descriptionLastEdit: 0,
modalShow: false,
- lastPasteImageCursor: null,
}
},
computed: {
@@ -187,6 +185,9 @@ export default {
hasDescription() {
return this.card?.description?.trim?.() !== ''
},
+ cardId() {
+ return this.card.id
+ },
},
methods: {
showEditor() {
@@ -202,18 +203,35 @@ export default {
showAttachmentModal() {
this.modalShow = true
},
- addAttachment(attachment) {
- const descString = this.$refs.markdownEditor.easymde.value()
+ async addAttachment(attachment) {
let embed = ''
if ((attachment.type === 'file' && attachment.extendedData.hasPreview) || attachment.extendedData.mimetype.includes('image')) {
embed = '!'
}
const attachmentString = embed + '[📎 ' + attachment.data + '](' + this.attachmentPreview(attachment) + ')'
- const newContent = descString + '\n' + attachmentString
+ const cursor = this.$refs.markdownEditor.easymde.codemirror.getCursor()
+ const descStringLines = this.$refs.markdownEditor.easymde.value().split('\n')
+ let lineUpatedLength = 0
+
+ for (let i = 0; i < descStringLines.length; i++) {
+ if (i === cursor.line) {
+ descStringLines[i] = descStringLines[i].substring(0, cursor.ch) + attachmentString + descStringLines[i].substring(cursor.ch)
+ lineUpatedLength = descStringLines[i].length
+ break
+ }
+ }
+
+ const newContent = descStringLines.join('\n')
this.$refs.markdownEditor.easymde.value(newContent)
this.description = newContent
this.modalShow = false
this.updateDescription()
+
+ if (lineUpatedLength > 0) {
+ await this.$nextTick()
+ this.$refs.markdownEditor.easymde.codemirror.focus()
+ this.$refs.markdownEditor.easymde.codemirror.setCursor({ line: cursor.line, ch: lineUpatedLength })
+ }
},
clickedPreview(e) {
if (e.target.getAttribute('type') === 'checkbox') {
@@ -255,41 +273,15 @@ export default {
},
async addLastAttachmmentOnCursor() {
const attachementLength = this.$store.getters.attachmentsByCard(this.card.id).length
- if (attachementLength === 0) return
-
- const attachment = this.$store.getters.attachmentsByCard(this.card.id)[attachementLength - 1]
- const descStringLines = this.$refs.markdownEditor.easymde.value().split('\n')
- const cursor = this.lastPasteImageCursor === null ? this.$refs.markdownEditor.easymde.codemirror.getCursor() : this.lastPasteImageCursor
- let embed = ''
- if ((attachment.type === 'file' && attachment.extendedData.hasPreview) || attachment.extendedData.mimetype.includes('image')) {
- embed = '!'
- }
-
- const attachmentString = embed + '[📎 ' + attachment.data + '](' + this.attachmentPreview(attachment) + ')'
- let lineUpatedLength = 0
- for (let i = 0; i < descStringLines.length; i++) {
- if (i === cursor.line) {
- descStringLines[i] = descStringLines[i].substring(0, cursor.ch) + attachmentString + descStringLines[i].substring(cursor.ch)
- lineUpatedLength = descStringLines[i].length
- break
- }
- }
- const newContent = descStringLines.join('\n')
- this.$refs.markdownEditor.easymde.value(newContent)
- this.description = newContent
- this.modalShow = false
- this.updateDescription()
-
- if (lineUpatedLength > 0) {
- await this.$nextTick()
- this.lastPasteImageCursor = { line: cursor.line, ch: lineUpatedLength }
- this.$refs.markdownEditor.easymde.codemirror.focus()
- this.$refs.markdownEditor.easymde.codemirror.setCursor({ line: cursor.line, ch: lineUpatedLength })
+ if (attachementLength === 0) {
+ return
}
-
+ this.addAttachment(this.$store.getters.attachmentsByCard(this.card.id)[attachementLength - 1])
},
onPaste() {
- if (!this.descriptionEditing) return
+ if (!this.descriptionEditing) {
+ return
+ }
const clipboardData = event.clipboardData
let files = []
@@ -303,15 +295,16 @@ export default {
}
}
- if (files.length === 0) return
+ if (files.length === 0) {
+ return
+ }
this.loading = true
- this.lastPasteImageCursor = null
event.preventDefault()
for (const file of files) {
this.onLocalAttachmentSelected(file, 'file').then(this.addLastAttachmmentOnCursor)
}
- }
+ },
},
}
From 69dd0b1a4258b99298bfd857ea2d6db21fff22bd Mon Sep 17 00:00:00 2001
From: "rija.propitech"
Date: Mon, 26 Sep 2022 13:00:24 +0300
Subject: [PATCH 5/7] description vue update
---
src/components/card/Description.vue | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/components/card/Description.vue b/src/components/card/Description.vue
index 0f7a54f2a..bc126c900 100644
--- a/src/components/card/Description.vue
+++ b/src/components/card/Description.vue
@@ -35,22 +35,22 @@
href="https://deck.readthedocs.io/en/latest/Markdown/"
target="_blank"
class="icon icon-info" />
-
+
{{ t('deck', 'Edit description') }}
{{ t('deck', 'View description') }}
-
-
+
+
{{ t('deck', 'Add Attachment') }}
-
+
-
+
{{ t('deck', 'Choose attachment') }}
-
+