@vueup/vue-quill 1.1.0 → 1.2.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.
- package/dist/vue-quill.cjs.js +24 -13
- package/dist/vue-quill.cjs.prod.js +3 -3
- package/dist/vue-quill.d.ts +6 -6
- package/dist/vue-quill.esm-browser.js +23 -12
- package/dist/vue-quill.esm-browser.prod.js +3 -3
- package/dist/vue-quill.esm-bundler.js +22 -10
- package/dist/vue-quill.esm-bundler.prod.js +3 -3
- package/dist/vue-quill.global.js +23 -12
- package/dist/vue-quill.global.prod.js +3 -3
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VueQuill @vueup/vue-quill v1.
|
|
2
|
+
* VueQuill @vueup/vue-quill v1.2.0
|
|
3
3
|
* https://vueup.github.io/vue-quill/
|
|
4
4
|
*
|
|
5
5
|
* Includes quill v1.3.7
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Copyright (c) 2023 Ahmad Luthfi Masruri
|
|
9
9
|
* Released under the MIT license
|
|
10
|
-
* Date: 2023-
|
|
10
|
+
* Date: 2023-05-12T08:44:03.742Z
|
|
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,
|
|
@@ -205,7 +205,7 @@ const QuillEditor = defineComponent({
|
|
|
205
205
|
return Object.assign({}, props.globalOptions, props.options, clientOptions);
|
|
206
206
|
};
|
|
207
207
|
const maybeClone = (delta) => {
|
|
208
|
-
return typeof delta === 'object' ? delta.slice() : delta;
|
|
208
|
+
return typeof delta === 'object' && delta ? delta.slice() : delta;
|
|
209
209
|
};
|
|
210
210
|
const deltaHasValuesOtherThanRetain = (delta) => {
|
|
211
211
|
return Object.values(delta.ops).some((v) => !v.retain || Object.keys(v).length !== 1);
|
|
@@ -218,7 +218,10 @@ const QuillEditor = defineComponent({
|
|
|
218
218
|
return true;
|
|
219
219
|
}
|
|
220
220
|
// Ref/Proxy does not support instanceof, so do a loose check
|
|
221
|
-
if (typeof against === 'object' &&
|
|
221
|
+
if (typeof against === 'object' &&
|
|
222
|
+
against &&
|
|
223
|
+
typeof internalModel === 'object' &&
|
|
224
|
+
internalModel) {
|
|
222
225
|
return !deltaHasValuesOtherThanRetain(internalModel.diff(against));
|
|
223
226
|
}
|
|
224
227
|
}
|
|
@@ -271,7 +274,7 @@ const QuillEditor = defineComponent({
|
|
|
271
274
|
if (quill)
|
|
272
275
|
return quill;
|
|
273
276
|
else
|
|
274
|
-
throw `The quill editor hasn't been instantiated yet,
|
|
277
|
+
throw `The quill editor hasn't been instantiated yet,
|
|
275
278
|
make sure to call this method when the editor ready
|
|
276
279
|
or use v-on:ready="onReady(quill)" event instead.`;
|
|
277
280
|
};
|
|
@@ -285,16 +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(
|
|
297
|
+
setHTML(normalizedContent);
|
|
290
298
|
}
|
|
291
299
|
else if (props.contentType === 'text') {
|
|
292
|
-
setText(
|
|
300
|
+
setText(normalizedContent, source);
|
|
293
301
|
}
|
|
294
302
|
else {
|
|
295
|
-
quill === null || quill === void 0 ? void 0 : quill.setContents(
|
|
303
|
+
quill === null || quill === void 0 ? void 0 : quill.setContents(normalizedContent, source);
|
|
296
304
|
}
|
|
297
|
-
internalModel = maybeClone(
|
|
305
|
+
internalModel = maybeClone(normalizedContent);
|
|
298
306
|
};
|
|
299
307
|
const getText = (index, length) => {
|
|
300
308
|
var _a;
|
|
@@ -316,6 +324,9 @@ const QuillEditor = defineComponent({
|
|
|
316
324
|
if (delta)
|
|
317
325
|
quill === null || quill === void 0 ? void 0 : quill.setContents(delta, source);
|
|
318
326
|
};
|
|
327
|
+
const focus = () => {
|
|
328
|
+
quill === null || quill === void 0 ? void 0 : quill.focus();
|
|
329
|
+
};
|
|
319
330
|
const reinit = () => {
|
|
320
331
|
nextTick(() => {
|
|
321
332
|
var _a;
|
|
@@ -348,6 +359,7 @@ const QuillEditor = defineComponent({
|
|
|
348
359
|
getHTML,
|
|
349
360
|
setHTML,
|
|
350
361
|
pasteHTML,
|
|
362
|
+
focus,
|
|
351
363
|
getText,
|
|
352
364
|
setText,
|
|
353
365
|
reinit,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VueQuill @vueup/vue-quill v1.
|
|
2
|
+
* VueQuill @vueup/vue-quill v1.2.0
|
|
3
3
|
* https://vueup.github.io/vue-quill/
|
|
4
4
|
*
|
|
5
5
|
* Includes quill v1.3.7
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Copyright (c) 2023 Ahmad Luthfi Masruri
|
|
9
9
|
* Released under the MIT license
|
|
10
|
-
* Date: 2023-
|
|
10
|
+
* Date: 2023-05-12T08:44:03.742Z
|
|
11
11
|
*/
|
|
12
|
-
import e from"quill";export{default as Quill}from"quill";export{default as Delta}from"quill-delta";import{defineComponent as
|
|
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 s}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"]]},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(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:(o,s)=>{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",v),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()})),s.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:d[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 f;const h=e=>{if(typeof f==typeof e){if(e===f)return!0;if("object"==typeof e&&e&&"object"==typeof f&&f)return t=f.diff(e),!Object.values(t.ops).some((e=>!e.retain||1!==Object.keys(e).length))}var t;return!1},v=(e,t,l)=>{f=g(q()),h(o.content)||s.emit("update:content",f),s.emit("textChange",{delta:e,oldContents:t,source:l})},y=r(),O=(e,t,o)=>{y.value=!!(null==u?void 0:u.hasFocus()),s.emit("selectionChange",{range:e,oldRange:t,source:o})};i(y,(e=>{s.emit(e?"focus":"blur",m)}));const T=(...e)=>{"text-change"===e[0]&&s.emit("editorChange",{name:e[0],delta:e[1],oldContents:e[2],source:e[3]}),"selection-change"===e[0]&&s.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),f=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||h(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))},focus:()=>{null==u||u.focus()},getText:j,setText:C,reinit:()=>{a((()=>{var e;!s.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),s("div",{ref:"editor",...this.$attrs})]}});export{u as QuillEditor};
|
package/dist/vue-quill.global.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VueQuill @vueup/vue-quill v1.
|
|
2
|
+
* VueQuill @vueup/vue-quill v1.2.0
|
|
3
3
|
* https://vueup.github.io/vue-quill/
|
|
4
4
|
*
|
|
5
5
|
* Includes quill v1.3.7
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Copyright (c) 2023 Ahmad Luthfi Masruri
|
|
9
9
|
* Released under the MIT license
|
|
10
|
-
* Date: 2023-
|
|
10
|
+
* Date: 2023-05-12T08:44:03.742Z
|
|
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
|
|
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,
|
|
@@ -18610,7 +18609,7 @@
|
|
|
18610
18609
|
return Object.assign({}, props.globalOptions, props.options, clientOptions);
|
|
18611
18610
|
};
|
|
18612
18611
|
const maybeClone = (delta) => {
|
|
18613
|
-
return typeof delta === 'object' ? delta.slice() : delta;
|
|
18612
|
+
return typeof delta === 'object' && delta ? delta.slice() : delta;
|
|
18614
18613
|
};
|
|
18615
18614
|
const deltaHasValuesOtherThanRetain = (delta) => {
|
|
18616
18615
|
return Object.values(delta.ops).some((v) => !v.retain || Object.keys(v).length !== 1);
|
|
@@ -18623,7 +18622,10 @@
|
|
|
18623
18622
|
return true;
|
|
18624
18623
|
}
|
|
18625
18624
|
// Ref/Proxy does not support instanceof, so do a loose check
|
|
18626
|
-
if (typeof against === 'object' &&
|
|
18625
|
+
if (typeof against === 'object' &&
|
|
18626
|
+
against &&
|
|
18627
|
+
typeof internalModel === 'object' &&
|
|
18628
|
+
internalModel) {
|
|
18627
18629
|
return !deltaHasValuesOtherThanRetain(internalModel.diff(against));
|
|
18628
18630
|
}
|
|
18629
18631
|
}
|
|
@@ -18676,7 +18678,7 @@
|
|
|
18676
18678
|
if (quill)
|
|
18677
18679
|
return quill;
|
|
18678
18680
|
else
|
|
18679
|
-
throw `The quill editor hasn't been instantiated yet,
|
|
18681
|
+
throw `The quill editor hasn't been instantiated yet,
|
|
18680
18682
|
make sure to call this method when the editor ready
|
|
18681
18683
|
or use v-on:ready="onReady(quill)" event instead.`;
|
|
18682
18684
|
};
|
|
@@ -18690,16 +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(
|
|
18701
|
+
setHTML(normalizedContent);
|
|
18695
18702
|
}
|
|
18696
18703
|
else if (props.contentType === 'text') {
|
|
18697
|
-
setText(
|
|
18704
|
+
setText(normalizedContent, source);
|
|
18698
18705
|
}
|
|
18699
18706
|
else {
|
|
18700
|
-
quill === null || quill === void 0 ? void 0 : quill.setContents(
|
|
18707
|
+
quill === null || quill === void 0 ? void 0 : quill.setContents(normalizedContent, source);
|
|
18701
18708
|
}
|
|
18702
|
-
internalModel = maybeClone(
|
|
18709
|
+
internalModel = maybeClone(normalizedContent);
|
|
18703
18710
|
};
|
|
18704
18711
|
const getText = (index, length) => {
|
|
18705
18712
|
var _a;
|
|
@@ -18721,6 +18728,9 @@
|
|
|
18721
18728
|
if (delta)
|
|
18722
18729
|
quill === null || quill === void 0 ? void 0 : quill.setContents(delta, source);
|
|
18723
18730
|
};
|
|
18731
|
+
const focus = () => {
|
|
18732
|
+
quill === null || quill === void 0 ? void 0 : quill.focus();
|
|
18733
|
+
};
|
|
18724
18734
|
const reinit = () => {
|
|
18725
18735
|
vue.nextTick(() => {
|
|
18726
18736
|
var _a;
|
|
@@ -18753,6 +18763,7 @@
|
|
|
18753
18763
|
getHTML,
|
|
18754
18764
|
setHTML,
|
|
18755
18765
|
pasteHTML,
|
|
18766
|
+
focus,
|
|
18756
18767
|
getText,
|
|
18757
18768
|
setText,
|
|
18758
18769
|
reinit,
|
|
@@ -18767,7 +18778,7 @@
|
|
|
18767
18778
|
},
|
|
18768
18779
|
});
|
|
18769
18780
|
|
|
18770
|
-
exports.Delta =
|
|
18781
|
+
exports.Delta = Delta$1;
|
|
18771
18782
|
exports.Quill = Quill;
|
|
18772
18783
|
exports.QuillEditor = QuillEditor;
|
|
18773
18784
|
|