2
2
<div class =" quillWrapper" >
3
3
<slot name =" toolbar" ></slot >
4
4
<div :id =" id" ref =" quillContainer" ></div >
5
- <input
5
+ <!-- < input
6
6
v-if="useCustomImageHandler"
7
7
id="file-upload"
8
8
ref="fileInput"
9
9
type="file"
10
10
accept="image/*"
11
11
style="display:none;"
12
12
@change="emitImageInfo($event)"
13
- />
13
+ /> -->
14
14
</div >
15
15
</template >
16
16
17
17
<script >
18
+ // import Quill from 'quill'
18
19
import Vue from " vue" ;
19
20
import defaultToolbar from " @/helpers/default-toolbar" ;
20
21
import oldApi from " @/helpers/old-api" ;
21
22
import mergeDeep from " @/helpers/merge-deep" ;
22
- // import MarkdownShortcuts from " @/helpers/markdown-shortcuts";
23
+ // import MarkdownShortcuts from ' @/helpers/markdown-shortcuts'
23
24
24
25
let Quill;
25
26
let MarkdownShortcuts;
27
+ // if (!Vue.prototype.$isServer) Quill = require('quill')
26
28
if (! Vue .prototype .$isServer ) {
27
- console .log (" NOT SERVER" );
28
-
29
29
Quill = require (" quill" );
30
30
MarkdownShortcuts = require (" @/helpers/markdown-shortcuts" );
31
31
}
32
32
33
33
export default {
34
- name: " VueEditor" ,
35
34
mixins: [oldApi],
36
35
props: {
37
36
id: {
@@ -74,6 +73,7 @@ export default {
74
73
75
74
watch: {
76
75
value (val ) {
76
+ // eslint-disable-next-line eqeqeq
77
77
if (val != this .quill .root .innerHTML && ! this .quill .hasFocus ()) {
78
78
this .quill .root .innerHTML = val;
79
79
}
@@ -84,11 +84,12 @@ export default {
84
84
},
85
85
86
86
mounted () {
87
- this .$parent .$once (" hook:mounted" , () => {
88
- console .log (" in mounted hook" );
87
+ // this.$parent.$once('hook:mounted', () => {
88
+ // // eslint-disable-next-line no-console
89
+ // console.log('in mounted hook')
89
90
90
- this .$parent .$forceUpdate ();
91
- });
91
+ // this.$parent.$forceUpdate()
92
+ // })
92
93
this .registerCustomModules (Quill);
93
94
this .registerPrototypes ();
94
95
this .initializeEditor ();
@@ -109,7 +110,7 @@ export default {
109
110
},
110
111
111
112
setupQuillEditor () {
112
- let editorConfig = {
113
+ const editorConfig = {
113
114
debug: false ,
114
115
modules: this .setModules (),
115
116
theme: " snow" ,
@@ -122,12 +123,12 @@ export default {
122
123
},
123
124
124
125
setModules () {
125
- let modules = {
126
+ const modules = {
126
127
toolbar: this .editorToolbar .length ? this .editorToolbar : defaultToolbar
127
128
};
128
129
if (this .useMarkdownShortcuts ) {
129
130
Quill .register (" modules/markdownShortcuts" , MarkdownShortcuts, true );
130
- modules[ " markdownShortcuts" ] = {};
131
+ modules . markdownShortcuts = {};
131
132
}
132
133
return modules;
133
134
},
@@ -154,7 +155,7 @@ export default {
154
155
return this .container .querySelector (" .ql-editor" ).innerHTML ;
155
156
};
156
157
Quill .prototype .getWordCount = function () {
157
- return this .container .querySelector (" .ql-editor" ).innerText .length ;
158
+ return this .container .querySelector (" .ql-editor" ).textContent .length ;
158
159
};
159
160
},
160
161
@@ -182,7 +183,7 @@ export default {
182
183
},
183
184
184
185
handleTextChange (delta , oldContents ) {
185
- let editorContent =
186
+ const editorContent =
186
187
this .quill .getHTML () === " <p><br></p>" ? " " : this .quill .getHTML ();
187
188
this .$emit (" input" , editorContent);
188
189
@@ -204,11 +205,12 @@ export default {
204
205
});
205
206
},
206
207
checkForCustomImageHandler () {
208
+ // eslint-disable-next-line no-unused-expressions
207
209
this .useCustomImageHandler === true ? this .setupCustomImageHandler () : " " ;
208
210
},
209
211
210
212
setupCustomImageHandler () {
211
- let toolbar = this .quill .getModule (" toolbar" );
213
+ const toolbar = this .quill .getModule (" toolbar" );
212
214
toolbar .addHandler (" image" , this .customImageHandler );
213
215
},
214
216
@@ -218,13 +220,13 @@ export default {
218
220
219
221
emitImageInfo ($event ) {
220
222
const resetUploader = function () {
221
- var uploader = document .getElementById (" file-upload" );
223
+ const uploader = document .getElementById (" file-upload" );
222
224
uploader .value = " " ;
223
225
};
224
- let file = $event .target .files [0 ];
225
- let Editor = this .quill ;
226
- let range = Editor .getSelection ();
227
- let cursorLocation = range .index ;
226
+ const file = $event .target .files [0 ];
227
+ const Editor = this .quill ;
228
+ const range = Editor .getSelection ();
229
+ const cursorLocation = range .index ;
228
230
this .$emit (" image-added" , file, Editor, cursorLocation, resetUploader);
229
231
this .$emit (" imageAdded" , file, Editor, cursorLocation, resetUploader);
230
232
}
@@ -233,4 +235,3 @@ export default {
233
235
</script >
234
236
235
237
<style src="quill/dist/quill.snow .css "></style >
236
- <style src="../assets/vue2-editor.scss " lang="scss"></style >
0 commit comments