Skip to content

Commit 76d473c

Browse files
committed
feat: add quill editor
1 parent a29cf79 commit 76d473c

File tree

3 files changed

+128
-1
lines changed

3 files changed

+128
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"vue-clipboard2": "^0.2.1",
3030
"vue-cropper": "0.4.4",
3131
"vue-ls": "^3.2.0",
32+
"vue-quill-editor": "^3.0.6",
3233
"vue-router": "^3.0.1",
3334
"vue-svg-component-runtime": "^1.0.1",
3435
"vuex": "^3.1.0",

src/components/Editor/QuillEditor.vue

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<template>
2+
<div :class="prefixCls">
3+
<quill-editor
4+
v-model="content"
5+
ref="myQuillEditor"
6+
:options="editorOption"
7+
@blur="onEditorBlur($event)"
8+
@focus="onEditorFocus($event)"
9+
@ready="onEditorReady($event)"
10+
@change="onEditorChange($event)">
11+
</quill-editor>
12+
13+
</div>
14+
</template>
15+
16+
<script>
17+
import 'quill/dist/quill.core.css'
18+
import 'quill/dist/quill.snow.css'
19+
import 'quill/dist/quill.bubble.css'
20+
21+
import { quillEditor } from 'vue-quill-editor'
22+
23+
export default {
24+
name: 'QuillEditor',
25+
components: {
26+
quillEditor
27+
},
28+
props: {
29+
prefixCls: {
30+
type: String,
31+
default: 'ant-editor-quill'
32+
},
33+
// 表单校验用字段
34+
// eslint-disable-next-line
35+
value: {
36+
type: String
37+
}
38+
},
39+
data () {
40+
return {
41+
content: null,
42+
editorOption: {
43+
// some quill options
44+
}
45+
}
46+
},
47+
methods: {
48+
onEditorBlur (quill) {
49+
console.log('editor blur!', quill)
50+
},
51+
onEditorFocus (quill) {
52+
console.log('editor focus!', quill)
53+
},
54+
onEditorReady (quill) {
55+
console.log('editor ready!', quill)
56+
},
57+
onEditorChange ({ quill, html, text }) {
58+
console.log('editor change!', quill, html, text)
59+
this.$emit('change', html)
60+
}
61+
},
62+
watch: {
63+
value (val) {
64+
this.content = val
65+
}
66+
}
67+
}
68+
</script>
69+
70+
<style lang="less" scoped>
71+
@import url('../index.less');
72+
73+
/* 覆盖 quill 默认边框圆角为 ant 默认圆角,用于统一 ant 组件风格 */
74+
.ant-editor-quill {
75+
/deep/ .ql-toolbar.ql-snow {
76+
border-radius: @border-radius-base @border-radius-base 0 0;
77+
}
78+
/deep/ .ql-container.ql-snow {
79+
border-radius: 0 0 @border-radius-base @border-radius-base;
80+
}
81+
}
82+
</style>

yarn.lock

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4338,6 +4338,11 @@ event-pubsub@4.3.0:
43384338
resolved "https://registry.yarnpkg.com/event-pubsub/-/event-pubsub-4.3.0.tgz#f68d816bc29f1ec02c539dc58c8dd40ce72cb36e"
43394339
integrity sha512-z7IyloorXvKbFx9Bpie2+vMJKKx1fH1EN5yiTfp8CiLOTptSYy1g8H4yDpGlEdshL1PBiFtBHepF2cNsqeEeFQ==
43404340

4341+
eventemitter3@^2.0.3:
4342+
version "2.0.3"
4343+
resolved "https://registry.npm.taobao.org/eventemitter3/download/eventemitter3-2.0.3.tgz#b5e1079b59fb5e1ba2771c0a993be060a58c99ba"
4344+
integrity sha1-teEHm1n7XhuidxwKmTvgYKWMmbo=
4345+
43414346
eventemitter3@^3.0.0:
43424347
version "3.1.0"
43434348
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.0.tgz#090b4d6cdbd645ed10bf750d4b5407942d7ba163"
@@ -4504,7 +4509,7 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2:
45044509
assign-symbols "^1.0.0"
45054510
is-extendable "^1.0.1"
45064511

4507-
extend@~3.0.2:
4512+
extend@^3.0.1, extend@^3.0.2, extend@~3.0.2:
45084513
version "3.0.2"
45094514
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa"
45104515
integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==
@@ -4575,6 +4580,11 @@ fast-deep-equal@^2.0.1:
45754580
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"
45764581
integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=
45774582

