@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.
Files changed (50) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +7 -3
  3. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +23 -19
  4. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +2 -1
  5. package/dist/cjs/plugins/table/nodeviews/table.js +5 -1
  6. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
  7. package/dist/cjs/version.json +1 -1
  8. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +7 -3
  9. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +22 -18
  10. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +3 -2
  11. package/dist/es2019/plugins/table/nodeviews/table.js +5 -1
  12. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
  13. package/dist/es2019/version.json +1 -1
  14. package/dist/esm/plugins/table/nodeviews/TableComponent.js +7 -3
  15. package/dist/esm/plugins/table/nodeviews/TableContainer.js +23 -19
  16. package/dist/esm/plugins/table/nodeviews/TableResizer.js +3 -2
  17. package/dist/esm/plugins/table/nodeviews/table.js +5 -1
  18. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
  19. package/dist/esm/version.json +1 -1
  20. package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +5 -3
  21. package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +2 -1
  22. package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +5 -3
  23. package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +2 -1
  24. package/package.json +4 -7
  25. package/src/__tests__/integration/layout.ts +1 -6
  26. package/src/__tests__/unit/analytics.ts +0 -21
  27. package/src/__tests__/unit/commands/misc.ts +0 -2
  28. package/src/__tests__/unit/commands/sort.ts +0 -131
  29. package/src/__tests__/unit/commands.ts +2 -264
  30. package/src/__tests__/unit/copy-paste.ts +1 -36
  31. package/src/__tests__/unit/event-handlers.ts +1 -113
  32. package/src/__tests__/unit/get-toolbar-config.ts +0 -29
  33. package/src/__tests__/unit/index.ts +3 -101
  34. package/src/__tests__/unit/layout.ts +1 -64
  35. package/src/__tests__/unit/nodeviews/cell.ts +1 -48
  36. package/src/__tests__/unit/pm-plugins/main.ts +1 -3
  37. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +2 -20
  38. package/src/__tests__/unit/sort-column.ts +21 -148
  39. package/src/__tests__/unit/utils/collapse.ts +3 -39
  40. package/src/plugins/table/nodeviews/TableComponent.tsx +10 -4
  41. package/src/plugins/table/nodeviews/TableContainer.tsx +28 -19
  42. package/src/plugins/table/nodeviews/TableResizer.tsx +3 -2
  43. package/src/plugins/table/nodeviews/table.tsx +6 -0
  44. package/src/plugins/table/pm-plugins/table-resizing/utils/scale-table.ts +10 -1
  45. package/.eslintrc.js +0 -37
  46. package/src/__tests__/unit/color-picker.ts +0 -110
  47. package/src/__tests__/unit/floating-toolbar.ts +0 -95
  48. package/src/__tests__/unit/keymap.ts +0 -609
  49. package/src/__tests__/unit/pm-plugins/main-with-allow-collapse.ts +0 -110
  50. package/src/__tests__/unit/pm-plugins/table-selection-keymap.ts +0 -574
@@ -3,11 +3,12 @@ import { EditorView } from 'prosemirror-view';
3
3
  import { Node as PMNode } from 'prosemirror-model';
4
4
  interface TableResizerProps {
5
5
  width: number;
6
+ maxWidth: number;
6
7
  updateWidth: (width: number) => void;
7
8
  editorView: EditorView;
8
9
  getPos: () => number | undefined;
9
10
  node: PMNode;
10
11
  tableRef: HTMLTableElement;
11
12
  }
