feat: Add Editor component and add editor demo

This commit is contained in:
陈凯龙
2022-02-10 10:04:47 +08:00
parent 17e8e7cda9
commit 3fb3e8da39
10 changed files with 1034 additions and 5 deletions

View File

@@ -0,0 +1,32 @@
<script setup lang="ts">
import { ContentWrap } from '@/components/ContentWrap'
import { Editor, EditorExpose } from '@/components/Editor'
import { useI18n } from '@/hooks/web/useI18n'
import { IDomEditor } from '@wangeditor/editor'
import { ref, onMounted, unref } from 'vue'
const { t } = useI18n()
const change = (editor: IDomEditor) => {
console.log(editor.getHtml())
}
const editorRef = ref<typeof Editor & EditorExpose>()
const defaultHtml = ref('')
onMounted(async () => {
const editor = await unref(editorRef)?.getEditorRef()
console.log(editor)
})
setTimeout(() => {
defaultHtml.value = '<p>hello <strong>world</strong></p>'
}, 3000)
</script>
<template>
<ContentWrap :title="t('richText.richText')" :message="t('richText.richTextDes')">
<Editor ref="editorRef" @change="change" :defaultHtml="defaultHtml" />
</ContentWrap>
</template>