quill-table-up 3.1.2 → 3.2.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.
Files changed (111) hide show
  1. package/README.md +7 -0
  2. package/dist/index.css +1 -1
  3. package/dist/index.d.ts +168 -146
  4. package/dist/index.js +47 -47
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.umd.js +52 -52
  7. package/dist/index.umd.js.map +1 -1
  8. package/package.json +22 -24
  9. package/src/__tests__/e2e/custom-creator.test.ts +44 -44
  10. package/src/__tests__/e2e/editor-page.ts +77 -77
  11. package/src/__tests__/e2e/table-align.test.ts +104 -104
  12. package/src/__tests__/e2e/table-blots.test.ts +169 -169
  13. package/src/__tests__/e2e/table-caption.test.ts +134 -134
  14. package/src/__tests__/e2e/table-clipboard.test.ts +20 -20
  15. package/src/__tests__/e2e/table-hack.test.ts +151 -151
  16. package/src/__tests__/e2e/table-keyboard-handler.test.ts +12 -3
  17. package/src/__tests__/e2e/table-menu.test.ts +172 -172
  18. package/src/__tests__/e2e/table-resize.test.ts +654 -9
  19. package/src/__tests__/e2e/table-scrollbar.test.ts +144 -144
  20. package/src/__tests__/e2e/table-selection.test.ts +563 -563
  21. package/src/__tests__/e2e/types.d.ts +7 -7
  22. package/src/__tests__/e2e/utils.ts +52 -52
  23. package/src/__tests__/unit/table-blots.test.ts +720 -720
  24. package/src/__tests__/unit/table-caption.test.ts +234 -234
  25. package/src/__tests__/unit/table-cell-merge.test.ts +724 -724
  26. package/src/__tests__/unit/table-clipboard.test.ts +2176 -2176
  27. package/src/__tests__/unit/table-hack.test.ts +1014 -1014
  28. package/src/__tests__/unit/table-insert.test.ts +926 -926
  29. package/src/__tests__/unit/table-redo-undo.test.ts +2429 -2429
  30. package/src/__tests__/unit/table-remove.test.ts +343 -343
  31. package/src/__tests__/unit/utils.test-d.ts +49 -49
  32. package/src/__tests__/unit/utils.test.ts +711 -711
  33. package/src/__tests__/unit/utils.ts +307 -307
  34. package/src/__tests__/unit/vitest.d.ts +14 -14
  35. package/src/formats/container-format.ts +107 -107
  36. package/src/formats/overrides/block-embed.ts +72 -72
  37. package/src/formats/overrides/block.ts +95 -95
  38. package/src/formats/overrides/index.ts +3 -3
  39. package/src/formats/overrides/scroll.ts +70 -70
  40. package/src/formats/table-body-format.ts +52 -52
  41. package/src/formats/table-caption-format.ts +116 -116
  42. package/src/formats/table-cell-format.ts +304 -304
  43. package/src/formats/table-cell-inner-format.ts +403 -398
  44. package/src/formats/table-colgroup-format.ts +136 -136
  45. package/src/formats/table-foot-format.ts +7 -7
  46. package/src/formats/table-head-format.ts +7 -7
  47. package/src/formats/table-main-format.ts +1 -1
  48. package/src/formats/table-row-format.ts +218 -210
  49. package/src/formats/utils.ts +6 -6
  50. package/src/index.ts +19 -19
  51. package/src/modules/index.ts +7 -7
  52. package/src/modules/table-align.ts +131 -131
  53. package/src/modules/table-clipboard/table-clipboard.ts +6 -8
  54. package/src/modules/table-dom-selector.ts +33 -33
  55. package/src/modules/table-menu/constants.ts +223 -223
  56. package/src/modules/table-menu/index.ts +4 -4
  57. package/src/modules/table-menu/table-menu-common.ts +330 -329
  58. package/src/modules/table-menu/table-menu-contextmenu.ts +111 -118
  59. package/src/modules/table-menu/table-menu-select.ts +96 -94
  60. package/src/modules/table-resize/index.ts +5 -5
  61. package/src/modules/table-resize/table-resize-box.ts +714 -363
  62. package/src/modules/table-resize/table-resize-common.ts +246 -382
  63. package/src/modules/table-resize/table-resize-drag.ts +241 -0
  64. package/src/modules/table-resize/table-resize-line.ts +244 -182
  65. package/src/modules/table-resize/table-resize-scale.ts +174 -173
  66. package/src/modules/table-resize/utils.ts +84 -3
  67. package/src/modules/table-scrollbar.ts +292 -292
  68. package/src/modules/table-selection.ts +613 -669
  69. package/src/style/button.less +45 -45
  70. package/src/style/color-picker.less +136 -136
  71. package/src/style/dialog.less +53 -53
  72. package/src/style/functions.less +9 -9
  73. package/src/style/index.less +120 -120
  74. package/src/style/input.less +64 -64
  75. package/src/style/select-box.less +52 -52
  76. package/src/style/table-creator.less +56 -56
  77. package/src/style/table-menu.less +125 -125
  78. package/src/style/table-resize-scale.less +31 -31
  79. package/src/style/table-resize.less +249 -202
  80. package/src/style/table-scrollbar.less +49 -49
  81. package/src/style/table-selection.less +23 -23
  82. package/src/style/tooltip.less +19 -19
  83. package/src/style/variables.less +1 -1
  84. package/src/svg/arrow-up-down.svg +11 -11
  85. package/src/svg/convert-cell.svg +7 -7
  86. package/src/table-up.ts +1360 -1360
  87. package/src/types.d.ts +4 -4
  88. package/src/utils/bem.ts +23 -23
  89. package/src/utils/blot-helper.ts +101 -105
  90. package/src/utils/color.ts +109 -109
  91. package/src/utils/components/button.ts +22 -22
  92. package/src/utils/components/color-picker.ts +236 -236
  93. package/src/utils/components/dialog.ts +83 -41
  94. package/src/utils/components/index.ts +6 -6
  95. package/src/utils/components/input.ts +74 -74
  96. package/src/utils/components/table/creator.ts +89 -89
  97. package/src/utils/components/table/index.ts +2 -2
  98. package/src/utils/components/table/select-box.ts +78 -78
  99. package/src/utils/components/tooltip.ts +179 -189
  100. package/src/utils/constants.ts +125 -124
  101. package/src/utils/drag-helper.ts +112 -0
  102. package/src/utils/index.ts +15 -14
  103. package/src/utils/is.ts +9 -9
  104. package/src/utils/position.ts +60 -60
  105. package/src/utils/resize-observer-helper.ts +47 -47
  106. package/src/utils/scroll.ts +145 -47
  107. package/src/utils/style-helper.ts +47 -47
  108. package/src/utils/transformer.ts +10 -10
  109. package/src/utils/transition-event-helper.ts +8 -8
  110. package/src/utils/types.ts +156 -157
  111. package/src/utils/utils.ts +12 -12
