-
Notifications
You must be signed in to change notification settings - Fork 1
/
ueditor.vue
67 lines (67 loc) · 1.66 KB
/
ueditor.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
<div class="ueditor" ref="rowUEditor">
<script id="editor" type="text/plain"></script>
</div>
</template>
<script>
export default {
name: 'ueditor',
data() {
return {
editor: null
}
},
props: {
defaultMsg: {
type: String
},
config: {
type: Object,
}
},
computed: {
DefaultConfig() {
let obj = this.config
let serverUrl = this.$store.state.baseURL + '/sys/ueditor/exec.act'
return {
autoFloatEnabled: false,
serverUrl,
...obj
}
}
},
mounted() {
this.initUEditor()
},
methods: {
initUEditor() {
const that = this;
this.editor = UE.getEditor('editor', this.DefaultConfig); // 初始化UE
this.editor.addListener("ready", function() {
if (that.defaultMsg == null) {
that.editor.setContent('');
} else {
that.editor.setContent(that.defaultMsg);
}
});
this.editor.addListener("contentChange", function() { //监听内容变化
that.getUEContent();
})
},
getUEContent() { // 获取内容方法
let content = this.editor.getContent();
// console.log(content)
content = content.replace(/<p([\s\S]*?)<\/p>/g, "<div$1</div>")
this.$emit("getUEContent", content)
}
},
destroyed() {
this.editor.destroy();
}
}
</script>
<style>
.ueditor {
line-height: normal;
}
</style>