tiptap/demos/src/Nodes/Mention/Vue/index.vue
2021-10-26 00:00:30 +02:00

68 lines
1.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div v-if="editor">
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor, EditorContent } from '@tiptap/vue-3'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
import Mention from '@tiptap/extension-mention'
import suggestion from './suggestion'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
Document,
Paragraph,
Text,
Mention.configure({
HTMLAttributes: {
class: 'mention',
},
suggestion,
}),
],
content: `
<p>Hi everyone! Dont forget the daily stand up at 8 AM.</p>
<p><span data-mention data-id="Jennifer Grey"></span> Would you mind to share what youve been working on lately? We fear not much happened since Dirty Dancing.
<p><span data-mention data-id="Winona Ryder"></span> <span data-mention data-id="Axl Rose"></span> Lets go through your most important points quickly.</p>
<p>I have a meeting with <span data-mention data-id="Christina Applegate"></span> and dont want to come late.</p>
<p> Thanks, your big boss</p>
`,
})
},
beforeUnmount() {
this.editor.destroy()
},
}
</script>
<style lang="scss">
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
}
.mention {
border: 1px solid #000;
border-radius: 0.4rem;
padding: 0.1rem 0.3rem;
}
</style>