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
|
@@ -87,7 +87,7 @@ describe('clipboard cell structure', () => {
|
|
|
87
87
|
</div>
|
|
88
88
|
<p><br></p>
|
|
89
89
|
`,
|
|
90
|
-
{ ignoreAttrs: ['data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
90
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
91
91
|
);
|
|
92
92
|
});
|
|
93
93
|
|
|
@@ -177,7 +177,7 @@ describe('clipboard cell structure', () => {
|
|
|
177
177
|
</div>
|
|
178
178
|
<p><br></p>
|
|
179
179
|
`,
|
|
180
|
-
{ ignoreAttrs: ['data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
180
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
181
181
|
);
|
|
182
182
|
});
|
|
183
183
|
|
|
@@ -240,7 +240,7 @@ describe('clipboard cell structure', () => {
|
|
|
240
240
|
</div>
|
|
241
241
|
<p><br></p>
|
|
242
242
|
`,
|
|
243
|
-
{ ignoreAttrs: ['data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
243
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
244
244
|
);
|
|
245
245
|
});
|
|
246
246
|
|
|
@@ -294,7 +294,7 @@ describe('clipboard cell structure', () => {
|
|
|
294
294
|
</div>
|
|
295
295
|
<p><br></p>
|
|
296
296
|
`,
|
|
297
|
-
{ ignoreAttrs: ['data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
297
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
298
298
|
);
|
|
299
299
|
});
|
|
300
300
|
|
|
@@ -373,7 +373,7 @@ describe('clipboard cell structure', () => {
|
|
|
373
373
|
</div>
|
|
374
374
|
<p><br></p>
|
|
375
375
|
`,
|
|
376
|
-
{ ignoreAttrs: ['data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
376
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
377
377
|
);
|
|
378
378
|
});
|
|
379
379
|
|
|
@@ -448,7 +448,7 @@ describe('clipboard cell structure', () => {
|
|
|
448
448
|
</div>
|
|
449
449
|
<p><br></p>
|
|
450
450
|
`,
|
|
451
|
-
{ ignoreAttrs: ['data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
451
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
452
452
|
);
|
|
453
453
|
});
|
|
454
454
|
|
|
@@ -524,7 +524,7 @@ describe('clipboard cell structure', () => {
|
|
|
524
524
|
</div>
|
|
525
525
|
<p><br></p>
|
|
526
526
|
`,
|
|
527
|
-
{ ignoreAttrs: ['data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
527
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
528
528
|
);
|
|
529
529
|
});
|
|
530
530
|
|
|
@@ -573,7 +573,7 @@ describe('clipboard cell structure', () => {
|
|
|
573
573
|
</div>
|
|
574
574
|
<p><br></p>
|
|
575
575
|
`,
|
|
576
|
-
{ ignoreAttrs: ['data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
576
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
577
577
|
);
|
|
578
578
|
});
|
|
579
579
|
|
|
@@ -649,7 +649,7 @@ describe('clipboard cell structure', () => {
|
|
|
649
649
|
</div>
|
|
650
650
|
<p><br></p>
|
|
651
651
|
`,
|
|
652
|
-
{ ignoreAttrs: ['class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
652
|
+
{ ignoreAttrs: ['data-wrap-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
653
653
|
);
|
|
654
654
|
});
|
|
655
655
|
|
|
@@ -687,7 +687,7 @@ describe('clipboard cell structure', () => {
|
|
|
687
687
|
</div>
|
|
688
688
|
<p><br></p>
|
|
689
689
|
`,
|
|
690
|
-
{ ignoreAttrs: ['data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
690
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
691
691
|
);
|
|
692
692
|
expectDelta(
|
|
693
693
|
new Delta([
|
|
@@ -738,7 +738,88 @@ describe('clipboard cell structure', () => {
|
|
|
738
738
|
</div>
|
|
739
739
|
<p><br></p>
|
|
740
740
|
`,
|
|
741
|
-
{ ignoreAttrs: ['data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
741
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
742
|
+
);
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
it('convert background on table/tbody/tr/td', async () => {
|
|
746
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
747
|
+
quill.setContents(
|
|
748
|
+
quill.clipboard.convert({
|
|
749
|
+
html: `
|
|
750
|
+
<table style="background-color: red">
|
|
751
|
+
<tbody>
|
|
752
|
+
<tr style="background-color: yellow">
|
|
753
|
+
<td style="background-color: aqua">1</td>
|
|
754
|
+
<td>2</td>
|
|
755
|
+
</tr>
|
|
756
|
+
<tr>
|
|
757
|
+
<td>3</td>
|
|
758
|
+
<td>4</td>
|
|
759
|
+
</tr>
|
|
760
|
+
</tbody><tfoot style="background-color: blue">
|
|
761
|
+
<tr>
|
|
762
|
+
<td>5</td>
|
|
763
|
+
<td>6</td>
|
|
764
|
+
</tr>
|
|
765
|
+
</tfoot>
|
|
766
|
+
</table>
|
|
767
|
+
`,
|
|
768
|
+
}),
|
|
769
|
+
);
|
|
770
|
+
await vi.runAllTimersAsync();
|
|
771
|
+
|
|
772
|
+
expect(quill.root).toEqualHTML(
|
|
773
|
+
`
|
|
774
|
+
<p><br></p>
|
|
775
|
+
<div>
|
|
776
|
+
<table cellpadding="0" cellspacing="0" style="margin-right: auto; width: 200px;">
|
|
777
|
+
${createTaleColHTML(2, { full: false, width: 100 })}
|
|
778
|
+
<tbody>
|
|
779
|
+
<tr>
|
|
780
|
+
<td colspan="1" rowspan="1" style="background-color: aqua;">
|
|
781
|
+
<div data-style="background-color: aqua;">
|
|
782
|
+
<p><span style="background-color: aqua;">1</span></p>
|
|
783
|
+
</div>
|
|
784
|
+
</td>
|
|
785
|
+
<td colspan="1" rowspan="1" style="background-color: yellow;">
|
|
786
|
+
<div data-style="background-color: yellow;">
|
|
787
|
+
<p><span style="background-color: yellow;">2</span></p>
|
|
788
|
+
</div>
|
|
789
|
+
</td>
|
|
790
|
+
</tr>
|
|
791
|
+
<tr>
|
|
792
|
+
<td colspan="1" rowspan="1" style="background-color: red;">
|
|
793
|
+
<div data-style="background-color: red;">
|
|
794
|
+
<p><span style="background-color: red;">3</span></p>
|
|
795
|
+
</div>
|
|
796
|
+
</td>
|
|
797
|
+
<td colspan="1" rowspan="1" style="background-color: red;">
|
|
798
|
+
<div data-style="background-color: red;">
|
|
799
|
+
<p><span style="background-color: red;">4</span></p>
|
|
800
|
+
</div>
|
|
801
|
+
</td>
|
|
802
|
+
</tr>
|
|
803
|
+
</tbody>
|
|
804
|
+
<tfoot>
|
|
805
|
+
<tr>
|
|
806
|
+
<td colspan="1" rowspan="1" style="background-color: blue;">
|
|
807
|
+
<div data-style="background-color: blue;">
|
|
808
|
+
<p><span style="background-color: blue;">5</span></p>
|
|
809
|
+
</div>
|
|
810
|
+
</td>
|
|
811
|
+
<td colspan="1" rowspan="1" style="background-color: blue;">
|
|
812
|
+
<div data-style="background-color: blue;">
|
|
813
|
+
<p><span style="background-color: blue;">6</span></p>
|
|
814
|
+
</div>
|
|
815
|
+
</td>
|
|
816
|
+
</tr>
|
|
817
|
+
</tfoot>
|
|
818
|
+
</table>
|
|
819
|
+
</div>
|
|
820
|
+
<p><br></p>
|
|
821
|
+
`,
|
|
822
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
742
823
|
);
|
|
743
824
|
});
|
|
744
825
|
|
|
@@ -773,11 +854,11 @@ describe('clipboard cell structure', () => {
|
|
|
773
854
|
{ insert: { 'table-up-col': { full: false, width: 100 } } },
|
|
774
855
|
{ insert: { 'table-up-col': { full: false, width: 100 } } },
|
|
775
856
|
{ insert: '1' },
|
|
776
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
857
|
+
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
777
858
|
{ insert: '2' },
|
|
778
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
859
|
+
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
779
860
|
{ insert: '3' },
|
|
780
|
-
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
861
|
+
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
781
862
|
{ insert: '\n' },
|
|
782
863
|
]),
|
|
783
864
|
quill.getContents(),
|
|
@@ -854,7 +935,7 @@ describe('clipboard cell structure', () => {
|
|
|
854
935
|
</div>
|
|
855
936
|
<p><br></p>
|
|
856
937
|
`,
|
|
857
|
-
{ ignoreAttrs: ['data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'data-style', 'style', 'contenteditable'] },
|
|
938
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'data-style', 'style', 'contenteditable'] },
|
|
858
939
|
);
|
|
859
940
|
expectDelta(
|
|
860
941
|
new Delta([
|
|
@@ -875,6 +956,89 @@ describe('clipboard cell structure', () => {
|
|
|
875
956
|
);
|
|
876
957
|
});
|
|
877
958
|
|
|
959
|
+
it('clipboard convert empty tr to `emptyRow`', async () => {
|
|
960
|
+
const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: false });
|
|
961
|
+
quill.setContents(
|
|
962
|
+
quill.clipboard.convert({
|
|
963
|
+
html: `<table><thead><tr><td rowspan="2" colspan="2">1</td></tr><tr></tr></thead><tbody><tr><td>1</td><td>2</td></tr><tr><td>1</td><td>2</td></tr></tbody></table>`,
|
|
964
|
+
}),
|
|
965
|
+
);
|
|
966
|
+
|
|
967
|
+
await vi.runAllTimersAsync();
|
|
968
|
+
|
|
969
|
+
expect(quill.root).toEqualHTML(
|
|
970
|
+
`
|
|
971
|
+
<p><br></p>
|
|
972
|
+
<div>
|
|
973
|
+
<table cellpadding="0" cellspacing="0">
|
|
974
|
+
${createTaleColHTML(2, { full: false, width: 100 })}
|
|
975
|
+
<thead>
|
|
976
|
+
<tr>
|
|
977
|
+
<td rowspan="2" colspan="2" data-empty-row="length:1">
|
|
978
|
+
<div data-empty-row="length:1"><p>1</p></div>
|
|
979
|
+
</td>
|
|
980
|
+
</tr>
|
|
981
|
+
<tr>
|
|
982
|
+
</tr>
|
|
983
|
+
</thead>
|
|
984
|
+
<tbody>
|
|
985
|
+
<tr>
|
|
986
|
+
<td rowspan="1" colspan="1">
|
|
987
|
+
<div><p>1</p></div>
|
|
988
|
+
</td>
|
|
989
|
+
<td rowspan="1" colspan="1">
|
|
990
|
+
<div><p>2</p></div>
|
|
991
|
+
</td>
|
|
992
|
+
</tr>
|
|
993
|
+
<tr>
|
|
994
|
+
<td rowspan="1" colspan="1">
|
|
995
|
+
<div><p>1</p></div>
|
|
996
|
+
</td>
|
|
997
|
+
<td rowspan="1" colspan="1">
|
|
998
|
+
<div><p>2</p></div>
|
|
999
|
+
</td>
|
|
1000
|
+
</tr>
|
|
1001
|
+
</tbody>
|
|
1002
|
+
</table>
|
|
1003
|
+
</div>
|
|
1004
|
+
<p><br></p>
|
|
1005
|
+
`,
|
|
1006
|
+
{
|
|
1007
|
+
ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'data-style', 'style', 'contenteditable'],
|
|
1008
|
+
replaceAttrs: {
|
|
1009
|
+
'data-empty-row': function (value: string) {
|
|
1010
|
+
try {
|
|
1011
|
+
const emptyRow = JSON.parse(value);
|
|
1012
|
+
return `length:${emptyRow.length}`;
|
|
1013
|
+
}
|
|
1014
|
+
catch {
|
|
1015
|
+
return value;
|
|
1016
|
+
}
|
|
1017
|
+
},
|
|
1018
|
+
},
|
|
1019
|
+
},
|
|
1020
|
+
);
|
|
1021
|
+
expectDelta(
|
|
1022
|
+
new Delta([
|
|
1023
|
+
{ insert: '\n' },
|
|
1024
|
+
{ insert: { 'table-up-col': { full: false, width: 100 } } },
|
|
1025
|
+
{ insert: { 'table-up-col': { full: false, width: 100 } } },
|
|
1026
|
+
{ insert: '1' },
|
|
1027
|
+
{ attributes: { 'table-up-cell-inner': { rowspan: 2, colspan: 2, wrapTag: 'thead' } }, insert: '\n' },
|
|
1028
|
+
{ insert: '1' },
|
|
1029
|
+
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1, wrapTag: 'tbody' } }, insert: '\n' },
|
|
1030
|
+
{ insert: '2' },
|
|
1031
|
+
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1, wrapTag: 'tbody' } }, insert: '\n' },
|
|
1032
|
+
{ insert: '1' },
|
|
1033
|
+
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1, wrapTag: 'tbody' } }, insert: '\n' },
|
|
1034
|
+
{ insert: '2' },
|
|
1035
|
+
{ attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1, wrapTag: 'tbody' } }, insert: '\n' },
|
|
1036
|
+
{ insert: '\n' },
|
|
1037
|
+
]),
|
|
1038
|
+
quill.getContents(),
|
|
1039
|
+
);
|
|
1040
|
+
});
|
|
1041
|
+
|
|
878
1042
|
it('clipboard convert col with span attribute', async () => {
|
|
879
1043
|
const quill = createQuillWithTableModule(`<p><br></p>`, { autoMergeCell: false });
|
|
880
1044
|
quill.setContents(
|
|
@@ -946,7 +1110,7 @@ describe('clipboard cell structure', () => {
|
|
|
946
1110
|
<p><br></p>
|
|
947
1111
|
`,
|
|
948
1112
|
{
|
|
949
|
-
ignoreAttrs: ['data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'data-style', 'style', 'contenteditable'],
|
|
1113
|
+
ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'data-style', 'style', 'contenteditable'],
|
|
950
1114
|
replaceAttrs: {
|
|
951
1115
|
'data-empty-row': function (value: string) {
|
|
952
1116
|
try {
|
|
@@ -1073,6 +1237,206 @@ describe('clipboard cell structure', () => {
|
|
|
1073
1237
|
</div>
|
|
1074
1238
|
<p><br></p>
|
|
1075
1239
|
`,
|
|
1240
|
+
{ ignoreAttrs: ['data-wrap-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
1241
|
+
);
|
|
1242
|
+
});
|
|
1243
|
+
|
|
1244
|
+
it('convert thead and tfoot correctly', async () => {
|
|
1245
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
1246
|
+
quill.setContents(
|
|
1247
|
+
quill.clipboard.convert({
|
|
1248
|
+
html: `
|
|
1249
|
+
<table>
|
|
1250
|
+
<thead>
|
|
1251
|
+
<tr>
|
|
1252
|
+
<th>head1</th>
|
|
1253
|
+
<th>head2</th>
|
|
1254
|
+
<th>head3</th>
|
|
1255
|
+
</tr>
|
|
1256
|
+
</thead><tbody>
|
|
1257
|
+
<tr>
|
|
1258
|
+
<td>body1</td>
|
|
1259
|
+
<td>body2</td>
|
|
1260
|
+
<td>body3</td>
|
|
1261
|
+
</tr>
|
|
1262
|
+
<tr>
|
|
1263
|
+
<td>body4</td>
|
|
1264
|
+
<td>body5</td>
|
|
1265
|
+
<td>body6</td>
|
|
1266
|
+
</tr>
|
|
1267
|
+
</tbody><tfoot>
|
|
1268
|
+
<tr>
|
|
1269
|
+
<td>foot1</td>
|
|
1270
|
+
<td>foot2</td>
|
|
1271
|
+
<td>foot3</td>
|
|
1272
|
+
</tr>
|
|
1273
|
+
</tfoot>
|
|
1274
|
+
</table>
|
|
1275
|
+
`,
|
|
1276
|
+
}),
|
|
1277
|
+
);
|
|
1278
|
+
await vi.runAllTimersAsync();
|
|
1279
|
+
|
|
1280
|
+
expect(quill.root).toEqualHTML(
|
|
1281
|
+
`
|
|
1282
|
+
<p><br></p>
|
|
1283
|
+
<div>
|
|
1284
|
+
<table cellpadding="0" cellspacing="0" style="margin-right: auto; width: 300px;">
|
|
1285
|
+
${createTaleColHTML(3, { full: false, width: 100 })}
|
|
1286
|
+
<thead>
|
|
1287
|
+
<tr data-wrap-tag="thead">
|
|
1288
|
+
<th colspan="1" rowspan="1" data-wrap-tag="thead">
|
|
1289
|
+
<div data-tag="th" data-wrap-tag="thead">
|
|
1290
|
+
<p>head1</p>
|
|
1291
|
+
</div>
|
|
1292
|
+
</th>
|
|
1293
|
+
<th colspan="1" rowspan="1" data-wrap-tag="thead">
|
|
1294
|
+
<div data-tag="th" data-wrap-tag="thead">
|
|
1295
|
+
<p>head2</p>
|
|
1296
|
+
</div>
|
|
1297
|
+
</th>
|
|
1298
|
+
<th colspan="1" rowspan="1" data-wrap-tag="thead">
|
|
1299
|
+
<div data-tag="th" data-wrap-tag="thead">
|
|
1300
|
+
<p>head3</p>
|
|
1301
|
+
</div>
|
|
1302
|
+
</th>
|
|
1303
|
+
</tr>
|
|
1304
|
+
</thead>
|
|
1305
|
+
<tbody>
|
|
1306
|
+
<tr data-wrap-tag="tbody">
|
|
1307
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tbody">
|
|
1308
|
+
<div data-tag="td" data-wrap-tag="tbody">
|
|
1309
|
+
<p>body1</p>
|
|
1310
|
+
</div>
|
|
1311
|
+
</td>
|
|
1312
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tbody">
|
|
1313
|
+
<div data-tag="td" data-wrap-tag="tbody">
|
|
1314
|
+
<p>body2</p>
|
|
1315
|
+
</div>
|
|
1316
|
+
</td>
|
|
1317
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tbody">
|
|
1318
|
+
<div data-tag="td" data-wrap-tag="tbody">
|
|
1319
|
+
<p>body3</p>
|
|
1320
|
+
</div>
|
|
1321
|
+
</td>
|
|
1322
|
+
</tr>
|
|
1323
|
+
<tr data-wrap-tag="tbody">
|
|
1324
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tbody">
|
|
1325
|
+
<div data-tag="td" data-wrap-tag="tbody">
|
|
1326
|
+
<p>body4</p>
|
|
1327
|
+
</div>
|
|
1328
|
+
</td>
|
|
1329
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tbody">
|
|
1330
|
+
<div data-tag="td" data-wrap-tag="tbody">
|
|
1331
|
+
<p>body5</p>
|
|
1332
|
+
</div>
|
|
1333
|
+
</td>
|
|
1334
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tbody">
|
|
1335
|
+
<div data-tag="td" data-wrap-tag="tbody">
|
|
1336
|
+
<p>body6</p>
|
|
1337
|
+
</div>
|
|
1338
|
+
</td>
|
|
1339
|
+
</tr>
|
|
1340
|
+
</tbody>
|
|
1341
|
+
<tfoot>
|
|
1342
|
+
<tr data-wrap-tag="tfoot">
|
|
1343
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tfoot">
|
|
1344
|
+
<div data-tag="td" data-wrap-tag="tfoot">
|
|
1345
|
+
<p>foot1</p>
|
|
1346
|
+
</div>
|
|
1347
|
+
</td>
|
|
1348
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tfoot">
|
|
1349
|
+
<div data-tag="td" data-wrap-tag="tfoot">
|
|
1350
|
+
<p>foot2</p>
|
|
1351
|
+
</div>
|
|
1352
|
+
</td>
|
|
1353
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tfoot">
|
|
1354
|
+
<div data-tag="td" data-wrap-tag="tfoot">
|
|
1355
|
+
<p>foot3</p>
|
|
1356
|
+
</div>
|
|
1357
|
+
</td>
|
|
1358
|
+
</tr>
|
|
1359
|
+
</tfoot>
|
|
1360
|
+
</table>
|
|
1361
|
+
</div>
|
|
1362
|
+
<p><br></p>
|
|
1363
|
+
`,
|
|
1364
|
+
{ ignoreAttrs: ['class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
1365
|
+
);
|
|
1366
|
+
});
|
|
1367
|
+
|
|
1368
|
+
it('convert thead rowspan to tbody', async () => {
|
|
1369
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
1370
|
+
quill.setContents(
|
|
1371
|
+
quill.clipboard.convert({
|
|
1372
|
+
html: `
|
|
1373
|
+
<table>
|
|
1374
|
+
<thead>
|
|
1375
|
+
<tr>
|
|
1376
|
+
<td rowspan="2" colspan="2">123</td>
|
|
1377
|
+
</tr>
|
|
1378
|
+
</thead>
|
|
1379
|
+
<tbody>
|
|
1380
|
+
<tr>
|
|
1381
|
+
<td>1</td>
|
|
1382
|
+
<td>2</td>
|
|
1383
|
+
</tr>
|
|
1384
|
+
<tr>
|
|
1385
|
+
<td>1</td>
|
|
1386
|
+
<td>2</td>
|
|
1387
|
+
</tr>
|
|
1388
|
+
</tbody>
|
|
1389
|
+
</table>
|
|
1390
|
+
`,
|
|
1391
|
+
}),
|
|
1392
|
+
);
|
|
1393
|
+
await vi.runAllTimersAsync();
|
|
1394
|
+
|
|
1395
|
+
expect(quill.root).toEqualHTML(
|
|
1396
|
+
`
|
|
1397
|
+
<p><br></p>
|
|
1398
|
+
<div>
|
|
1399
|
+
<table cellpadding="0" cellspacing="0" style="margin-right: auto; width: 200px;">
|
|
1400
|
+
${createTaleColHTML(2, { full: false, width: 100 })}
|
|
1401
|
+
<thead>
|
|
1402
|
+
<tr data-wrap-tag="thead">
|
|
1403
|
+
<td colspan="2" rowspan="1" data-wrap-tag="thead">
|
|
1404
|
+
<div data-tag="td" data-wrap-tag="thead">
|
|
1405
|
+
<p>123</p>
|
|
1406
|
+
</div>
|
|
1407
|
+
</td>
|
|
1408
|
+
</tr>
|
|
1409
|
+
</thead>
|
|
1410
|
+
<tbody>
|
|
1411
|
+
<tr data-wrap-tag="tbody">
|
|
1412
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tbody">
|
|
1413
|
+
<div data-tag="td" data-wrap-tag="tbody">
|
|
1414
|
+
<p>1</p>
|
|
1415
|
+
</div>
|
|
1416
|
+
</td>
|
|
1417
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tbody">
|
|
1418
|
+
<div data-tag="td" data-wrap-tag="tbody">
|
|
1419
|
+
<p>2</p>
|
|
1420
|
+
</div>
|
|
1421
|
+
</td>
|
|
1422
|
+
</tr>
|
|
1423
|
+
<tr data-wrap-tag="tbody">
|
|
1424
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tbody">
|
|
1425
|
+
<div data-tag="td" data-wrap-tag="tbody">
|
|
1426
|
+
<p>1</p>
|
|
1427
|
+
</div>
|
|
1428
|
+
</td>
|
|
1429
|
+
<td colspan="1" rowspan="1" data-wrap-tag="tbody">
|
|
1430
|
+
<div data-tag="td" data-wrap-tag="tbody">
|
|
1431
|
+
<p>2</p>
|
|
1432
|
+
</div>
|
|
1433
|
+
</td>
|
|
1434
|
+
</tr>
|
|
1435
|
+
</tbody>
|
|
1436
|
+
</table>
|
|
1437
|
+
</div>
|
|
1438
|
+
<p><br></p>
|
|
1439
|
+
`,
|
|
1076
1440
|
{ ignoreAttrs: ['class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
|
|
1077
1441
|
);
|
|
1078
1442
|
});
|
|
@@ -1329,7 +1693,7 @@ describe('clipboard content format', () => {
|
|
|
1329
1693
|
</div>
|
|
1330
1694
|
<p><br></p>
|
|
1331
1695
|
`,
|
|
1332
|
-
{ ignoreAttrs: ['data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
1696
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
1333
1697
|
);
|
|
1334
1698
|
});
|
|
1335
1699
|
|
|
@@ -1408,7 +1772,7 @@ describe('clipboard content format', () => {
|
|
|
1408
1772
|
<p><br></p>
|
|
1409
1773
|
`,
|
|
1410
1774
|
{
|
|
1411
|
-
ignoreAttrs: ['data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'],
|
|
1775
|
+
ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'],
|
|
1412
1776
|
},
|
|
1413
1777
|
);
|
|
1414
1778
|
});
|
|
@@ -1505,7 +1869,7 @@ describe('clipboard content format', () => {
|
|
|
1505
1869
|
</div>
|
|
1506
1870
|
<p><br></p>
|
|
1507
1871
|
`,
|
|
1508
|
-
{ ignoreAttrs: ['data-tag', 'class', 'colspan', 'rowspan', 'data-colspan', 'data-rowspan', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
1872
|
+
{ ignoreAttrs: ['data-wrap-tag', 'data-tag', 'class', 'colspan', 'rowspan', 'data-colspan', 'data-rowspan', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
1509
1873
|
);
|
|
1510
1874
|
expectDelta(
|
|
1511
1875
|
new Delta([
|