quill-resize-module 2.0.3 → 2.0.5
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/README.md +5 -0
- package/demo/demo.jpg +0 -0
- package/demo/index.html +9 -2
- package/demo/index.js +14 -0
- package/dist/resize.css +1 -1
- package/dist/resize.js +2 -2
- package/package.json +2 -2
- package/src/assets/resize.scss +4 -0
- package/src/modules/Resize.js +0 -2
- package/src/modules/Toolbar.js +71 -25
package/README.md
CHANGED
|
@@ -108,6 +108,11 @@ const quill = new Quill(editor, {
|
|
|
108
108
|
'left', 'right',
|
|
109
109
|
{
|
|
110
110
|
text: 'Alt',
|
|
111
|
+
// set attributes
|
|
112
|
+
attrs: {
|
|
113
|
+
title: 'Set image alt',
|
|
114
|
+
class: 'btn-alt'
|
|
115
|
+
},
|
|
111
116
|
verify (activeEle) {
|
|
112
117
|
return (activeEle && activeEle.tagName === 'IMG')
|
|
113
118
|
},
|
package/demo/demo.jpg
CHANGED
|
Binary file
|
package/demo/index.html
CHANGED
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
opacity: .5;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
.ql-resize-toolbar .btn-alt {
|
|
50
|
+
background-color: #ccc;
|
|
51
|
+
}
|
|
52
|
+
|
|
49
53
|
#result {
|
|
50
54
|
width: 100%;
|
|
51
55
|
}
|
|
@@ -57,9 +61,9 @@
|
|
|
57
61
|
<div class="editor-box">
|
|
58
62
|
<div id="editor">
|
|
59
63
|
<p>Click target to resize.</p>
|
|
60
|
-
<p><img src="https://i.ytimg.com/vi/Fp5ghKduTK8/hq720.jpg" width="
|
|
64
|
+
<p><img src="https://i.ytimg.com/vi/Fp5ghKduTK8/hq720.jpg" width="400"> text <img src="https://i.ytimg.com/vi/etdb8-v2enI/hq720.jpg" width="350"></p>
|
|
61
65
|
<p><br></p>
|
|
62
|
-
<iframe width="560" height="315" src="https://www.youtube.com/embed/
|
|
66
|
+
<iframe width="560" height="315" src="https://www.youtube.com/embed/HGl75kurxok?si=xZWI9qVC3oJs0Lll" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
|
|
63
67
|
<p><br></p>
|
|
64
68
|
<p>Try to press left/right key around the placeholder.</p>
|
|
65
69
|
</div>
|
|
@@ -69,6 +73,9 @@
|
|
|
69
73
|
<button class="btn btn-content">getContent</button>
|
|
70
74
|
<button class="btn btn-text">getText</button>
|
|
71
75
|
|
|
76
|
+
<button class="btn btn-set-html">setHTML</button>
|
|
77
|
+
<button class="btn btn-set-content">setContent</button>
|
|
78
|
+
|
|
72
79
|
<button class="btn btn-undo">undo</button>
|
|
73
80
|
<button class="btn btn-redo">redo</button>
|
|
74
81
|
</div>
|
package/demo/index.js
CHANGED
|
@@ -26,6 +26,10 @@ const demoEditor = new Quill('#editor', {
|
|
|
26
26
|
'left', 'center', 'right', 'full', 'edit',
|
|
27
27
|
{
|
|
28
28
|
text: 'Alt',
|
|
29
|
+
attrs: {
|
|
30
|
+
title: 'Set image alt',
|
|
31
|
+
class: 'btn-alt'
|
|
32
|
+
},
|
|
29
33
|
verify (activeEle) {
|
|
30
34
|
return (activeEle && activeEle.tagName === 'IMG')
|
|
31
35
|
},
|
|
@@ -53,6 +57,16 @@ document.querySelector('.btn-content').addEventListener('click', function () {
|
|
|
53
57
|
document.querySelector('.btn-text').addEventListener('click', function () {
|
|
54
58
|
$result.value = demoEditor.getText()
|
|
55
59
|
})
|
|
60
|
+
document.querySelector('.btn-set-html').addEventListener('click', function () {
|
|
61
|
+
const contents = demoEditor.clipboard.convert({
|
|
62
|
+
html: `${$result.value}<p><br></p>`,
|
|
63
|
+
text: '\n'
|
|
64
|
+
})
|
|
65
|
+
demoEditor.setContents(contents)
|
|
66
|
+
})
|
|
67
|
+
document.querySelector('.btn-set-content').addEventListener('click', function () {
|
|
68
|
+
demoEditor.setContents(JSON.parse($result.value))
|
|
69
|
+
})
|
|
56
70
|
document.querySelector('.btn-undo').addEventListener('click', function () {
|
|
57
71
|
demoEditor.history.undo()
|
|
58
72
|
})
|
package/dist/resize.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Quill Resize Module v2.0.
|
|
2
|
+
* Quill Resize Module v2.0.4
|
|
3
3
|
* https://github.com/mudoo/quill-resize-module
|
|
4
4
|
*/
|
|
5
5
|
.ql-resize-overlay{position:absolute;box-sizing:border-box;border:1px dashed #444;pointer-events:none}.ql-resize-toolbar{position:absolute;top:-12px;right:0;left:0;height:0;min-width:120px;text-align:center;color:#333;box-sizing:border-box;cursor:default;pointer-events:all}.ql-resize-toolbar button{display:inline-block;min-width:24px;height:24px;padding:2px;background-color:#fff;border:1px solid #999;vertical-align:middle}.ql-resize-toolbar button:first-child{border-top-left-radius:3px;border-bottom-left-radius:3px}.ql-resize-toolbar button:last-child{border-bottom-right-radius:3px;border-top-right-radius:3px}.ql-resize-toolbar button:not(:first-child){border-left:none}.ql-resize-toolbar button.active{filter:invert(20%)}.ql-resize-toolbar svg{width:18px}.ql-resize-handle{position:absolute;height:12px;width:12px;background-color:#fff;border:1px solid #777;box-sizing:border-box;opacity:.8;pointer-events:all}.ql-resize-handle.tl{top:-6px;left:-6px;cursor:nwse-resize}.ql-resize-handle.tr{top:-6px;right:-6px;cursor:nesw-resize}.ql-resize-handle.br{right:-6px;bottom:-6px;cursor:nwse-resize}.ql-resize-handle.bl{left:-6px;bottom:-6px;cursor:nwse-resize}.ql-resize-display{position:absolute;padding:4px 8px;text-align:center;background-color:#fff;color:#333;border:1px solid #777;box-sizing:border-box;opacity:.8;cursor:default;line-height:1}.ql-resize-style-left{float:left;margin:0 1em 1em 0}.ql-resize-style-center{display:block;margin:auto}.ql-resize-style-right{float:right;margin:0 0 1em 1em}.ql-resize-style-full{width:100% !important}
|
package/dist/resize.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Quill Resize Module v2.0.
|
|
2
|
+
* Quill Resize Module v2.0.4
|
|
3
3
|
* https://github.com/mudoo/quill-resize-module
|
|
4
4
|
*/
|
|
5
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("Quill")):"function"==typeof define&&define.amd?define(["Quill"],e):"object"==typeof exports?exports.QuillResize=e(require("Quill")):t.QuillResize=e(t.Quill)}(self,(t=>(()=>{"use strict";var e=[,e=>{e.exports=t}],i={};function r(t){var o=i[t];if(void 0!==o)return o.exports;var n=i[t]={exports:{}};return e[t](n,n.exports,r),n.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};r.r(o),r.d(o,{default:()=>ct});const n={modules:["DisplaySize","Toolbar","Resize","Keyboard"],keyboardSelect:!0,selectedClass:"selected",activeClass:"active",embedTags:["VIDEO","IFRAME"],tools:["left","center","right","full","edit"],parchment:{image:{attribute:["width"],limit:{minWidth:100}},video:{attribute:["width","height"],limit:{minWidth:200,ratio:.5625}}}};function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function s(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,a(r.key),r)}}function a(t){var e=function(t,e){if("object"!=l(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==l(e)?e:e+""}var u=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.resizer=e,this.quill=e.quill,this.overlay=e.overlay,this.activeEle=e.activeEle,this.blot=e.blot,this.options=e.options,this.requestUpdate=function(){e.onUpdate(!0)}},(e=[{key:"onCreate",value:function(){}},{key:"onDestroy",value:function(){}},{key:"onUpdate",value:function(){}}])&&s(t.prototype,e),i&&s(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,i}();function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}function h(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,f(r.key),r)}}function f(t){var e=function(t,e){if("object"!=c(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=c(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==c(e)?e:e+""}function d(t,e,i){return e=y(e),function(t,e){if(e&&("object"==c(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,p()?Reflect.construct(e,i||[],y(t).constructor):e.apply(t,i))}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}function y(t){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},y(t)}function v(t,e){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},v(t,e)}var b=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),d(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&v(t,e)}(e,t),i=e,(r=[{key:"onCreate",value:function(){this.display=document.createElement("div"),this.display.className="ql-resize-display",this.overlay.appendChild(this.display)}},{key:"onUpdate",value:function(){if(this.display&&this.activeEle){var t=this.getCurrentSize();if(this.display.innerHTML=t.join(" × "),t[0]>120&&t[1]>30)Object.assign(this.display.style,{right:"4px",bottom:"4px",left:"auto"});else if("right"===this.activeEle.style.float){var e=this.display.getBoundingClientRect();Object.assign(this.display.style,{right:"auto",bottom:"-".concat(e.height+4,"px"),left:"-".concat(e.width+4,"px")})}else{var i=this.display.getBoundingClientRect();Object.assign(this.display.style,{right:"-".concat(i.width+4,"px"),bottom:"-".concat(i.height+4,"px"),left:"auto"})}}}},{key:"getCurrentSize",value:function(){return[this.activeEle.offsetWidth,this.activeEle.offsetHeight]}}])&&h(i.prototype,r),o&&h(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,o}(u);var m=r(1),g=r.n(m);function w(t){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(t)}function E(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,k(r.key),r)}}function O(t,e,i){return e=S(e),function(t,e){if(e&&("object"==w(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,j()?Reflect.construct(e,i||[],S(t).constructor):e.apply(t,i))}function j(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(j=function(){return!!t})()}function S(t){return S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},S(t)}function x(t,e){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},x(t,e)}function P(t,e,i){return(e=k(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function k(t){var e=function(t,e){if("object"!=w(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=w(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==w(e)?e:e+""}var q=(window.Quill||g()).import("parchment"),C=new(q.ClassAttributor?q.ClassAttributor:q.Attributor.Class)("imagestyle","ql-resize-style"),T=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),O(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&x(t,e)}(e,t),i=e,r=[{key:"onCreate",value:function(){this.toolbar=document.createElement("div"),this.toolbar.className="ql-resize-toolbar",this.overlay.appendChild(this.toolbar),this._addToolbarButtons()}},{key:"_addToolbarButtons",value:function(){var t=this,e=this.constructor.Icons,i=this.constructor.Tools,r=[];this.options.tools.forEach((function(o){var n=i[o]||o;if(!n.verify||!1!==n.verify.call(t,t.activeEle)){var l=document.createElement("button");r.push(l),l.innerHTML=(n.icon||"")+(n.text||"")||e[o],l.addEventListener("click",(function(e){n.handler&&!0!==n.handler.call(t,e,l,t.activeEle)||(r.forEach((function(t){return t.classList.remove("active")})),n.isApplied&&n.isApplied.call(t,t.activeEle)?C.remove(t.activeEle):(l.classList.add("active"),n.apply&&n.apply.call(t,t.activeEle)),t.requestUpdate())})),n.isApplied&&n.isApplied.call(t,t.activeEle)&&l.classList.add("active"),t.toolbar.appendChild(l)}}))}}],r&&E(i.prototype,r),o&&E(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,o}(u);function A(t){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},A(t)}function L(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function M(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?L(Object(i),!0).forEach((function(e){H(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):L(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function H(t,e,i){return(e=B(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function z(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,B(r.key),r)}}function B(t){var e=function(t,e){if("object"!=A(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=A(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==A(e)?e:e+""}function _(t,e,i){return e=N(e),function(t,e){if(e&&("object"==A(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,D()?Reflect.construct(e,i||[],N(t).constructor):e.apply(t,i))}function D(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(D=function(){return!!t})()}function N(t){return N=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},N(t)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}P(T,"Icons",{left:'<svg viewbox="0 0 18 18">\n <path class="ql-fill" d="M15,8H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,8Z"/>\n <path class="ql-fill" d="M15,12H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,12Z"/>\n <path class="ql-fill" d="M15,16H5a1,1,0,0,1,0-2H15A1,1,0,0,1,15,16Z"/>\n <path class="ql-fill" d="M15,4H5A1,1,0,0,1,5,2H15A1,1,0,0,1,15,4Z"/>\n <rect class="ql-fill" x="2" y="6" width="8" height="6" rx="1" ry="1"/>\n</svg>',center:'<svg viewbox="0 0 18 18">\n <path class="ql-fill" d="M14,16H4a1,1,0,0,1,0-2H14A1,1,0,0,1,14,16Z"/>\n <path class="ql-fill" d="M14,4H4A1,1,0,0,1,4,2H14A1,1,0,0,1,14,4Z"/>\n <rect class="ql-fill" x="3" y="6" width="12" height="6" rx="1" ry="1"/>\n</svg>',right:'<svg viewbox="0 0 18 18">\n <path class="ql-fill" d="M5,8H3A1,1,0,0,1,3,6H5A1,1,0,0,1,5,8Z"/>\n <path class="ql-fill" d="M5,12H3a1,1,0,0,1,0-2H5A1,1,0,0,1,5,12Z"/>\n <path class="ql-fill" d="M13,16H3a1,1,0,0,1,0-2H13A1,1,0,0,1,13,16Z"/>\n <path class="ql-fill" d="M13,4H3A1,1,0,0,1,3,2H13A1,1,0,0,1,13,4Z"/>\n <rect class="ql-fill" x="8" y="6" width="8" height="6" rx="1" ry="1" transform="translate(24 18) rotate(-180)"/>\n</svg>',full:'<svg viewbox="0 0 18 18">\n <path class="ql-fill" d="M13,16H5a1,1,0,0,1,0-2h8A1,1,0,0,1,13,16Z"/>\n <path class="ql-fill" d="M13,4H5A1,1,0,0,1,5,2h8A1,1,0,0,1,13,4Z"/>\n <rect class="ql-fill" x="2" y="6" width="14" height="6" rx="1" ry="1"/>\n</svg>',edit:'<svg viewBox="0 0 18 18">\n <path class="ql-fill" d="M 12.9 2 L 11.3 3.6 L 14.8 7 L 16.3 5.5 L 12.9 2 Z M 9.3 5.5 L 2 12.2 L 2 15.5 L 5.7 15.5 L 13 8.9 L 9.3 5.5 Z"></path>\n</svg>\n'}),P(T,"Tools",{left:{apply:function(t){C.add(t,"left")},isApplied:function(t){return"left"===C.value(t)}},center:{apply:function(t){C.add(t,"center")},isApplied:function(t){return"center"===C.value(t)}},right:{apply:function(t){C.add(t,"right")},isApplied:function(t){return"right"===C.value(t)}},full:{apply:function(t){C.add(t,"full")},isApplied:function(t){return"full"===C.value(t)}},edit:{handler:function(t,e,i){this.quill.emitter.emit("resize-edit",i,this.blot)}}});var W=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),_(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&R(t,e)}(e,t),i=e,r=[{key:"onCreate",value:function(){this.blotOptions=this.options.parchment[this.blot.statics.blotName],this.boxes=[],this.addBox("tl"),this.addBox("tr"),this.addBox("br"),this.addBox("bl")}},{key:"onDestroy",value:function(){this.setCursor("")}},{key:"addBox",value:function(t){var e=document.createElement("div");e.className="ql-resize-handle ".concat(t),e.addEventListener("mousedown",this.handleMousedown.bind(this),!1),this.overlay.appendChild(e),this.boxes.push(e)}},{key:"handleMousedown",value:function(t){var e=this;this.blot.handling&&this.blot.handling(!0),this.dragBox=t.target,this.dragStartX=t.clientX,this.dragStartY=t.clientY,this.preDragSize={width:this.activeEle.offsetWidth,height:this.activeEle.offsetHeight},this.naturalSize=this.getNaturalSize();var i=window.getComputedStyle(this.dragBox).cursor;this.setCursor(i),this.handleDragProxy=function(t){return e.handleDrag(t)},this.handleMouseupProxy=function(t){return e.handleMouseup(t)},document.addEventListener("mousemove",this.handleDragProxy,!1),document.addEventListener("mouseup",this.handleMouseupProxy,!1)}},{key:"handleMouseup",value:function(t){var e=this.calcSize(t,this.blotOptions.limit);Object.assign(this.activeEle,e),Object.assign(this.activeEle.style,{width:null,height:null}),this.setCursor(""),this.blot.handling&&this.blot.handling(!1),document.removeEventListener("mousemove",this.handleDragProxy),document.removeEventListener("mouseup",this.handleMouseupProxy)}},{key:"handleDrag",value:function(t){if(this.activeEle&&this.blot){var e=M(M({},this.blotOptions.limit),{},{unit:!0});Object.assign(this.activeEle.style,this.calcSize(t,e)),this.requestUpdate()}}},{key:"calcSize",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.clientX-this.dragStartX,o=t.clientY-this.dragStartY,n={},l=1;(this.blotOptions.attribute||["width"]).forEach((function(t){n[t]=e.preDragSize[t]})),this.dragBox!==this.boxes[0]&&this.dragBox!==this.boxes[3]||(l=-1),n.width&&(n.width=Math.round(this.preDragSize.width+r*l)),n.height&&(n.height=Math.round(this.preDragSize.height+o*l));var s,a=n.width,u=n.height;i.ratio?(i.minWidth&&(a=Math.max(i.minWidth,a)),i.maxWidth&&(a=Math.min(i.maxWidth,a)),u=a*i.ratio,i.minHeight&&u<i.minHeight&&(s=!0,u=i.minHeight),i.maxHeight&&u>i.maxHeight&&(s=!0,u=i.maxHeight),s&&(a=u/i.ratio)):(n.width&&(i.minWidth&&(a=Math.max(i.minWidth,a)),i.maxWidth&&(a=Math.min(i.maxWidth,a))),n.height&&(i.minHeight&&(u=Math.max(i.minHeight,u)),i.maxHeight&&(u=Math.min(i.maxHeight,u)))),i.unit&&(a&&(a+="px"),u&&(u+="px"));var c={};return a&&(c.width=a),u&&(c.height=u),c}},{key:"getNaturalSize",value:function(){var t=this.activeEle,e=[0,0];return t.getAttribute("data-size")?e=t.getAttribute("data-size").split(","):(e=[t.naturalWidth||t.offsetWidth,t.naturalHeight||t.offsetHeight],t.setAttribute("data-size",e[0]+","+e[1])),{width:parseInt(e[0]),height:parseInt(e[1])}}},{key:"setCursor",value:function(t){[document.body,this.activeEle].forEach((function(e){e.style.cursor="".concat(t," !important")}))}}],r&&z(i.prototype,r),o&&z(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,o}(u);function I(t){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},I(t)}function U(t,e,i){return(e=Q(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Z(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var r,o,n,l,s=[],a=!0,u=!1;try{if(n=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;a=!1}else for(;!(a=(r=n.call(i)).done)&&(s.push(r.value),s.length!==e);a=!0);}catch(t){u=!0,o=t}finally{try{if(!a&&null!=i.return&&(l=i.return(),Object(l)!==l))return}finally{if(u)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return F(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?F(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}function K(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Q(r.key),r)}}function Q(t){var e=function(t,e){if("object"!=I(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=I(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==I(e)?e:e+""}function G(t,e,i){return e=Y(e),function(t,e){if(e&&("object"==I(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,X()?Reflect.construct(e,i||[],Y(t).constructor):e.apply(t,i))}function X(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(X=function(){return!!t})()}function Y(t){return Y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Y(t)}function V(t,e){return V=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},V(t,e)}var $=window.Quill||g(),J=$.import("parchment"),tt={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46},et=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),G(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&V(t,e)}(e,t),i=e,o=[{key:"injectInit",value:function(t){var e=t.keyboard.bindings;e[this.keys.LEFT].unshift(this.makeArrowHandler(this.keys.LEFT,!1)),e[this.keys.RIGHT].unshift(this.makeArrowHandler(this.keys.RIGHT,!1))}},{key:"makeArrowHandler",value:function(t,i){var r=t===e.keys.LEFT?"prefix":"suffix";return U(U({key:t,shiftKey:i,altKey:null},r,/^$/),"handler",(function(i){if(!this.quill.resizer)return!0;var r=i.index,o=t===e.keys.LEFT,n=t===e.keys.RIGHT,l=Z(this.quill.getLine(r+(o?-1:0)),1)[0];if(this.quill.resizer.judgeShow(l))return!1;var s=this.quill.getIndex(l);if(n&&s+l.length()-1===r)return!0;n&&(r+=i.length+1);var a=Z(this.quill.getLeaf(r),1)[0],u=a.offset(a.parent),c=a.constructor.scope===J.Scope.BLOCK_BLOT;return!(!o||!(c&&r===u||0===r||r===s))||(o&&0===u&&(r-=1,a=this.quill.getLeaf(r)[0]),!this.quill.resizer.judgeShow(a))}))}}],(r=[{key:"onCreate",value:function(t){var e=this;this.keyboardProxy=function(t){return e.keyboardHandle(t)},document.addEventListener("keydown",this.keyboardProxy,!0)}},{key:"onDestroy",value:function(){document.removeEventListener("keydown",this.keyboardProxy,!0)}},{key:"keyboardHandle",value:function(t){if(!t.defaultPrevented&&!(t.shiftKey||t.ctrlKey||t.altKey)&&this.activeEle&&!t.fromResize&&!t.ctrlKey){var e,i=t.keyCode,r=this.blot.offset(this.quill.scroll),o=!1;i===tt.BACKSPACE||i===tt.DELETE?(this.blot.deleteAt(0),this.blot.parent.optimize(),o=!0):i>=tt.LEFT&&i<=tt.DOWN&&(i===tt.RIGHT?r+=this.blot.length()||1:i===tt.UP?(r=this.getOtherLineIndex(-1),e=this.quill.getLeaf(r)[0]):i===tt.DOWN&&(r=this.getOtherLineIndex(1),e=this.quill.getLeaf(r)[0]),o=!0),o&&(t.stopPropagation(),t.preventDefault()),e&&this.resizer.judgeShow(e,e.domNode)||(this.quill.setSelection(r),this.resizer.hide())}}},{key:"getOtherLineIndex",value:function(t){var e=this.blot.offset(this.quill.scroll),i=Z(this.quill.getLine(e),1)[0],r=this.blot.offset(i)+1,o=t>0?i.next:i.prev;if(o){var n=o.length();"block"===o.statics.blotName&&n--,e=o.offset(this.quill.scroll)+Math.min(n,r)}return e}},{key:"dispatchEvent",value:function(t){var e=new t.constructor(t);e.fromResize=!0,this.quill.root.dispatchEvent(e)}}])&&K(i.prototype,r),o&&K(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,o}(u);function it(t){return it="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},it(t)}function rt(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ot(r.key),r)}}function ot(t){var e=function(t,e){if("object"!=it(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=it(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==it(e)?e:e+""}/^2\./.test($.version)?et.keys={BACKSPACE:"Backspace",TAB:"Tab",ENTER:"Enter",ESCAPE:"Escape",LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown",DELETE:"Delete"}:et.keys=tt;var nt,lt,st,at=(window.Quill||g()).import("parchment"),ut=function(){return t=function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e.resizer=this,this.quill=e;var r=!1;i.modules&&(r=i.modules.slice()),this.options=Object.assign({},n,i),!1!==r&&(this.options.modules=r),document.execCommand("enableObjectResizing",!1,"false"),this.quill.root.addEventListener("mousedown",this.handleClick.bind(this),!1),this.quill.on("text-change",this.handleChange.bind(this)),this.quill.emitter.on("resize-edit",this.handleEdit.bind(this)),this.quill.container.style.position=this.quill.container.style.position||"relative",this.selectedBlots=[],this.options.selectedClass&&this.quill.on("selection-change",this.addBlotsSelectedClass.bind(this)),this.moduleClasses=this.options.modules,this.modules=[],this.options.keyboardSelect&&et.injectInit(this.quill),this.options.embedTags&&this.initializeEmbed()},e=[{key:"initializeModules",value:function(){var t=this;this.removeModules(),this.modules=this.moduleClasses.map((function(e){return new(t.constructor.Modules[e]||e)(t)})),this.modules.forEach((function(e){e.onCreate(t)})),this.onUpdate()}},{key:"initializeEmbed",value:function(){if(this.options.embedTags.length){this.embedClassName="ql-".concat(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";return Array.from({length:t},(function(){return e[Math.floor(62*Math.random())]})).join("")}());var t=[""].concat(this.options.embedTags).join(", .".concat(this.embedClassName," ")).slice(2);t+="{pointer-events: none;}";var e=document.createElement("style");e.textContent=t,this.quill.container.appendChild(e),this.quill.root.classList.add(this.embedClassName)}}},{key:"onUpdate",value:function(t){this.updateFromModule=t,this.repositionElements(),this.modules.forEach((function(t){t.onUpdate()}))}},{key:"removeModules",value:function(){this.modules.forEach((function(t){t.onDestroy()})),this.modules=[]}},{key:"handleEdit",value:function(){if(this.blot){var t=this.blot.offset(this.quill.scroll);this.hide(),this.quill.focus(),this.quill.setSelection(t,1)}}},{key:"handleClick",value:function(t){var e,i,r=!1,o=t.target,n=null===(e=this.options.embedTags)||void 0===e?void 0:e.join();if(n){var l=this.quill.root;(o===l||o.querySelectorAll(n).length)&&(l.classList.remove(this.embedClassName),o=document.elementFromPoint(t.clientX,t.clientY),l.classList.add(this.embedClassName))}o&&o.tagName&&(i=this.quill.constructor.find(o))&&(r=this.judgeShow(i,o)),r?t.preventDefault():this.activeEle&&this.hide()}},{key:"judgeShow",value:function(t,e){var i=!1;if(!t)return i;!e&&t.domNode&&(e=t.domNode);var r=this.options.parchment[t.statics.blotName];if(!r)return i;if(this.activeEle===e)return!0;var o=r.limit||{};return(!o.minWidth||o.minWidth&&e.offsetWidth>=o.minWidth)&&(i=!0,this.activeEle&&this.hide(),this.activeEle=e,this.blot=t,this.show(e)),i}},{key:"handleChange",value:function(t,e,i){this.updateFromModule?this.updateFromModule=!1:"user"===i&&this.overlay&&this.activeEle&&this.onUpdate()}},{key:"show",value:function(){this.showOverlay(),this.initializeModules(),this.options.activeClass&&this.activeEle.classList.add(this.options.activeClass)}},{key:"showOverlay",value:function(){var t=this;this.overlay&&this.hideOverlay(),this.quill.setSelection(null),this.setUserSelect("none"),this.overlay=document.createElement("div"),this.overlay.className="ql-resize-overlay",this.overlay.addEventListener("dblclick",this.handleEdit.bind(this),!1),this.quill.container.appendChild(this.overlay),this.hideProxy=function(e){t.activeEle&&t.hide()},this.quill.root.addEventListener("input",this.hideProxy,!0),this.updateOverlayPositionProxy=this.updateOverlayPosition.bind(this),this.quill.root.addEventListener("scroll",this.updateOverlayPositionProxy),this.repositionElements()}},{key:"hideOverlay",value:function(){this.overlay&&(this.quill.container.removeChild(this.overlay),this.overlay=void 0,this.quill.root.removeEventListener("input",this.hideProxy,!0),this.quill.root.removeEventListener("scroll",this.updateOverlayPositionProxy),this.setUserSelect(""))}},{key:"repositionElements",value:function(){if(this.overlay&&this.activeEle){var t=this.quill.container,e=this.activeEle.getBoundingClientRect(),i=t.getBoundingClientRect();Object.assign(this.overlay.style,{left:"".concat(e.left-i.left-1+t.scrollLeft,"px"),top:"".concat(e.top-i.top+this.quill.root.scrollTop,"px"),width:"".concat(e.width,"px"),height:"".concat(e.height,"px"),marginTop:-1*this.quill.root.scrollTop+"px"})}}},{key:"updateOverlayPosition",value:function(){this.overlay.style.marginTop=-1*this.quill.root.scrollTop+"px"}},{key:"addBlotsSelectedClass",value:function(t,e){var i=this;if(!t)return this.removeBlotsSelectedClass(),void(this.selectedBlots=[]);var r=this.quill.scroll.descendants(at.Leaf||at.LeafBlot,t.index,t.length).filter((function(t){var e=!!i.options.parchment[t.statics.blotName];return e&&t.domNode.classList.add(i.options.selectedClass),e}));this.removeBlotsSelectedClass(r),this.selectedBlots=r}},{key:"removeBlotsSelectedClass",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];Array.isArray(e)||(e=[e]),this.selectedBlots.forEach((function(i){-1===e.indexOf(i)&&i.domNode.classList.remove(t.options.selectedClass)}))}},{key:"hide",value:function(){this.hideOverlay(),this.removeModules(),this.activeEle&&this.options.activeClass&&this.activeEle.classList.remove(this.options.activeClass),this.activeEle=void 0,this.blot=void 0}},{key:"setUserSelect",value:function(t){var e=this;["userSelect","mozUserSelect","webkitUserSelect","msUserSelect"].forEach((function(i){e.quill.root.style[i]=t,document.documentElement.style[i]=t}))}}],e&&rt(t.prototype,e),i&&rt(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,i}();nt=ut,st={Base:u,DisplaySize:b,Toolbar:T,Resize:W,Keyboard:et},(lt=ot(lt="Modules"))in nt?Object.defineProperty(nt,lt,{value:st,enumerable:!0,configurable:!0,writable:!0}):nt[lt]=st,window.Quill&&window.Quill.register("modules/resize",ut);const ct=ut;return o})()));
|
|
5
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("Quill")):"function"==typeof define&&define.amd?define(["Quill"],e):"object"==typeof exports?exports.QuillResize=e(require("Quill")):t.QuillResize=e(t.Quill)}(self,(t=>(()=>{"use strict";var e=[,e=>{e.exports=t}],i={};function r(t){var o=i[t];if(void 0!==o)return o.exports;var n=i[t]={exports:{}};return e[t](n,n.exports,r),n.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};r.r(o),r.d(o,{default:()=>ct});const n={modules:["DisplaySize","Toolbar","Resize","Keyboard"],keyboardSelect:!0,selectedClass:"selected",activeClass:"active",embedTags:["VIDEO","IFRAME"],tools:["left","center","right","full","edit"],parchment:{image:{attribute:["width"],limit:{minWidth:100}},video:{attribute:["width","height"],limit:{minWidth:200,ratio:.5625}}}};function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function s(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,a(r.key),r)}}function a(t){var e=function(t,e){if("object"!=l(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==l(e)?e:e+""}var u=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.resizer=e,this.quill=e.quill,this.overlay=e.overlay,this.activeEle=e.activeEle,this.blot=e.blot,this.options=e.options,this.requestUpdate=function(){e.onUpdate(!0)}},(e=[{key:"onCreate",value:function(){}},{key:"onDestroy",value:function(){}},{key:"onUpdate",value:function(){}}])&&s(t.prototype,e),i&&s(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,i}();function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}function h(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,f(r.key),r)}}function f(t){var e=function(t,e){if("object"!=c(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=c(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==c(e)?e:e+""}function d(t,e,i){return e=y(e),function(t,e){if(e&&("object"==c(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,p()?Reflect.construct(e,i||[],y(t).constructor):e.apply(t,i))}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}function y(t){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},y(t)}function v(t,e){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},v(t,e)}var b=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),d(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&v(t,e)}(e,t),i=e,(r=[{key:"onCreate",value:function(){this.display=document.createElement("div"),this.display.className="ql-resize-display",this.overlay.appendChild(this.display)}},{key:"onUpdate",value:function(){if(this.display&&this.activeEle){var t=this.getCurrentSize();if(this.display.innerHTML=t.join(" × "),t[0]>120&&t[1]>30)Object.assign(this.display.style,{right:"4px",bottom:"4px",left:"auto"});else if("right"===this.activeEle.style.float){var e=this.display.getBoundingClientRect();Object.assign(this.display.style,{right:"auto",bottom:"-".concat(e.height+4,"px"),left:"-".concat(e.width+4,"px")})}else{var i=this.display.getBoundingClientRect();Object.assign(this.display.style,{right:"-".concat(i.width+4,"px"),bottom:"-".concat(i.height+4,"px"),left:"auto"})}}}},{key:"getCurrentSize",value:function(){return[this.activeEle.offsetWidth,this.activeEle.offsetHeight]}}])&&h(i.prototype,r),o&&h(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,o}(u);var m=r(1),g=r.n(m);function w(t){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(t)}function E(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,k(r.key),r)}}function O(t,e,i){return e=S(e),function(t,e){if(e&&("object"==w(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,j()?Reflect.construct(e,i||[],S(t).constructor):e.apply(t,i))}function j(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(j=function(){return!!t})()}function S(t){return S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},S(t)}function x(t,e){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},x(t,e)}function P(t,e,i){return(e=k(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function k(t){var e=function(t,e){if("object"!=w(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=w(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==w(e)?e:e+""}var q=(window.Quill||g()).import("parchment"),C=new(q.ClassAttributor?q.ClassAttributor:q.Attributor.Class)("imagestyle","ql-resize-style"),T=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),O(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&x(t,e)}(e,t),i=e,r=[{key:"onCreate",value:function(){this.toolbar=document.createElement("div"),this.toolbar.className="ql-resize-toolbar",this.overlay.appendChild(this.toolbar),this._addToolbarButtons()}},{key:"_addToolbarButtons",value:function(){var t=this,e=this.constructor.Icons,i=this.constructor.Tools,r=[];this.options.tools.forEach((function(o){var n=i[o]||o;if(!n.verify||!1!==n.verify.call(t,t.activeEle)){var l=document.createElement("button");l.type="button",r.push(l),l.innerHTML=(n.icon||"")+(n.text||"")||e[o],l.addEventListener("click",(function(e){n.handler&&!0!==n.handler.call(t,e,l,t.activeEle)||(r.forEach((function(t){return t.classList.remove("active")})),n.isApplied&&n.isApplied.call(t,t.activeEle)?C.remove(t.activeEle):(l.classList.add("active"),n.apply&&n.apply.call(t,t.activeEle)),t.requestUpdate())})),n.isApplied&&n.isApplied.call(t,t.activeEle)&&l.classList.add("active"),t.toolbar.appendChild(l)}}))}}],r&&E(i.prototype,r),o&&E(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,o}(u);function A(t){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},A(t)}function L(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function M(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?L(Object(i),!0).forEach((function(e){H(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):L(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function H(t,e,i){return(e=B(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function z(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,B(r.key),r)}}function B(t){var e=function(t,e){if("object"!=A(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=A(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==A(e)?e:e+""}function _(t,e,i){return e=N(e),function(t,e){if(e&&("object"==A(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,D()?Reflect.construct(e,i||[],N(t).constructor):e.apply(t,i))}function D(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(D=function(){return!!t})()}function N(t){return N=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},N(t)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}P(T,"Icons",{left:'<svg viewbox="0 0 18 18">\n <path class="ql-fill" d="M15,8H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,8Z"/>\n <path class="ql-fill" d="M15,12H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,12Z"/>\n <path class="ql-fill" d="M15,16H5a1,1,0,0,1,0-2H15A1,1,0,0,1,15,16Z"/>\n <path class="ql-fill" d="M15,4H5A1,1,0,0,1,5,2H15A1,1,0,0,1,15,4Z"/>\n <rect class="ql-fill" x="2" y="6" width="8" height="6" rx="1" ry="1"/>\n</svg>',center:'<svg viewbox="0 0 18 18">\n <path class="ql-fill" d="M14,16H4a1,1,0,0,1,0-2H14A1,1,0,0,1,14,16Z"/>\n <path class="ql-fill" d="M14,4H4A1,1,0,0,1,4,2H14A1,1,0,0,1,14,4Z"/>\n <rect class="ql-fill" x="3" y="6" width="12" height="6" rx="1" ry="1"/>\n</svg>',right:'<svg viewbox="0 0 18 18">\n <path class="ql-fill" d="M5,8H3A1,1,0,0,1,3,6H5A1,1,0,0,1,5,8Z"/>\n <path class="ql-fill" d="M5,12H3a1,1,0,0,1,0-2H5A1,1,0,0,1,5,12Z"/>\n <path class="ql-fill" d="M13,16H3a1,1,0,0,1,0-2H13A1,1,0,0,1,13,16Z"/>\n <path class="ql-fill" d="M13,4H3A1,1,0,0,1,3,2H13A1,1,0,0,1,13,4Z"/>\n <rect class="ql-fill" x="8" y="6" width="8" height="6" rx="1" ry="1" transform="translate(24 18) rotate(-180)"/>\n</svg>',full:'<svg viewbox="0 0 18 18">\n <path class="ql-fill" d="M13,16H5a1,1,0,0,1,0-2h8A1,1,0,0,1,13,16Z"/>\n <path class="ql-fill" d="M13,4H5A1,1,0,0,1,5,2h8A1,1,0,0,1,13,4Z"/>\n <rect class="ql-fill" x="2" y="6" width="14" height="6" rx="1" ry="1"/>\n</svg>',edit:'<svg viewBox="0 0 18 18">\n <path class="ql-fill" d="M 12.9 2 L 11.3 3.6 L 14.8 7 L 16.3 5.5 L 12.9 2 Z M 9.3 5.5 L 2 12.2 L 2 15.5 L 5.7 15.5 L 13 8.9 L 9.3 5.5 Z"></path>\n</svg>\n'}),P(T,"Tools",{left:{apply:function(t){C.add(t,"left")},isApplied:function(t){return"left"===C.value(t)}},center:{apply:function(t){C.add(t,"center")},isApplied:function(t){return"center"===C.value(t)}},right:{apply:function(t){C.add(t,"right")},isApplied:function(t){return"right"===C.value(t)}},full:{apply:function(t){C.add(t,"full")},isApplied:function(t){return"full"===C.value(t)}},edit:{handler:function(t,e,i){this.quill.emitter.emit("resize-edit",i,this.blot)}}});var W=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),_(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&R(t,e)}(e,t),i=e,r=[{key:"onCreate",value:function(){this.blotOptions=this.options.parchment[this.blot.statics.blotName],this.boxes=[],this.addBox("tl"),this.addBox("tr"),this.addBox("br"),this.addBox("bl")}},{key:"onDestroy",value:function(){this.setCursor("")}},{key:"addBox",value:function(t){var e=document.createElement("div");e.className="ql-resize-handle ".concat(t),e.addEventListener("mousedown",this.handleMousedown.bind(this),!1),this.overlay.appendChild(e),this.boxes.push(e)}},{key:"handleMousedown",value:function(t){var e=this;this.blot.handling&&this.blot.handling(!0),this.dragBox=t.target,this.dragStartX=t.clientX,this.dragStartY=t.clientY,this.preDragSize={width:this.activeEle.offsetWidth,height:this.activeEle.offsetHeight},this.naturalSize=this.getNaturalSize();var i=window.getComputedStyle(this.dragBox).cursor;this.setCursor(i),this.handleDragProxy=function(t){return e.handleDrag(t)},this.handleMouseupProxy=function(t){return e.handleMouseup(t)},document.addEventListener("mousemove",this.handleDragProxy,!1),document.addEventListener("mouseup",this.handleMouseupProxy,!1)}},{key:"handleMouseup",value:function(t){var e=this.calcSize(t,this.blotOptions.limit);Object.assign(this.activeEle,e),Object.assign(this.activeEle.style,{width:null,height:null}),this.setCursor(""),this.blot.handling&&this.blot.handling(!1),document.removeEventListener("mousemove",this.handleDragProxy),document.removeEventListener("mouseup",this.handleMouseupProxy)}},{key:"handleDrag",value:function(t){if(this.activeEle&&this.blot){var e=M(M({},this.blotOptions.limit),{},{unit:!0});Object.assign(this.activeEle.style,this.calcSize(t,e)),this.requestUpdate()}}},{key:"calcSize",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.clientX-this.dragStartX,o=t.clientY-this.dragStartY,n={},l=1;(this.blotOptions.attribute||["width"]).forEach((function(t){n[t]=e.preDragSize[t]})),this.dragBox!==this.boxes[0]&&this.dragBox!==this.boxes[3]||(l=-1),n.width&&(n.width=Math.round(this.preDragSize.width+r*l)),n.height&&(n.height=Math.round(this.preDragSize.height+o*l));var s,a=n.width,u=n.height;i.ratio?(i.minWidth&&(a=Math.max(i.minWidth,a)),i.maxWidth&&(a=Math.min(i.maxWidth,a)),u=a*i.ratio,i.minHeight&&u<i.minHeight&&(s=!0,u=i.minHeight),i.maxHeight&&u>i.maxHeight&&(s=!0,u=i.maxHeight),s&&(a=u/i.ratio)):(n.width&&(i.minWidth&&(a=Math.max(i.minWidth,a)),i.maxWidth&&(a=Math.min(i.maxWidth,a))),n.height&&(i.minHeight&&(u=Math.max(i.minHeight,u)),i.maxHeight&&(u=Math.min(i.maxHeight,u)))),i.unit&&(a&&(a+="px"),u&&(u+="px"));var c={};return a&&(c.width=a),u&&(c.height=u),c}},{key:"getNaturalSize",value:function(){var t=this.activeEle,e=[0,0];return t.getAttribute("data-size")?e=t.getAttribute("data-size").split(","):(e=[t.naturalWidth||t.offsetWidth,t.naturalHeight||t.offsetHeight],t.setAttribute("data-size",e[0]+","+e[1])),{width:parseInt(e[0]),height:parseInt(e[1])}}},{key:"setCursor",value:function(t){[document.body,this.activeEle].forEach((function(e){e.style.cursor="".concat(t," !important")}))}}],r&&z(i.prototype,r),o&&z(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,o}(u);function I(t){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},I(t)}function U(t,e,i){return(e=Q(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Z(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var r,o,n,l,s=[],a=!0,u=!1;try{if(n=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;a=!1}else for(;!(a=(r=n.call(i)).done)&&(s.push(r.value),s.length!==e);a=!0);}catch(t){u=!0,o=t}finally{try{if(!a&&null!=i.return&&(l=i.return(),Object(l)!==l))return}finally{if(u)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return F(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?F(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}function K(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Q(r.key),r)}}function Q(t){var e=function(t,e){if("object"!=I(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=I(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==I(e)?e:e+""}function G(t,e,i){return e=Y(e),function(t,e){if(e&&("object"==I(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,X()?Reflect.construct(e,i||[],Y(t).constructor):e.apply(t,i))}function X(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(X=function(){return!!t})()}function Y(t){return Y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Y(t)}function V(t,e){return V=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},V(t,e)}var $=window.Quill||g(),J=$.import("parchment"),tt={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46},et=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),G(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&V(t,e)}(e,t),i=e,o=[{key:"injectInit",value:function(t){var e=t.keyboard.bindings;e[this.keys.LEFT].unshift(this.makeArrowHandler(this.keys.LEFT,!1)),e[this.keys.RIGHT].unshift(this.makeArrowHandler(this.keys.RIGHT,!1))}},{key:"makeArrowHandler",value:function(t,i){var r=t===e.keys.LEFT?"prefix":"suffix";return U(U({key:t,shiftKey:i,altKey:null},r,/^$/),"handler",(function(i){if(!this.quill.resizer)return!0;var r=i.index,o=t===e.keys.LEFT,n=t===e.keys.RIGHT,l=Z(this.quill.getLine(r+(o?-1:0)),1)[0];if(this.quill.resizer.judgeShow(l))return!1;var s=this.quill.getIndex(l);if(n&&s+l.length()-1===r)return!0;n&&(r+=i.length+1);var a=Z(this.quill.getLeaf(r),1)[0],u=a.offset(a.parent),c=a.constructor.scope===J.Scope.BLOCK_BLOT;return!(!o||!(c&&r===u||0===r||r===s))||(o&&0===u&&(r-=1,a=this.quill.getLeaf(r)[0]),!this.quill.resizer.judgeShow(a))}))}}],(r=[{key:"onCreate",value:function(t){var e=this;this.keyboardProxy=function(t){return e.keyboardHandle(t)},document.addEventListener("keydown",this.keyboardProxy,!0)}},{key:"onDestroy",value:function(){document.removeEventListener("keydown",this.keyboardProxy,!0)}},{key:"keyboardHandle",value:function(t){if(!t.defaultPrevented&&!(t.shiftKey||t.ctrlKey||t.altKey)&&this.activeEle&&!t.fromResize&&!t.ctrlKey){var e,i=t.keyCode,r=this.blot.offset(this.quill.scroll),o=!1;i===tt.BACKSPACE||i===tt.DELETE?(this.blot.deleteAt(0),this.blot.parent.optimize(),o=!0):i>=tt.LEFT&&i<=tt.DOWN&&(i===tt.RIGHT?r+=this.blot.length()||1:i===tt.UP?(r=this.getOtherLineIndex(-1),e=this.quill.getLeaf(r)[0]):i===tt.DOWN&&(r=this.getOtherLineIndex(1),e=this.quill.getLeaf(r)[0]),o=!0),o&&(t.stopPropagation(),t.preventDefault()),e&&this.resizer.judgeShow(e,e.domNode)||(this.quill.setSelection(r),this.resizer.hide())}}},{key:"getOtherLineIndex",value:function(t){var e=this.blot.offset(this.quill.scroll),i=Z(this.quill.getLine(e),1)[0],r=this.blot.offset(i)+1,o=t>0?i.next:i.prev;if(o){var n=o.length();"block"===o.statics.blotName&&n--,e=o.offset(this.quill.scroll)+Math.min(n,r)}return e}},{key:"dispatchEvent",value:function(t){var e=new t.constructor(t);e.fromResize=!0,this.quill.root.dispatchEvent(e)}}])&&K(i.prototype,r),o&&K(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,o}(u);function it(t){return it="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},it(t)}function rt(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ot(r.key),r)}}function ot(t){var e=function(t,e){if("object"!=it(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=it(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==it(e)?e:e+""}/^2\./.test($.version)?et.keys={BACKSPACE:"Backspace",TAB:"Tab",ENTER:"Enter",ESCAPE:"Escape",LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown",DELETE:"Delete"}:et.keys=tt;var nt,lt,st,at=(window.Quill||g()).import("parchment"),ut=function(){return t=function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e.resizer=this,this.quill=e;var r=!1;i.modules&&(r=i.modules.slice()),this.options=Object.assign({},n,i),!1!==r&&(this.options.modules=r),document.execCommand("enableObjectResizing",!1,"false"),this.quill.root.addEventListener("mousedown",this.handleClick.bind(this),!1),this.quill.on("text-change",this.handleChange.bind(this)),this.quill.emitter.on("resize-edit",this.handleEdit.bind(this)),this.quill.container.style.position=this.quill.container.style.position||"relative",this.selectedBlots=[],this.options.selectedClass&&this.quill.on("selection-change",this.addBlotsSelectedClass.bind(this)),this.moduleClasses=this.options.modules,this.modules=[],this.options.keyboardSelect&&et.injectInit(this.quill),this.options.embedTags&&this.initializeEmbed()},e=[{key:"initializeModules",value:function(){var t=this;this.removeModules(),this.modules=this.moduleClasses.map((function(e){return new(t.constructor.Modules[e]||e)(t)})),this.modules.forEach((function(e){e.onCreate(t)})),this.onUpdate()}},{key:"initializeEmbed",value:function(){if(this.options.embedTags.length){this.embedClassName="ql-".concat(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";return Array.from({length:t},(function(){return e[Math.floor(62*Math.random())]})).join("")}());var t=[""].concat(this.options.embedTags).join(", .".concat(this.embedClassName," ")).slice(2);t+="{pointer-events: none;}";var e=document.createElement("style");e.textContent=t,this.quill.container.appendChild(e),this.quill.root.classList.add(this.embedClassName)}}},{key:"onUpdate",value:function(t){this.updateFromModule=t,this.repositionElements(),this.modules.forEach((function(t){t.onUpdate()}))}},{key:"removeModules",value:function(){this.modules.forEach((function(t){t.onDestroy()})),this.modules=[]}},{key:"handleEdit",value:function(){if(this.blot){var t=this.blot.offset(this.quill.scroll);this.hide(),this.quill.focus(),this.quill.setSelection(t,1)}}},{key:"handleClick",value:function(t){var e,i,r=!1,o=t.target,n=null===(e=this.options.embedTags)||void 0===e?void 0:e.join();if(n){var l=this.quill.root;(o===l||o.querySelectorAll(n).length)&&(l.classList.remove(this.embedClassName),o=document.elementFromPoint(t.clientX,t.clientY),l.classList.add(this.embedClassName))}o&&o.tagName&&(i=this.quill.constructor.find(o))&&(r=this.judgeShow(i,o)),r?t.preventDefault():this.activeEle&&this.hide()}},{key:"judgeShow",value:function(t,e){var i=!1;if(!t)return i;!e&&t.domNode&&(e=t.domNode);var r=this.options.parchment[t.statics.blotName];if(!r)return i;if(this.activeEle===e)return!0;var o=r.limit||{};return(!o.minWidth||o.minWidth&&e.offsetWidth>=o.minWidth)&&(i=!0,this.activeEle&&this.hide(),this.activeEle=e,this.blot=t,this.show(e)),i}},{key:"handleChange",value:function(t,e,i){this.updateFromModule?this.updateFromModule=!1:"user"===i&&this.overlay&&this.activeEle&&this.onUpdate()}},{key:"show",value:function(){this.showOverlay(),this.initializeModules(),this.options.activeClass&&this.activeEle.classList.add(this.options.activeClass)}},{key:"showOverlay",value:function(){var t=this;this.overlay&&this.hideOverlay(),this.quill.setSelection(null),this.setUserSelect("none"),this.overlay=document.createElement("div"),this.overlay.className="ql-resize-overlay",this.overlay.addEventListener("dblclick",this.handleEdit.bind(this),!1),this.quill.container.appendChild(this.overlay),this.hideProxy=function(e){t.activeEle&&t.hide()},this.quill.root.addEventListener("input",this.hideProxy,!0),this.updateOverlayPositionProxy=this.updateOverlayPosition.bind(this),this.quill.root.addEventListener("scroll",this.updateOverlayPositionProxy),this.repositionElements()}},{key:"hideOverlay",value:function(){this.overlay&&(this.quill.container.removeChild(this.overlay),this.overlay=void 0,this.quill.root.removeEventListener("input",this.hideProxy,!0),this.quill.root.removeEventListener("scroll",this.updateOverlayPositionProxy),this.setUserSelect(""))}},{key:"repositionElements",value:function(){if(this.overlay&&this.activeEle){var t=this.quill.container,e=this.activeEle.getBoundingClientRect(),i=t.getBoundingClientRect();Object.assign(this.overlay.style,{left:"".concat(e.left-i.left-1+t.scrollLeft,"px"),top:"".concat(e.top-i.top+this.quill.root.scrollTop,"px"),width:"".concat(e.width,"px"),height:"".concat(e.height,"px"),marginTop:-1*this.quill.root.scrollTop+"px"})}}},{key:"updateOverlayPosition",value:function(){this.overlay.style.marginTop=-1*this.quill.root.scrollTop+"px"}},{key:"addBlotsSelectedClass",value:function(t,e){var i=this;if(!t)return this.removeBlotsSelectedClass(),void(this.selectedBlots=[]);var r=this.quill.scroll.descendants(at.Leaf||at.LeafBlot,t.index,t.length).filter((function(t){var e=!!i.options.parchment[t.statics.blotName];return e&&t.domNode.classList.add(i.options.selectedClass),e}));this.removeBlotsSelectedClass(r),this.selectedBlots=r}},{key:"removeBlotsSelectedClass",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];Array.isArray(e)||(e=[e]),this.selectedBlots.forEach((function(i){-1===e.indexOf(i)&&i.domNode.classList.remove(t.options.selectedClass)}))}},{key:"hide",value:function(){this.hideOverlay(),this.removeModules(),this.activeEle&&this.options.activeClass&&this.activeEle.classList.remove(this.options.activeClass),this.activeEle=void 0,this.blot=void 0}},{key:"setUserSelect",value:function(t){var e=this;["userSelect","mozUserSelect","webkitUserSelect","msUserSelect"].forEach((function(i){e.quill.root.style[i]=t,document.documentElement.style[i]=t}))}}],e&&rt(t.prototype,e),i&&rt(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,i}();nt=ut,st={Base:u,DisplaySize:b,Toolbar:T,Resize:W,Keyboard:et},(lt=ot(lt="Modules"))in nt?Object.defineProperty(nt,lt,{value:st,enumerable:!0,configurable:!0,writable:!0}):nt[lt]=st,window.Quill&&window.Quill.register("modules/resize",ut);const ct=ut;return o})()));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quill-resize-module",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "A module for Quill rich text editor to allow images/iframe/video and custom elements
|
|
3
|
+
"version": "2.0.5",
|
|
4
|
+
"description": "A module for Quill rich text editor to allow images/iframe/video and custom elements to be resized.",
|
|
5
5
|
"main": "dist/resize.js",
|
|
6
6
|
"module": "src/index.js",
|
|
7
7
|
"scripts": {
|
package/src/assets/resize.scss
CHANGED
|
@@ -102,6 +102,7 @@
|
|
|
102
102
|
.ql-resize-style-center {
|
|
103
103
|
display: block;
|
|
104
104
|
margin: auto;
|
|
105
|
+
text-align: center;
|
|
105
106
|
}
|
|
106
107
|
.ql-resize-style-right {
|
|
107
108
|
float: right;
|
|
@@ -109,4 +110,7 @@
|
|
|
109
110
|
}
|
|
110
111
|
.ql-resize-style-full {
|
|
111
112
|
width: 100% !important;
|
|
113
|
+
> * {
|
|
114
|
+
width: 100%;
|
|
115
|
+
}
|
|
112
116
|
}
|
package/src/modules/Resize.js
CHANGED
|
@@ -32,7 +32,6 @@ export default class Resize extends BaseModule {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
handleMousedown (evt) {
|
|
35
|
-
this.blot.handling && this.blot.handling(true)
|
|
36
35
|
// note which box
|
|
37
36
|
this.dragBox = evt.target
|
|
38
37
|
// note starting mousedown position
|
|
@@ -64,7 +63,6 @@ export default class Resize extends BaseModule {
|
|
|
64
63
|
|
|
65
64
|
// reset cursor everywhere
|
|
66
65
|
this.setCursor('')
|
|
67
|
-
this.blot.handling && this.blot.handling(false)
|
|
68
66
|
// stop listening for movement and mouseup
|
|
69
67
|
document.removeEventListener('mousemove', this.handleDragProxy)
|
|
70
68
|
document.removeEventListener('mouseup', this.handleMouseupProxy)
|
package/src/modules/Toolbar.js
CHANGED
|
@@ -11,11 +11,32 @@ const Quill = window.Quill || _Quill
|
|
|
11
11
|
|
|
12
12
|
const Parchment = Quill.import('parchment')
|
|
13
13
|
|
|
14
|
+
const ALIGNMENT_CLASSES = {
|
|
15
|
+
LEFT: 'left',
|
|
16
|
+
RIGHT: 'right',
|
|
17
|
+
CENTER: 'center',
|
|
18
|
+
FULL: 'full'
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
// Quill.js 2.x support
|
|
15
22
|
const ClassAttributor = Parchment.ClassAttributor
|
|
16
23
|
? Parchment.ClassAttributor
|
|
17
24
|
: Parchment.Attributor.Class
|
|
18
|
-
|
|
25
|
+
|
|
26
|
+
const INLINE_FORMAT_ATTRIBUTOR = 'resize-inline'
|
|
27
|
+
const InlineFormatClass = new ClassAttributor(INLINE_FORMAT_ATTRIBUTOR, 'ql-resize-style', {
|
|
28
|
+
scope: Parchment.Scope.INLINE,
|
|
29
|
+
whitelist: Object.values(ALIGNMENT_CLASSES)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const BLOCK_FORMAT_ATTRIBUTOR = 'resize-block'
|
|
33
|
+
const BlockFormatClass = new ClassAttributor(BLOCK_FORMAT_ATTRIBUTOR, 'ql-resize-style', {
|
|
34
|
+
scope: Parchment.Scope.BLOCK,
|
|
35
|
+
whitelist: Object.values(ALIGNMENT_CLASSES)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
Quill.register(InlineFormatClass, true)
|
|
39
|
+
Quill.register(BlockFormatClass, true)
|
|
19
40
|
|
|
20
41
|
export default class Toolbar extends BaseModule {
|
|
21
42
|
static Icons = {
|
|
@@ -28,35 +49,27 @@ export default class Toolbar extends BaseModule {
|
|
|
28
49
|
|
|
29
50
|
static Tools = {
|
|
30
51
|
left: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
isApplied (activeEle) {
|
|
35
|
-
return ImageFormatClass.value(activeEle) === 'left'
|
|
52
|
+
toolClass: ALIGNMENT_CLASSES.LEFT,
|
|
53
|
+
isApplied (activeEle, blot) {
|
|
54
|
+
return this._getFormatValue(activeEle, blot) === ALIGNMENT_CLASSES.LEFT
|
|
36
55
|
}
|
|
37
56
|
},
|
|
38
57
|
center: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
isApplied (activeEle) {
|
|
43
|
-
return ImageFormatClass.value(activeEle) === 'center'
|
|
58
|
+
toolClass: ALIGNMENT_CLASSES.CENTER,
|
|
59
|
+
isApplied (activeEle, blot) {
|
|
60
|
+
return this._getFormatValue(activeEle, blot) === ALIGNMENT_CLASSES.CENTER
|
|
44
61
|
}
|
|
45
62
|
},
|
|
46
63
|
right: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
isApplied (activeEle) {
|
|
51
|
-
return ImageFormatClass.value(activeEle) === 'right'
|
|
64
|
+
toolClass: ALIGNMENT_CLASSES.RIGHT,
|
|
65
|
+
isApplied (activeEle, blot) {
|
|
66
|
+
return this._getFormatValue(activeEle, blot) === ALIGNMENT_CLASSES.RIGHT
|
|
52
67
|
}
|
|
53
68
|
},
|
|
54
69
|
full: {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
isApplied (activeEle) {
|
|
59
|
-
return ImageFormatClass.value(activeEle) === 'full'
|
|
70
|
+
toolClass: ALIGNMENT_CLASSES.FULL,
|
|
71
|
+
isApplied (activeEle, blot) {
|
|
72
|
+
return this._getFormatValue(activeEle, blot) === ALIGNMENT_CLASSES.FULL
|
|
60
73
|
}
|
|
61
74
|
},
|
|
62
75
|
edit: {
|
|
@@ -85,31 +98,64 @@ export default class Toolbar extends BaseModule {
|
|
|
85
98
|
if (tool.verify && tool.verify.call(this, this.activeEle) === false) return
|
|
86
99
|
|
|
87
100
|
const button = document.createElement('button')
|
|
101
|
+
button.type = 'button'
|
|
88
102
|
buttons.push(button)
|
|
89
103
|
button.innerHTML = ((tool.icon || '') + (tool.text || '')) || Icons[t]
|
|
104
|
+
if (typeof t === 'string') button.className = `ql-resize-toolbar-${t}`
|
|
105
|
+
if (tool.attrs) {
|
|
106
|
+
Object.keys(tool.attrs).forEach((key) => {
|
|
107
|
+
button.setAttribute(key, tool.attrs[key])
|
|
108
|
+
})
|
|
109
|
+
}
|
|
90
110
|
button.addEventListener('click', (evt) => {
|
|
91
111
|
if (tool.handler && tool.handler.call(this, evt, button, this.activeEle) !== true) return
|
|
92
112
|
|
|
93
113
|
// deselect all buttons
|
|
94
114
|
buttons.forEach(button => (button.classList.remove('active')))
|
|
95
|
-
if (tool.isApplied && tool.isApplied.call(this, this.activeEle)) {
|
|
115
|
+
if (tool.isApplied && tool.isApplied.call(this, this.activeEle, this.blot)) {
|
|
96
116
|
// If applied, unapply
|
|
97
|
-
|
|
117
|
+
this._applyToolFormatting('')
|
|
98
118
|
} else {
|
|
99
119
|
// otherwise, select button and apply
|
|
100
120
|
button.classList.add('active')
|
|
101
|
-
|
|
121
|
+
|
|
122
|
+
if (tool.toolClass) {
|
|
123
|
+
this._applyToolFormatting(tool.toolClass)
|
|
124
|
+
}
|
|
102
125
|
}
|
|
103
126
|
|
|
104
127
|
// image may change position; redraw drag handles
|
|
105
128
|
this.requestUpdate()
|
|
106
129
|
})
|
|
107
130
|
|
|
108
|
-
if (tool.isApplied && tool.isApplied.call(this, this.activeEle)) {
|
|
131
|
+
if (tool.isApplied && tool.isApplied.call(this, this.activeEle, this.blot)) {
|
|
109
132
|
// select button if previously applied
|
|
110
133
|
button.classList.add('active')
|
|
111
134
|
}
|
|
112
135
|
this.toolbar.appendChild(button)
|
|
113
136
|
})
|
|
114
137
|
}
|
|
138
|
+
|
|
139
|
+
_getFormatValue (activeEle, blot) {
|
|
140
|
+
if (blot.statics.scope === Parchment.Scope.INLINE_BLOT) {
|
|
141
|
+
// return InlineFormatClass.value(activeEle)
|
|
142
|
+
const blotIndex = this.quill.getIndex(blot)
|
|
143
|
+
const formats = this.quill.getFormat(blotIndex, 1)
|
|
144
|
+
return formats[INLINE_FORMAT_ATTRIBUTOR]
|
|
145
|
+
} else if (blot.statics.scope === Parchment.Scope.BLOCK_BLOT) {
|
|
146
|
+
return BlockFormatClass.value(activeEle)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
_applyToolFormatting (toolClass) {
|
|
151
|
+
const blotIndex = this.quill.getIndex(this.blot)
|
|
152
|
+
|
|
153
|
+
if (this.blot.statics.scope === Parchment.Scope.INLINE_BLOT) {
|
|
154
|
+
// Format inline blot
|
|
155
|
+
this.quill.formatText(blotIndex, 1, INLINE_FORMAT_ATTRIBUTOR, toolClass)
|
|
156
|
+
} else if (this.blot.statics.scope === Parchment.Scope.BLOCK_BLOT) {
|
|
157
|
+
// Format block blot
|
|
158
|
+
this.quill.formatLine(blotIndex, 1, BLOCK_FORMAT_ATTRIBUTOR, toolClass)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
115
161
|
}
|