@atlaskit/editor-plugin-table 2.0.1 → 2.1.1
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 +12 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/version.json +1 -1
- package/package.json +5 -6
- 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/.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
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
LightEditorPlugin,
|
|
15
15
|
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
16
16
|
import dispatchPasteEvent from '@atlaskit/editor-test-helpers/dispatch-paste-event';
|
|
17
|
-
import sendKeyToPm from '@atlaskit/editor-test-helpers/send-key-to-pm';
|
|
18
17
|
import {
|
|
19
18
|
doc,
|
|
20
19
|
p,
|
|
@@ -42,7 +41,6 @@ import { pluginKey as tablePluginKey } from '../../plugins/table/pm-plugins/plug
|
|
|
42
41
|
import { transformSliceToRemoveOpenExpand } from '@atlaskit/editor-common/transforms';
|
|
43
42
|
import { Schema } from 'prosemirror-model';
|
|
44
43
|
import tablePlugin from '../../plugins/table-plugin';
|
|
45
|
-
import undoRedoPlugin from '@atlaskit/editor-core/src/plugins/undo-redo';
|
|
46
44
|
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
47
45
|
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
48
46
|
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
@@ -109,8 +107,7 @@ describe('table plugin', () => {
|
|
|
109
107
|
.add([analyticsPlugin, {}])
|
|
110
108
|
.add(contentInsertionPlugin)
|
|
111
109
|
.add(widthPlugin)
|
|
112
|
-
.add([tablePlugin, { tableOptions }])
|
|
113
|
-
.add(undoRedoPlugin);
|
|
110
|
+
.add([tablePlugin, { tableOptions }]);
|
|
114
111
|
|
|
115
112
|
const editor = (doc: DocBuilder) => {
|
|
116
113
|
return createEditor<TablePluginState, PluginKey>({
|
|
@@ -325,22 +322,6 @@ describe('table plugin', () => {
|
|
|
325
322
|
),
|
|
326
323
|
);
|
|
327
324
|
});
|
|
328
|
-
|
|
329
|
-
it('should undo copy-paste with 1 undo operation', () => {
|
|
330
|
-
sendKeyToPm(editorView, 'Mod-z');
|
|
331
|
-
|
|
332
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
333
|
-
doc(
|
|
334
|
-
p('hello'),
|
|
335
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
336
|
-
tr(th()(p()), th()(p()), th()(p())),
|
|
337
|
-
tr(td()(p()), td()(p('world')), td()(p())),
|
|
338
|
-
tr(td()(p()), td()(p()), td()(p())),
|
|
339
|
-
),
|
|
340
|
-
p('{<>}'),
|
|
341
|
-
),
|
|
342
|
-
);
|
|
343
|
-
});
|
|
344
325
|
});
|
|
345
326
|
|
|
346
327
|
describe('when copying from text inside a table cell to text outside table and then pasting', () => {
|
|
@@ -384,22 +365,6 @@ describe('table plugin', () => {
|
|
|
384
365
|
),
|
|
385
366
|
);
|
|
386
367
|
});
|
|
387
|
-
|
|
388
|
-
it('should undo copy-paste with 1 undo operation', () => {
|
|
389
|
-
sendKeyToPm(editorView, 'Mod-z');
|
|
390
|
-
|
|
391
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
392
|
-
doc(
|
|
393
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
394
|
-
tr(th()(p()), th()(p()), th()(p())),
|
|
395
|
-
tr(td()(p()), td()(p('hello')), td()(p('more'))),
|
|
396
|
-
tr(td()(p()), td()(p()), td()(p())),
|
|
397
|
-
),
|
|
398
|
-
p('world'),
|
|
399
|
-
p('{<>}'),
|
|
400
|
-
),
|
|
401
|
-
);
|
|
402
|
-
});
|
|
403
368
|
});
|
|
404
369
|
});
|
|
405
370
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MediaAttributes } from '@atlaskit/adf-schema';
|
|
2
1
|
import { TextSelection } from 'prosemirror-state';
|
|
3
2
|
import {
|
|
4
3
|
createProsemirrorEditorFactory,
|
|
@@ -11,17 +10,13 @@ import {
|
|
|
11
10
|
td,
|
|
12
11
|
tr,
|
|
13
12
|
tdEmpty,
|
|
14
|
-
thEmpty,
|
|
15
13
|
tdCursor,
|
|
16
14
|
DocBuilder,
|
|
17
|
-
media,
|
|
18
|
-
mediaGroup,
|
|
19
15
|
p,
|
|
20
16
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
21
17
|
import {
|
|
22
18
|
handleMouseOver,
|
|
23
19
|
handleMouseMove,
|
|
24
|
-
handleClick,
|
|
25
20
|
} from '../../plugins/table/event-handlers';
|
|
26
21
|
import {
|
|
27
22
|
showInsertColumnButton,
|
|
@@ -34,9 +29,6 @@ import {
|
|
|
34
29
|
import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
35
30
|
import { TableCssClassName as ClassName } from '../../plugins/table/types';
|
|
36
31
|
import tablePlugin from '../../plugins/table-plugin';
|
|
37
|
-
import mediaPlugin from '@atlaskit/editor-core/src/plugins/media';
|
|
38
|
-
import floatingToolbarPlugin from '@atlaskit/editor-core/src/plugins/floating-toolbar';
|
|
39
|
-
import editorDisabledPlugin from '@atlaskit/editor-core/src/plugins/editor-disabled';
|
|
40
32
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
41
33
|
import { gridPlugin } from '@atlaskit/editor-plugin-grid';
|
|
42
34
|
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
@@ -168,21 +160,12 @@ describe('table event handlers', () => {
|
|
|
168
160
|
attachTo: document.body,
|
|
169
161
|
preset: new Preset<LightEditorPlugin>()
|
|
170
162
|
.add([featureFlagsPlugin, {}])
|
|
171
|
-
.add(editorDisabledPlugin)
|
|
172
163
|
.add([analyticsPlugin, {}])
|
|
173
164
|
.add(contentInsertionPlugin)
|
|
174
165
|
.add(decorationsPlugin)
|
|
175
166
|
.add(widthPlugin)
|
|
176
167
|
.add(gridPlugin)
|
|
177
|
-
.add(tablePlugin)
|
|
178
|
-
.add(floatingToolbarPlugin)
|
|
179
|
-
.add([
|
|
180
|
-
mediaPlugin,
|
|
181
|
-
{
|
|
182
|
-
allowMediaSingle: true,
|
|
183
|
-
allowMediaGroup: true,
|
|
184
|
-
},
|
|
185
|
-
]),
|
|
168
|
+
.add(tablePlugin),
|
|
186
169
|
pluginKey,
|
|
187
170
|
});
|
|
188
171
|
|
|
@@ -243,99 +226,4 @@ describe('table event handlers', () => {
|
|
|
243
226
|
});
|
|
244
227
|
});
|
|
245
228
|
});
|
|
246
|
-
|
|
247
|
-
describe('#handleClick', () => {
|
|
248
|
-
describe('clicking on media group node', () => {
|
|
249
|
-
describe('when on last cell of middle row', () => {
|
|
250
|
-
describe('when last element is media group node', () => {
|
|
251
|
-
it('should insert a new paragraph node', () => {
|
|
252
|
-
const testCollectionName = 'media-plugin-mock-collection-random-id';
|
|
253
|
-
const fileId = 'random-id';
|
|
254
|
-
const mediaAttrs: MediaAttributes = {
|
|
255
|
-
id: fileId,
|
|
256
|
-
type: 'file',
|
|
257
|
-
collection: testCollectionName,
|
|
258
|
-
};
|
|
259
|
-
const tableAttrs = { localId: 'table' };
|
|
260
|
-
|
|
261
|
-
const { editorView } = editor(
|
|
262
|
-
doc(
|
|
263
|
-
table(tableAttrs)(
|
|
264
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
265
|
-
tr(tdEmpty, tdEmpty, td()(mediaGroup(media(mediaAttrs)()))),
|
|
266
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
267
|
-
),
|
|
268
|
-
),
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
const firstCell = editorView.domAtPos(27);
|
|
272
|
-
const event = {
|
|
273
|
-
target: firstCell.node,
|
|
274
|
-
};
|
|
275
|
-
expect(handleClick(editorView, event as any)).toEqual(true);
|
|
276
|
-
|
|
277
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
278
|
-
doc(
|
|
279
|
-
table(tableAttrs)(
|
|
280
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
281
|
-
tr(
|
|
282
|
-
tdEmpty,
|
|
283
|
-
tdEmpty,
|
|
284
|
-
td()(mediaGroup(media(mediaAttrs)()), p()),
|
|
285
|
-
),
|
|
286
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
287
|
-
),
|
|
288
|
-
),
|
|
289
|
-
);
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
describe('when last element is not media group node', () => {
|
|
294
|
-
it('should not insert a new paragraph node', () => {
|
|
295
|
-
const testCollectionName = 'media-plugin-mock-collection-random-id';
|
|
296
|
-
const fileId = 'random-id';
|
|
297
|
-
const mediaAttrs: MediaAttributes = {
|
|
298
|
-
id: fileId,
|
|
299
|
-
type: 'file',
|
|
300
|
-
collection: testCollectionName,
|
|
301
|
-
};
|
|
302
|
-
const tableAttrs = { localId: 'table' };
|
|
303
|
-
const { editorView } = editor(
|
|
304
|
-
doc(
|
|
305
|
-
table(tableAttrs)(
|
|
306
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
307
|
-
tr(
|
|
308
|
-
tdEmpty,
|
|
309
|
-
tdEmpty,
|
|
310
|
-
td()(mediaGroup(media(mediaAttrs)()), p()),
|
|
311
|
-
),
|
|
312
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
313
|
-
),
|
|
314
|
-
),
|
|
315
|
-
);
|
|
316
|
-
|
|
317
|
-
const firstCell = editorView.domAtPos(27);
|
|
318
|
-
const event = {
|
|
319
|
-
target: firstCell.node,
|
|
320
|
-
};
|
|
321
|
-
expect(handleClick(editorView, event as any)).toEqual(true);
|
|
322
|
-
|
|
323
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
324
|
-
doc(
|
|
325
|
-
table(tableAttrs)(
|
|
326
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
327
|
-
tr(
|
|
328
|
-
tdEmpty,
|
|
329
|
-
tdEmpty,
|
|
330
|
-
td()(mediaGroup(media(mediaAttrs)()), p()),
|
|
331
|
-
),
|
|
332
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
333
|
-
),
|
|
334
|
-
),
|
|
335
|
-
);
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
229
|
});
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
table,
|
|
7
7
|
tdCursor,
|
|
8
8
|
tdEmpty,
|
|
9
|
-
dataConsumer,
|
|
10
|
-
extension,
|
|
11
9
|
DocBuilder,
|
|
12
10
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
13
11
|
|
|
@@ -21,8 +19,6 @@ import tablePlugin from '../../plugins/table';
|
|
|
21
19
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
22
20
|
import { getToolbarConfig } from '../../plugins/table/toolbar';
|
|
23
21
|
import { setTableRef, setEditorFocus } from '../../plugins/table/commands';
|
|
24
|
-
import extensionPlugin from '@atlaskit/editor-core/src/plugins/extension';
|
|
25
|
-
import dataConsumerPlugin from '@atlaskit/editor-core/src/plugins/data-consumer';
|
|
26
22
|
import type {
|
|
27
23
|
FloatingToolbarItem,
|
|
28
24
|
FloatingToolbarButton,
|
|
@@ -83,8 +79,6 @@ describe('getToolbarConfig', () => {
|
|
|
83
79
|
.add(contentInsertionPlugin)
|
|
84
80
|
.add(decorationsPlugin)
|
|
85
81
|
.add(widthPlugin)
|
|
86
|
-
.add(dataConsumerPlugin)
|
|
87
|
-
.add(extensionPlugin)
|
|
88
82
|
.add(tablePlugin),
|
|
89
83
|
});
|
|
90
84
|
|
|
@@ -122,27 +116,4 @@ describe('getToolbarConfig', () => {
|
|
|
122
116
|
expect(button.confirmDialog).toBeUndefined();
|
|
123
117
|
});
|
|
124
118
|
});
|
|
125
|
-
|
|
126
|
-
describe('should add confirmDialog to delete button', () => {
|
|
127
|
-
it('if localId defined and is referenced', () => {
|
|
128
|
-
const { editorView } = createEditor(
|
|
129
|
-
doc(
|
|
130
|
-
p('text'),
|
|
131
|
-
table({ localId: 'ILY300' })(tr(tdCursor, tdEmpty)),
|
|
132
|
-
dataConsumer({ sources: ['ILY300'] })(
|
|
133
|
-
extension({
|
|
134
|
-
extensionKey: 'test-key-123',
|
|
135
|
-
extensionType: 'com.atlassian.extensions.update',
|
|
136
|
-
parameters: { count: 0 },
|
|
137
|
-
layout: 'default',
|
|
138
|
-
localId: 'testId0',
|
|
139
|
-
})(),
|
|
140
|
-
),
|
|
141
|
-
),
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
const button = getButton(editorView);
|
|
145
|
-
expect(typeof button.confirmDialog).toBe('function');
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
119
|
});
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
Preset,
|
|
12
12
|
LightEditorPlugin,
|
|
13
13
|
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
14
|
-
import randomId from '@atlaskit/editor-test-helpers/random-id';
|
|
15
14
|
|
|
16
15
|
import {
|
|
17
16
|
doc,
|
|
@@ -21,14 +20,10 @@ import {
|
|
|
21
20
|
tr,
|
|
22
21
|
td,
|
|
23
22
|
th,
|
|
24
|
-
ul,
|
|
25
|
-
li,
|
|
26
23
|
tdEmpty,
|
|
27
24
|
tdCursor,
|
|
28
25
|
thCursor,
|
|
29
|
-
strong,
|
|
30
26
|
mediaGroup,
|
|
31
|
-
mediaSingle,
|
|
32
27
|
media,
|
|
33
28
|
DocBuilder,
|
|
34
29
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
@@ -51,25 +46,16 @@ import {
|
|
|
51
46
|
checkIfHeaderColumnEnabled,
|
|
52
47
|
checkIfHeaderRowEnabled,
|
|
53
48
|
} from '../../plugins/table/utils';
|
|
54
|
-
|
|
55
|
-
import textFormattingPlugin from '@atlaskit/editor-core/src/plugins/text-formatting';
|
|
56
|
-
import deprecatedAnalyticsPlugin from '@atlaskit/editor-core/src/plugins/analytics';
|
|
49
|
+
|
|
57
50
|
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
58
|
-
import mediaPlugin from '@atlaskit/editor-core/src/plugins/media';
|
|
59
|
-
import editorDisabledPlugin from '@atlaskit/editor-core/src/plugins/editor-disabled';
|
|
60
|
-
import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
|
|
61
|
-
import floatingToolbarPlugin from '@atlaskit/editor-core/src/plugins/floating-toolbar';
|
|
62
51
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
63
52
|
import { gridPlugin } from '@atlaskit/editor-plugin-grid';
|
|
64
|
-
import { insertMediaAsMediaSingle } from '@atlaskit/editor-core/src/plugins/media/utils/media-single';
|
|
65
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
66
53
|
import { getPluginState } from '../../plugins/table/pm-plugins/plugin-factory';
|
|
67
54
|
import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
68
55
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
69
56
|
import tablePlugin from '../../plugins/table-plugin';
|
|
70
57
|
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
71
58
|
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
72
|
-
import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
73
59
|
|
|
74
60
|
const TABLE_LOCAL_ID = 'test-table-local-id';
|
|
75
61
|
|
|
@@ -101,18 +87,10 @@ describe('table plugin', () => {
|
|
|
101
87
|
const preset = new Preset<LightEditorPlugin>()
|
|
102
88
|
.add([featureFlagsPlugin, {}])
|
|
103
89
|
.add([analyticsPlugin, {}])
|
|
104
|
-
.add([deprecatedAnalyticsPlugin, {}])
|
|
105
|
-
.add(editorDisabledPlugin)
|
|
106
|
-
.add(contentInsertionPlugin)
|
|
107
|
-
.add(decorationsPlugin)
|
|
108
90
|
.add(widthPlugin)
|
|
109
91
|
.add(gridPlugin)
|
|
110
|
-
.add(
|
|
111
|
-
.add(
|
|
112
|
-
.add([mediaPlugin, { allowMediaSingle: true }])
|
|
113
|
-
.add(textFormattingPlugin)
|
|
114
|
-
.add(listPlugin)
|
|
115
|
-
.add(selectionPlugin);
|
|
92
|
+
.add(contentInsertionPlugin)
|
|
93
|
+
.add([tablePlugin, { tableOptions }]);
|
|
116
94
|
|
|
117
95
|
return createEditor({
|
|
118
96
|
doc,
|
|
@@ -136,25 +114,6 @@ describe('table plugin', () => {
|
|
|
136
114
|
expect(editorView.state.doc).toEqualDocument(doc(tableNode));
|
|
137
115
|
});
|
|
138
116
|
});
|
|
139
|
-
|
|
140
|
-
describe('when selection has a mark', () => {
|
|
141
|
-
it('it should create a new table and return true', () => {
|
|
142
|
-
const { editorView } = editor(doc(p(strong('text{<>}'))));
|
|
143
|
-
expect(createTable()(editorView.state, editorView.dispatch)).toEqual(
|
|
144
|
-
true,
|
|
145
|
-
);
|
|
146
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
147
|
-
doc(
|
|
148
|
-
p(strong('text')),
|
|
149
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
150
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
151
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
152
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
153
|
-
),
|
|
154
|
-
),
|
|
155
|
-
);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
117
|
});
|
|
159
118
|
|
|
160
119
|
describe('insertColumn(number)', () => {
|
|
@@ -868,63 +827,6 @@ describe('table plugin', () => {
|
|
|
868
827
|
});
|
|
869
828
|
});
|
|
870
829
|
|
|
871
|
-
describe('when images is inside lists in table', () => {
|
|
872
|
-
const testCollectionName = `media-plugin-mock-collection-${randomId()}`;
|
|
873
|
-
const temporaryFileId = `temporary:${randomId()}`;
|
|
874
|
-
|
|
875
|
-
it('inserts image as single', () => {
|
|
876
|
-
const { editorView } = editor(
|
|
877
|
-
doc(
|
|
878
|
-
p('1'),
|
|
879
|
-
table()(
|
|
880
|
-
tr(td()(p('2'), ul(li(p('3{<>}'))))),
|
|
881
|
-
tr(tdEmpty),
|
|
882
|
-
tr(tdEmpty),
|
|
883
|
-
),
|
|
884
|
-
),
|
|
885
|
-
);
|
|
886
|
-
|
|
887
|
-
insertMediaAsMediaSingle(
|
|
888
|
-
editorView,
|
|
889
|
-
media({
|
|
890
|
-
id: temporaryFileId,
|
|
891
|
-
type: 'file',
|
|
892
|
-
collection: testCollectionName,
|
|
893
|
-
__fileMimeType: 'image/png',
|
|
894
|
-
})()(editorView.state.schema),
|
|
895
|
-
INPUT_METHOD.PICKER_CLOUD,
|
|
896
|
-
);
|
|
897
|
-
|
|
898
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
899
|
-
doc(
|
|
900
|
-
p('1'),
|
|
901
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
902
|
-
tr(
|
|
903
|
-
td()(
|
|
904
|
-
p('2'),
|
|
905
|
-
ul(
|
|
906
|
-
li(
|
|
907
|
-
p('3'),
|
|
908
|
-
mediaSingle()(
|
|
909
|
-
media({
|
|
910
|
-
id: temporaryFileId,
|
|
911
|
-
type: 'file',
|
|
912
|
-
collection: testCollectionName,
|
|
913
|
-
__fileMimeType: 'image/png',
|
|
914
|
-
})(),
|
|
915
|
-
),
|
|
916
|
-
),
|
|
917
|
-
),
|
|
918
|
-
),
|
|
919
|
-
),
|
|
920
|
-
tr(tdEmpty),
|
|
921
|
-
tr(tdEmpty),
|
|
922
|
-
),
|
|
923
|
-
),
|
|
924
|
-
);
|
|
925
|
-
});
|
|
926
|
-
});
|
|
927
|
-
|
|
928
830
|
describe('checkIfNumberColumnEnabled', () => {
|
|
929
831
|
it('should return false if table is not in focus', () => {
|
|
930
832
|
const { editorView } = editor(
|
|
@@ -4,20 +4,13 @@ import {
|
|
|
4
4
|
Preset,
|
|
5
5
|
LightEditorPlugin,
|
|
6
6
|
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
7
|
-
import { bodiedExtensionData } from '@atlaskit/editor-test-helpers/mock-extension-data';
|
|
8
7
|
|
|
9
8
|
import {
|
|
10
9
|
doc,
|
|
11
|
-
p,
|
|
12
10
|
table,
|
|
13
11
|
tr,
|
|
14
|
-
td,
|
|
15
|
-
th,
|
|
16
12
|
tdCursor,
|
|
17
13
|
tdEmpty,
|
|
18
|
-
bodiedExtension,
|
|
19
|
-
layoutSection,
|
|
20
|
-
layoutColumn,
|
|
21
14
|
DocBuilder,
|
|
22
15
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
23
16
|
|
|
@@ -27,13 +20,9 @@ import {
|
|
|
27
20
|
TablePluginState,
|
|
28
21
|
} from '../../plugins/table/types';
|
|
29
22
|
import { toggleTableLayout } from '../../plugins/table/commands';
|
|
30
|
-
import { isLayoutSupported } from '../../plugins/table/utils';
|
|
31
23
|
import { getPluginState } from '../../plugins/table/pm-plugins/plugin-factory';
|
|
32
24
|
import { pluginKey as tablePluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
33
25
|
import tablePlugin from '../../plugins/table-plugin';
|
|
34
|
-
import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
|
|
35
|
-
import extensionPlugin from '@atlaskit/editor-core/src/plugins/extension';
|
|
36
|
-
import layoutPlugin from '@atlaskit/editor-core/src/plugins/layout';
|
|
37
26
|
import { PluginKey } from 'prosemirror-state';
|
|
38
27
|
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
39
28
|
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
@@ -56,10 +45,7 @@ describe('table toolbar', () => {
|
|
|
56
45
|
.add(contentInsertionPlugin)
|
|
57
46
|
.add(decorationsPlugin)
|
|
58
47
|
.add(widthPlugin)
|
|
59
|
-
.add([tablePlugin, { tableOptions }])
|
|
60
|
-
.add(expandPlugin)
|
|
61
|
-
.add(extensionPlugin)
|
|
62
|
-
.add(layoutPlugin);
|
|
48
|
+
.add([tablePlugin, { tableOptions }]);
|
|
63
49
|
|
|
64
50
|
const editor = (doc: DocBuilder) => {
|
|
65
51
|
return createEditor<TablePluginState, PluginKey>({
|
|
@@ -154,53 +140,4 @@ describe('table toolbar', () => {
|
|
|
154
140
|
expect(tableElement.getAttribute('data-layout')).toBe('full-width');
|
|
155
141
|
});
|
|
156
142
|
});
|
|
157
|
-
|
|
158
|
-
describe('#isLayoutSupported', () => {
|
|
159
|
-
(['default', 'wide', 'full-width'] as TableLayout[]).forEach((layout) => {
|
|
160
|
-
describe(`when called with "${layout}"`, () => {
|
|
161
|
-
it('returns true if permittedLayouts="all"', () => {
|
|
162
|
-
const { editorView } = editor(
|
|
163
|
-
doc(
|
|
164
|
-
table()(
|
|
165
|
-
tr(th()(p('{<>}1')), th()(p('2'))),
|
|
166
|
-
tr(td()(p('3')), td()(p('4'))),
|
|
167
|
-
),
|
|
168
|
-
),
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
expect(isLayoutSupported(editorView.state)).toBe(true);
|
|
172
|
-
});
|
|
173
|
-
it('returns false if table is nested in bodiedExtension', () => {
|
|
174
|
-
const { editorView } = editor(
|
|
175
|
-
doc(
|
|
176
|
-
bodiedExtension(bodiedExtensionData[0].attrs)(
|
|
177
|
-
table()(
|
|
178
|
-
tr(th()(p('{<>}1')), th()(p('2'))),
|
|
179
|
-
tr(td()(p('3')), td()(p('4'))),
|
|
180
|
-
),
|
|
181
|
-
),
|
|
182
|
-
),
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
expect(isLayoutSupported(editorView.state)).toBe(false);
|
|
186
|
-
});
|
|
187
|
-
it('returns false if table is nested in Columns', () => {
|
|
188
|
-
const { editorView } = editor(
|
|
189
|
-
doc(
|
|
190
|
-
layoutSection(
|
|
191
|
-
layoutColumn({ width: 50 })(
|
|
192
|
-
table()(
|
|
193
|
-
tr(th()(p('{<>}1')), th()(p('2'))),
|
|
194
|
-
tr(td()(p('3')), td()(p('4'))),
|
|
195
|
-
),
|
|
196
|
-
),
|
|
197
|
-
layoutColumn({ width: 50 })(p('text')),
|
|
198
|
-
),
|
|
199
|
-
),
|
|
200
|
-
);
|
|
201
|
-
expect(isLayoutSupported(editorView.state)).toBe(false);
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
143
|
});
|
|
@@ -15,8 +15,6 @@ import {
|
|
|
15
15
|
td,
|
|
16
16
|
tdEmpty,
|
|
17
17
|
DocBuilder,
|
|
18
|
-
thEmpty,
|
|
19
|
-
th,
|
|
20
18
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
21
19
|
import {
|
|
22
20
|
tableBackgroundColorNames,
|
|
@@ -24,13 +22,9 @@ import {
|
|
|
24
22
|
uuid,
|
|
25
23
|
} from '@atlaskit/adf-schema';
|
|
26
24
|
import { PluginConfig } from '../../../plugins/table/types';
|
|
27
|
-
import { mergeCells } from '../../../plugins/table/transforms';
|
|
28
25
|
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
29
26
|
import TableCellViews from '../../../plugins/table/nodeviews/tableCell';
|
|
30
|
-
import sendKeyToPm from '@atlaskit/editor-test-helpers/send-key-to-pm';
|
|
31
|
-
import * as domHelpers from '../../../plugins/table/pm-plugins/sticky-headers/nodeviews/dom';
|
|
32
27
|
import tablePlugin from '../../../plugins/table-plugin';
|
|
33
|
-
import undoRedoPlugin from '@atlaskit/editor-core/src/plugins/undo-redo';
|
|
34
28
|
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
35
29
|
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
36
30
|
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
@@ -56,8 +50,7 @@ describe('table -> nodeviews -> tableCell.tsx', () => {
|
|
|
56
50
|
.add([analyticsPlugin, {}])
|
|
57
51
|
.add(contentInsertionPlugin)
|
|
58
52
|
.add(widthPlugin)
|
|
59
|
-
.add([tablePlugin, { tableOptions: { advanced: true, ...props } }])
|
|
60
|
-
.add(undoRedoPlugin),
|
|
53
|
+
.add([tablePlugin, { tableOptions: { advanced: true, ...props } }]),
|
|
61
54
|
pluginKey,
|
|
62
55
|
});
|
|
63
56
|
|
|
@@ -128,45 +121,5 @@ describe('table -> nodeviews -> tableCell.tsx', () => {
|
|
|
128
121
|
const cellDomNode = document.querySelector('td')!;
|
|
129
122
|
expect(rgbToHex(cellDomNode.style.backgroundColor!)).toEqual(background);
|
|
130
123
|
});
|
|
131
|
-
|
|
132
|
-
it('should preserve the correct rowspan and colspan after merge cells and undo', () => {
|
|
133
|
-
jest.spyOn(domHelpers, 'getTop').mockImplementation(() => 0);
|
|
134
|
-
|
|
135
|
-
const originalDoc = doc(
|
|
136
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
137
|
-
tr(th()(p('{<cell}')), thEmpty, thEmpty),
|
|
138
|
-
tr(td()(p('{cell>}')), tdEmpty, tdEmpty),
|
|
139
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
140
|
-
),
|
|
141
|
-
);
|
|
142
|
-
const { editorView } = editor(originalDoc, {
|
|
143
|
-
stickyHeaders: true,
|
|
144
|
-
});
|
|
145
|
-
const { state, dispatch } = editorView;
|
|
146
|
-
|
|
147
|
-
dispatch(mergeCells(state.tr));
|
|
148
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
149
|
-
doc(
|
|
150
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
151
|
-
tr(th({ rowspan: 2 })(p('')), thEmpty, thEmpty),
|
|
152
|
-
tr(tdEmpty, tdEmpty),
|
|
153
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
154
|
-
),
|
|
155
|
-
),
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
sendKeyToPm(editorView, 'Mod-z');
|
|
159
|
-
validateUnmergedDomCells();
|
|
160
|
-
expect(editorView.state.doc).toEqualDocument(originalDoc);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// make sure all colspan/rowspan attributes are removed from cells
|
|
164
|
-
function validateUnmergedDomCells() {
|
|
165
|
-
const cells = document.querySelectorAll('table td, table th');
|
|
166
|
-
Array.from(cells).forEach((cell) => {
|
|
167
|
-
expect(cell.getAttribute('rowspan')).toBeFalsy();
|
|
168
|
-
expect(cell.getAttribute('colspan')).toBeFalsy();
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
124
|
});
|
|
172
125
|
});
|
|
@@ -16,7 +16,6 @@ import { Selection } from 'prosemirror-state';
|
|
|
16
16
|
import * as pmUtils from 'prosemirror-utils';
|
|
17
17
|
|
|
18
18
|
import tablePlugin from '../../../plugins/table';
|
|
19
|
-
import textFormattingPlugin from '@atlaskit/editor-core/src/plugins/text-formatting';
|
|
20
19
|
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
21
20
|
import { getPluginState } from '../../../plugins/table/pm-plugins/plugin-factory';
|
|
22
21
|
import { setEditorFocus } from '../../../plugins/table/commands/misc';
|
|
@@ -43,8 +42,7 @@ describe('tables: main plugin', () => {
|
|
|
43
42
|
.add([analyticsPlugin, {}])
|
|
44
43
|
.add(contentInsertionPlugin)
|
|
45
44
|
.add(widthPlugin)
|
|
46
|
-
.add(tablePlugin)
|
|
47
|
-
.add(textFormattingPlugin),
|
|
45
|
+
.add(tablePlugin),
|
|
48
46
|
pluginKey,
|
|
49
47
|
});
|
|
50
48
|
const tablePluginKey = (pluginKey as any).key;
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
tr,
|
|
11
11
|
td,
|
|
12
12
|
p,
|
|
13
|
-
panel,
|
|
14
13
|
DocBuilder,
|
|
15
14
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
16
15
|
import {
|
|
@@ -21,9 +20,8 @@ import {
|
|
|
21
20
|
|
|
22
21
|
import tablePlugin from '../../../../plugins/table';
|
|
23
22
|
import { pluginKey } from '../../../../plugins/table/pm-plugins/plugin-key';
|
|
24
|
-
import { TextSelection,
|
|
23
|
+
import { TextSelection, EditorState } from 'prosemirror-state';
|
|
25
24
|
import { EditorView } from 'prosemirror-view';
|
|
26
|
-
import panelPlugin from '@atlaskit/editor-core/src/plugins/panel';
|
|
27
25
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
28
26
|
import {
|
|
29
27
|
akEditorFullPageMaxWidth,
|
|
@@ -63,8 +61,7 @@ describe('table-resizing/event-handlers', () => {
|
|
|
63
61
|
{
|
|
64
62
|
tableOptions: { allowColumnResizing: true },
|
|
65
63
|
},
|
|
66
|
-
])
|
|
67
|
-
.add(panelPlugin),
|
|
64
|
+
]),
|
|
68
65
|
pluginKey,
|
|
69
66
|
});
|
|
70
67
|
});
|
|
@@ -150,21 +147,6 @@ describe('table-resizing/event-handlers', () => {
|
|
|
150
147
|
expect(currentSelection instanceof TextSelection).toBeTruthy();
|
|
151
148
|
expect(currentSelection.$cursor.pos).toBe(15);
|
|
152
149
|
});
|
|
153
|
-
|
|
154
|
-
it('should restore node selection after replacing the table', async () => {
|
|
155
|
-
const { editorView: view } = editor(
|
|
156
|
-
doc(table()(tr(td()(panel()(p(''))), td()(p('2')), td()(p('3'))))),
|
|
157
|
-
);
|
|
158
|
-
const _tr = view.state.tr.setSelection(
|
|
159
|
-
NodeSelection.create(view.state.tr.doc, 3),
|
|
160
|
-
);
|
|
161
|
-
view.dispatch(_tr);
|
|
162
|
-
expect(view.state.tr.selection.node.type.name).toBe('panel');
|
|
163
|
-
|
|
164
|
-
resizeColumn(view, 13, 150, 250);
|
|
165
|
-
|
|
166
|
-
expect(view.state.tr.selection.node.type.name).toBe('panel');
|
|
167
|
-
});
|
|
168
150
|
});
|
|
169
151
|
});
|
|
170
152
|
|