@atlaskit/editor-plugin-table 0.0.6 → 0.0.8
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/CHANGELOG.md +17 -0
- package/dist/cjs/plugins/table/event-handlers.js +7 -6
- package/dist/cjs/plugins/table/nodeviews/table.js +4 -2
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +4 -4
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/column-state.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +8 -3
- package/dist/cjs/plugins/table/toolbar.js +0 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +23 -10
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +23 -10
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +4 -4
- package/dist/cjs/plugins/table/utils/column-controls.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/event-handlers.js +8 -7
- package/dist/es2019/plugins/table/nodeviews/table.js +4 -2
- package/dist/es2019/plugins/table/nodeviews/tableCell.js +3 -4
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/column-state.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +8 -3
- package/dist/es2019/plugins/table/toolbar.js +1 -2
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +18 -3
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +18 -3
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +2 -2
- package/dist/es2019/plugins/table/utils/column-controls.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/event-handlers.js +8 -7
- package/dist/esm/plugins/table/nodeviews/table.js +4 -2
- package/dist/esm/plugins/table/nodeviews/tableCell.js +3 -4
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/column-state.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +8 -3
- package/dist/esm/plugins/table/toolbar.js +1 -2
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +19 -9
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +19 -9
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +2 -2
- package/dist/esm/plugins/table/utils/column-controls.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/nodeviews/types.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +5 -8
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +5 -5
- package/dist/types-ts4.0/plugins/table/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +5 -8
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +5 -5
- package/package.json +10 -3
- package/src/__tests__/unit/analytics.ts +737 -0
- package/src/__tests__/unit/collab.ts +76 -0
- package/src/__tests__/unit/commands/sort.ts +230 -0
- package/src/__tests__/unit/copy-paste.ts +686 -0
- package/src/__tests__/unit/event-handlers/index.ts +106 -0
- package/src/__tests__/unit/event-handlers.ts +202 -0
- package/src/__tests__/unit/fix-tables.ts +156 -0
- package/src/__tests__/unit/floating-toolbar.ts +95 -0
- package/src/__tests__/unit/handlers.ts +81 -0
- package/src/__tests__/unit/hover-selection.ts +277 -0
- package/src/__tests__/unit/index-with-fake-timers.ts +107 -0
- package/src/__tests__/unit/index.ts +986 -0
- package/src/__tests__/unit/keymap.ts +602 -0
- package/src/__tests__/unit/layout.ts +196 -0
- package/src/__tests__/unit/nodeviews/cell.ts +167 -0
- package/src/__tests__/unit/pm-plugins/table-resizing/utils/resize-state.ts +33 -0
- package/src/__tests__/unit/sort-column.ts +512 -0
- package/src/__tests__/unit/transforms/delete-columns.ts +499 -0
- package/src/__tests__/unit/transforms/delete-rows.ts +557 -0
- package/src/__tests__/unit/transforms/merging.ts +374 -0
- package/src/__tests__/unit/ui/CornerControls.tsx +80 -0
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +95 -0
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +175 -0
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +266 -0
- package/src/__tests__/unit/ui/RowControls.tsx +301 -0
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +93 -0
- package/src/__tests__/unit/undo-redo.ts +202 -0
- package/src/__tests__/unit/utils/dom.ts +286 -0
- package/src/__tests__/unit/utils/nodes.ts +59 -0
- package/src/__tests__/unit/utils/row-controls.ts +176 -0
- package/src/__tests__/unit/utils/table.ts +93 -0
- package/src/__tests__/unit/utils.ts +652 -0
- package/src/plugins/table/__tests__/unit/commands/insert.ts +2 -2
- package/src/plugins/table/__tests__/unit/commands.ts +2 -2
- package/src/plugins/table/__tests__/unit/nodeviews/TableComponent.tsx +2 -2
- package/src/plugins/table/__tests__/unit/nodeviews/table.ts +1 -0
- package/src/plugins/table/event-handlers.ts +5 -6
- package/src/plugins/table/nodeviews/table.tsx +7 -0
- package/src/plugins/table/nodeviews/tableCell.tsx +5 -4
- package/src/plugins/table/nodeviews/types.ts +1 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/column-state.ts +1 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-logic.ts +6 -2
- package/src/plugins/table/toolbar.ts +0 -1
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/ContextualMenu.tsx +1 -1
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/FloatingContextualMenu.tsx +1 -1
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +19 -1
- package/src/plugins/table/ui/TableFloatingControls/RowControls/index.tsx +16 -1
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +2 -2
- package/src/plugins/table/utils/column-controls.ts +1 -1
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProsemirrorEditorFactory,
|
|
3
|
+
Preset,
|
|
4
|
+
LightEditorPlugin,
|
|
5
|
+
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
6
|
+
import {
|
|
7
|
+
doc,
|
|
8
|
+
p,
|
|
9
|
+
table,
|
|
10
|
+
h1,
|
|
11
|
+
tr,
|
|
12
|
+
td,
|
|
13
|
+
th,
|
|
14
|
+
strong,
|
|
15
|
+
DocBuilder,
|
|
16
|
+
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
17
|
+
import {
|
|
18
|
+
PermittedLayoutsDescriptor,
|
|
19
|
+
TablePluginState,
|
|
20
|
+
} from '../../plugins/table/types';
|
|
21
|
+
import { uuid } from '@atlaskit/adf-schema';
|
|
22
|
+
import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
|
|
23
|
+
import textFormattingPlugin from '@atlaskit/editor-core/src/plugins/text-formatting';
|
|
24
|
+
import blockTypePlugin from '@atlaskit/editor-core/src/plugins/block-type';
|
|
25
|
+
import { sortByColumn } from '../../plugins/table/commands';
|
|
26
|
+
import { pluginKey as tablePluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
27
|
+
import tablePlugin from '../../plugins/table-plugin';
|
|
28
|
+
import { PluginKey } from 'prosemirror-state';
|
|
29
|
+
|
|
30
|
+
const TABLE_LOCAL_ID = 'test-table-local-id';
|
|
31
|
+
|
|
32
|
+
describe('table plugin', () => {
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
uuid.setStatic(TABLE_LOCAL_ID);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterEach(() => {
|
|
38
|
+
uuid.setStatic(false);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
42
|
+
const tableOptions = {
|
|
43
|
+
allowNumberColumn: true,
|
|
44
|
+
allowHeaderRow: true,
|
|
45
|
+
allowHeaderColumn: true,
|
|
46
|
+
allowBackgroundColor: true,
|
|
47
|
+
permittedLayouts: 'all' as PermittedLayoutsDescriptor,
|
|
48
|
+
allowColumnSorting: true,
|
|
49
|
+
};
|
|
50
|
+
const preset = new Preset<LightEditorPlugin>()
|
|
51
|
+
.add([tablePlugin, { tableOptions }])
|
|
52
|
+
.add(textFormattingPlugin)
|
|
53
|
+
.add(blockTypePlugin);
|
|
54
|
+
|
|
55
|
+
const editor = (doc: DocBuilder) => {
|
|
56
|
+
return createEditor<TablePluginState, PluginKey>({
|
|
57
|
+
doc,
|
|
58
|
+
preset,
|
|
59
|
+
pluginKey: tablePluginKey,
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
describe('TableView', () => {
|
|
64
|
+
describe('Sort Columns in given order', () => {
|
|
65
|
+
it('sorts the given column in ascending order', () => {
|
|
66
|
+
const { editorView } = editor(
|
|
67
|
+
doc(
|
|
68
|
+
table({ isNumberColumnEnabled: false, layout: 'default' })(
|
|
69
|
+
tr(
|
|
70
|
+
th({})(p(strong('1'))),
|
|
71
|
+
th({})(p(strong('2'))),
|
|
72
|
+
th({})(p(strong('3'))),
|
|
73
|
+
th({})(p(strong('4'))),
|
|
74
|
+
th({})(p(strong('5'))),
|
|
75
|
+
),
|
|
76
|
+
tr(
|
|
77
|
+
td({})(p('c')),
|
|
78
|
+
td({})(p('c')),
|
|
79
|
+
td({})(p()),
|
|
80
|
+
td({})(p('c')),
|
|
81
|
+
td({})(p()),
|
|
82
|
+
),
|
|
83
|
+
tr(
|
|
84
|
+
td({})(p('b')),
|
|
85
|
+
td({})(p()),
|
|
86
|
+
td({})(p('d')),
|
|
87
|
+
td({})(p()),
|
|
88
|
+
td({})(p('c')),
|
|
89
|
+
),
|
|
90
|
+
tr(
|
|
91
|
+
td({})(p()),
|
|
92
|
+
td({})(p('z')),
|
|
93
|
+
td({})(p()),
|
|
94
|
+
td({})(p()),
|
|
95
|
+
td({})(p('f')),
|
|
96
|
+
),
|
|
97
|
+
tr(
|
|
98
|
+
td({})(p('2')),
|
|
99
|
+
td({})(p()),
|
|
100
|
+
td({})(p()),
|
|
101
|
+
td({})(p()),
|
|
102
|
+
td({})(p()),
|
|
103
|
+
),
|
|
104
|
+
tr(
|
|
105
|
+
td({})(p('1')),
|
|
106
|
+
td({})(p()),
|
|
107
|
+
td({})(p('c')),
|
|
108
|
+
td({})(p()),
|
|
109
|
+
td({})(p()),
|
|
110
|
+
),
|
|
111
|
+
tr(
|
|
112
|
+
td({})(p('a')),
|
|
113
|
+
td({})(p()),
|
|
114
|
+
td({})(p()),
|
|
115
|
+
td({})(p()),
|
|
116
|
+
td({})(p()),
|
|
117
|
+
),
|
|
118
|
+
),
|
|
119
|
+
),
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const sortByColumnCommand = sortByColumn(0, SortOrder.ASC);
|
|
123
|
+
|
|
124
|
+
sortByColumnCommand(editorView.state, editorView.dispatch);
|
|
125
|
+
|
|
126
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
127
|
+
doc(
|
|
128
|
+
table({
|
|
129
|
+
isNumberColumnEnabled: false,
|
|
130
|
+
layout: 'default',
|
|
131
|
+
localId: TABLE_LOCAL_ID,
|
|
132
|
+
})(
|
|
133
|
+
tr(
|
|
134
|
+
th({})(p(strong('1'))),
|
|
135
|
+
th({})(p(strong('2'))),
|
|
136
|
+
th({})(p(strong('3'))),
|
|
137
|
+
th({})(p(strong('4'))),
|
|
138
|
+
th({})(p(strong('5'))),
|
|
139
|
+
),
|
|
140
|
+
tr(
|
|
141
|
+
td({})(p('1')),
|
|
142
|
+
td({})(p()),
|
|
143
|
+
td({})(p('c')),
|
|
144
|
+
td({})(p()),
|
|
145
|
+
td({})(p()),
|
|
146
|
+
),
|
|
147
|
+
tr(
|
|
148
|
+
td({})(p('2')),
|
|
149
|
+
td({})(p()),
|
|
150
|
+
td({})(p()),
|
|
151
|
+
td({})(p()),
|
|
152
|
+
td({})(p()),
|
|
153
|
+
),
|
|
154
|
+
tr(
|
|
155
|
+
td({})(p('a')),
|
|
156
|
+
td({})(p()),
|
|
157
|
+
td({})(p()),
|
|
158
|
+
td({})(p()),
|
|
159
|
+
td({})(p()),
|
|
160
|
+
),
|
|
161
|
+
tr(
|
|
162
|
+
td({})(p('b')),
|
|
163
|
+
td({})(p()),
|
|
164
|
+
td({})(p('d')),
|
|
165
|
+
td({})(p()),
|
|
166
|
+
td({})(p('c')),
|
|
167
|
+
),
|
|
168
|
+
tr(
|
|
169
|
+
td({})(p('c')),
|
|
170
|
+
td({})(p('c')),
|
|
171
|
+
td({})(p()),
|
|
172
|
+
td({})(p('c')),
|
|
173
|
+
td({})(p()),
|
|
174
|
+
),
|
|
175
|
+
tr(
|
|
176
|
+
td({})(p()),
|
|
177
|
+
td({})(p('z')),
|
|
178
|
+
td({})(p()),
|
|
179
|
+
td({})(p()),
|
|
180
|
+
td({})(p('f')),
|
|
181
|
+
),
|
|
182
|
+
),
|
|
183
|
+
),
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
it('sorts the given column in descending order', () => {
|
|
187
|
+
const { editorView } = editor(
|
|
188
|
+
doc(
|
|
189
|
+
table({ isNumberColumnEnabled: false, layout: 'default' })(
|
|
190
|
+
tr(
|
|
191
|
+
th({})(p(strong('1'))),
|
|
192
|
+
th({})(p(strong('2'))),
|
|
193
|
+
th({})(p(strong('3'))),
|
|
194
|
+
th({})(p(strong('4'))),
|
|
195
|
+
th({})(p(strong('5'))),
|
|
196
|
+
),
|
|
197
|
+
tr(
|
|
198
|
+
td({})(p('c')),
|
|
199
|
+
td({})(p('c')),
|
|
200
|
+
td({})(p()),
|
|
201
|
+
td({})(p('c')),
|
|
202
|
+
td({})(p()),
|
|
203
|
+
),
|
|
204
|
+
tr(
|
|
205
|
+
td({})(p('b')),
|
|
206
|
+
td({})(p()),
|
|
207
|
+
td({})(p('d')),
|
|
208
|
+
td({})(p()),
|
|
209
|
+
td({})(p('c')),
|
|
210
|
+
),
|
|
211
|
+
tr(
|
|
212
|
+
td({})(p()),
|
|
213
|
+
td({})(p('z')),
|
|
214
|
+
td({})(p()),
|
|
215
|
+
td({})(p()),
|
|
216
|
+
td({})(p('f')),
|
|
217
|
+
),
|
|
218
|
+
tr(
|
|
219
|
+
td({})(p('2')),
|
|
220
|
+
td({})(p()),
|
|
221
|
+
td({})(p()),
|
|
222
|
+
td({})(p()),
|
|
223
|
+
td({})(p()),
|
|
224
|
+
),
|
|
225
|
+
tr(
|
|
226
|
+
td({})(p('1')),
|
|
227
|
+
td({})(p()),
|
|
228
|
+
td({})(p('c')),
|
|
229
|
+
td({})(p()),
|
|
230
|
+
td({})(p()),
|
|
231
|
+
),
|
|
232
|
+
tr(
|
|
233
|
+
td({})(p('a')),
|
|
234
|
+
td({})(p()),
|
|
235
|
+
td({})(p()),
|
|
236
|
+
td({})(p()),
|
|
237
|
+
td({})(p()),
|
|
238
|
+
),
|
|
239
|
+
),
|
|
240
|
+
),
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
const sortByColumnCommand = sortByColumn(0, SortOrder.DESC);
|
|
244
|
+
|
|
245
|
+
sortByColumnCommand(editorView.state, editorView.dispatch);
|
|
246
|
+
|
|
247
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
248
|
+
doc(
|
|
249
|
+
table({
|
|
250
|
+
isNumberColumnEnabled: false,
|
|
251
|
+
layout: 'default',
|
|
252
|
+
localId: TABLE_LOCAL_ID,
|
|
253
|
+
})(
|
|
254
|
+
tr(
|
|
255
|
+
th({})(p(strong('1'))),
|
|
256
|
+
th({})(p(strong('2'))),
|
|
257
|
+
th({})(p(strong('3'))),
|
|
258
|
+
th({})(p(strong('4'))),
|
|
259
|
+
th({})(p(strong('5'))),
|
|
260
|
+
),
|
|
261
|
+
tr(
|
|
262
|
+
td({})(p('c')),
|
|
263
|
+
td({})(p('c')),
|
|
264
|
+
td({})(p()),
|
|
265
|
+
td({})(p('c')),
|
|
266
|
+
td({})(p()),
|
|
267
|
+
),
|
|
268
|
+
tr(
|
|
269
|
+
td({})(p('b')),
|
|
270
|
+
td({})(p()),
|
|
271
|
+
td({})(p('d')),
|
|
272
|
+
td({})(p()),
|
|
273
|
+
td({})(p('c')),
|
|
274
|
+
),
|
|
275
|
+
tr(
|
|
276
|
+
td({})(p('a')),
|
|
277
|
+
td({})(p()),
|
|
278
|
+
td({})(p()),
|
|
279
|
+
td({})(p()),
|
|
280
|
+
td({})(p()),
|
|
281
|
+
),
|
|
282
|
+
tr(
|
|
283
|
+
td({})(p('2')),
|
|
284
|
+
td({})(p()),
|
|
285
|
+
td({})(p()),
|
|
286
|
+
td({})(p()),
|
|
287
|
+
td({})(p()),
|
|
288
|
+
),
|
|
289
|
+
tr(
|
|
290
|
+
td({})(p('1')),
|
|
291
|
+
td({})(p()),
|
|
292
|
+
td({})(p('c')),
|
|
293
|
+
td({})(p()),
|
|
294
|
+
td({})(p()),
|
|
295
|
+
),
|
|
296
|
+
tr(
|
|
297
|
+
td({})(p()),
|
|
298
|
+
td({})(p('z')),
|
|
299
|
+
td({})(p()),
|
|
300
|
+
td({})(p()),
|
|
301
|
+
td({})(p('f')),
|
|
302
|
+
),
|
|
303
|
+
),
|
|
304
|
+
),
|
|
305
|
+
);
|
|
306
|
+
});
|
|
307
|
+
it('sorts the given column with header text in ascending order', () => {
|
|
308
|
+
const { editorView } = editor(
|
|
309
|
+
doc(
|
|
310
|
+
table({ isNumberColumnEnabled: false, layout: 'default' })(
|
|
311
|
+
tr(
|
|
312
|
+
th({})(h1(strong('asdasdasd'))),
|
|
313
|
+
th({})(p(strong('asdasd'))),
|
|
314
|
+
th({})(p(strong('sdfsdf'))),
|
|
315
|
+
th({})(p('sdfsdfsdf')),
|
|
316
|
+
th({})(p(strong('asdasda'))),
|
|
317
|
+
),
|
|
318
|
+
tr(
|
|
319
|
+
td({})(h1(strong('c'))),
|
|
320
|
+
td({})(p('cda')),
|
|
321
|
+
td({})(p()),
|
|
322
|
+
td({})(p('cz')),
|
|
323
|
+
td({})(p()),
|
|
324
|
+
),
|
|
325
|
+
tr(
|
|
326
|
+
td({})(h1(strong('b'))),
|
|
327
|
+
td({})(p()),
|
|
328
|
+
td({})(p('dfsf')),
|
|
329
|
+
td({})(p()),
|
|
330
|
+
td({})(p('cvsd')),
|
|
331
|
+
),
|
|
332
|
+
tr(
|
|
333
|
+
td({})(p(strong('a'))),
|
|
334
|
+
td({})(p('zc')),
|
|
335
|
+
td({})(p()),
|
|
336
|
+
td({})(p()),
|
|
337
|
+
td({})(p('fsdf')),
|
|
338
|
+
),
|
|
339
|
+
tr(
|
|
340
|
+
td({})(p(strong('2'))),
|
|
341
|
+
td({})(p()),
|
|
342
|
+
td({})(p()),
|
|
343
|
+
td({})(p()),
|
|
344
|
+
td({})(p()),
|
|
345
|
+
),
|
|
346
|
+
tr(
|
|
347
|
+
td({})(p(strong('1'))),
|
|
348
|
+
td({})(p()),
|
|
349
|
+
td({})(p('cxzcz')),
|
|
350
|
+
td({})(p()),
|
|
351
|
+
td({})(p()),
|
|
352
|
+
),
|
|
353
|
+
tr(
|
|
354
|
+
td({})(p()),
|
|
355
|
+
td({})(p()),
|
|
356
|
+
td({})(p()),
|
|
357
|
+
td({})(p('sdfs')),
|
|
358
|
+
td({})(p()),
|
|
359
|
+
),
|
|
360
|
+
),
|
|
361
|
+
),
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
const sortByColumnCommand = sortByColumn(0, SortOrder.ASC);
|
|
365
|
+
|
|
366
|
+
sortByColumnCommand(editorView.state, editorView.dispatch);
|
|
367
|
+
|
|
368
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
369
|
+
doc(
|
|
370
|
+
table({
|
|
371
|
+
isNumberColumnEnabled: false,
|
|
372
|
+
layout: 'default',
|
|
373
|
+
localId: TABLE_LOCAL_ID,
|
|
374
|
+
})(
|
|
375
|
+
tr(
|
|
376
|
+
th({})(h1(strong('asdasdasd'))),
|
|
377
|
+
th({})(p(strong('asdasd'))),
|
|
378
|
+
th({})(p(strong('sdfsdf'))),
|
|
379
|
+
th({})(p('sdfsdfsdf')),
|
|
380
|
+
th({})(p(strong('asdasda'))),
|
|
381
|
+
),
|
|
382
|
+
tr(
|
|
383
|
+
td({})(p(strong('1'))),
|
|
384
|
+
td({})(p()),
|
|
385
|
+
td({})(p('cxzcz')),
|
|
386
|
+
td({})(p()),
|
|
387
|
+
td({})(p()),
|
|
388
|
+
),
|
|
389
|
+
tr(
|
|
390
|
+
td({})(p(strong('2'))),
|
|
391
|
+
td({})(p()),
|
|
392
|
+
td({})(p()),
|
|
393
|
+
td({})(p()),
|
|
394
|
+
td({})(p()),
|
|
395
|
+
),
|
|
396
|
+
tr(
|
|
397
|
+
td({})(p(strong('a'))),
|
|
398
|
+
td({})(p('zc')),
|
|
399
|
+
td({})(p()),
|
|
400
|
+
td({})(p()),
|
|
401
|
+
td({})(p('fsdf')),
|
|
402
|
+
),
|
|
403
|
+
tr(
|
|
404
|
+
td({})(h1(strong('b'))),
|
|
405
|
+
td({})(p()),
|
|
406
|
+
td({})(p('dfsf')),
|
|
407
|
+
td({})(p()),
|
|
408
|
+
td({})(p('cvsd')),
|
|
409
|
+
),
|
|
410
|
+
tr(
|
|
411
|
+
td({})(h1(strong('c'))),
|
|
412
|
+
td({})(p('cda')),
|
|
413
|
+
td({})(p()),
|
|
414
|
+
td({})(p('cz')),
|
|
415
|
+
td({})(p()),
|
|
416
|
+
),
|
|
417
|
+
tr(
|
|
418
|
+
td({})(p()),
|
|
419
|
+
td({})(p()),
|
|
420
|
+
td({})(p()),
|
|
421
|
+
td({})(p('sdfs')),
|
|
422
|
+
td({})(p()),
|
|
423
|
+
),
|
|
424
|
+
),
|
|
425
|
+
),
|
|
426
|
+
);
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
describe('case sensitivity', () => {
|
|
430
|
+
describe('ascending order', () => {
|
|
431
|
+
it('sorts the given column', () => {
|
|
432
|
+
const { editorView } = editor(
|
|
433
|
+
doc(
|
|
434
|
+
table({ isNumberColumnEnabled: false, layout: 'default' })(
|
|
435
|
+
tr(th({})(p()), th({})(p())),
|
|
436
|
+
tr(td({})(p('A')), td({})(p('1'))),
|
|
437
|
+
tr(td({})(p('a')), td({})(p('2'))),
|
|
438
|
+
tr(td({})(p('b')), td({})(p('3'))),
|
|
439
|
+
tr(td({})(p('B')), td({})(p('4'))),
|
|
440
|
+
tr(td({})(p('bb')), td({})(p('5'))),
|
|
441
|
+
tr(td({})(p('Bb')), td({})(p('6'))),
|
|
442
|
+
),
|
|
443
|
+
),
|
|
444
|
+
);
|
|
445
|
+
|
|
446
|
+
const sortByColumnCommand = sortByColumn(0, SortOrder.ASC);
|
|
447
|
+
|
|
448
|
+
sortByColumnCommand(editorView.state, editorView.dispatch);
|
|
449
|
+
|
|
450
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
451
|
+
doc(
|
|
452
|
+
table({
|
|
453
|
+
isNumberColumnEnabled: false,
|
|
454
|
+
layout: 'default',
|
|
455
|
+
localId: TABLE_LOCAL_ID,
|
|
456
|
+
})(
|
|
457
|
+
tr(th({})(p()), th({})(p())),
|
|
458
|
+
tr(td({})(p('A')), td({})(p('1'))),
|
|
459
|
+
tr(td({})(p('a')), td({})(p('2'))),
|
|
460
|
+
tr(td({})(p('B')), td({})(p('4'))),
|
|
461
|
+
tr(td({})(p('b')), td({})(p('3'))),
|
|
462
|
+
tr(td({})(p('Bb')), td({})(p('6'))),
|
|
463
|
+
tr(td({})(p('bb')), td({})(p('5'))),
|
|
464
|
+
),
|
|
465
|
+
),
|
|
466
|
+
);
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
describe('descending order', () => {
|
|
471
|
+
it('sorts the given column', () => {
|
|
472
|
+
const { editorView } = editor(
|
|
473
|
+
doc(
|
|
474
|
+
table({ isNumberColumnEnabled: false, layout: 'default' })(
|
|
475
|
+
tr(th({})(p()), th({})(p())),
|
|
476
|
+
tr(td({})(p('A')), td({})(p('1'))),
|
|
477
|
+
tr(td({})(p('a')), td({})(p('2'))),
|
|
478
|
+
tr(td({})(p('b')), td({})(p('3'))),
|
|
479
|
+
tr(td({})(p('B')), td({})(p('4'))),
|
|
480
|
+
tr(td({})(p('bb')), td({})(p('5'))),
|
|
481
|
+
tr(td({})(p('Bb')), td({})(p('6'))),
|
|
482
|
+
),
|
|
483
|
+
),
|
|
484
|
+
);
|
|
485
|
+
|
|
486
|
+
const sortByColumnCommand = sortByColumn(0, SortOrder.DESC);
|
|
487
|
+
|
|
488
|
+
sortByColumnCommand(editorView.state, editorView.dispatch);
|
|
489
|
+
|
|
490
|
+
expect(editorView.state.doc).toEqualDocument(
|
|
491
|
+
doc(
|
|
492
|
+
table({
|
|
493
|
+
isNumberColumnEnabled: false,
|
|
494
|
+
layout: 'default',
|
|
495
|
+
localId: TABLE_LOCAL_ID,
|
|
496
|
+
})(
|
|
497
|
+
tr(th({})(p()), th({})(p())),
|
|
498
|
+
tr(td({})(p('bb')), td({})(p('5'))),
|
|
499
|
+
tr(td({})(p('Bb')), td({})(p('6'))),
|
|
500
|
+
tr(td({})(p('b')), td({})(p('3'))),
|
|
501
|
+
tr(td({})(p('B')), td({})(p('4'))),
|
|
502
|
+
tr(td({})(p('a')), td({})(p('2'))),
|
|
503
|
+
tr(td({})(p('A')), td({})(p('1'))),
|
|
504
|
+
),
|
|
505
|
+
),
|
|
506
|
+
);
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
});
|