quill-resizable-table 1.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abhijeet Satpute
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,229 @@
1
+ # quill-resizable-table
2
+
3
+ A [Quill.js](https://quilljs.com/) plugin for drag-resizable tables -- resize columns, rows, and the entire table. Add or remove rows and columns with a right-click context menu or floating edge buttons.
4
+
5
+ **[📺 Live Demo](https://abhijeetsatpute.github.io/quill-resizable-table/)**
6
+
7
+ <p align="center">
8
+ <img src="" alt="quill-resizable-table demo" width="700" />
9
+ <br />
10
+ <em><!-- Add your demo GIF here --></em>
11
+ </p>
12
+
13
+ ---
14
+
15
+ ## Features
16
+
17
+ - **Drag to resize** columns, rows, or the entire table
18
+ - **Right-click context menu** to insert/delete rows and columns
19
+ - **Floating buttons** on table edges for quick row/column addition and **table deletion**
20
+ - **Delete table** via context menu or floating delete button
21
+ - **Toolbar button** with a table icon to insert new tables
22
+ - Works with **Quill 1.3+** and **Quill 2.x**
23
+ - Zero dependencies (only Quill as a peer dependency)
24
+ - Ships ESM, CJS, and UMD builds
25
+ - TypeScript types included
26
+ - **Comprehensive test coverage** (80%+ test coverage)
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ npm install quill-resizable-table
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ```js
37
+ import Quill from 'quill';
38
+ import { ResizableTable } from 'quill-resizable-table';
39
+ import 'quill-resizable-table/dist/quill-resizable-table.css';
40
+
41
+ Quill.register('modules/resizableTable', ResizableTable);
42
+
43
+ const quill = new Quill('#editor', {
44
+ theme: 'snow',
45
+ modules: {
46
+ toolbar: [['bold', 'italic'], ['table']],
47
+ resizableTable: true,
48
+ },
49
+ });
50
+ ```
51
+
52
+ Tables inside the editor are now resizable by drag, and you get a context menu and edge buttons for free.
53
+
54
+ ## Usage Examples
55
+
56
+ ### Toolbar table button
57
+
58
+ Register the built-in table icon so the toolbar renders a clickable grid button:
59
+
60
+ ```js
61
+ import Quill from 'quill';
62
+ import { ResizableTable } from 'quill-resizable-table';
63
+ import 'quill-resizable-table/dist/quill-resizable-table.css';
64
+
65
+ // Register icon BEFORE creating the editor
66
+ const icons = Quill.import('ui/icons');
67
+ icons['table'] = ResizableTable.TABLE_ICON;
68
+
69
+ Quill.register('modules/resizableTable', ResizableTable);
70
+
71
+ const quill = new Quill('#editor', {
72
+ theme: 'snow',
73
+ modules: {
74
+ toolbar: [
75
+ ['bold', 'italic', 'underline'],
76
+ [{ header: [1, 2, 3, false] }],
77
+ ['table'],
78
+ ['clean'],
79
+ ],
80
+ resizableTable: true,
81
+ },
82
+ });
83
+ ```
84
+
85
+ Clicking the table button inserts a 3x3 table at the cursor position.
86
+
87
+ ### Custom options
88
+
89
+ ```js
90
+ const quill = new Quill('#editor', {
91
+ theme: 'snow',
92
+ modules: {
93
+ resizableTable: {
94
+ handleSize: 8, // grab-zone width in px (default: 5)
95
+ minColumnWidth: 50, // minimum column width in px (default: 30)
96
+ minRowHeight: 30, // minimum row height in px (default: 20)
97
+ },
98
+ },
99
+ });
100
+ ```
101
+
102
+ ### UMD / CDN (no bundler)
103
+
104
+ ```html
105
+ <link href="https://cdn.jsdelivr.net/npm/quill@2/dist/quill.snow.css" rel="stylesheet" />
106
+ <link href="https://cdn.jsdelivr.net/npm/quill-resizable-table/dist/quill-resizable-table.css" rel="stylesheet" />
107
+
108
+ <script src="https://cdn.jsdelivr.net/npm/quill@2/dist/quill.js"></script>
109
+ <script src="https://cdn.jsdelivr.net/npm/quill-resizable-table/dist/quill-resizable-table.umd.js"></script>
110
+
111
+ <div id="editor"></div>
112
+
113
+ <script>
114
+ var ResizableTable = QuillResizableTable.ResizableTable;
115
+
116
+ var icons = Quill.import('ui/icons');
117
+ icons['table'] = ResizableTable.TABLE_ICON;
118
+
119
+ Quill.register('modules/resizableTable', ResizableTable);
120
+
121
+ var quill = new Quill('#editor', {
122
+ theme: 'snow',
123
+ modules: {
124
+ toolbar: [['bold', 'italic'], ['table']],
125
+ resizableTable: true,
126
+ },
127
+ });
128
+ </script>
129
+ ```
130
+
131
+ ### Programmatic table insertion
132
+
133
+ ```js
134
+ const resizableTable = quill.getModule('resizableTable');
135
+
136
+ // Insert a 4x5 table at the cursor
137
+ resizableTable.insertNewTable(4, 5);
138
+ ```
139
+
140
+ ### Programmatic row/column/table manipulation
141
+
142
+ ```js
143
+ const resizableTable = quill.getModule('resizableTable');
144
+ const table = document.querySelector('.ql-editor table');
145
+
146
+ resizableTable.insertColumn(table, 1, 'after'); // column right of index 1
147
+ resizableTable.insertColumn(table, 0, 'before'); // column left of index 0
148
+ resizableTable.insertRow(table, 0, 'after'); // row below index 0
149
+ resizableTable.insertRow(table, 2, 'before'); // row above index 2
150
+ resizableTable.deleteColumn(table, 2); // remove column 2
151
+ resizableTable.deleteRow(table, 1); // remove row 1
152
+ resizableTable.deleteTable(table); // remove entire table
153
+ ```
154
+
155
+ ## Options
156
+
157
+ | Option | Type | Default | Description |
158
+ |---|---|---|---|
159
+ | `handleSize` | `number` | `5` | Width (px) of the invisible grab zone on cell borders |
160
+ | `minColumnWidth` | `number` | `30` | Minimum column width in px during resize |
161
+ | `minRowHeight` | `number` | `20` | Minimum row height in px during resize |
162
+
163
+ ## How It Works
164
+
165
+ | Action | How |
166
+ |---|---|
167
+ | Resize a column | Drag the right edge of any cell |
168
+ | Resize a row | Drag the bottom edge of any cell |
169
+ | Resize the table | Drag the bottom-right corner of the table |
170
+ | Insert/delete rows & columns | Right-click any cell for the context menu |
171
+ | Quick-add row or column | Hover the right or bottom edge of a table, click **+** |
172
+ | Delete table | Right-click any cell → **Delete Table** or hover table and click red **✕** button |
173
+ | Insert a new table | Click the table icon in the toolbar |
174
+
175
+ ## API
176
+
177
+ ### `ResizableTable`
178
+
179
+ | Method | Description |
180
+ |---|---|
181
+ | `insertNewTable(rows?, cols?)` | Insert a new table at the cursor (default 3x3) |
182
+ | `insertColumn(table, colIndex, 'before' \| 'after')` | Insert a column |
183
+ | `deleteColumn(table, colIndex)` | Delete a column (min 1 enforced) |
184
+ | `insertRow(table, rowIndex, 'before' \| 'after')` | Insert a row |
185
+ | `deleteRow(table, rowIndex)` | Delete a row (min 1 enforced) |
186
+ | `deleteTable(table)` | Delete the entire table |
187
+ | `destroy()` | Remove all listeners and clean up |
188
+
189
+ ### Static Properties
190
+
191
+ | Property | Description |
192
+ |---|---|
193
+ | `ResizableTable.TABLE_ICON` | SVG string for the Quill toolbar table icon |
194
+
195
+ ## Development
196
+
197
+ ```bash
198
+ git clone https://github.com/abhijeetsatpute/quill-resizable-table.git
199
+ cd quill-resizable-table
200
+ npm install
201
+ npm run dev # start demo at localhost
202
+ npm test # run tests
203
+ npm run build # build dist/
204
+ ```
205
+
206
+ ### Test Coverage
207
+
208
+ The project maintains comprehensive test coverage:
209
+
210
+ - **42 tests** covering all core functionality
211
+ - **80%+ code coverage** (Statements: 80.39%, Branches: 52.79%, Functions: 75%, Lines: 83.46%)
212
+ - Tests for table resizing, row/column operations, table deletion, context menus, and edge button interactions
213
+
214
+ Run tests with coverage:
215
+ ```bash
216
+ npm test -- --coverage
217
+ ```
218
+
219
+ ## Contributing
220
+
221
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
222
+
223
+ ## Code of Conduct
224
+
225
+ This project follows the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
226
+
227
+ ## License
228
+
229
+ [MIT](LICENSE) -- Abhijeet Satpute
@@ -0,0 +1,109 @@
1
+ /**
2
+ * quill-resizable-table
3
+ * Drag-to-resize columns, rows, and entire tables inside a Quill editor.
4
+ * Right-click context menu & floating edge buttons for adding/removing rows & columns.
5
+ */
6
+ export interface ResizableTableOptions {
7
+ /** Pixel width of the invisible grab zone on each border (default 5) */
8
+ handleSize?: number;
9
+ /** Minimum column width in px (default 30) */
10
+ minColumnWidth?: number;
11
+ /** Minimum row height in px (default 20) */
12
+ minRowHeight?: number;
13
+ /** Minimum table width in px (default 50) */
14
+ minTableWidth?: number;
15
+ /** Minimum table height in px (default 30) */
16
+ minTableHeight?: number;
17
+ }
18
+ export declare class ResizableTable {
19
+ private quill;
20
+ private options;
21
+ private drag;
22
+ private overlay;
23
+ private doc;
24
+ private contextMenu;
25
+ private contextCell;
26
+ private addColBtn;
27
+ private addRowBtn;
28
+ private deleteTableBtn;
29
+ private hoveredTable;
30
+ private hideEdgeBtnTimer;
31
+ private onMouseMoveBound;
32
+ private onMouseUpBound;
33
+ private onEditorMouseMoveBound;
34
+ private onEditorMouseDownBound;
35
+ private onContextMenuBound;
36
+ private onDismissMenuBound;
37
+ private onDismissMenuKeyBound;
38
+ private onEditorMouseOverBound;
39
+ private onEditorMouseOutBound;
40
+ private onScrollBound;
41
+ constructor(quill: any, options?: ResizableTableOptions | boolean);
42
+ /** Table icon SVG for the Quill toolbar */
43
+ static TABLE_ICON: string;
44
+ /** Hook into Quill's toolbar to handle the "table" button */
45
+ private registerToolbarHandler;
46
+ /** Wire up listeners on the editor root */
47
+ private attach;
48
+ /** Remove all listeners (call if you ever destroy the module) */
49
+ destroy(): void;
50
+ /**
51
+ * Detect which resize edge (if any) the mouse is near.
52
+ * Returns null when the cursor isn't on a resize boundary.
53
+ */
54
+ private detectEdge;
55
+ /** Update cursor style as the mouse moves over cells */
56
+ private onEditorMouseMove;
57
+ /** Start a drag operation */
58
+ private onEditorMouseDown;
59
+ private onDocumentMouseMove;
60
+ private onDocumentMouseUp;
61
+ private addOverlay;
62
+ private removeOverlay;
63
+ /** Get the visual column index of a cell accounting for previous colSpans */
64
+ private getCellColIndex;
65
+ /** Get the row index of a cell */
66
+ private getCellRowIndex;
67
+ /** Total number of visual columns in the first row */
68
+ private getColumnCount;
69
+ /** Read current column widths from the first row's cells */
70
+ private getColumnWidths;
71
+ /** Read current row heights */
72
+ private getRowHeights;
73
+ /** Apply column widths via a <colgroup> */
74
+ private applyColumnWidths;
75
+ /** Resize a single column independently (only that column changes width) */
76
+ private resizeColumnDirect;
77
+ /** Apply row heights directly on <tr> elements */
78
+ private applyRowHeights;
79
+ private onContextMenu;
80
+ private showContextMenu;
81
+ private dismissContextMenu;
82
+ private onKeyDown;
83
+ private cancelHideEdgeButtons;
84
+ private scheduleHideEdgeButtons;
85
+ private onEditorMouseOver;
86
+ private onEditorMouseOut;
87
+ /** Update button positions on scroll to keep them anchored to the table */
88
+ private onScroll;
89
+ private showEdgeButtons;
90
+ private removeEdgeButtons;
91
+ /** Insert a new 3×3 table at the current cursor position */
92
+ insertNewTable(rows?: number, cols?: number): void;
93
+ /**
94
+ * Consume pending MutationObserver records so Quill's async handler
95
+ * never processes our structural DOM changes (which it would corrupt).
96
+ * Style-only changes (resize) don't need this — only structural ones.
97
+ */
98
+ private syncQuill;
99
+ /** Insert a column before or after colIndex */
100
+ insertColumn(table: HTMLTableElement, colIndex: number, position: 'before' | 'after'): void;
101
+ /** Delete column at colIndex (no-op if only 1 column remains) */
102
+ deleteColumn(table: HTMLTableElement, colIndex: number): void;
103
+ /** Insert a row before or after rowIndex */
104
+ insertRow(table: HTMLTableElement, rowIndex: number, position: 'before' | 'after'): void;
105
+ /** Delete row at rowIndex (no-op if only 1 row remains) */
106
+ deleteRow(table: HTMLTableElement, rowIndex: number): void;
107
+ /** Delete the entire table */
108
+ deleteTable(table: HTMLTableElement): void;
109
+ }
@@ -0,0 +1,2 @@
1
+ export { ResizableTable } from './ResizableTable';
2
+ export type { ResizableTableOptions } from './ResizableTable';