Revert "Revert "[stable22] Fix mentions rendering in comment editor""

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
pull/35548/head
Louis 1 year ago committed by nextcloud-command
parent 210bc31c33
commit 3d15c24dfa

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -71,6 +71,7 @@
:auto-complete="autoComplete"
:contenteditable="!loading"
:value="localMessage"
:user-data="userData"
@update:value="updateLocalMessage"
@submit="onSubmit" />
<input v-tooltip="t('comments', 'Post comment')"

@ -25,6 +25,7 @@
<!-- Editor -->
<Comment v-bind="editorData"
:auto-complete="autoComplete"
:user-data="userData"
:editor="true"
:ressource-id="ressourceId"
class="comments__writer"
@ -77,9 +78,9 @@ import Vue from 'vue'
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
import Comment from '../components/Comment'
import getComments, { DEFAULT_LIMIT } from '../services/GetComments'
import cancelableRequest from '../utils/cancelableRequest'
import Comment from '../components/Comment.vue'
import getComments, { DEFAULT_LIMIT } from '../services/GetComments.js'
import cancelableRequest from '../utils/cancelableRequest.js'
Vue.use(VTooltip)
@ -111,6 +112,7 @@ export default {
},
Comment,
userData: {},
}
},
@ -153,21 +155,22 @@ export default {
/**
* Make sure we have all mentions as Array of objects
* @param {Array} mentions the mentions list
* @returns {Object[]}
* @returns {Object<string, object>}
*/
genMentionsData(mentions) {
const list = Object.values(mentions).flat()
return list.reduce((mentions, mention) => {
mentions[mention.mentionId] = {
// TODO: support groups
icon: 'icon-user',
id: mention.mentionId,
label: mention.mentionDisplayName,
source: 'users',
primary: getCurrentUser().uid === mention.mentionId,
}
return mentions
}, {})
Object.values(mentions)
.flat()
.forEach(mention => {
this.userData[mention.mentionId] = {
// TODO: support groups
icon: 'icon-user',
id: mention.mentionId,
label: mention.mentionDisplayName,
source: 'users',
primary: getCurrentUser().uid === mention.mentionId,
}
})
return this.userData
},
/**
@ -230,7 +233,9 @@ export default {
limit: loadState('comments', 'maxAutoCompleteResults'),
},
})
return callback(results.data.ocs.data)
// Save user data so it can be used by the editor to replace mentions
results.data.ocs.data.forEach(user => { this.userData[user.id] = user })
return callback(Object.values(this.userData))
},
/**

Loading…
Cancel
Save