@atlaskit/editor-plugin-table 1.2.1 → 1.2.3

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 (67) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/i18n/en.js +43 -0
  3. package/dist/cjs/i18n/en_GB.js +43 -0
  4. package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +13 -26
  5. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +17 -1
  6. package/dist/cjs/plugins/table/nodeviews/table.js +7 -0
  7. package/dist/cjs/plugins/table/transforms/delete-rows.js +1 -1
  8. package/dist/cjs/plugins/table/transforms/index.js +3 -3
  9. package/dist/cjs/plugins/table/transforms/merge.js +39 -54
  10. package/dist/cjs/plugins/table/ui/common-styles.js +12 -6
  11. package/dist/cjs/plugins/table/utils/row-controls.js +3 -2
  12. package/dist/cjs/version.json +1 -1
  13. package/dist/es2019/i18n/en.js +36 -0
  14. package/dist/es2019/i18n/en_GB.js +36 -0
  15. package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +13 -26
  16. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +21 -1
  17. package/dist/es2019/plugins/table/nodeviews/table.js +7 -0
  18. package/dist/es2019/plugins/table/transforms/delete-rows.js +2 -2
  19. package/dist/es2019/plugins/table/transforms/index.js +1 -1
  20. package/dist/es2019/plugins/table/transforms/merge.js +39 -43
  21. package/dist/es2019/plugins/table/ui/common-styles.js +50 -8
  22. package/dist/es2019/plugins/table/utils/row-controls.js +3 -2
  23. package/dist/es2019/version.json +1 -1
  24. package/dist/esm/i18n/en.js +36 -0
  25. package/dist/esm/i18n/en_GB.js +36 -0
  26. package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +13 -26
  27. package/dist/esm/plugins/table/nodeviews/TableComponent.js +17 -1
  28. package/dist/esm/plugins/table/nodeviews/table.js +7 -0
  29. package/dist/esm/plugins/table/transforms/delete-rows.js +2 -2
  30. package/dist/esm/plugins/table/transforms/index.js +1 -1
  31. package/dist/esm/plugins/table/transforms/merge.js +38 -53
  32. package/dist/esm/plugins/table/ui/common-styles.js +12 -6
  33. package/dist/esm/plugins/table/utils/row-controls.js +3 -2
  34. package/dist/esm/version.json +1 -1
  35. package/dist/types/i18n/en.d.ts +35 -0
  36. package/dist/types/i18n/en_GB.d.ts +35 -0
  37. package/dist/types/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +4 -5
  38. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +1 -0
  39. package/dist/types/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.d.ts +3 -3
  40. package/dist/types/plugins/table/transforms/index.d.ts +1 -1
  41. package/dist/types/plugins/table/transforms/merge.d.ts +1 -1
  42. package/dist/types/plugins/table/types.d.ts +2 -0
  43. package/package.json +7 -6
  44. package/src/__tests__/integration/__fixtures__/table-and-paragraph-adf.ts +130 -0
  45. package/src/__tests__/integration/horizontal-scroll-shadows.ts +199 -0
  46. package/src/__tests__/integration/meta-arrowup-cursor-in-first-row.ts +4 -2
  47. package/src/__tests__/unit/commands/sort.ts +4 -0
  48. package/src/__tests__/unit/commands.ts +2 -0
  49. package/src/__tests__/unit/index.ts +2 -0
  50. package/src/__tests__/unit/keymap.ts +4 -2
  51. package/src/__tests__/unit/layout.ts +2 -0
  52. package/src/__tests__/unit/nodeviews/OverflowShadowsObserver.ts +20 -11
  53. package/src/__tests__/unit/pm-plugins/main-with-allow-collapse.ts +2 -0
  54. package/src/__tests__/unit/transforms/delete-rows.ts +45 -0
  55. package/src/__tests__/unit/utils/collapse.ts +4 -1
  56. package/src/i18n/en.ts +36 -0
  57. package/src/i18n/en_GB.ts +36 -0
  58. package/src/plugins/table/nodeviews/OverflowShadowsObserver.ts +24 -40
  59. package/src/plugins/table/nodeviews/TableComponent.tsx +19 -2
  60. package/src/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.ts +3 -3
  61. package/src/plugins/table/nodeviews/table.tsx +12 -0
  62. package/src/plugins/table/transforms/delete-rows.ts +2 -2
  63. package/src/plugins/table/transforms/index.ts +1 -1
  64. package/src/plugins/table/transforms/merge.ts +41 -43
  65. package/src/plugins/table/ui/common-styles.ts +54 -5
  66. package/src/plugins/table/utils/row-controls.ts +3 -2
  67. package/src/__tests__/integration/__fixtures__/table-and-paragraph-adf.json +0 -130
