@vueup/vue-quill 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,385 +1,390 @@
1
1
  /*!
2
- * VueQuill @vueup/vue-quill v1.2.1
2
+ * VueQuill @vueup/vue-quill v1.3.0
3
3
  * https://vueup.github.io/vue-quill/
4
4
  *
5
- * Includes quill v1.3.7
5
+ * Includes quill v2.0.2 || >=2.0.4 <3
6
6
  * https://quilljs.com/
7
7
  *
8
8
  * Copyright (c) 2026 Ahmad Luthfi Masruri
9
9
  * Released under the MIT license
10
- * Date: 2026-06-01T03:41:54.233Z
10
+ * Date: 2026-06-01T10:26:31.645Z
11
11
  */
12
12
  import Quill from 'quill';
13
13
  export { default as Quill } from 'quill';
14
14
  import Delta from 'quill-delta';
15
15
  export { default as Delta } from 'quill-delta';
16
- import { defineComponent, onMounted, onBeforeUnmount, ref, watch, nextTick, h } from 'vue';
16
+ import { defineComponent, h, onMounted, onBeforeUnmount, ref, watch, nextTick } from 'vue';
17
17
 
18
- const toolbarOptions = {
19
- essential: [
20
- [{ header: [1, 2, 3, 4, 5, 6, false] }],
21
- ['bold', 'italic', 'underline'],
22
- [{ list: 'ordered' }, { list: 'bullet' }, { align: [] }],
23
- ['blockquote', 'code-block', 'link'],
24
- [{ color: [] }, 'clean'],
25
- ],
26
- minimal: [
27
- [{ header: 1 }, { header: 2 }],
28
- ['bold', 'italic', 'underline'],
29
- [{ list: 'ordered' }, { list: 'bullet' }, { align: [] }],
30
- ],
31
- full: [
32
- ['bold', 'italic', 'underline', 'strike'],
33
- ['blockquote', 'code-block'],
34
- [{ header: 1 }, { header: 2 }],
35
- [{ list: 'ordered' }, { list: 'bullet' }],
36
- [{ script: 'sub' }, { script: 'super' }],
37
- [{ indent: '-1' }, { indent: '+1' }],
38
- [{ direction: 'rtl' }],
39
- [{ size: ['small', false, 'large', 'huge'] }],
40
- [{ header: [1, 2, 3, 4, 5, 6, false] }],
41
- [{ color: [] }, { background: [] }],
42
- [{ font: [] }],
43
- [{ align: [] }],
44
- ['link', 'video', 'image'],
45
- ['clean'], // remove formatting button
46
- ],
18
+ const toolbarOptions = {
19
+ essential: [
20
+ [{ header: [1, 2, 3, 4, 5, 6, false] }],
21
+ ['bold', 'italic', 'underline'],
22
+ [{ list: 'ordered' }, { list: 'bullet' }, { align: [] }],
23
+ ['blockquote', 'code-block', 'link'],
24
+ [{ color: [] }, 'clean'],
25
+ ],
26
+ minimal: [
27
+ [{ header: 1 }, { header: 2 }],
28
+ ['bold', 'italic', 'underline'],
29
+ [{ list: 'ordered' }, { list: 'bullet' }, { align: [] }],
30
+ ],
31
+ full: [
32
+ ['bold', 'italic', 'underline', 'strike'], // toggled buttons
33
+ ['blockquote', 'code-block'],
34
+ [{ header: 1 }, { header: 2 }], // custom button values
35
+ [{ list: 'ordered' }, { list: 'bullet' }],
36
+ [{ script: 'sub' }, { script: 'super' }], // superscript/subscript
37
+ [{ indent: '-1' }, { indent: '+1' }], // outdent/indent
38
+ [{ direction: 'rtl' }], // text direction
39
+ [{ size: ['small', false, 'large', 'huge'] }], // custom dropdown
40
+ [{ header: [1, 2, 3, 4, 5, 6, false] }],
41
+ [{ color: [] }, { background: [] }], // dropdown with defaults from theme
42
+ [{ font: [] }],
43
+ [{ align: [] }],
44
+ ['link', 'video', 'image'],
45
+ ['clean'], // remove formatting button
46
+ ],
47
47
  };
48
48
 
49
- const QuillEditor = defineComponent({
50
- name: 'QuillEditor',
51
- inheritAttrs: false,
52
- props: {
53
- content: {
54
- type: [String, Object],
55
- },
56
- contentType: {
57
- type: String,
58
- default: 'delta',
59
- validator: (value) => {
60
- return ['delta', 'html', 'text'].includes(value);
61
- },
62
- },
63
- enable: {
64
- type: Boolean,
65
- default: true,
66
- },
67
- readOnly: {
68
- type: Boolean,
69
- default: false,
70
- },
71
- placeholder: {
72
- type: String,
73
- required: false,
74
- },
75
- theme: {
76
- type: String,
77
- default: 'snow',
78
- validator: (value) => {
79
- return ['snow', 'bubble', ''].includes(value);
80
- },
81
- },
82
- toolbar: {
83
- type: [String, Array, Object],
84
- required: false,
85
- validator: (value) => {
86
- if (typeof value === 'string' && value !== '') {
87
- return value.charAt(0) === '#'
88
- ? true
89
- : Object.keys(toolbarOptions).indexOf(value) !== -1;
90
- }
91
- return true;
92
- },
93
- },
94
- modules: {
95
- type: Object,
96
- required: false,
97
- },
98
- options: {
99
- type: Object,
100
- required: false,
101
- },
102
- globalOptions: {
103
- type: Object,
104
- required: false,
105
- },
106
- },
107
- emits: [
108
- 'textChange',
109
- 'selectionChange',
110
- 'editorChange',
111
- 'update:content',
112
- 'focus',
113
- 'blur',
114
- 'ready',
115
- ],
116
- setup: (props, ctx) => {
117
- onMounted(() => {
118
- initialize();
119
- });
120
- onBeforeUnmount(() => {
121
- quill = null;
122
- });
123
- let quill;
124
- let options;
125
- const editor = ref();
126
- // Register Module if not already registered
127
- const registerModule = (moduleName, module) => {
128
- const quillImports = Quill.imports;
129
- if (quillImports && moduleName in quillImports) {
130
- return;
131
- }
132
- Quill.register(moduleName, module);
133
- };
134
- // Initialize Quill
135
- const initialize = () => {
136
- var _a;
137
- if (!editor.value)
138
- return;
139
- options = composeOptions();
140
- // Register modules
141
- if (props.modules) {
142
- if (Array.isArray(props.modules)) {
143
- for (const module of props.modules) {
144
- registerModule(`modules/${module.name}`, module.module);
145
- }
146
- }
147
- else {
148
- registerModule(`modules/${props.modules.name}`, props.modules.module);
149
- }
150
- }
151
- // Create new Quill instance
152
- quill = new Quill(editor.value, options);
153
- // Set editor content
154
- setContents(props.content);
155
- // Set event handlers
156
- quill.on('text-change', handleTextChange);
157
- quill.on('selection-change', handleSelectionChange);
158
- quill.on('editor-change', handleEditorChange);
159
- // Remove editor class when theme changes
160
- if (props.theme !== 'bubble')
161
- editor.value.classList.remove('ql-bubble');
162
- if (props.theme !== 'snow')
163
- editor.value.classList.remove('ql-snow');
164
- // Fix clicking the quill toolbar is detected as blur event
165
- (_a = quill
166
- .getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container.addEventListener('mousedown', (e) => {
167
- e.preventDefault();
168
- });
169
- // Emit ready event
170
- ctx.emit('ready', quill);
171
- };
172
- // Compose Options
173
- const composeOptions = () => {
174
- const clientOptions = {};
175
- if (props.theme !== '')
176
- clientOptions.theme = props.theme;
177
- if (props.readOnly)
178
- clientOptions.readOnly = props.readOnly;
179
- if (props.placeholder)
180
- clientOptions.placeholder = props.placeholder;
181
- if (props.toolbar && props.toolbar !== '') {
182
- clientOptions.modules = {
183
- toolbar: (() => {
184
- if (typeof props.toolbar === 'object') {
185
- return props.toolbar;
186
- }
187
- else if (typeof props.toolbar === 'string') {
188
- const str = props.toolbar;
189
- return str.charAt(0) === '#'
190
- ? props.toolbar
191
- : toolbarOptions[props.toolbar];
192
- }
193
- return;
194
- })(),
195
- };
196
- }
197
- if (props.modules) {
198
- const modules = (() => {
199
- var _a, _b;
200
- const modulesOption = {};
201
- if (Array.isArray(props.modules)) {
202
- for (const module of props.modules) {
203
- modulesOption[module.name] = (_a = module.options) !== null && _a !== void 0 ? _a : {};
204
- }
205
- }
206
- else {
207
- modulesOption[props.modules.name] = (_b = props.modules.options) !== null && _b !== void 0 ? _b : {};
208
- }
209
- return modulesOption;
210
- })();
211
- clientOptions.modules = Object.assign({}, clientOptions.modules, modules);
212
- }
213
- return Object.assign({}, props.globalOptions, props.options, clientOptions);
214
- };
215
- const maybeClone = (delta) => {
216
- return typeof delta === 'object' && delta ? delta.slice() : delta;
217
- };
218
- const deltaHasValuesOtherThanRetain = (delta) => {
219
- return Object.values(delta.ops).some((v) => !v.retain || Object.keys(v).length !== 1);
220
- };
221
- // Doesn't need reactivity, but does need to be cloned to avoid deep mutations always registering as equal
222
- let internalModel;
223
- const internalModelEquals = (against) => {
224
- if (typeof internalModel === typeof against) {
225
- if (against === internalModel) {
226
- return true;
227
- }
228
- // Ref/Proxy does not support instanceof, so do a loose check
229
- if (typeof against === 'object' &&
230
- against &&
231
- typeof internalModel === 'object' &&
232
- internalModel) {
233
- return !deltaHasValuesOtherThanRetain(internalModel.diff(against));
234
- }
235
- }
236
- return false;
237
- };
238
- const handleTextChange = (delta, oldContents, source) => {
239
- internalModel = maybeClone(getContents());
240
- // Update v-model:content when text changes
241
- if (!internalModelEquals(props.content)) {
242
- ctx.emit('update:content', internalModel);
243
- }
244
- ctx.emit('textChange', { delta, oldContents, source });
245
- };
246
- const isEditorFocus = ref();
247
- const handleSelectionChange = (range, oldRange, source) => {
248
- // Set isEditorFocus if quill.hasFocus()
249
- isEditorFocus.value = !!(quill === null || quill === void 0 ? void 0 : quill.hasFocus());
250
- ctx.emit('selectionChange', { range, oldRange, source });
251
- };
252
- watch(isEditorFocus, (focus) => {
253
- if (focus)
254
- ctx.emit('focus', editor);
255
- else
256
- ctx.emit('blur', editor);
257
- });
258
- const handleEditorChange = (...args) => {
259
- if (args[0] === 'text-change')
260
- ctx.emit('editorChange', {
261
- name: args[0],
262
- delta: args[1],
263
- oldContents: args[2],
264
- source: args[3],
265
- });
266
- if (args[0] === 'selection-change')
267
- ctx.emit('editorChange', {
268
- name: args[0],
269
- range: args[1],
270
- oldRange: args[2],
271
- source: args[3],
272
- });
273
- };
274
- const getEditor = () => {
275
- return editor.value;
276
- };
277
- const getToolbar = () => {
278
- var _a;
279
- return (_a = quill === null || quill === void 0 ? void 0 : quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container;
280
- };
281
- const getQuill = () => {
282
- if (quill)
283
- return quill;
284
- else
49
+ const QuillEditor = defineComponent({
50
+ name: 'QuillEditor',
51
+ inheritAttrs: false,
52
+ props: {
53
+ content: {
54
+ type: [String, Object],
55
+ },
56
+ contentType: {
57
+ type: String,
58
+ default: 'delta',
59
+ validator: (value) => {
60
+ return ['delta', 'html', 'text'].includes(value);
61
+ },
62
+ },
63
+ enable: {
64
+ type: Boolean,
65
+ default: true,
66
+ },
67
+ readOnly: {
68
+ type: Boolean,
69
+ default: false,
70
+ },
71
+ placeholder: {
72
+ type: String,
73
+ required: false,
74
+ },
75
+ theme: {
76
+ type: String,
77
+ default: 'snow',
78
+ validator: (value) => {
79
+ return ['snow', 'bubble', ''].includes(value);
80
+ },
81
+ },
82
+ toolbar: {
83
+ type: [String, Array, Object],
84
+ required: false,
85
+ validator: (value) => {
86
+ if (typeof value === 'string' && value !== '') {
87
+ return value.charAt(0) === '#'
88
+ ? true
89
+ : Object.keys(toolbarOptions).indexOf(value) !== -1;
90
+ }
91
+ return true;
92
+ },
93
+ },
94
+ modules: {
95
+ type: Object,
96
+ required: false,
97
+ },
98
+ options: {
99
+ type: Object,
100
+ required: false,
101
+ },
102
+ globalOptions: {
103
+ type: Object,
104
+ required: false,
105
+ },
106
+ },
107
+ emits: [
108
+ 'textChange',
109
+ 'selectionChange',
110
+ 'editorChange',
111
+ 'update:content',
112
+ 'focus',
113
+ 'blur',
114
+ 'ready',
115
+ ],
116
+ setup: (props, ctx) => {
117
+ onMounted(() => {
118
+ initialize();
119
+ });
120
+ onBeforeUnmount(() => {
121
+ quill = null;
122
+ });
123
+ let quill;
124
+ let options;
125
+ const editor = ref();
126
+ // Register Module if not already registered
127
+ const registerModule = (moduleName, module) => {
128
+ const quillImports = Quill.imports;
129
+ if (quillImports && moduleName in quillImports) {
130
+ return;
131
+ }
132
+ Quill.register(moduleName, module);
133
+ };
134
+ // Initialize Quill
135
+ const initialize = () => {
136
+ var _a, _b;
137
+ if (!editor.value)
138
+ return;
139
+ options = composeOptions();
140
+ // Register modules
141
+ if (props.modules) {
142
+ if (Array.isArray(props.modules)) {
143
+ for (const module of props.modules) {
144
+ registerModule(`modules/${module.name}`, module.module);
145
+ }
146
+ }
147
+ else {
148
+ registerModule(`modules/${props.modules.name}`, props.modules.module);
149
+ }
150
+ }
151
+ // Create new Quill instance
152
+ quill = new Quill(editor.value, options);
153
+ // Set editor content
154
+ setContents(props.content);
155
+ // Set event handlers
156
+ quill.on('text-change', handleTextChange);
157
+ quill.on('selection-change', handleSelectionChange);
158
+ quill.on('editor-change', handleEditorChange);
159
+ // Remove editor class when theme changes
160
+ if (props.theme !== 'bubble')
161
+ editor.value.classList.remove('ql-bubble');
162
+ if (props.theme !== 'snow')
163
+ editor.value.classList.remove('ql-snow');
164
+ // Fix clicking the quill toolbar is detected as blur event
165
+ (_b = (_a = getToolbarModule()) === null || _a === void 0 ? void 0 : _a.container) === null || _b === void 0 ? void 0 : _b.addEventListener('mousedown', (e) => {
166
+ e.preventDefault();
167
+ });
168
+ // Emit ready event
169
+ ctx.emit('ready', quill);
170
+ };
171
+ // Compose Options
172
+ const composeOptions = () => {
173
+ const clientOptions = {};
174
+ if (props.theme !== '')
175
+ clientOptions.theme = props.theme;
176
+ if (props.readOnly)
177
+ clientOptions.readOnly = props.readOnly;
178
+ if (props.placeholder)
179
+ clientOptions.placeholder = props.placeholder;
180
+ if (props.toolbar && props.toolbar !== '') {
181
+ clientOptions.modules = {
182
+ toolbar: (() => {
183
+ if (typeof props.toolbar === 'object') {
184
+ return props.toolbar;
185
+ }
186
+ else if (typeof props.toolbar === 'string') {
187
+ const str = props.toolbar;
188
+ return str.charAt(0) === '#'
189
+ ? props.toolbar
190
+ : toolbarOptions[props.toolbar];
191
+ }
192
+ return;
193
+ })(),
194
+ };
195
+ }
196
+ if (props.modules) {
197
+ const modules = (() => {
198
+ var _a, _b;
199
+ const modulesOption = {};
200
+ if (Array.isArray(props.modules)) {
201
+ for (const module of props.modules) {
202
+ modulesOption[module.name] = (_a = module.options) !== null && _a !== void 0 ? _a : {};
203
+ }
204
+ }
205
+ else {
206
+ modulesOption[props.modules.name] = (_b = props.modules.options) !== null && _b !== void 0 ? _b : {};
207
+ }
208
+ return modulesOption;
209
+ })();
210
+ clientOptions.modules = Object.assign({}, clientOptions.modules, modules);
211
+ }
212
+ return Object.assign({}, props.globalOptions, props.options, clientOptions);
213
+ };
214
+ const maybeClone = (delta) => {
215
+ return typeof delta === 'object' && delta ? delta.slice() : delta;
216
+ };
217
+ const getToolbarModule = () => {
218
+ return quill === null || quill === void 0 ? void 0 : quill.getModule('toolbar');
219
+ };
220
+ const deltaHasValuesOtherThanRetain = (delta) => {
221
+ return Object.values(delta.ops).some((v) => !v.retain || Object.keys(v).length !== 1);
222
+ };
223
+ // Doesn't need reactivity, but does need to be cloned to avoid deep mutations always registering as equal
224
+ let internalModel;
225
+ const internalModelEquals = (against) => {
226
+ if (typeof internalModel === typeof against) {
227
+ if (against === internalModel) {
228
+ return true;
229
+ }
230
+ // Ref/Proxy does not support instanceof, so do a loose check
231
+ if (typeof against === 'object' &&
232
+ against &&
233
+ typeof internalModel === 'object' &&
234
+ internalModel) {
235
+ return !deltaHasValuesOtherThanRetain(internalModel.diff(against));
236
+ }
237
+ }
238
+ return false;
239
+ };
240
+ const handleTextChange = (delta, oldContents, source) => {
241
+ internalModel = maybeClone(getContents());
242
+ // Update v-model:content when text changes
243
+ if (!internalModelEquals(props.content)) {
244
+ ctx.emit('update:content', internalModel);
245
+ }
246
+ ctx.emit('textChange', { delta, oldContents, source });
247
+ };
248
+ const isEditorFocus = ref();
249
+ const handleSelectionChange = (range, oldRange, source) => {
250
+ // Set isEditorFocus if quill.hasFocus()
251
+ isEditorFocus.value = !!(quill === null || quill === void 0 ? void 0 : quill.hasFocus());
252
+ ctx.emit('selectionChange', { range, oldRange, source });
253
+ };
254
+ watch(isEditorFocus, (focus) => {
255
+ // Focus and blur events document the editor ref as their payload.
256
+ // eslint-disable-next-line vue/no-ref-as-operand
257
+ if (focus)
258
+ ctx.emit('focus', editor);
259
+ // eslint-disable-next-line vue/no-ref-as-operand
260
+ else
261
+ ctx.emit('blur', editor);
262
+ });
263
+ const handleEditorChange = (...args) => {
264
+ if (args[0] === 'text-change')
265
+ ctx.emit('editorChange', {
266
+ name: args[0],
267
+ delta: args[1],
268
+ oldContents: args[2],
269
+ source: args[3],
270
+ });
271
+ if (args[0] === 'selection-change')
272
+ ctx.emit('editorChange', {
273
+ name: args[0],
274
+ range: args[1],
275
+ oldRange: args[2],
276
+ source: args[3],
277
+ });
278
+ };
279
+ const getEditor = () => {
280
+ return editor.value;
281
+ };
282
+ const getToolbar = () => {
283
+ var _a;
284
+ return (_a = getToolbarModule()) === null || _a === void 0 ? void 0 : _a.container;
285
+ };
286
+ const getQuill = () => {
287
+ if (quill)
288
+ return quill;
289
+ else
285
290
  throw `The quill editor hasn't been instantiated yet,
286
291
  make sure to call this method when the editor ready
287
- or use v-on:ready="onReady(quill)" event instead.`;
288
- };
289
- const getContents = (index, length) => {
290
- if (props.contentType === 'html') {
291
- return getHTML();
292
- }
293
- else if (props.contentType === 'text') {
294
- return getText(index, length);
295
- }
296
- return quill === null || quill === void 0 ? void 0 : quill.getContents(index, length);
297
- };
298
- const setContents = (content, source = 'api') => {
299
- const normalizedContent = !content
300
- ? props.contentType === 'delta'
301
- ? new Delta()
302
- : ''
303
- : content;
304
- if (props.contentType === 'html') {
305
- setHTML(normalizedContent);
306
- }
307
- else if (props.contentType === 'text') {
308
- setText(normalizedContent, source);
309
- }
310
- else {
311
- quill === null || quill === void 0 ? void 0 : quill.setContents(normalizedContent, source);
312
- }
313
- internalModel = maybeClone(normalizedContent);
314
- };
315
- const getText = (index, length) => {
316
- var _a;
317
- return (_a = quill === null || quill === void 0 ? void 0 : quill.getText(index, length)) !== null && _a !== void 0 ? _a : '';
318
- };
319
- const setText = (text, source = 'api') => {
320
- quill === null || quill === void 0 ? void 0 : quill.setText(text, source);
321
- };
322
- const getHTML = () => {
323
- var _a;
324
- return (_a = quill === null || quill === void 0 ? void 0 : quill.root.innerHTML) !== null && _a !== void 0 ? _a : '';
325
- };
326
- const setHTML = (html) => {
327
- if (quill)
328
- quill.root.innerHTML = html;
329
- };
330
- const pasteHTML = (html, source = 'api') => {
331
- const delta = quill === null || quill === void 0 ? void 0 : quill.clipboard.convert(html);
332
- if (delta)
333
- quill === null || quill === void 0 ? void 0 : quill.setContents(delta, source);
334
- };
335
- const focus = () => {
336
- quill === null || quill === void 0 ? void 0 : quill.focus();
337
- };
338
- const reinit = () => {
339
- nextTick(() => {
340
- var _a;
341
- if (!ctx.slots.toolbar && quill)
342
- (_a = quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container.remove();
343
- initialize();
344
- });
345
- };
346
- watch(() => props.content, (newContent) => {
347
- if (!quill || !newContent || internalModelEquals(newContent))
348
- return;
349
- // Restore the selection and cursor position after updating the content
350
- const selection = quill.getSelection();
351
- if (selection) {
352
- nextTick(() => quill === null || quill === void 0 ? void 0 : quill.setSelection(selection));
353
- }
354
- setContents(newContent);
355
- }, { deep: true });
356
- watch(() => props.enable, (newValue) => {
357
- if (quill)
358
- quill.enable(newValue);
359
- });
360
- return {
361
- editor,
362
- getEditor,
363
- getToolbar,
364
- getQuill,
365
- getContents,
366
- setContents,
367
- getHTML,
368
- setHTML,
369
- pasteHTML,
370
- focus,
371
- getText,
372
- setText,
373
- reinit,
374
- };
375
- },
376
- render() {
377
- var _a, _b;
378
- return [
379
- (_b = (_a = this.$slots).toolbar) === null || _b === void 0 ? void 0 : _b.call(_a),
380
- h('div', { ref: 'editor', ...this.$attrs }),
381
- ];
382
- },
292
+ or use v-on:ready="onReady(quill)" event instead.`;
293
+ };
294
+ const getContents = (index, length) => {
295
+ if (props.contentType === 'html') {
296
+ return getHTML();
297
+ }
298
+ else if (props.contentType === 'text') {
299
+ return getText(index, length);
300
+ }
301
+ return quill === null || quill === void 0 ? void 0 : quill.getContents(index, length);
302
+ };
303
+ const setContents = (content, source = 'api') => {
304
+ const normalizedContent = !content
305
+ ? props.contentType === 'delta'
306
+ ? new Delta()
307
+ : ''
308
+ : content;
309
+ if (props.contentType === 'html') {
310
+ setHTML(normalizedContent);
311
+ }
312
+ else if (props.contentType === 'text') {
313
+ setText(normalizedContent, source);
314
+ }
315
+ else {
316
+ quill === null || quill === void 0 ? void 0 : quill.setContents(normalizedContent, source);
317
+ }
318
+ internalModel = maybeClone(normalizedContent);
319
+ };
320
+ const getText = (index, length) => {
321
+ var _a;
322
+ return (_a = quill === null || quill === void 0 ? void 0 : quill.getText(index, length)) !== null && _a !== void 0 ? _a : '';
323
+ };
324
+ const setText = (text, source = 'api') => {
325
+ quill === null || quill === void 0 ? void 0 : quill.setText(text, source);
326
+ };
327
+ const getHTML = () => {
328
+ var _a;
329
+ return (_a = quill === null || quill === void 0 ? void 0 : quill.root.innerHTML) !== null && _a !== void 0 ? _a : '';
330
+ };
331
+ const setHTML = (html) => {
332
+ if (quill)
333
+ quill.root.innerHTML = html;
334
+ };
335
+ const pasteHTML = (html, source = 'api') => {
336
+ const delta = quill === null || quill === void 0 ? void 0 : quill.clipboard.convert({ html });
337
+ if (delta)
338
+ quill === null || quill === void 0 ? void 0 : quill.setContents(delta, source);
339
+ };
340
+ const focus = () => {
341
+ quill === null || quill === void 0 ? void 0 : quill.focus();
342
+ };
343
+ const reinit = () => {
344
+ nextTick(() => {
345
+ var _a, _b;
346
+ if (!ctx.slots.toolbar && quill)
347
+ (_b = (_a = getToolbarModule()) === null || _a === void 0 ? void 0 : _a.container) === null || _b === void 0 ? void 0 : _b.remove();
348
+ initialize();
349
+ });
350
+ };
351
+ watch(() => props.content, (newContent) => {
352
+ if (!quill || !newContent || internalModelEquals(newContent))
353
+ return;
354
+ // Restore the selection and cursor position after updating the content
355
+ const selection = quill.getSelection();
356
+ if (selection) {
357
+ nextTick(() => quill === null || quill === void 0 ? void 0 : quill.setSelection(selection));
358
+ }
359
+ setContents(newContent);
360
+ }, { deep: true });
361
+ watch(() => props.enable, (newValue) => {
362
+ if (quill)
363
+ quill.enable(newValue);
364
+ });
365
+ return {
366
+ editor,
367
+ getEditor,
368
+ getToolbar,
369
+ getQuill,
370
+ getContents,
371
+ setContents,
372
+ getHTML,
373
+ setHTML,
374
+ pasteHTML,
375
+ focus,
376
+ getText,
377
+ setText,
378
+ reinit,
379
+ };
380
+ },
381
+ render() {
382
+ var _a, _b;
383
+ return [
384
+ (_b = (_a = this.$slots).toolbar) === null || _b === void 0 ? void 0 : _b.call(_a),
385
+ h('div', { ref: 'editor', ...this.$attrs }),
386
+ ];
387
+ },
383
388
  });
384
389
 
385
390
  export { QuillEditor };