12
- export declare const TableResizer: ({ children, width, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
13
+ export declare const TableResizer: ({ children, width, maxWidth, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
13
14
  export {};
@@ -4,8 +4,10 @@ import { EditorView } from 'prosemirror-view';
4
4
  import { EditorContainerWidth } from '@atlaskit/editor-common/types';
5
5
  type InnerContainerProps = {
6
6
  className: string;
7
- marginLeft: number | undefined;
8
- width: number | 'inherit';
7
+ style?: {
8
+ width: number | 'inherit';
9
+ marginLeft: number | undefined;
10
+ };
9
11
  node: PMNode;
10
12
  };
11
13
  export declare const InnerContainer: React.ForwardRefExoticComponent<InnerContainerProps & {
@@ -20,7 +22,7 @@ type ResizableTableContainerProps = {
20
22
  getPos: () => number | undefined;
21
23
  tableRef: HTMLTableElement;
22
24
  };
23
- export declare const ResizableTableContainer: ({ children, className, node, lineLength, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
25
+ export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
24
26
  type TableContainerProps = {
25
27
  node: PMNode;
26
28
  className: string;
@@ -3,11 +3,12 @@ import { EditorView } from 'prosemirror-view';
3
3
  import { Node as PMNode } from 'prosemirror-model';
4
4
  interface TableResizerProps {
5
5
  width: number;
6
+ maxWidth: number;
6
7
  updateWidth: (width: number) => void;
7
8
  editorView: EditorView;
8
9
  getPos: () => number | undefined;
9
10
  node: PMNode;
10
11
  tableRef: HTMLTableElement;
11
12
  }
12
- export declare const TableResizer: ({ children, width, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
13
+ export declare const TableResizer: ({ children, width, maxWidth, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
13
14
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -27,8 +27,8 @@
27
27
  "releaseModel": "continuous"
28
28
  },
29
29
  "dependencies": {
30
- "@atlaskit/adf-schema": "^26.1.0",
31
- "@atlaskit/editor-common": "^74.15.0",
30
+ "@atlaskit/adf-schema": "^26.2.0",
31
+ "@atlaskit/editor-common": "^74.19.0",
32
32
  "@atlaskit/editor-palette": "1.5.1",
33
33
  "@atlaskit/editor-plugin-analytics": "^0.0.5",
34
34
  "@atlaskit/editor-plugin-content-insertion": "^0.0.5",
@@ -60,15 +60,12 @@
60
60
  "react-intl-next": "npm:react-intl@^5.18.1"
61
61
  },
62
62
  "devDependencies": {
63
- "@af/editor-libra": "*",
64
63
  "@atlaskit/analytics-next": "^9.1.0",
65
- "@atlaskit/editor-core": "^185.9.0",
66
64
  "@atlaskit/editor-plugin-decorations": "^0.1.0",
67
65
  "@atlaskit/editor-plugin-feature-flags": "^0.1.0",
68
66
  "@atlaskit/editor-plugin-grid": "^0.1.0",
69
67
  "@atlaskit/editor-plugin-width": "^0.1.0",
70
- "@atlaskit/editor-test-helpers": "^18.9.0",
71
- "@atlaskit/media-integration-test-helpers": "^3.0.0",
68
+ "@atlaskit/editor-test-helpers": "^18.10.0",
72
69
  "@atlaskit/visual-regression": "*",
73
70
  "@atlaskit/webdriver-runner": "*",
74
71
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
@@ -22,8 +22,6 @@ import {
22
22
  mountEditor,
23
23
  } from '@atlaskit/editor-test-helpers/testing-example-page';
24
24
 
25
- import messages from '@atlaskit/editor-core/src/messages';
26
-
27
25
  BrowserTestCase(
28
26
  'Avoid overflow when table scale to wide',
29
27
  { skip: ['safari', 'firefox'] },
@@ -175,10 +173,7 @@ BrowserTestCase(
175
173
 
176
174
  await page.waitForSelector('.extension-container p');
177
175
  await page.click('.extension-container p');
178
- await changeSelectedNodeLayout(
179
- page,
180
- messages.layoutFixedWidth.defaultMessage,
181
- );
176
+ await changeSelectedNodeLayout(page, 'Back to center');
182
177
  await animationFrame(page);
183
178
 
184
179
  const doc = await page.$eval(editable, getDocFromElement);
@@ -41,8 +41,6 @@ import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
41
41
  import { replaceSelectedTable } from '../../plugins/table/transforms';
42
42
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
43
43
  import tablePlugin from '../../plugins/table-plugin';
44
- import typeAheadPlugin from '@atlaskit/editor-core/src/plugins/type-ahead';
45
- import quickInsertPlugin from '@atlaskit/editor-core/src/plugins/quick-insert';
46
44
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
47
45
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
48
46
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
@@ -97,9 +95,7 @@ describe('Table analytic events', () => {
97
95
  analyticsPluginFake as unknown as typeof analyticsPlugin,
98
96
  { createAnalyticsEvent: jest.fn() },
99
97
  ])
100
- .add(typeAheadPlugin)
101
98
  .add(contentInsertionPlugin)
102
- .add(quickInsertPlugin)
103
99
  .add(widthPlugin)
104
100
  .add([tablePlugin, { tableOptions }]),
105
101
  pluginKey,
@@ -108,23 +104,6 @@ describe('Table analytic events', () => {
108
104
  return _editor;
109
105
  };
110
106
 
111
- describe('table inserted via quickInsert', () => {
112
- beforeEach(async () => {
113
- const { typeAheadTool } = editor(doc(p('{<>}')));
114
- typeAheadTool.searchQuickInsert('Table').insert({ index: 0 });
115
- });
116
-
117
- it('should fire v3 analytics', () => {
118
- expect(mockAttachPayload).toBeCalledWith({
119
- action: 'inserted',
120
- actionSubject: 'document',
121
- actionSubjectId: 'table',
122
- attributes: expect.objectContaining({ inputMethod: 'quickInsert' }),
123
- eventType: 'track',
124
- });
125
- });
126
- });
127
-
128
107
  describe('table deleted', () => {
129
108
  beforeEach(() => {
130
109
  const { editorView } = editor(defaultTableDoc);
@@ -14,7 +14,6 @@ import {
14
14
  LightEditorPlugin,
15
15
  createProsemirrorEditorFactory,
16
16
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
17
- import panelPlugin from '@atlaskit/editor-core/src/plugins/panel';
18
17
  import {
19
18
  selectColumn,
20
19
  moveCursorBackward,
@@ -39,7 +38,6 @@ describe('table plugin: commands', () => {
39
38
  .add([featureFlagsPlugin, {}])
40
39
  .add([analyticsPlugin, {}])
41
40
  .add(decorationsPlugin)
42
- .add(panelPlugin)
43
41
  .add(contentInsertionPlugin)
44
42
  .add(widthPlugin)
45
43
  .add([
@@ -10,21 +10,11 @@ import {
10
10
  td,
11
11
  th,
12
12
  tr,
13
- mention,
14
- date,
15
- a,
16
- status,
17
13
  } from '@atlaskit/editor-test-helpers/doc-builder';
18
- import { EditorView } from 'prosemirror-view';
19
14
  import { sortByColumn } from '../../../plugins/table/commands/sort';
20
15
  import { uuid } from '@atlaskit/adf-schema';
21
16
  import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
22
17
  import tablePlugin from '../../../plugins/table-plugin';
23
- import statusPlugin from '@atlaskit/editor-core/src/plugins/status';
24
- import mentionsPlugin from '@atlaskit/editor-core/src/plugins/mentions';
25
- import editorDisabledPlugin from '@atlaskit/editor-core/src/plugins/editor-disabled';
26
- import hyperlinkPlugin from '@atlaskit/editor-core/src/plugins/hyperlink';
27
- import datePlugin from '@atlaskit/editor-core/src/plugins/date';
28
18
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
29
19
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
30
20
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
@@ -122,125 +112,4 @@ describe('Sort Table', () => {
122
112
  ),
123
113
  );
124
114
  });
125
-
126
- describe('mixed content ordering', () => {
127
- let editorView: EditorView;
128
-
129
- beforeEach(() => {
130
- ({ editorView } = createEditor({
131
- preset: new Preset<LightEditorPlugin>()
132
- .add([featureFlagsPlugin, {}])
133
- .add([analyticsPlugin, {}])
134
- .add(contentInsertionPlugin)
135
- .add(editorDisabledPlugin)
136
- .add(widthPlugin)
137
- .add([tablePlugin, { tableOptions: { allowHeaderRow: true } }])
138
- .add([statusPlugin, { menuDisabled: false }])
139
- .add(mentionsPlugin)
140
- .add(hyperlinkPlugin)
141
- .add(datePlugin),
142
- doc: doc(
143
- table()(
144
- tr(th({})(p('Mixed{<>}'))),
145
- tr(td({})(p(a({ href: '' })('LinkB')))),
146
- tr(td({})(p('a1'))),
147
- tr(
148
- td({})(
149
- p(status({ text: 'statusB', color: '#FFF', localId: 'a' })),
150
- ),
151
- ),
152
- tr(td({})(p('10'))),
153
- tr(td({})(p('b1'))),
154
- tr(td({})(p(mention({ id: 'a', text: 'MentionA' })()))),
155
- tr(td({})(p('20'))),
156
- tr(
157
- td({})(p(date({ timestamp: new Date('2019-01-01').getTime() }))),
158
- ),
159
- tr(td({})(p(a({ href: '' })('LinkA')))),
160
- tr(td({})(p(mention({ id: 'a', text: 'MentionB' })()))),
161
- tr(
162
- td({})(
163
- p(status({ text: 'statusA', color: '#FFF', localId: 'a' })),
164
- ),
165
- ),
166
- tr(
167
- td({})(p(date({ timestamp: new Date('2020-01-01').getTime() }))),
168
- ),
169
- ),
170
- ),
171
- }));
172
- });
173
-
174
- it('should test a basic table ascending', () => {
175
- sortByColumn(0, SortOrder.ASC)(editorView.state, editorView.dispatch);
176
-
177
- expect(editorView.state.doc).toEqualDocument(
178
- doc(
179
- table({ localId: TABLE_LOCAL_ID })(
180
- tr(th({})(p('Mixed{<>}'))),
181
- tr(td({})(p('10'))),
182
- tr(td({})(p('20'))),
183
- tr(td({})(p('a1'))),
184
- tr(td({})(p('b1'))),
185
- tr(td({})(p(mention({ id: 'a', text: 'MentionA' })()))),
186
- tr(td({})(p(mention({ id: 'a', text: 'MentionB' })()))),
187
- tr(
188
- td({})(p(date({ timestamp: new Date('2019-01-01').getTime() }))),
189
- ),
190
- tr(
191
- td({})(p(date({ timestamp: new Date('2020-01-01').getTime() }))),
192
- ),
193
- tr(
194
- td({})(
195
- p(status({ text: 'statusA', color: '#FFF', localId: 'a' })),
196
- ),
197
- ),
198
- tr(
199
- td({})(
200
- p(status({ text: 'statusB', color: '#FFF', localId: 'a' })),
201
- ),
202
- ),
203
- tr(td({})(p(a({ href: '' })('LinkA')))),
204
- tr(td({})(p(a({ href: '' })('LinkB')))),
205
- ),
206
- ),
207
- );
208
- });
209
-
210
- it('should test a basic table descending', () => {
211
- sortByColumn(0, SortOrder.DESC)(editorView.state, editorView.dispatch);
212
-
213
- expect(editorView.state.doc).toEqualDocument(
214
- doc(
215
- table({ localId: TABLE_LOCAL_ID })(
216
- tr(th({})(p('Mixed{<>}'))),
217
- tr(td({})(p(a({ href: '' })('LinkB')))),
218
- tr(td({})(p(a({ href: '' })('LinkA')))),
219
- tr(
220
- td({})(
221
- p(status({ text: 'statusB', color: '#FFF', localId: 'a' })),
222
- ),
223
- ),
224
- tr(
225
- td({})(
226
- p(status({ text: 'statusA', color: '#FFF', localId: 'a' })),
227
- ),
228
- ),
229
- tr(
230
- td({})(p(date({ timestamp: new Date('2020-01-01').getTime() }))),
231
- ),
232
- tr(
233
- td({})(p(date({ timestamp: new Date('2019-01-01').getTime() }))),
234
- ),
235
- tr(td({})(p(mention({ id: 'a', text: 'MentionB' })()))),
236
- tr(td({})(p(mention({ id: 'a', text: 'MentionA' })()))),
237
- tr(td({})(p('b1'))),
238
- tr(td({})(p('a1'))),
239
- tr(td({})(p('20'))),
240
- tr(td({})(p('10'))),
241
- ),
242
- ),
243
- );
244
- });
245
- });
246
115
  });
@@ -21,24 +21,14 @@ import {
21
21
  tdCursor,
22
22
  tdEmpty,
23
23
  thCursor,
24
- thEmpty,
25
24
  th,
26
25
  tr,
27
- expand,
28
- bodiedExtension,
29
26
  DocBuilder,
30
27
  } from '@atlaskit/editor-test-helpers/doc-builder';
31
28
 
32
29
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
33
- import {
34
- getFreshMediaProvider,
35
- temporaryMediaGroup,
36
- } from '@atlaskit/editor-test-helpers/media-provider';
37
-
38
- import type { EditorProps } from '@atlaskit/editor-core';
39
30
  import {
40
31
  addBoldInEmptyHeaderCells,
41
- clearMultipleCells,
42
32
  selectColumn,
43
33
  selectRow,
44
34
  setEditorFocus,
@@ -50,21 +40,13 @@ import {
50
40
  transformSliceToAddTableHeaders,
51
41
  } from '../../plugins/table/commands';
52
42
  import { splitCell } from '../../plugins/table/commands/split-cell';
53
- import { wrapTableInExpand } from '../../plugins/table/commands/collapse';
54
43
  import { handleCut } from '../../plugins/table/event-handlers';
55
44
  import { getPluginState } from '../../plugins/table/pm-plugins/plugin-factory';
56
45
  import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
57
46
  import tablePlugin from '../../plugins/table';
58
- import editorDisabledPlugin from '@atlaskit/editor-core/src/plugins/editor-disabled';
59
- import panelPlugin from '@atlaskit/editor-core/src/plugins/panel';
60
- import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
61
- import extensionPlugin from '@atlaskit/editor-core/src/plugins/extension';
62
- import mediaPlugin from '@atlaskit/editor-core/src/plugins/media';
63
- import floatingToolbarPlugin from '@atlaskit/editor-core/src/plugins/floating-toolbar';
64
47
 
65
48
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
66
49
  import { gridPlugin } from '@atlaskit/editor-plugin-grid';
67
- import textFormattingPlugin from '@atlaskit/editor-core/src/plugins/text-formatting';
68
50
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
69
51
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
70
52
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
@@ -82,25 +64,18 @@ describe('table plugin: actions', () => {
82
64
  });
83
65
 
84
66
  const createEditor = createProsemirrorEditorFactory();
85
- const editor = (doc: DocBuilder, props: Partial<EditorProps> = {}) =>
67
+ const editor = (doc: DocBuilder) =>
86
68
  createEditor({
87
69
  doc,
88
70
  attachTo: document.body,
89
71
  preset: new Preset<LightEditorPlugin>()
90
72
  .add([featureFlagsPlugin, {}])
91
- .add(editorDisabledPlugin)
92
73
  .add([analyticsPlugin, {}])
93
74
  .add(contentInsertionPlugin)
94
75
  .add(decorationsPlugin)
95
76
  .add(widthPlugin)
96
77
  .add(gridPlugin)
97
- .add(tablePlugin)
98
- .add(panelPlugin)
99
- .add(textFormattingPlugin)
100
- .add(extensionPlugin)
101
- .add(floatingToolbarPlugin)
102
- .add([mediaPlugin, { allowMediaSingle: true }])
103
- .add(expandPlugin),
78
+ .add(tablePlugin),
104
79
  pluginKey,
105
80
  });
106
81
 
@@ -264,56 +239,6 @@ describe('table plugin: actions', () => {
264
239
  });
265
240
  });
266
241
 
267
- describe('#clearMultipleCells', () => {
268
- it('should empty selected cells', () => {
269
- const { editorView } = editor(
270
- doc(
271
- p('text'),
272
- table()(
273
- tr(td()(p('c1')), tdEmpty),
274
- tr(td()(panelNote(p('text'))), tdEmpty),
275
- ),
276
- ),
277
- );
278
- const { state, dispatch } = editorView;
279
- selectColumn(0)(state, dispatch);
280
- clearMultipleCells()(editorView.state, dispatch);
281
- expect(editorView.state.doc).toEqualDocument(
282
- doc(
283
- p('text'),
284
- table({ localId: TABLE_LOCAL_ID })(
285
- tr(tdEmpty, tdEmpty),
286
- tr(tdEmpty, tdEmpty),
287
- ),
288
- ),
289
- );
290
- });
291
-
292
- it('should empty cell with the cursor', () => {
293
- const { editorView } = editor(
294
- doc(
295
- p('text'),
296
- table()(
297
- tr(td()(p('c1')), tdEmpty),
298
- tr(td()(panelNote(p('te{<>}xt'))), tdEmpty),
299
- ),
300
- ),
301
- );
302
- const { state, dispatch } = editorView;
303
- clearMultipleCells(state.selection.$from.pos)(editorView.state, dispatch);
304
-
305
- expect(editorView.state.doc).toEqualDocument(
306
- doc(
307
- p('text'),
308
- table({ localId: TABLE_LOCAL_ID })(
309
- tr(td()(p('c1')), tdEmpty),
310
- tr(tdEmpty, tdEmpty),
311
- ),
312
- ),
313
- );
314
- });
315
- });
316
-
317
242
  describe('#setMultipleCellAttrs', () => {
318
243
  it('should set selected cell attributes', () => {
319
244
  const { editorView } = editor(
@@ -341,31 +266,6 @@ describe('table plugin: actions', () => {
341
266
  ),
342
267
  );
343
268
  });
344
- it('should set cell attributes if the cell has cursor', () => {
345
- const { editorView } = editor(
346
- doc(
347
- p('text'),
348
- table()(
349
- tr(tdEmpty, tdEmpty),
350
- tr(td()(panelNote(p('te{<>}xt'))), tdEmpty),
351
- ),
352
- ),
353
- );
354
- const { state, dispatch } = editorView;
355
- setMultipleCellAttrs({ colspan: 2 }, state.selection.$from.pos)(
356
- editorView.state,
357
- dispatch,
358
- );
359
- expect(editorView.state).toEqualDocumentAndSelection(
360
- doc(
361
- p('text'),
362
- table({ localId: TABLE_LOCAL_ID })(
363
- tr(tdEmpty, tdEmpty, tdEmpty),
364
- tr(td({ colspan: 2 })(panelNote(p('te{<>}xt'))), tdEmpty),
365
- ),
366
- ),
367
- );
368
- });
369
269
  });
370
270
 
371
271
  describe('#toggleContextualMenu', () => {
@@ -729,22 +629,6 @@ describe('table plugin: actions', () => {
729
629
  });
730
630
  describe('when the cursor is on table header cell', () => {
731
631
  describe('and the cell is empty', () => {
732
- it('should add strong mark on storedMarks', () => {
733
- const { editorView } = editor(
734
- doc(table()(tr(thCursor), tr(td()(p(''))))),
735
- );
736
- const { state, dispatch } = editorView;
737
-
738
- const tableCellHeader = findParentNodeOfType(
739
- state.schema.nodes.tableHeader,
740
- )(state.selection);
741
-
742
- addBoldInEmptyHeaderCells(tableCellHeader!)(state, dispatch);
743
- const result = editorView.state.storedMarks || [];
744
- expect(result.length).toBeGreaterThan(0);
745
- expect(result[0].type).toEqual(state.schema.marks.strong);
746
- });
747
-
748
632
  describe('and the user removed the strong mark', () => {
749
633
  it('should not add strong mark on storedMarks', () => {
750
634
  const { editorView } = editor(
@@ -849,151 +733,5 @@ describe('table plugin: actions', () => {
849
733
  ),
850
734
  );
851
735
  });
852
-
853
- it('should split cell with media selected', () => {
854
- const { editorView } = editor(
855
- doc(
856
- table()(
857
- tr(th()(p('')), th()(p('')), th()(p(''))),
858
- tr(
859
- td({ colspan: 2 })('{<node>}', temporaryMediaGroup),
860
- td()(p('')),
861
- ),
862
- ),
863
- ),
864
- {
865
- media: {
866
- allowMediaSingle: true,
867
- provider: getFreshMediaProvider(),
868
- },
869
- },
870
- );
871
-
872
- splitCell(editorView.state, editorView.dispatch);
873
-
874
- expect(editorView.state.doc).toEqualDocument(
875
- doc(
876
- table({ localId: TABLE_LOCAL_ID })(
877
- tr(th()(p('')), th()(p('')), th()(p(''))),
878
- tr(td()(temporaryMediaGroup), td()(p('')), td()(p(''))),
879
- ),
880
- ),
881
- );
882
- });
883
- });
884
-
885
- describe('#wrapTableInExpand', () => {
886
- it('should not wrap if selection is not on a table', () => {
887
- const { editorView } = editor(
888
- doc(
889
- p('Cursor here{<>}'),
890
- table()(tr(thEmpty, thEmpty, thEmpty), tr(tdEmpty, tdEmpty, tdEmpty)),
891
- ),
892
- { allowExpand: true, allowTables: { allowCollapse: true } },
893
- );
894
-
895
- const result = wrapTableInExpand(editorView.state, editorView.dispatch);
896
-
897
- expect(result).toBeFalsy();
898
- expect(editorView.state.doc).toEqualDocument(
899
- doc(
900
- p('Cursor {<>}here'),
901
- table({ localId: 'test-table-local-id' })(
902
- tr(thEmpty, thEmpty, thEmpty),
903
- tr(tdEmpty, tdEmpty, tdEmpty),
904
- ),
905
- ),
906
- );
907
- });
908
-
909
- it('should be able to wrap a root level table', () => {
910
- const { editorView } = editor(
911
- doc(
912
- table()(
913
- tr(thCursor, thEmpty, thEmpty),
914
- tr(tdEmpty, tdEmpty, tdEmpty),
915
- ),
916
- ),
917
- { allowExpand: true },
918
- );
919
-
920
- const result = wrapTableInExpand(editorView.state, editorView.dispatch);
921
-
922
- expect(result).toBeTruthy();
923
- expect(editorView.state.doc).toEqualDocument(
924
- doc(
925
- expand()(
926
- table({ localId: 'test-table-local-id' })(
927
- tr(thEmpty, thEmpty, thEmpty),
928
- tr(tdEmpty, tdEmpty, tdEmpty),
929
- ),
930
- ),
931
- ),
932
- );
933
- });
934
-
935
- it('should not wrap a table under an expand', () => {
936
- const { editorView } = editor(
937
- doc(
938
- expand()(
939
- table()(
940
- tr(thCursor, thEmpty, thEmpty),
941
- tr(tdEmpty, tdEmpty, tdEmpty),
942
- ),
943
- ),
944
- ),
945
- { allowExpand: true },
946
- );
947
-
948
- const result = wrapTableInExpand(editorView.state, editorView.dispatch);
949
-
950
- expect(result).toBeFalsy();
951
- expect(editorView.state.doc).toEqualDocument(
952
- doc(
953
- expand()(
954
- table({ localId: 'test-table-local-id' })(
955
- tr(thEmpty, thEmpty, thEmpty),
956
- tr(tdEmpty, tdEmpty, tdEmpty),
957
- ),
958
- ),
959
- ),
960
- );
961
- });
962
-
963
- it('should not wrap a table inside a bodiedExtension', () => {
964
- const { editorView } = editor(
965
- doc(
966
- bodiedExtension({
967
- extensionKey: 'key',
968
- extensionType: 'type',
969
- localId: 'localId',
970
- })(
971
- table()(
972
- tr(thCursor, thEmpty, thEmpty),
973
- tr(tdEmpty, tdEmpty, tdEmpty),
974
- ),
975
- ),
976
- ),
977
- { allowExpand: true, allowExtension: true },
978
- );
979
-
980
- const result = wrapTableInExpand(editorView.state, editorView.dispatch);
981
-
982
- expect(result).toBeFalsy();
983
- expect(editorView.state.doc).toEqualDocument(
984
- doc(
985
- bodiedExtension({
986
- extensionKey: 'key',
987
- extensionType: 'type',
988
- localId: 'localId',
989
- })(
990
- table({ localId: 'test-table-local-id' })(
991
- tr(thEmpty, thEmpty, thEmpty),
992
- tr(tdEmpty, tdEmpty, tdEmpty),
993
- ),
994
- ),
995
- ),
996
- );
997
- });
998
736
  });
999
737
  });