quill-resize-module 2.0.7 → 2.0.8
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/demo/index.js +3 -3
- package/dist/resize.css +1 -1
- package/dist/resize.js +2 -2
- package/package.json +1 -1
- package/src/QuillResize.js +2 -2
- package/src/modules/Resize.js +1 -1
package/demo/index.js
CHANGED
|
@@ -44,17 +44,17 @@ const demoEditor = new Quill('#editor', {
|
|
|
44
44
|
|
|
45
45
|
// Triggered when an element is activated (selected)
|
|
46
46
|
onActive: function (blot, target) {
|
|
47
|
-
console.log('Element activated:', blot, target)
|
|
47
|
+
console.log('Element activated:', this.quill, blot, target)
|
|
48
48
|
},
|
|
49
49
|
|
|
50
50
|
// Triggered when an element loses active state
|
|
51
51
|
onInactive: function (blot, target) {
|
|
52
|
-
console.log('Element deactivated:', blot, target)
|
|
52
|
+
console.log('Element deactivated:', this.quill, blot, target)
|
|
53
53
|
},
|
|
54
54
|
|
|
55
55
|
// Triggered when element size changed
|
|
56
56
|
onChangeSize: function (blot, target, size) {
|
|
57
|
-
console.log('Size changed:', blot, target, size)
|
|
57
|
+
console.log('Size changed:', this.quill, blot, target, size)
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
package/dist/resize.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Quill Resize Module v2.0.
|
|
2
|
+
* Quill Resize Module v2.0.8
|
|
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;text-align:center}.ql-resize-style-right{float:right;margin:0 0 1em 1em}.ql-resize-style-full{width:100% !important}.ql-resize-style-full>*{width:100%}
|
package/dist/resize.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Quill Resize Module v2.0.
|
|
2
|
+
* Quill Resize Module v2.0.8
|
|
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 o(t){var r=i[t];if(void 0!==r)return r.exports;var n=i[t]={exports:{}};return e[t](n,n.exports,o),n.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};o.r(r),o.d(r,{default:()=>vt});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 o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,a(o.key),o)}}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 o=i.call(t,e||"default");if("object"!=l(o))return o;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 o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,f(o.key),o)}}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 o=i.call(t,e||"default");if("object"!=c(o))return o;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,(o=[{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,o),r&&h(i,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,o,r}(u);var m=o(1),g=o.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 o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,C(o.key),o)}}function O(t,e,i){return e=j(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,S()?Reflect.construct(e,i||[],j(t).constructor):e.apply(t,i))}function S(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(S=function(){return!!t})()}function j(t){return j=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},j(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=C(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function C(t){var e=function(t,e){if("object"!=w(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,e||"default");if("object"!=w(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==w(e)?e:e+""}var k=window.Quill||g(),q=k.import("parchment"),L={LEFT:"left",RIGHT:"right",CENTER:"center",FULL:"full"},T=q.ClassAttributor?q.ClassAttributor:q.Attributor.Class,A="resize-inline",z=new T(A,"ql-resize-style",{scope:q.Scope.INLINE,whitelist:Object.values(L)}),B="resize-block",H=new T(B,"ql-resize-style",{scope:q.Scope.BLOCK,whitelist:Object.values(L)});k.register(z,!0),k.register(H,!0);var _=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,o=[{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,o=[];this.options.tools.forEach((function(r){var n=i[r]||r;if(!n.verify||!1!==n.verify.call(t,t.activeEle,t.blot)){var l=document.createElement("button");l.type="button",o.push(l),l.innerHTML=(n.icon||"")+(n.text||"")||e[r],"string"==typeof r&&(l.className="ql-resize-toolbar-".concat(r)),n.attrs&&Object.keys(n.attrs).forEach((function(t){l.setAttribute(t,n.attrs[t])})),l.addEventListener("click",(function(e){n.handler&&!0!==n.handler.call(t,e,l,t.activeEle,t.blot)||(o.forEach((function(t){return t.classList.remove("active")})),n.isApplied&&n.isApplied.call(t,t.activeEle,t.blot)?t._applyToolFormatting(""):(l.classList.add("active"),n.toolClass&&t._applyToolFormatting(n.toolClass)),t.requestUpdate())})),n.isApplied&&n.isApplied.call(t,t.activeEle,t.blot)&&l.classList.add("active"),t.toolbar.appendChild(l)}}))}},{key:"_getFormatValue",value:function(t,e){if(e.statics.scope===q.Scope.INLINE_BLOT){var i=this.quill.getIndex(e);return this.quill.getFormat(i,1)[A]}if(e.statics.scope===q.Scope.BLOCK_BLOT)return H.value(t)}},{key:"_applyToolFormatting",value:function(t){var e=this.quill.getIndex(this.blot);this.blot.statics.scope===q.Scope.INLINE_BLOT?this.quill.formatText(e,1,A,t):this.blot.statics.scope===q.Scope.BLOCK_BLOT&&this.quill.formatLine(e,1,B,t)}}],o&&E(i.prototype,o),r&&E(i,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,o,r}(u);function M(t){return M="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},M(t)}function N(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,o)}return i}function R(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?N(Object(i),!0).forEach((function(e){D(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):N(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function D(t,e,i){return(e=F(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function I(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,F(o.key),o)}}function F(t){var e=function(t,e){if("object"!=M(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,e||"default");if("object"!=M(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==M(e)?e:e+""}function U(t,e,i){return e=K(e),function(t,e){if(e&&("object"==M(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,W()?Reflect.construct(e,i||[],K(t).constructor):e.apply(t,i))}function W(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(W=function(){return!!t})()}function K(t){return K=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},K(t)}function Z(t,e){return Z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Z(t,e)}P(_,"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(_,"Tools",{left:{toolClass:L.LEFT,isApplied:function(t,e){return this._getFormatValue(t,e)===L.LEFT}},center:{toolClass:L.CENTER,isApplied:function(t,e){return this._getFormatValue(t,e)===L.CENTER}},right:{toolClass:L.RIGHT,isApplied:function(t,e){return this._getFormatValue(t,e)===L.RIGHT}},full:{toolClass:L.FULL,isApplied:function(t,e){return this._getFormatValue(t,e)===L.FULL}},edit:{handler:function(t,e,i){this.quill.emitter.emit("resize-edit",i,this.blot)}}});var Q=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),U(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&&Z(t,e)}(e,t),i=e,o=[{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.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.options.onChangeSize&&this.options.onChangeSize(this.blot,this.activeEle,e),this.setCursor(""),document.removeEventListener("mousemove",this.handleDragProxy),document.removeEventListener("mouseup",this.handleMouseupProxy)}},{key:"handleDrag",value:function(t){if(this.activeEle&&this.blot){var e=R(R({},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]:{},o=t.clientX-this.dragStartX,r=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+o*l)),n.height&&(n.height=Math.round(this.preDragSize.height+r*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")}))}}],o&&I(i.prototype,o),r&&I(i,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,o,r}(u);function G(t){return G="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},G(t)}function V(t,e,i){return(e=J(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function X(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 o,r,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=(o=n.call(i)).done)&&(s.push(o.value),s.length!==e);a=!0);}catch(t){u=!0,r=t}finally{try{if(!a&&null!=i.return&&(l=i.return(),Object(l)!==l))return}finally{if(u)throw r}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Y(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)?Y(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 Y(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,o=Array(e);i<e;i++)o[i]=t[i];return o}function $(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,J(o.key),o)}}function J(t){var e=function(t,e){if("object"!=G(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,e||"default");if("object"!=G(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==G(e)?e:e+""}function tt(t,e,i){return e=it(e),function(t,e){if(e&&("object"==G(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,et()?Reflect.construct(e,i||[],it(t).constructor):e.apply(t,i))}function et(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(et=function(){return!!t})()}function it(t){return it=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},it(t)}function ot(t,e){return ot=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ot(t,e)}var rt=window.Quill||g(),nt=rt.import("parchment"),lt={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46},st=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),tt(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&&ot(t,e)}(e,t),i=e,r=[{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 o=t===e.keys.LEFT?"prefix":"suffix";return V(V({key:t,shiftKey:i,altKey:null},o,/^$/),"handler",(function(i){if(!this.quill.resizer)return!0;var o=i.index,r=t===e.keys.LEFT,n=t===e.keys.RIGHT,l=X(this.quill.getLine(o+(r?-1:0)),1)[0];if(this.quill.resizer.judgeShow(l))return!1;var s=this.quill.getIndex(l);if(n&&s+l.length()-1===o)return!0;n&&(o+=i.length+1);var a=X(this.quill.getLeaf(o),1)[0],u=a.offset(a.parent),c=a.constructor.scope===nt.Scope.BLOCK_BLOT;return!(!r||!(c&&o===u||0===o||o===s))||(r&&0===u&&(o-=1,a=this.quill.getLeaf(o)[0]),!this.quill.resizer.judgeShow(a))}))}}],(o=[{key:"onCreate",value:function(t){var i=this;this.options.keyboardSelect&&e.injectInit(this.quill),this.keyboardProxy=function(t){return i.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,o=this.blot.offset(this.quill.scroll),r=!1;i===lt.BACKSPACE||i===lt.DELETE?(this.blot.deleteAt(0),this.blot.parent.optimize(),r=!0):i>=lt.LEFT&&i<=lt.DOWN&&(i===lt.RIGHT?o+=this.blot.length()||1:i===lt.UP?(o=this.getOtherLineIndex(-1),e=this.quill.getLeaf(o)[0]):i===lt.DOWN&&(o=this.getOtherLineIndex(1),e=this.quill.getLeaf(o)[0]),r=!0),r&&(t.stopPropagation(),t.preventDefault()),e&&this.resizer.judgeShow(e,e.domNode)||(this.quill.setSelection(o),this.resizer.hide())}}},{key:"getOtherLineIndex",value:function(t){var e=this.blot.offset(this.quill.scroll),i=X(this.quill.getLine(e),1)[0],o=this.blot.offset(i)+1,r=t>0?i.next:i.prev;if(r){var n=r.length();"block"===r.statics.blotName&&n--,e=r.offset(this.quill.scroll)+Math.min(n,o)}return e}},{key:"dispatchEvent",value:function(t){var e=new t.constructor(t);e.fromResize=!0,this.quill.root.dispatchEvent(e)}}])&&$(i.prototype,o),r&&$(i,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,o,r}(u);function at(t){return at="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},at(t)}function ut(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,ct(o.key),o)}}function ct(t){var e=function(t,e){if("object"!=at(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,e||"default");if("object"!=at(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==at(e)?e:e+""}/^2\./.test(rt.version)?st.keys={BACKSPACE:"Backspace",TAB:"Tab",ENTER:"Enter",ESCAPE:"Escape",LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown",DELETE:"Delete"}:st.keys=lt;var ht,ft,dt,pt=(window.Quill||g()).import("parchment"),yt=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 o=!1;i.modules&&(o=i.modules.slice()),this.options=Object.assign({},n,i),!1!==o&&(this.options.modules=o),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.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,o=!1,r=t.target,n=null===(e=this.options.embedTags)||void 0===e?void 0:e.join();if(n){var l=this.quill.root;(r===l||r.querySelectorAll(n).length)&&(l.classList.remove(this.embedClassName),r=document.elementFromPoint(t.clientX,t.clientY),l.classList.add(this.embedClassName))}r&&r.tagName&&(i=this.quill.constructor.find(r))&&(o=this.judgeShow(i,r)),o?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 o=this.options.parchment[t.statics.blotName];if(!o)return i;if(this.activeEle===e)return!0;var r=o.limit||{};return(!r.minWidth||r.minWidth&&e.offsetWidth>=r.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),this.options.onActive&&this.options.onActive(this.blot,this.activeEle)}},{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 o=this.quill.scroll.descendants(pt.Leaf||pt.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(o),this.selectedBlots=o}},{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.options.onInactive&&this.options.onInactive(this.blot,this.activeEle),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&&ut(t.prototype,e),i&&ut(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,i}();ht=yt,dt={Base:u,DisplaySize:b,Toolbar:_,Resize:Q,Keyboard:st},(ft=ct(ft="Modules"))in ht?Object.defineProperty(ht,ft,{value:dt,enumerable:!0,configurable:!0,writable:!0}):ht[ft]=dt,window.Quill&&window.Quill.register("modules/resize",yt);const vt=yt;return r})()));
|
|
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 o(t){var r=i[t];if(void 0!==r)return r.exports;var n=i[t]={exports:{}};return e[t](n,n.exports,o),n.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};o.r(r),o.d(r,{default:()=>vt});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 o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,a(o.key),o)}}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 o=i.call(t,e||"default");if("object"!=l(o))return o;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 o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,f(o.key),o)}}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 o=i.call(t,e||"default");if("object"!=c(o))return o;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,(o=[{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,o),r&&h(i,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,o,r}(u);var m=o(1),g=o.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 o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,C(o.key),o)}}function O(t,e,i){return e=j(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,S()?Reflect.construct(e,i||[],j(t).constructor):e.apply(t,i))}function S(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(S=function(){return!!t})()}function j(t){return j=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},j(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=C(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function C(t){var e=function(t,e){if("object"!=w(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,e||"default");if("object"!=w(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==w(e)?e:e+""}var k=window.Quill||g(),q=k.import("parchment"),L={LEFT:"left",RIGHT:"right",CENTER:"center",FULL:"full"},T=q.ClassAttributor?q.ClassAttributor:q.Attributor.Class,A="resize-inline",z=new T(A,"ql-resize-style",{scope:q.Scope.INLINE,whitelist:Object.values(L)}),B="resize-block",H=new T(B,"ql-resize-style",{scope:q.Scope.BLOCK,whitelist:Object.values(L)});k.register(z,!0),k.register(H,!0);var _=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,o=[{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,o=[];this.options.tools.forEach((function(r){var n=i[r]||r;if(!n.verify||!1!==n.verify.call(t,t.activeEle,t.blot)){var l=document.createElement("button");l.type="button",o.push(l),l.innerHTML=(n.icon||"")+(n.text||"")||e[r],"string"==typeof r&&(l.className="ql-resize-toolbar-".concat(r)),n.attrs&&Object.keys(n.attrs).forEach((function(t){l.setAttribute(t,n.attrs[t])})),l.addEventListener("click",(function(e){n.handler&&!0!==n.handler.call(t,e,l,t.activeEle,t.blot)||(o.forEach((function(t){return t.classList.remove("active")})),n.isApplied&&n.isApplied.call(t,t.activeEle,t.blot)?t._applyToolFormatting(""):(l.classList.add("active"),n.toolClass&&t._applyToolFormatting(n.toolClass)),t.requestUpdate())})),n.isApplied&&n.isApplied.call(t,t.activeEle,t.blot)&&l.classList.add("active"),t.toolbar.appendChild(l)}}))}},{key:"_getFormatValue",value:function(t,e){if(e.statics.scope===q.Scope.INLINE_BLOT){var i=this.quill.getIndex(e);return this.quill.getFormat(i,1)[A]}if(e.statics.scope===q.Scope.BLOCK_BLOT)return H.value(t)}},{key:"_applyToolFormatting",value:function(t){var e=this.quill.getIndex(this.blot);this.blot.statics.scope===q.Scope.INLINE_BLOT?this.quill.formatText(e,1,A,t):this.blot.statics.scope===q.Scope.BLOCK_BLOT&&this.quill.formatLine(e,1,B,t)}}],o&&E(i.prototype,o),r&&E(i,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,o,r}(u);function M(t){return M="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},M(t)}function N(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,o)}return i}function R(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?N(Object(i),!0).forEach((function(e){D(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):N(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function D(t,e,i){return(e=F(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function I(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,F(o.key),o)}}function F(t){var e=function(t,e){if("object"!=M(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,e||"default");if("object"!=M(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==M(e)?e:e+""}function U(t,e,i){return e=K(e),function(t,e){if(e&&("object"==M(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,W()?Reflect.construct(e,i||[],K(t).constructor):e.apply(t,i))}function W(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(W=function(){return!!t})()}function K(t){return K=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},K(t)}function Z(t,e){return Z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Z(t,e)}P(_,"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(_,"Tools",{left:{toolClass:L.LEFT,isApplied:function(t,e){return this._getFormatValue(t,e)===L.LEFT}},center:{toolClass:L.CENTER,isApplied:function(t,e){return this._getFormatValue(t,e)===L.CENTER}},right:{toolClass:L.RIGHT,isApplied:function(t,e){return this._getFormatValue(t,e)===L.RIGHT}},full:{toolClass:L.FULL,isApplied:function(t,e){return this._getFormatValue(t,e)===L.FULL}},edit:{handler:function(t,e,i){this.quill.emitter.emit("resize-edit",i,this.blot)}}});var Q=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),U(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&&Z(t,e)}(e,t),i=e,o=[{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.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.options.onChangeSize&&this.options.onChangeSize.call(this,this.blot,this.activeEle,e),this.setCursor(""),document.removeEventListener("mousemove",this.handleDragProxy),document.removeEventListener("mouseup",this.handleMouseupProxy)}},{key:"handleDrag",value:function(t){if(this.activeEle&&this.blot){var e=R(R({},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]:{},o=t.clientX-this.dragStartX,r=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+o*l)),n.height&&(n.height=Math.round(this.preDragSize.height+r*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")}))}}],o&&I(i.prototype,o),r&&I(i,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,o,r}(u);function G(t){return G="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},G(t)}function V(t,e,i){return(e=J(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function X(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 o,r,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=(o=n.call(i)).done)&&(s.push(o.value),s.length!==e);a=!0);}catch(t){u=!0,r=t}finally{try{if(!a&&null!=i.return&&(l=i.return(),Object(l)!==l))return}finally{if(u)throw r}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Y(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)?Y(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 Y(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,o=Array(e);i<e;i++)o[i]=t[i];return o}function $(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,J(o.key),o)}}function J(t){var e=function(t,e){if("object"!=G(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,e||"default");if("object"!=G(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==G(e)?e:e+""}function tt(t,e,i){return e=it(e),function(t,e){if(e&&("object"==G(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,et()?Reflect.construct(e,i||[],it(t).constructor):e.apply(t,i))}function et(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(et=function(){return!!t})()}function it(t){return it=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},it(t)}function ot(t,e){return ot=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ot(t,e)}var rt=window.Quill||g(),nt=rt.import("parchment"),lt={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46},st=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),tt(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&&ot(t,e)}(e,t),i=e,r=[{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 o=t===e.keys.LEFT?"prefix":"suffix";return V(V({key:t,shiftKey:i,altKey:null},o,/^$/),"handler",(function(i){if(!this.quill.resizer)return!0;var o=i.index,r=t===e.keys.LEFT,n=t===e.keys.RIGHT,l=X(this.quill.getLine(o+(r?-1:0)),1)[0];if(this.quill.resizer.judgeShow(l))return!1;var s=this.quill.getIndex(l);if(n&&s+l.length()-1===o)return!0;n&&(o+=i.length+1);var a=X(this.quill.getLeaf(o),1)[0],u=a.offset(a.parent),c=a.constructor.scope===nt.Scope.BLOCK_BLOT;return!(!r||!(c&&o===u||0===o||o===s))||(r&&0===u&&(o-=1,a=this.quill.getLeaf(o)[0]),!this.quill.resizer.judgeShow(a))}))}}],(o=[{key:"onCreate",value:function(t){var i=this;this.options.keyboardSelect&&e.injectInit(this.quill),this.keyboardProxy=function(t){return i.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,o=this.blot.offset(this.quill.scroll),r=!1;i===lt.BACKSPACE||i===lt.DELETE?(this.blot.deleteAt(0),this.blot.parent.optimize(),r=!0):i>=lt.LEFT&&i<=lt.DOWN&&(i===lt.RIGHT?o+=this.blot.length()||1:i===lt.UP?(o=this.getOtherLineIndex(-1),e=this.quill.getLeaf(o)[0]):i===lt.DOWN&&(o=this.getOtherLineIndex(1),e=this.quill.getLeaf(o)[0]),r=!0),r&&(t.stopPropagation(),t.preventDefault()),e&&this.resizer.judgeShow(e,e.domNode)||(this.quill.setSelection(o),this.resizer.hide())}}},{key:"getOtherLineIndex",value:function(t){var e=this.blot.offset(this.quill.scroll),i=X(this.quill.getLine(e),1)[0],o=this.blot.offset(i)+1,r=t>0?i.next:i.prev;if(r){var n=r.length();"block"===r.statics.blotName&&n--,e=r.offset(this.quill.scroll)+Math.min(n,o)}return e}},{key:"dispatchEvent",value:function(t){var e=new t.constructor(t);e.fromResize=!0,this.quill.root.dispatchEvent(e)}}])&&$(i.prototype,o),r&&$(i,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,o,r}(u);function at(t){return at="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},at(t)}function ut(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,ct(o.key),o)}}function ct(t){var e=function(t,e){if("object"!=at(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,e||"default");if("object"!=at(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==at(e)?e:e+""}/^2\./.test(rt.version)?st.keys={BACKSPACE:"Backspace",TAB:"Tab",ENTER:"Enter",ESCAPE:"Escape",LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown",DELETE:"Delete"}:st.keys=lt;var ht,ft,dt,pt=(window.Quill||g()).import("parchment"),yt=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 o=!1;i.modules&&(o=i.modules.slice()),this.options=Object.assign({},n,i),!1!==o&&(this.options.modules=o),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.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,o=!1,r=t.target,n=null===(e=this.options.embedTags)||void 0===e?void 0:e.join();if(n){var l=this.quill.root;(r===l||r.querySelectorAll(n).length)&&(l.classList.remove(this.embedClassName),r=document.elementFromPoint(t.clientX,t.clientY),l.classList.add(this.embedClassName))}r&&r.tagName&&(i=this.quill.constructor.find(r))&&(o=this.judgeShow(i,r)),o?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 o=this.options.parchment[t.statics.blotName];if(!o)return i;if(this.activeEle===e)return!0;var r=o.limit||{};return(!r.minWidth||r.minWidth&&e.offsetWidth>=r.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),this.options.onActive&&this.options.onActive.call(this,this.blot,this.activeEle)}},{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 o=this.quill.scroll.descendants(pt.Leaf||pt.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(o),this.selectedBlots=o}},{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.options.onInactive&&this.options.onInactive.call(this,this.blot,this.activeEle),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&&ut(t.prototype,e),i&&ut(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,i}();ht=yt,dt={Base:u,DisplaySize:b,Toolbar:_,Resize:Q,Keyboard:st},(ft=ct(ft="Modules"))in ht?Object.defineProperty(ht,ft,{value:dt,enumerable:!0,configurable:!0,writable:!0}):ht[ft]=dt,window.Quill&&window.Quill.register("modules/resize",yt);const vt=yt;return r})()));
|
package/package.json
CHANGED
package/src/QuillResize.js
CHANGED
|
@@ -196,7 +196,7 @@ export default class QuillResize {
|
|
|
196
196
|
this.showOverlay()
|
|
197
197
|
this.initializeModules()
|
|
198
198
|
if (this.options.activeClass) this.activeEle.classList.add(this.options.activeClass)
|
|
199
|
-
this.options.onActive && this.options.onActive(this.blot, this.activeEle)
|
|
199
|
+
this.options.onActive && this.options.onActive.call(this, this.blot, this.activeEle)
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
showOverlay () {
|
|
@@ -300,7 +300,7 @@ export default class QuillResize {
|
|
|
300
300
|
this.hideOverlay()
|
|
301
301
|
this.removeModules()
|
|
302
302
|
if (this.activeEle && this.options.activeClass) this.activeEle.classList.remove(this.options.activeClass)
|
|
303
|
-
this.options.onInactive && this.options.onInactive(this.blot, this.activeEle)
|
|
303
|
+
this.options.onInactive && this.options.onInactive.call(this, this.blot, this.activeEle)
|
|
304
304
|
this.activeEle = undefined
|
|
305
305
|
this.blot = undefined
|
|
306
306
|
}
|
package/src/modules/Resize.js
CHANGED
|
@@ -60,7 +60,7 @@ export default class Resize extends BaseModule {
|
|
|
60
60
|
const calcSize = this.calcSize(evt, this.blotOptions.limit)
|
|
61
61
|
Object.assign(this.activeEle, calcSize)
|
|
62
62
|
Object.assign(this.activeEle.style, { width: null, height: null })
|
|
63
|
-
this.options.onChangeSize && this.options.onChangeSize(this.blot, this.activeEle, calcSize)
|
|
63
|
+
this.options.onChangeSize && this.options.onChangeSize.call(this, this.blot, this.activeEle, calcSize)
|
|
64
64
|
|
|
65
65
|
// reset cursor everywhere
|
|
66
66
|
this.setCursor('')
|