feat(front): add Tiptap component for rich text editing functionality

This commit is contained in:
keven1024
2025-04-13 17:08:45 +08:00
parent f996535e51
commit ad07ffd332

View 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>