Add mention '@all' in webapp

This commit is contained in:
Wolfgang Huß 2023-07-24 10:26:59 +02:00
parent a5578e4ff4
commit 32758de23a
5 changed files with 19 additions and 1 deletions

View File

@ -21,6 +21,7 @@
</template>
<script>
import { mapGetters } from 'vuex'
import { Editor, EditorContent } from 'tiptap'
import { History } from 'tiptap-extensions'
import linkify from 'linkify-it'
@ -68,6 +69,10 @@ export default {
}
},
computed: {
...mapGetters({
currentUser: 'auth/user',
isAdmin: 'auth/isAdmin',
}),
placeholder() {
return this.$t('editor.placeholder')
},
@ -78,6 +83,15 @@ export default {
extensions.push(
new Mention({
items: () => {
if (this.isAdmin)
return [
...this.users,
{
id: this.currentUser.id,
slug: this.$t('editor.mention.atAllLabel'),
dataMentionId: 'all',
},
]
return this.users
},
onEnter: (props) => this.openSuggestionList(props, MENTION),
@ -227,6 +241,7 @@ export default {
const typeAttrs = {
mention: {
id: item.id,
dataMentionId: item.dataMentionId ?? item.id,
label: item.slug,
},
hashtag: {

View File

@ -30,6 +30,7 @@
import { HASHTAG, MENTION } from '../../constants/editor'
export default {
name: 'SuggestionList',
props: {
suggestionType: String,
filteredItems: Array,

View File

@ -14,7 +14,7 @@ export default class Mention extends TipTapMention {
{
class: this.options.mentionClass,
href: `/profile/${node.attrs.id}`,
'data-mention-id': node.attrs.id,
'data-mention-id': node.attrs.dataMentionId,
target: '_blank',
},
`${this.options.matcher.char}${node.attrs.label} `,

View File

@ -393,6 +393,7 @@
"unorderedList": "Ungeordnete Liste"
},
"mention": {
"atAllLabel": "alle",
"noUsersFound": "Keine Nutzer gefunden"
},
"placeholder": "Schreib etwas Inspirierendes …"

View File

@ -393,6 +393,7 @@
"unorderedList": "Unordered list"
},
"mention": {
"atAllLabel": "all",
"noUsersFound": "No users found"
},
"placeholder": "Leave your inspirational thoughts …"