Seigwai/src/components/Tiptap/Editor.vue
2023-03-29 23:27:06 +08:00

40 lines
1.2 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.

<script setup lang="ts">
import { EditorContent, useEditor } from '@tiptap/vue-3'
import StarterKit from '@tiptap/starter-kit'
import Typography from '@tiptap/extension-typography'
import Link from '@tiptap/extension-link'
import BubbleMenu from './BubbleMenu.vue'
import Commands from './commands'
import suggestion from './suggestion'
const editor = useEditor({
content: `<p>
Wow, this editor has support for links to the whole <a href="https://en.wikipedia.org/wiki/World_Wide_Web">world wide web</a>. We tested a lot of URLs and I think you can add *every URL* you want. Isnt that cool? Lets try <a href="https://statamic.com/">another one!</a> Yep, seems to work.
</p>
<p>
By default every link will get a <code>rel="noopener noreferrer nofollow"</code> attribute. Its configurable though.
</p>`,
extensions: [
StarterKit,
Typography,
Link.configure({
openOnClick: false,
}),
Commands.configure({
suggestion,
}),
],
editable: true,
autofocus: true,
editorProps: {
attributes: {
class: 'prose',
},
},
})
</script>
<template>
<BubbleMenu v-if="editor" :editor="editor" />
<EditorContent :editor="editor" />
</template>