Skip to content

Commit a29cf79

Browse files
committed
feat: wang editor
1 parent 5815379 commit a29cf79

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"vue-ls": "^3.2.0",
3232
"vue-router": "^3.0.1",
3333
"vue-svg-component-runtime": "^1.0.1",
34-
"vuex": "^3.1.0"
34+
"vuex": "^3.1.0",
35+
"wangeditor": "^3.1.1"
3536
},
3637
"devDependencies": {
3738
"@babel/polyfill": "^7.2.5",

src/components/Editor/WangEditor.vue

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<template>
2+
<div :class="prefixCls">
3+
<div ref="editor" class="editor-wrapper"></div>
4+
</div>
5+
</template>
6+
7+
<script>
8+
import WEditor from 'wangeditor'
9+
10+
export default {
11+
name: 'WangEditor',
12+
props: {
13+
prefixCls: {
14+
type: String,
15+
default: 'ant-editor-wang'
16+
},
17+
// eslint-disable-next-line
18+
value: {
19+
type: String
20+
}
21+
},
22+
data () {
23+
return {
24+
editor: null,
25+
editorContent: null
26+
}
27+
},
28+
watch: {
29+
value (val) {
30+
this.editorContent = val
31+
this.editor.txt.html(val)
32+
}
33+
},
34+
mounted () {
35+
this.initEditor()
36+
},
37+
methods: {
38+
initEditor () {
39+
this.editor = new WEditor(this.$refs.editor)
40+
// this.editor.onchangeTimeout = 200
41+
this.editor.customConfig.onchange = (html) => {
42+
this.editorContent = html
43+
this.$emit('change', this.editorContent)
44+
}
45+
this.editor.create()
46+
}
47+
}
48+
}
49+
</script>
50+
51+
<style lang="less" scoped>
52+
.ant-editor-wang {
53+
.editor-wrapper {
54+
text-align: left;
55+
}
56+
}
57+
</style>

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10548,6 +10548,11 @@ walker@~1.0.5:
1054810548
dependencies:
1054910549
makeerror "1.0.x"
1055010550

10551+
wangeditor@^3.1.1:
10552+
version "3.1.1"
10553+
resolved "https://registry.npm.taobao.org/wangeditor/download/wangeditor-3.1.1.tgz#fbd3c1d4976923c9edebb85b29d30b35512ad039"
10554+
integrity sha1-+9PB1JdpI8nt67hbKdMLNVEq0Dk=
10555+
1055110556
warning@^3.0.0:
1055210557
version "3.0.0"
1055310558
resolved "https://registry.yarnpkg.com/warning/-/warning-3.0.0.tgz#32e5377cb572de4ab04753bdf8821c01ed605b7c"

0 commit comments

Comments
 (0)