quill-resize-module 2.1.0-beta.0 → 2.1.2
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 +13 -11
- package/demo/index.html +3 -2
- package/demo/index.ts +1 -2
- package/dist/DefaultOptions.d.ts.map +1 -1
- package/dist/QuillResize.d.ts +3 -7
- package/dist/QuillResize.d.ts.map +1 -1
- package/dist/Util.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/modules/BaseModule.d.ts.map +1 -1
- package/dist/modules/DisplaySize.d.ts.map +1 -1
- package/dist/modules/Keyboard.d.ts +0 -5
- package/dist/modules/Keyboard.d.ts.map +1 -1
- package/dist/modules/Resize.d.ts +4 -4
- package/dist/modules/Resize.d.ts.map +1 -1
- package/dist/modules/Toolbar.d.ts +0 -6
- package/dist/modules/Toolbar.d.ts.map +1 -1
- package/dist/resize.css +1 -5
- package/dist/resize.esm.js +82 -64
- package/dist/resize.js +2 -2
- package/package.json +1 -1
- package/src/QuillResize.ts +1 -0
- package/src/assets/resize.scss +1 -1
- package/src/modules/Resize.ts +41 -14
- package/src/types.d.ts +3 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Quill Resize Module
|
|
2
2
|
|
|
3
|
-
A module for Quill rich text editor
|
|
3
|
+
A module for Quill rich text editor that allows images/iframes/videos and custom embedded elements to be resized.
|
|
4
4
|
|
|
5
5
|
This module is original forked from <https://github.com/whatcould/quill-image-resize-module>.
|
|
6
6
|
|
|
@@ -8,18 +8,20 @@ This module is original forked from <https://github.com/whatcould/quill-image-re
|
|
|
8
8
|
1. Support Quill2
|
|
9
9
|
2. Removed formats/image formats/placeholder
|
|
10
10
|
3. Removed `options.styles`
|
|
11
|
-
4.
|
|
12
|
-
|
|
11
|
+
4. Added `embedTags` option for custom embedded elements
|
|
12
|
+
5. Added `tools` option for custom toolbar buttons
|
|
13
13
|
|
|
14
14
|
## Features
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
- Image resizing
|
|
16
|
+
- Embedded element resizing (defaults to iframe and video)
|
|
17
|
+
- Resize any custom elements
|
|
18
|
+
- Touch device support
|
|
19
|
+
|
|
20
|
+
- Min/max width and height limits
|
|
21
|
+
- Aspect ratio constraints
|
|
22
|
+
- Selected embedded element styling
|
|
23
|
+
- Arrow key support
|
|
24
|
+
|
|
23
25
|
|
|
24
26
|
## Demo
|
|
25
27
|
|
package/demo/index.html
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="utf-8">
|
|
6
6
|
<title>Quill Resize Module Demo</title>
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
8
|
<style>
|
|
8
9
|
body {
|
|
9
|
-
width: 1000px;
|
|
10
|
+
max-width: 1000px;
|
|
10
11
|
margin: 0 auto;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
.editor-box {
|
|
14
|
-
height: 600px;
|
|
15
15
|
padding-top: 42px;
|
|
16
16
|
margin: 0 auto;
|
|
17
17
|
}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
.editor-box .ql-container {
|
|
24
|
+
height: 600px;
|
|
24
25
|
overflow: hidden;
|
|
25
26
|
}
|
|
26
27
|
|
package/demo/index.ts
CHANGED
|
@@ -3,7 +3,6 @@ import '../src/assets/resize.scss'
|
|
|
3
3
|
|
|
4
4
|
import Resize from '../src/index'
|
|
5
5
|
import type { QuillResizeOptions } from '../src/DefaultOptions'
|
|
6
|
-
import '../src/types'
|
|
7
6
|
|
|
8
7
|
import _Quill from 'quill'
|
|
9
8
|
const Quill = window.Quill || _Quill
|
|
@@ -67,7 +66,7 @@ const demoEditor = new Quill('#editor', {
|
|
|
67
66
|
})
|
|
68
67
|
|
|
69
68
|
const $result = document.querySelector('#result') as HTMLTextAreaElement
|
|
70
|
-
$result.value = `Quill V${Quill.version}`
|
|
69
|
+
$result.value = `Quill V${Quill.version}\nResize Module V${Resize.version}\n`
|
|
71
70
|
document.querySelector('.btn-html')!.addEventListener('click', function () {
|
|
72
71
|
$result.value = demoEditor.root.innerHTML
|
|
73
72
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultOptions.d.ts","sourceRoot":"","sources":["../src/DefaultOptions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE3E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC;IACzD,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,KAAK,IAAI,CAAC;CAC7E;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,CAAC,UAAU,GAAG,GAAG,CAAC,EAAE,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,CAAC,MAAM,GAAG,gBAAgB,CAAC,EAAE,CAAC;IACtC,SAAS,CAAC,EAAE;QACV,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC;KAChC,CAAC;IACF,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,KAAK,IAAI,CAAC;IACvD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,KAAK,IAAI,CAAC;IACzD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACvG;AAED,QAAA,MAAM,cAAc,EAAE,kBAuBrB,
|
|
1
|
+
{"version":3,"file":"DefaultOptions.d.ts","sourceRoot":"","sources":["../src/DefaultOptions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE3E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC;IACzD,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,KAAK,IAAI,CAAC;CAC7E;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,CAAC,UAAU,GAAG,GAAG,CAAC,EAAE,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,CAAC,MAAM,GAAG,gBAAgB,CAAC,EAAE,CAAC;IACtC,SAAS,CAAC,EAAE;QACV,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC;KAChC,CAAC;IACF,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,KAAK,IAAI,CAAC;IACvD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,KAAK,IAAI,CAAC;IACzD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACvG;AAED,QAAA,MAAM,cAAc,EAAE,kBAuBrB,CAAA;AAED,eAAe,cAAc,CAAA"}
|
package/dist/QuillResize.d.ts
CHANGED
|
@@ -5,11 +5,6 @@ import Toolbar from './modules/Toolbar';
|
|
|
5
5
|
import Resize from './modules/Resize';
|
|
6
6
|
import Keyboard from './modules/Keyboard';
|
|
7
7
|
import Quill from 'quill';
|
|
8
|
-
declare global {
|
|
9
|
-
interface Window {
|
|
10
|
-
Quill?: typeof Quill;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
8
|
/**
|
|
14
9
|
* Custom module for quilljs to allow user to resize elements
|
|
15
10
|
* (Works on Chrome, Edge, Safari and replaces Firefox's native resize behavior)
|
|
@@ -23,6 +18,7 @@ export default class QuillResize {
|
|
|
23
18
|
Resize: typeof Resize;
|
|
24
19
|
Keyboard: typeof Keyboard;
|
|
25
20
|
};
|
|
21
|
+
static version: string;
|
|
26
22
|
quill: Quill;
|
|
27
23
|
options: QuillResizeOptions;
|
|
28
24
|
moduleClasses: any[];
|
|
@@ -44,12 +40,12 @@ export default class QuillResize {
|
|
|
44
40
|
handleClick(evt: MouseEvent): void;
|
|
45
41
|
judgeShow(blot: any, target?: HTMLElement): boolean;
|
|
46
42
|
handleChange(delta: any, oldDelta: any, source: string): void;
|
|
47
|
-
show(
|
|
43
|
+
show(): void;
|
|
48
44
|
showOverlay(): void;
|
|
49
45
|
hideOverlay(): void;
|
|
50
46
|
repositionElements(): void;
|
|
51
47
|
updateOverlayPosition(): void;
|
|
52
|
-
addBlotsSelectedClass(range: any
|
|
48
|
+
addBlotsSelectedClass(range: any): void;
|
|
53
49
|
removeBlotsSelectedClass(ignoreBlots?: any | any[]): void;
|
|
54
50
|
hide(): void;
|
|
55
51
|
setUserSelect(value: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuillResize.d.ts","sourceRoot":"","sources":["../src/QuillResize.ts"],"names":[],"mappings":"AAAA,OAAuB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"QuillResize.d.ts","sourceRoot":"","sources":["../src/QuillResize.ts"],"names":[],"mappings":"AAAA,OAAuB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,IAAI,MAAM,sBAAsB,CAAA;AACvC,OAAO,WAAW,MAAM,uBAAuB,CAAA;AAC/C,OAAO,OAAO,MAAM,mBAAmB,CAAA;AACvC,OAAO,MAAM,MAAM,kBAAkB,CAAA;AACrC,OAAO,QAAQ,MAAM,oBAAoB,CAAA;AAEzC,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B,MAAM,CAAC,OAAO;;;;;;MAAmD;IACjE,MAAM,CAAC,OAAO,SAAc;IAE5B,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,kBAAkB,CAAA;IAC3B,aAAa,EAAE,GAAG,EAAE,CAAA;IACpB,OAAO,EAAE,GAAG,EAAE,CAAK;IACnB,aAAa,EAAE,GAAG,EAAE,CAAK;IACzB,SAAS,CAAC,EAAE,WAAW,CAAA;IACvB,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAA;IACvC,gBAAgB,CAAC,EAAE,OAAO,CAAA;gBAEb,KAAK,EAAE,KAAK,EAAE,OAAO,GAAE,kBAAuB;IAqD3D,iBAAiB,IAAK,IAAI;IAc1B,eAAe,IAAK,IAAI;IAYxB,QAAQ,CAAE,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI;IAQrC,aAAa,IAAK,IAAI;IAQtB,UAAU,IAAK,IAAI;IAQnB,WAAW,CAAE,GAAG,EAAE,UAAU,GAAG,IAAI;IAgCnC,SAAS,CAAE,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO;IA8BpD,YAAY,CAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAU9D,IAAI,IAAK,IAAI;IAOb,WAAW,IAAK,IAAI;IA+BpB,WAAW,IAAK,IAAI;IAiBpB,kBAAkB,IAAK,IAAI;IAmB3B,qBAAqB,IAAK,IAAI;IAI9B,qBAAqB,CAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAiBxC,wBAAwB,CAAE,WAAW,GAAE,GAAG,GAAG,GAAG,EAAO,GAAG,IAAI;IAU9D,IAAI,IAAK,IAAI;IASb,aAAa,CAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAYpC"}
|
package/dist/Util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../src/Util.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,YAAY,
|
|
1
|
+
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../src/Util.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,YAAY,CAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAGxD"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,sBAAsB,CAAA;AAE7B,cAAc,kBAAkB,CAAA;AAChC,eAAe,WAAW,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseModule.d.ts","sourceRoot":"","sources":["../../src/modules/BaseModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"BaseModule.d.ts","sourceRoot":"","sources":["../../src/modules/BaseModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,WAAW,MAAM,gBAAgB,CAAA;AAExC,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,OAAO,EAAE,GAAG,CAAA;IACZ,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,WAAW,CAAA;IACpB,SAAS,EAAE,WAAW,CAAA;IACtB,IAAI,EAAE,GAAG,CAAA;IACT,OAAO,EAAE,kBAAkB,CAAA;IAC3B,aAAa,EAAE,MAAM,IAAI,CAAA;gBAEZ,OAAO,EAAE,WAAW;IA4BjC,QAAQ,IAAK,IAAI;IAOjB,SAAS,IAAK,IAAI;IAQlB,QAAQ,IAAK,IAAI;CAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisplaySize.d.ts","sourceRoot":"","sources":["../../src/modules/DisplaySize.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"DisplaySize.d.ts","sourceRoot":"","sources":["../../src/modules/DisplaySize.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAA;AAErC,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,OAAO,EAAE,WAAW,GAAG,IAAI,CAAO;IAElC,QAAQ,IAAK,IAAI;IASjB,QAAQ,IAAK,IAAI;IAiCjB,cAAc,IAAK,CAAC,MAAM,EAAE,MAAM,CAAC;CAGpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Keyboard.d.ts","sourceRoot":"","sources":["../../src/modules/Keyboard.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"Keyboard.d.ts","sourceRoot":"","sources":["../../src/modules/Keyboard.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,OAAO,CAAA;AAiBzB,UAAU,YAAY;IACpB,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,UAAU;IAC9C,MAAM,CAAC,IAAI,EAAE,YAAY,CAAA;IACzB,aAAa,EAAG,CAAC,GAAG,EAAE,aAAa,KAAK,IAAI,CAAA;IAE5C,MAAM,CAAC,UAAU,CAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAWtC,MAAM,CAAC,gBAAgB,CAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,GAAG;IA6CtE,QAAQ,IAAK,IAAI;IAUjB,SAAS,IAAK,IAAI;IAIlB,cAAc,CAAE,GAAG,EAAE,aAAa,GAAG,IAAI;IA2CzC,iBAAiB,CAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAiBvC,aAAa,CAAE,GAAG,EAAE,KAAK,GAAG,IAAI;CAKjC"}
|
package/dist/modules/Resize.d.ts
CHANGED
|
@@ -24,10 +24,10 @@ export default class Resize extends BaseModule {
|
|
|
24
24
|
onCreate(): void;
|
|
25
25
|
onDestroy(): void;
|
|
26
26
|
addBox(place: string): void;
|
|
27
|
-
handleMousedown(evt: MouseEvent): void;
|
|
28
|
-
handleMouseup(evt: MouseEvent): void;
|
|
29
|
-
handleDrag(evt: MouseEvent): void;
|
|
30
|
-
calcSize(evt: MouseEvent, limit?: SizeLimit & {
|
|
27
|
+
handleMousedown(evt: MouseEvent | TouchEvent): void;
|
|
28
|
+
handleMouseup(evt: MouseEvent | TouchEvent): void;
|
|
29
|
+
handleDrag(evt: MouseEvent | TouchEvent): void;
|
|
30
|
+
calcSize(evt: MouseEvent | TouchEvent, limit?: SizeLimit & {
|
|
31
31
|
unit?: boolean;
|
|
32
32
|
}): SizeResult;
|
|
33
33
|
getNaturalSize(): NaturalSize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resize.d.ts","sourceRoot":"","sources":["../../src/modules/Resize.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"Resize.d.ts","sourceRoot":"","sources":["../../src/modules/Resize.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE9D,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,UAAU;IAC5C,WAAW,EAAG,eAAe,CAAA;IAC7B,KAAK,EAAE,WAAW,EAAE,CAAK;IACzB,OAAO,EAAG,WAAW,CAAA;IACrB,UAAU,EAAG,MAAM,CAAA;IACnB,UAAU,EAAG,MAAM,CAAA;IACnB,WAAW,EAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IAC/C,WAAW,EAAG,WAAW,CAAA;IACzB,eAAe,EAAG,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAA;IAC3C,kBAAkB,EAAG,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAA;IAE9C,QAAQ,IAAK,IAAI;IAYjB,SAAS,IAAK,IAAI;IAKlB,MAAM,CAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAc5B,eAAe,CAAE,GAAG,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;IAgCpD,aAAa,CAAE,GAAG,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;IAmBlD,UAAU,CAAE,GAAG,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;IAmB/C,QAAQ,CAAE,GAAG,EAAE,UAAU,GAAG,UAAU,EAAE,KAAK,GAAE,SAAS,GAAG;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,UAAU;IA6E/F,cAAc,IAAK,WAAW;IAmB9B,SAAS,CAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAKhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/modules/Toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/modules/Toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAA;AAuCrC,UAAU,UAAU;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAClC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;IACvE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;IAC1E,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,GAAG,IAAI,CAAC;CAC5H;AAED,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,UAAU;IAC7C,MAAM,CAAC,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAMtC;IAED,MAAM,CAAC,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG;YAAE,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,MAAM,CAAA;SAAE,CAAA;KAAE,CA8BhH;IAED,OAAO,EAAG,WAAW,CAAA;IAErB,QAAQ,IAAK,IAAI;IAUjB,kBAAkB,IAAK,IAAI;IA+C3B,eAAe,CAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,MAAM;IAY3D,oBAAoB,CAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAW/C"}
|
package/dist/resize.css
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Quill Resize Module v2.1.0-beta.0
|
|
3
|
-
* https://github.com/mudoo/quill-resize-module
|
|
4
|
-
*/
|
|
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%}
|
|
1
|
+
.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:nesw-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.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Quill Resize Module v2.1.
|
|
2
|
+
* Quill Resize Module v2.1.2
|
|
3
3
|
* https://github.com/mudoo/quill-resize-module
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import { default as __WEBPACK_EXTERNAL_MODULE_quill_default__ } from "quill";
|
|
6
6
|
/******/ // The require scope
|
|
7
7
|
/******/ var __webpack_require__ = {};
|
|
8
8
|
/******/
|
|
@@ -27,11 +27,6 @@ import * as __WEBPACK_EXTERNAL_MODULE_quill__ from "quill";
|
|
|
27
27
|
/************************************************************************/
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
|
|
30
|
-
// EXPORTS
|
|
31
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
32
|
-
A: () => (/* binding */ src)
|
|
33
|
-
});
|
|
34
|
-
|
|
35
30
|
;// ./src/DefaultOptions.ts
|
|
36
31
|
const defaultOptions = {
|
|
37
32
|
modules: ['DisplaySize', 'Toolbar', 'Resize', 'Keyboard'],
|
|
@@ -44,17 +39,17 @@ const defaultOptions = {
|
|
|
44
39
|
image: {
|
|
45
40
|
attribute: ['width'],
|
|
46
41
|
limit: {
|
|
47
|
-
minWidth: 100
|
|
48
|
-
}
|
|
42
|
+
minWidth: 100,
|
|
43
|
+
},
|
|
49
44
|
},
|
|
50
45
|
video: {
|
|
51
46
|
attribute: ['width', 'height'],
|
|
52
47
|
limit: {
|
|
53
48
|
minWidth: 200,
|
|
54
|
-
ratio: 0.5625
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
49
|
+
ratio: 0.5625,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
58
53
|
};
|
|
59
54
|
/* harmony default export */ const DefaultOptions = (defaultOptions);
|
|
60
55
|
|
|
@@ -128,7 +123,7 @@ class DisplaySize extends BaseModule {
|
|
|
128
123
|
Object.assign(this.display.style, {
|
|
129
124
|
right: '4px',
|
|
130
125
|
bottom: '4px',
|
|
131
|
-
left: 'auto'
|
|
126
|
+
left: 'auto',
|
|
132
127
|
});
|
|
133
128
|
}
|
|
134
129
|
else if (this.activeEle.style.float === 'right') {
|
|
@@ -137,7 +132,7 @@ class DisplaySize extends BaseModule {
|
|
|
137
132
|
Object.assign(this.display.style, {
|
|
138
133
|
right: 'auto',
|
|
139
134
|
bottom: `-${displayRect.height + 4}px`,
|
|
140
|
-
left: `-${displayRect.width + 4}px
|
|
135
|
+
left: `-${displayRect.width + 4}px`,
|
|
141
136
|
});
|
|
142
137
|
}
|
|
143
138
|
else {
|
|
@@ -146,7 +141,7 @@ class DisplaySize extends BaseModule {
|
|
|
146
141
|
Object.assign(this.display.style, {
|
|
147
142
|
right: `-${displayRect.width + 4}px`,
|
|
148
143
|
bottom: `-${displayRect.height + 4}px`,
|
|
149
|
-
left: 'auto'
|
|
144
|
+
left: 'auto',
|
|
150
145
|
});
|
|
151
146
|
}
|
|
152
147
|
}
|
|
@@ -156,18 +151,14 @@ class DisplaySize extends BaseModule {
|
|
|
156
151
|
}
|
|
157
152
|
|
|
158
153
|
;// external "quill"
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
var y = (x) => (() => (x))
|
|
163
|
-
const external_quill_namespaceObject = x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_quill__["default"]) });
|
|
164
|
-
;// ./node_modules/quill/assets/icons/float-left.svg?raw
|
|
154
|
+
|
|
155
|
+
;// ./node_modules/.pnpm/quill@2.0.3/node_modules/quill/assets/icons/float-left.svg?raw
|
|
165
156
|
const float_leftraw_namespaceObject = "<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>";
|
|
166
|
-
;// ./node_modules/quill/assets/icons/float-center.svg?raw
|
|
157
|
+
;// ./node_modules/.pnpm/quill@2.0.3/node_modules/quill/assets/icons/float-center.svg?raw
|
|
167
158
|
const float_centerraw_namespaceObject = "<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>";
|
|
168
|
-
;// ./node_modules/quill/assets/icons/float-right.svg?raw
|
|
159
|
+
;// ./node_modules/.pnpm/quill@2.0.3/node_modules/quill/assets/icons/float-right.svg?raw
|
|
169
160
|
const float_rightraw_namespaceObject = "<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>";
|
|
170
|
-
;// ./node_modules/quill/assets/icons/float-full.svg?raw
|
|
161
|
+
;// ./node_modules/.pnpm/quill@2.0.3/node_modules/quill/assets/icons/float-full.svg?raw
|
|
171
162
|
const float_fullraw_namespaceObject = "<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>";
|
|
172
163
|
;// ./src/assets/pencil.svg?raw
|
|
173
164
|
const pencilraw_namespaceObject = "<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";
|
|
@@ -179,13 +170,13 @@ const pencilraw_namespaceObject = "<svg viewBox=\"0 0 18 18\">\n <path class=\"
|
|
|
179
170
|
|
|
180
171
|
|
|
181
172
|
|
|
182
|
-
const _Quill = window.Quill ||
|
|
173
|
+
const _Quill = window.Quill || __WEBPACK_EXTERNAL_MODULE_quill_default__;
|
|
183
174
|
const Parchment = _Quill.import('parchment');
|
|
184
175
|
const ALIGNMENT_CLASSES = {
|
|
185
176
|
LEFT: 'left',
|
|
186
177
|
RIGHT: 'right',
|
|
187
178
|
CENTER: 'center',
|
|
188
|
-
FULL: 'full'
|
|
179
|
+
FULL: 'full',
|
|
189
180
|
};
|
|
190
181
|
// Quill.js 2.x support
|
|
191
182
|
const ClassAttributor = Parchment.ClassAttributor
|
|
@@ -194,12 +185,12 @@ const ClassAttributor = Parchment.ClassAttributor
|
|
|
194
185
|
const INLINE_FORMAT_ATTRIBUTOR = 'resize-inline';
|
|
195
186
|
const InlineFormatClass = new ClassAttributor(INLINE_FORMAT_ATTRIBUTOR, 'ql-resize-style', {
|
|
196
187
|
scope: Parchment.Scope.INLINE,
|
|
197
|
-
whitelist: Object.values(ALIGNMENT_CLASSES)
|
|
188
|
+
whitelist: Object.values(ALIGNMENT_CLASSES),
|
|
198
189
|
});
|
|
199
190
|
const BLOCK_FORMAT_ATTRIBUTOR = 'resize-block';
|
|
200
191
|
const BlockFormatClass = new ClassAttributor(BLOCK_FORMAT_ATTRIBUTOR, 'ql-resize-style', {
|
|
201
192
|
scope: Parchment.Scope.BLOCK,
|
|
202
|
-
whitelist: Object.values(ALIGNMENT_CLASSES)
|
|
193
|
+
whitelist: Object.values(ALIGNMENT_CLASSES),
|
|
203
194
|
});
|
|
204
195
|
_Quill.register(InlineFormatClass, true);
|
|
205
196
|
_Quill.register(BlockFormatClass, true);
|
|
@@ -286,38 +277,38 @@ Toolbar.Icons = {
|
|
|
286
277
|
center: float_centerraw_namespaceObject,
|
|
287
278
|
right: float_rightraw_namespaceObject,
|
|
288
279
|
full: float_fullraw_namespaceObject,
|
|
289
|
-
edit: pencilraw_namespaceObject
|
|
280
|
+
edit: pencilraw_namespaceObject,
|
|
290
281
|
};
|
|
291
282
|
Toolbar.Tools = {
|
|
292
283
|
left: {
|
|
293
284
|
toolClass: ALIGNMENT_CLASSES.LEFT,
|
|
294
285
|
isApplied(activeEle, blot) {
|
|
295
286
|
return this._getFormatValue(activeEle, blot) === ALIGNMENT_CLASSES.LEFT;
|
|
296
|
-
}
|
|
287
|
+
},
|
|
297
288
|
},
|
|
298
289
|
center: {
|
|
299
290
|
toolClass: ALIGNMENT_CLASSES.CENTER,
|
|
300
291
|
isApplied(activeEle, blot) {
|
|
301
292
|
return this._getFormatValue(activeEle, blot) === ALIGNMENT_CLASSES.CENTER;
|
|
302
|
-
}
|
|
293
|
+
},
|
|
303
294
|
},
|
|
304
295
|
right: {
|
|
305
296
|
toolClass: ALIGNMENT_CLASSES.RIGHT,
|
|
306
297
|
isApplied(activeEle, blot) {
|
|
307
298
|
return this._getFormatValue(activeEle, blot) === ALIGNMENT_CLASSES.RIGHT;
|
|
308
|
-
}
|
|
299
|
+
},
|
|
309
300
|
},
|
|
310
301
|
full: {
|
|
311
302
|
toolClass: ALIGNMENT_CLASSES.FULL,
|
|
312
303
|
isApplied(activeEle, blot) {
|
|
313
304
|
return this._getFormatValue(activeEle, blot) === ALIGNMENT_CLASSES.FULL;
|
|
314
|
-
}
|
|
305
|
+
},
|
|
315
306
|
},
|
|
316
307
|
edit: {
|
|
317
308
|
handler(evt, button, activeEle, blot) {
|
|
318
309
|
this.quill.emitter.emit('resize-edit', activeEle, blot);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
310
|
+
},
|
|
311
|
+
},
|
|
321
312
|
};
|
|
322
313
|
/* harmony default export */ const modules_Toolbar = (Toolbar);
|
|
323
314
|
|
|
@@ -348,6 +339,7 @@ class Resize extends BaseModule {
|
|
|
348
339
|
box.className = `ql-resize-handle ${place}`;
|
|
349
340
|
// listen for mousedown on each box
|
|
350
341
|
box.addEventListener('mousedown', this.handleMousedown.bind(this), false);
|
|
342
|
+
box.addEventListener('touchstart', this.handleMousedown.bind(this), { passive: false });
|
|
351
343
|
// add drag handle to document
|
|
352
344
|
this.overlay.appendChild(box);
|
|
353
345
|
// keep track of drag handle
|
|
@@ -357,12 +349,18 @@ class Resize extends BaseModule {
|
|
|
357
349
|
// note which box
|
|
358
350
|
this.dragBox = evt.target;
|
|
359
351
|
// note starting mousedown position
|
|
360
|
-
|
|
361
|
-
|
|
352
|
+
if (evt instanceof TouchEvent) {
|
|
353
|
+
this.dragStartX = evt.changedTouches[0].clientX;
|
|
354
|
+
this.dragStartY = evt.changedTouches[0].clientY;
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
this.dragStartX = evt.clientX;
|
|
358
|
+
this.dragStartY = evt.clientY;
|
|
359
|
+
}
|
|
362
360
|
// store the width before the drag
|
|
363
361
|
this.preDragSize = {
|
|
364
362
|
width: this.activeEle.offsetWidth,
|
|
365
|
-
height: this.activeEle.offsetHeight
|
|
363
|
+
height: this.activeEle.offsetHeight,
|
|
366
364
|
};
|
|
367
365
|
// store the natural size
|
|
368
366
|
this.naturalSize = this.getNaturalSize();
|
|
@@ -372,37 +370,55 @@ class Resize extends BaseModule {
|
|
|
372
370
|
this.handleDragProxy = (evt) => this.handleDrag(evt);
|
|
373
371
|
this.handleMouseupProxy = (evt) => this.handleMouseup(evt);
|
|
374
372
|
// listen for movement and mouseup
|
|
375
|
-
document.addEventListener('mousemove', this.handleDragProxy
|
|
376
|
-
document.addEventListener('
|
|
373
|
+
document.addEventListener('mousemove', this.handleDragProxy);
|
|
374
|
+
document.addEventListener('touchmove', this.handleDragProxy, { passive: false });
|
|
375
|
+
document.addEventListener('mouseup', this.handleMouseupProxy, true);
|
|
376
|
+
document.addEventListener('touchend', this.handleMouseupProxy, true);
|
|
377
|
+
document.addEventListener('touchcancel', this.handleMouseupProxy, true);
|
|
377
378
|
}
|
|
378
379
|
handleMouseup(evt) {
|
|
380
|
+
var _a;
|
|
381
|
+
evt.stopPropagation();
|
|
379
382
|
// save size, clear style
|
|
380
383
|
const calcSize = this.calcSize(evt, this.blotOptions.limit);
|
|
381
384
|
Object.assign(this.activeEle, calcSize);
|
|
382
385
|
Object.assign(this.activeEle.style, { width: null, height: null });
|
|
383
|
-
this.options.onChangeSize
|
|
386
|
+
(_a = this.options.onChangeSize) === null || _a === void 0 ? void 0 : _a.call(this, this.blot, this.activeEle, calcSize);
|
|
384
387
|
// reset cursor everywhere
|
|
385
388
|
this.setCursor('');
|
|
386
389
|
// stop listening for movement and mouseup
|
|
387
390
|
document.removeEventListener('mousemove', this.handleDragProxy);
|
|
388
|
-
document.removeEventListener('
|
|
391
|
+
document.removeEventListener('touchmove', this.handleDragProxy);
|
|
392
|
+
document.removeEventListener('mouseup', this.handleMouseupProxy, true);
|
|
393
|
+
document.removeEventListener('touchend', this.handleMouseupProxy, true);
|
|
394
|
+
document.removeEventListener('touchcancel', this.handleMouseupProxy, true);
|
|
389
395
|
}
|
|
390
396
|
handleDrag(evt) {
|
|
391
397
|
if (!this.activeEle || !this.blot) {
|
|
392
398
|
// activeEle not set yet
|
|
393
399
|
return;
|
|
394
400
|
}
|
|
401
|
+
if (evt instanceof TouchEvent && evt.cancelable) {
|
|
402
|
+
evt.preventDefault();
|
|
403
|
+
}
|
|
395
404
|
const limit = Object.assign(Object.assign({}, this.blotOptions.limit), { unit: true });
|
|
396
405
|
Object.assign(this.activeEle.style, this.calcSize(evt, limit));
|
|
397
406
|
this.requestUpdate();
|
|
398
407
|
}
|
|
399
408
|
calcSize(evt, limit = {}) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
409
|
+
let clientX, clientY;
|
|
410
|
+
if (evt instanceof TouchEvent) {
|
|
411
|
+
clientX = evt.changedTouches[0].clientX;
|
|
412
|
+
clientY = evt.changedTouches[0].clientY;
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
clientX = evt.clientX;
|
|
416
|
+
clientY = evt.clientY;
|
|
417
|
+
}
|
|
418
|
+
const deltaX = clientX - this.dragStartX;
|
|
419
|
+
const deltaY = clientY - this.dragStartY;
|
|
403
420
|
const size = {};
|
|
404
421
|
let direction = 1;
|
|
405
|
-
;
|
|
406
422
|
(this.blotOptions.attribute || ['width']).forEach(key => {
|
|
407
423
|
size[key] = this.preDragSize[key];
|
|
408
424
|
});
|
|
@@ -470,7 +486,7 @@ class Resize extends BaseModule {
|
|
|
470
486
|
if (!ele.getAttribute('data-size')) {
|
|
471
487
|
size = [
|
|
472
488
|
ele.naturalWidth || ele.offsetWidth,
|
|
473
|
-
ele.naturalHeight || ele.offsetHeight
|
|
489
|
+
ele.naturalHeight || ele.offsetHeight,
|
|
474
490
|
];
|
|
475
491
|
ele.setAttribute('data-size', size[0] + ',' + size[1]);
|
|
476
492
|
}
|
|
@@ -480,7 +496,7 @@ class Resize extends BaseModule {
|
|
|
480
496
|
}
|
|
481
497
|
return {
|
|
482
498
|
width: size[0],
|
|
483
|
-
height: size[1]
|
|
499
|
+
height: size[1],
|
|
484
500
|
};
|
|
485
501
|
}
|
|
486
502
|
setCursor(value) {
|
|
@@ -493,7 +509,7 @@ class Resize extends BaseModule {
|
|
|
493
509
|
;// ./src/modules/Keyboard.ts
|
|
494
510
|
|
|
495
511
|
|
|
496
|
-
const Keyboard_Quill = window.Quill ||
|
|
512
|
+
const Keyboard_Quill = window.Quill || __WEBPACK_EXTERNAL_MODULE_quill_default__;
|
|
497
513
|
const Keyboard_Parchment = Keyboard_Quill.import('parchment');
|
|
498
514
|
const keyCodes = {
|
|
499
515
|
BACKSPACE: 8,
|
|
@@ -504,7 +520,7 @@ const keyCodes = {
|
|
|
504
520
|
UP: 38,
|
|
505
521
|
RIGHT: 39,
|
|
506
522
|
DOWN: 40,
|
|
507
|
-
DELETE: 46
|
|
523
|
+
DELETE: 46,
|
|
508
524
|
};
|
|
509
525
|
class Keyboard extends BaseModule {
|
|
510
526
|
static injectInit(quill) {
|
|
@@ -551,7 +567,7 @@ class Keyboard extends BaseModule {
|
|
|
551
567
|
}
|
|
552
568
|
}
|
|
553
569
|
return !this.quill.resizer.judgeShow(leaf);
|
|
554
|
-
}
|
|
570
|
+
},
|
|
555
571
|
};
|
|
556
572
|
}
|
|
557
573
|
onCreate() {
|
|
@@ -637,7 +653,7 @@ if (/^2\./.test(Keyboard_Quill.version)) {
|
|
|
637
653
|
UP: 'ArrowUp',
|
|
638
654
|
RIGHT: 'ArrowRight',
|
|
639
655
|
DOWN: 'ArrowDown',
|
|
640
|
-
DELETE: 'Delete'
|
|
656
|
+
DELETE: 'Delete',
|
|
641
657
|
};
|
|
642
658
|
}
|
|
643
659
|
else {
|
|
@@ -664,7 +680,7 @@ function randomString(length = 8) {
|
|
|
664
680
|
|
|
665
681
|
|
|
666
682
|
|
|
667
|
-
const QuillResize_Quill = window.Quill ||
|
|
683
|
+
const QuillResize_Quill = window.Quill || __WEBPACK_EXTERNAL_MODULE_quill_default__;
|
|
668
684
|
const QuillResize_Parchment = QuillResize_Quill.import('parchment');
|
|
669
685
|
/**
|
|
670
686
|
* Custom module for quilljs to allow user to resize elements
|
|
@@ -804,7 +820,7 @@ class QuillResize {
|
|
|
804
820
|
this.activeEle = target;
|
|
805
821
|
this.blot = blot;
|
|
806
822
|
// clicked on an image inside the editor
|
|
807
|
-
this.show(
|
|
823
|
+
this.show();
|
|
808
824
|
}
|
|
809
825
|
return res;
|
|
810
826
|
}
|
|
@@ -817,12 +833,13 @@ class QuillResize {
|
|
|
817
833
|
return;
|
|
818
834
|
this.onUpdate();
|
|
819
835
|
}
|
|
820
|
-
show(
|
|
836
|
+
show() {
|
|
837
|
+
var _a;
|
|
821
838
|
this.showOverlay();
|
|
822
839
|
this.initializeModules();
|
|
823
840
|
if (this.options.activeClass)
|
|
824
841
|
this.activeEle.classList.add(this.options.activeClass);
|
|
825
|
-
this.options.onActive
|
|
842
|
+
(_a = this.options.onActive) === null || _a === void 0 ? void 0 : _a.call(this, this.blot, this.activeEle);
|
|
826
843
|
}
|
|
827
844
|
showOverlay() {
|
|
828
845
|
if (this.overlay) {
|
|
@@ -837,7 +854,7 @@ class QuillResize {
|
|
|
837
854
|
// this.overlay.setAttribute('title', "Double-click to select image");
|
|
838
855
|
this.overlay.addEventListener('dblclick', this.handleEdit.bind(this), false);
|
|
839
856
|
this.quill.container.appendChild(this.overlay);
|
|
840
|
-
this.hideProxy = (
|
|
857
|
+
this.hideProxy = () => {
|
|
841
858
|
if (!this.activeEle)
|
|
842
859
|
return;
|
|
843
860
|
this.hide();
|
|
@@ -874,13 +891,13 @@ class QuillResize {
|
|
|
874
891
|
top: `${eleRect.top - containerRect.top + this.quill.root.scrollTop}px`,
|
|
875
892
|
width: `${eleRect.width}px`,
|
|
876
893
|
height: `${eleRect.height}px`,
|
|
877
|
-
marginTop: -1 * this.quill.root.scrollTop + 'px'
|
|
894
|
+
marginTop: -1 * this.quill.root.scrollTop + 'px',
|
|
878
895
|
});
|
|
879
896
|
}
|
|
880
897
|
updateOverlayPosition() {
|
|
881
898
|
this.overlay.style.marginTop = -1 * this.quill.root.scrollTop + 'px';
|
|
882
899
|
}
|
|
883
|
-
addBlotsSelectedClass(range
|
|
900
|
+
addBlotsSelectedClass(range) {
|
|
884
901
|
if (!range) {
|
|
885
902
|
this.removeBlotsSelectedClass();
|
|
886
903
|
this.selectedBlots = [];
|
|
@@ -907,11 +924,12 @@ class QuillResize {
|
|
|
907
924
|
});
|
|
908
925
|
}
|
|
909
926
|
hide() {
|
|
927
|
+
var _a;
|
|
910
928
|
this.hideOverlay();
|
|
911
929
|
this.removeModules();
|
|
912
930
|
if (this.activeEle && this.options.activeClass)
|
|
913
931
|
this.activeEle.classList.remove(this.options.activeClass);
|
|
914
|
-
this.options.onInactive
|
|
932
|
+
(_a = this.options.onInactive) === null || _a === void 0 ? void 0 : _a.call(this, this.blot, this.activeEle);
|
|
915
933
|
this.activeEle = undefined;
|
|
916
934
|
this.blot = undefined;
|
|
917
935
|
}
|
|
@@ -920,7 +938,7 @@ class QuillResize {
|
|
|
920
938
|
'userSelect',
|
|
921
939
|
'mozUserSelect',
|
|
922
940
|
'webkitUserSelect',
|
|
923
|
-
'msUserSelect'
|
|
941
|
+
'msUserSelect',
|
|
924
942
|
].forEach(prop => {
|
|
925
943
|
// set on contenteditable element and <html>
|
|
926
944
|
this.quill.root.style[prop] = value;
|
|
@@ -929,6 +947,7 @@ class QuillResize {
|
|
|
929
947
|
}
|
|
930
948
|
}
|
|
931
949
|
QuillResize.Modules = { Base: BaseModule, DisplaySize: DisplaySize, Toolbar: modules_Toolbar, Resize: Resize, Keyboard: Keyboard };
|
|
950
|
+
QuillResize.version = "2.1.2";
|
|
932
951
|
/* harmony default export */ const src_QuillResize = (QuillResize);
|
|
933
952
|
if (window.Quill) {
|
|
934
953
|
window.Quill.register('modules/resize', QuillResize);
|
|
@@ -940,5 +959,4 @@ if (window.Quill) {
|
|
|
940
959
|
|
|
941
960
|
/* harmony default export */ const src = (src_QuillResize);
|
|
942
961
|
|
|
943
|
-
|
|
944
|
-
export { __webpack_exports__default as default };
|
|
962
|
+
export { src as default };
|
package/dist/resize.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Quill Resize Module v2.1.
|
|
2
|
+
* Quill Resize Module v2.1.2
|
|
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)}(this,(t=>(()=>{"use strict";var e={912:e=>{e.exports=t}},i={};function s(t){var l=i[t];if(void 0!==l)return l.exports;var o=i[t]={exports:{}};return e[t](o,o.exports,s),o.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var l={};s.r(l),s.d(l,{default:()=>T});const o={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}}}};class a{constructor(t){this.resizer=t,this.quill=t.quill,this.overlay=t.overlay,this.activeEle=t.activeEle,this.blot=t.blot,this.options=t.options,this.requestUpdate=()=>{t.onUpdate(!0)}}onCreate(){}onDestroy(){}onUpdate(){}}var h=s(912),r=s.n(h);const n=window.Quill||r(),d=n.import("parchment"),c={LEFT:"left",RIGHT:"right",CENTER:"center",FULL:"full"},u=d.ClassAttributor?d.ClassAttributor:d.Attributor.Class,p="resize-inline",m=new u(p,"ql-resize-style",{scope:d.Scope.INLINE,whitelist:Object.values(c)}),v="resize-block",g=new u(v,"ql-resize-style",{scope:d.Scope.BLOCK,whitelist:Object.values(c)});n.register(m,!0),n.register(g,!0);class f extends a{onCreate(){this.toolbar=document.createElement("div"),this.toolbar.className="ql-resize-toolbar",this.overlay.appendChild(this.toolbar),this._addToolbarButtons()}_addToolbarButtons(){const t=this.constructor.Icons,e=this.constructor.Tools,i=[];this.options.tools.forEach((s=>{const l="string"==typeof s?e[s]:s;if(l.verify&&!1===l.verify.call(this,this.activeEle,this.blot))return;const o=document.createElement("button");o.type="button",i.push(o),o.innerHTML=(l.icon||"")+(l.text||"")||("string"==typeof s?t[s]:""),"string"==typeof s&&(o.className=`ql-resize-toolbar-${s}`),l.attrs&&Object.keys(l.attrs).forEach((t=>{o.setAttribute(t,l.attrs[t])})),o.addEventListener("click",(t=>{l.handler&&!0!==l.handler.call(this,t,o,this.activeEle,this.blot)||(i.forEach((t=>t.classList.remove("active"))),l.isApplied&&l.isApplied.call(this,this.activeEle,this.blot)?this._applyToolFormatting(""):(o.classList.add("active"),l.toolClass&&this._applyToolFormatting(l.toolClass)),this.requestUpdate())})),l.isApplied&&l.isApplied.call(this,this.activeEle,this.blot)&&o.classList.add("active"),this.toolbar.appendChild(o)}))}_getFormatValue(t,e){if(e.statics.scope===d.Scope.INLINE_BLOT){const t=this.quill.getIndex(e);return this.quill.getFormat(t,1)[p]||""}return e.statics.scope===d.Scope.BLOCK_BLOT&&g.value(t)||""}_applyToolFormatting(t){const e=this.quill.getIndex(this.blot);this.blot.statics.scope===d.Scope.INLINE_BLOT?this.quill.formatText(e,1,p,t):this.blot.statics.scope===d.Scope.BLOCK_BLOT&&this.quill.formatLine(e,1,v,t)}}f.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'},f.Tools={left:{toolClass:c.LEFT,isApplied(t,e){return this._getFormatValue(t,e)===c.LEFT}},center:{toolClass:c.CENTER,isApplied(t,e){return this._getFormatValue(t,e)===c.CENTER}},right:{toolClass:c.RIGHT,isApplied(t,e){return this._getFormatValue(t,e)===c.RIGHT}},full:{toolClass:c.FULL,isApplied(t,e){return this._getFormatValue(t,e)===c.FULL}},edit:{handler(t,e,i,s){this.quill.emitter.emit("resize-edit",i,s)}}};const y=f;const b=window.Quill||r(),E=b.import("parchment"),x={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};class q extends a{static injectInit(t){const 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))}static makeArrowHandler(t,e){const i=t===q.keys.LEFT?"prefix":"suffix";return{key:t,shiftKey:e,altKey:null,[i]:/^$/,handler:function(e){if(!this.quill.resizer)return!0;let i=e.index;const s=t===q.keys.LEFT,l=t===q.keys.RIGHT,[o]=this.quill.getLine(i+(s?-1:0));if(this.quill.resizer.judgeShow(o))return!1;const a=this.quill.getIndex(o);if(l&&a+o.length()-1===i)return!0;l&&(i+=e.length+1);let[h]=this.quill.getLeaf(i);const r=h.offset(h.parent),n=h.constructor.scope===E.Scope.BLOCK_BLOT;return!(!s||!(n&&i===r||0===i||i===a))||(s&&0===r&&(i-=1,h=this.quill.getLeaf(i)[0]),!this.quill.resizer.judgeShow(h))}}}onCreate(){this.options.keyboardSelect&&q.injectInit(this.quill),this.keyboardProxy=t=>this.keyboardHandle(t),document.addEventListener("keydown",this.keyboardProxy,!0)}onDestroy(){document.removeEventListener("keydown",this.keyboardProxy,!0)}keyboardHandle(t){if(t.defaultPrevented)return;if(t.shiftKey||t.ctrlKey||t.altKey)return;if(!this.activeEle||t.fromResize||t.ctrlKey)return;const e=t.keyCode;let i,s=this.blot.offset(this.quill.scroll),l=!1;e===x.BACKSPACE||e===x.DELETE?(this.blot.deleteAt(0),this.blot.parent.optimize(),l=!0):e>=x.LEFT&&e<=x.DOWN&&(e===x.RIGHT?s+=this.blot.length()||1:e===x.UP?(s=this.getOtherLineIndex(-1),i=this.quill.getLeaf(s)[0]):e===x.DOWN&&(s=this.getOtherLineIndex(1),i=this.quill.getLeaf(s)[0]),l=!0),l&&(t.stopPropagation(),t.preventDefault()),i&&this.resizer.judgeShow(i,i.domNode)||(this.quill.setSelection(s),this.resizer.hide())}getOtherLineIndex(t){let e=this.blot.offset(this.quill.scroll);const[i]=this.quill.getLine(e),s=this.blot.offset(i)+1,l=t>0?i.next:i.prev;if(l){let t=l.length();"block"===l.statics.blotName&&t--,e=l.offset(this.quill.scroll)+Math.min(t,s)}return e}dispatchEvent(t){const e=new t.constructor(t);e.fromResize=!0,this.quill.root.dispatchEvent(e)}}/^2\./.test(b.version)?q.keys={BACKSPACE:"Backspace",TAB:"Tab",ENTER:"Enter",ESCAPE:"Escape",LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown",DELETE:"Delete"}:q.keys=x;const L=window.Quill||r(),C=L.import("parchment");class w{constructor(t,e={}){this.modules=[],this.selectedBlots=[],t.resizer=this,this.quill=t;let i=!1;e.modules&&(i=e.modules.slice()),this.options=Object.assign({},o,e),!1!==i&&(this.options.modules=i),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()}initializeModules(){this.removeModules(),this.modules=this.moduleClasses.map((t=>new(w.Modules[t]||t)(this))),this.modules.forEach((t=>{t.onCreate(this)})),this.onUpdate()}initializeEmbed(){if(!this.options.embedTags.length)return;this.embedClassName=`ql-${function(t=8){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";return Array.from({length:t},(()=>e[Math.floor(62*Math.random())])).join("")}()}`;let t=[""].concat(this.options.embedTags).join(`, .${this.embedClassName} `).slice(2);t+="{pointer-events: none;}";const e=document.createElement("style");e.textContent=t,this.quill.container.appendChild(e),this.quill.root.classList.add(this.embedClassName)}onUpdate(t){this.updateFromModule=t,this.repositionElements(),this.modules.forEach((t=>{t.onUpdate()}))}removeModules(){this.modules.forEach((t=>{t.onDestroy()})),this.modules=[]}handleEdit(){if(!this.blot)return;const t=this.blot.offset(this.quill.scroll);this.hide(),this.quill.focus(),this.quill.setSelection(t,1)}handleClick(t){var e;let i,s=!1,l=t.target;const o=null===(e=this.options.embedTags)||void 0===e?void 0:e.join();if(o){const e=this.quill.root;(l===e||l.querySelectorAll(o).length)&&(e.classList.remove(this.embedClassName),l=document.elementFromPoint(t.clientX,t.clientY),e.classList.add(this.embedClassName))}l&&l.tagName&&(i=L.find(l),i&&(s=this.judgeShow(i,l))),s?t.preventDefault():this.activeEle&&this.hide()}judgeShow(t,e){let i=!1;if(!t)return i;!e&&t.domNode&&(e=t.domNode);const s=this.options.parchment[t.statics.blotName];if(!s)return i;if(this.activeEle===e)return!0;const l=s.limit||{};return(!l.minWidth||l.minWidth&&e.offsetWidth>=l.minWidth)&&(i=!0,this.activeEle&&this.hide(),this.activeEle=e,this.blot=t,this.show(e)),i}handleChange(t,e,i){this.updateFromModule?this.updateFromModule=!1:"user"===i&&this.overlay&&this.activeEle&&this.onUpdate()}show(t){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)}showOverlay(){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=t=>{this.activeEle&&this.hide()},this.quill.root.addEventListener("input",this.hideProxy,!0),this.updateOverlayPositionProxy=this.updateOverlayPosition.bind(this),this.quill.root.addEventListener("scroll",this.updateOverlayPositionProxy),this.repositionElements()}hideOverlay(){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(""))}repositionElements(){if(!this.overlay||!this.activeEle)return;const t=this.quill.container,e=this.activeEle.getBoundingClientRect(),i=t.getBoundingClientRect();Object.assign(this.overlay.style,{left:`${e.left-i.left-1+t.scrollLeft}px`,top:`${e.top-i.top+this.quill.root.scrollTop}px`,width:`${e.width}px`,height:`${e.height}px`,marginTop:-1*this.quill.root.scrollTop+"px"})}updateOverlayPosition(){this.overlay.style.marginTop=-1*this.quill.root.scrollTop+"px"}addBlotsSelectedClass(t,e){if(!t)return this.removeBlotsSelectedClass(),void(this.selectedBlots=[]);const i=C.Leaf||C.LeafBlot,s=this.quill.scroll.descendants(i,t.index,t.length).filter((t=>{const e=!!this.options.parchment[t.statics.blotName];return e&&t.domNode.classList.add(this.options.selectedClass),e}));this.removeBlotsSelectedClass(s),this.selectedBlots=s}removeBlotsSelectedClass(t=[]){Array.isArray(t)||(t=[t]),this.selectedBlots.forEach((e=>{-1===t.indexOf(e)&&e.domNode.classList.remove(this.options.selectedClass)}))}hide(){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}setUserSelect(t){["userSelect","mozUserSelect","webkitUserSelect","msUserSelect"].forEach((e=>{this.quill.root.style[e]=t,document.documentElement.style[e]=t}))}}w.Modules={Base:a,DisplaySize:class extends a{constructor(){super(...arguments),this.display=null}onCreate(){this.display=document.createElement("div"),this.display.className="ql-resize-display",this.overlay.appendChild(this.display)}onUpdate(){if(!this.display||!this.activeEle)return;const 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){const t=this.display.getBoundingClientRect();Object.assign(this.display.style,{right:"auto",bottom:`-${t.height+4}px`,left:`-${t.width+4}px`})}else{const t=this.display.getBoundingClientRect();Object.assign(this.display.style,{right:`-${t.width+4}px`,bottom:`-${t.height+4}px`,left:"auto"})}}getCurrentSize(){return[this.activeEle.offsetWidth,this.activeEle.offsetHeight]}},Toolbar:y,Resize:class extends a{constructor(){super(...arguments),this.boxes=[]}onCreate(){this.blotOptions=this.options.parchment[this.blot.statics.blotName],this.boxes=[],this.addBox("tl"),this.addBox("tr"),this.addBox("br"),this.addBox("bl")}onDestroy(){this.setCursor("")}addBox(t){const e=document.createElement("div");e.className=`ql-resize-handle ${t}`,e.addEventListener("mousedown",this.handleMousedown.bind(this),!1),this.overlay.appendChild(e),this.boxes.push(e)}handleMousedown(t){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();const e=window.getComputedStyle(this.dragBox).cursor;this.setCursor(e),this.handleDragProxy=t=>this.handleDrag(t),this.handleMouseupProxy=t=>this.handleMouseup(t),document.addEventListener("mousemove",this.handleDragProxy,!1),document.addEventListener("mouseup",this.handleMouseupProxy,!1)}handleMouseup(t){const 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)}handleDrag(t){if(!this.activeEle||!this.blot)return;const e=Object.assign(Object.assign({},this.blotOptions.limit),{unit:!0});Object.assign(this.activeEle.style,this.calcSize(t,e)),this.requestUpdate()}calcSize(t,e={}){const i=t.clientX-this.dragStartX,s=t.clientY-this.dragStartY,l={};let o=1;(this.blotOptions.attribute||["width"]).forEach((t=>{l[t]=this.preDragSize[t]})),this.dragBox!==this.boxes[0]&&this.dragBox!==this.boxes[3]||(o=-1),void 0!==l.width&&(l.width=Math.round(this.preDragSize.width+i*o)),void 0!==l.height&&(l.height=Math.round(this.preDragSize.height+s*o));let{width:a,height:h}=l;if(e.ratio){let t;e.minWidth&&(a=Math.max(e.minWidth,a)),e.maxWidth&&(a=Math.min(e.maxWidth,a)),h=a*e.ratio,e.minHeight&&h<e.minHeight&&(t=!0,h=e.minHeight),e.maxHeight&&h>e.maxHeight&&(t=!0,h=e.maxHeight),t&&(a=h/e.ratio)}else void 0!==l.width&&(e.minWidth&&(a=Math.max(e.minWidth,a)),e.maxWidth&&(a=Math.min(e.maxWidth,a))),void 0!==l.height&&(e.minHeight&&(h=Math.max(e.minHeight,h)),e.maxHeight&&(h=Math.min(e.maxHeight,h)));e.unit&&(a&&(a+="px"),h&&(h+="px"));const r={};return a&&(r.width=a),h&&(r.height=h),r}getNaturalSize(){const t=this.activeEle;let e=[0,0];if(t.getAttribute("data-size")){const i=t.getAttribute("data-size").split(",");e=[parseInt(i[0]),parseInt(i[1])]}else e=[t.naturalWidth||t.offsetWidth,t.naturalHeight||t.offsetHeight],t.setAttribute("data-size",e[0]+","+e[1]);return{width:e[0],height:e[1]}}setCursor(t){[document.body,this.activeEle].forEach((e=>{e.style.cursor=`${t} !important`}))}},Keyboard:q};const S=w;window.Quill&&window.Quill.register("modules/resize",w);const T=S;return l})()));
|
|
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)}(this,(t=>(()=>{"use strict";var e={912(e){e.exports=t}},i={};function s(t){var l=i[t];if(void 0!==l)return l.exports;var o=i[t]={exports:{}};return e[t](o,o.exports,s),o.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var l={};s.r(l),s.d(l,{default:()=>S});const o={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}}}};class a{constructor(t){this.resizer=t,this.quill=t.quill,this.overlay=t.overlay,this.activeEle=t.activeEle,this.blot=t.blot,this.options=t.options,this.requestUpdate=()=>{t.onUpdate(!0)}}onCreate(){}onDestroy(){}onUpdate(){}}var h=s(912),n=s.n(h);const r=window.Quill||n(),d=r.import("parchment"),c={LEFT:"left",RIGHT:"right",CENTER:"center",FULL:"full"},u=d.ClassAttributor?d.ClassAttributor:d.Attributor.Class,p="resize-inline",m=new u(p,"ql-resize-style",{scope:d.Scope.INLINE,whitelist:Object.values(c)}),v="resize-block",g=new u(v,"ql-resize-style",{scope:d.Scope.BLOCK,whitelist:Object.values(c)});r.register(m,!0),r.register(g,!0);class f extends a{onCreate(){this.toolbar=document.createElement("div"),this.toolbar.className="ql-resize-toolbar",this.overlay.appendChild(this.toolbar),this._addToolbarButtons()}_addToolbarButtons(){const t=this.constructor.Icons,e=this.constructor.Tools,i=[];this.options.tools.forEach((s=>{const l="string"==typeof s?e[s]:s;if(l.verify&&!1===l.verify.call(this,this.activeEle,this.blot))return;const o=document.createElement("button");o.type="button",i.push(o),o.innerHTML=(l.icon||"")+(l.text||"")||("string"==typeof s?t[s]:""),"string"==typeof s&&(o.className=`ql-resize-toolbar-${s}`),l.attrs&&Object.keys(l.attrs).forEach((t=>{o.setAttribute(t,l.attrs[t])})),o.addEventListener("click",(t=>{l.handler&&!0!==l.handler.call(this,t,o,this.activeEle,this.blot)||(i.forEach((t=>t.classList.remove("active"))),l.isApplied&&l.isApplied.call(this,this.activeEle,this.blot)?this._applyToolFormatting(""):(o.classList.add("active"),l.toolClass&&this._applyToolFormatting(l.toolClass)),this.requestUpdate())})),l.isApplied&&l.isApplied.call(this,this.activeEle,this.blot)&&o.classList.add("active"),this.toolbar.appendChild(o)}))}_getFormatValue(t,e){if(e.statics.scope===d.Scope.INLINE_BLOT){const t=this.quill.getIndex(e);return this.quill.getFormat(t,1)[p]||""}return e.statics.scope===d.Scope.BLOCK_BLOT&&g.value(t)||""}_applyToolFormatting(t){const e=this.quill.getIndex(this.blot);this.blot.statics.scope===d.Scope.INLINE_BLOT?this.quill.formatText(e,1,p,t):this.blot.statics.scope===d.Scope.BLOCK_BLOT&&this.quill.formatLine(e,1,v,t)}}f.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'},f.Tools={left:{toolClass:c.LEFT,isApplied(t,e){return this._getFormatValue(t,e)===c.LEFT}},center:{toolClass:c.CENTER,isApplied(t,e){return this._getFormatValue(t,e)===c.CENTER}},right:{toolClass:c.RIGHT,isApplied(t,e){return this._getFormatValue(t,e)===c.RIGHT}},full:{toolClass:c.FULL,isApplied(t,e){return this._getFormatValue(t,e)===c.FULL}},edit:{handler(t,e,i,s){this.quill.emitter.emit("resize-edit",i,s)}}};const y=f;const b=window.Quill||n(),E=b.import("parchment"),x={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};class L extends a{static injectInit(t){const 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))}static makeArrowHandler(t,e){const i=t===L.keys.LEFT?"prefix":"suffix";return{key:t,shiftKey:e,altKey:null,[i]:/^$/,handler:function(e){if(!this.quill.resizer)return!0;let i=e.index;const s=t===L.keys.LEFT,l=t===L.keys.RIGHT,[o]=this.quill.getLine(i+(s?-1:0));if(this.quill.resizer.judgeShow(o))return!1;const a=this.quill.getIndex(o);if(l&&a+o.length()-1===i)return!0;l&&(i+=e.length+1);let[h]=this.quill.getLeaf(i);const n=h.offset(h.parent),r=h.constructor.scope===E.Scope.BLOCK_BLOT;return!(!s||!(r&&i===n||0===i||i===a))||(s&&0===n&&(i-=1,h=this.quill.getLeaf(i)[0]),!this.quill.resizer.judgeShow(h))}}}onCreate(){this.options.keyboardSelect&&L.injectInit(this.quill),this.keyboardProxy=t=>this.keyboardHandle(t),document.addEventListener("keydown",this.keyboardProxy,!0)}onDestroy(){document.removeEventListener("keydown",this.keyboardProxy,!0)}keyboardHandle(t){if(t.defaultPrevented)return;if(t.shiftKey||t.ctrlKey||t.altKey)return;if(!this.activeEle||t.fromResize||t.ctrlKey)return;const e=t.keyCode;let i,s=this.blot.offset(this.quill.scroll),l=!1;e===x.BACKSPACE||e===x.DELETE?(this.blot.deleteAt(0),this.blot.parent.optimize(),l=!0):e>=x.LEFT&&e<=x.DOWN&&(e===x.RIGHT?s+=this.blot.length()||1:e===x.UP?(s=this.getOtherLineIndex(-1),i=this.quill.getLeaf(s)[0]):e===x.DOWN&&(s=this.getOtherLineIndex(1),i=this.quill.getLeaf(s)[0]),l=!0),l&&(t.stopPropagation(),t.preventDefault()),i&&this.resizer.judgeShow(i,i.domNode)||(this.quill.setSelection(s),this.resizer.hide())}getOtherLineIndex(t){let e=this.blot.offset(this.quill.scroll);const[i]=this.quill.getLine(e),s=this.blot.offset(i)+1,l=t>0?i.next:i.prev;if(l){let t=l.length();"block"===l.statics.blotName&&t--,e=l.offset(this.quill.scroll)+Math.min(t,s)}return e}dispatchEvent(t){const e=new t.constructor(t);e.fromResize=!0,this.quill.root.dispatchEvent(e)}}/^2\./.test(b.version)?L.keys={BACKSPACE:"Backspace",TAB:"Tab",ENTER:"Enter",ESCAPE:"Escape",LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown",DELETE:"Delete"}:L.keys=x;const q=window.Quill||n(),C=q.import("parchment");class w{constructor(t,e={}){this.modules=[],this.selectedBlots=[],t.resizer=this,this.quill=t;let i=!1;e.modules&&(i=e.modules.slice()),this.options=Object.assign({},o,e),!1!==i&&(this.options.modules=i),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()}initializeModules(){this.removeModules(),this.modules=this.moduleClasses.map((t=>new(w.Modules[t]||t)(this))),this.modules.forEach((t=>{t.onCreate(this)})),this.onUpdate()}initializeEmbed(){if(!this.options.embedTags.length)return;this.embedClassName=`ql-${function(t=8){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";return Array.from({length:t},(()=>e[Math.floor(62*Math.random())])).join("")}()}`;let t=[""].concat(this.options.embedTags).join(`, .${this.embedClassName} `).slice(2);t+="{pointer-events: none;}";const e=document.createElement("style");e.textContent=t,this.quill.container.appendChild(e),this.quill.root.classList.add(this.embedClassName)}onUpdate(t){this.updateFromModule=t,this.repositionElements(),this.modules.forEach((t=>{t.onUpdate()}))}removeModules(){this.modules.forEach((t=>{t.onDestroy()})),this.modules=[]}handleEdit(){if(!this.blot)return;const t=this.blot.offset(this.quill.scroll);this.hide(),this.quill.focus(),this.quill.setSelection(t,1)}handleClick(t){var e;let i,s=!1,l=t.target;const o=null===(e=this.options.embedTags)||void 0===e?void 0:e.join();if(o){const e=this.quill.root;(l===e||l.querySelectorAll(o).length)&&(e.classList.remove(this.embedClassName),l=document.elementFromPoint(t.clientX,t.clientY),e.classList.add(this.embedClassName))}l&&l.tagName&&(i=q.find(l),i&&(s=this.judgeShow(i,l))),s?t.preventDefault():this.activeEle&&this.hide()}judgeShow(t,e){let i=!1;if(!t)return i;!e&&t.domNode&&(e=t.domNode);const s=this.options.parchment[t.statics.blotName];if(!s)return i;if(this.activeEle===e)return!0;const l=s.limit||{};return(!l.minWidth||l.minWidth&&e.offsetWidth>=l.minWidth)&&(i=!0,this.activeEle&&this.hide(),this.activeEle=e,this.blot=t,this.show()),i}handleChange(t,e,i){this.updateFromModule?this.updateFromModule=!1:"user"===i&&this.overlay&&this.activeEle&&this.onUpdate()}show(){var t;this.showOverlay(),this.initializeModules(),this.options.activeClass&&this.activeEle.classList.add(this.options.activeClass),null===(t=this.options.onActive)||void 0===t||t.call(this,this.blot,this.activeEle)}showOverlay(){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=()=>{this.activeEle&&this.hide()},this.quill.root.addEventListener("input",this.hideProxy,!0),this.updateOverlayPositionProxy=this.updateOverlayPosition.bind(this),this.quill.root.addEventListener("scroll",this.updateOverlayPositionProxy),this.repositionElements()}hideOverlay(){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(""))}repositionElements(){if(!this.overlay||!this.activeEle)return;const t=this.quill.container,e=this.activeEle.getBoundingClientRect(),i=t.getBoundingClientRect();Object.assign(this.overlay.style,{left:`${e.left-i.left-1+t.scrollLeft}px`,top:`${e.top-i.top+this.quill.root.scrollTop}px`,width:`${e.width}px`,height:`${e.height}px`,marginTop:-1*this.quill.root.scrollTop+"px"})}updateOverlayPosition(){this.overlay.style.marginTop=-1*this.quill.root.scrollTop+"px"}addBlotsSelectedClass(t){if(!t)return this.removeBlotsSelectedClass(),void(this.selectedBlots=[]);const e=C.Leaf||C.LeafBlot,i=this.quill.scroll.descendants(e,t.index,t.length).filter((t=>{const e=!!this.options.parchment[t.statics.blotName];return e&&t.domNode.classList.add(this.options.selectedClass),e}));this.removeBlotsSelectedClass(i),this.selectedBlots=i}removeBlotsSelectedClass(t=[]){Array.isArray(t)||(t=[t]),this.selectedBlots.forEach((e=>{-1===t.indexOf(e)&&e.domNode.classList.remove(this.options.selectedClass)}))}hide(){var t;this.hideOverlay(),this.removeModules(),this.activeEle&&this.options.activeClass&&this.activeEle.classList.remove(this.options.activeClass),null===(t=this.options.onInactive)||void 0===t||t.call(this,this.blot,this.activeEle),this.activeEle=void 0,this.blot=void 0}setUserSelect(t){["userSelect","mozUserSelect","webkitUserSelect","msUserSelect"].forEach((e=>{this.quill.root.style[e]=t,document.documentElement.style[e]=t}))}}w.Modules={Base:a,DisplaySize:class extends a{constructor(){super(...arguments),this.display=null}onCreate(){this.display=document.createElement("div"),this.display.className="ql-resize-display",this.overlay.appendChild(this.display)}onUpdate(){if(!this.display||!this.activeEle)return;const 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){const t=this.display.getBoundingClientRect();Object.assign(this.display.style,{right:"auto",bottom:`-${t.height+4}px`,left:`-${t.width+4}px`})}else{const t=this.display.getBoundingClientRect();Object.assign(this.display.style,{right:`-${t.width+4}px`,bottom:`-${t.height+4}px`,left:"auto"})}}getCurrentSize(){return[this.activeEle.offsetWidth,this.activeEle.offsetHeight]}},Toolbar:y,Resize:class extends a{constructor(){super(...arguments),this.boxes=[]}onCreate(){this.blotOptions=this.options.parchment[this.blot.statics.blotName],this.boxes=[],this.addBox("tl"),this.addBox("tr"),this.addBox("br"),this.addBox("bl")}onDestroy(){this.setCursor("")}addBox(t){const e=document.createElement("div");e.className=`ql-resize-handle ${t}`,e.addEventListener("mousedown",this.handleMousedown.bind(this),!1),e.addEventListener("touchstart",this.handleMousedown.bind(this),{passive:!1}),this.overlay.appendChild(e),this.boxes.push(e)}handleMousedown(t){this.dragBox=t.target,t instanceof TouchEvent?(this.dragStartX=t.changedTouches[0].clientX,this.dragStartY=t.changedTouches[0].clientY):(this.dragStartX=t.clientX,this.dragStartY=t.clientY),this.preDragSize={width:this.activeEle.offsetWidth,height:this.activeEle.offsetHeight},this.naturalSize=this.getNaturalSize();const e=window.getComputedStyle(this.dragBox).cursor;this.setCursor(e),this.handleDragProxy=t=>this.handleDrag(t),this.handleMouseupProxy=t=>this.handleMouseup(t),document.addEventListener("mousemove",this.handleDragProxy),document.addEventListener("touchmove",this.handleDragProxy,{passive:!1}),document.addEventListener("mouseup",this.handleMouseupProxy,!0),document.addEventListener("touchend",this.handleMouseupProxy,!0),document.addEventListener("touchcancel",this.handleMouseupProxy,!0)}handleMouseup(t){var e;t.stopPropagation();const i=this.calcSize(t,this.blotOptions.limit);Object.assign(this.activeEle,i),Object.assign(this.activeEle.style,{width:null,height:null}),null===(e=this.options.onChangeSize)||void 0===e||e.call(this,this.blot,this.activeEle,i),this.setCursor(""),document.removeEventListener("mousemove",this.handleDragProxy),document.removeEventListener("touchmove",this.handleDragProxy),document.removeEventListener("mouseup",this.handleMouseupProxy,!0),document.removeEventListener("touchend",this.handleMouseupProxy,!0),document.removeEventListener("touchcancel",this.handleMouseupProxy,!0)}handleDrag(t){if(!this.activeEle||!this.blot)return;t instanceof TouchEvent&&t.cancelable&&t.preventDefault();const e=Object.assign(Object.assign({},this.blotOptions.limit),{unit:!0});Object.assign(this.activeEle.style,this.calcSize(t,e)),this.requestUpdate()}calcSize(t,e={}){let i,s;t instanceof TouchEvent?(i=t.changedTouches[0].clientX,s=t.changedTouches[0].clientY):(i=t.clientX,s=t.clientY);const l=i-this.dragStartX,o=s-this.dragStartY,a={};let h=1;(this.blotOptions.attribute||["width"]).forEach((t=>{a[t]=this.preDragSize[t]})),this.dragBox!==this.boxes[0]&&this.dragBox!==this.boxes[3]||(h=-1),void 0!==a.width&&(a.width=Math.round(this.preDragSize.width+l*h)),void 0!==a.height&&(a.height=Math.round(this.preDragSize.height+o*h));let{width:n,height:r}=a;if(e.ratio){let t;e.minWidth&&(n=Math.max(e.minWidth,n)),e.maxWidth&&(n=Math.min(e.maxWidth,n)),r=n*e.ratio,e.minHeight&&r<e.minHeight&&(t=!0,r=e.minHeight),e.maxHeight&&r>e.maxHeight&&(t=!0,r=e.maxHeight),t&&(n=r/e.ratio)}else void 0!==a.width&&(e.minWidth&&(n=Math.max(e.minWidth,n)),e.maxWidth&&(n=Math.min(e.maxWidth,n))),void 0!==a.height&&(e.minHeight&&(r=Math.max(e.minHeight,r)),e.maxHeight&&(r=Math.min(e.maxHeight,r)));e.unit&&(n&&(n+="px"),r&&(r+="px"));const d={};return n&&(d.width=n),r&&(d.height=r),d}getNaturalSize(){const t=this.activeEle;let e=[0,0];if(t.getAttribute("data-size")){const i=t.getAttribute("data-size").split(",");e=[parseInt(i[0]),parseInt(i[1])]}else e=[t.naturalWidth||t.offsetWidth,t.naturalHeight||t.offsetHeight],t.setAttribute("data-size",e[0]+","+e[1]);return{width:e[0],height:e[1]}}setCursor(t){[document.body,this.activeEle].forEach((e=>{e.style.cursor=`${t} !important`}))}},Keyboard:L},w.version="2.1.2";const T=w;window.Quill&&window.Quill.register("modules/resize",w);const S=T;return l})()));
|
package/package.json
CHANGED
package/src/QuillResize.ts
CHANGED
package/src/assets/resize.scss
CHANGED
package/src/modules/Resize.ts
CHANGED
|
@@ -46,18 +46,24 @@ export default class Resize extends BaseModule {
|
|
|
46
46
|
|
|
47
47
|
// listen for mousedown on each box
|
|
48
48
|
box.addEventListener('mousedown', this.handleMousedown.bind(this), false)
|
|
49
|
+
box.addEventListener('touchstart', this.handleMousedown.bind(this), { passive: false })
|
|
49
50
|
// add drag handle to document
|
|
50
51
|
this.overlay.appendChild(box)
|
|
51
52
|
// keep track of drag handle
|
|
52
53
|
this.boxes.push(box)
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
handleMousedown (evt: MouseEvent): void {
|
|
56
|
+
handleMousedown (evt: MouseEvent | TouchEvent): void {
|
|
56
57
|
// note which box
|
|
57
58
|
this.dragBox = evt.target as HTMLElement
|
|
58
59
|
// note starting mousedown position
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
if (evt instanceof TouchEvent) {
|
|
61
|
+
this.dragStartX = evt.changedTouches[0].clientX
|
|
62
|
+
this.dragStartY = evt.changedTouches[0].clientY
|
|
63
|
+
} else {
|
|
64
|
+
this.dragStartX = evt.clientX
|
|
65
|
+
this.dragStartY = evt.clientY
|
|
66
|
+
}
|
|
61
67
|
// store the width before the drag
|
|
62
68
|
this.preDragSize = {
|
|
63
69
|
width: this.activeEle.offsetWidth,
|
|
@@ -69,14 +75,19 @@ export default class Resize extends BaseModule {
|
|
|
69
75
|
const cursor = window.getComputedStyle(this.dragBox).cursor
|
|
70
76
|
this.setCursor(cursor)
|
|
71
77
|
|
|
72
|
-
this.handleDragProxy = (evt: MouseEvent) => this.handleDrag(evt)
|
|
73
|
-
this.handleMouseupProxy = (evt: MouseEvent) => this.handleMouseup(evt)
|
|
78
|
+
this.handleDragProxy = (evt: MouseEvent | TouchEvent) => this.handleDrag(evt)
|
|
79
|
+
this.handleMouseupProxy = (evt: MouseEvent | TouchEvent) => this.handleMouseup(evt)
|
|
74
80
|
// listen for movement and mouseup
|
|
75
|
-
document.addEventListener('mousemove', this.handleDragProxy
|
|
76
|
-
document.addEventListener('
|
|
81
|
+
document.addEventListener('mousemove', this.handleDragProxy)
|
|
82
|
+
document.addEventListener('touchmove', this.handleDragProxy, { passive: false })
|
|
83
|
+
document.addEventListener('mouseup', this.handleMouseupProxy, true)
|
|
84
|
+
document.addEventListener('touchend', this.handleMouseupProxy, true)
|
|
85
|
+
document.addEventListener('touchcancel', this.handleMouseupProxy, true)
|
|
77
86
|
}
|
|
78
87
|
|
|
79
|
-
handleMouseup (evt: MouseEvent): void {
|
|
88
|
+
handleMouseup (evt: MouseEvent | TouchEvent): void {
|
|
89
|
+
evt.stopPropagation()
|
|
90
|
+
|
|
80
91
|
// save size, clear style
|
|
81
92
|
const calcSize = this.calcSize(evt, this.blotOptions.limit)
|
|
82
93
|
Object.assign(this.activeEle, calcSize)
|
|
@@ -87,15 +98,22 @@ export default class Resize extends BaseModule {
|
|
|
87
98
|
this.setCursor('')
|
|
88
99
|
// stop listening for movement and mouseup
|
|
89
100
|
document.removeEventListener('mousemove', this.handleDragProxy)
|
|
90
|
-
document.removeEventListener('
|
|
101
|
+
document.removeEventListener('touchmove', this.handleDragProxy)
|
|
102
|
+
document.removeEventListener('mouseup', this.handleMouseupProxy, true)
|
|
103
|
+
document.removeEventListener('touchend', this.handleMouseupProxy, true)
|
|
104
|
+
document.removeEventListener('touchcancel', this.handleMouseupProxy, true)
|
|
91
105
|
}
|
|
92
106
|
|
|
93
|
-
handleDrag (evt: MouseEvent): void {
|
|
107
|
+
handleDrag (evt: MouseEvent | TouchEvent): void {
|
|
94
108
|
if (!this.activeEle || !this.blot) {
|
|
95
109
|
// activeEle not set yet
|
|
96
110
|
return
|
|
97
111
|
}
|
|
98
112
|
|
|
113
|
+
if (evt instanceof TouchEvent && evt.cancelable) {
|
|
114
|
+
evt.preventDefault()
|
|
115
|
+
}
|
|
116
|
+
|
|
99
117
|
const limit: SizeLimit & { unit?: boolean } = {
|
|
100
118
|
...this.blotOptions.limit,
|
|
101
119
|
unit: true,
|
|
@@ -105,10 +123,19 @@ export default class Resize extends BaseModule {
|
|
|
105
123
|
this.requestUpdate()
|
|
106
124
|
}
|
|
107
125
|
|
|
108
|
-
calcSize (evt: MouseEvent, limit: SizeLimit & { unit?: boolean } = {}): SizeResult {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
126
|
+
calcSize (evt: MouseEvent | TouchEvent, limit: SizeLimit & { unit?: boolean } = {}): SizeResult {
|
|
127
|
+
let clientX: number, clientY: number
|
|
128
|
+
|
|
129
|
+
if (evt instanceof TouchEvent) {
|
|
130
|
+
clientX = evt.changedTouches[0].clientX
|
|
131
|
+
clientY = evt.changedTouches[0].clientY
|
|
132
|
+
} else {
|
|
133
|
+
clientX = evt.clientX
|
|
134
|
+
clientY = evt.clientY
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const deltaX = clientX - this.dragStartX
|
|
138
|
+
const deltaY = clientY - this.dragStartY
|
|
112
139
|
|
|
113
140
|
const size: any = {}
|
|
114
141
|
let direction = 1
|