@@ -0,0 +1,130 @@
1
+ export default {
2
+ version: 1,
3
+ type: 'doc',
4
+ content: [
5
+ {
6
+ type: 'table',
7
+ attrs: {
8
+ isNumberColumnEnabled: false,
9
+ layout: 'default',
10
+ localId: '79259280-56bc-4cb0-9587-572864b97f39',
11
+ },
12
+ content: [
13
+ {
14
+ type: 'tableRow',
15
+ content: [
16
+ {
17
+ type: 'tableHeader',
18
+ attrs: {},
19
+ content: [
20
+ {
21
+ type: 'paragraph',
22
+ content: [],
23
+ },
24
+ ],
25
+ },
26
+ {
27
+ type: 'tableHeader',
28
+ attrs: {},
29
+ content: [
30
+ {
31
+ type: 'paragraph',
32
+ content: [],
33
+ },
34
+ ],
35
+ },
36
+ {
37
+ type: 'tableHeader',
38
+ attrs: {},
39
+ content: [
40
+ {
41
+ type: 'paragraph',
42
+ content: [],
43
+ },
44
+ ],
45
+ },
46
+ ],
47
+ },
48
+ {
49
+ type: 'tableRow',
50
+ content: [
51
+ {
52
+ type: 'tableCell',
53
+ attrs: {},
54
+ content: [
55
+ {
56
+ type: 'paragraph',
57
+ content: [],
58
+ },
59
+ ],
60
+ },
61
+ {
62
+ type: 'tableCell',
63
+ attrs: {},
64
+ content: [
65
+ {
66
+ type: 'paragraph',
67
+ content: [],
68
+ },
69
+ ],
70
+ },
71
+ {
72
+ type: 'tableCell',
73
+ attrs: {},
74
+ content: [
75
+ {
76
+ type: 'paragraph',
77
+ content: [],
78
+ },
79
+ ],
80
+ },
81
+ ],
82
+ },
83
+ {
84
+ type: 'tableRow',
85
+ content: [
86
+ {
87
+ type: 'tableCell',
88
+ attrs: {},
89
+ content: [
90
+ {
91
+ type: 'paragraph',
92
+ content: [],
93
+ },
94
+ ],
95
+ },
96
+ {
97
+ type: 'tableCell',
98
+ attrs: {},
99
+ content: [
100
+ {
101
+ type: 'paragraph',
102
+ content: [],
103
+ },
104
+ ],
105
+ },
106
+ {
107
+ type: 'tableCell',
108
+ attrs: {},
109
+ content: [
110
+ {
111
+ type: 'paragraph',
112
+ content: [],
113
+ },
114
+ ],
115
+ },
116
+ ],
117
+ },
118
+ ],
119
+ },
120
+ {
121
+ type: 'paragraph',
122
+ content: [
123
+ {
124
+ type: 'text',
125
+ text: 'test',
126
+ },
127
+ ],
128
+ },
129
+ ],
130
+ };
@@ -0,0 +1,199 @@
1
+ import { BrowserTestCase } from '@atlaskit/webdriver-runner/runner';
2
+ import WebdriverPage from '@atlaskit/webdriver-runner/wd-wrapper';
3
+
4
+ import {
5
+ goToEditorTestingWDExample,
6
+ mountEditor,
7
+ } from '@atlaskit/editor-test-helpers/testing-example-page';
8
+
9
+ import {
10
+ fullpage,
11
+ resizeColumn,
12
+ } from '@atlaskit/editor-test-helpers/integration/helpers';
13
+
14
+ import { TableCssClassName as className } from '../../plugins/table/types';
15
+ import basicTable from './__fixtures__/basic-table';
16
+
17
+ const checkShadows = async (page: WebdriverPage, side?: 'left' | 'right') => {
18
+ const leftShadow = await page.$(`.${className.TABLE_LEFT_SHADOW}`);
19
+ const leftShadowStyle = await leftShadow.getAttribute('style');
20
+ const rightShadow = await page.$(`.${className.TABLE_RIGHT_SHADOW}`);
21
+ const rightShadowStyle = await rightShadow.getAttribute('style');
22
+
23
+ if (!side) {
24
+ return (
25
+ leftShadowStyle.includes('display: block;') &&
26
+ rightShadowStyle.includes('display: block;')
27
+ );
28
+ } else if (side === 'left') {
29
+ return leftShadowStyle.includes('display: block;');
30
+ } else if (side === 'right') {
31
+ return rightShadowStyle.includes('display: block;');
32
+ }
33
+ };
34
+
35
+ BrowserTestCase(
36
+ 'Table does not show horizontal scroll shadows when there is no scrollbar',
37
+ {},
38
+ async (client: any, testName: string) => {
39
+ const page = await goToEditorTestingWDExample(
40
+ client,
41
+ 'editor-plugin-table',
42
+ );
43
+
44
+ await mountEditor(page, {
45
+ appearance: fullpage.appearance,
46
+ defaultValue: JSON.stringify(basicTable),
47
+ allowTables: {
48
+ advanced: true,
49
+ },
50
+ });
51
+
52
+ await page.waitForSelector('table');
53
+ expect(await checkShadows(page)).toBeFalsy();
54
+ },
55
+ );
56
+
57
+ BrowserTestCase(
58
+ 'Table shows right shadow when table is scrollable and all the way to the left',
59
+ {},
60
+ async (client: any, testName: string) => {
61
+ const page = await goToEditorTestingWDExample(
62
+ client,
63
+ 'editor-plugin-table',
64
+ );
65
+
66
+ await mountEditor(page, {
67
+ appearance: fullpage.appearance,
68
+ defaultValue: JSON.stringify(basicTable),
69
+ allowTables: {
70
+ advanced: true,
71
+ },
72
+ });
73
+
74
+ await page.waitForSelector('table');
75
+ await resizeColumn(page, { cellHandlePos: 2, resizeWidth: 1000 });
76
+
77
+ expect(await checkShadows(page, 'right')).toBeTruthy();
78
+ },
79
+ );
80
+
81
+ BrowserTestCase(
82
+ 'Table should not show left shadow when table is scrollable and all the way to the left',
83
+ {},
84
+ async (client: any, testName: string) => {
85
+ const page = await goToEditorTestingWDExample(
86
+ client,
87
+ 'editor-plugin-table',
88
+ );
89
+
90
+ await mountEditor(page, {
91
+ appearance: fullpage.appearance,
92
+ defaultValue: JSON.stringify(basicTable),
93
+ allowTables: {
94
+ advanced: true,
95
+ },
96
+ });
97
+
98
+ await page.waitForSelector('table');
99
+ await resizeColumn(page, { cellHandlePos: 2, resizeWidth: 1000 });
100
+
101
+ expect(await checkShadows(page, 'left')).toBeFalsy();
102
+ },
103
+ );
104
+
105
+ BrowserTestCase(
106
+ 'Table should show both left and right shadows when table is scrollable and scrolled',
107
+ {},
108
+ async (client: any, testName: string) => {
109
+ const page = await goToEditorTestingWDExample(
110
+ client,
111
+ 'editor-plugin-table',
112
+ );
113
+
114
+ await mountEditor(page, {
115
+ appearance: fullpage.appearance,
116
+ defaultValue: JSON.stringify(basicTable),
117
+ allowTables: {
118
+ advanced: true,
119
+ },
120
+ });
121
+
122
+ await page.waitForSelector('table');
123
+ await resizeColumn(page, { cellHandlePos: 2, resizeWidth: 1000 });
124
+ await page.evaluate(() => {
125
+ const tableWrapper =
126
+ document.querySelector<HTMLElement>('.pm-table-wrapper');
127
+ if (tableWrapper) {
128
+ tableWrapper.scrollLeft += 500;
129
+ }
130
+ return tableWrapper;
131
+ });
132
+
133
+ expect(await checkShadows(page)).toBeTruthy();
134
+ },
135
+ );
136
+
137
+ BrowserTestCase(
138
+ 'Table should not show right shadow when table is scrollable and scrolled all the way to the right',
139
+ {},
140
+ async (client: any, testName: string) => {
141
+ const page = await goToEditorTestingWDExample(
142
+ client,
143
+ 'editor-plugin-table',
144
+ );
145
+
146
+ await mountEditor(page, {
147
+ appearance: fullpage.appearance,
148
+ defaultValue: JSON.stringify(basicTable),
149
+ allowTables: {
150
+ advanced: true,
151
+ },
152
+ });
153
+
154
+ await page.waitForSelector('table');
155
+ await resizeColumn(page, { cellHandlePos: 2, resizeWidth: 1000 });
156
+ await page.evaluate(() => {
157
+ const tableWrapper =
158
+ document.querySelector<HTMLElement>('.pm-table-wrapper');
159
+ if (tableWrapper) {
160
+ tableWrapper.scrollLeft += 1000;
161
+ }
162
+ return tableWrapper;
163
+ });
164
+
165
+ expect(await checkShadows(page, 'right')).toBeFalsy();
166
+ },
167
+ );
168
+
169
+ BrowserTestCase(
170
+ 'Table should show left shadow when table is scrollable and scrolled all the way to the right',
171
+ {},
172
+ async (client: any, testName: string) => {
173
+ const page = await goToEditorTestingWDExample(
174
+ client,
175
+ 'editor-plugin-table',
176
+ );
177
+
178
+ await mountEditor(page, {
179
+ appearance: fullpage.appearance,
180
+ defaultValue: JSON.stringify(basicTable),
181
+ allowTables: {
182
+ advanced: true,
183
+ },
184
+ });
185
+
186
+ await page.waitForSelector('table');
187
+ await resizeColumn(page, { cellHandlePos: 2, resizeWidth: 1000 });
188
+ await page.evaluate(() => {
189
+ const tableWrapper =
190
+ document.querySelector<HTMLElement>('.pm-table-wrapper');
191
+ if (tableWrapper) {
192
+ tableWrapper.scrollLeft += 1000;
193
+ }
194
+ return tableWrapper;
195
+ });
196
+
197
+ expect(await checkShadows(page, 'left')).toBeTruthy();
198
+ },
199
+ );
@@ -8,7 +8,7 @@ import {
8
8
  goToEditorTestingWDExample,
9
9
  mountEditor,
10
10
  } from '@atlaskit/editor-test-helpers/testing-example-page';
