quill-resize-module 2.0.6 → 2.0.7
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 +140 -59
- package/demo/index.js +16 -1
- package/dist/resize.css +1 -1
- package/dist/resize.js +2 -2
- package/package.json +2 -2
- package/src/QuillResize.js +2 -5
- package/src/modules/Keyboard.js +5 -0
- package/src/modules/Resize.js +1 -0
- package/src/modules/Toolbar.js +2 -2
package/README.md
CHANGED
|
@@ -68,104 +68,186 @@ var quill = new Quill(editor, {
|
|
|
68
68
|
|
|
69
69
|
### Config
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
Here's a complete configuration example showing all available options:
|
|
72
|
+
|
|
72
73
|
```javascript
|
|
73
|
-
|
|
74
|
-
// ...
|
|
74
|
+
const quill = new Quill(editor, {
|
|
75
75
|
modules: {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
resize: {
|
|
77
|
+
// Enable feature modules
|
|
78
|
+
modules: ['DisplaySize', 'Toolbar', 'Resize', 'Keyboard'],
|
|
79
|
+
|
|
80
|
+
// Enable keyboard arrow keys for selection
|
|
81
|
+
keyboardSelect: true,
|
|
82
|
+
|
|
83
|
+
// CSS classes for selected and active states
|
|
84
|
+
selectedClass: 'selected',
|
|
85
|
+
activeClass: 'active',
|
|
86
|
+
|
|
87
|
+
// Resizable embedded tags (video and iframe by default)
|
|
88
|
+
embedTags: ['VIDEO', 'IFRAME'],
|
|
89
|
+
|
|
90
|
+
// Toolbar buttons (default: left align, center, right align, full width, edit)
|
|
91
|
+
tools: ['left', 'center', 'right', 'full', 'edit'],
|
|
92
|
+
|
|
93
|
+
// Parchment configuration: set attributes and limits for different element types
|
|
94
|
+
parchment: {
|
|
95
|
+
// Image configuration
|
|
96
|
+
image: {
|
|
97
|
+
attribute: ['width'], // Adjustable attributes
|
|
98
|
+
limit: {
|
|
99
|
+
minWidth: 100 // Minimum width limit
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
// Video configuration
|
|
103
|
+
video: {
|
|
104
|
+
attribute: ['width', 'height'], // Adjustable attributes
|
|
105
|
+
limit: {
|
|
106
|
+
minWidth: 200, // Minimum width limit
|
|
107
|
+
ratio: 0.5625 // Width/height ratio limit (16:9)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
// Event callbacks
|
|
113
|
+
onActive: function (blot, target) {
|
|
114
|
+
// Triggered when an element is activated
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
onInactive: function (blot, target) {
|
|
118
|
+
// Triggered when an element is deactivated
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
onChangeSize: function (blot, target, size) {
|
|
122
|
+
// Triggered when element size changes
|
|
123
|
+
}
|
|
124
|
+
}
|
|
78
125
|
}
|
|
79
126
|
});
|
|
80
127
|
```
|
|
81
128
|
|
|
82
|
-
|
|
83
|
-
the default is to include all modules:
|
|
129
|
+
You can use only specific modules based on your needs. For example, if you only want resize and size display functionality:
|
|
84
130
|
|
|
85
131
|
```javascript
|
|
86
132
|
const quill = new Quill(editor, {
|
|
87
|
-
// ...
|
|
88
133
|
modules: {
|
|
89
|
-
// ...
|
|
90
134
|
resize: {
|
|
91
|
-
modules: [
|
|
135
|
+
modules: ['Resize', 'DisplaySize']
|
|
92
136
|
}
|
|
93
137
|
}
|
|
94
138
|
});
|
|
95
139
|
```
|
|
96
140
|
|
|
97
|
-
|
|
141
|
+
### Module Details
|
|
98
142
|
|
|
99
|
-
|
|
143
|
+
#### `Resize` Module - Element Resizing
|
|
144
|
+
|
|
145
|
+
This module adds drag handles to elements, allowing size adjustment via mouse. The behavior is controlled through the `parchment` configuration for different element types:
|
|
100
146
|
|
|
101
147
|
```javascript
|
|
102
148
|
const quill = new Quill(editor, {
|
|
103
|
-
// ...
|
|
104
149
|
modules: {
|
|
105
|
-
// ...
|
|
106
150
|
resize: {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
151
|
+
parchment: {
|
|
152
|
+
// Image element configuration
|
|
153
|
+
image: {
|
|
154
|
+
// Adjustable attributes: ['width'] or ['width', 'height']
|
|
155
|
+
attribute: ['width'],
|
|
156
|
+
// Size limits
|
|
157
|
+
limit: {
|
|
158
|
+
minWidth: 200, // Minimum width
|
|
159
|
+
maxWidth: 600, // Maximum width
|
|
160
|
+
minHeight: 200, // Minimum height
|
|
161
|
+
maxHeight: 450, // Maximum height
|
|
162
|
+
ratio: 0.5625 // Width/height ratio (e.g., 16:9 = 0.5625)
|
|
163
|
+
}
|
|
118
164
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (alt == null) return
|
|
123
|
-
activeEle.setAttribute('alt', alt)
|
|
165
|
+
// Similar configuration can be added for other element types
|
|
166
|
+
video: {
|
|
167
|
+
// ...
|
|
124
168
|
}
|
|
125
|
-
|
|
126
|
-
]
|
|
169
|
+
}
|
|
127
170
|
}
|
|
128
171
|
}
|
|
129
172
|
});
|
|
130
173
|
```
|
|
131
174
|
|
|
132
|
-
#### `
|
|
175
|
+
#### `Toolbar` Module - Toolbar
|
|
133
176
|
|
|
134
|
-
|
|
177
|
+
The toolbar module provides quick action buttons that can be customized through the `tools` option:
|
|
135
178
|
|
|
136
|
-
|
|
179
|
+
1. Predefined buttons:
|
|
180
|
+
- `left`: Left align
|
|
181
|
+
- `center`: Center align
|
|
182
|
+
- `right`: Right align
|
|
183
|
+
- `full`: Full width
|
|
184
|
+
- `edit`: Edit button
|
|
185
|
+
|
|
186
|
+
2. Custom button example:
|
|
137
187
|
|
|
138
188
|
```javascript
|
|
139
|
-
|
|
140
|
-
// ...
|
|
189
|
+
const quill = new Quill(editor, {
|
|
141
190
|
modules: {
|
|
142
|
-
// ...
|
|
143
191
|
resize: {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
192
|
+
tools: [
|
|
193
|
+
'left', 'right', // Use predefined buttons
|
|
194
|
+
{
|
|
195
|
+
text: 'Alt', // Button text
|
|
196
|
+
// Custom button attributes
|
|
197
|
+
attrs: {
|
|
198
|
+
title: 'Set image alt',
|
|
199
|
+
class: 'btn-alt'
|
|
200
|
+
},
|
|
201
|
+
// Button display condition
|
|
202
|
+
verify (activeEle) {
|
|
203
|
+
return activeEle?.tagName === 'IMG';
|
|
204
|
+
},
|
|
205
|
+
// Button click handler
|
|
206
|
+
handler (evt, button, activeEle) {
|
|
207
|
+
let alt = activeEle.alt || '';
|
|
208
|
+
alt = window.prompt('Alt for image', alt);
|
|
209
|
+
if (alt != null) {
|
|
210
|
+
activeEle.setAttribute('alt', alt);
|
|
211
|
+
}
|
|
155
212
|
}
|
|
156
213
|
}
|
|
157
|
-
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### `DisplaySize` Module - Size Display
|
|
221
|
+
|
|
222
|
+
Shows current size information while resizing elements. No additional configuration needed. Included in the default module list:
|
|
223
|
+
|
|
224
|
+
```javascript
|
|
225
|
+
const quill = new Quill(editor, {
|
|
226
|
+
modules: {
|
|
227
|
+
resize: {
|
|
228
|
+
modules: ['Resize', 'DisplaySize']
|
|
158
229
|
}
|
|
159
230
|
}
|
|
160
231
|
});
|
|
161
232
|
```
|
|
162
233
|
|
|
163
|
-
#### `
|
|
234
|
+
#### `Keyboard` Module - Keyboard Support
|
|
235
|
+
|
|
236
|
+
Enables element selection and manipulation using keyboard arrow keys. Can be controlled using the `keyboardSelect` option:
|
|
237
|
+
|
|
238
|
+
```javascript
|
|
239
|
+
const quill = new Quill(editor, {
|
|
240
|
+
modules: {
|
|
241
|
+
resize: {
|
|
242
|
+
keyboardSelect: true // Enable keyboard arrow key selection
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
```
|
|
164
247
|
|
|
165
|
-
|
|
166
|
-
the module setup.
|
|
248
|
+
#### Custom Module Development
|
|
167
249
|
|
|
168
|
-
|
|
250
|
+
You can create your own module by extending the `BaseModule` class. Here's a complete example:
|
|
169
251
|
|
|
170
252
|
```javascript
|
|
171
253
|
import QuillResize from 'quill-resize-module';
|
|
@@ -175,13 +257,12 @@ class MyModule extends QuillResize.Modules.Base {
|
|
|
175
257
|
// See src/modules/BaseModule.js for documentation on the various lifecycle callbacks
|
|
176
258
|
}
|
|
177
259
|
|
|
178
|
-
|
|
179
|
-
// ...
|
|
260
|
+
const quill = new Quill(editor, {
|
|
180
261
|
modules: {
|
|
181
|
-
// ...
|
|
262
|
+
// Other modules...
|
|
182
263
|
resize: {
|
|
183
|
-
modules: [
|
|
184
|
-
// ...
|
|
264
|
+
modules: [MyModule, QuillResize.Modules.Resize],
|
|
265
|
+
// Other configuration...
|
|
185
266
|
}
|
|
186
267
|
}
|
|
187
268
|
});
|
package/demo/index.js
CHANGED
|
@@ -40,7 +40,22 @@ const demoEditor = new Quill('#editor', {
|
|
|
40
40
|
activeEle.setAttribute('alt', alt)
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
]
|
|
43
|
+
],
|
|
44
|
+
|
|
45
|
+
// Triggered when an element is activated (selected)
|
|
46
|
+
onActive: function (blot, target) {
|
|
47
|
+
console.log('Element activated:', blot, target)
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
// Triggered when an element loses active state
|
|
51
|
+
onInactive: function (blot, target) {
|
|
52
|
+
console.log('Element deactivated:', blot, target)
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
// Triggered when element size changed
|
|
56
|
+
onChangeSize: function (blot, target, size) {
|
|
57
|
+
console.log('Size changed:', blot, target, size)
|
|
58
|
+
}
|
|
44
59
|
}
|
|
45
60
|
}
|
|
46
61
|
})
|
package/dist/resize.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Quill Resize Module v2.0.
|
|
2
|
+
* Quill Resize Module v2.0.7
|
|
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.7
|
|
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,k(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=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 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 C=window.Quill||g(),q=C.import("parchment"),L={LEFT:"left",RIGHT:"right",CENTER:"center",FULL:"full"},T=q.ClassAttributor?q.ClassAttributor:q.Attributor.Class,A="resize-inline",B=new T(A,"ql-resize-style",{scope:q.Scope.INLINE,whitelist:Object.values(L)}),H="resize-block",_=new T(H,"ql-resize-style",{scope:q.Scope.BLOCK,whitelist:Object.values(L)});C.register(B,!0),C.register(_,!0);var z=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)){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)||(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 _.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,H,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(z,"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(z,"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.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 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,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.keyboardSelect&&st.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,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)}},{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.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:z,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(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})()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quill-resize-module",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
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",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"build": "webpack --mode=production --node-env=production",
|
|
12
12
|
"build:dev": "webpack --mode=development",
|
|
13
13
|
"build:prod": "webpack --mode=production --node-env=production",
|
|
14
|
-
"prepublish": "
|
|
14
|
+
"prepublish": "npm run build"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
package/src/QuillResize.js
CHANGED
|
@@ -64,11 +64,6 @@ export default class QuillResize {
|
|
|
64
64
|
|
|
65
65
|
this.modules = []
|
|
66
66
|
|
|
67
|
-
// inject keyboard event
|
|
68
|
-
if (this.options.keyboardSelect) {
|
|
69
|
-
Keyboard.injectInit(this.quill)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
67
|
// create embed elements style
|
|
73
68
|
if (this.options.embedTags) {
|
|
74
69
|
this.initializeEmbed()
|
|
@@ -201,6 +196,7 @@ export default class QuillResize {
|
|
|
201
196
|
this.showOverlay()
|
|
202
197
|
this.initializeModules()
|
|
203
198
|
if (this.options.activeClass) this.activeEle.classList.add(this.options.activeClass)
|
|
199
|
+
this.options.onActive && this.options.onActive(this.blot, this.activeEle)
|
|
204
200
|
}
|
|
205
201
|
|
|
206
202
|
showOverlay () {
|
|
@@ -304,6 +300,7 @@ export default class QuillResize {
|
|
|
304
300
|
this.hideOverlay()
|
|
305
301
|
this.removeModules()
|
|
306
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)
|
|
307
304
|
this.activeEle = undefined
|
|
308
305
|
this.blot = undefined
|
|
309
306
|
}
|
package/src/modules/Keyboard.js
CHANGED
|
@@ -75,6 +75,11 @@ export default class Keyboard extends BaseModule {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
onCreate (e) {
|
|
78
|
+
// inject keyboard event
|
|
79
|
+
if (this.options.keyboardSelect) {
|
|
80
|
+
Keyboard.injectInit(this.quill)
|
|
81
|
+
}
|
|
82
|
+
|
|
78
83
|
this.keyboardProxy = evt => this.keyboardHandle(evt)
|
|
79
84
|
document.addEventListener('keydown', this.keyboardProxy, true)
|
|
80
85
|
}
|
package/src/modules/Resize.js
CHANGED
|
@@ -60,6 +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
64
|
|
|
64
65
|
// reset cursor everywhere
|
|
65
66
|
this.setCursor('')
|
package/src/modules/Toolbar.js
CHANGED
|
@@ -95,7 +95,7 @@ export default class Toolbar extends BaseModule {
|
|
|
95
95
|
const buttons = []
|
|
96
96
|
this.options.tools.forEach((t) => {
|
|
97
97
|
const tool = Tools[t] || t
|
|
98
|
-
if (tool.verify && tool.verify.call(this, this.activeEle) === false) return
|
|
98
|
+
if (tool.verify && tool.verify.call(this, this.activeEle, this.blot) === false) return
|
|
99
99
|
|
|
100
100
|
const button = document.createElement('button')
|
|
101
101
|
button.type = 'button'
|
|
@@ -108,7 +108,7 @@ export default class Toolbar extends BaseModule {
|
|
|
108
108
|
})
|
|
109
109
|
}
|
|
110
110
|
button.addEventListener('click', (evt) => {
|
|
111
|
-
if (tool.handler && tool.handler.call(this, evt, button, this.activeEle) !== true) return
|
|
111
|
+
if (tool.handler && tool.handler.call(this, evt, button, this.activeEle, this.blot) !== true) return
|
|
112
112
|
|
|
113
113
|
// deselect all buttons
|
|
114
114
|
buttons.forEach(button => (button.classList.remove('active')))
|