@atlaskit/editor-plugin-table 2.0.0 → 2.1.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/CHANGELOG.md +13 -0
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +7 -3
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +23 -19
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +2 -1
- package/dist/cjs/plugins/table/nodeviews/table.js +5 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +7 -3
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +22 -18
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +3 -2
- package/dist/es2019/plugins/table/nodeviews/table.js +5 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +7 -3
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +23 -19
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +3 -2
- package/dist/esm/plugins/table/nodeviews/table.js +5 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +5 -3
- package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +5 -3
- package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +2 -1
- package/package.json +4 -7
- package/src/__tests__/integration/layout.ts +1 -6
- package/src/__tests__/unit/analytics.ts +0 -21
- package/src/__tests__/unit/commands/misc.ts +0 -2
- package/src/__tests__/unit/commands/sort.ts +0 -131
- package/src/__tests__/unit/commands.ts +2 -264
- package/src/__tests__/unit/copy-paste.ts +1 -36
- package/src/__tests__/unit/event-handlers.ts +1 -113
- package/src/__tests__/unit/get-toolbar-config.ts +0 -29
- package/src/__tests__/unit/index.ts +3 -101
- package/src/__tests__/unit/layout.ts +1 -64
- package/src/__tests__/unit/nodeviews/cell.ts +1 -48
- package/src/__tests__/unit/pm-plugins/main.ts +1 -3
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +2 -20
- package/src/__tests__/unit/sort-column.ts +21 -148
- package/src/__tests__/unit/utils/collapse.ts +3 -39
- package/src/plugins/table/nodeviews/TableComponent.tsx +10 -4
- package/src/plugins/table/nodeviews/TableContainer.tsx +28 -19
- package/src/plugins/table/nodeviews/TableResizer.tsx +3 -2
- package/src/plugins/table/nodeviews/table.tsx +6 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/scale-table.ts +10 -1
- package/.eslintrc.js +0 -37
- package/src/__tests__/unit/color-picker.ts +0 -110
- package/src/__tests__/unit/floating-toolbar.ts +0 -95
- package/src/__tests__/unit/keymap.ts +0 -609
- package/src/__tests__/unit/pm-plugins/main-with-allow-collapse.ts +0 -110
- package/src/__tests__/unit/pm-plugins/table-selection-keymap.ts +0 -574
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createProsemirrorEditorFactory,
|
|
3
|
-
LightEditorPlugin,
|
|
4
|
-
Preset,
|
|
5
|
-
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
6
|
-
import {
|
|
7
|
-
doc,
|
|
8
|
-
p,
|
|
9
|
-
table,
|
|
10
|
-
tdCursor,
|
|
11
|
-
tdEmpty,
|
|
12
|
-
tr,
|
|
13
|
-
expand,
|
|
14
|
-
bodiedExtension,
|
|
15
|
-
DocBuilder,
|
|
16
|
-
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
17
|
-
|
|
18
|
-
import tablePlugin from '../../../plugins/table';
|
|
19
|
-
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
20
|
-
import { TablePluginState } from '../../../plugins/table/types';
|
|
21
|
-
import { handleDocOrSelectionChanged } from '../../../plugins/table/handlers';
|
|
22
|
-
import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
|
|
23
|
-
import extensionPlugin from '@atlaskit/editor-core/src/plugins/extension';
|
|
24
|
-
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
25
|
-
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
26
|
-
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
27
|
-
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
28
|
-
import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
29
|
-
|
|
30
|
-
describe('tables: main plugin with allowCollapse: true', () => {
|
|
31
|
-
const createEditor = createProsemirrorEditorFactory();
|
|
32
|
-
const editor = (doc: DocBuilder) =>
|
|
33
|
-
createEditor({
|
|
34
|
-
doc,
|
|
35
|
-
preset: new Preset<LightEditorPlugin>()
|
|
36
|
-
.add([featureFlagsPlugin, {}])
|
|
37
|
-
.add([analyticsPlugin, {}])
|
|
38
|
-
.add(contentInsertionPlugin)
|
|
39
|
-
.add(decorationsPlugin)
|
|
40
|
-
.add(widthPlugin)
|
|
41
|
-
.add(tablePlugin)
|
|
42
|
-
.add(expandPlugin)
|
|
43
|
-
.add(extensionPlugin),
|
|
44
|
-
pluginKey,
|
|
45
|
-
});
|
|
46
|
-
const baseTablePluginState: TablePluginState = {
|
|
47
|
-
editorHasFocus: true,
|
|
48
|
-
hoveredColumns: [],
|
|
49
|
-
hoveredRows: [],
|
|
50
|
-
pluginConfig: {
|
|
51
|
-
allowCollapse: true,
|
|
52
|
-
},
|
|
53
|
-
isHeaderColumnEnabled: false,
|
|
54
|
-
isHeaderRowEnabled: true,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
it.each<[string, DocBuilder, object]>([
|
|
58
|
-
[
|
|
59
|
-
'should set canCollapseTable & !isTableCollapsed when table is on doc',
|
|
60
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
61
|
-
{
|
|
62
|
-
canCollapseTable: true,
|
|
63
|
-
isTableCollapsed: false,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
[
|
|
67
|
-
'should set !canCollapseTable & isTableCollapsed when table is in expand',
|
|
68
|
-
doc(
|
|
69
|
-
expand({ title: '' })(
|
|
70
|
-
table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty)),
|
|
71
|
-
),
|
|
72
|
-
),
|
|
73
|
-
{
|
|
74
|
-
canCollapseTable: false,
|
|
75
|
-
isTableCollapsed: true,
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
[
|
|
79
|
-
'should set !canCollapseTable & !isTableCollapsed when table is in bodiedExtension',
|
|
80
|
-
doc(
|
|
81
|
-
bodiedExtension({
|
|
82
|
-
extensionKey: 'bodied-eh',
|
|
83
|
-
extensionType: 'com.floofs',
|
|
84
|
-
})(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
85
|
-
p(),
|
|
86
|
-
),
|
|
87
|
-
{
|
|
88
|
-
canCollapseTable: false,
|
|
89
|
-
isTableCollapsed: false,
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
])('%s', (_, docBuilder, expected) => {
|
|
93
|
-
const { editorView } = editor(docBuilder);
|
|
94
|
-
const pluginState = {
|
|
95
|
-
...baseTablePluginState,
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const oldState = handleDocOrSelectionChanged(
|
|
99
|
-
editorView.state.tr,
|
|
100
|
-
pluginState,
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
const newState = handleDocOrSelectionChanged(editorView.state.tr, oldState);
|
|
104
|
-
|
|
105
|
-
expect(newState).toEqual({
|
|
106
|
-
...oldState,
|
|
107
|
-
...expected,
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
});
|
|
@@ -1,574 +0,0 @@
|
|
|
1
|
-
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
2
|
-
import { EditorView } from 'prosemirror-view';
|
|
3
|
-
import { PluginKey } from 'prosemirror-state';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
createProsemirrorEditorFactory,
|
|
7
|
-
LightEditorPlugin,
|
|
8
|
-
Preset,
|
|
9
|
-
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
10
|
-
import {
|
|
11
|
-
doc,
|
|
12
|
-
table,
|
|
13
|
-
tr,
|
|
14
|
-
td,
|
|
15
|
-
p,
|
|
16
|
-
panel,
|
|
17
|
-
code_block as codeBlock,
|
|
18
|
-
DocBuilder,
|
|
19
|
-
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
20
|
-
import sendKeyToPm from '@atlaskit/editor-test-helpers/send-key-to-pm';
|
|
21
|
-
import { uuid } from '@atlaskit/adf-schema';
|
|
22
|
-
|
|
23
|
-
import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
|
|
24
|
-
import panelPlugin from '@atlaskit/editor-core/src/plugins/panel';
|
|
25
|
-
import codeBlockPlugin from '@atlaskit/editor-core/src/plugins/code-block';
|
|
26
|
-
import tablePlugin from '../../../plugins/table';
|
|
27
|
-
import { TablePluginState } from '../../../plugins/table/types';
|
|
28
|
-
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
29
|
-
import { createEditorSelectionAPI } from '@atlaskit/editor-core/src/selection-api/api';
|
|
30
|
-
import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
31
|
-
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
32
|
-
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
33
|
-
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
34
|
-
import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
35
|
-
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
36
|
-
|
|
37
|
-
const TABLE_LOCAL_ID = 'test-table-local-id';
|
|
38
|
-
describe('table selection keymap', () => {
|
|
39
|
-
const editorSelectionAPI: EditorSelectionAPI = createEditorSelectionAPI();
|
|
40
|
-
beforeAll(() => {
|
|
41
|
-
uuid.setStatic(TABLE_LOCAL_ID);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
afterAll(() => {
|
|
45
|
-
uuid.setStatic(false);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const createEditor = createProsemirrorEditorFactory();
|
|
49
|
-
const preset = new Preset<LightEditorPlugin>()
|
|
50
|
-
.add([featureFlagsPlugin, {}])
|
|
51
|
-
.add([analyticsPlugin, {}])
|
|
52
|
-
.add(contentInsertionPlugin)
|
|
53
|
-
.add(decorationsPlugin)
|
|
54
|
-
.add(selectionPlugin)
|
|
55
|
-
.add(widthPlugin)
|
|
56
|
-
.add([tablePlugin, { tableOptions: {}, editorSelectionAPI }])
|
|
57
|
-
.add(panelPlugin)
|
|
58
|
-
.add([codeBlockPlugin, { appearance: 'full-page' }]);
|
|
59
|
-
|
|
60
|
-
const editor = (doc: DocBuilder) =>
|
|
61
|
-
createEditor<TablePluginState, PluginKey>({
|
|
62
|
-
doc,
|
|
63
|
-
preset,
|
|
64
|
-
pluginKey,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const selectTable = (anchorCell: number, headCell: number) => {
|
|
68
|
-
const cellSelection = CellSelection.create(
|
|
69
|
-
editorView.state.doc,
|
|
70
|
-
anchorCell,
|
|
71
|
-
headCell,
|
|
72
|
-
);
|
|
73
|
-
editorView.dispatch(editorView.state.tr.setSelection(cellSelection as any));
|
|
74
|
-
expect(editorView.state.selection).toBeInstanceOf(CellSelection);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
let editorView: EditorView;
|
|
78
|
-
let refs: { [ref: string]: number };
|
|
79
|
-
|
|
80
|
-
describe('Arrow right keypress', () => {
|
|
81
|
-
describe('from left side gap cursor selection', () => {
|
|
82
|
-
beforeEach(() => {
|
|
83
|
-
({ editorView } = editor(
|
|
84
|
-
doc(
|
|
85
|
-
'{<gap|>}',
|
|
86
|
-
table()(
|
|
87
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
88
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
89
|
-
),
|
|
90
|
-
),
|
|
91
|
-
));
|
|
92
|
-
sendKeyToPm(editorView, 'ArrowRight');
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('sets cell selection for whole table when user hits right arrow', () => {
|
|
96
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
97
|
-
doc(
|
|
98
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
99
|
-
tr(td()(p('{cell>}1')), td()(p('2')), td()(p('3'))),
|
|
100
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6{<cell}'))),
|
|
101
|
-
),
|
|
102
|
-
),
|
|
103
|
-
);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe('to text selection', () => {
|
|
107
|
-
it('sets selection at start of first cell when user hits right arrow twice', () => {
|
|
108
|
-
({ editorView } = editor(
|
|
109
|
-
doc(
|
|
110
|
-
'{<gap|>}',
|
|
111
|
-
table()(
|
|
112
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
113
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
114
|
-
),
|
|
115
|
-
),
|
|
116
|
-
));
|
|
117
|
-
sendKeyToPm(editorView, 'ArrowRight');
|
|
118
|
-
sendKeyToPm(editorView, 'ArrowRight');
|
|
119
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
120
|
-
doc(
|
|
121
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
122
|
-
tr(td()(p('{<>}1')), td()(p('2')), td()(p('3'))),
|
|
123
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
124
|
-
),
|
|
125
|
-
),
|
|
126
|
-
);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
describe('to gap cursor selection', () => {
|
|
131
|
-
it('sets left-side gap cursor selection at start of first cell when user hits right arrow twice', () => {
|
|
132
|
-
({ editorView } = editor(
|
|
133
|
-
doc(
|
|
134
|
-
'{<gap|>}',
|
|
135
|
-
table()(
|
|
136
|
-
tr(td()(panel()(p('1'))), td()(p('2')), td()(p('3'))),
|
|
137
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
138
|
-
),
|
|
139
|
-
),
|
|
140
|
-
));
|
|
141
|
-
sendKeyToPm(editorView, 'ArrowRight');
|
|
142
|
-
sendKeyToPm(editorView, 'ArrowRight');
|
|
143
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
144
|
-
doc(
|
|
145
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
146
|
-
tr(
|
|
147
|
-
td()('{<gap|>}', panel()(p('1'))),
|
|
148
|
-
td()(p('2')),
|
|
149
|
-
td()(p('3')),
|
|
150
|
-
),
|
|
151
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
152
|
-
),
|
|
153
|
-
),
|
|
154
|
-
);
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
describe('from last position of last cell', () => {
|
|
160
|
-
describe('for text selection', () => {
|
|
161
|
-
beforeEach(() => {
|
|
162
|
-
({ editorView } = editor(
|
|
163
|
-
doc(
|
|
164
|
-
table()(
|
|
165
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
166
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6{<>}'))),
|
|
167
|
-
),
|
|
168
|
-
),
|
|
169
|
-
));
|
|
170
|
-
sendKeyToPm(editorView, 'ArrowRight');
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('sets cell selection for whole table when user hits right arrow', () => {
|
|
174
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
175
|
-
doc(
|
|
176
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
177
|
-
tr(td()(p('{<cell}1')), td()(p('2')), td()(p('3'))),
|
|
178
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6{cell>}'))),
|
|
179
|
-
),
|
|
180
|
-
),
|
|
181
|
-
);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('sets right side gap cursor when user hits right arrow twice', () => {
|
|
185
|
-
sendKeyToPm(editorView, 'ArrowRight');
|
|
186
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
187
|
-
doc(
|
|
188
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
189
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
190
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
191
|
-
),
|
|
192
|
-
'{<|gap>}',
|
|
193
|
-
),
|
|
194
|
-
);
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
describe('for text selection inside child node', () => {
|
|
199
|
-
it("doesn't set cell selection for whole table when user hits right arrow", () => {
|
|
200
|
-
({ editorView } = editor(
|
|
201
|
-
doc(
|
|
202
|
-
table()(
|
|
203
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
204
|
-
tr(td()(p('4')), td()(p('5')), td()(codeBlock()('6{<>}'))),
|
|
205
|
-
),
|
|
206
|
-
),
|
|
207
|
-
));
|
|
208
|
-
sendKeyToPm(editorView, 'ArrowRight');
|
|
209
|
-
|
|
210
|
-
expect(editorView.state.selection).not.toBeInstanceOf(CellSelection);
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe('for node selection', () => {
|
|
215
|
-
it('sets right side gap cursor on node when user hits right arrow', () => {
|
|
216
|
-
({ editorView } = editor(
|
|
217
|
-
doc(
|
|
218
|
-
table()(
|
|
219
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
220
|
-
tr(td()(p('4')), td()(p('5')), td()('{<node>}', panel()(p()))),
|
|
221
|
-
),
|
|
222
|
-
),
|
|
223
|
-
));
|
|
224
|
-
sendKeyToPm(editorView, 'ArrowRight');
|
|
225
|
-
|
|
226
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
227
|
-
doc(
|
|
228
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
229
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
230
|
-
tr(td()(p('4')), td()(p('5')), td()(panel()(p()), '{<|gap>}')),
|
|
231
|
-
),
|
|
232
|
-
),
|
|
233
|
-
);
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
describe('for gap cursor selection', () => {
|
|
238
|
-
beforeEach(() => {
|
|
239
|
-
({ editorView } = editor(
|
|
240
|
-
doc(
|
|
241
|
-
table()(
|
|
242
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
243
|
-
tr(
|
|
244
|
-
td()(p('4')),
|
|
245
|
-
td()(p('5')),
|
|
246
|
-
td()(panel()(p('6')), '{<|gap>}'),
|
|
247
|
-
),
|
|
248
|
-
),
|
|
249
|
-
),
|
|
250
|
-
));
|
|
251
|
-
sendKeyToPm(editorView, 'ArrowRight');
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('sets cell selection for whole table when user hits right arrow', () => {
|
|
255
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
256
|
-
doc(
|
|
257
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
258
|
-
tr(td()(p('{<cell}1')), td()(p('2')), td()(p('3'))),
|
|
259
|
-
tr(td()(p('4')), td()(p('5')), td()(panel()(p('6{cell>}')))),
|
|
260
|
-
),
|
|
261
|
-
),
|
|
262
|
-
);
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
it('sets right side gap cursor when user hits right arrow twice', () => {
|
|
266
|
-
sendKeyToPm(editorView, 'ArrowRight');
|
|
267
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
268
|
-
doc(
|
|
269
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
270
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
271
|
-
tr(td()(p('4')), td()(p('5')), td()(panel()(p('6')))),
|
|
272
|
-
),
|
|
273
|
-
'{<|gap>}',
|
|
274
|
-
),
|
|
275
|
-
);
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
describe('after clicking table controls to select whole table', () => {
|
|
281
|
-
it('sets right side gap cursor when user hits right arrow', () => {
|
|
282
|
-
({ editorView, refs } = editor(
|
|
283
|
-
doc(
|
|
284
|
-
table()(
|
|
285
|
-
tr('{firstCell}', td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
286
|
-
tr(td()(p('4')), td()(p('5')), '{lastCell}', td()(p('6'))),
|
|
287
|
-
),
|
|
288
|
-
),
|
|
289
|
-
));
|
|
290
|
-
selectTable(refs.lastCell, refs.firstCell);
|
|
291
|
-
sendKeyToPm(editorView, 'ArrowRight');
|
|
292
|
-
|
|
293
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
294
|
-
doc(
|
|
295
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
296
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
297
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
298
|
-
),
|
|
299
|
-
'{<|gap>}',
|
|
300
|
-
),
|
|
301
|
-
);
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
describe('Arrow left keypress', () => {
|
|
307
|
-
describe('from right side gap cursor selection', () => {
|
|
308
|
-
beforeEach(() => {
|
|
309
|
-
({ editorView } = editor(
|
|
310
|
-
doc(
|
|
311
|
-
table()(
|
|
312
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
313
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
314
|
-
),
|
|
315
|
-
'{<|gap>}',
|
|
316
|
-
),
|
|
317
|
-
));
|
|
318
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it('sets cell selection for whole table when user hits left arrow', () => {
|
|
322
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
323
|
-
doc(
|
|
324
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
325
|
-
tr(td()(p('{<cell}1')), td()(p('2')), td()(p('3'))),
|
|
326
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6{cell>}'))),
|
|
327
|
-
),
|
|
328
|
-
),
|
|
329
|
-
);
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
describe('to text selection', () => {
|
|
333
|
-
it('sets selection at end of last cell when user hits left arrow twice', () => {
|
|
334
|
-
({ editorView } = editor(
|
|
335
|
-
doc(
|
|
336
|
-
table()(
|
|
337
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
338
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
339
|
-
),
|
|
340
|
-
'{<|gap>}',
|
|
341
|
-
),
|
|
342
|
-
));
|
|
343
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
344
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
345
|
-
|
|
346
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
347
|
-
doc(
|
|
348
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
349
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
350
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6{<>}'))),
|
|
351
|
-
),
|
|
352
|
-
),
|
|
353
|
-
);
|
|
354
|
-
});
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
describe('to gap cursor selection', () => {
|
|
358
|
-
it('sets right-side gap cursor selection at end of last cell when user hits left arrow twice', () => {
|
|
359
|
-
({ editorView } = editor(
|
|
360
|
-
doc(
|
|
361
|
-
table()(
|
|
362
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
363
|
-
tr(td()(p('4')), td()(p('5')), td()(panel()(p('6')))),
|
|
364
|
-
),
|
|
365
|
-
'{<|gap>}',
|
|
366
|
-
),
|
|
367
|
-
));
|
|
368
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
369
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
370
|
-
|
|
371
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
372
|
-
doc(
|
|
373
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
374
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
375
|
-
tr(
|
|
376
|
-
td()(p('4')),
|
|
377
|
-
td()(p('5')),
|
|
378
|
-
td()(panel()(p('6')), '{<|gap>}'),
|
|
379
|
-
),
|
|
380
|
-
),
|
|
381
|
-
),
|
|
382
|
-
);
|
|
383
|
-
});
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
describe('from start position of first cell', () => {
|
|
388
|
-
describe('for text selection', () => {
|
|
389
|
-
beforeEach(() => {
|
|
390
|
-
({ editorView } = editor(
|
|
391
|
-
doc(
|
|
392
|
-
table()(
|
|
393
|
-
tr(td()(p('{<>}1')), td()(p('2')), td()(p('3'))),
|
|
394
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
395
|
-
),
|
|
396
|
-
),
|
|
397
|
-
));
|
|
398
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
it('sets cell selection for whole table when user hits left arrow', () => {
|
|
402
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
403
|
-
doc(
|
|
404
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
405
|
-
tr(td()(p('{cell>}1')), td()(p('2')), td()(p('3'))),
|
|
406
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6{<cell}'))),
|
|
407
|
-
),
|
|
408
|
-
),
|
|
409
|
-
);
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
it('sets left side gap cursor when user hits left arrow twice', () => {
|
|
413
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
414
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
415
|
-
doc(
|
|
416
|
-
'{<gap|>}',
|
|
417
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
418
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
419
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
420
|
-
),
|
|
421
|
-
),
|
|
422
|
-
);
|
|
423
|
-
});
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
describe('for text selection inside child node', () => {
|
|
427
|
-
it("doesn't set cell selection for whole table when user hits left arrow", () => {
|
|
428
|
-
({ editorView } = editor(
|
|
429
|
-
doc(
|
|
430
|
-
table()(
|
|
431
|
-
tr(td()(codeBlock()('{<>}1')), td()(p('2')), td()(p('3'))),
|
|
432
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
433
|
-
),
|
|
434
|
-
),
|
|
435
|
-
));
|
|
436
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
437
|
-
|
|
438
|
-
expect(editorView.state.selection).not.toBeInstanceOf(CellSelection);
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
describe('for gap cursor selection', () => {
|
|
443
|
-
beforeEach(() => {
|
|
444
|
-
({ editorView } = editor(
|
|
445
|
-
doc(
|
|
446
|
-
table()(
|
|
447
|
-
tr(
|
|
448
|
-
td()('{<gap|>}', panel()(p('1'))),
|
|
449
|
-
td()(p('2')),
|
|
450
|
-
td()(p('3')),
|
|
451
|
-
),
|
|
452
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
453
|
-
),
|
|
454
|
-
),
|
|
455
|
-
));
|
|
456
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
it('sets cell selection for whole table when user hits left arrow', () => {
|
|
460
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
461
|
-
doc(
|
|
462
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
463
|
-
tr(td()(panel()(p('{cell>}1'))), td()(p('2')), td()(p('3'))),
|
|
464
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6{<cell}'))),
|
|
465
|
-
),
|
|
466
|
-
),
|
|
467
|
-
);
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
it('sets left side gap cursor when user hits left arrow twice', () => {
|
|
471
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
472
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
473
|
-
doc(
|
|
474
|
-
'{<gap|>}',
|
|
475
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
476
|
-
tr(td()(panel()(p('1'))), td()(p('2')), td()(p('3'))),
|
|
477
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
478
|
-
),
|
|
479
|
-
),
|
|
480
|
-
);
|
|
481
|
-
});
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
describe('after clicking table controls to select whole table', () => {
|
|
486
|
-
describe('for table containing text in first cell', () => {
|
|
487
|
-
beforeEach(() => {
|
|
488
|
-
({ editorView, refs } = editor(
|
|
489
|
-
doc(
|
|
490
|
-
table()(
|
|
491
|
-
tr('{firstCell}', td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
492
|
-
tr(td()(p('4')), td()(p('5')), '{lastCell}', td()(p('6'))),
|
|
493
|
-
),
|
|
494
|
-
),
|
|
495
|
-
));
|
|
496
|
-
selectTable(refs.lastCell, refs.firstCell);
|
|
497
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
it('sets selection at start of first cell when user hits left arrow', () => {
|
|
501
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
502
|
-
doc(
|
|
503
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
504
|
-
tr(td()(p('{<>}1')), td()(p('2')), td()(p('3'))),
|
|
505
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
506
|
-
),
|
|
507
|
-
),
|
|
508
|
-
);
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
it('sets left side gap cursor when user hits left arrow twice', () => {
|
|
512
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
513
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
514
|
-
doc(
|
|
515
|
-
'{<gap|>}',
|
|
516
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
517
|
-
tr(td()(p('1')), td()(p('2')), td()(p('3'))),
|
|
518
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
519
|
-
),
|
|
520
|
-
),
|
|
521
|
-
);
|
|
522
|
-
});
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
describe('for table containing node in first cell', () => {
|
|
526
|
-
beforeEach(() => {
|
|
527
|
-
({ editorView, refs } = editor(
|
|
528
|
-
doc(
|
|
529
|
-
table()(
|
|
530
|
-
tr(
|
|
531
|
-
'{firstCell}',
|
|
532
|
-
td()(panel()(p('1'))),
|
|
533
|
-
td()(p('2')),
|
|
534
|
-
td()(p('3')),
|
|
535
|
-
),
|
|
536
|
-
tr(td()(p('4')), td()(p('5')), '{lastCell}', td()(p('6'))),
|
|
537
|
-
),
|
|
538
|
-
),
|
|
539
|
-
));
|
|
540
|
-
selectTable(refs.lastCell, refs.firstCell);
|
|
541
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
542
|
-
});
|
|
543
|
-
|
|
544
|
-
it('sets selection at start of first cell when user hits left arrow', () => {
|
|
545
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
546
|
-
doc(
|
|
547
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
548
|
-
tr(
|
|
549
|
-
td()('{<gap|>}', panel()(p('1'))),
|
|
550
|
-
td()(p('2')),
|
|
551
|
-
td()(p('3')),
|
|
552
|
-
),
|
|
553
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
554
|
-
),
|
|
555
|
-
),
|
|
556
|
-
);
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
it('sets left side gap cursor when user hits left arrow twice', () => {
|
|
560
|
-
sendKeyToPm(editorView, 'ArrowLeft');
|
|
561
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
562
|
-
doc(
|
|
563
|
-
'{<gap|>}',
|
|
564
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
565
|
-
tr(td()(panel()(p('1'))), td()(p('2')), td()(p('3'))),
|
|
566
|
-
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
567
|
-
),
|
|
568
|
-
),
|
|
569
|
-
);
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
});
|
|
573
|
-
});
|
|
574
|
-
});
|