feat: add editor

This commit is contained in:
xiaoxian521
2021-04-04 17:52:30 +08:00
parent 42dfb536bd
commit b76e199b6d
6 changed files with 112 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<template>
<div>
<div ref="editor"></div>
<div :innerHTML="content.html"></div>
</div>
</template>
<script>
import { onMounted, onBeforeUnmount, ref, reactive } from 'vue'
import WangEditor from 'wangeditor'
export default {
name: 'editor',
setup() {
const editor = ref()
const content = reactive({
html: '',
text: '',
})
let instance
onMounted(() => {
instance = new WangEditor(editor.value)
Object.assign(instance.config, {
onchange() {
content.html = instance.txt.html()
},
})
instance.create()
})
onBeforeUnmount(() => {
instance.destroy()
instance = null
})
return {
editor,
content,
}
},
};
</script>
<style lang="scss" scoped>
:deep(.w-e-text-container) {
z-index: 999 !important;
}
</style>