quill-table-up 2.4.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -40
- package/dist/index.css +1 -1
- package/dist/index.d.ts +172 -110
- package/dist/index.js +29 -28
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +29 -28
- package/dist/index.umd.js.map +1 -1
- package/dist/table-creator.css +1 -1
- package/package.json +1 -1
- package/src/__tests__/e2e/table-align.test.ts +1 -2
- package/src/__tests__/e2e/table-blots.test.ts +45 -35
- package/src/__tests__/e2e/table-clipboard.test.ts +20 -0
- package/src/__tests__/e2e/table-hack.test.ts +5 -5
- package/src/__tests__/e2e/table-keyboard-handler.test.ts +6 -6
- package/src/__tests__/e2e/table-menu.test.ts +23 -0
- package/src/__tests__/e2e/table-selection.test.ts +3 -3
- package/src/__tests__/unit/table-blots.test.ts +26 -26
- package/src/__tests__/unit/table-caption.test.ts +33 -36
- package/src/__tests__/unit/table-cell-merge.test.ts +114 -114
- package/src/__tests__/unit/table-clipboard.test.ts +383 -19
- package/src/__tests__/unit/table-hack.test.ts +202 -144
- package/src/__tests__/unit/table-insert.test.ts +79 -79
- package/src/__tests__/unit/table-redo-undo.test.ts +495 -64
- package/src/__tests__/unit/table-remove.test.ts +8 -11
- package/src/__tests__/unit/utils.test.ts +4 -4
- package/src/__tests__/unit/utils.ts +4 -3
- package/src/formats/container-format.ts +25 -2
- package/src/formats/index.ts +54 -8
- package/src/formats/overrides/block.ts +35 -30
- package/src/formats/table-body-format.ts +18 -58
- package/src/formats/table-cell-format.ts +296 -286
- package/src/formats/table-cell-inner-format.ts +384 -358
- package/src/formats/table-foot-format.ts +7 -0
- package/src/formats/table-head-format.ts +7 -0
- package/src/formats/table-main-format.ts +84 -5
- package/src/formats/table-row-format.ts +44 -14
- package/src/modules/index.ts +1 -0
- package/src/modules/table-align.ts +59 -53
- package/src/modules/table-clipboard.ts +60 -39
- package/src/modules/table-dom-selector.ts +33 -0
- package/src/modules/table-menu/constants.ts +21 -31
- package/src/modules/table-menu/table-menu-common.ts +72 -51
- package/src/modules/table-menu/table-menu-contextmenu.ts +22 -6
- package/src/modules/table-menu/table-menu-select.ts +75 -12
- package/src/modules/table-resize/table-resize-box.ts +148 -128
- package/src/modules/table-resize/table-resize-common.ts +37 -32
- package/src/modules/table-resize/table-resize-line.ts +53 -36
- package/src/modules/table-resize/table-resize-scale.ts +32 -27
- package/src/modules/table-scrollbar.ts +58 -32
- package/src/modules/table-selection.ts +102 -79
- package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/src/style/index.less +0 -1
- package/src/style/select-box.less +1 -0
- package/src/style/table-menu.less +4 -4
- package/src/style/table-resize.less +1 -0
- package/src/style/table-scrollbar.less +2 -2
- package/src/table-up.ts +161 -194
- package/src/utils/components/table/creator.ts +4 -1
- package/src/utils/components/tooltip.ts +6 -1
- package/src/utils/constants.ts +8 -2
- package/src/utils/index.ts +2 -1
- package/src/utils/scroll.ts +47 -0
- package/src/utils/style-helper.ts +47 -0
- package/src/utils/transformer.ts +0 -25
- package/src/utils/types.ts +15 -15
- package/src/utils/scroll-event-helper.ts +0 -22
|
@@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
3
3
|
import { TableCellInnerFormat } from '../../formats';
|
|
4
4
|
import { TableSelection } from '../../modules';
|
|
5
5
|
import { TableUp } from '../../table-up';
|
|
6
|
-
import { createQuillWithTableModule, createTable,
|
|
6
|
+
import { createQuillWithTableModule, createTable, createTableCaptionHTML, createTableDeltaOps, createTaleColHTML, expectDelta } from './utils';
|
|
7
7
|
|
|
8
8
|
const Delta = Quill.import('delta');
|
|
9
9
|
if (!Range.prototype.getBoundingClientRect) {
|
|
@@ -39,11 +39,11 @@ describe('hack html convert', () => {
|
|
|
39
39
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100, align: 'right' } } },
|
|
40
40
|
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100, align: 'right' } } },
|
|
41
41
|
{ insert: '1' },
|
|
42
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
42
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'th' } }, insert: '\n' },
|
|
43
43
|
{ insert: '2' },
|
|
44
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
44
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'th' } }, insert: '\n' },
|
|
45
45
|
{ insert: '3' },
|
|
46
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
46
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1, tag: 'th' } }, insert: '\n' },
|
|
47
47
|
{ insert: '4' },
|
|
48
48
|
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
49
49
|
{ insert: '5' },
|
|
@@ -69,12 +69,64 @@ describe('hack html convert', () => {
|
|
|
69
69
|
<table cellpadding="0" cellspacing="0" style="width: 300px; margin-left: auto;" data-align="right">
|
|
70
70
|
${createTableCaptionHTML({ text: 'Table Caption', side: 'bottom' }, { editable: null })}
|
|
71
71
|
${createTaleColHTML(3, { full: false, width: 100, align: 'right' })}
|
|
72
|
-
|
|
72
|
+
<tbody>
|
|
73
|
+
<tr data-row-id="1">
|
|
74
|
+
<th colspan="1" data-col-id="1" data-row-id="1" rowspan="1">
|
|
75
|
+
<div data-col-id="1" data-colspan="1" data-row-id="1" data-rowspan="1">
|
|
76
|
+
<p>1</p>
|
|
77
|
+
</div>
|
|
78
|
+
</th>
|
|
79
|
+
<th colspan="1" data-col-id="2" data-row-id="1" rowspan="1">
|
|
80
|
+
<div data-col-id="2" data-colspan="1" data-row-id="1" data-rowspan="1">
|
|
81
|
+
<p>2</p>
|
|
82
|
+
</div>
|
|
83
|
+
</th>
|
|
84
|
+
<th colspan="1" data-col-id="3" data-row-id="1" rowspan="1">
|
|
85
|
+
<div data-col-id="3" data-colspan="1" data-row-id="1" data-rowspan="1">
|
|
86
|
+
<p>3</p>
|
|
87
|
+
</div>
|
|
88
|
+
</th>
|
|
89
|
+
</tr>
|
|
90
|
+
<tr data-row-id="2">
|
|
91
|
+
<td colspan="1" data-col-id="1" data-row-id="2" rowspan="1">
|
|
92
|
+
<div data-col-id="1" data-colspan="1" data-row-id="2" data-rowspan="1">
|
|
93
|
+
<p>4</p>
|
|
94
|
+
</div>
|
|
95
|
+
</td>
|
|
96
|
+
<td colspan="1" data-col-id="2" data-row-id="2" rowspan="1">
|
|
97
|
+
<div data-col-id="2" data-colspan="1" data-row-id="2" data-rowspan="1">
|
|
98
|
+
<p>5</p>
|
|
99
|
+
</div>
|
|
100
|
+
</td>
|
|
101
|
+
<td colspan="1" data-col-id="3" data-row-id="2" rowspan="1">
|
|
102
|
+
<div data-col-id="3" data-colspan="1" data-row-id="2" data-rowspan="1">
|
|
103
|
+
<p>6</p>
|
|
104
|
+
</div>
|
|
105
|
+
</td>
|
|
106
|
+
</tr>
|
|
107
|
+
<tr data-row-id="3">
|
|
108
|
+
<td colspan="1" data-col-id="1" data-row-id="3" rowspan="1">
|
|
109
|
+
<div data-col-id="1" data-colspan="1" data-row-id="3" data-rowspan="1">
|
|
110
|
+
<p>7</p>
|
|
111
|
+
</div>
|
|
112
|
+
</td>
|
|
113
|
+
<td colspan="1" data-col-id="2" data-row-id="3" rowspan="1">
|
|
114
|
+
<div data-col-id="2" data-colspan="1" data-row-id="3" data-rowspan="1">
|
|
115
|
+
<p>8</p>
|
|
116
|
+
</div>
|
|
117
|
+
</td>
|
|
118
|
+
<td colspan="1" data-col-id="3" data-row-id="3" rowspan="1">
|
|
119
|
+
<div data-col-id="3" data-colspan="1" data-row-id="3" data-rowspan="1">
|
|
120
|
+
<p>9</p>
|
|
121
|
+
</div>
|
|
122
|
+
</td>
|
|
123
|
+
</tr>
|
|
124
|
+
</tbody>
|
|
73
125
|
</table>
|
|
74
126
|
</div>
|
|
75
127
|
<p></p>
|
|
76
128
|
`,
|
|
77
|
-
{ ignoreAttrs: ['class', 'data-table-id'] },
|
|
129
|
+
{ ignoreAttrs: ['data-wrap-tag', 'class', 'data-table-id', 'data-tag'] },
|
|
78
130
|
);
|
|
79
131
|
});
|
|
80
132
|
|
|
@@ -87,11 +139,11 @@ describe('hack html convert', () => {
|
|
|
87
139
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100, align: 'right' } } },
|
|
88
140
|
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100, align: 'right' } } },
|
|
89
141
|
{ insert: '1' },
|
|
90
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
142
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'th' } }, insert: '\n' },
|
|
91
143
|
{ insert: '2' },
|
|
92
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
144
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'th' } }, insert: '\n' },
|
|
93
145
|
{ insert: '3' },
|
|
94
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
146
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1, tag: 'th' } }, insert: '\n' },
|
|
95
147
|
{ insert: '4' },
|
|
96
148
|
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
97
149
|
{ insert: '5' },
|
|
@@ -122,16 +174,16 @@ describe('hack html convert', () => {
|
|
|
122
174
|
</colgroup>
|
|
123
175
|
<tbody>
|
|
124
176
|
<tr data-row-id="1">
|
|
125
|
-
<
|
|
177
|
+
<th colspan="1" data-col-id="1" data-row-id="1" rowspan="1">
|
|
126
178
|
<div data-col-id="1" data-colspan="1" data-row-id="1" data-rowspan="1">
|
|
127
179
|
<p>1</p>
|
|
128
180
|
</div>
|
|
129
|
-
</
|
|
130
|
-
<
|
|
181
|
+
</th>
|
|
182
|
+
<th colspan="1" data-col-id="2" data-row-id="1" rowspan="1">
|
|
131
183
|
<div data-col-id="2" data-colspan="1" data-row-id="1" data-rowspan="1">
|
|
132
184
|
<p>2</p>
|
|
133
185
|
</div>
|
|
134
|
-
</
|
|
186
|
+
</th>
|
|
135
187
|
</tr>
|
|
136
188
|
<tr data-row-id="2">
|
|
137
189
|
<td colspan="1" data-col-id="1" data-row-id="2" rowspan="1">
|
|
@@ -149,7 +201,7 @@ describe('hack html convert', () => {
|
|
|
149
201
|
</table>
|
|
150
202
|
</div>
|
|
151
203
|
`,
|
|
152
|
-
{ ignoreAttrs: ['data-tag', 'class', 'data-table-id'] },
|
|
204
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'data-table-id', 'data-tag'] },
|
|
153
205
|
);
|
|
154
206
|
});
|
|
155
207
|
});
|
|
@@ -194,25 +246,25 @@ describe('hack format cell', () => {
|
|
|
194
246
|
.insert('123456789'),
|
|
195
247
|
);
|
|
196
248
|
expectDelta(
|
|
249
|
+
quill.getContents(),
|
|
197
250
|
new Delta([
|
|
198
251
|
{ insert: '\n' },
|
|
199
252
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
200
253
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
201
254
|
{ insert: '123456789' },
|
|
202
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
255
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
203
256
|
{ insert: '12345' },
|
|
204
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
257
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
205
258
|
{ insert: '123456789' },
|
|
206
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
259
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
207
260
|
{ insert: '2' },
|
|
208
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
261
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
209
262
|
{ insert: '3' },
|
|
210
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
263
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
211
264
|
{ insert: '4' },
|
|
212
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
265
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
213
266
|
{ insert: '\n' },
|
|
214
267
|
]),
|
|
215
|
-
quill.getContents(),
|
|
216
268
|
);
|
|
217
269
|
|
|
218
270
|
quill.setSelection(7, 17, Quill.sources.SILENT);
|
|
@@ -227,18 +279,18 @@ describe('hack format cell', () => {
|
|
|
227
279
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
228
280
|
{ insert: '1234' },
|
|
229
281
|
{ attributes: { underline: true, bold: true }, insert: '56789' },
|
|
230
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
282
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
231
283
|
{ attributes: { underline: true, bold: true }, insert: '12345' },
|
|
232
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
284
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
233
285
|
{ attributes: { underline: true, bold: true }, insert: '12345' },
|
|
234
286
|
{ insert: '6789' },
|
|
235
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
287
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
236
288
|
{ insert: '2' },
|
|
237
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
289
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
238
290
|
{ insert: '3' },
|
|
239
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
291
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
240
292
|
{ insert: '4' },
|
|
241
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
293
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
242
294
|
{ insert: '\n' },
|
|
243
295
|
]),
|
|
244
296
|
);
|
|
@@ -262,22 +314,22 @@ describe('hack format cell', () => {
|
|
|
262
314
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
263
315
|
{ insert: '1234' },
|
|
264
316
|
{ attributes: { underline: true, bold: true }, insert: '56789' },
|
|
265
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
317
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
266
318
|
{ attributes: { underline: true, bold: true }, insert: '12345' },
|
|
267
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
319
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
268
320
|
{ attributes: { underline: true, bold: true }, insert: '12345' },
|
|
269
321
|
{ insert: '6789' },
|
|
270
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
322
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
271
323
|
{ insert: '2345' },
|
|
272
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
324
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
273
325
|
{ insert: '2345' },
|
|
274
|
-
{ attributes: { 'list': 'ordered', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
326
|
+
{ attributes: { 'list': 'ordered', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
275
327
|
{ insert: '2345' },
|
|
276
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
328
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
277
329
|
{ insert: '3' },
|
|
278
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
330
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
279
331
|
{ insert: '4' },
|
|
280
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
332
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
281
333
|
{ insert: '\n' },
|
|
282
334
|
]),
|
|
283
335
|
);
|
|
@@ -303,17 +355,17 @@ describe('hack format cell', () => {
|
|
|
303
355
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
304
356
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
305
357
|
{ insert: '123456789' },
|
|
306
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
358
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
307
359
|
{ insert: '12345' },
|
|
308
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
360
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
309
361
|
{ insert: '123456789' },
|
|
310
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
362
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
311
363
|
{ insert: '2' },
|
|
312
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
364
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
313
365
|
{ insert: '3' },
|
|
314
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
366
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
315
367
|
{ insert: '4' },
|
|
316
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
368
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
317
369
|
{ insert: '\n' },
|
|
318
370
|
]),
|
|
319
371
|
);
|
|
@@ -321,7 +373,7 @@ describe('hack format cell', () => {
|
|
|
321
373
|
});
|
|
322
374
|
|
|
323
375
|
it('selection not in cell and selectedTds not empty should format all text in cell', async () => {
|
|
324
|
-
const quill = createQuillWithTableModule('<p></p>', {
|
|
376
|
+
const quill = createQuillWithTableModule('<p></p>', { modules: [{ module: TableSelection }] });
|
|
325
377
|
quill.setContents(createTableDeltaOps(2, 2, { full: false }));
|
|
326
378
|
quill.updateContents(
|
|
327
379
|
new Delta()
|
|
@@ -338,10 +390,11 @@ describe('hack format cell', () => {
|
|
|
338
390
|
quill.focus();
|
|
339
391
|
const tableUp = quill.getModule(TableUp.moduleName) as TableUp;
|
|
340
392
|
const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
|
|
341
|
-
|
|
393
|
+
const tableSelection = tableUp.getModule<TableSelection>('table-selection');
|
|
394
|
+
tableSelection!.setSelectedTds([tds[0], tds[2]]);
|
|
342
395
|
quill.format('bold', true);
|
|
343
396
|
// simulate `getBoundingClientRect` will effect selectedTd computed position. need manual set
|
|
344
|
-
|
|
397
|
+
tableSelection!.setSelectedTds([tds[0], tds[2]]);
|
|
345
398
|
quill.format('list', 'bullet');
|
|
346
399
|
expectDelta(
|
|
347
400
|
quill.getContents(),
|
|
@@ -350,24 +403,24 @@ describe('hack format cell', () => {
|
|
|
350
403
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
351
404
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
352
405
|
{ insert: '123456789', attributes: { bold: true } },
|
|
353
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
406
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
354
407
|
{ insert: '12345', attributes: { bold: true } },
|
|
355
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
408
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
356
409
|
{ insert: '123456789', attributes: { bold: true } },
|
|
357
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
410
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
358
411
|
{ insert: '2' },
|
|
359
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
412
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
360
413
|
{ insert: '3', attributes: { bold: true } },
|
|
361
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
414
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
362
415
|
{ insert: '4' },
|
|
363
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
416
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
364
417
|
{ insert: '\n' },
|
|
365
418
|
]),
|
|
366
419
|
);
|
|
367
420
|
});
|
|
368
421
|
|
|
369
422
|
it('selection can get format tableCellInner. should format like origin', async () => {
|
|
370
|
-
const quill = createQuillWithTableModule('<p></p>', {
|
|
423
|
+
const quill = createQuillWithTableModule('<p></p>', { modules: [{ module: TableSelection }] });
|
|
371
424
|
quill.setContents([
|
|
372
425
|
{ insert: '12345\n' },
|
|
373
426
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
@@ -395,13 +448,13 @@ describe('hack format cell', () => {
|
|
|
395
448
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
396
449
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
397
450
|
{ insert: '1' },
|
|
398
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
451
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
399
452
|
{ insert: '2' },
|
|
400
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
453
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
401
454
|
{ insert: '3' },
|
|
402
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
455
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
403
456
|
{ attributes: { bold: true }, insert: '4' },
|
|
404
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
457
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
405
458
|
{ insert: '\n' },
|
|
406
459
|
]),
|
|
407
460
|
);
|
|
@@ -456,13 +509,13 @@ describe('hack toolbar clean handler', () => {
|
|
|
456
509
|
{ insert: '1', attributes: { bold: true } },
|
|
457
510
|
{ insert: '234' },
|
|
458
511
|
{ insert: '5', attributes: { bold: true } },
|
|
459
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
512
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
460
513
|
{ insert: '22345', attributes: { bold: true } },
|
|
461
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
514
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
462
515
|
{ insert: '3' },
|
|
463
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
516
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
464
517
|
{ insert: '4' },
|
|
465
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
518
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
466
519
|
{ insert: '\n' },
|
|
467
520
|
]),
|
|
468
521
|
);
|
|
@@ -497,15 +550,15 @@ describe('hack toolbar clean handler', () => {
|
|
|
497
550
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
498
551
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
499
552
|
{ insert: '12345', attributes: { bold: true } },
|
|
500
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
553
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
501
554
|
{ insert: '12345', attributes: { bold: true } },
|
|
502
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
555
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
503
556
|
{ insert: '22345', attributes: { bold: true } },
|
|
504
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
557
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
505
558
|
{ insert: '3' },
|
|
506
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
559
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
507
560
|
{ insert: '4' },
|
|
508
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
561
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
509
562
|
{ insert: '\n' },
|
|
510
563
|
]),
|
|
511
564
|
);
|
|
@@ -513,7 +566,7 @@ describe('hack toolbar clean handler', () => {
|
|
|
513
566
|
});
|
|
514
567
|
|
|
515
568
|
it('clean handler should clean all format in selectedTds', async () => {
|
|
516
|
-
const quill = createQuillWithTableModule('<p></p>', {
|
|
569
|
+
const quill = createQuillWithTableModule('<p></p>', { modules: [{ module: TableSelection }] });
|
|
517
570
|
quill.setContents([
|
|
518
571
|
{ insert: '\n' },
|
|
519
572
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
@@ -531,9 +584,10 @@ describe('hack toolbar clean handler', () => {
|
|
|
531
584
|
{ insert: '\n' },
|
|
532
585
|
]);
|
|
533
586
|
const tableUp = quill.getModule(TableUp.moduleName) as TableUp;
|
|
534
|
-
tableUp.tableSelection!.table = quill.root.querySelector('table')!;
|
|
535
587
|
const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
|
|
536
|
-
|
|
588
|
+
const tableSelection = tableUp.getModule<TableSelection>('table-selection');
|
|
589
|
+
tableSelection!.table = quill.root.querySelector('table')!;
|
|
590
|
+
tableSelection!.setSelectedTds(tds);
|
|
537
591
|
|
|
538
592
|
quill.theme.modules.toolbar!.handlers!.clean.call(quill.theme.modules.toolbar as any, true);
|
|
539
593
|
expectDelta(
|
|
@@ -543,15 +597,15 @@ describe('hack toolbar clean handler', () => {
|
|
|
543
597
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
544
598
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
545
599
|
{ insert: '12345' },
|
|
546
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
600
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
547
601
|
{ insert: '12345' },
|
|
548
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
602
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
549
603
|
{ insert: '22345' },
|
|
550
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
604
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
551
605
|
{ insert: '3' },
|
|
552
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
606
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
553
607
|
{ insert: '4' },
|
|
554
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
608
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
555
609
|
{ insert: '\n' },
|
|
556
610
|
]),
|
|
557
611
|
);
|
|
@@ -559,7 +613,7 @@ describe('hack toolbar clean handler', () => {
|
|
|
559
613
|
});
|
|
560
614
|
|
|
561
615
|
it('selection not in cell but have selectedTds. should clean all text in selected cell', async () => {
|
|
562
|
-
const quill = createQuillWithTableModule('<p></p>', {
|
|
616
|
+
const quill = createQuillWithTableModule('<p></p>', { modules: [{ module: TableSelection }] });
|
|
563
617
|
quill.setContents([
|
|
564
618
|
{ insert: '12345', attributes: { bold: true } },
|
|
565
619
|
{ insert: '\n' },
|
|
@@ -577,8 +631,9 @@ describe('hack toolbar clean handler', () => {
|
|
|
577
631
|
]);
|
|
578
632
|
const tableUp = quill.getModule(TableUp.moduleName) as TableUp;
|
|
579
633
|
const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
|
|
580
|
-
|
|
581
|
-
|
|
634
|
+
const tableSelection = tableUp.getModule<TableSelection>('table-selection');
|
|
635
|
+
tableSelection!.table = quill.root.querySelector('table')!;
|
|
636
|
+
tableSelection!.setSelectedTds(tds);
|
|
582
637
|
quill.setSelection(1, 3, Quill.sources.SILENT);
|
|
583
638
|
|
|
584
639
|
quill.theme.modules.toolbar!.handlers!.clean.call(quill.theme.modules.toolbar as any, true);
|
|
@@ -590,13 +645,13 @@ describe('hack toolbar clean handler', () => {
|
|
|
590
645
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
591
646
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
592
647
|
{ insert: '1' },
|
|
593
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
648
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
594
649
|
{ insert: '2' },
|
|
595
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
650
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
596
651
|
{ insert: '3' },
|
|
597
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
652
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
598
653
|
{ insert: '4' },
|
|
599
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
654
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
600
655
|
{ insert: '\n' },
|
|
601
656
|
]),
|
|
602
657
|
);
|
|
@@ -632,16 +687,16 @@ describe('hack toolbar clean handler', () => {
|
|
|
632
687
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
633
688
|
{ insert: '1', attributes: { bold: true } },
|
|
634
689
|
{ insert: '23' },
|
|
635
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
690
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
636
691
|
{ insert: '12' },
|
|
637
692
|
{ insert: '3', attributes: { bold: true } },
|
|
638
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
693
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
639
694
|
{ insert: '2' },
|
|
640
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
695
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
641
696
|
{ insert: '3', attributes: { bold: true } },
|
|
642
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
697
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
643
698
|
{ insert: '4' },
|
|
644
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
699
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
645
700
|
{ insert: '\n' },
|
|
646
701
|
]),
|
|
647
702
|
);
|
|
@@ -649,7 +704,7 @@ describe('hack toolbar clean handler', () => {
|
|
|
649
704
|
});
|
|
650
705
|
|
|
651
706
|
it('clean handler should clean embed correct', async () => {
|
|
652
|
-
const quill = createQuillWithTableModule('<p></p>', {
|
|
707
|
+
const quill = createQuillWithTableModule('<p></p>', { modules: [{ module: TableSelection }] });
|
|
653
708
|
quill.setContents([
|
|
654
709
|
{ insert: '\n' },
|
|
655
710
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
@@ -671,10 +726,10 @@ describe('hack toolbar clean handler', () => {
|
|
|
671
726
|
{ insert: '\n' },
|
|
672
727
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
673
728
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
674
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
675
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
676
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
677
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
729
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
730
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
731
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
732
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
678
733
|
{ insert: '\n' },
|
|
679
734
|
]),
|
|
680
735
|
);
|
|
@@ -684,8 +739,9 @@ describe('hack toolbar clean handler', () => {
|
|
|
684
739
|
await vi.runAllTimersAsync();
|
|
685
740
|
const tableUp = quill.getModule(TableUp.moduleName) as TableUp;
|
|
686
741
|
const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
|
|
687
|
-
|
|
688
|
-
|
|
742
|
+
const tableSelection = tableUp.getModule<TableSelection>('table-selection');
|
|
743
|
+
tableSelection!.table = quill.root.querySelector('table')!;
|
|
744
|
+
tableSelection!.setSelectedTds([tds[1]]);
|
|
689
745
|
quill.theme.modules.toolbar!.handlers!.clean.call(quill.theme.modules.toolbar as any, true);
|
|
690
746
|
expectDelta(
|
|
691
747
|
quill.getContents(),
|
|
@@ -693,17 +749,17 @@ describe('hack toolbar clean handler', () => {
|
|
|
693
749
|
{ insert: '\n' },
|
|
694
750
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
695
751
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
696
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
697
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
698
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
699
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
752
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
753
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
754
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
755
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
700
756
|
{ insert: '\n' },
|
|
701
757
|
]),
|
|
702
758
|
);
|
|
703
759
|
});
|
|
704
760
|
|
|
705
761
|
it('clean handler trigger source should be USER', async () => {
|
|
706
|
-
const quill = createQuillWithTableModule('<p></p>', {
|
|
762
|
+
const quill = createQuillWithTableModule('<p></p>', { modules: [{ module: TableSelection }] });
|
|
707
763
|
quill.setContents([
|
|
708
764
|
{ insert: '\n' },
|
|
709
765
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
@@ -724,21 +780,21 @@ describe('hack toolbar clean handler', () => {
|
|
|
724
780
|
});
|
|
725
781
|
|
|
726
782
|
it('clean handler should not clean cell style when selection in cell', async () => {
|
|
727
|
-
const quill = createQuillWithTableModule('<p></p>', {
|
|
783
|
+
const quill = createQuillWithTableModule('<p></p>', { modules: [{ module: TableSelection }] });
|
|
728
784
|
quill.setContents([
|
|
729
785
|
{ insert: '\n' },
|
|
730
|
-
{ insert: { 'table-up-col': { tableId: '
|
|
731
|
-
{ insert: { 'table-up-col': { tableId: '
|
|
786
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 121 } } },
|
|
787
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 121 } } },
|
|
732
788
|
{ attributes: { background: '#e60000' }, insert: '1' },
|
|
733
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '
|
|
789
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, style: 'background-color: rgb(41, 114, 244);' } }, insert: '\n' },
|
|
734
790
|
{ insert: '2' },
|
|
735
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '
|
|
791
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
736
792
|
{ insert: '3' },
|
|
737
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '
|
|
793
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
738
794
|
{ attributes: { italic: true, bold: true }, insert: '5555' },
|
|
739
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '
|
|
795
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, style: 'background-color: rgb(49, 155, 98);' } }, insert: '\n' },
|
|
740
796
|
{ attributes: { italic: true, bold: true }, insert: '6666' },
|
|
741
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '
|
|
797
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, style: 'background-color: rgb(49, 155, 98);' } }, insert: '\n' },
|
|
742
798
|
{ insert: '\n' },
|
|
743
799
|
]);
|
|
744
800
|
|
|
@@ -746,25 +802,25 @@ describe('hack toolbar clean handler', () => {
|
|
|
746
802
|
quill.theme.modules.toolbar!.handlers!.clean.call(quill.theme.modules.toolbar as any, true);
|
|
747
803
|
|
|
748
804
|
expectDelta(
|
|
805
|
+
quill.getContents(),
|
|
749
806
|
new Delta([
|
|
750
807
|
{ insert: '\n' },
|
|
751
|
-
{ insert: { 'table-up-col': { full: false, width: 121 } } },
|
|
752
|
-
{ insert: { 'table-up-col': { full: false, width: 121 } } },
|
|
808
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 121 } } },
|
|
809
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 121 } } },
|
|
753
810
|
{ attributes: { background: '#e60000' }, insert: '1' },
|
|
754
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1, style: 'background-color: rgb(41, 114, 244);' } }, insert: '\n' },
|
|
811
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', colId: '1', rowId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'background-color: rgb(41, 114, 244);' } }, insert: '\n' },
|
|
755
812
|
{ insert: '2' },
|
|
756
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
813
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', colId: '2', rowId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
757
814
|
{ insert: '3' },
|
|
758
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
815
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', colId: '1', rowId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
759
816
|
{ attributes: { italic: true, bold: true }, insert: '55' },
|
|
760
817
|
{ insert: '55' },
|
|
761
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1, style: 'background-color: rgb(49, 155, 98);' } }, insert: '\n' },
|
|
818
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', colId: '2', rowId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'background-color: rgb(49, 155, 98);' } }, insert: '\n' },
|
|
762
819
|
{ insert: '66' },
|
|
763
820
|
{ attributes: { italic: true, bold: true }, insert: '66' },
|
|
764
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1, style: 'background-color: rgb(49, 155, 98);' } }, insert: '\n' },
|
|
821
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', colId: '2', rowId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'background-color: rgb(49, 155, 98);' } }, insert: '\n' },
|
|
765
822
|
{ insert: '\n' },
|
|
766
823
|
]),
|
|
767
|
-
quill.getContents(),
|
|
768
824
|
);
|
|
769
825
|
expect(quill.root).toEqualHTML(
|
|
770
826
|
`
|
|
@@ -802,53 +858,54 @@ describe('hack toolbar clean handler', () => {
|
|
|
802
858
|
</div>
|
|
803
859
|
<p><br></p>
|
|
804
860
|
`,
|
|
805
|
-
{ ignoreAttrs: ['data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
861
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
806
862
|
);
|
|
807
863
|
});
|
|
808
864
|
|
|
809
865
|
it('clean handler should clean cell style when have selectedTds cleaning', async () => {
|
|
810
|
-
const quill = createQuillWithTableModule('<p></p>', {
|
|
866
|
+
const quill = createQuillWithTableModule('<p></p>', { modules: [{ module: TableSelection }] });
|
|
811
867
|
quill.setContents([
|
|
812
868
|
{ insert: '\n' },
|
|
813
|
-
{ insert: { 'table-up-col': { tableId: '
|
|
814
|
-
{ insert: { 'table-up-col': { tableId: '
|
|
869
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 121 } } },
|
|
870
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 121 } } },
|
|
815
871
|
{ attributes: { background: '#e60000' }, insert: '1' },
|
|
816
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '
|
|
872
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, style: 'background-color: rgb(41, 114, 244);' } }, insert: '\n' },
|
|
817
873
|
{ insert: '2' },
|
|
818
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '
|
|
874
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
819
875
|
{ insert: '3' },
|
|
820
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '
|
|
876
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
821
877
|
{ attributes: { italic: true, bold: true }, insert: '5555' },
|
|
822
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '
|
|
878
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, style: 'background-color: rgb(49, 155, 98);' } }, insert: '\n' },
|
|
823
879
|
{ attributes: { italic: true, bold: true }, insert: '6666' },
|
|
824
|
-
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '
|
|
880
|
+
{ attributes: { 'list': 'bullet', 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, style: 'background-color: rgb(49, 155, 98);' } }, insert: '\n' },
|
|
825
881
|
{ insert: '\n' },
|
|
826
882
|
]);
|
|
827
883
|
|
|
828
884
|
const tableUp = quill.getModule(TableUp.moduleName) as TableUp;
|
|
829
885
|
const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
|
|
830
|
-
|
|
831
|
-
|
|
886
|
+
const tableSelection = tableUp.getModule<TableSelection>('table-selection');
|
|
887
|
+
tableSelection!.table = quill.root.querySelector('table')!;
|
|
888
|
+
tableSelection!.setSelectedTds(tds);
|
|
832
889
|
quill.theme.modules.toolbar!.handlers!.clean.call(quill.theme.modules.toolbar as any, true);
|
|
833
890
|
|
|
834
891
|
expectDelta(
|
|
892
|
+
quill.getContents(),
|
|
835
893
|
new Delta([
|
|
836
894
|
{ insert: '\n' },
|
|
837
|
-
{ insert: { 'table-up-col': { full: false, width: 121 } } },
|
|
838
|
-
{ insert: { 'table-up-col': { full: false, width: 121 } } },
|
|
895
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 121 } } },
|
|
896
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 121 } } },
|
|
839
897
|
{ insert: '1' },
|
|
840
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
898
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
841
899
|
{ insert: '2' },
|
|
842
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
900
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
843
901
|
{ insert: '3' },
|
|
844
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
902
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
845
903
|
{ insert: '5555' },
|
|
846
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
904
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
847
905
|
{ insert: '6666' },
|
|
848
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
906
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
849
907
|
{ insert: '\n' },
|
|
850
908
|
]),
|
|
851
|
-
quill.getContents(),
|
|
852
909
|
);
|
|
853
910
|
expect(quill.root).toEqualHTML(
|
|
854
911
|
`
|
|
@@ -886,12 +943,12 @@ describe('hack toolbar clean handler', () => {
|
|
|
886
943
|
</div>
|
|
887
944
|
<p><br></p>
|
|
888
945
|
`,
|
|
889
|
-
{ ignoreAttrs: ['data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
946
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
890
947
|
);
|
|
891
948
|
});
|
|
892
949
|
|
|
893
950
|
it('clean handler should clean cell selectedTds style', async () => {
|
|
894
|
-
const quill = createQuillWithTableModule('<p></p>', {
|
|
951
|
+
const quill = createQuillWithTableModule('<p></p>', { modules: [{ module: TableSelection }] });
|
|
895
952
|
quill.setContents([
|
|
896
953
|
{ insert: '\n' },
|
|
897
954
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
@@ -920,8 +977,9 @@ describe('hack toolbar clean handler', () => {
|
|
|
920
977
|
|
|
921
978
|
const tableUp = quill.getModule(TableUp.moduleName) as TableUp;
|
|
922
979
|
const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
|
|
923
|
-
|
|
924
|
-
|
|
980
|
+
const tableSelection = tableUp.getModule<TableSelection>('table-selection');
|
|
981
|
+
tableSelection!.table = quill.root.querySelector('table')!;
|
|
982
|
+
tableSelection!.setSelectedTds([tds[4]]);
|
|
925
983
|
quill.theme.modules.toolbar!.handlers!.clean.call(quill.theme.modules.toolbar as any, true);
|
|
926
984
|
|
|
927
985
|
expectDelta(
|
|
@@ -932,23 +990,23 @@ describe('hack toolbar clean handler', () => {
|
|
|
932
990
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
933
991
|
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
|
|
934
992
|
{ insert: '1' },
|
|
935
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td' } }, insert: '\n' },
|
|
993
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
936
994
|
{ insert: '2' },
|
|
937
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td' } }, insert: '\n' },
|
|
995
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
938
996
|
{ insert: '3' },
|
|
939
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td' } }, insert: '\n' },
|
|
997
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
940
998
|
{ insert: '4' },
|
|
941
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td' } }, insert: '\n' },
|
|
999
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
942
1000
|
{ insert: '5' },
|
|
943
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
1001
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
944
1002
|
{ insert: '6' },
|
|
945
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td' } }, insert: '\n' },
|
|
1003
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
946
1004
|
{ insert: '7' },
|
|
947
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td' } }, insert: '\n' },
|
|
1005
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
948
1006
|
{ insert: '8' },
|
|
949
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td' } }, insert: '\n' },
|
|
1007
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
950
1008
|
{ insert: '9' },
|
|
951
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td' } }, insert: '\n' },
|
|
1009
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1, style: 'background-color: rgb(201, 16, 16);', tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
952
1010
|
{ insert: '\n' },
|
|
953
1011
|
]),
|
|
954
1012
|
);
|