quill-table-up 2.1.9 → 2.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.
- package/README.md +41 -34
- package/dist/index.css +1 -1
- package/dist/index.d.ts +53 -17
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +16 -16
- package/src/__tests__/e2e/editor-page.ts +6 -0
- package/src/__tests__/e2e/table-blots.test.ts +52 -0
- package/src/__tests__/e2e/table-caption.test.ts +93 -0
- package/src/__tests__/e2e/table-hack.test.ts +43 -0
- package/src/__tests__/e2e/table-resize.test.ts +136 -5
- package/src/__tests__/e2e/table-selection.test.ts +7 -10
- package/src/__tests__/e2e/utils.ts +2 -2
- package/src/__tests__/unit/table-blots.test.ts +223 -0
- package/src/__tests__/unit/table-caption.test.ts +237 -0
- package/src/__tests__/unit/table-clipboard.test.ts +6 -6
- package/src/__tests__/unit/table-hack.test.ts +137 -63
- package/src/__tests__/unit/table-insert.test.ts +4 -4
- package/src/__tests__/unit/table-redo-undo.test.ts +252 -3
- package/src/__tests__/unit/utils.test.ts +2 -2
- package/src/__tests__/unit/utils.ts +44 -25
- package/src/__tests__/unit/vitest.d.ts +0 -1
- package/src/formats/index.ts +1 -0
- package/src/formats/overrides/scroll.ts +6 -0
- package/src/formats/table-caption-format.ts +115 -0
- package/src/formats/table-cell-format.ts +63 -33
- package/src/formats/table-cell-inner-format.ts +3 -3
- package/src/formats/table-col-format.ts +16 -12
- package/src/formats/table-colgroup-format.ts +2 -2
- package/src/formats/table-main-format.ts +0 -9
- package/src/formats/table-wrapper-format.ts +2 -2
- package/src/modules/table-clipboard.ts +21 -3
- package/src/modules/table-menu/constants.ts +18 -2
- package/src/modules/table-menu/table-menu-common.ts +0 -5
- package/src/modules/table-resize/table-resize-box.ts +74 -31
- package/src/modules/table-resize/table-resize-common.ts +8 -7
- package/src/modules/table-resize/table-resize-scale.ts +12 -5
- package/src/modules/table-scrollbar.ts +12 -7
- package/src/modules/table-selection.ts +16 -19
- package/src/style/color-picker.less +4 -2
- package/src/style/index.less +19 -0
- package/src/style/table-resize.less +16 -1
- package/src/svg/arrow-up-down.svg +11 -0
- package/src/svg/auto-full.svg +11 -1
- package/src/svg/background.svg +10 -1
- package/src/svg/border.svg +10 -1
- package/src/svg/color.svg +10 -1
- package/src/svg/copy.svg +8 -1
- package/src/svg/cut.svg +7 -1
- package/src/svg/insert-bottom.svg +6 -1
- package/src/svg/insert-left.svg +6 -1
- package/src/svg/insert-right.svg +6 -1
- package/src/svg/insert-top.svg +6 -1
- package/src/svg/merge-cell.svg +6 -1
- package/src/svg/remove-column.svg +6 -1
- package/src/svg/remove-row.svg +6 -1
- package/src/svg/remove-table.svg +6 -1
- package/src/svg/split-cell.svg +6 -1
- package/src/svg/table-head.svg +4 -0
- package/src/table-up.ts +149 -112
- package/src/utils/bem.ts +2 -2
- package/src/utils/blot-helper.ts +12 -0
- package/src/utils/color.ts +12 -12
- package/src/utils/components/button.ts +2 -2
- package/src/utils/components/color-picker.ts +2 -2
- package/src/utils/components/dialog.ts +2 -2
- package/src/utils/components/input.ts +2 -2
- package/src/utils/components/table/creator.ts +2 -2
- package/src/utils/components/table/select-box.ts +2 -2
- package/src/utils/components/tooltip.ts +2 -2
- package/src/utils/constants.ts +5 -3
- package/src/utils/position.ts +2 -2
- package/src/utils/resize-observer-helper.ts +2 -2
- package/src/utils/transformer.ts +5 -0
- package/src/utils/transition-event-helper.ts +2 -2
- package/src/utils/types.ts +5 -1
- package/src/utils/utils.ts +2 -2
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { TableCellFormat } from '../../formats';
|
|
3
|
+
import { TableUp } from '../../table-up';
|
|
4
|
+
import { createQuillWithTableModule } from './utils';
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
vi.useFakeTimers();
|
|
8
|
+
});
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
vi.useRealTimers();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe('test tableCell getNearByCell', () => {
|
|
14
|
+
it('getNearByCell left', async () => {
|
|
15
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
16
|
+
const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
|
|
17
|
+
tableModule.insertTable(3, 3);
|
|
18
|
+
await vi.runAllTimersAsync();
|
|
19
|
+
const tds = quill.scroll.descendants(TableCellFormat, 0);
|
|
20
|
+
expect(tds[4].getNearByCell('left')).toEqual([tds[3]]);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('getNearByCell left (before cell have merge cell)', async () => {
|
|
24
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
25
|
+
quill.setContents([
|
|
26
|
+
{ insert: '\n' },
|
|
27
|
+
{ insert: { 'table-up-col': { tableId: 'vv2xmonkcdq', colId: 'yyzprl5nm6a', full: false, width: 100 } } },
|
|
28
|
+
{ insert: { 'table-up-col': { tableId: 'vv2xmonkcdq', colId: 'rbxstjgmt1', full: false, width: 100 } } },
|
|
29
|
+
{ insert: { 'table-up-col': { tableId: 'vv2xmonkcdq', colId: 'wiy1z7o6r8', full: false, width: 100 } } },
|
|
30
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'vv2xmonkcdq', rowId: 'dfvd9tlo86d', colId: 'yyzprl5nm6a', rowspan: 2, colspan: 2 } }, insert: '\n' },
|
|
31
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'vv2xmonkcdq', rowId: 'dfvd9tlo86d', colId: 'wiy1z7o6r8', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
32
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'vv2xmonkcdq', rowId: 'cp2te48tbi', colId: 'wiy1z7o6r8', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
33
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'vv2xmonkcdq', rowId: 'y9c5spa0rj', colId: 'yyzprl5nm6a', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
34
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'vv2xmonkcdq', rowId: 'y9c5spa0rj', colId: 'rbxstjgmt1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
35
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'vv2xmonkcdq', rowId: 'y9c5spa0rj', colId: 'wiy1z7o6r8', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
36
|
+
{ insert: '\n' },
|
|
37
|
+
]);
|
|
38
|
+
await vi.runAllTimersAsync();
|
|
39
|
+
const tds1 = quill.scroll.descendants(TableCellFormat, 0);
|
|
40
|
+
expect(tds1[1].getNearByCell('left')).toEqual([tds1[0]]);
|
|
41
|
+
expect(tds1[2].getNearByCell('left')).toEqual([]);
|
|
42
|
+
expect(tds1[5].getNearByCell('left')).toEqual([tds1[4]]);
|
|
43
|
+
|
|
44
|
+
quill.setContents([
|
|
45
|
+
{ insert: '\n' },
|
|
46
|
+
{ insert: { 'table-up-col': { tableId: 'p0a2x1lw2rk', colId: '4coaaxs1bka', full: false, width: 100 } } },
|
|
47
|
+
{ insert: { 'table-up-col': { tableId: 'p0a2x1lw2rk', colId: '6q7c4xg24ht', full: false, width: 100 } } },
|
|
48
|
+
{ insert: { 'table-up-col': { tableId: 'p0a2x1lw2rk', colId: 'yqycicys6cq', full: false, width: 100 } } },
|
|
49
|
+
{ insert: { 'table-up-col': { tableId: 'p0a2x1lw2rk', colId: '4gtetquckd5', full: false, width: 100 } } },
|
|
50
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: 'imqhpv9xmu', colId: '4coaaxs1bka', rowspan: 1, colspan: 2 } }, insert: '\n' },
|
|
51
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: 'imqhpv9xmu', colId: 'yqycicys6cq', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
52
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: 'imqhpv9xmu', colId: '4gtetquckd5', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
53
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: '4wygeorbfdf', colId: '4coaaxs1bka', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
54
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: '4wygeorbfdf', colId: '6q7c4xg24ht', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
55
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: '4wygeorbfdf', colId: 'yqycicys6cq', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
56
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: '4wygeorbfdf', colId: '4gtetquckd5', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
57
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: '01iyk867h9sj', colId: '4coaaxs1bka', rowspan: 2, colspan: 1 } }, insert: '\n' },
|
|
58
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: '01iyk867h9sj', colId: '6q7c4xg24ht', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
59
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: '01iyk867h9sj', colId: 'yqycicys6cq', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
60
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: '01iyk867h9sj', colId: '4gtetquckd5', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
61
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: 'wsbuoh24w4', colId: '6q7c4xg24ht', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
62
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: 'wsbuoh24w4', colId: 'yqycicys6cq', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
63
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'p0a2x1lw2rk', rowId: 'wsbuoh24w4', colId: '4gtetquckd5', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
64
|
+
{ insert: '\n' },
|
|
65
|
+
]);
|
|
66
|
+
await vi.runAllTimersAsync();
|
|
67
|
+
const tds2 = quill.scroll.descendants(TableCellFormat, 0);
|
|
68
|
+
expect(tds2[2].getNearByCell('left')).toEqual([tds2[1]]);
|
|
69
|
+
expect(tds2[9].getNearByCell('left')).toEqual([tds2[8]]);
|
|
70
|
+
expect(tds2[13].getNearByCell('left')).toEqual([tds2[12]]);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('getNearByCell left (current merge cell)', async () => {
|
|
74
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
75
|
+
quill.setContents([
|
|
76
|
+
{ insert: '\n' },
|
|
77
|
+
{ insert: { 'table-up-col': { tableId: 'nhvnk5kj1ae', colId: '147glanhu4', full: false, width: 100 } } },
|
|
78
|
+
{ insert: { 'table-up-col': { tableId: 'nhvnk5kj1ae', colId: '5gi4xubff5n', full: false, width: 100 } } },
|
|
79
|
+
{ insert: { 'table-up-col': { tableId: 'nhvnk5kj1ae', colId: 'q2susi91kv', full: false, width: 100 } } },
|
|
80
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'nhvnk5kj1ae', rowId: 'uxj0buah8p', colId: '147glanhu4', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
81
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'nhvnk5kj1ae', rowId: 'uxj0buah8p', colId: '5gi4xubff5n', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
82
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'nhvnk5kj1ae', rowId: 'uxj0buah8p', colId: 'q2susi91kv', rowspan: 3, colspan: 1 } }, insert: '\n' },
|
|
83
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'nhvnk5kj1ae', rowId: '07jgi0d0hhf', colId: '147glanhu4', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
84
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'nhvnk5kj1ae', rowId: '07jgi0d0hhf', colId: '5gi4xubff5n', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
85
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'nhvnk5kj1ae', rowId: 'fdamb6hr8bt', colId: '147glanhu4', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
86
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'nhvnk5kj1ae', rowId: 'fdamb6hr8bt', colId: '5gi4xubff5n', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
87
|
+
{ insert: '\n' },
|
|
88
|
+
]);
|
|
89
|
+
await vi.runAllTimersAsync();
|
|
90
|
+
const tds = quill.scroll.descendants(TableCellFormat, 0);
|
|
91
|
+
expect(tds[2].getNearByCell('left')).toEqual([tds[1], tds[4], tds[6]]);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('getNearByCell left (current merge cell and before have merge cell)', async () => {
|
|
95
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
96
|
+
quill.setContents([
|
|
97
|
+
{ insert: '\n' },
|
|
98
|
+
{ insert: { 'table-up-col': { tableId: 'd6nxgcr2nsd', colId: '1rvvyleo0ee', full: false, width: 100 } } },
|
|
99
|
+
{ insert: { 'table-up-col': { tableId: 'd6nxgcr2nsd', colId: '3jvqzgjzvc3', full: false, width: 100 } } },
|
|
100
|
+
{ insert: { 'table-up-col': { tableId: 'd6nxgcr2nsd', colId: 'e9qn1b3zhto', full: false, width: 100 } } },
|
|
101
|
+
{ insert: { 'table-up-col': { tableId: 'd6nxgcr2nsd', colId: 'iwktteaq5p', full: false, width: 100 } } },
|
|
102
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'd6nxgcr2nsd', rowId: 'vhjv6xkdo8e', colId: '1rvvyleo0ee', rowspan: 1, colspan: 3 } }, insert: '\n' },
|
|
103
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'd6nxgcr2nsd', rowId: 'vhjv6xkdo8e', colId: 'iwktteaq5p', rowspan: 3, colspan: 1 } }, insert: '\n' },
|
|
104
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'd6nxgcr2nsd', rowId: '33922uw827e', colId: '1rvvyleo0ee', rowspan: 2, colspan: 2 } }, insert: '\n' },
|
|
105
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'd6nxgcr2nsd', rowId: '33922uw827e', colId: 'e9qn1b3zhto', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
106
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'd6nxgcr2nsd', rowId: '0wyvy9e7zq8', colId: 'e9qn1b3zhto', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
107
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'd6nxgcr2nsd', rowId: 'zvmle5uwesp', colId: '1rvvyleo0ee', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
108
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'd6nxgcr2nsd', rowId: 'zvmle5uwesp', colId: '3jvqzgjzvc3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
109
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'd6nxgcr2nsd', rowId: 'zvmle5uwesp', colId: 'e9qn1b3zhto', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
110
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'd6nxgcr2nsd', rowId: 'zvmle5uwesp', colId: 'iwktteaq5p', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
111
|
+
{ insert: '\n' },
|
|
112
|
+
]);
|
|
113
|
+
await vi.runAllTimersAsync();
|
|
114
|
+
const tds = quill.scroll.descendants(TableCellFormat, 0);
|
|
115
|
+
expect(tds[1].getNearByCell('left')).toEqual([tds[0], tds[3], tds[4]]);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('getNearByCell top', async () => {
|
|
119
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
120
|
+
const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
|
|
121
|
+
tableModule.insertTable(3, 3);
|
|
122
|
+
await vi.runAllTimersAsync();
|
|
123
|
+
const tds = quill.scroll.descendants(TableCellFormat, 0);
|
|
124
|
+
expect(tds[4].getNearByCell('top')).toEqual([tds[1]]);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('getNearByCell top (before cell have merge cell)', async () => {
|
|
128
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
129
|
+
quill.setContents([
|
|
130
|
+
{ insert: '\n' },
|
|
131
|
+
{ insert: { 'table-up-col': { tableId: 'vv2xmonkcdq', colId: 'yyzprl5nm6a', full: false, width: 100 } } },
|
|
132
|
+
{ insert: { 'table-up-col': { tableId: 'vv2xmonkcdq', colId: 'rbxstjgmt1', full: false, width: 100 } } },
|
|
133
|
+
{ insert: { 'table-up-col': { tableId: 'vv2xmonkcdq', colId: 'wiy1z7o6r8', full: false, width: 100 } } },
|
|
134
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'vv2xmonkcdq', rowId: 'dfvd9tlo86d', colId: 'yyzprl5nm6a', rowspan: 2, colspan: 2 } }, insert: '\n' },
|
|
135
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'vv2xmonkcdq', rowId: 'dfvd9tlo86d', colId: 'wiy1z7o6r8', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
136
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'vv2xmonkcdq', rowId: 'cp2te48tbi', colId: 'wiy1z7o6r8', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
137
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'vv2xmonkcdq', rowId: 'y9c5spa0rj', colId: 'yyzprl5nm6a', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
138
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'vv2xmonkcdq', rowId: 'y9c5spa0rj', colId: 'rbxstjgmt1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
139
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'vv2xmonkcdq', rowId: 'y9c5spa0rj', colId: 'wiy1z7o6r8', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
140
|
+
{ insert: '\n' },
|
|
141
|
+
]);
|
|
142
|
+
await vi.runAllTimersAsync();
|
|
143
|
+
const tds1 = quill.scroll.descendants(TableCellFormat, 0);
|
|
144
|
+
expect(tds1[3].getNearByCell('top')).toEqual([tds1[0]]);
|
|
145
|
+
expect(tds1[4].getNearByCell('top')).toEqual([]);
|
|
146
|
+
expect(tds1[5].getNearByCell('top')).toEqual([tds1[2]]);
|
|
147
|
+
|
|
148
|
+
quill.setContents([
|
|
149
|
+
{ insert: '\n' },
|
|
150
|
+
{ insert: { 'table-up-col': { tableId: '30jgnjw9n9w', colId: '00jo66o6uwlk', full: false, width: 100 } } },
|
|
151
|
+
{ insert: { 'table-up-col': { tableId: '30jgnjw9n9w', colId: 'ks1njmku5oe', full: false, width: 100 } } },
|
|
152
|
+
{ insert: { 'table-up-col': { tableId: '30jgnjw9n9w', colId: 'u2zqw9rwkxd', full: false, width: 100 } } },
|
|
153
|
+
{ insert: { 'table-up-col': { tableId: '30jgnjw9n9w', colId: 'jgw4vh5knc', full: false, width: 100 } } },
|
|
154
|
+
{ insert: { 'table-up-col': { tableId: '30jgnjw9n9w', colId: 'tyrw6mifzq', full: false, width: 100 } } },
|
|
155
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: 'vzf07egv1br', colId: '00jo66o6uwlk', rowspan: 2, colspan: 2 } }, insert: '\n' },
|
|
156
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: 'vzf07egv1br', colId: 'u2zqw9rwkxd', rowspan: 3, colspan: 1 } }, insert: '\n' },
|
|
157
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: 'vzf07egv1br', colId: 'jgw4vh5knc', rowspan: 1, colspan: 2 } }, insert: '\n' },
|
|
158
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: '8mdx3y6lp1h', colId: 'jgw4vh5knc', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
159
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: '8mdx3y6lp1h', colId: 'tyrw6mifzq', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
160
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: '2dwhizp7ji', colId: '00jo66o6uwlk', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
161
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: '2dwhizp7ji', colId: 'ks1njmku5oe', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
162
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: '2dwhizp7ji', colId: 'jgw4vh5knc', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
163
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: '2dwhizp7ji', colId: 'tyrw6mifzq', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
164
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: 'su9l1e8rmfc', colId: '00jo66o6uwlk', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
165
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: 'su9l1e8rmfc', colId: 'ks1njmku5oe', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
166
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: 'su9l1e8rmfc', colId: 'u2zqw9rwkxd', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
167
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: 'su9l1e8rmfc', colId: 'jgw4vh5knc', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
168
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '30jgnjw9n9w', rowId: 'su9l1e8rmfc', colId: 'tyrw6mifzq', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
169
|
+
{ insert: '\n' },
|
|
170
|
+
]);
|
|
171
|
+
await vi.runAllTimersAsync();
|
|
172
|
+
const tds2 = quill.scroll.descendants(TableCellFormat, 0);
|
|
173
|
+
expect(tds2[3].getNearByCell('top')).toEqual([tds2[2]]);
|
|
174
|
+
expect(tds2[4].getNearByCell('top')).toEqual([]);
|
|
175
|
+
expect(tds2[5].getNearByCell('top')).toEqual([tds2[0]]);
|
|
176
|
+
expect(tds2[6].getNearByCell('top')).toEqual([]);
|
|
177
|
+
expect(tds2[7].getNearByCell('top')).toEqual([tds2[3]]);
|
|
178
|
+
expect(tds2[8].getNearByCell('top')).toEqual([tds2[4]]);
|
|
179
|
+
expect(tds2[11].getNearByCell('top')).toEqual([tds2[1]]);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('getNearByCell top (current merge cell)', async () => {
|
|
183
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
184
|
+
quill.setContents([
|
|
185
|
+
{ insert: '\n' },
|
|
186
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
187
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
188
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
|
|
189
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
190
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
191
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
192
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
193
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 2, colspan: 2 } }, insert: '\n' },
|
|
194
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
195
|
+
{ insert: '\n' },
|
|
196
|
+
]);
|
|
197
|
+
await vi.runAllTimersAsync();
|
|
198
|
+
const tds = quill.scroll.descendants(TableCellFormat, 0);
|
|
199
|
+
expect(tds[4].getNearByCell('top')).toEqual([tds[1], tds[2]]);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('getNearByCell top (current merge cell and before have merge cell)', async () => {
|
|
203
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
204
|
+
quill.setContents([
|
|
205
|
+
{ insert: '\n' },
|
|
206
|
+
{ insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '1vwhsx9zayhi', full: false, width: 100 } } },
|
|
207
|
+
{ insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'gpais2dyp87', full: false, width: 100 } } },
|
|
208
|
+
{ insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'xtfguzk629', full: false, width: 100 } } },
|
|
209
|
+
{ insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'y0epsy6odnm', full: false, width: 100 } } },
|
|
210
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 2, colspan: 2 } }, insert: '\n' },
|
|
211
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'xtfguzk629', rowspan: 1, colspan: 2 } }, insert: '\n' },
|
|
212
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'xtfguzk629', rowspan: 2, colspan: 1 } }, insert: '\n' },
|
|
213
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
214
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
215
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'gpais2dyp87', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
216
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
217
|
+
{ insert: '\n' },
|
|
218
|
+
]);
|
|
219
|
+
await vi.runAllTimersAsync();
|
|
220
|
+
const tds = quill.scroll.descendants(TableCellFormat, 0);
|
|
221
|
+
expect(tds[2].getNearByCell('top')).toEqual([tds[1]]);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import type { TableCaptionFormat } from '../../formats';
|
|
2
|
+
import type { ToolOption } from '../../utils';
|
|
3
|
+
import Quill from 'quill';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { tableMenuTools } from '../../modules';
|
|
6
|
+
import { TableUp } from '../../table-up';
|
|
7
|
+
import { createQuillWithTableModule, createTable, createTableHTML, expectDelta } from './utils';
|
|
8
|
+
|
|
9
|
+
const Delta = Quill.import('delta');
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
vi.useFakeTimers();
|
|
13
|
+
});
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
vi.useRealTimers();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('test tableCaption', () => {
|
|
19
|
+
it('insert tableCaption', async () => {
|
|
20
|
+
const quill = await createTable(3, 3, { full: false });
|
|
21
|
+
const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
|
|
22
|
+
await vi.runAllTimersAsync();
|
|
23
|
+
const table = quill.root.querySelector('table')!;
|
|
24
|
+
tableModule.table = table;
|
|
25
|
+
(tableMenuTools.InsertCaption as ToolOption).handle(tableModule, [], null);
|
|
26
|
+
await vi.runAllTimersAsync();
|
|
27
|
+
|
|
28
|
+
expectDelta(
|
|
29
|
+
new Delta([
|
|
30
|
+
{ insert: '\nTable Caption' },
|
|
31
|
+
{ attributes: { 'table-up-caption': { tableId: '1', side: 'top' } }, insert: '\n' },
|
|
32
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
33
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
34
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
|
|
35
|
+
{ insert: '1' },
|
|
36
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
37
|
+
{ insert: '2' },
|
|
38
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
39
|
+
{ insert: '3' },
|
|
40
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
41
|
+
{ insert: '4' },
|
|
42
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
43
|
+
{ insert: '5' },
|
|
44
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
45
|
+
{ insert: '6' },
|
|
46
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
47
|
+
{ insert: '7' },
|
|
48
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
49
|
+
{ insert: '8' },
|
|
50
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
51
|
+
{ insert: '9' },
|
|
52
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
53
|
+
{ insert: '\n' },
|
|
54
|
+
]),
|
|
55
|
+
quill.getContents(),
|
|
56
|
+
);
|
|
57
|
+
expect(quill.root).toEqualHTML(
|
|
58
|
+
`
|
|
59
|
+
<p><br></p>
|
|
60
|
+
${createTableHTML(3, 3, { full: false }, { text: 'Table Caption' })}
|
|
61
|
+
<p><br></p>
|
|
62
|
+
`,
|
|
63
|
+
{ ignoreAttrs: ['class', 'contenteditable'] },
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('tableCaption switch position', async () => {
|
|
68
|
+
const quill = await createTable(3, 3, { full: false });
|
|
69
|
+
const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
|
|
70
|
+
await vi.runAllTimersAsync();
|
|
71
|
+
const table = quill.root.querySelector('table')!;
|
|
72
|
+
tableModule.table = table;
|
|
73
|
+
(tableMenuTools.InsertCaption as ToolOption).handle(tableModule, [], null);
|
|
74
|
+
await vi.runAllTimersAsync();
|
|
75
|
+
|
|
76
|
+
const tableCaption = Quill.find(table.querySelector('caption')!)! as TableCaptionFormat;
|
|
77
|
+
expect(tableCaption).not.toBeNull();
|
|
78
|
+
tableCaption.side = 'bottom';
|
|
79
|
+
await vi.runAllTimersAsync();
|
|
80
|
+
|
|
81
|
+
expectDelta(
|
|
82
|
+
new Delta([
|
|
83
|
+
{ insert: '\nTable Caption' },
|
|
84
|
+
{ attributes: { 'table-up-caption': { tableId: '1', side: 'bottom' } }, insert: '\n' },
|
|
85
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
86
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
87
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
|
|
88
|
+
{ insert: '1' },
|
|
89
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
90
|
+
{ insert: '2' },
|
|
91
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
92
|
+
{ insert: '3' },
|
|
93
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
94
|
+
{ insert: '4' },
|
|
95
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
96
|
+
{ insert: '5' },
|
|
97
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
98
|
+
{ insert: '6' },
|
|
99
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
100
|
+
{ insert: '7' },
|
|
101
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
102
|
+
{ insert: '8' },
|
|
103
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
104
|
+
{ insert: '9' },
|
|
105
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
106
|
+
{ insert: '\n' },
|
|
107
|
+
]),
|
|
108
|
+
quill.getContents(),
|
|
109
|
+
);
|
|
110
|
+
expect(quill.root).toEqualHTML(
|
|
111
|
+
`
|
|
112
|
+
<p><br></p>
|
|
113
|
+
${createTableHTML(3, 3, { full: false }, { text: 'Table Caption', side: 'bottom' })}
|
|
114
|
+
<p><br></p>
|
|
115
|
+
`,
|
|
116
|
+
{ ignoreAttrs: ['class', 'contenteditable'] },
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('tableCaption should merge', async () => {
|
|
121
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
122
|
+
quill.setContents([
|
|
123
|
+
{ insert: '\nTable Caption' },
|
|
124
|
+
{ attributes: { 'table-up-caption': { tableId: '1', side: 'bottom' } }, insert: '\n' },
|
|
125
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
126
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
127
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
|
|
128
|
+
{ insert: '1' },
|
|
129
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
130
|
+
{ insert: '2' },
|
|
131
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
132
|
+
{ insert: '3' },
|
|
133
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
134
|
+
{ insert: '4' },
|
|
135
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
136
|
+
{ insert: '5' },
|
|
137
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
138
|
+
{ insert: '6' },
|
|
139
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
140
|
+
{ insert: '7' },
|
|
141
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
142
|
+
{ insert: '8' },
|
|
143
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
144
|
+
{ insert: '9' },
|
|
145
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
146
|
+
{ insert: '\n' },
|
|
147
|
+
]);
|
|
148
|
+
await vi.runAllTimersAsync();
|
|
149
|
+
|
|
150
|
+
const table = quill.root.querySelector('table')!;
|
|
151
|
+
const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
|
|
152
|
+
tableModule.table = table;
|
|
153
|
+
(tableMenuTools.InsertCaption as ToolOption).handle(tableModule, [], null);
|
|
154
|
+
await vi.runAllTimersAsync();
|
|
155
|
+
expectDelta(
|
|
156
|
+
new Delta([
|
|
157
|
+
{ insert: '\nTable CaptionTable Caption' },
|
|
158
|
+
{ attributes: { 'table-up-caption': { tableId: '1', side: 'top' } }, insert: '\n' },
|
|
159
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
160
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
161
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
|
|
162
|
+
{ insert: '1' },
|
|
163
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
164
|
+
{ insert: '2' },
|
|
165
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
166
|
+
{ insert: '3' },
|
|
167
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
168
|
+
{ insert: '4' },
|
|
169
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
170
|
+
{ insert: '5' },
|
|
171
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
172
|
+
{ insert: '6' },
|
|
173
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
174
|
+
{ insert: '7' },
|
|
175
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
176
|
+
{ insert: '8' },
|
|
177
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
178
|
+
{ insert: '9' },
|
|
179
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
180
|
+
{ insert: '\n' },
|
|
181
|
+
]),
|
|
182
|
+
quill.getContents(),
|
|
183
|
+
);
|
|
184
|
+
expect(quill.root).toEqualHTML(
|
|
185
|
+
`
|
|
186
|
+
<p><br></p>
|
|
187
|
+
${createTableHTML(3, 3, { full: false }, { text: 'Table CaptionTable Caption' })}
|
|
188
|
+
<p><br></p>
|
|
189
|
+
`,
|
|
190
|
+
{ ignoreAttrs: ['class', 'contenteditable'] },
|
|
191
|
+
);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('tableCaption uiNode should not in html string', async () => {
|
|
195
|
+
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
196
|
+
quill.setContents([
|
|
197
|
+
{ insert: '\nTable Caption' },
|
|
198
|
+
{ attributes: { 'table-up-caption': { tableId: '1', side: 'top' } }, insert: '\n' },
|
|
199
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
200
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
201
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
|
|
202
|
+
{ insert: '1' },
|
|
203
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
204
|
+
{ insert: '2' },
|
|
205
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
206
|
+
{ insert: '3' },
|
|
207
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
208
|
+
{ insert: '4' },
|
|
209
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
210
|
+
{ insert: '5' },
|
|
211
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
212
|
+
{ insert: '6' },
|
|
213
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
214
|
+
{ insert: '7' },
|
|
215
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
216
|
+
{ insert: '8' },
|
|
217
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
218
|
+
{ insert: '9' },
|
|
219
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
220
|
+
{ insert: '\n' },
|
|
221
|
+
]);
|
|
222
|
+
await vi.runAllTimersAsync();
|
|
223
|
+
|
|
224
|
+
const html = quill.getSemanticHTML();
|
|
225
|
+
const parser = new DOMParser();
|
|
226
|
+
const doc = parser.parseFromString(html, 'text/html');
|
|
227
|
+
expect(doc.body).toEqualHTML(
|
|
228
|
+
`
|
|
229
|
+
<p></p>
|
|
230
|
+
${createTableHTML(3, 3, { full: false }, { text: 'Table Caption' })}
|
|
231
|
+
<p></p>
|
|
232
|
+
`,
|
|
233
|
+
{ ignoreAttrs: ['class', 'contenteditable'] },
|
|
234
|
+
);
|
|
235
|
+
expect(doc.body.querySelector('caption .ql-ui')).toBeNull();
|
|
236
|
+
});
|
|
237
|
+
});
|
|
@@ -26,7 +26,7 @@ describe('clipboard cell structure', () => {
|
|
|
26
26
|
expect(quill.root).toEqualHTML(
|
|
27
27
|
`
|
|
28
28
|
<p><br></p>
|
|
29
|
-
${createTableHTML(3, 3, { width: 100, full: false }, { isEmpty: false })}
|
|
29
|
+
${createTableHTML(3, 3, { width: 100, full: false }, undefined, { isEmpty: false })}
|
|
30
30
|
<p><br></p>
|
|
31
31
|
`,
|
|
32
32
|
{ ignoreAttrs: ['class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
@@ -255,7 +255,7 @@ describe('clipboard cell structure', () => {
|
|
|
255
255
|
expect(quill.root).toEqualHTML(
|
|
256
256
|
`
|
|
257
257
|
<p>123</p>
|
|
258
|
-
${createTableHTML(3, 3, { width: 100, full: false }, { isEmpty: false })}
|
|
258
|
+
${createTableHTML(3, 3, { width: 100, full: false }, undefined, { isEmpty: false })}
|
|
259
259
|
<p>123</p>
|
|
260
260
|
`,
|
|
261
261
|
{ ignoreAttrs: ['class', 'style', 'data-table-id', 'data-row-id', 'data-col-id', 'contenteditable'] },
|
|
@@ -1152,7 +1152,7 @@ describe('clipboard content format', () => {
|
|
|
1152
1152
|
describe('clipboard cell in cell', () => {
|
|
1153
1153
|
it('paste simple text into table', async () => {
|
|
1154
1154
|
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
1155
|
-
quill.setContents(createTableDeltaOps(1, 1, { full: false, width: 100 }, { isEmpty: true }));
|
|
1155
|
+
quill.setContents(createTableDeltaOps(1, 1, { full: false, width: 100 }, {}, { isEmpty: true }));
|
|
1156
1156
|
await vi.runAllTimersAsync();
|
|
1157
1157
|
await simulatePasteHTML(
|
|
1158
1158
|
quill,
|
|
@@ -1176,7 +1176,7 @@ describe('clipboard cell in cell', () => {
|
|
|
1176
1176
|
|
|
1177
1177
|
it('paste format text into table', async () => {
|
|
1178
1178
|
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
1179
|
-
quill.setContents(createTableDeltaOps(1, 1, { full: false, width: 100 }, { isEmpty: true }));
|
|
1179
|
+
quill.setContents(createTableDeltaOps(1, 1, { full: false, width: 100 }, {}, { isEmpty: true }));
|
|
1180
1180
|
await vi.runAllTimersAsync();
|
|
1181
1181
|
await simulatePasteHTML(
|
|
1182
1182
|
quill,
|
|
@@ -1202,7 +1202,7 @@ describe('clipboard cell in cell', () => {
|
|
|
1202
1202
|
|
|
1203
1203
|
it('paste cell text into table', async () => {
|
|
1204
1204
|
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
1205
|
-
quill.setContents(createTableDeltaOps(1, 1, { full: false, width: 100 }, { isEmpty: true }));
|
|
1205
|
+
quill.setContents(createTableDeltaOps(1, 1, { full: false, width: 100 }, {}, { isEmpty: true }));
|
|
1206
1206
|
await vi.runAllTimersAsync();
|
|
1207
1207
|
const range = { index: 2, length: 0 };
|
|
1208
1208
|
quill.setSelection(range);
|
|
@@ -1228,7 +1228,7 @@ describe('clipboard cell in cell', () => {
|
|
|
1228
1228
|
|
|
1229
1229
|
it('paste cell with format text into table', async () => {
|
|
1230
1230
|
const quill = createQuillWithTableModule(`<p><br></p>`);
|
|
1231
|
-
quill.setContents(createTableDeltaOps(1, 1, { full: false, width: 100 }, { isEmpty: true }));
|
|
1231
|
+
quill.setContents(createTableDeltaOps(1, 1, { full: false, width: 100 }, {}, { isEmpty: true }));
|
|
1232
1232
|
await vi.runAllTimersAsync();
|
|
1233
1233
|
const range = { index: 2, length: 0 };
|
|
1234
1234
|
quill.setSelection(range);
|