4583+
fast-diff@1.1.2:
4584+
version "1.1.2"
4585+
resolved "https://registry.npm.taobao.org/fast-diff/download/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154"
4586+
integrity sha1-S2LEK44D3j+EhGC2OQeZIGldAVQ=
4587+
45784588
fast-glob@^2.2.6:
45794589
version "2.2.6"
45804590
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.6.tgz#a5d5b697ec8deda468d85a74035290a025a95295"
@@ -7823,6 +7833,11 @@ param-case@2.1.x:
78237833
dependencies:
78247834
no-case "^2.2.0"
78257835

7836+
parchment@^1.1.4:
7837+
version "1.1.4"
7838+
resolved "https://registry.npm.taobao.org/parchment/download/parchment-1.1.4.tgz#aeded7ab938fe921d4c34bc339ce1168bc2ffde5"
7839+
integrity sha1-rt7Xq5OP6SHUw0vDOc4RaLwv/eU=
7840+
78267841
parent-module@^1.0.0:
78277842
version "1.0.0"
78287843
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.0.tgz#df250bdc5391f4a085fb589dad761f5ad6b865b5"
@@ -8577,6 +8592,27 @@ querystringify@^2.0.0:
85778592
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.1.0.tgz#7ded8dfbf7879dcc60d0a644ac6754b283ad17ef"
85788593
integrity sha512-sluvZZ1YiTLD5jsqZcDmFyV2EwToyXZBfpoVOmktMmW+VEnhgakFHnasVph65fOjGPTWN0Nw3+XQaSeMayr0kg==
85798594

8595+
quill-delta@^3.6.2:
8596+
version "3.6.3"
8597+
resolved "https://registry.npm.taobao.org/quill-delta/download/quill-delta-3.6.3.tgz#b19fd2b89412301c60e1ff213d8d860eac0f1032"
8598+
integrity sha1-sZ/SuJQSMBxg4f8hPY2GDqwPEDI=
8599+
dependencies:
8600+
deep-equal "^1.0.1"
8601+
extend "^3.0.2"
8602+
fast-diff "1.1.2"
8603+
8604+
quill@^1.3.4:
8605+
version "1.3.6"
8606+
resolved "https://registry.npm.taobao.org/quill/download/quill-1.3.6.tgz#99f4de1fee85925a0d7d4163b6d8328f23317a4d"
8607+
integrity sha1-mfTeH+6FkloNfUFjttgyjyMxek0=
8608+
dependencies:
8609+
clone "^2.1.1"
8610+
deep-equal "^1.0.1"
8611+
eventemitter3 "^2.0.3"
8612+
extend "^3.0.1"
8613+
parchment "^1.1.4"
8614+
quill-delta "^3.6.2"
8615+
85808616
raf@^3.4.0:
85818617
version "3.4.1"
85828618
resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.1.tgz#0742e99a4a6552f445d73e3ee0328af0ff1ede39"
@@ -10473,6 +10509,14 @@ vue-ls@^3.2.0:
1047310509
resolved "https://registry.yarnpkg.com/vue-ls/-/vue-ls-3.2.1.tgz#25d1c75b3a51c17018129de607b44bb120a3385a"
1047410510
integrity sha512-JoZDpSu0qV5AM50vspEzOut2lcm8R0tr5WG99jMHh14qFXkUes3ZdmDMG/p8iSQVQpg0pd/svGwM9Nd7OI2oaw==
1047510511

10512+
vue-quill-editor@^3.0.6:
10513+
version "3.0.6"
10514+
resolved "https://registry.npm.taobao.org/vue-quill-editor/download/vue-quill-editor-3.0.6.tgz#1f85646211d68a31a80a72cb7f45bb2f119bc8fb"
10515+
integrity sha1-H4VkYhHWijGoCnLLf0W7LxGbyPs=
10516+
dependencies:
10517+
object-assign "^4.1.1"
10518+
quill "^1.3.4"
10519+
1047610520
vue-ref@^1.0.4:
1047710521
version "1.0.4"
1047810522
resolved "https://registry.yarnpkg.com/vue-ref/-/vue-ref-1.0.4.tgz#c27862b15a2720cff6b792566d824d1c3ac53320"

0 commit comments

Comments
 (0)