This commit is contained in:
alvis
2020-07-16 14:12:31 +08:00
parent 1c159a7bad
commit f746aef851
2140 changed files with 7218 additions and 4689 deletions

View File

@@ -0,0 +1,65 @@
<template>
<div>
<script :id="randomId" type="text/plain" style="height: 300px;"></script>
</div>
</template>
<script>
export default {
name: 'UE',
props: {
value: {
default: function () {
return ''
}
}
},
data () {
return {
randomId: 'editor_' + Math.random() * 100000000000000000,
// 编辑器实例
instance: null,
ready: false
}
},
watch: {
value: function (val, oldVal) {
if (val != null && this.ready) {
// eslint-disable-next-line no-undef
this.instance = UE.getEditor(this.randomId)
this.instance.setContent(val)
}
}
},
mounted () {
this.initEditor()
},
beforeDestroy () {
if (this.instance !== null && this.instance.destroy) {
this.instance.destroy()
}
},
methods: {
initEditor () {
this.$nextTick(() => {
// eslint-disable-next-line no-undef
this.instance = UE.getEditor(this.randomId)
this.instance.addListener('ready', () => {
this.ready = true
this.$emit('ready', this.instance)
})
})
},
getUEContent () {
return this.instance.getContent()
},
setText (con) {
// eslint-disable-next-line no-undef
this.instance = UE.getEditor(this.randomId)
this.instance.setContent(con)
}
}
}
</script>