@vueup/vue-quill 1.3.0 → 1.4.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,5 +1,5 @@
1
1
  /*!
2
- * VueQuill @vueup/vue-quill v1.3.0
2
+ * VueQuill @vueup/vue-quill v1.4.0
3
3
  * https://vueup.github.io/vue-quill/
4
4
  *
5
5
  * Includes quill v2.0.2 || >=2.0.4 <3
@@ -7,11 +7,10 @@
7
7
  *
8
8
  * Copyright (c) 2026 Ahmad Luthfi Masruri
9
9
  * Released under the MIT license
10
- * Date: 2026-06-01T10:26:31.645Z
10
+ * Date: 2026-06-02T00:10:10.011Z
11
11
  */
12
12
  'use strict';
13
13
 
14
- var Quill = require('quill');
15
14
  var Delta = require('quill-delta');
16
15
  var vue = require('vue');
17
16
 
@@ -46,6 +45,58 @@ const toolbarOptions = {
46
45
  ],
47
46
  };
48
47
 
48
+ let loadedQuill;
49
+ let quillLoadPromise;
50
+ let pendingRegistrations = [];
51
+ const isBrowser = () => typeof document !== 'undefined';
52
+ const replayPendingRegistrations = (Quill) => {
53
+ const registrations = pendingRegistrations;
54
+ pendingRegistrations = [];
55
+ for (const args of registrations) {
56
+ Quill.register(...args);
57
+ }
58
+ };
59
+ const loadQuill = async () => {
60
+ if (loadedQuill)
61
+ return loadedQuill;
62
+ if (!isBrowser()) {
63
+ throw new Error('@vueup/vue-quill: Quill can only be loaded in a browser environment.');
64
+ }
65
+ quillLoadPromise !== null && quillLoadPromise !== void 0 ? quillLoadPromise : (quillLoadPromise = import('quill').then(({ default: Quill }) => {
66
+ loadedQuill = Quill;
67
+ replayPendingRegistrations(Quill);
68
+ return Quill;
69
+ }));
70
+ return quillLoadPromise;
71
+ };
72
+ const getLoadedQuill = () => loadedQuill;
73
+ const getQuillOrThrow = () => {
74
+ if (loadedQuill)
75
+ return loadedQuill;
76
+ throw new Error('@vueup/vue-quill: Quill is not loaded yet. Use loadQuill() in a browser-only lifecycle hook, or access the Quill instance from the ready event.');
77
+ };
78
+ const Quill = new Proxy(function QuillProxy() { }, {
79
+ get(_target, property) {
80
+ if (property === 'register') {
81
+ return (...args) => {
82
+ if (loadedQuill) {
83
+ return loadedQuill.register(...args);
84
+ }
85
+ pendingRegistrations.push(args);
86
+ if (isBrowser())
87
+ void loadQuill();
88
+ };
89
+ }
90
+ const Quill = getQuillOrThrow();
91
+ const value = Quill[property];
92
+ return typeof value === 'function' ? value.bind(Quill) : value;
93
+ },
94
+ construct(_target, args) {
95
+ const Quill = getQuillOrThrow();
96
+ return new Quill(...args);
97
+ },
98
+ });
99
+
49
100
  const QuillEditor = vue.defineComponent({
50
101
  name: 'QuillEditor',
51
102
  inheritAttrs: false,
@@ -115,16 +166,19 @@ const QuillEditor = vue.defineComponent({
115
166
  ],
116
167
  setup: (props, ctx) => {
117
168
  vue.onMounted(() => {
118
- initialize();
169
+ isUnmounted = false;
170
+ void initialize();
119
171
  });
120
172
  vue.onBeforeUnmount(() => {
121
173
  quill = null;
174
+ isUnmounted = true;
122
175
  });
176
+ let isUnmounted = false;
123
177
  let quill;
124
178
  let options;
125
179
  const editor = vue.ref();
126
180
  // Register Module if not already registered
127
- const registerModule = (moduleName, module) => {
181
+ const registerModule = (Quill, moduleName, module) => {
128
182
  const quillImports = Quill.imports;
129
183
  if (quillImports && moduleName in quillImports) {
130
184
  return;
@@ -132,20 +186,24 @@ const QuillEditor = vue.defineComponent({
132
186
  Quill.register(moduleName, module);
133
187
  };
134
188
  // Initialize Quill
135
- const initialize = () => {
189
+ const initialize = async () => {
136
190
  var _a, _b;
137
191
  if (!editor.value)
138
192
  return;
193
+ const editorElement = editor.value;
194
+ const Quill = await loadQuill();
195
+ if (isUnmounted || !editor.value || editor.value !== editorElement)
196
+ return;
139
197
  options = composeOptions();
140
198
  // Register modules
141
199
  if (props.modules) {
142
200
  if (Array.isArray(props.modules)) {
143
201
  for (const module of props.modules) {
144
- registerModule(`modules/${module.name}`, module.module);
202
+ registerModule(Quill, `modules/${module.name}`, module.module);
145
203
  }
146
204
  }
147
205
  else {
148
- registerModule(`modules/${props.modules.name}`, props.modules.module);
206
+ registerModule(Quill, `modules/${props.modules.name}`, props.modules.module);
149
207
  }
150
208
  }
151
209
  // Create new Quill instance
@@ -345,7 +403,7 @@ const QuillEditor = vue.defineComponent({
345
403
  var _a, _b;
346
404
  if (!ctx.slots.toolbar && quill)
347
405
  (_b = (_a = getToolbarModule()) === null || _a === void 0 ? void 0 : _a.container) === null || _b === void 0 ? void 0 : _b.remove();
348
- initialize();
406
+ void initialize();
349
407
  });
350
408
  };
351
409
  vue.watch(() => props.content, (newContent) => {
@@ -387,6 +445,8 @@ const QuillEditor = vue.defineComponent({
387
445
  },
388
446
  });
389
447
 
390
- exports.Quill = Quill;
391
448
  exports.Delta = Delta;
449
+ exports.Quill = Quill;
392
450
  exports.QuillEditor = QuillEditor;
451
+ exports.getLoadedQuill = getLoadedQuill;
452
+ exports.loadQuill = loadQuill;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * VueQuill @vueup/vue-quill v1.3.0
2
+ * VueQuill @vueup/vue-quill v1.4.0
3
3
  * https://vueup.github.io/vue-quill/
4
4
  *
5
5
  * Includes quill v2.0.2 || >=2.0.4 <3
@@ -7,6 +7,6 @@
7
7
  *
8
8
  * Copyright (c) 2026 Ahmad Luthfi Masruri
9
9
  * Released under the MIT license
10
- * Date: 2026-06-01T10:26:31.645Z
10
+ * Date: 2026-06-02T00:10:10.011Z
11
11
  */
12
- "use strict";var e=require("quill"),t=require("quill-delta"),o=require("vue");const l={essential:[[{header:[1,2,3,4,5,6,!1]}],["bold","italic","underline"],[{list:"ordered"},{list:"bullet"},{align:[]}],["blockquote","code-block","link"],[{color:[]},"clean"]],minimal:[[{header:1},{header:2}],["bold","italic","underline"],[{list:"ordered"},{list:"bullet"},{align:[]}]],full:[["bold","italic","underline","strike"],["blockquote","code-block"],[{header:1},{header:2}],[{list:"ordered"},{list:"bullet"}],[{script:"sub"},{script:"super"}],[{indent:"-1"},{indent:"+1"}],[{direction:"rtl"}],[{size:["small",!1,"large","huge"]}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{font:[]}],[{align:[]}],["link","video","image"],["clean"]]},n=o.defineComponent({name:"QuillEditor",inheritAttrs:!1,props:{content:{type:[String,Object]},contentType:{type:String,default:"delta",validator:e=>["delta","html","text"].includes(e)},enable:{type:Boolean,default:!0},readOnly:{type:Boolean,default:!1},placeholder:{type:String,required:!1},theme:{type:String,default:"snow",validator:e=>["snow","bubble",""].includes(e)},toolbar:{type:[String,Array,Object],required:!1,validator:e=>"string"!=typeof e||""===e||("#"===e.charAt(0)||-1!==Object.keys(l).indexOf(e))},modules:{type:Object,required:!1},options:{type:Object,required:!1},globalOptions:{type:Object,required:!1}},emits:["textChange","selectionChange","editorChange","update:content","focus","blur","ready"],setup:(n,r)=>{let i,a;o.onMounted(()=>{u()}),o.onBeforeUnmount(()=>{i=null});const s=o.ref(),d=(t,o)=>{const l=e.imports;l&&t in l||e.register(t,o)},u=()=>{var t,o;if(s.value){if(a=c(),n.modules)if(Array.isArray(n.modules))for(const e of n.modules)d(`modules/${e.name}`,e.module);else d(`modules/${n.modules.name}`,n.modules.module);i=new e(s.value,a),x(n.content),i.on("text-change",v),i.on("selection-change",f),i.on("editor-change",y),"bubble"!==n.theme&&s.value.classList.remove("ql-bubble"),"snow"!==n.theme&&s.value.classList.remove("ql-snow"),null===(o=null===(t=m())||void 0===t?void 0:t.container)||void 0===o||o.addEventListener("mousedown",e=>{e.preventDefault()}),r.emit("ready",i)}},c=()=>{const e={};if(""!==n.theme&&(e.theme=n.theme),n.readOnly&&(e.readOnly=n.readOnly),n.placeholder&&(e.placeholder=n.placeholder),n.toolbar&&""!==n.toolbar&&(e.modules={toolbar:(()=>{if("object"==typeof n.toolbar)return n.toolbar;if("string"==typeof n.toolbar){return"#"===n.toolbar.charAt(0)?n.toolbar:l[n.toolbar]}})()}),n.modules){const t=(()=>{var e,t;const o={};if(Array.isArray(n.modules))for(const l of n.modules)o[l.name]=null!==(e=l.options)&&void 0!==e?e:{};else o[n.modules.name]=null!==(t=n.modules.options)&&void 0!==t?t:{};return o})();e.modules=Object.assign({},e.modules,t)}return Object.assign({},n.globalOptions,n.options,e)},b=e=>"object"==typeof e&&e?e.slice():e,m=()=>null==i?void 0:i.getModule("toolbar");let p;const h=e=>{if(typeof p==typeof e){if(e===p)return!0;if("object"==typeof e&&e&&"object"==typeof p&&p)return t=p.diff(e),!Object.values(t.ops).some(e=>!e.retain||1!==Object.keys(e).length)}var t;return!1},v=(e,t,o)=>{p=b(T()),h(n.content)||r.emit("update:content",p),r.emit("textChange",{delta:e,oldContents:t,source:o})},g=o.ref(),f=(e,t,o)=>{g.value=!!(null==i?void 0:i.hasFocus()),r.emit("selectionChange",{range:e,oldRange:t,source:o})};o.watch(g,e=>{r.emit(e?"focus":"blur",s)});const y=(...e)=>{"text-change"===e[0]&&r.emit("editorChange",{name:e[0],delta:e[1],oldContents:e[2],source:e[3]}),"selection-change"===e[0]&&r.emit("editorChange",{name:e[0],range:e[1],oldRange:e[2],source:e[3]})},T=(e,t)=>"html"===n.contentType?C():"text"===n.contentType?O(e,t):null==i?void 0:i.getContents(e,t),x=(e,o="api")=>{const l=e||("delta"===n.contentType?new t:"");"html"===n.contentType?j(l):"text"===n.contentType?q(l,o):null==i||i.setContents(l,o),p=b(l)},O=(e,t)=>{var o;return null!==(o=null==i?void 0:i.getText(e,t))&&void 0!==o?o:""},q=(e,t="api")=>{null==i||i.setText(e,t)},C=()=>{var e;return null!==(e=null==i?void 0:i.root.innerHTML)&&void 0!==e?e:""},j=e=>{i&&(i.root.innerHTML=e)};return o.watch(()=>n.content,e=>{if(!i||!e||h(e))return;const t=i.getSelection();t&&o.nextTick(()=>null==i?void 0:i.setSelection(t)),x(e)},{deep:!0}),o.watch(()=>n.enable,e=>{i&&i.enable(e)}),{editor:s,getEditor:()=>s.value,getToolbar:()=>{var e;return null===(e=m())||void 0===e?void 0:e.container},getQuill:()=>{if(i)return i;throw'The quill editor hasn\'t been instantiated yet,\n make sure to call this method when the editor ready\n or use v-on:ready="onReady(quill)" event instead.'},getContents:T,setContents:x,getHTML:C,setHTML:j,pasteHTML:(e,t="api")=>{const o=null==i?void 0:i.clipboard.convert({html:e});o&&(null==i||i.setContents(o,t))},focus:()=>{null==i||i.focus()},getText:O,setText:q,reinit:()=>{o.nextTick(()=>{var e,t;!r.slots.toolbar&&i&&(null===(t=null===(e=m())||void 0===e?void 0:e.container)||void 0===t||t.remove()),u()})}}},render(){var e,t;return[null===(t=(e=this.$slots).toolbar)||void 0===t?void 0:t.call(e),o.h("div",{ref:"editor",...this.$attrs})]}});exports.Quill=e,exports.Delta=t,exports.QuillEditor=n;
12
+ "use strict";var e=require("quill-delta"),t=require("vue");const o={essential:[[{header:[1,2,3,4,5,6,!1]}],["bold","italic","underline"],[{list:"ordered"},{list:"bullet"},{align:[]}],["blockquote","code-block","link"],[{color:[]},"clean"]],minimal:[[{header:1},{header:2}],["bold","italic","underline"],[{list:"ordered"},{list:"bullet"},{align:[]}]],full:[["bold","italic","underline","strike"],["blockquote","code-block"],[{header:1},{header:2}],[{list:"ordered"},{list:"bullet"}],[{script:"sub"},{script:"super"}],[{indent:"-1"},{indent:"+1"}],[{direction:"rtl"}],[{size:["small",!1,"large","huge"]}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{font:[]}],[{align:[]}],["link","video","image"],["clean"]]};let n,l,r=[];const i=()=>"undefined"!=typeof document,a=async()=>{if(n)return n;if(!i())throw new Error("@vueup/vue-quill: Quill can only be loaded in a browser environment.");return null!=l||(l=import("quill").then(({default:e})=>(n=e,(e=>{const t=r;r=[];for(const o of t)e.register(...o)})(e),e))),l},s=()=>{if(n)return n;throw new Error("@vueup/vue-quill: Quill is not loaded yet. Use loadQuill() in a browser-only lifecycle hook, or access the Quill instance from the ready event.")},u=new Proxy(function(){},{get(e,t){if("register"===t)return(...e)=>{if(n)return n.register(...e);r.push(e),i()&&a()};const o=s(),l=o[t];return"function"==typeof l?l.bind(o):l},construct:(e,t)=>new(s())(...t)}),d=t.defineComponent({name:"QuillEditor",inheritAttrs:!1,props:{content:{type:[String,Object]},contentType:{type:String,default:"delta",validator:e=>["delta","html","text"].includes(e)},enable:{type:Boolean,default:!0},readOnly:{type:Boolean,default:!1},placeholder:{type:String,required:!1},theme:{type:String,default:"snow",validator:e=>["snow","bubble",""].includes(e)},toolbar:{type:[String,Array,Object],required:!1,validator:e=>"string"!=typeof e||""===e||("#"===e.charAt(0)||-1!==Object.keys(o).indexOf(e))},modules:{type:Object,required:!1},options:{type:Object,required:!1},globalOptions:{type:Object,required:!1}},emits:["textChange","selectionChange","editorChange","update:content","focus","blur","ready"],setup:(n,l)=>{t.onMounted(()=>{s=!1,c()}),t.onBeforeUnmount(()=>{r=null,s=!0});let r,i,s=!1;const u=t.ref(),d=(e,t,o)=>{const n=e.imports;n&&t in n||e.register(t,o)},c=async()=>{var e,t;if(!u.value)return;const o=u.value,c=await a();if(!s&&u.value&&u.value===o){if(i=p(),n.modules)if(Array.isArray(n.modules))for(const e of n.modules)d(c,`modules/${e.name}`,e.module);else d(c,`modules/${n.modules.name}`,n.modules.module);r=new c(u.value,i),T(n.content),r.on("text-change",h),r.on("selection-change",y),r.on("editor-change",w),"bubble"!==n.theme&&u.value.classList.remove("ql-bubble"),"snow"!==n.theme&&u.value.classList.remove("ql-snow"),null===(t=null===(e=m())||void 0===e?void 0:e.container)||void 0===t||t.addEventListener("mousedown",e=>{e.preventDefault()}),l.emit("ready",r)}},p=()=>{const e={};if(""!==n.theme&&(e.theme=n.theme),n.readOnly&&(e.readOnly=n.readOnly),n.placeholder&&(e.placeholder=n.placeholder),n.toolbar&&""!==n.toolbar&&(e.modules={toolbar:(()=>{if("object"==typeof n.toolbar)return n.toolbar;if("string"==typeof n.toolbar){return"#"===n.toolbar.charAt(0)?n.toolbar:o[n.toolbar]}})()}),n.modules){const t=(()=>{var e,t;const o={};if(Array.isArray(n.modules))for(const l of n.modules)o[l.name]=null!==(e=l.options)&&void 0!==e?e:{};else o[n.modules.name]=null!==(t=n.modules.options)&&void 0!==t?t:{};return o})();e.modules=Object.assign({},e.modules,t)}return Object.assign({},n.globalOptions,n.options,e)},b=e=>"object"==typeof e&&e?e.slice():e,m=()=>null==r?void 0:r.getModule("toolbar");let v;const f=e=>{if(typeof v==typeof e){if(e===v)return!0;if("object"==typeof e&&e&&"object"==typeof v&&v)return t=v.diff(e),!Object.values(t.ops).some(e=>!e.retain||1!==Object.keys(e).length)}var t;return!1},h=(e,t,o)=>{v=b(x()),f(n.content)||l.emit("update:content",v),l.emit("textChange",{delta:e,oldContents:t,source:o})},g=t.ref(),y=(e,t,o)=>{g.value=!!(null==r?void 0:r.hasFocus()),l.emit("selectionChange",{range:e,oldRange:t,source:o})};t.watch(g,e=>{l.emit(e?"focus":"blur",u)});const w=(...e)=>{"text-change"===e[0]&&l.emit("editorChange",{name:e[0],delta:e[1],oldContents:e[2],source:e[3]}),"selection-change"===e[0]&&l.emit("editorChange",{name:e[0],range:e[1],oldRange:e[2],source:e[3]})},x=(e,t)=>"html"===n.contentType?C():"text"===n.contentType?q(e,t):null==r?void 0:r.getContents(e,t),T=(t,o="api")=>{const l=t||("delta"===n.contentType?new e:"");"html"===n.contentType?j(l):"text"===n.contentType?O(l,o):null==r||r.setContents(l,o),v=b(l)},q=(e,t)=>{var o;return null!==(o=null==r?void 0:r.getText(e,t))&&void 0!==o?o:""},O=(e,t="api")=>{null==r||r.setText(e,t)},C=()=>{var e;return null!==(e=null==r?void 0:r.root.innerHTML)&&void 0!==e?e:""},j=e=>{r&&(r.root.innerHTML=e)};return t.watch(()=>n.content,e=>{if(!r||!e||f(e))return;const o=r.getSelection();o&&t.nextTick(()=>null==r?void 0:r.setSelection(o)),T(e)},{deep:!0}),t.watch(()=>n.enable,e=>{r&&r.enable(e)}),{editor:u,getEditor:()=>u.value,getToolbar:()=>{var e;return null===(e=m())||void 0===e?void 0:e.container},getQuill:()=>{if(r)return r;throw'The quill editor hasn\'t been instantiated yet,\n make sure to call this method when the editor ready\n or use v-on:ready="onReady(quill)" event instead.'},getContents:x,setContents:T,getHTML:C,setHTML:j,pasteHTML:(e,t="api")=>{const o=null==r?void 0:r.clipboard.convert({html:e});o&&(null==r||r.setContents(o,t))},focus:()=>{null==r||r.focus()},getText:q,setText:O,reinit:()=>{t.nextTick(()=>{var e,t;!l.slots.toolbar&&r&&(null===(t=null===(e=m())||void 0===e?void 0:e.container)||void 0===t||t.remove()),c()})}}},render(){var e,o;return[null===(o=(e=this.$slots).toolbar)||void 0===o?void 0:o.call(e),t.h("div",{ref:"editor",...this.$attrs})]}});exports.Delta=e,exports.Quill=u,exports.QuillEditor=d,exports.getLoadedQuill=()=>n,exports.loadQuill=a;
@@ -4,9 +4,10 @@ import { DefineComponent } from 'vue';
4
4
  import Delta from 'quill-delta';
5
5
  import type { EmitterSource } from 'quill';
6
6
  import { ExtractPropTypes } from 'vue';
7
- import { PropType } from 'vue';
7
+ import type { PropType } from 'vue';
8
8
  import { PublicProps } from 'vue';
9
- import Quill from 'quill';
9
+ import type { default as Quill_2 } from 'quill';
10
+ import type QuillConstructorType from 'quill';
10
11
  import type { QuillOptions } from 'quill';
11
12
  import { Ref } from 'vue';
12
13
 
@@ -14,13 +15,19 @@ declare type ContentPropType = string | Delta | undefined | null;
14
15
 
15
16
  export { Delta }
16
17
 
18
+ export declare const getLoadedQuill: () => QuillConstructor | undefined;
19
+
20
+ export declare const loadQuill: () => Promise<QuillConstructor>;
21
+
17
22
  declare type Module = {
18
23
  name: string;
19
24
  module: unknown;
20
25
  options?: object;
21
26
  };
22
27
 
23
- export { Quill }
28
+ export declare const Quill: QuillConstructor;
29
+
30
+ export declare type QuillConstructor = typeof QuillConstructorType;
24
31
 
25
32
  export declare const QuillEditor: DefineComponent<ExtractPropTypes< {
26
33
  content: {
@@ -69,7 +76,7 @@ required: false;
69
76
  editor: Ref<HTMLElement | undefined, HTMLElement | undefined>;
70
77
  getEditor: () => Element;
71
78
  getToolbar: () => Element;
72
- getQuill: () => Quill;
79
+ getQuill: () => Quill_2;
73
80
  getContents: (index?: number, length?: number) => string | Delta | undefined;
74
81
  setContents: (content: ContentPropType, source?: EmitterSource) => void;
75
82
  getHTML: () => string;