mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 07:08:02 +00:00
feat(front): add Tiptap component for rich text editing functionality
This commit is contained in:
30
front/components/Tiptap.vue
Normal file
30
front/components/Tiptap.vue
Normal file
@@ -0,0 +1,30 @@
|
||||
<template>
|
||||
<editor-content :editor="editor" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Editor, EditorContent } from '@tiptap/vue-3'
|
||||
import StarterKit from '@tiptap/starter-kit'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: string
|
||||
}>()
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: string): void
|
||||
}>()
|
||||
|
||||
const editor = ref<Editor | undefined>(undefined)
|
||||
onMounted(() => {
|
||||
editor.value = new Editor({
|
||||
content: props.modelValue,
|
||||
extensions: [StarterKit],
|
||||
onUpdate: () => {
|
||||
// HTML
|
||||
emit('update:modelValue', editor.value?.getHTML() ?? '')
|
||||
}
|
||||
})
|
||||
})
|
||||
onUnmounted(() => {
|
||||
editor.value?.destroy()
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user