refactoring

This commit is contained in:
Philipp Kühn
2021-01-19 20:42:15 +01:00
parent 563f37d74b
commit 4256de7cde
3 changed files with 17 additions and 5 deletions

View File

@@ -104,8 +104,8 @@ export default {
&.is-selected, &.is-selected,
&:hover { &:hover {
color: black; color: #A975FF;
background: rgba(black, 0.1); background: rgba(#A975FF, 0.1);
} }
} }
</style> </style>

View File

@@ -31,6 +31,9 @@ export default {
Paragraph, Paragraph,
Text, Text,
Mention.configure({ Mention.configure({
HTMLAttributes: {
class: 'mention',
},
suggestionOptions: { suggestionOptions: {
items: query => { items: query => {
return ['Hans', 'Philipp', 'Kris'].filter(item => item.startsWith(query)) return ['Hans', 'Philipp', 'Kris'].filter(item => item.startsWith(query))
@@ -76,7 +79,7 @@ export default {
}), }),
], ],
content: ` content: `
<p>text <span data-mention="Philipp"></span></p> <p>Hello <span data-mention="Hans"></span> and <span data-mention="Philipp"></span> and <span data-mention="Kris"></span>!</p>
`, `,
}) })
}, },
@@ -86,3 +89,12 @@ export default {
}, },
} }
</script> </script>
<style lang="scss">
.mention {
color: #A975FF;
background-color: rgba(#A975FF, 0.1);
border-radius: 0.3rem;
padding: 0.1rem 0.3rem;
}
</style>

View File

@@ -1,4 +1,4 @@
import { Node } from '@tiptap/core' import { Node, mergeAttributes } from '@tiptap/core'
import Suggestion, { SuggestionOptions } from '@tiptap/suggestion' import Suggestion, { SuggestionOptions } from '@tiptap/suggestion'
export type MentionOptions = { export type MentionOptions = {
@@ -57,7 +57,7 @@ export const Mention = Node.create({
}, },
renderHTML({ node, HTMLAttributes }) { renderHTML({ node, HTMLAttributes }) {
return ['span', HTMLAttributes, `@${node.attrs.id}`] return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id}`]
}, },
renderText({ node }) { renderText({ node }) {