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