From 435d029f33e4b0d38c72b378288abc81a56d5f64 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 10 Nov 2025 11:25:47 +0100 Subject: [PATCH] feat: show avatar for mentioned users --- .../src/components/input/editor/TipTap.vue | 35 ++++++++------- .../input/editor/mention/MentionUser.vue | 44 +++++++++++++++++++ 2 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 frontend/src/components/input/editor/mention/MentionUser.vue diff --git a/frontend/src/components/input/editor/TipTap.vue b/frontend/src/components/input/editor/TipTap.vue index caefa4c01..473d3a2af 100644 --- a/frontend/src/components/input/editor/TipTap.vue +++ b/frontend/src/components/input/editor/TipTap.vue @@ -146,7 +146,7 @@ import EditorToolbar from './EditorToolbar.vue' import StarterKit from '@tiptap/starter-kit' import {Extension, mergeAttributes} from '@tiptap/core' -import {EditorContent, type Extensions, useEditor} from '@tiptap/vue-3' +import {EditorContent, type Extensions, useEditor, VueNodeViewRenderer} from '@tiptap/vue-3' import {Plugin, PluginKey} from '@tiptap/pm/state' import {marked} from 'marked' import {BubbleMenu} from '@tiptap/vue-3/menus' @@ -168,6 +168,7 @@ import {Node} from '@tiptap/pm/model' import Commands from './commands' import suggestionSetup from './suggestion' import mentionSuggestionSetup from './mention/mentionSuggestion' +import MentionUser from './mention/MentionUser.vue' import {common, createLowlight} from 'lowlight' @@ -494,6 +495,23 @@ if (props.enableMentions && props.mentionProjectId > 0) { class: 'mention', }, suggestion: mentionSuggestionSetup(props.mentionProjectId), + }).extend({ + + parseHTML() { + return [ + { + tag: 'mention-user', + }, + ] + }, + + renderHTML({ HTMLAttributes }) { + return ['mention-user', mergeAttributes(HTMLAttributes)] + }, + + addNodeView() { + return VueNodeViewRenderer(MentionUser) + }, }), ) } @@ -822,21 +840,6 @@ watch( border-radius: $radius; } - // Mention styles - .mention { - background-color: var(--grey-200); - color: var(--grey-800); - border-radius: 0.25rem; - padding: 0.125rem 0.375rem; - font-weight: 400; - text-decoration: none; - cursor: default; - - &:hover { - background-color: var(--grey-300); - } - } - pre { background: var(--grey-200); color: var(--grey-700); diff --git a/frontend/src/components/input/editor/mention/MentionUser.vue b/frontend/src/components/input/editor/mention/MentionUser.vue new file mode 100644 index 000000000..f32a1f42d --- /dev/null +++ b/frontend/src/components/input/editor/mention/MentionUser.vue @@ -0,0 +1,44 @@ + + + + + \ No newline at end of file