From 628677904179db38908a7241719217f05fa0883c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 31 Jan 2020 11:38:57 +0100 Subject: [PATCH] Implement editing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../card/CardSidebarTabComments.vue | 66 ++----------------- src/components/card/CommentItem.vue | 48 +++++++------- src/services/CommentApi.js | 23 +++++++ src/store/comment.js | 20 +++--- 4 files changed, 62 insertions(+), 95 deletions(-) diff --git a/src/components/card/CardSidebarTabComments.vue b/src/components/card/CardSidebarTabComments.vue index 2856b0b41..a4c403625 100644 --- a/src/components/card/CardSidebarTabComments.vue +++ b/src/components/card/CardSidebarTabComments.vue @@ -7,33 +7,7 @@ -
-
- - - -
- - - -
+
    import { mapState, mapGetters } from 'vuex' -import { Avatar, UserBubble } from '@nextcloud/vue' +import { Avatar } from '@nextcloud/vue' import CommentItem from './CommentItem' +import CommentForm from './CommentForm' import InfiniteLoading from 'vue-infinite-loading' -import At from 'vue-at' -import { rawToParsed } from '../../helpers/mentions' export default { name: 'CardSidebarTabComments', components: { Avatar, CommentItem, + CommentForm, InfiniteLoading, - At, - UserBubble, }, props: { card: { @@ -117,8 +89,7 @@ export default { await this.$store.dispatch('fetchComments', { cardId: this.card.id }) this.isLoading = false }, - async createComment() { - const content = this.contentEditableToParsed() + async createComment(content) { const commentObj = { cardId: this.card.id, comment: content, @@ -132,37 +103,10 @@ export default { await this.$store.dispatch('fetchMore', { cardId: this.card.id }) this.isLoading = false }, - - /** - * All credits for this go to the talk app - * https://github.com/nextcloud/spreed/blob/e69740b372e17eec4541337b47baa262a5766510/src/components/NewMessageForm/NewMessageForm.vue#L100-L143 - */ - contentEditableToParsed() { - const mentions = this.$refs.contentEditable.querySelectorAll('span[data-at-embedded]') - mentions.forEach(mention => { - // FIXME Adding a space after the mention should be improved to - // do it or not based on the next element instead of always - // adding it. - mention.replaceWith('@' + mention.firstElementChild.attributes['data-mention-id'].value + ' ') - }) - - return rawToParsed(this.$refs.contentEditable.innerHTML) - }, }, } diff --git a/src/components/card/CommentItem.vue b/src/components/card/CommentItem.vue index 273b0ac91..11efc52b3 100644 --- a/src/components/card/CommentItem.vue +++ b/src/components/card/CommentItem.vue @@ -1,12 +1,12 @@