7
7
8
8
<script >
9
9
import _Quill from " quill" ;
10
- const Quill = window .Quill || _Quill;
11
10
import defaultOptions from " ./helpers/default-options" ;
12
- import { objectAssignPolyfillHandler } from " ./helpers/polyfills.js" ;
11
+ import { objectAssignPolyfillHandler } from " ./helpers/polyfills" ;
12
+ import { configSettingsMerger } from " ./helpers/config-settings-merger" ;
13
+ import merge from " lodash.merge" ;
14
+
15
+ const Quill = window .Quill || _Quill;
13
16
14
17
export default {
15
18
name: " VueEditor" ,
@@ -25,11 +28,6 @@ export default {
25
28
type: Object ,
26
29
required: false ,
27
30
default : () => ({})
28
- },
29
- globalOptions: {
30
- type: Object ,
31
- required: false ,
32
- default : () => ({})
33
31
}
34
32
},
35
33
@@ -40,20 +38,16 @@ export default {
40
38
}),
41
39
42
40
mounted () {
41
+ console .log (this .config );
42
+ configSettingsMerger (this .defaultOptions , this .options );
43
43
this .registerPrototypes ();
44
44
this .initialize ();
45
45
},
46
46
47
47
methods: {
48
48
initialize () {
49
49
if (this .$el ) {
50
- this .config = Object .assign (
51
- {},
52
- this .defaultOptions ,
53
- this .globalOptions ,
54
- this .options
55
- );
56
-
50
+ this .config = Object .assign ({}, this .options );
57
51
this .quill = new Quill (this .$refs .editor , this .config );
58
52
this .handleInitialContent ();
59
53
this .registerEditorEventListeners ();
@@ -71,7 +65,7 @@ export default {
71
65
},
72
66
73
67
registerEditorEventListeners () {
74
- this .quill .on (' text-change' , this .handleTextChange )
68
+ this .quill .on (" text-change" , this .handleTextChange );
75
69
this .quill .on (" selection-change" , this .handleSelectionChange );
76
70
this .listenForEditorEvent (" text-change" );
77
71
this .listenForEditorEvent (" selection-change" );
@@ -85,7 +79,7 @@ export default {
85
79
},
86
80
87
81
handleInitialContent () {
88
- if (this .value ) this .quill .root .innerHTML = this .value ; // Set initial editor content
82
+ if (this .value ) this .quill .root .innerHTML = this .value ; // Set initial editor content
89
83
},
90
84
91
85
handleSelectionChange (range , oldRange ) {
@@ -94,7 +88,8 @@ export default {
94
88
},
95
89
96
90
handleTextChange () {
97
- let editorContent = this .quill .getHTML () === " <p><br></p>" ? " " : this .quill .getHTML ();
91
+ let editorContent =
92
+ this .quill .getHTML () === " <p><br></p>" ? " " : this .quill .getHTML ();
98
93
this .$emit (" input" , editorContent);
99
94
}
100
95
},
0 commit comments