@vueup/vue-quill 1.0.1 → 1.1.1

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,16 +1,17 @@
1
1
  /*!
2
- * VueQuill @vueup/vue-quill v1.0.1
2
+ * VueQuill @vueup/vue-quill v1.1.1
3
3
  * https://vueup.github.io/vue-quill/
4
4
  *
5
5
  * Includes quill v1.3.7
6
6
  * https://quilljs.com/
7
7
  *
8
- * Copyright (c) 2022 Ahmad Luthfi Masruri
8
+ * Copyright (c) 2023 Ahmad Luthfi Masruri
9
9
  * Released under the MIT license
10
- * Date: 2022-12-20T16:01:54.428Z
10
+ * Date: 2023-03-08T12:39:52.151Z
11
11
  */
12
12
  import Quill from 'quill';
13
13
  export { default as Quill } from 'quill';
14
+ import Delta from 'quill-delta';
14
15
  export { default as Delta } from 'quill-delta';
15
16
  import { defineComponent, onMounted, onBeforeUnmount, ref, watch, nextTick, h } from 'vue';
16
17
 
@@ -51,7 +52,6 @@ const QuillEditor = defineComponent({
51
52
  props: {
52
53
  content: {
53
54
  type: [String, Object],
54
- default: () => { },
55
55
  },
56
56
  contentType: {
57
57
  type: String,
@@ -204,28 +204,31 @@ const QuillEditor = defineComponent({
204
204
  }
205
205
  return Object.assign({}, props.globalOptions, props.options, clientOptions);
206
206
  };
207
+ const maybeClone = (delta) => {
208
+ return typeof delta === 'object' && delta ? delta.slice() : delta;
209
+ };
207
210
  const deltaHasValuesOtherThanRetain = (delta) => {
208
- return Object.values(delta).some((v) => !v.retain);
211
+ return Object.values(delta.ops).some((v) => !v.retain || Object.keys(v).length !== 1);
209
212
  };
210
- // eslint-disable-next-line vue/no-setup-props-destructure
211
- let internalModel = props.content; // Doesn't need reactivity
213
+ // Doesn't need reactivity, but does need to be cloned to avoid deep mutations always registering as equal
214
+ let internalModel;
212
215
  const internalModelEquals = (against) => {
213
216
  if (typeof internalModel === typeof against) {
214
217
  if (against === internalModel) {
215
218
  return true;
216
219
  }
217
220
  // Ref/Proxy does not support instanceof, so do a loose check
218
- if (typeof against === 'object' && typeof internalModel === 'object') {
221
+ if (typeof against === 'object' &&
222
+ against &&
223
+ typeof internalModel === 'object' &&
224
+ internalModel) {
219
225
  return !deltaHasValuesOtherThanRetain(internalModel.diff(against));
220
226
  }
221
227
  }
222
228
  return false;
223
229
  };
224
230
  const handleTextChange = (delta, oldContents, source) => {
225
- // Quill should never be null at this point because we receive an event
226
- // so content should not be undefined but let's make ts and eslint happy
227
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
228
- internalModel = getContents();
231
+ internalModel = maybeClone(getContents());
229
232
  // Update v-model:content when text changes
230
233
  if (!internalModelEquals(props.content)) {
231
234
  ctx.emit('update:content', internalModel);
@@ -285,15 +288,21 @@ const QuillEditor = defineComponent({
285
288
  return quill === null || quill === void 0 ? void 0 : quill.getContents(index, length);
286
289
  };
287
290
  const setContents = (content, source = 'api') => {
291
+ const normalizedContent = !content
292
+ ? props.contentType === 'delta'
293
+ ? new Delta()
294
+ : ''
295
+ : content;
288
296
  if (props.contentType === 'html') {
289
- setHTML(content);
297
+ setHTML(normalizedContent);
290
298
  }
291
299
  else if (props.contentType === 'text') {
292
- setText(content, source);
300
+ setText(normalizedContent, source);
293
301
  }
294
302
  else {
295
- quill === null || quill === void 0 ? void 0 : quill.setContents(content, source);
303
+ quill === null || quill === void 0 ? void 0 : quill.setContents(normalizedContent, source);
296
304
  }
305
+ internalModel = maybeClone(normalizedContent);
297
306
  };
298
307
  const getText = (index, length) => {
299
308
  var _a;
@@ -326,14 +335,13 @@ const QuillEditor = defineComponent({
326
335
  watch(() => props.content, (newContent) => {
327
336
  if (!quill || !newContent || internalModelEquals(newContent))
328
337
  return;
329
- internalModel = newContent;
330
338
  // Restore the selection and cursor position after updating the content
331
339
  const selection = quill.getSelection();
332
340
  if (selection) {
333
341
  nextTick(() => quill === null || quill === void 0 ? void 0 : quill.setSelection(selection));
334
342
  }
335
343
  setContents(newContent);
336
- });
344
+ }, { deep: true });
337
345
  watch(() => props.enable, (newValue) => {
338
346
  if (quill)
339
347
  quill.enable(newValue);
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * VueQuill @vueup/vue-quill v1.0.1
2
+ * VueQuill @vueup/vue-quill v1.1.1
3
3
  * https://vueup.github.io/vue-quill/
4
4
  *
5
5
  * Includes quill v1.3.7
6
6
  * https://quilljs.com/
7
7
  *
8
- * Copyright (c) 2022 Ahmad Luthfi Masruri
8
+ * Copyright (c) 2023 Ahmad Luthfi Masruri
9
9
  * Released under the MIT license
10
- * Date: 2022-12-20T16:01:54.428Z
10
+ * Date: 2023-03-08T12:39:52.151Z
11
11
  */
12
- import e from"quill";export{default as Quill}from"quill";export{default as Delta}from"quill-delta";import{defineComponent as t,onMounted as o,onBeforeUnmount as l,ref as n,watch as r,nextTick as i,h as a}from"vue";const d={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"]]},s=t({name:"QuillEditor",inheritAttrs:!1,props:{content:{type:[String,Object],default:()=>{}},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(d).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:(t,a)=>{let s,u;o((()=>{m()})),l((()=>{s=null}));const c=n(),m=()=>{var o;if(c.value){if(u=b(),t.modules)if(Array.isArray(t.modules))for(const o of t.modules)e.register(`modules/${o.name}`,o.module);else e.register(`modules/${t.modules.name}`,t.modules.module);s=new e(c.value,u),T(t.content),s.on("text-change",v),s.on("selection-change",f),s.on("editor-change",y),"bubble"!==t.theme&&c.value.classList.remove("ql-bubble"),"snow"!==t.theme&&c.value.classList.remove("ql-snow"),null===(o=s.getModule("toolbar"))||void 0===o||o.container.addEventListener("mousedown",(e=>{e.preventDefault()})),a.emit("ready",s)}},b=()=>{const e={};if(""!==t.theme&&(e.theme=t.theme),t.readOnly&&(e.readOnly=t.readOnly),t.placeholder&&(e.placeholder=t.placeholder),t.toolbar&&""!==t.toolbar&&(e.modules={toolbar:(()=>{if("object"==typeof t.toolbar)return t.toolbar;if("string"==typeof t.toolbar){return"#"===t.toolbar.charAt(0)?t.toolbar:d[t.toolbar]}})()}),t.modules){const o=(()=>{var e,o;const l={};if(Array.isArray(t.modules))for(const n of t.modules)l[n.name]=null!==(e=n.options)&&void 0!==e?e:{};else l[t.modules.name]=null!==(o=t.modules.options)&&void 0!==o?o:{};return l})();e.modules=Object.assign({},e.modules,o)}return Object.assign({},t.globalOptions,t.options,e)};let p=t.content;const g=e=>{if(typeof p==typeof e){if(e===p)return!0;if("object"==typeof e&&"object"==typeof p)return t=p.diff(e),!Object.values(t).some((e=>!e.retain))}var t;return!1},v=(e,o,l)=>{p=O(),g(t.content)||a.emit("update:content",p),a.emit("textChange",{delta:e,oldContents:o,source:l})},h=n(),f=(e,t,o)=>{h.value=!!(null==s?void 0:s.hasFocus()),a.emit("selectionChange",{range:e,oldRange:t,source:o})};r(h,(e=>{a.emit(e?"focus":"blur",c)}));const y=(...e)=>{"text-change"===e[0]&&a.emit("editorChange",{name:e[0],delta:e[1],oldContents:e[2],source:e[3]}),"selection-change"===e[0]&&a.emit("editorChange",{name:e[0],range:e[1],oldRange:e[2],source:e[3]})},O=(e,o)=>"html"===t.contentType?C():"text"===t.contentType?x(e,o):null==s?void 0:s.getContents(e,o),T=(e,o="api")=>{"html"===t.contentType?j(e):"text"===t.contentType?q(e,o):null==s||s.setContents(e,o)},x=(e,t)=>{var o;return null!==(o=null==s?void 0:s.getText(e,t))&&void 0!==o?o:""},q=(e,t="api")=>{null==s||s.setText(e,t)},C=()=>{var e;return null!==(e=null==s?void 0:s.root.innerHTML)&&void 0!==e?e:""},j=e=>{s&&(s.root.innerHTML=e)};return r((()=>t.content),(e=>{if(!s||!e||g(e))return;p=e;const t=s.getSelection();t&&i((()=>null==s?void 0:s.setSelection(t))),T(e)})),r((()=>t.enable),(e=>{s&&s.enable(e)})),{editor:c,getEditor:()=>c.value,getToolbar:()=>{var e;return null===(e=null==s?void 0:s.getModule("toolbar"))||void 0===e?void 0:e.container},getQuill:()=>{if(s)return s;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:O,setContents:T,getHTML:C,setHTML:j,pasteHTML:(e,t="api")=>{const o=null==s?void 0:s.clipboard.convert(e);o&&(null==s||s.setContents(o,t))},getText:x,setText:q,reinit:()=>{i((()=>{var e;!a.slots.toolbar&&s&&(null===(e=s.getModule("toolbar"))||void 0===e||e.container.remove()),m()}))}}},render(){var e,t;return[null===(t=(e=this.$slots).toolbar)||void 0===t?void 0:t.call(e),a("div",{ref:"editor",...this.$attrs})]}});export{s as QuillEditor};
12
+ import e from"quill";export{default as Quill}from"quill";import t from"quill-delta";export{default as Delta}from"quill-delta";import{defineComponent as o,onMounted as l,onBeforeUnmount as n,ref as r,watch as i,nextTick as a,h as d}from"vue";const s={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"]]},u=o({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(s).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:(o,d)=>{let u,c;l((()=>{b()})),n((()=>{u=null}));const m=r(),b=()=>{var t;if(m.value){if(c=p(),o.modules)if(Array.isArray(o.modules))for(const t of o.modules)e.register(`modules/${t.name}`,t.module);else e.register(`modules/${o.modules.name}`,o.modules.module);u=new e(m.value,c),x(o.content),u.on("text-change",f),u.on("selection-change",O),u.on("editor-change",T),"bubble"!==o.theme&&m.value.classList.remove("ql-bubble"),"snow"!==o.theme&&m.value.classList.remove("ql-snow"),null===(t=u.getModule("toolbar"))||void 0===t||t.container.addEventListener("mousedown",(e=>{e.preventDefault()})),d.emit("ready",u)}},p=()=>{const e={};if(""!==o.theme&&(e.theme=o.theme),o.readOnly&&(e.readOnly=o.readOnly),o.placeholder&&(e.placeholder=o.placeholder),o.toolbar&&""!==o.toolbar&&(e.modules={toolbar:(()=>{if("object"==typeof o.toolbar)return o.toolbar;if("string"==typeof o.toolbar){return"#"===o.toolbar.charAt(0)?o.toolbar:s[o.toolbar]}})()}),o.modules){const t=(()=>{var e,t;const l={};if(Array.isArray(o.modules))for(const n of o.modules)l[n.name]=null!==(e=n.options)&&void 0!==e?e:{};else l[o.modules.name]=null!==(t=o.modules.options)&&void 0!==t?t:{};return l})();e.modules=Object.assign({},e.modules,t)}return Object.assign({},o.globalOptions,o.options,e)},g=e=>"object"==typeof e&&e?e.slice():e;let h;const v=e=>{if(typeof h==typeof e){if(e===h)return!0;if("object"==typeof e&&e&&"object"==typeof h&&h)return t=h.diff(e),!Object.values(t.ops).some((e=>!e.retain||1!==Object.keys(e).length))}var t;return!1},f=(e,t,l)=>{h=g(q()),v(o.content)||d.emit("update:content",h),d.emit("textChange",{delta:e,oldContents:t,source:l})},y=r(),O=(e,t,o)=>{y.value=!!(null==u?void 0:u.hasFocus()),d.emit("selectionChange",{range:e,oldRange:t,source:o})};i(y,(e=>{d.emit(e?"focus":"blur",m)}));const T=(...e)=>{"text-change"===e[0]&&d.emit("editorChange",{name:e[0],delta:e[1],oldContents:e[2],source:e[3]}),"selection-change"===e[0]&&d.emit("editorChange",{name:e[0],range:e[1],oldRange:e[2],source:e[3]})},q=(e,t)=>"html"===o.contentType?k():"text"===o.contentType?j(e,t):null==u?void 0:u.getContents(e,t),x=(e,l="api")=>{const n=e||("delta"===o.contentType?new t:"");"html"===o.contentType?w(n):"text"===o.contentType?C(n,l):null==u||u.setContents(n,l),h=g(n)},j=(e,t)=>{var o;return null!==(o=null==u?void 0:u.getText(e,t))&&void 0!==o?o:""},C=(e,t="api")=>{null==u||u.setText(e,t)},k=()=>{var e;return null!==(e=null==u?void 0:u.root.innerHTML)&&void 0!==e?e:""},w=e=>{u&&(u.root.innerHTML=e)};return i((()=>o.content),(e=>{if(!u||!e||v(e))return;const t=u.getSelection();t&&a((()=>null==u?void 0:u.setSelection(t))),x(e)}),{deep:!0}),i((()=>o.enable),(e=>{u&&u.enable(e)})),{editor:m,getEditor:()=>m.value,getToolbar:()=>{var e;return null===(e=null==u?void 0:u.getModule("toolbar"))||void 0===e?void 0:e.container},getQuill:()=>{if(u)return u;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:q,setContents:x,getHTML:k,setHTML:w,pasteHTML:(e,t="api")=>{const o=null==u?void 0:u.clipboard.convert(e);o&&(null==u||u.setContents(o,t))},getText:j,setText:C,reinit:()=>{a((()=>{var e;!d.slots.toolbar&&u&&(null===(e=u.getModule("toolbar"))||void 0===e||e.container.remove()),b()}))}}},render(){var e,t;return[null===(t=(e=this.$slots).toolbar)||void 0===t?void 0:t.call(e),d("div",{ref:"editor",...this.$attrs})]}});export{u as QuillEditor};
@@ -1,13 +1,13 @@
1
1
  /*!
2
- * VueQuill @vueup/vue-quill v1.0.1
2
+ * VueQuill @vueup/vue-quill v1.1.1
3
3
  * https://vueup.github.io/vue-quill/
4
4
  *
5
5
  * Includes quill v1.3.7
6
6
  * https://quilljs.com/
7
7
  *
8
- * Copyright (c) 2022 Ahmad Luthfi Masruri
8
+ * Copyright (c) 2023 Ahmad Luthfi Masruri
9
9
  * Released under the MIT license
10
- * Date: 2022-12-20T16:01:54.428Z
10
+ * Date: 2023-03-08T12:39:52.151Z
11
11
  */
12
12
  (function (global, factory) {
13
13
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
@@ -18417,7 +18417,7 @@
18417
18417
  var Delta_1 = Delta;
18418
18418
 
18419
18419
 
18420
- var Delta_1$1 = Delta_1;
18420
+ var Delta$1 = Delta_1;
18421
18421
 
18422
18422
  const toolbarOptions = {
18423
18423
  essential: [
@@ -18456,7 +18456,6 @@
18456
18456
  props: {
18457
18457
  content: {
18458
18458
  type: [String, Object],
18459
- default: () => { },
18460
18459
  },
18461
18460
  contentType: {
18462
18461
  type: String,
@@ -18609,28 +18608,31 @@
18609
18608
  }
18610
18609
  return Object.assign({}, props.globalOptions, props.options, clientOptions);
18611
18610
  };
18611
+ const maybeClone = (delta) => {
18612
+ return typeof delta === 'object' && delta ? delta.slice() : delta;
18613
+ };
18612
18614
  const deltaHasValuesOtherThanRetain = (delta) => {
18613
- return Object.values(delta).some((v) => !v.retain);
18615
+ return Object.values(delta.ops).some((v) => !v.retain || Object.keys(v).length !== 1);
18614
18616
  };
18615
- // eslint-disable-next-line vue/no-setup-props-destructure
18616
- let internalModel = props.content; // Doesn't need reactivity
18617
+ // Doesn't need reactivity, but does need to be cloned to avoid deep mutations always registering as equal
18618
+ let internalModel;
18617
18619
  const internalModelEquals = (against) => {
18618
18620
  if (typeof internalModel === typeof against) {
18619
18621
  if (against === internalModel) {
18620
18622
  return true;
18621
18623
  }
18622
18624
  // Ref/Proxy does not support instanceof, so do a loose check
18623
- if (typeof against === 'object' && typeof internalModel === 'object') {
18625
+ if (typeof against === 'object' &&
18626
+ against &&
18627
+ typeof internalModel === 'object' &&
18628
+ internalModel) {
18624
18629
  return !deltaHasValuesOtherThanRetain(internalModel.diff(against));
18625
18630
  }
18626
18631
  }
18627
18632
  return false;
18628
18633
  };
18629
18634
  const handleTextChange = (delta, oldContents, source) => {
18630
- // Quill should never be null at this point because we receive an event
18631
- // so content should not be undefined but let's make ts and eslint happy
18632
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
18633
- internalModel = getContents();
18635
+ internalModel = maybeClone(getContents());
18634
18636
  // Update v-model:content when text changes
18635
18637
  if (!internalModelEquals(props.content)) {
18636
18638
  ctx.emit('update:content', internalModel);
@@ -18690,15 +18692,21 @@
18690
18692
  return quill === null || quill === void 0 ? void 0 : quill.getContents(index, length);
18691
18693
  };
18692
18694
  const setContents = (content, source = 'api') => {
18695
+ const normalizedContent = !content
18696
+ ? props.contentType === 'delta'
18697
+ ? new Delta$1()
18698
+ : ''
18699
+ : content;
18693
18700
  if (props.contentType === 'html') {
18694
- setHTML(content);
18701
+ setHTML(normalizedContent);
18695
18702
  }
18696
18703
  else if (props.contentType === 'text') {
18697
- setText(content, source);
18704
+ setText(normalizedContent, source);
18698
18705
  }
18699
18706
  else {
18700
- quill === null || quill === void 0 ? void 0 : quill.setContents(content, source);
18707
+ quill === null || quill === void 0 ? void 0 : quill.setContents(normalizedContent, source);
18701
18708
  }
18709
+ internalModel = maybeClone(normalizedContent);
18702
18710
  };
18703
18711
  const getText = (index, length) => {
18704
18712
  var _a;
@@ -18731,14 +18739,13 @@
18731
18739
  vue.watch(() => props.content, (newContent) => {
18732
18740
  if (!quill || !newContent || internalModelEquals(newContent))
18733
18741
  return;
18734
- internalModel = newContent;
18735
18742
  // Restore the selection and cursor position after updating the content
18736
18743
  const selection = quill.getSelection();
18737
18744
  if (selection) {
18738
18745
  vue.nextTick(() => quill === null || quill === void 0 ? void 0 : quill.setSelection(selection));
18739
18746
  }
18740
18747
  setContents(newContent);
18741
- });
18748
+ }, { deep: true });
18742
18749
  vue.watch(() => props.enable, (newValue) => {
18743
18750
  if (quill)
18744
18751
  quill.enable(newValue);
@@ -18767,7 +18774,7 @@
18767
18774
  },
18768
18775
  });
18769
18776
 
18770
- exports.Delta = Delta_1$1;
18777
+ exports.Delta = Delta$1;
18771
18778
  exports.Quill = Quill;
18772
18779
  exports.QuillEditor = QuillEditor;
18773
18780