Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Mention.vue « extensions « src - github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2a27a8e687663b1fcc36f00f8997272c855b579a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<template>
	<NodeViewWrapper as="span" class="mention" contenteditable="false">
		<NcUserBubble :user="node.attrs.id"
			:display-name="username"
			:primary="isCurrentUser"
			class="mention-user-bubble">
			@{{ username }}
		</NcUserBubble>
	</NodeViewWrapper>
</template>

<script>
import NcUserBubble from '@nextcloud/vue/dist/Components/NcUserBubble.js'
import { NodeViewWrapper } from '@tiptap/vue-2'
import { getCurrentUser } from '@nextcloud/auth'

export default {
	name: 'Mention',
	components: {
		NcUserBubble,
		NodeViewWrapper,
	},
	props: {
		updateAttributes: {
			type: Function,
			required: true,
		},

		node: {
			type: Object,
			required: true,
		},
	},
	data() {
		return {
			username: this.node.attrs.label,
		}
	},
	computed: {
		isCurrentUser() {
			return this.node.attrs.id === getCurrentUser()?.uid
		},
	},
}
</script>
<style scoped>
/* This is required to properly render the bubble text (which seems linke a browser bug) */
.text-editor__wrapper div.ProseMirror .mention[contenteditable=false] :deep(*) {
	-webkit-user-modify: read-only !important;
}
</style>