11
- import tableAdf from './__fixtures__/table-and-paragraph-adf.json';
11
+ import tableAdf from './__fixtures__/table-and-paragraph-adf';
12
12
 
13
13
  BrowserTestCase(
14
14
  'meta-arrowup-cursor-in-first-row.ts: pressing command/ctrl + arrow up should move cursor into first row',
@@ -20,7 +20,9 @@ BrowserTestCase(
20
20
  );
21
21
  await mountEditor(page, {
22
22
  appearance: fullpage.appearance,
23
- allowTables: {},
23
+ allowTables: {
24
+ advanced: true,
25
+ },
24
26
  defaultValue: tableAdf,
25
27
  });
26
28
 
@@ -22,8 +22,10 @@ import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
22
22
  import tablePlugin from '../../../plugins/table-plugin';
23
23
  import statusPlugin from '@atlaskit/editor-core/src/plugins/status';
24
24
  import mentionsPlugin from '@atlaskit/editor-core/src/plugins/mentions';
25
+ import editorDisabledPlugin from '@atlaskit/editor-core/src/plugins/editor-disabled';
25
26
  import hyperlinkPlugin from '@atlaskit/editor-core/src/plugins/hyperlink';
26
27
  import datePlugin from '@atlaskit/editor-core/src/plugins/date';
28
+ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
27
29
 
28
30
  const TABLE_LOCAL_ID = 'test-table-local-id';
29
31
 
@@ -118,6 +120,8 @@ describe('Sort Table', () => {
118
120
  beforeEach(() => {
119
121
  ({ editorView } = createEditor({
120
122
  preset: new Preset<LightEditorPlugin>()
123
+ .add([featureFlagsPlugin, {}])
124
+ .add(editorDisabledPlugin)
121
125
  .add([tablePlugin, { tableOptions: { allowHeaderRow: true } }])
122
126
  .add([statusPlugin, { menuDisabled: false }])
123
127
  .add(mentionsPlugin)
@@ -60,6 +60,7 @@ import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
60
60
  import extensionPlugin from '@atlaskit/editor-core/src/plugins/extension';
61
61
  import mediaPlugin from '@atlaskit/editor-core/src/plugins/media';
62
62
  import textFormattingPlugin from '@atlaskit/editor-core/src/plugins/text-formatting';
63
+ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
63
64
 
64
65
  const TABLE_LOCAL_ID = 'test-table-local-id';
65
66
 
@@ -78,6 +79,7 @@ describe('table plugin: actions', () => {
78
79
  doc,
79
80
  attachTo: document.body,
80
81
  preset: new Preset<LightEditorPlugin>()
82
+ .add([featureFlagsPlugin, {}])
81
83
  .add(tablePlugin)
82
84
  .add(panelPlugin)
83
85
  .add(textFormattingPlugin)
@@ -62,6 +62,7 @@ import { getPluginState } from '../../plugins/table/pm-plugins/plugin-factory';
62
62
  import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
63
63
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
64
64
  import tablePlugin from '../../plugins/table-plugin';
65
+ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
65
66
 
66
67
  const TABLE_LOCAL_ID = 'test-table-local-id';
67
68
 
@@ -91,6 +92,7 @@ describe('table plugin', () => {
91
92
  } as PluginConfig;
92
93
 
93
94
  const preset = new Preset<LightEditorPlugin>()
95
+ .add([featureFlagsPlugin, {}])
94
96
  .add([tablePlugin, { tableOptions }])
95
97
  .add([mediaPlugin, { allowMediaSingle: true }])
96
98
  .add([analyticsPlugin, {}])
@@ -56,8 +56,9 @@ import statusPlugin from '@atlaskit/editor-core/src/plugins/status';
56
56
  import tablePlugin from '../../plugins/table';
57
57
  import { TablePluginState } from '../../plugins/table/types';
58
58
  import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
59
- import featureFlagsPlugin from '@atlaskit/editor-core/src/plugins/feature-flags-context';
60
59
  import widthPlugin from '@atlaskit/editor-core/src/plugins/width';
60
+ import editorDisabledPlugin from '@atlaskit/editor-core/src/plugins/editor-disabled';
61
+ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
61
62
 
62
63
  const TABLE_LOCAL_ID = 'test-table-local-id';
63
64
 
@@ -81,6 +82,7 @@ describe('table keymap', () => {
81
82
 
82
83
  const createEditor = createProsemirrorEditorFactory();
83
84
  const preset = new Preset<LightEditorPlugin>()
85
+ .add([featureFlagsPlugin, {}])
84
86
  .add(selectionPlugin)
85
87
  .add([
86
88
  tablePlugin,
@@ -97,12 +99,12 @@ describe('table keymap', () => {
97
99
  .add(emojiPlugin)
98
100
  .add(jiraIssuePlugin)
99
101
  .add(extensionPlugin)
102
+ .add(editorDisabledPlugin)
100
103
  .add(datePlugin)
101
104
  .add(layoutPlugin)
102
105
  .add([statusPlugin, { menuDisabled: false }])
103
106
  .add([mediaPlugin, { allowMediaSingle: true }])
104
107
  .add([analyticsPlugin, { createAnalyticsEvent }])
105
- .add([featureFlagsPlugin, {}])
106
108
  .add(widthPlugin);
107
109
 
108
110
  const editor = (doc: DocBuilder) =>
@@ -35,6 +35,7 @@ import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
35
35
  import extensionPlugin from '@atlaskit/editor-core/src/plugins/extension';
36
36
  import layoutPlugin from '@atlaskit/editor-core/src/plugins/layout';
37
37
  import { PluginKey } from 'prosemirror-state';
38
+ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
38
39
 
39
40
  describe('table toolbar', () => {
40
41
  const tableOptions = {
@@ -46,6 +47,7 @@ describe('table toolbar', () => {
46
47
 
47
48
  const createEditor = createProsemirrorEditorFactory();
48
49
  const preset = new Preset<LightEditorPlugin>()
50
+ .add([featureFlagsPlugin, {}])
49
51
  .add([tablePlugin, { tableOptions }])
50
52
  .add(expandPlugin)
51
53
  .add(extensionPlugin)
@@ -1,12 +1,15 @@
1
1
  import { MockIntersectionObserver } from '@atlaskit/editor-test-helpers/mock-intersection-observer';
2
2
 
3
3
  import { OverflowShadowsObserver } from '../../../plugins/table/nodeviews/OverflowShadowsObserver';
4
+ import { TableCssClassName as className } from '../../../plugins/table/types';
4
5
  import { ShadowEvent } from '../../../plugins/table/types';
5
6
 
6
7
  describe('OverflowShadowsObserver', () => {
7
8
  let table: HTMLTableElement;
8
9
  let td1: HTMLTableDataCellElement;
9
10
  let td2: HTMLTableDataCellElement;
11
+ let shadowSentinelLeft: HTMLDivElement;
12
+ let shadowSentinelRight: HTMLDivElement;
10
13
  let wrapper: HTMLDivElement;
11
14
  const updateSpy = jest.fn();
12
15
  const observeSpy = jest.fn();
@@ -37,15 +40,15 @@ describe('OverflowShadowsObserver', () => {
37
40
  });
38
41
 
39
42
  it('observes on first and last table cells', () => {
40
- overflowShadowsObserver.observeCells();
41
- expect(observeSpy).toHaveBeenCalledWith(td1);
42
- expect(observeSpy).toHaveBeenCalledWith(td2);
43
+ overflowShadowsObserver.observeShadowSentinels();
44
+ expect(observeSpy).toHaveBeenCalledWith(shadowSentinelLeft);
45
+ expect(observeSpy).toHaveBeenCalledWith(shadowSentinelRight);
43
46
  });
44
47
 
45
- it('does not re-observe if cells did not change', () => {
46
- overflowShadowsObserver.observeCells();
48
+ it('does not re-observe if shadow sentinels are already observed', () => {
49
+ overflowShadowsObserver.observeShadowSentinels();
47
50
  observeSpy.mockClear();
48
- overflowShadowsObserver.observeCells();
51
+ overflowShadowsObserver.observeShadowSentinels();
49
52
  expect(observeSpy).not.toHaveBeenCalled();
50
53
  });
51
54
 
@@ -61,14 +64,14 @@ describe('OverflowShadowsObserver', () => {
61
64
 
62
65
  describe('calls the provided update function when intersecting', () => {
63
66
  beforeEach(() => {
64
- overflowShadowsObserver.observeCells();
67
+ overflowShadowsObserver.observeShadowSentinels();
65
68
  });
66
69
 
67
70
  it.each([
68
71
  [
69
72
  'hides first shadow when first cell fully intersects',
70
73
  {
71
- getTarget: () => td1,
74
+ getTarget: () => shadowSentinelLeft,
72
75
  intersectionRatio: 1,
73
76
  isIntersecting: true,
74
77
  expectedShadow: ShadowEvent.SHOW_BEFORE_SHADOW,
@@ -78,7 +81,7 @@ describe('OverflowShadowsObserver', () => {
78
81
  [
79
82
  'hides last shadow when last cell fully intersects',
80
83
  {
81
- getTarget: () => td2,
84
+ getTarget: () => shadowSentinelRight,
82
85
  intersectionRatio: 1,
83
86
  isIntersecting: true,
84
87
  expectedShadow: ShadowEvent.SHOW_AFTER_SHADOW,
@@ -88,7 +91,7 @@ describe('OverflowShadowsObserver', () => {
88
91
  [
89
92
  'shows first shadow when first cell partially intersects',
90
93
  {
91
- getTarget: () => td1,
94
+ getTarget: () => shadowSentinelLeft,
92
95
  intersectionRatio: 0,
93
96
  isIntersecting: true,
94
97
  expectedShadow: ShadowEvent.SHOW_BEFORE_SHADOW,
@@ -98,7 +101,7 @@ describe('OverflowShadowsObserver', () => {
98
101
  [
99
102
  'shows last shadow when last cell partially intersects',
100
103
  {
101
- getTarget: () => td2,
104
+ getTarget: () => shadowSentinelRight,
102
105
  intersectionRatio: 0,
103
106
  isIntersecting: true,
104
107
  expectedShadow: ShadowEvent.SHOW_AFTER_SHADOW,
@@ -140,6 +143,12 @@ describe('OverflowShadowsObserver', () => {
140
143
  function buildTable() {
141
144
  wrapper = document.createElement('div');
142
145
  table = document.createElement('table');
146
+ shadowSentinelLeft = document.createElement('div');
147
+ shadowSentinelLeft.className = className.TABLE_SHADOW_SENTINEL_LEFT;
148
+ shadowSentinelRight = document.createElement('div');
149
+ shadowSentinelRight.className = className.TABLE_SHADOW_SENTINEL_RIGHT;
150
+ table.prepend(shadowSentinelLeft);
151
+ table.prepend(shadowSentinelRight);
143
152
  wrapper.appendChild(table);
144
153
  const tbody = document.createElement('tbody');
145
154
  table.appendChild(tbody);
@@ -21,6 +21,7 @@ import { TablePluginState } from '../../../plugins/table/types';
21
21
  import { handleDocOrSelectionChanged } from '../../../plugins/table/handlers';
22
22
  import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
23
23
  import extensionPlugin from '@atlaskit/editor-core/src/plugins/extension';
24
+ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
24
25
 
25
26
  describe('tables: main plugin with allowCollapse: true', () => {
26
27
  const createEditor = createProsemirrorEditorFactory();
@@ -28,6 +29,7 @@ describe('tables: main plugin with allowCollapse: true', () => {
28
29
  createEditor({
29
30
  doc,
30
31
  preset: new Preset<LightEditorPlugin>()
32
+ .add([featureFlagsPlugin, {}])
31
33
  .add(tablePlugin)
32
34
  .add(expandPlugin)
33
35
  .add(extensionPlugin),
@@ -241,6 +241,51 @@ describe('table plugin -> transforms -> delete rows', () => {
241
241
  });
242
242
  });
243
243
 
244
+ describe('when delete the row in between rows that have merged cells with an extra row underneath', () => {
245
+ it('should decrement colspan of these cells', () => {
246
+ const { editorView } = editor(
247
+ doc(
248
+ p('text'),
249
+ table()(
250
+ tr(td({ colspan: 5 })(p('a1')), td({})(p('a6'))),
251
+ tr(
252
+ td({})(p('b1{<cell}')),
253
+ td({})(p('b2')),
254
+ td({})(p('b3')),
255
+ td({})(p('b4')),
256
+ td({})(p('b5')),
257
+ td({})(p('b6{cell>}')),
258
+ ),
259
+ tr(td({})(p('c1')), td({ colspan: 5 })(p('c6'))),
260
+ tr(
261
+ td({ colspan: 3 })(p('d1')),
262
+ td({})(p('d4')),
263
+ td({})(p('d5')),
264
+ td({})(p('d6')),
265
+ ),
266
+ ),
267
+ ),
268
+ );
269
+ const { state, dispatch } = editorView;
270
+ dispatch(deleteRows(getSelectionRect(state.selection)!)(state.tr));
271
+ expect(editorView.state.doc).toEqualDocument(
272
+ doc(
273
+ p('text'),
274
+ table({ localId: TABLE_LOCAL_ID })(
275
+ tr(td({ colspan: 4 })(p('a1')), td({})(p('a6'))),
276
+ tr(td({})(p('c1')), td({ colspan: 4 })(p('c6'))),
277
+ tr(
278
+ td({ colspan: 2 })(p('d1')),
279
+ td({})(p('d4')),
280
+ td({})(p('d5')),
281
+ td({})(p('d6')),
282
+ ),
283
+ ),
284
+ ),
285
+ );
286
+ });
287
+ });
288
+
244
289
  describe('when after deleting the first row table has columns where all cells have colspan > 1', () => {
245
290
  it('should decrement colspan of these cells', () => {
246
291
  const { editorView } = editor(
@@ -18,12 +18,15 @@ import {
18
18
  isTableCollapsible,
19
19
  collapseSelectedTable,
20
20
  } from '../../../plugins/table/utils/collapse';
21
+ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
21
22
 
22
23
  describe('collapse', () => {
23
24
  const createEditor = createProsemirrorEditorFactory();
24
25
 
25
26
  const editor = (doc: DocBuilder, expandInPlugins?: boolean) => {
26
- const preset = new Preset<LightEditorPlugin>().add(tablePlugin);
27
+ const preset = new Preset<LightEditorPlugin>()
28
+ .add([featureFlagsPlugin, {}])
29
+ .add(tablePlugin);
27
30
 
28
31
  const finalPreset = expandInPlugins ? preset.add(expandPlugin) : preset;
29
32
 
package/src/i18n/en.ts ADDED
@@ -0,0 +1,36 @@
1
+ /* prettier-ignore */
2
+ /**
3
+ * NOTE:
4
+ *
5
+ * This file is automatically generated by Traduki 2.0.
6
+ * DO NOT CHANGE IT BY HAND or your changes will be lost.
7
+ */
8
+ //
9
+ export default {
10
+ 'fabric.editor.canNotSortTable': "⚠️ You can't sort a table with merged cells",
11
+ 'fabric.editor.cellBackground': 'Cell background',
12
+ 'fabric.editor.cellOptions': 'Cell options',
13
+ 'fabric.editor.clearCells': 'Clear {0, plural, one {cell} other {cells}}',
14
+ 'fabric.editor.collapseTable': 'Collapse table',
15
+ 'fabric.editor.cornerControl': 'Highlight table',
16
+ 'fabric.editor.distributeColumns': 'Distribute columns',
17
+ 'fabric.editor.extension.confirmDeleteLinkedModalMessagePrefix': 'Deleting',
18
+ 'fabric.editor.extension.deleteElementTitle': 'Delete element',
19
+ 'fabric.editor.extension.sourceNoTitledName': 'this element',
20
+ 'fabric.editor.floatingToolbar.confirmModalCheckboxLabel': 'Also delete connected elements',
21
+ 'fabric.editor.headerColumn': 'Header column',
22
+ 'fabric.editor.headerRow': 'Header row',
23
+ 'fabric.editor.insertColumn': 'Insert column right',
24
+ 'fabric.editor.insertRow': 'Insert row below',
25
+ 'fabric.editor.mergeCells': 'Merge cells',
26
+ 'fabric.editor.numberedColumn': 'Numbered column',
27
+ 'fabric.editor.removeColumns': 'Delete {0, plural, one {column} other {columns}}',
28
+ 'fabric.editor.removeRows': 'Delete {0, plural, one {row} other {rows}}',
29
+ 'fabric.editor.rowControl': 'Highlight row',
30
+ 'fabric.editor.sortColumnASC': 'Sort column A → Z',
31
+ 'fabric.editor.sortColumnDESC': 'Sort column Z → A',
32
+ 'fabric.editor.splitCell': 'Split cell',
33
+ 'fabric.editor.tableOptions': 'Table options',
34
+ 'fabric.editor.tables.confirmDeleteLinkedModalMessage': 'Deleting {nodeName} will break anything connected to it.',
35
+ 'fabric.editor.tables.confirmDeleteLinkedModalOKButton': 'Delete',
36
+ };