@@ -1,724 +1,724 @@
1
- import Quill from 'quill';
2
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
- import { TableCellInnerFormat, TableMainFormat } from '../../formats';
4
- import { TableUp } from '../../table-up';
5
- import { createQuillWithTableModule, createTable, createTableDeltaOps, createTaleColHTML, expectDelta } from './utils';
6
-
7
- const Delta = Quill.import('delta');
8
-
9
- beforeEach(() => {
10
- vi.useFakeTimers();
11
- });
12
- afterEach(() => {
13
- vi.useRealTimers();
14
- });
15
-
16
- describe('merge and split cell', () => {
17
- it('merge cells', async () => {
18
- const quill = createQuillWithTableModule(`<p><br></p>`);
19
- const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
20
- tableModule.insertTable(3, 3);
21
- await vi.runAllTimersAsync();
22
- const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
23
- tableModule.mergeCells([tds[3], tds[4], tds[6], tds[7]]);
24
- await vi.runAllTimersAsync();
25
- expect(quill.root).toEqualHTML(
26
- `
27
- <p><br></p>
28
- <div>
29
- <table cellpadding="0" cellspacing="0" data-full="true">
30
- <colgroup data-full="true">
31
- ${new Array(3).fill(0).map(() => `<col width="${1 / 3 * 100}%" data-full="true" />`).join('\n')}
32
- </colgroup>
33
- <tbody>
34
- <tr>
35
- ${new Array(3).fill(0).map(() => `<td rowspan="1" colspan="1"><div><p><br></p></div></td>`).join('\n')}
36
- </tr>
37
- <tr>
38
- <td rowspan="2" colspan="2">
39
- <div>
40
- <p><br></p>
41
- <p><br></p>
42
- <p><br></p>
43
- <p><br></p>
44
- </div>
45
- </td>
46
- <td rowspan="1" colspan="1"><div><p><br></p></div></td>
47
- </tr>
48
- <tr>
49
- <td rowspan="1" colspan="1"><div><p><br></p></div></td>
50
- </tr>
51
- </tbody>
52
- </table>
53
- </div>
54
- <p><br></p>
55
- `,
56
- { ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
57
- );
58
- });
59
-
60
- it('merge cells and clear rowspan or colspan', async () => {
61
- const quill = createQuillWithTableModule(`<p><br></p>`);
62
- const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
63
- tableModule.insertTable(2, 5);
64
- await vi.runAllTimersAsync();
65
- const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
66
- tableModule.mergeCells([tds[1], tds[2], tds[3], tds[6], tds[7], tds[8]]);
67
- await vi.runAllTimersAsync();
68
- expect(quill.root).toEqualHTML(
69
- `
70
- <p><br></p>
71
- <div>
72
- <table cellpadding="0" cellspacing="0" data-full="true">
73
- <colgroup data-full="true">
74
- <col width="20%" data-full="true" />
75
- <col width="60%" data-full="true" />
76
- <col width="20%" data-full="true" />
77
- </colgroup>
78
- <tbody>
79
- <tr>
80
- <td rowspan="1" colspan="1"><div><p><br></p></div></td>
81
- <td rowspan="2" colspan="1">
82
- <div>
83
- <p><br></p>
84
- <p><br></p>
85
- <p><br></p>
86
- <p><br></p>
87
- <p><br></p>
88
- <p><br></p>
89
- </div>
90
- </td>
91
- <td rowspan="1" colspan="1"><div><p><br></p></div></td>
92
- </tr>
93
- <tr>
94
- <td rowspan="1" colspan="1"><div><p><br></p></div></td>
95
- <td rowspan="1" colspan="1"><div><p><br></p></div></td>
96
- </tr>
97
- </tbody>
98
- </table>
99
- </div>
100
- <p><br></p>
101
- `,
102
- { ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
103
- );
104
- });
105
-
106
- it('merge cells across rowspan and colspan', async () => {
107
- const quill = createQuillWithTableModule(`<p><br></p>`);
108
- const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
109
- tableModule.insertTable(6, 7);
110
- await vi.runAllTimersAsync();
111
- const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
112
- tableModule.mergeCells([tds[7], tds[8], tds[9], tds[14], tds[15], tds[16], tds[21], tds[22], tds[23]]);
113
- await vi.runAllTimersAsync();
114
- tableModule.mergeCells([tds[25], tds[26], tds[27], tds[32], tds[33], tds[34], tds[39], tds[40], tds[41]]);
115
- await vi.runAllTimersAsync();
116
- tableModule.mergeCells([tds[3], tds[4], tds[5], tds[10], tds[11], tds[12], tds[17], tds[18], tds[19]]);
117
- await vi.runAllTimersAsync();
118
- expect(quill.root).toEqualHTML(
119
- `
120
- <p><br></p>
121
- <div>
122
- <table cellpadding="0" cellspacing="0" data-full="true">
123
- <colgroup data-full="true">
124
- ${new Array(4).fill(0).map(() => `<col width="${1 / 7 * 100}%" data-full="true" />`).join('\n')}
125
- <col width="${2 / 7 * 100}%" data-full="true" />
126
- <col width="${1 / 7 * 100}%" data-full="true" />
127
- </colgroup>
128
- <tbody>
129
- <tr>
130
- ${new Array(3).fill(0).map(() => `<td rowspan="1" colspan="1"><div><p><br></p></div></td>`).join('\n')}
131
- <td rowspan="3" colspan="2">
132
- <div>
133
- ${new Array(9).fill(0).map(() => `<p><br></p>`).join('\n')}
134
- </div>
135
- </td>
136
- <td rowspan="1" colspan="1"><div><p><br></p></div></td>
137
- </tr>
138
- <tr>
139
- <td rowspan="3" colspan="3">
140
- <div>
141
- ${new Array(9).fill(0).map(() => `<p><br></p>`).join('\n')}
142
- </div>
143
- </td>
144
- <td rowspan="1" colspan="1"><div><p><br></p></div></td>
145
- </tr>
146
- <tr>
147
- <td rowspan="1" colspan="1"><div><p><br></p></div></td>
148
- </tr>
149
- <tr>
150
- <td rowspan="1" colspan="1"><div><p><br></p></div></td>
151
- <td rowspan="3" colspan="2">
152
- <div>
153
- ${new Array(9).fill(0).map(() => `<p><br></p>`).join('\n')}
154
- </div>
155
- </td>
156
- </tr>
157
- ${
158
- new Array(2).fill(0).map(() => `
159
- <tr>
160
- ${new Array(4).fill(0).map(() => `<td rowspan="1" colspan="1"><div><p><br></p></div></td>`).join('\n')}
161
- </tr>
162
- `).join('\n')
163
- }
164
- </tbody>
165
- </table>
166
- </div>
167
- <p><br></p>
168
- `,
169
- { ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
170
- );
171
- });
172
-
173
- it('split cell', async () => {
174
- const quill = createQuillWithTableModule(`<p><br></p>`);
175
- const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
176
- tableModule.insertTable(3, 3);
177
- await vi.runAllTimersAsync();
178
- const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
179
- tableModule.mergeCells([tds[0], tds[1], tds[3], tds[4]]);
180
- await vi.runAllTimersAsync();
181
- tableModule.splitCell([tds[0]]);
182
- await vi.runAllTimersAsync();
183
- expect(quill.root).toEqualHTML(
184
- `
185
- <p><br></p>
186
- <div>
187
- <table cellpadding="0" cellspacing="0" data-full="true">
188
- <colgroup data-full="true">
189
- ${new Array(3).fill(0).map(() => `<col width="${1 / 3 * 100}%" data-full="true" />`).join('\n')}
190
- </colgroup>
191
- <tbody>
192
- <tr>
193
- <td rowspan="1" colspan="1">
194
- <div>
195
- <p><br></p>
196
- <p><br></p>
197
- <p><br></p>
198
- <p><br></p>
199
- </div>
200
- </td>
201
- <td rowspan="1" colspan="1"><div><p><br></p></div></td>
202
- <td rowspan="1" colspan="1"><div><p><br></p></div></td>
203
- </tr>
204
- ${
205
- new Array(2).fill(0).map(() => `
206
- <tr>
207
- ${new Array(3).fill(0).map(() => `<td rowspan="1" colspan="1"><div><p><br></p></div></td>`).join('\n')}
208
- </tr>
209
- `).join('\n')
210
- }
211
- </tbody>
212
- </table>
213
- </div>
214
- <p><br></p>
215
- `,
216
- { ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
217
- );
218
- });
219
-
220
- it('merge cells should sort correct colId', async () => {
221
- const quill = await createTable(5, 5);
222
- const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
223
- const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
224
- tableModule.mergeCells([tds[6], tds[7], tds[11], tds[12]]);
225
- await vi.runAllTimersAsync();
226
- tableModule.mergeCells([tds[5], tds[6], tds[10], tds[15], tds[16], tds[17], tds[20], tds[21], tds[22]]);
227
- await vi.runAllTimersAsync();
228
- expect(quill.root).toEqualHTML(
229
- `
230
- <p><br></p>
231
- <div>
232
- <table cellpadding="0" cellspacing="0" data-full="true">
233
- ${createTaleColHTML(5)}
234
- <tbody>
235
- <tr data-row-id="1">
236
- ${
237
- new Array(5).fill(0).map((_, j) => `<td rowspan="1" colspan="1" data-row-id="1" data-col-id="${j + 1}">
238
- <div data-rowspan="1" data-colspan="1" data-row-id="1" data-col-id="${j + 1}"><p>${j + 1}</p></div>
239
- </td>`).join('\n')
240
- }
241
- </tr>
242
- <tr data-row-id="2">
243
- <td rowspan="4" colspan="3" data-row-id="2" data-col-id="1">
244
- <div data-rowspan="4" data-colspan="3" data-row-id="2" data-col-id="1">
245
- <p>6</p>
246
- <p>7</p>
247
- <p>8</p>
248
- <p>12</p>
249
- <p>13</p>
250
- <p>11</p>
251
- <p>16</p>
252
- <p>17</p>
253
- <p>18</p>
254
- <p>21</p>
255
- <p>22</p>
256
- <p>23</p>
257
- </div>
258
- </td>
259
- <td rowspan="1" colspan="1" data-row-id="2" data-col-id="4">
260
- <div data-rowspan="1" data-colspan="1" data-row-id="2" data-col-id="4"><p>9</p></div>
261
- </td>
262
- <td rowspan="1" colspan="1" data-row-id="2" data-col-id="5">
263
- <div data-rowspan="1" data-colspan="1" data-row-id="2" data-col-id="5"><p>10</p></div>
264
- </td>
265
- </tr>
266
- <tr data-row-id="3">
267
- <td rowspan="1" colspan="1" data-row-id="3" data-col-id="4">
268
- <div data-rowspan="1" data-colspan="1" data-row-id="3" data-col-id="4"><p>14</p></div>
269
- </td>
270
- <td rowspan="1" colspan="1" data-row-id="3" data-col-id="5">
271
- <div data-rowspan="1" data-colspan="1" data-row-id="3" data-col-id="5"><p>15</p></div>
272
- </td>
273
- </tr>
274
- <tr data-row-id="4">
275
- <td rowspan="1" colspan="1" data-row-id="4" data-col-id="4">
276
- <div data-rowspan="1" data-colspan="1" data-row-id="4" data-col-id="4"><p>19</p></div>
277
- </td>
278
- <td rowspan="1" colspan="1" data-row-id="4" data-col-id="5">
279
- <div data-rowspan="1" data-colspan="1" data-row-id="4" data-col-id="5"><p>20</p></div>
280
- </td>
281
- </tr>
282
- <tr data-row-id="5">
283
- <td rowspan="1" colspan="1" data-row-id="5" data-col-id="4">
284
- <div data-rowspan="1" data-colspan="1" data-row-id="5" data-col-id="4"><p>24</p></div>
285
- </td>
286
- <td rowspan="1" colspan="1" data-row-id="5" data-col-id="5">
287
- <div data-rowspan="1" data-colspan="1" data-row-id="5" data-col-id="5"><p>25</p></div>
288
- </td>
289
- </tr>
290
- </tbody>
291
- </table>
292
- </div>
293
- <p><br></p>
294
- `,
295
- { ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'contenteditable'] },
296
- );
297
- });
298
-
299
- it('split cell should copy style to split cells', async () => {
300
- const quill = createQuillWithTableModule(`<p><br></p>`);
301
- quill.setContents([
302
- { insert: '\n' },
303
- { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '1vwhsx9zayhi', full: true, width: 20 } } },
304
- { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'gpais2dyp87', full: true, width: 20 } } },
305
- { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'xtfguzk629', full: true, width: 20 } } },
306
- { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '94w8b6fhy2p', full: true, width: 20 } } },
307
- { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'y0epsy6odnm', full: true, width: 20 } } },
308
- { insert: '1' },
309
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
310
- { insert: '2' },
311
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
312
- { insert: '3' },
313
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
314
- { insert: '4' },
315
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
316
- { insert: '6' },
317
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
318
- { insert: '7' },
319
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
320
- { insert: '8' },
321
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
322
- { insert: '9' },
323
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
324
- { insert: '11' },
325
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
326
- { insert: '12' },
327
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
328
- { insert: '13' },
329
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
330
- { insert: '14' },
331
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
332
- { insert: '16' },
333
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
334
- { insert: '17' },
335
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
336
- { insert: '18' },
337
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
338
- { insert: '19' },
339
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
340
- { insert: '5' },
341
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
342
- { insert: '10' },
343
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
344
- { insert: '15' },
345
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
346
- { insert: '20' },
347
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
348
- { insert: '21' },
349
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1 } }, insert: '\n' },
350
- { insert: '22' },
351
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'gpais2dyp87', rowspan: 1, colspan: 1 } }, insert: '\n' },
352
- { insert: '23' },
353
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'xtfguzk629', rowspan: 1, colspan: 1 } }, insert: '\n' },
354
- { insert: '24' },
355
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1 } }, insert: '\n' },
356
- { insert: '25' },
357
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
358
- { insert: '\n' },
359
- ]);
360
- await vi.runAllTimersAsync();
361
- const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
362
- const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
363
- tableModule.splitCell([tds[0]]);
364
- await vi.runAllTimersAsync();
365
- expectDelta(
366
- quill.getContents(),
367
- new Delta([
368
- { insert: '\n' },
369
- { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '1vwhsx9zayhi', full: true, width: 20 } } },
370
- { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'gpais2dyp87', full: true, width: 20 } } },
371
- { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'xtfguzk629', full: true, width: 20 } } },
372
- { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '94w8b6fhy2p', full: true, width: 20 } } },
373
- { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'y0epsy6odnm', full: true, width: 20 } } },
374
- { insert: '1' },
375
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
376
- { insert: '2' },
377
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
378
- { insert: '3' },
379
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
380
- { insert: '4' },
381
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
382
- { insert: '6' },
383
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
384
- { insert: '7' },
385
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
386
- { insert: '8' },
387
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
388
- { insert: '9' },
389
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
390
- { insert: '11' },
391
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
392
- { insert: '12' },
393
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
394
- { insert: '13' },
395
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
396
- { insert: '14' },
397
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
398
- { insert: '16' },
399
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
400
- { insert: '17' },
401
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
402
- { insert: '18' },
403
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
404
- { insert: '19' },
405
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
406
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
407
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'xtfguzk629', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
408
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
409
- { insert: '5' },
410
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
411
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
412
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
413
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: 'xtfguzk629', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
414
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
415
- { insert: '10' },
416
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
417
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
418
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
419
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'xtfguzk629', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
420
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
421
- { insert: '15' },
422
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
423
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
424
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
425
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'xtfguzk629', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
426
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
427
- { insert: '20' },
428
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
429
- { insert: '21' },
430
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
431
- { insert: '22' },
432
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
433
- { insert: '23' },
434
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'xtfguzk629', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
435
- { insert: '24' },
436
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
437
- { insert: '25' },
438
- { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
439
- { insert: '\n' },
440
- ]),
441
- );
442
- });
443
- });
444
-
445
- describe('disable auto merge', () => {
446
- it('empty row should not merge', async () => {
447
- const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: false });
448
- quill.setContents(createTableDeltaOps(5, 3, { full: false }, {}, { isEmpty: false }));
449
- const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
450
- const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
451
- tableModule.mergeCells([tds[3], tds[4], tds[5], tds[6], tds[7], tds[8], tds[9], tds[10], tds[11]]);
452
- await vi.runAllTimersAsync();
453
- expectDelta(
454
- quill.getContents(),
455
- new Delta([
456
- { insert: '\n' },
457
- { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
458
- { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
459
- { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
460
- { insert: '1' },
461
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
462
- { insert: '2' },
463
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
464
- { insert: '3' },
465
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
466
- { insert: '4' },
467
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
468
- { insert: '5' },
469
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
470
- { insert: '6' },
471
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
472
- { insert: '7' },
473
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
474
- { insert: '8' },
475
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
476
- { insert: '9' },
477
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
478
- { insert: '10' },
479
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
480
- { insert: '11' },
481
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
482
- { insert: '12' },
483
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
484
- { insert: '13' },
485
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '5', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
486
- { insert: '14' },
487
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '5', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
488
- { insert: '15' },
489
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '5', colId: '3', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
490
- { insert: '\n' },
491
- ]),
492
- );
493
- });
494
-
495
- it('empty col should not merge', async () => {
496
- const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: false });
497
- quill.setContents(createTableDeltaOps(3, 5, { full: false }, {}, { isEmpty: false }));
498
- const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
499
- const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
500
- tableModule.mergeCells([tds[1], tds[2], tds[3], tds[6], tds[7], tds[8], tds[11], tds[12], tds[13]]);
501
- await vi.runAllTimersAsync();
502
- expectDelta(
503
- quill.getContents(),
504
- new Delta([
505
- { insert: '\n' },
506
- { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
507
- { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
508
- { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
509
- { insert: { 'table-up-col': { tableId: '1', colId: '4', full: false, width: 100 } } },
510
- { insert: { 'table-up-col': { tableId: '1', colId: '5', full: false, width: 100 } } },
511
- { insert: '1' },
512
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
513
- { insert: '2' },
514
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
515
- { insert: '3' },
516
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
517
- { insert: '4' },
518
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
519
- { insert: '7' },
520
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
521
- { insert: '8' },
522
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
523
- { insert: '9' },
524
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
525
- { insert: '12' },
526
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
527
- { insert: '13' },
528
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
529
- { insert: '14' },
530
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
531
- { insert: '5' },
532
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '5', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
533
- { insert: '6' },
534
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
535
- { insert: '10' },
536
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '5', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
537
- { insert: '11' },
538
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
539
- { insert: '15' },
540
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '5', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
541
- { insert: '\n' },
542
- ]),
543
- );
544
- });
545
-
546
- it('empty col and row should not merge', async () => {
547
- const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: false });
548
- quill.setContents(createTableDeltaOps(3, 3, { full: false }, {}, { isEmpty: false }));
549
- const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
550
- const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
551
- tableModule.mergeCells([tds[0], tds[1], tds[2], tds[3], tds[4], tds[5], tds[6], tds[7], tds[8]]);
552
- await vi.runAllTimersAsync();
553
- expectDelta(
554
- quill.getContents(),
555
- new Delta([
556
- { insert: '\n' },
557
- { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
558
- { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
559
- { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
560
- { insert: '1' },
561
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
562
- { insert: '2' },
563
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
564
- { insert: '3' },
565
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
566
- { insert: '4' },
567
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
568
- { insert: '5' },
569
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
570
- { insert: '6' },
571
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
572
- { insert: '7' },
573
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
574
- { insert: '8' },
575
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
576
- { insert: '9' },
577
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
578
- { insert: '\n' },
579
- ]),
580
- );
581
- });
582
-
583
- it('setContents should auto merge empty row', async () => {
584
- const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: true });
585
- quill.setContents([
586
- { insert: '\n' },
587
- { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'i9yhk34pvj', full: false, width: 100 } } },
588
- { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'n7e0gc1xg9f', full: false, width: 100 } } },
589
- { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'gv9p4lkgae', full: false, width: 100 } } },
590
- { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'ffqtapdtna5', full: false, width: 100 } } },
591
- { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'jwhwfy06br', full: false, width: 100 } } },
592
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'i9yhk34pvj', rowspan: 1, colspan: 1 } }, insert: '\n' },
593
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'n7e0gc1xg9f', rowspan: 1, colspan: 1 } }, insert: '\n' },
594
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'gv9p4lkgae', rowspan: 1, colspan: 1 } }, insert: '\n' },
595
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'ffqtapdtna5', rowspan: 1, colspan: 1 } }, insert: '\n' },
596
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'jwhwfy06br', rowspan: 1, colspan: 1 } }, insert: '\n' },
597
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'i9yhk34pvj', rowspan: 1, colspan: 1 } }, insert: '\n' },
598
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'n7e0gc1xg9f', rowspan: 1, colspan: 1 } }, insert: '\n' },
599
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'gv9p4lkgae', rowspan: 1, colspan: 1 } }, insert: '\n' },
600
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'ffqtapdtna5', rowspan: 1, colspan: 1 } }, insert: '\n' },
601
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'jwhwfy06br', rowspan: 1, colspan: 1 } }, insert: '\n' },
602
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'do0hckk1ete', colId: 'i9yhk34pvj', rowspan: 3, colspan: 5, emptyRow: ['17tp5f5600t', '3c1ldcf2rwc'] } }, insert: '\n' },
603
- { insert: '\n' },
604
- ]);
605
- await vi.runAllTimersAsync();
606
-
607
- expectDelta(
608
- quill.getContents(),
609
- new Delta([
610
- { insert: '\n' },
611
- { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'i9yhk34pvj', full: false, width: 100 } } },
612
- { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'n7e0gc1xg9f', full: false, width: 100 } } },
613
- { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'gv9p4lkgae', full: false, width: 100 } } },
614
- { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'ffqtapdtna5', full: false, width: 100 } } },
615
- { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'jwhwfy06br', full: false, width: 100 } } },
616
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'i9yhk34pvj', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
617
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'n7e0gc1xg9f', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
618
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'gv9p4lkgae', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
619
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'ffqtapdtna5', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
620
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'jwhwfy06br', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
621
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'i9yhk34pvj', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
622
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'n7e0gc1xg9f', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
623
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'gv9p4lkgae', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
624
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'ffqtapdtna5', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
625
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'jwhwfy06br', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
626
- { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'do0hckk1ete', colId: 'i9yhk34pvj', rowspan: 1, colspan: 5, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
627
- { insert: '\n' },
628
- ]),
629
- );
630
- });
631
-
632
- it('setContents should auto merge empty col', async () => {
633
- const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: true });
634
- quill.setContents([
635
- { insert: '\n' },
636
- { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: 's557nidp0z', full: false, width: 100 } } },
637
- { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: '63fssosw5z', full: false, width: 100 } } },
638
- { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: 'j5clq5hlefa', full: false, width: 100 } } },
639
- { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: 'v8c96f1poao', full: false, width: 100 } } },
640
- { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: '31opl1kh2ez', full: false, width: 100 } } },
641
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '50d6mllesnf', colId: 's557nidp0z', rowspan: 1, colspan: 1 } }, insert: '\n' },
642
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '50d6mllesnf', colId: '63fssosw5z', rowspan: 1, colspan: 1 } }, insert: '\n' },
643
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '50d6mllesnf', colId: 'j5clq5hlefa', rowspan: 5, colspan: 3 } }, insert: '\n' },
644
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'dk3fj38jr0q', colId: 's557nidp0z', rowspan: 1, colspan: 1 } }, insert: '\n' },
645
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'dk3fj38jr0q', colId: '63fssosw5z', rowspan: 1, colspan: 1 } }, insert: '\n' },
646
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '0hp4pxkxs8eg', colId: 's557nidp0z', rowspan: 1, colspan: 1 } }, insert: '\n' },
647
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '0hp4pxkxs8eg', colId: '63fssosw5z', rowspan: 1, colspan: 1 } }, insert: '\n' },
648
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'd7xc4ei18x', colId: 's557nidp0z', rowspan: 1, colspan: 1 } }, insert: '\n' },
649
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'd7xc4ei18x', colId: '63fssosw5z', rowspan: 1, colspan: 1 } }, insert: '\n' },
650
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'i5xpndw78t', colId: 's557nidp0z', rowspan: 1, colspan: 1 } }, insert: '\n' },
651
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'i5xpndw78t', colId: '63fssosw5z', rowspan: 1, colspan: 1 } }, insert: '\n' },
652
- { insert: '\n' },
653
- ]);
654
- await vi.runAllTimersAsync();
655
-
656
- expectDelta(
657
- quill.getContents(),
658
- new Delta([
659
- { insert: '\n' },
660
- { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: 's557nidp0z', full: false, width: 100 } } },
661
- { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: '63fssosw5z', full: false, width: 100 } } },
662
- { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: 'j5clq5hlefa', full: false, width: 300 } } },
663
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '50d6mllesnf', colId: 's557nidp0z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
664
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '50d6mllesnf', colId: '63fssosw5z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
665
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '50d6mllesnf', colId: 'j5clq5hlefa', rowspan: 5, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
666
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'dk3fj38jr0q', colId: 's557nidp0z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
667
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'dk3fj38jr0q', colId: '63fssosw5z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
668
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '0hp4pxkxs8eg', colId: 's557nidp0z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
669
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '0hp4pxkxs8eg', colId: '63fssosw5z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
670
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'd7xc4ei18x', colId: 's557nidp0z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
671
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'd7xc4ei18x', colId: '63fssosw5z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
672
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'i5xpndw78t', colId: 's557nidp0z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
673
- { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'i5xpndw78t', colId: '63fssosw5z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
674
- { insert: '\n' },
675
- ]),
676
- );
677
- });
678
-
679
- it('setContents should auto merge empty col and empty row', async () => {
680
- const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: true });
681
- quill.setContents([
682
- { insert: '\n' },
683
- { insert: { 'table-up-col': { tableId: 'bgpbkkx7n8t', colId: 'zmikq4vcb7q', full: false, width: 100 } } },
684
- { insert: { 'table-up-col': { tableId: 'bgpbkkx7n8t', colId: 'jgdjl8jtn', full: false, width: 100 } } },
685
- { insert: { 'table-up-col': { tableId: 'bgpbkkx7n8t', colId: 'v51gsg6tcr', full: false, width: 100 } } },
686
- { insert: { 'table-up-col': { tableId: 'bgpbkkx7n8t', colId: 'bthp5lq8z6f', full: false, width: 100 } } },
687
- { insert: { 'table-up-col': { tableId: 'bgpbkkx7n8t', colId: 'w02ywy5elc', full: false, width: 100 } } },
688
- { attributes: { 'table-up-cell-inner': { tableId: 'bgpbkkx7n8t', rowId: '6kt0grl6zwn', colId: 'zmikq4vcb7q', rowspan: 5, colspan: 5, emptyRow: ['cc88nvap3xj', 'aj0a8w2fzbh', 'q9v14h4sgx', '7kz0ke5l4eq'] } }, insert: '\n' },
689
- { insert: '\n' },
690
- ]);
691
- await vi.runAllTimersAsync();
692
-
693
- expectDelta(
694
- quill.getContents(),
695
- new Delta([
696
- { insert: '\n' },
697
- { insert: { 'table-up-col': { tableId: 'bgpbkkx7n8t', colId: 'zmikq4vcb7q', full: false, width: 500 } } },
698
- { attributes: { 'table-up-cell-inner': { tableId: 'bgpbkkx7n8t', rowId: '6kt0grl6zwn', colId: 'zmikq4vcb7q', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
699
- { insert: '\n' },
700
- ]),
701
- );
702
- });
703
-
704
- it('`emptyRow` should have same order with tr', async () => {
705
- const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: false });
706
- quill.setContents(createTableDeltaOps(5, 3, { full: false }, {}, { isEmpty: false }));
707
- const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
708
- const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
709
- tableModule.mergeCells([tds[3], tds[4], tds[5], tds[6], tds[7], tds[8], tds[9], tds[10], tds[11]]);
710
- await vi.runAllTimersAsync();
711
-
712
- const tableBlot = quill.scroll.descendants(TableMainFormat, 0)[0];
713
- const emptyRowIds = tds[3].emptyRow;
714
- const rowIds = tableBlot.getRowIds();
715
- const startRowIndex = rowIds.indexOf(tds[3].rowId);
716
-
717
- expect(emptyRowIds.length).toEqual(2);
718
- expect(tds[3].rowspan).toEqual(3);
719
- expect(startRowIndex).toEqual(1);
720
- for (let i = startRowIndex + 1; i < startRowIndex + emptyRowIds.length; i++) {
721
- expect(rowIds[i]).toEqual(emptyRowIds[i - startRowIndex - 1]);
722
- }
723
- });
724
- });
1
+ import Quill from 'quill';
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
+ import { TableCellInnerFormat, TableMainFormat } from '../../formats';
4
+ import { TableUp } from '../../table-up';
5
+ import { createQuillWithTableModule, createTable, createTableDeltaOps, createTaleColHTML, expectDelta } from './utils';
6
+
7
+ const Delta = Quill.import('delta');
8
+
9
+ beforeEach(() => {
10
+ vi.useFakeTimers();
11
+ });
12
+ afterEach(() => {
13
+ vi.useRealTimers();
14
+ });
15
+
16
+ describe('merge and split cell', () => {
17
+ it('merge cells', async () => {
18
+ const quill = createQuillWithTableModule(`<p><br></p>`);
19
+ const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
20
+ tableModule.insertTable(3, 3);
21
+ await vi.runAllTimersAsync();
22
+ const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
23
+ tableModule.mergeCells([tds[3], tds[4], tds[6], tds[7]]);
24
+ await vi.runAllTimersAsync();
25
+ expect(quill.root).toEqualHTML(
26
+ `
27
+ <p><br></p>
28
+ <div>
29
+ <table cellpadding="0" cellspacing="0" data-full="true">
30
+ <colgroup data-full="true">
31
+ ${new Array(3).fill(0).map(() => `<col width="${1 / 3 * 100}%" data-full="true" />`).join('\n')}
32
+ </colgroup>
33
+ <tbody>
34
+ <tr>
35
+ ${new Array(3).fill(0).map(() => `<td rowspan="1" colspan="1"><div><p><br></p></div></td>`).join('\n')}
36
+ </tr>
37
+ <tr>
38
+ <td rowspan="2" colspan="2">
39
+ <div>
40
+ <p><br></p>
41
+ <p><br></p>
42
+ <p><br></p>
43
+ <p><br></p>
44
+ </div>
45
+ </td>
46
+ <td rowspan="1" colspan="1"><div><p><br></p></div></td>
47
+ </tr>
48
+ <tr>
49
+ <td rowspan="1" colspan="1"><div><p><br></p></div></td>
50
+ </tr>
51
+ </tbody>
52
+ </table>
53
+ </div>
54
+ <p><br></p>
55
+ `,
56
+ { ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
57
+ );
58
+ });
59
+
60
+ it('merge cells and clear rowspan or colspan', async () => {
61
+ const quill = createQuillWithTableModule(`<p><br></p>`);
62
+ const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
63
+ tableModule.insertTable(2, 5);
64
+ await vi.runAllTimersAsync();
65
+ const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
66
+ tableModule.mergeCells([tds[1], tds[2], tds[3], tds[6], tds[7], tds[8]]);
67
+ await vi.runAllTimersAsync();
68
+ expect(quill.root).toEqualHTML(
69
+ `
70
+ <p><br></p>
71
+ <div>
72
+ <table cellpadding="0" cellspacing="0" data-full="true">
73
+ <colgroup data-full="true">
74
+ <col width="20%" data-full="true" />
75
+ <col width="60%" data-full="true" />
76
+ <col width="20%" data-full="true" />
77
+ </colgroup>
78
+ <tbody>
79
+ <tr>
80
+ <td rowspan="1" colspan="1"><div><p><br></p></div></td>
81
+ <td rowspan="2" colspan="1">
82
+ <div>
83
+ <p><br></p>
84
+ <p><br></p>
85
+ <p><br></p>
86
+ <p><br></p>
87
+ <p><br></p>
88
+ <p><br></p>
89
+ </div>
90
+ </td>
91
+ <td rowspan="1" colspan="1"><div><p><br></p></div></td>
92
+ </tr>
93
+ <tr>
94
+ <td rowspan="1" colspan="1"><div><p><br></p></div></td>
95
+ <td rowspan="1" colspan="1"><div><p><br></p></div></td>
96
+ </tr>
97
+ </tbody>
98
+ </table>
99
+ </div>
100
+ <p><br></p>
101
+ `,
102
+ { ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
103
+ );
104
+ });
105
+
106
+ it('merge cells across rowspan and colspan', async () => {
107
+ const quill = createQuillWithTableModule(`<p><br></p>`);
108
+ const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
109
+ tableModule.insertTable(6, 7);
110
+ await vi.runAllTimersAsync();
111
+ const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
112
+ tableModule.mergeCells([tds[7], tds[8], tds[9], tds[14], tds[15], tds[16], tds[21], tds[22], tds[23]]);
113
+ await vi.runAllTimersAsync();
114
+ tableModule.mergeCells([tds[25], tds[26], tds[27], tds[32], tds[33], tds[34], tds[39], tds[40], tds[41]]);
115
+ await vi.runAllTimersAsync();
116
+ tableModule.mergeCells([tds[3], tds[4], tds[5], tds[10], tds[11], tds[12], tds[17], tds[18], tds[19]]);
117
+ await vi.runAllTimersAsync();
118
+ expect(quill.root).toEqualHTML(
119
+ `
120
+ <p><br></p>
121
+ <div>
122
+ <table cellpadding="0" cellspacing="0" data-full="true">
123
+ <colgroup data-full="true">
124
+ ${new Array(4).fill(0).map(() => `<col width="${1 / 7 * 100}%" data-full="true" />`).join('\n')}
125
+ <col width="${2 / 7 * 100}%" data-full="true" />
126
+ <col width="${1 / 7 * 100}%" data-full="true" />
127
+ </colgroup>
128
+ <tbody>
129
+ <tr>
130
+ ${new Array(3).fill(0).map(() => `<td rowspan="1" colspan="1"><div><p><br></p></div></td>`).join('\n')}
131
+ <td rowspan="3" colspan="2">
132
+ <div>
133
+ ${new Array(9).fill(0).map(() => `<p><br></p>`).join('\n')}
134
+ </div>
135
+ </td>
136
+ <td rowspan="1" colspan="1"><div><p><br></p></div></td>
137
+ </tr>
138
+ <tr>
139
+ <td rowspan="3" colspan="3">
140
+ <div>
141
+ ${new Array(9).fill(0).map(() => `<p><br></p>`).join('\n')}
142
+ </div>
143
+ </td>
144
+ <td rowspan="1" colspan="1"><div><p><br></p></div></td>
145
+ </tr>
146
+ <tr>
147
+ <td rowspan="1" colspan="1"><div><p><br></p></div></td>
148
+ </tr>
149
+ <tr>
150
+ <td rowspan="1" colspan="1"><div><p><br></p></div></td>
151
+ <td rowspan="3" colspan="2">
152
+ <div>
153
+ ${new Array(9).fill(0).map(() => `<p><br></p>`).join('\n')}
154
+ </div>
155
+ </td>
156
+ </tr>
157
+ ${
158
+ new Array(2).fill(0).map(() => `
159
+ <tr>
160
+ ${new Array(4).fill(0).map(() => `<td rowspan="1" colspan="1"><div><p><br></p></div></td>`).join('\n')}
161
+ </tr>
162
+ `).join('\n')
163
+ }
164
+ </tbody>
165
+ </table>
166
+ </div>
167
+ <p><br></p>
168
+ `,
169
+ { ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
170
+ );
171
+ });
172
+
173
+ it('split cell', async () => {
174
+ const quill = createQuillWithTableModule(`<p><br></p>`);
175
+ const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
176
+ tableModule.insertTable(3, 3);
177
+ await vi.runAllTimersAsync();
178
+ const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
179
+ tableModule.mergeCells([tds[0], tds[1], tds[3], tds[4]]);
180
+ await vi.runAllTimersAsync();
181
+ tableModule.splitCell([tds[0]]);
182
+ await vi.runAllTimersAsync();
183
+ expect(quill.root).toEqualHTML(
184
+ `
185
+ <p><br></p>
186
+ <div>
187
+ <table cellpadding="0" cellspacing="0" data-full="true">
188
+ <colgroup data-full="true">
189
+ ${new Array(3).fill(0).map(() => `<col width="${1 / 3 * 100}%" data-full="true" />`).join('\n')}
190
+ </colgroup>
191
+ <tbody>
192
+ <tr>
193
+ <td rowspan="1" colspan="1">
194
+ <div>
195
+ <p><br></p>
196
+ <p><br></p>
197
+ <p><br></p>
198
+ <p><br></p>
199
+ </div>
200
+ </td>
201
+ <td rowspan="1" colspan="1"><div><p><br></p></div></td>
202
+ <td rowspan="1" colspan="1"><div><p><br></p></div></td>
203
+ </tr>
204
+ ${
205
+ new Array(2).fill(0).map(() => `
206
+ <tr>
207
+ ${new Array(3).fill(0).map(() => `<td rowspan="1" colspan="1"><div><p><br></p></div></td>`).join('\n')}
208
+ </tr>
209
+ `).join('\n')
210
+ }
211
+ </tbody>
212
+ </table>
213
+ </div>
214
+ <p><br></p>
215
+ `,
216
+ { ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
217
+ );
218
+ });
219
+
220
+ it('merge cells should sort correct colId', async () => {
221
+ const quill = await createTable(5, 5);
222
+ const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
223
+ const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
224
+ tableModule.mergeCells([tds[6], tds[7], tds[11], tds[12]]);
225
+ await vi.runAllTimersAsync();
226
+ tableModule.mergeCells([tds[5], tds[6], tds[10], tds[15], tds[16], tds[17], tds[20], tds[21], tds[22]]);
227
+ await vi.runAllTimersAsync();
228
+ expect(quill.root).toEqualHTML(
229
+ `
230
+ <p><br></p>
231
+ <div>
232
+ <table cellpadding="0" cellspacing="0" data-full="true">
233
+ ${createTaleColHTML(5)}
234
+ <tbody>
235
+ <tr data-row-id="1">
236
+ ${
237
+ new Array(5).fill(0).map((_, j) => `<td rowspan="1" colspan="1" data-row-id="1" data-col-id="${j + 1}">
238
+ <div data-rowspan="1" data-colspan="1" data-row-id="1" data-col-id="${j + 1}"><p>${j + 1}</p></div>
239
+ </td>`).join('\n')
240
+ }
241
+ </tr>
242
+ <tr data-row-id="2">
243
+ <td rowspan="4" colspan="3" data-row-id="2" data-col-id="1">
244
+ <div data-rowspan="4" data-colspan="3" data-row-id="2" data-col-id="1">
245
+ <p>6</p>
246
+ <p>7</p>
247
+ <p>8</p>
248
+ <p>12</p>
249
+ <p>13</p>
250
+ <p>11</p>
251
+ <p>16</p>
252
+ <p>17</p>
253
+ <p>18</p>
254
+ <p>21</p>
255
+ <p>22</p>
256
+ <p>23</p>
257
+ </div>
258
+ </td>
259
+ <td rowspan="1" colspan="1" data-row-id="2" data-col-id="4">
260
+ <div data-rowspan="1" data-colspan="1" data-row-id="2" data-col-id="4"><p>9</p></div>
261
+ </td>
262
+ <td rowspan="1" colspan="1" data-row-id="2" data-col-id="5">
263
+ <div data-rowspan="1" data-colspan="1" data-row-id="2" data-col-id="5"><p>10</p></div>
264
+ </td>
265
+ </tr>
266
+ <tr data-row-id="3">
267
+ <td rowspan="1" colspan="1" data-row-id="3" data-col-id="4">
268
+ <div data-rowspan="1" data-colspan="1" data-row-id="3" data-col-id="4"><p>14</p></div>
269
+ </td>
270
+ <td rowspan="1" colspan="1" data-row-id="3" data-col-id="5">
271
+ <div data-rowspan="1" data-colspan="1" data-row-id="3" data-col-id="5"><p>15</p></div>
272
+ </td>
273
+ </tr>
274
+ <tr data-row-id="4">
275
+ <td rowspan="1" colspan="1" data-row-id="4" data-col-id="4">
276
+ <div data-rowspan="1" data-colspan="1" data-row-id="4" data-col-id="4"><p>19</p></div>
277
+ </td>
278
+ <td rowspan="1" colspan="1" data-row-id="4" data-col-id="5">
279
+ <div data-rowspan="1" data-colspan="1" data-row-id="4" data-col-id="5"><p>20</p></div>
280
+ </td>
281
+ </tr>
282
+ <tr data-row-id="5">
283
+ <td rowspan="1" colspan="1" data-row-id="5" data-col-id="4">
284
+ <div data-rowspan="1" data-colspan="1" data-row-id="5" data-col-id="4"><p>24</p></div>
285
+ </td>
286
+ <td rowspan="1" colspan="1" data-row-id="5" data-col-id="5">
287
+ <div data-rowspan="1" data-colspan="1" data-row-id="5" data-col-id="5"><p>25</p></div>
288
+ </td>
289
+ </tr>
290
+ </tbody>
291
+ </table>
292
+ </div>
293
+ <p><br></p>
294
+ `,
295
+ { ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'contenteditable'] },
296
+ );
297
+ });
298
+
299
+ it('split cell should copy style to split cells', async () => {
300
+ const quill = createQuillWithTableModule(`<p><br></p>`);
301
+ quill.setContents([
302
+ { insert: '\n' },
303
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '1vwhsx9zayhi', full: true, width: 20 } } },
304
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'gpais2dyp87', full: true, width: 20 } } },
305
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'xtfguzk629', full: true, width: 20 } } },
306
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '94w8b6fhy2p', full: true, width: 20 } } },
307
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'y0epsy6odnm', full: true, width: 20 } } },
308
+ { insert: '1' },
309
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
310
+ { insert: '2' },
311
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
312
+ { insert: '3' },
313
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
314
+ { insert: '4' },
315
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
316
+ { insert: '6' },
317
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
318
+ { insert: '7' },
319
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
320
+ { insert: '8' },
321
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
322
+ { insert: '9' },
323
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
324
+ { insert: '11' },
325
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
326
+ { insert: '12' },
327
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
328
+ { insert: '13' },
329
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
330
+ { insert: '14' },
331
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
332
+ { insert: '16' },
333
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
334
+ { insert: '17' },
335
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
336
+ { insert: '18' },
337
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
338
+ { insert: '19' },
339
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
340
+ { insert: '5' },
341
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
342
+ { insert: '10' },
343
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
344
+ { insert: '15' },
345
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
346
+ { insert: '20' },
347
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
348
+ { insert: '21' },
349
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1 } }, insert: '\n' },
350
+ { insert: '22' },
351
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'gpais2dyp87', rowspan: 1, colspan: 1 } }, insert: '\n' },
352
+ { insert: '23' },
353
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'xtfguzk629', rowspan: 1, colspan: 1 } }, insert: '\n' },
354
+ { insert: '24' },
355
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1 } }, insert: '\n' },
356
+ { insert: '25' },
357
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
358
+ { insert: '\n' },
359
+ ]);
360
+ await vi.runAllTimersAsync();
361
+ const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
362
+ const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
363
+ tableModule.splitCell([tds[0]]);
364
+ await vi.runAllTimersAsync();
365
+ expectDelta(
366
+ quill.getContents(),
367
+ new Delta([
368
+ { insert: '\n' },
369
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '1vwhsx9zayhi', full: true, width: 20 } } },
370
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'gpais2dyp87', full: true, width: 20 } } },
371
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'xtfguzk629', full: true, width: 20 } } },
372
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '94w8b6fhy2p', full: true, width: 20 } } },
373
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'y0epsy6odnm', full: true, width: 20 } } },
374
+ { insert: '1' },
375
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
376
+ { insert: '2' },
377
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
378
+ { insert: '3' },
379
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
380
+ { insert: '4' },
381
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
382
+ { insert: '6' },
383
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
384
+ { insert: '7' },
385
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
386
+ { insert: '8' },
387
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
388
+ { insert: '9' },
389
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
390
+ { insert: '11' },
391
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
392
+ { insert: '12' },
393
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
394
+ { insert: '13' },
395
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
396
+ { insert: '14' },
397
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
398
+ { insert: '16' },
399
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
400
+ { insert: '17' },
401
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
402
+ { insert: '18' },
403
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
404
+ { insert: '19' },
405
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
406
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
407
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'xtfguzk629', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
408
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
409
+ { insert: '5' },
410
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
411
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
412
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
413
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: 'xtfguzk629', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
414
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
415
+ { insert: '10' },
416
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
417
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
418
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
419
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'xtfguzk629', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
420
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
421
+ { insert: '15' },
422
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
423
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
424
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
425
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'xtfguzk629', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
426
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
427
+ { insert: '20' },
428
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
429
+ { insert: '21' },
430
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
431
+ { insert: '22' },
432
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
433
+ { insert: '23' },
434
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'xtfguzk629', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
435
+ { insert: '24' },
436
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
437
+ { insert: '25' },
438
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
439
+ { insert: '\n' },
440
+ ]),
441
+ );
442
+ });
443
+ });
444
+
445
+ describe('disable auto merge', () => {
446
+ it('empty row should not merge', async () => {
447
+ const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: false });
448
+ quill.setContents(createTableDeltaOps(5, 3, { full: false }, {}, { isEmpty: false }));
449
+ const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
450
+ const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
451
+ tableModule.mergeCells([tds[3], tds[4], tds[5], tds[6], tds[7], tds[8], tds[9], tds[10], tds[11]]);
452
+ await vi.runAllTimersAsync();
453
+ expectDelta(
454
+ quill.getContents(),
455
+ new Delta([
456
+ { insert: '\n' },
457
+ { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
458
+ { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
459
+ { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
460
+ { insert: '1' },
461
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
462
+ { insert: '2' },
463
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
464
+ { insert: '3' },
465
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
466
+ { insert: '4' },
467
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
468
+ { insert: '5' },
469
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
470
+ { insert: '6' },
471
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
472
+ { insert: '7' },
473
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
474
+ { insert: '8' },
475
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
476
+ { insert: '9' },
477
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
478
+ { insert: '10' },
479
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
480
+ { insert: '11' },
481
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
482
+ { insert: '12' },
483
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['3', '4'] } }, insert: '\n' },
484
+ { insert: '13' },
485
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '5', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
486
+ { insert: '14' },
487
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '5', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
488
+ { insert: '15' },
489
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '5', colId: '3', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
490
+ { insert: '\n' },
491
+ ]),
492
+ );
493
+ });
494
+
495
+ it('empty col should not merge', async () => {
496
+ const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: false });
497
+ quill.setContents(createTableDeltaOps(3, 5, { full: false }, {}, { isEmpty: false }));
498
+ const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
499
+ const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
500
+ tableModule.mergeCells([tds[1], tds[2], tds[3], tds[6], tds[7], tds[8], tds[11], tds[12], tds[13]]);
501
+ await vi.runAllTimersAsync();
502
+ expectDelta(
503
+ quill.getContents(),
504
+ new Delta([
505
+ { insert: '\n' },
506
+ { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
507
+ { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
508
+ { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
509
+ { insert: { 'table-up-col': { tableId: '1', colId: '4', full: false, width: 100 } } },
510
+ { insert: { 'table-up-col': { tableId: '1', colId: '5', full: false, width: 100 } } },
511
+ { insert: '1' },
512
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
513
+ { insert: '2' },
514
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
515
+ { insert: '3' },
516
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
517
+ { insert: '4' },
518
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
519
+ { insert: '7' },
520
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
521
+ { insert: '8' },
522
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
523
+ { insert: '9' },
524
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
525
+ { insert: '12' },
526
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
527
+ { insert: '13' },
528
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
529
+ { insert: '14' },
530
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
531
+ { insert: '5' },
532
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '5', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
533
+ { insert: '6' },
534
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
535
+ { insert: '10' },
536
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '5', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
537
+ { insert: '11' },
538
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
539
+ { insert: '15' },
540
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '5', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
541
+ { insert: '\n' },
542
+ ]),
543
+ );
544
+ });
545
+
546
+ it('empty col and row should not merge', async () => {
547
+ const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: false });
548
+ quill.setContents(createTableDeltaOps(3, 3, { full: false }, {}, { isEmpty: false }));
549
+ const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
550
+ const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
551
+ tableModule.mergeCells([tds[0], tds[1], tds[2], tds[3], tds[4], tds[5], tds[6], tds[7], tds[8]]);
552
+ await vi.runAllTimersAsync();
553
+ expectDelta(
554
+ quill.getContents(),
555
+ new Delta([
556
+ { insert: '\n' },
557
+ { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
558
+ { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
559
+ { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
560
+ { insert: '1' },
561
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
562
+ { insert: '2' },
563
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
564
+ { insert: '3' },
565
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
566
+ { insert: '4' },
567
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
568
+ { insert: '5' },
569
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
570
+ { insert: '6' },
571
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
572
+ { insert: '7' },
573
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
574
+ { insert: '8' },
575
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
576
+ { insert: '9' },
577
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 3, colspan: 3, tag: 'td', wrapTag: 'tbody', emptyRow: ['2', '3'] } }, insert: '\n' },
578
+ { insert: '\n' },
579
+ ]),
580
+ );
581
+ });
582
+
583
+ it('setContents should auto merge empty row', async () => {
584
+ const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: true });
585
+ quill.setContents([
586
+ { insert: '\n' },
587
+ { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'i9yhk34pvj', full: false, width: 100 } } },
588
+ { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'n7e0gc1xg9f', full: false, width: 100 } } },
589
+ { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'gv9p4lkgae', full: false, width: 100 } } },
590
+ { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'ffqtapdtna5', full: false, width: 100 } } },
591
+ { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'jwhwfy06br', full: false, width: 100 } } },
592
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'i9yhk34pvj', rowspan: 1, colspan: 1 } }, insert: '\n' },
593
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'n7e0gc1xg9f', rowspan: 1, colspan: 1 } }, insert: '\n' },
594
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'gv9p4lkgae', rowspan: 1, colspan: 1 } }, insert: '\n' },
595
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'ffqtapdtna5', rowspan: 1, colspan: 1 } }, insert: '\n' },
596
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'jwhwfy06br', rowspan: 1, colspan: 1 } }, insert: '\n' },
597
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'i9yhk34pvj', rowspan: 1, colspan: 1 } }, insert: '\n' },
598
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'n7e0gc1xg9f', rowspan: 1, colspan: 1 } }, insert: '\n' },
599
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'gv9p4lkgae', rowspan: 1, colspan: 1 } }, insert: '\n' },
600
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'ffqtapdtna5', rowspan: 1, colspan: 1 } }, insert: '\n' },
601
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'jwhwfy06br', rowspan: 1, colspan: 1 } }, insert: '\n' },
602
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'do0hckk1ete', colId: 'i9yhk34pvj', rowspan: 3, colspan: 5, emptyRow: ['17tp5f5600t', '3c1ldcf2rwc'] } }, insert: '\n' },
603
+ { insert: '\n' },
604
+ ]);
605
+ await vi.runAllTimersAsync();
606
+
607
+ expectDelta(
608
+ quill.getContents(),
609
+ new Delta([
610
+ { insert: '\n' },
611
+ { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'i9yhk34pvj', full: false, width: 100 } } },
612
+ { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'n7e0gc1xg9f', full: false, width: 100 } } },
613
+ { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'gv9p4lkgae', full: false, width: 100 } } },
614
+ { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'ffqtapdtna5', full: false, width: 100 } } },
615
+ { insert: { 'table-up-col': { tableId: 'khwu5pmtg5l', colId: 'jwhwfy06br', full: false, width: 100 } } },
616
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'i9yhk34pvj', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
617
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'n7e0gc1xg9f', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
618
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'gv9p4lkgae', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
619
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'ffqtapdtna5', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
620
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'outr9871l1', colId: 'jwhwfy06br', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
621
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'i9yhk34pvj', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
622
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'n7e0gc1xg9f', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
623
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'gv9p4lkgae', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
624
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'ffqtapdtna5', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
625
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: '3ofclohah6a', colId: 'jwhwfy06br', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
626
+ { attributes: { 'table-up-cell-inner': { tableId: 'khwu5pmtg5l', rowId: 'do0hckk1ete', colId: 'i9yhk34pvj', rowspan: 1, colspan: 5, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
627
+ { insert: '\n' },
628
+ ]),
629
+ );
630
+ });
631
+
632
+ it('setContents should auto merge empty col', async () => {
633
+ const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: true });
634
+ quill.setContents([
635
+ { insert: '\n' },
636
+ { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: 's557nidp0z', full: false, width: 100 } } },
637
+ { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: '63fssosw5z', full: false, width: 100 } } },
638
+ { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: 'j5clq5hlefa', full: false, width: 100 } } },
639
+ { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: 'v8c96f1poao', full: false, width: 100 } } },
640
+ { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: '31opl1kh2ez', full: false, width: 100 } } },
641
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '50d6mllesnf', colId: 's557nidp0z', rowspan: 1, colspan: 1 } }, insert: '\n' },
642
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '50d6mllesnf', colId: '63fssosw5z', rowspan: 1, colspan: 1 } }, insert: '\n' },
643
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '50d6mllesnf', colId: 'j5clq5hlefa', rowspan: 5, colspan: 3 } }, insert: '\n' },
644
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'dk3fj38jr0q', colId: 's557nidp0z', rowspan: 1, colspan: 1 } }, insert: '\n' },
645
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'dk3fj38jr0q', colId: '63fssosw5z', rowspan: 1, colspan: 1 } }, insert: '\n' },
646
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '0hp4pxkxs8eg', colId: 's557nidp0z', rowspan: 1, colspan: 1 } }, insert: '\n' },
647
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '0hp4pxkxs8eg', colId: '63fssosw5z', rowspan: 1, colspan: 1 } }, insert: '\n' },
648
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'd7xc4ei18x', colId: 's557nidp0z', rowspan: 1, colspan: 1 } }, insert: '\n' },
649
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'd7xc4ei18x', colId: '63fssosw5z', rowspan: 1, colspan: 1 } }, insert: '\n' },
650
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'i5xpndw78t', colId: 's557nidp0z', rowspan: 1, colspan: 1 } }, insert: '\n' },
651
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'i5xpndw78t', colId: '63fssosw5z', rowspan: 1, colspan: 1 } }, insert: '\n' },
652
+ { insert: '\n' },
653
+ ]);
654
+ await vi.runAllTimersAsync();
655
+
656
+ expectDelta(
657
+ quill.getContents(),
658
+ new Delta([
659
+ { insert: '\n' },
660
+ { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: 's557nidp0z', full: false, width: 100 } } },
661
+ { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: '63fssosw5z', full: false, width: 100 } } },
662
+ { insert: { 'table-up-col': { tableId: 'sqhdx5zecxh', colId: 'j5clq5hlefa', full: false, width: 300 } } },
663
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '50d6mllesnf', colId: 's557nidp0z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
664
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '50d6mllesnf', colId: '63fssosw5z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
665
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '50d6mllesnf', colId: 'j5clq5hlefa', rowspan: 5, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
666
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'dk3fj38jr0q', colId: 's557nidp0z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
667
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'dk3fj38jr0q', colId: '63fssosw5z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
668
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '0hp4pxkxs8eg', colId: 's557nidp0z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
669
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: '0hp4pxkxs8eg', colId: '63fssosw5z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
670
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'd7xc4ei18x', colId: 's557nidp0z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
671
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'd7xc4ei18x', colId: '63fssosw5z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
672
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'i5xpndw78t', colId: 's557nidp0z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
673
+ { attributes: { 'table-up-cell-inner': { tableId: 'sqhdx5zecxh', rowId: 'i5xpndw78t', colId: '63fssosw5z', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
674
+ { insert: '\n' },
675
+ ]),
676
+ );
677
+ });
678
+
679
+ it('setContents should auto merge empty col and empty row', async () => {
680
+ const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: true });
681
+ quill.setContents([
682
+ { insert: '\n' },
683
+ { insert: { 'table-up-col': { tableId: 'bgpbkkx7n8t', colId: 'zmikq4vcb7q', full: false, width: 100 } } },
684
+ { insert: { 'table-up-col': { tableId: 'bgpbkkx7n8t', colId: 'jgdjl8jtn', full: false, width: 100 } } },
685
+ { insert: { 'table-up-col': { tableId: 'bgpbkkx7n8t', colId: 'v51gsg6tcr', full: false, width: 100 } } },
686
+ { insert: { 'table-up-col': { tableId: 'bgpbkkx7n8t', colId: 'bthp5lq8z6f', full: false, width: 100 } } },
687
+ { insert: { 'table-up-col': { tableId: 'bgpbkkx7n8t', colId: 'w02ywy5elc', full: false, width: 100 } } },
688
+ { attributes: { 'table-up-cell-inner': { tableId: 'bgpbkkx7n8t', rowId: '6kt0grl6zwn', colId: 'zmikq4vcb7q', rowspan: 5, colspan: 5, emptyRow: ['cc88nvap3xj', 'aj0a8w2fzbh', 'q9v14h4sgx', '7kz0ke5l4eq'] } }, insert: '\n' },
689
+ { insert: '\n' },
690
+ ]);
691
+ await vi.runAllTimersAsync();
692
+
693
+ expectDelta(
694
+ quill.getContents(),
695
+ new Delta([
696
+ { insert: '\n' },
697
+ { insert: { 'table-up-col': { tableId: 'bgpbkkx7n8t', colId: 'zmikq4vcb7q', full: false, width: 500 } } },
698
+ { attributes: { 'table-up-cell-inner': { tableId: 'bgpbkkx7n8t', rowId: '6kt0grl6zwn', colId: 'zmikq4vcb7q', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
699
+ { insert: '\n' },
700
+ ]),
701
+ );
702
+ });
703
+
704
+ it('`emptyRow` should have same order with tr', async () => {
705
+ const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: false });
706
+ quill.setContents(createTableDeltaOps(5, 3, { full: false }, {}, { isEmpty: false }));
707
+ const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
708
+ const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
709
+ tableModule.mergeCells([tds[3], tds[4], tds[5], tds[6], tds[7], tds[8], tds[9], tds[10], tds[11]]);
710
+ await vi.runAllTimersAsync();
711
+
712
+ const tableBlot = quill.scroll.descendants(TableMainFormat, 0)[0];
713
+ const emptyRowIds = tds[3].emptyRow;
714
+ const rowIds = tableBlot.getRowIds();
715
+ const startRowIndex = rowIds.indexOf(tds[3].rowId);
716
+
717
+ expect(emptyRowIds.length).toEqual(2);
718
+ expect(tds[3].rowspan).toEqual(3);
719
+ expect(startRowIndex).toEqual(1);
720
+ for (let i = startRowIndex + 1; i < startRowIndex + emptyRowIds.length; i++) {
721
+ expect(rowIds[i]).toEqual(emptyRowIds[i - startRowIndex - 1]);
722
+ }
723
+ });
724
+ });