@mgreminger/quill-image-resize-module 1.0.2 → 1.0.4

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.
Files changed (2) hide show
  1. package/README.md +35 -41
  2. package/package.json +3 -1
package/README.md CHANGED
@@ -5,28 +5,36 @@ A module for Quill rich text editor to allow images to be resized.
5
5
  A fork of [kensnyder/quill-image-resize-module](https://github.com/kensnyder/quill-image-resize-module) with the following changes:
6
6
 
7
7
  - Updated to work with Quill 2
8
- - Modernized toolchain using vite and TypeScript
9
- - Toolbar buttons removed since allignment settings were not preserved in the document Delta
10
- - The presence of resize handles no longer impacts underlying selection range so keyboard actions such as copy to clipboard and type to replace still work as expected
8
+ - Toolbar removed since alignment settings were not preserved in the Quill Delta data structure
9
+ - The presence of resize handles no longer impacts the underlying selection range so keyboard actions such as copy to clipboard and type to replace still work as expected
11
10
  - Keyboard shortcuts added to increase image size (+ key) and decrease image size (- key)
12
11
  - Resize handles now appear when image is selected with the keyboard (using shift with the arrow keys)
13
12
  - Works with touch events in addition to mouse events
13
+ - Add `minWidth` and `keyboardSizeDelta` options for min image width and keyboard + and - size increment (both in pixels)
14
+ - Modernized toolchain using vite and TypeScript
15
+ - Add Playwright tests
14
16
 
15
17
  ## Demo
16
18
 
17
19
  [Preview Site](https://mgreminger.github.io/quill-image-resize-module/)
18
20
 
21
+ ## Installation
22
+
23
+ ```console
24
+ npm install --save-dev @mgreminger/quill-image-resize-module
25
+ ```
26
+
19
27
  ## Usage
20
28
 
21
- ### Webpack/ES6
29
+ ### Importing and Registering the Module
22
30
 
23
31
  ```javascript
24
32
  import Quill from "quill";
25
- import { ImageResize } from "quill-image-resize-module";
33
+ import ImageResize from "@mgreminger/quill-image-resize-module";;
26
34
 
27
35
  Quill.register("modules/imageResize", ImageResize);
28
36
 
29
- const quill = new Quill(editor, {
37
+ const quill = new Quill(editorDiv, {
30
38
  // ...
31
39
  modules: {
32
40
  // ...
@@ -37,51 +45,37 @@ const quill = new Quill(editor, {
37
45
  });
38
46
  ```
39
47
 
40
- ### Script Tag
41
-
42
- Copy image-resize.min.js into your web root or include from node_modules
43
-
44
- ```html
45
- <script src="/node_modules/quill-image-resize-module/image-resize.min.js"></script>
46
- ```
47
-
48
- ```javascript
49
- var quill = new Quill(editor, {
50
- // ...
51
- modules: {
52
- // ...
53
- ImageResize: {
54
- // See optional "config" below
55
- },
56
- },
57
- });
58
- ```
59
-
60
48
  ### Config
61
49
 
62
50
  For the default experience, pass an empty object, like so:
63
51
 
64
52
  ```javascript
65
- var quill = new Quill(editor, {
53
+ var quill = new Quill(editorDiv, {
66
54
  // ...
67
55
  modules: {
68
56
  // ...
69
- ImageResize: {},
57
+ imageResize: {},
70
58
  },
71
59
  });
72
60
  ```
73
61
 
74
62
  Functionality is broken down into modules, which can be mixed and matched as you like. For example,
75
- the default is to include all modules:
63
+ this config includes all of the modules (this is the default) and uses the default values for `minWidth` and `keyboardSizeDelta`:
76
64
 
77
65
  ```javascript
78
- const quill = new Quill(editor, {
66
+ import { type ImageResizeOptions } from "@mgreminger/quill-image-resize-module/dist/types";
67
+
68
+ const options: ImageResizeOptions = {
69
+ modules: ["Resize", "DisplaySize"],
70
+ minWidth: 13,
71
+ keyboardSizeDelta: 10
72
+ };
73
+
74
+ const quill = new Quill(editorDiv, {
79
75
  // ...
80
76
  modules: {
81
77
  // ...
82
- ImageResize: {
83
- modules: ["Resize", "DisplaySize"],
84
- },
78
+ imageResize: options,
85
79
  },
86
80
  });
87
81
  ```
@@ -95,11 +89,11 @@ Adds handles to the image's corners which can be dragged with the mouse to resiz
95
89
  The look and feel can be controlled with options:
96
90
 
97
91
  ```javascript
98
- var quill = new Quill(editor, {
92
+ var quill = new Quill(editorDiv, {
99
93
  // ...
100
94
  modules: {
101
95
  // ...
102
- ImageResize: {
96
+ imageResize: {
103
97
  // ...
104
98
  handleStyles: {
105
99
  backgroundColor: "black",
@@ -119,11 +113,11 @@ Shows the size of the image in pixels near the bottom right of the image.
119
113
  The look and feel can be controlled with options:
120
114
 
121
115
  ```javascript
122
- var quill = new Quill(editor, {
116
+ var quill = new Quill(editorDiv, {
123
117
  // ...
124
118
  modules: {
125
119
  // ...
126
- ImageResize: {
120
+ imageResize: {
127
121
  // ...
128
122
  displayStyles: {
129
123
  backgroundColor: "black",
@@ -147,15 +141,15 @@ For example,
147
141
  import { Resize, BaseModule } from "quill-image-resize-module";
148
142
 
149
143
  class MyModule extends BaseModule {
150
- // See src/modules/BaseModule.js for documentation on the various lifecycle callbacks
144
+ // See lib/modules/BaseModule.js for documentation on the various lifecycle callbacks
151
145
  }
152
146
 
153
- var quill = new Quill(editor, {
147
+ var quill = new Quill(editorDiv, {
154
148
  // ...
155
149
  modules: {
156
150
  // ...
157
- ImageResize: {
158
- modules: [MyModule, Resize],
151
+ imageResize: {
152
+ modules: [MyModule, Resize, DisplaySize],
159
153
  // ...
160
154
  },
161
155
  },
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@mgreminger/quill-image-resize-module",
3
3
  "private": false,
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "description": "A module for Quill rich text editor to allow images to be resized.",
6
6
  "type": "module",
7
7
  "main": "dist/index.es.js",
8
+ "types": "dist/ImageResize.d.ts",
9
+ "license": "MIT",
8
10
  "scripts": {
9
11
  "dev": "vite --port 5173",
10
12
  "build": "vite build",