@atlaskit/editor-plugin-table 1.1.2 → 1.1.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.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +13 -3
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/commands.js +7 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +17 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +38 -6
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +2 -2
- package/dist/cjs/plugins/table/transforms/column-width.js +47 -5
- package/dist/cjs/plugins/table/ui/common-styles.js +4 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +13 -3
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +7 -2
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +15 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +37 -4
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +2 -2
- package/dist/es2019/plugins/table/transforms/column-width.js +45 -5
- package/dist/es2019/plugins/table/ui/common-styles.js +5 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +13 -3
- package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +7 -2
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +15 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +35 -4
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +2 -2
- package/dist/esm/plugins/table/transforms/column-width.js +47 -5
- package/dist/esm/plugins/table/ui/common-styles.js +3 -3
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +7 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +2 -1
- package/dist/types/plugins/table/ui/common-styles.d.ts +1 -0
- package/package.json +8 -6
- package/src/__tests__/integration/__fixtures__/empty-layout.ts +35 -0
- package/src/__tests__/integration/__fixtures__/nested-in-expand.ts +129 -0
- package/src/__tests__/integration/horizontal-scroll.ts +489 -0
- package/src/__tests__/unit/commands/insert.ts +3 -3
- package/src/__tests__/unit/keymap.ts +3 -1
- package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +38 -0
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +5 -2
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +2 -2
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +2 -2
- package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-2-snap.png +2 -2
- package/src/__tests__/visual-regression/sticky-header.ts +2 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +16 -3
- package/src/plugins/table/pm-plugins/table-resizing/commands.ts +6 -2
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +9 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/colgroup.ts +19 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +57 -5
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-logic.ts +2 -2
- package/src/plugins/table/transforms/column-width.ts +60 -6
- package/src/plugins/table/ui/common-styles.ts +5 -2
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import WebdriverPage from '@atlaskit/webdriver-runner/wd-wrapper';
|
|
2
|
+
import { BrowserTestCase } from '@atlaskit/webdriver-runner/runner';
|
|
3
|
+
import {
|
|
4
|
+
fullpage,
|
|
5
|
+
resizeColumn,
|
|
6
|
+
} from '@atlaskit/editor-test-helpers/integration/helpers';
|
|
7
|
+
import {
|
|
8
|
+
goToEditorTestingWDExample,
|
|
9
|
+
mountEditor,
|
|
10
|
+
} from '@atlaskit/editor-test-helpers/testing-example-page';
|
|
11
|
+
import {
|
|
12
|
+
insertColumn,
|
|
13
|
+
insertTable,
|
|
14
|
+
} from '@atlaskit/editor-test-helpers/page-objects/table';
|
|
15
|
+
import basicTableAdf from './__fixtures__/basic-table';
|
|
16
|
+
import nestedInExpand from './__fixtures__/nested-in-expand';
|
|
17
|
+
import { nestedInExtension } from './__fixtures__/nested-in-extension';
|
|
18
|
+
import { table as tableInsideLayout } from './__fixtures__/table-inside-layout';
|
|
19
|
+
import { emptyLayout } from './__fixtures__/empty-layout';
|
|
20
|
+
|
|
21
|
+
// TODO - Add wider screen size here once editor-common fix is made ED-16647
|
|
22
|
+
const screenWidths = [1920];
|
|
23
|
+
|
|
24
|
+
const breakout = async (
|
|
25
|
+
page: WebdriverPage,
|
|
26
|
+
breakoutButton: WebdriverIO.Element,
|
|
27
|
+
) => {
|
|
28
|
+
let tableContainer = await page.$('.pm-table-container');
|
|
29
|
+
|
|
30
|
+
const currentWidth = await tableContainer.getCSSProperty('width');
|
|
31
|
+
breakoutButton.click();
|
|
32
|
+
|
|
33
|
+
await page.waitUntil(async () => {
|
|
34
|
+
tableContainer = await page.$('.pm-table-container');
|
|
35
|
+
const updatedWidth = await tableContainer.getCSSProperty('width');
|
|
36
|
+
return updatedWidth.value !== currentWidth.value;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const assertTableDoesNotScroll = async (page: WebdriverPage) => {
|
|
41
|
+
const table = await page.$('.pm-table-wrapper');
|
|
42
|
+
|
|
43
|
+
const tableScrollWidth = await table.getProperty('scrollWidth');
|
|
44
|
+
const tableOffsetWidth = await table.getProperty('offsetWidth');
|
|
45
|
+
|
|
46
|
+
expect(tableScrollWidth).toEqual(tableOffsetWidth);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const assertTableDoesScroll = async (page: WebdriverPage) => {
|
|
50
|
+
const table = await page.$('.pm-table-wrapper');
|
|
51
|
+
|
|
52
|
+
const tableScrollWidth = await table.getProperty('scrollWidth');
|
|
53
|
+
const tableOffsetWidth = (await table.getProperty('offsetWidth')) as number;
|
|
54
|
+
|
|
55
|
+
expect(tableScrollWidth).toBeGreaterThan(tableOffsetWidth);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// insertColumn helper doesn't work in Safari
|
|
59
|
+
BrowserTestCase(
|
|
60
|
+
'Table: Does not scroll when column is resized and a new column is inserted',
|
|
61
|
+
{ skip: ['safari'] },
|
|
62
|
+
async (client: any, testName: string) => {
|
|
63
|
+
for (const screenWidth of screenWidths) {
|
|
64
|
+
const page = await goToEditorTestingWDExample(
|
|
65
|
+
client,
|
|
66
|
+
'editor-plugin-table',
|
|
67
|
+
{ width: screenWidth, height: 1440 },
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
await mountEditor(page, {
|
|
71
|
+
appearance: fullpage.appearance,
|
|
72
|
+
defaultValue: basicTableAdf,
|
|
73
|
+
allowTables: {
|
|
74
|
+
advanced: true,
|
|
75
|
+
allowDistributeColumns: true,
|
|
76
|
+
},
|
|
77
|
+
allowLayouts: true,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
await resizeColumn(page, { cellHandlePos: 2, resizeWidth: -100 });
|
|
81
|
+
await insertColumn(page, 0, 'right');
|
|
82
|
+
await assertTableDoesNotScroll(page);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// insertColumn helper doesn't work in Safari
|
|
88
|
+
BrowserTestCase(
|
|
89
|
+
'Table: Does not scroll when column is resized and breakout button is clicked 3x',
|
|
90
|
+
{ skip: ['safari'] },
|
|
91
|
+
async (client: any, testName: string) => {
|
|
92
|
+
for (const screenWidth of screenWidths) {
|
|
93
|
+
const page = await goToEditorTestingWDExample(
|
|
94
|
+
client,
|
|
95
|
+
'editor-plugin-table',
|
|
96
|
+
{ width: screenWidth, height: 1440 },
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
await mountEditor(page, {
|
|
100
|
+
appearance: fullpage.appearance,
|
|
101
|
+
defaultValue: basicTableAdf,
|
|
102
|
+
allowTables: {
|
|
103
|
+
advanced: true,
|
|
104
|
+
allowDistributeColumns: true,
|
|
105
|
+
},
|
|
106
|
+
allowLayouts: true,
|
|
107
|
+
allowBreakout: true,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
await resizeColumn(page, { cellHandlePos: 2, resizeWidth: -100 });
|
|
111
|
+
await insertColumn(page, 0, 'right');
|
|
112
|
+
|
|
113
|
+
const breakoutButton = await page.$('[aria-label="Go wide"]');
|
|
114
|
+
|
|
115
|
+
await breakout(page, breakoutButton);
|
|
116
|
+
await assertTableDoesNotScroll(page);
|
|
117
|
+
|
|
118
|
+
await breakout(page, breakoutButton);
|
|
119
|
+
await assertTableDoesNotScroll(page);
|
|
120
|
+
|
|
121
|
+
await breakout(page, breakoutButton);
|
|
122
|
+
await assertTableDoesNotScroll(page);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
BrowserTestCase(
|
|
128
|
+
'Table: Does not scroll when nested in expand, column is resized and breakout button is clicked',
|
|
129
|
+
{ skip: [] },
|
|
130
|
+
async (client: any, testName: string) => {
|
|
131
|
+
for (const screenWidth of screenWidths) {
|
|
132
|
+
const page = await goToEditorTestingWDExample(
|
|
133
|
+
client,
|
|
134
|
+
'editor-plugin-table',
|
|
135
|
+
{ width: screenWidth, height: 1440 },
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
await mountEditor(page, {
|
|
139
|
+
appearance: fullpage.appearance,
|
|
140
|
+
defaultValue: nestedInExpand,
|
|
141
|
+
allowTables: {
|
|
142
|
+
advanced: true,
|
|
143
|
+
allowDistributeColumns: true,
|
|
144
|
+
},
|
|
145
|
+
allowExpand: true,
|
|
146
|
+
allowLayouts: true,
|
|
147
|
+
allowBreakout: true,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const breakoutButton = await page.$('[aria-label="Go wide"]');
|
|
151
|
+
|
|
152
|
+
await resizeColumn(page, { cellHandlePos: 3, resizeWidth: -100 });
|
|
153
|
+
await breakout(page, breakoutButton);
|
|
154
|
+
await assertTableDoesNotScroll(page);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
BrowserTestCase(
|
|
160
|
+
'Table: Last column can be resized to remove scroll',
|
|
161
|
+
{ skip: [] },
|
|
162
|
+
async (client: any, testName: string) => {
|
|
163
|
+
for (const screenWidth of screenWidths) {
|
|
164
|
+
const page = await goToEditorTestingWDExample(
|
|
165
|
+
client,
|
|
166
|
+
'editor-plugin-table',
|
|
167
|
+
{ width: screenWidth, height: 1440 },
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
await mountEditor(page, {
|
|
171
|
+
appearance: fullpage.appearance,
|
|
172
|
+
defaultValue: basicTableAdf,
|
|
173
|
+
allowTables: {
|
|
174
|
+
advanced: true,
|
|
175
|
+
allowDistributeColumns: true,
|
|
176
|
+
},
|
|
177
|
+
allowExpand: true,
|
|
178
|
+
allowLayouts: true,
|
|
179
|
+
allowBreakout: true,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
await resizeColumn(page, { cellHandlePos: 2, resizeWidth: 1000 });
|
|
183
|
+
await assertTableDoesScroll(page);
|
|
184
|
+
await resizeColumn(page, { cellHandlePos: 10, resizeWidth: -1000 });
|
|
185
|
+
await assertTableDoesNotScroll(page);
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
BrowserTestCase(
|
|
191
|
+
'Table: When nested in expand, last column can be resized to remove scroll',
|
|
192
|
+
{ skip: [] },
|
|
193
|
+
async (client: any, testName: string) => {
|
|
194
|
+
for (const screenWidth of screenWidths) {
|
|
195
|
+
const page = await goToEditorTestingWDExample(
|
|
196
|
+
client,
|
|
197
|
+
'editor-plugin-table',
|
|
198
|
+
{ width: screenWidth, height: 1440 },
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
await mountEditor(page, {
|
|
202
|
+
appearance: fullpage.appearance,
|
|
203
|
+
defaultValue: nestedInExpand,
|
|
204
|
+
allowTables: {
|
|
205
|
+
advanced: true,
|
|
206
|
+
allowDistributeColumns: true,
|
|
207
|
+
},
|
|
208
|
+
allowExpand: true,
|
|
209
|
+
allowLayouts: true,
|
|
210
|
+
allowBreakout: true,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
await resizeColumn(page, { cellHandlePos: 3, resizeWidth: 1000 });
|
|
214
|
+
await assertTableDoesScroll(page);
|
|
215
|
+
await resizeColumn(page, { cellHandlePos: 11, resizeWidth: -1000 });
|
|
216
|
+
await assertTableDoesNotScroll(page);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
BrowserTestCase(
|
|
222
|
+
'Table: When nested in layout, last column can be resized to remove scroll',
|
|
223
|
+
{ skip: [] },
|
|
224
|
+
async (client: any, testName: string) => {
|
|
225
|
+
for (const screenWidth of screenWidths) {
|
|
226
|
+
const page = await goToEditorTestingWDExample(
|
|
227
|
+
client,
|
|
228
|
+
'editor-plugin-table',
|
|
229
|
+
{ width: screenWidth, height: 1440 },
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
await mountEditor(page, {
|
|
233
|
+
appearance: fullpage.appearance,
|
|
234
|
+
defaultValue: tableInsideLayout,
|
|
235
|
+
allowTables: {
|
|
236
|
+
advanced: true,
|
|
237
|
+
allowDistributeColumns: true,
|
|
238
|
+
},
|
|
239
|
+
allowExpand: true,
|
|
240
|
+
allowLayouts: true,
|
|
241
|
+
allowBreakout: true,
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
await resizeColumn(page, { cellHandlePos: 8, resizeWidth: 1000 });
|
|
245
|
+
await assertTableDoesScroll(page);
|
|
246
|
+
await resizeColumn(page, { cellHandlePos: 16, resizeWidth: -1000 });
|
|
247
|
+
await assertTableDoesNotScroll(page);
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
BrowserTestCase(
|
|
253
|
+
'Table: When nested in bodied macro, last column can be resized to remove scroll',
|
|
254
|
+
{ skip: [] },
|
|
255
|
+
async (client: any, testName: string) => {
|
|
256
|
+
for (const screenWidth of screenWidths) {
|
|
257
|
+
const page = await goToEditorTestingWDExample(
|
|
258
|
+
client,
|
|
259
|
+
'editor-plugin-table',
|
|
260
|
+
{ width: screenWidth, height: 1440 },
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
await mountEditor(page, {
|
|
264
|
+
appearance: fullpage.appearance,
|
|
265
|
+
defaultValue: nestedInExtension,
|
|
266
|
+
allowTables: {
|
|
267
|
+
advanced: true,
|
|
268
|
+
allowDistributeColumns: true,
|
|
269
|
+
},
|
|
270
|
+
allowExpand: true,
|
|
271
|
+
allowLayouts: true,
|
|
272
|
+
allowBreakout: true,
|
|
273
|
+
allowExtension: true,
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
await resizeColumn(page, { cellHandlePos: 3, resizeWidth: 1000 });
|
|
277
|
+
await assertTableDoesScroll(page);
|
|
278
|
+
await resizeColumn(page, { cellHandlePos: 11, resizeWidth: -1000 });
|
|
279
|
+
await assertTableDoesNotScroll(page);
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
// insertColumn helper doesn't work in Safari
|
|
285
|
+
BrowserTestCase(
|
|
286
|
+
'Table: Scrolls when there are more columns added than can fit the current width',
|
|
287
|
+
{ skip: ['safari'] },
|
|
288
|
+
async (client: any, testName: string) => {
|
|
289
|
+
for (const screenWidth of screenWidths) {
|
|
290
|
+
const page = await goToEditorTestingWDExample(
|
|
291
|
+
client,
|
|
292
|
+
'editor-plugin-table',
|
|
293
|
+
{ width: screenWidth, height: 1440 },
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
await mountEditor(page, {
|
|
297
|
+
appearance: fullpage.appearance,
|
|
298
|
+
defaultValue: basicTableAdf,
|
|
299
|
+
allowTables: {
|
|
300
|
+
advanced: true,
|
|
301
|
+
allowDistributeColumns: true,
|
|
302
|
+
},
|
|
303
|
+
allowExpand: true,
|
|
304
|
+
allowLayouts: true,
|
|
305
|
+
allowBreakout: true,
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
const numberOfColumns = 14;
|
|
309
|
+
for (const _column of [...Array(numberOfColumns).keys()]) {
|
|
310
|
+
await insertColumn(page, 0, 'right');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
await assertTableDoesScroll(page);
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
// insertColumn helper doesn't work in Safari
|
|
319
|
+
BrowserTestCase(
|
|
320
|
+
'Table: Does not scroll when nested in Bodied Macro, column is resized and breakout button is clicked',
|
|
321
|
+
{ skip: ['safari'] },
|
|
322
|
+
async (client: any, testName: string) => {
|
|
323
|
+
for (const screenWidth of screenWidths) {
|
|
324
|
+
const page = await goToEditorTestingWDExample(
|
|
325
|
+
client,
|
|
326
|
+
'editor-plugin-table',
|
|
327
|
+
{ width: screenWidth, height: 1440 },
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
await mountEditor(page, {
|
|
331
|
+
appearance: fullpage.appearance,
|
|
332
|
+
defaultValue: JSON.stringify(nestedInExtension),
|
|
333
|
+
allowTables: {
|
|
334
|
+
advanced: true,
|
|
335
|
+
},
|
|
336
|
+
allowExtension: true,
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
await resizeColumn(page, { cellHandlePos: 3, resizeWidth: -100 });
|
|
340
|
+
await insertColumn(page, 0, 'right');
|
|
341
|
+
await assertTableDoesNotScroll(page);
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
BrowserTestCase(
|
|
347
|
+
'Table: Does not scroll when nested in layout, column is resized and breakout button is clicked',
|
|
348
|
+
{ skip: [] },
|
|
349
|
+
async (client: any, testName: string) => {
|
|
350
|
+
for (const screenWidth of screenWidths) {
|
|
351
|
+
const page = await goToEditorTestingWDExample(
|
|
352
|
+
client,
|
|
353
|
+
'editor-plugin-table',
|
|
354
|
+
{ width: screenWidth, height: 1440 },
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
await mountEditor(page, {
|
|
358
|
+
appearance: fullpage.appearance,
|
|
359
|
+
defaultValue: JSON.stringify(tableInsideLayout),
|
|
360
|
+
allowTables: {
|
|
361
|
+
advanced: true,
|
|
362
|
+
},
|
|
363
|
+
allowLayouts: {
|
|
364
|
+
allowBreakout: true,
|
|
365
|
+
},
|
|
366
|
+
allowBreakout: true,
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
const breakoutButton = await page.$('[aria-label="Go wide"]');
|
|
370
|
+
|
|
371
|
+
await resizeColumn(page, { cellHandlePos: 8, resizeWidth: -100 });
|
|
372
|
+
await breakout(page, breakoutButton);
|
|
373
|
+
await assertTableDoesNotScroll(page);
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
BrowserTestCase(
|
|
379
|
+
'Table: Does not scroll when nested in single column layout, table column is resized and breakout button is clicked',
|
|
380
|
+
{ skip: [] },
|
|
381
|
+
async (client: any, testName: string) => {
|
|
382
|
+
for (const screenWidth of screenWidths) {
|
|
383
|
+
const page = await goToEditorTestingWDExample(
|
|
384
|
+
client,
|
|
385
|
+
'editor-plugin-table',
|
|
386
|
+
{ width: screenWidth, height: 1440 },
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
await mountEditor(page, {
|
|
390
|
+
appearance: fullpage.appearance,
|
|
391
|
+
defaultValue: JSON.stringify(tableInsideLayout),
|
|
392
|
+
allowTables: {
|
|
393
|
+
advanced: true,
|
|
394
|
+
allowDistributeColumns: true,
|
|
395
|
+
},
|
|
396
|
+
allowLayouts: {
|
|
397
|
+
allowBreakout: true,
|
|
398
|
+
UNSAFE_allowSingleColumnLayout: true,
|
|
399
|
+
},
|
|
400
|
+
allowBreakout: true,
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
await resizeColumn(page, { cellHandlePos: 8, resizeWidth: -100 });
|
|
404
|
+
|
|
405
|
+
const singleColumnButton = await page.$('[aria-label="Single column"]');
|
|
406
|
+
singleColumnButton.click();
|
|
407
|
+
|
|
408
|
+
const breakoutButton = await page.$('[aria-label="Go wide"]');
|
|
409
|
+
|
|
410
|
+
await breakout(page, breakoutButton);
|
|
411
|
+
await assertTableDoesNotScroll(page);
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
BrowserTestCase(
|
|
417
|
+
'Table: Does not scroll when nested in three columns layout, table column is resized and breakout button is clicked',
|
|
418
|
+
{ skip: [] },
|
|
419
|
+
async (client: any, testName: string) => {
|
|
420
|
+
for (const screenWidth of screenWidths) {
|
|
421
|
+
const page = await goToEditorTestingWDExample(
|
|
422
|
+
client,
|
|
423
|
+
'editor-plugin-table',
|
|
424
|
+
{ width: screenWidth, height: 1440 },
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
await mountEditor(page, {
|
|
428
|
+
appearance: fullpage.appearance,
|
|
429
|
+
defaultValue: JSON.stringify(tableInsideLayout),
|
|
430
|
+
allowTables: {
|
|
431
|
+
advanced: true,
|
|
432
|
+
allowDistributeColumns: true,
|
|
433
|
+
},
|
|
434
|
+
allowLayouts: {
|
|
435
|
+
allowBreakout: true,
|
|
436
|
+
UNSAFE_allowSingleColumnLayout: true,
|
|
437
|
+
},
|
|
438
|
+
allowBreakout: true,
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
await resizeColumn(page, { cellHandlePos: 8, resizeWidth: -100 });
|
|
442
|
+
|
|
443
|
+
const threeColumnButton = await page.$('[aria-label="Three columns"]');
|
|
444
|
+
threeColumnButton.click();
|
|
445
|
+
|
|
446
|
+
const breakoutButton = await page.$('[aria-label="Go wide"]');
|
|
447
|
+
|
|
448
|
+
await breakout(page, breakoutButton);
|
|
449
|
+
await assertTableDoesNotScroll(page);
|
|
450
|
+
}
|
|
451
|
+
},
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
// insertColumn helper doesn't work in Safari
|
|
455
|
+
BrowserTestCase(
|
|
456
|
+
'Table: Does not scroll when nested in full-width layout, columns is resized and new column is inserted',
|
|
457
|
+
{ skip: ['safari'] },
|
|
458
|
+
async (client: any, testName: string) => {
|
|
459
|
+
for (const screenWidth of screenWidths) {
|
|
460
|
+
const page = await goToEditorTestingWDExample(
|
|
461
|
+
client,
|
|
462
|
+
'editor-plugin-table',
|
|
463
|
+
{ width: screenWidth, height: 1440 },
|
|
464
|
+
);
|
|
465
|
+
|
|
466
|
+
await mountEditor(page, {
|
|
467
|
+
appearance: fullpage.appearance,
|
|
468
|
+
defaultValue: emptyLayout,
|
|
469
|
+
allowTables: {
|
|
470
|
+
advanced: true,
|
|
471
|
+
},
|
|
472
|
+
allowLayouts: {
|
|
473
|
+
allowBreakout: true,
|
|
474
|
+
},
|
|
475
|
+
allowBreakout: true,
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
const goWideButton = await page.$('[aria-label="Go wide"]');
|
|
479
|
+
goWideButton.click();
|
|
480
|
+
goWideButton.click();
|
|
481
|
+
|
|
482
|
+
insertTable(page);
|
|
483
|
+
await assertTableDoesNotScroll(page);
|
|
484
|
+
await resizeColumn(page, { cellHandlePos: 4, resizeWidth: -100 });
|
|
485
|
+
await insertColumn(page, 0, 'right');
|
|
486
|
+
await assertTableDoesNotScroll(page);
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
);
|
|
@@ -58,9 +58,9 @@ describe('table plugin: insert', () => {
|
|
|
58
58
|
doc(
|
|
59
59
|
table({ localId: TABLE_LOCAL_ID })(
|
|
60
60
|
tr(
|
|
61
|
-
td({ colwidth: [
|
|
62
|
-
td({ colwidth: [
|
|
63
|
-
td({ colwidth: [
|
|
61
|
+
td({ colwidth: [230] })(p('')),
|
|
62
|
+
td({ colwidth: [230] })(p('')),
|
|
63
|
+
td({ colwidth: [230] })(p('')),
|
|
64
64
|
),
|
|
65
65
|
),
|
|
66
66
|
),
|
|
@@ -57,6 +57,7 @@ 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
59
|
import featureFlagsPlugin from '@atlaskit/editor-core/src/plugins/feature-flags-context';
|
|
60
|
+
import widthPlugin from '@atlaskit/editor-core/src/plugins/width';
|
|
60
61
|
|
|
61
62
|
const TABLE_LOCAL_ID = 'test-table-local-id';
|
|
62
63
|
|
|
@@ -101,7 +102,8 @@ describe('table keymap', () => {
|
|
|
101
102
|
.add([statusPlugin, { menuDisabled: false }])
|
|
102
103
|
.add([mediaPlugin, { allowMediaSingle: true }])
|
|
103
104
|
.add([analyticsPlugin, { createAnalyticsEvent }])
|
|
104
|
-
.add([featureFlagsPlugin, {}])
|
|
105
|
+
.add([featureFlagsPlugin, {}])
|
|
106
|
+
.add(widthPlugin);
|
|
105
107
|
|
|
106
108
|
const editor = (doc: DocBuilder) =>
|
|
107
109
|
createEditor<TablePluginState, PluginKey>({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { p, table, tr, td } from '@atlaskit/editor-test-helpers/doc-builder';
|
|
2
2
|
import defaultSchema from '@atlaskit/editor-test-helpers/schema';
|
|
3
|
+
import { isMinCellWidthTable } from '../../../../plugins/table/pm-plugins/table-resizing/utils/colgroup';
|
|
3
4
|
import { generateColgroup } from '../../../../plugins/table/pm-plugins/table-resizing/utils';
|
|
4
5
|
|
|
5
6
|
describe('table-resizing/colgroup', () => {
|
|
@@ -83,4 +84,41 @@ describe('table-resizing/colgroup', () => {
|
|
|
83
84
|
}
|
|
84
85
|
});
|
|
85
86
|
});
|
|
87
|
+
|
|
88
|
+
//isMinCellWidthTable function test
|
|
89
|
+
describe('#isMinCellWidthTable', () => {
|
|
90
|
+
describe('check if a table has all the columns with minimum width', () => {
|
|
91
|
+
it('when input table has all columns in minimum width', () => {
|
|
92
|
+
const result = isMinCellWidthTable(getMinCellWidthTable());
|
|
93
|
+
|
|
94
|
+
expect(result).toEqual(true);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('when input table has a column that is not minimum width', () => {
|
|
98
|
+
const result = isMinCellWidthTable(getNonMinCellWidthTable());
|
|
99
|
+
|
|
100
|
+
expect(result).toEqual(false);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
function getMinCellWidthTable() {
|
|
104
|
+
return table()(
|
|
105
|
+
tr(
|
|
106
|
+
td({ colwidth: [48] })(p('')),
|
|
107
|
+
td({ colwidth: [48] })(p('')),
|
|
108
|
+
td({ colwidth: [48] })(p('')),
|
|
109
|
+
),
|
|
110
|
+
)(defaultSchema);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function getNonMinCellWidthTable() {
|
|
114
|
+
return table()(
|
|
115
|
+
tr(
|
|
116
|
+
td({ colwidth: [200] })(p('')),
|
|
117
|
+
td({ colwidth: [200] })(p('')),
|
|
118
|
+
td({ colwidth: [48] })(p('')),
|
|
119
|
+
),
|
|
120
|
+
)(defaultSchema);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
86
124
|
});
|
|
@@ -26,7 +26,10 @@ import { EditorView } from 'prosemirror-view';
|
|
|
26
26
|
import panelPlugin from '@atlaskit/editor-core/src/plugins/panel';
|
|
27
27
|
import widthPlugin from '@atlaskit/editor-core/src/plugins/width';
|
|
28
28
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
akEditorFullPageMaxWidth,
|
|
31
|
+
akEditorDefaultLayoutWidth,
|
|
32
|
+
} from '@atlaskit/editor-shared-styles/consts';
|
|
30
33
|
|
|
31
34
|
describe('table-resizing/event-handlers', () => {
|
|
32
35
|
const editorAnalyticsAPIFake: EditorAnalyticsAPI = {
|
|
@@ -92,7 +95,7 @@ describe('table-resizing/event-handlers', () => {
|
|
|
92
95
|
|
|
93
96
|
// No matter how large we try to resize the result should equal the width (within 1 pt)
|
|
94
97
|
expect(getTotalTableWidth(view.state as EditorState)).toBeLessThanOrEqual(
|
|
95
|
-
|
|
98
|
+
akEditorDefaultLayoutWidth,
|
|
96
99
|
);
|
|
97
100
|
expect(
|
|
98
101
|
getTotalTableWidth(view.state as EditorState),
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
version https://git-lfs.github.com/spec/v1
|
|
2
|
-
oid sha256:
|
|
3
|
-
size
|
|
2
|
+
oid sha256:73e26bdfa1009884d8657a69ff2a721ecf9f0a0763629cae053550cf9b640425
|
|
3
|
+
size 29791
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
version https://git-lfs.github.com/spec/v1
|
|
2
|
-
oid sha256:
|
|
3
|
-
size
|
|
2
|
+
oid sha256:4c6f837604b1df78aef416e043bfd090906490e7604121f6f0c683d43dd7c9da
|
|
3
|
+
size 29783
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
version https://git-lfs.github.com/spec/v1
|
|
2
|
-
oid sha256:
|
|
3
|
-
size
|
|
2
|
+
oid sha256:19e5db9586d2f5b635464786308235a3da2adda2bea5ab7dcde7a50d901cd869
|
|
3
|
+
size 19731
|
|
@@ -38,7 +38,8 @@ describe('Snapshot Test: Table', () => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
describe('sticky header', () => {
|
|
41
|
-
|
|
41
|
+
// FIXME: This test was automatically skipped due to failure on 14/02/2023: https://product-fabric.atlassian.net/browse/ED-16900
|
|
42
|
+
it.skip('should align with table cell when active', async () => {
|
|
42
43
|
await initEditor(page, stickyHeaderWithHorizontalScroll);
|
|
43
44
|
|
|
44
45
|
await clickFirstCell(page, true);
|
|
@@ -55,6 +55,7 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
|
55
55
|
|
|
56
56
|
import memoizeOne from 'memoize-one';
|
|
57
57
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
58
|
+
import { getParentWidthWithoutPadding } from '../pm-plugins/table-resizing/utils/misc';
|
|
58
59
|
|
|
59
60
|
const isIE11 = browser.ie_version === 11;
|
|
60
61
|
const NOOP = () => undefined;
|
|
@@ -620,14 +621,23 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
620
621
|
|
|
621
622
|
private handleWindowResize = () => {
|
|
622
623
|
const { getNode, containerWidth } = this.props;
|
|
623
|
-
const
|
|
624
|
+
const node = getNode();
|
|
625
|
+
const prevNode = this.node;
|
|
626
|
+
const layoutSize = this.tableNodeLayoutSize(node);
|
|
627
|
+
const prevAttrs = prevNode?.attrs;
|
|
628
|
+
const layoutChanged =
|
|
629
|
+
prevAttrs?.layout !== node?.attrs?.layout &&
|
|
630
|
+
prevAttrs?.__autoSize === node?.attrs?.__autoSize;
|
|
624
631
|
|
|
625
632
|
if (containerWidth.width > layoutSize) {
|
|
626
633
|
return;
|
|
627
634
|
}
|
|
628
635
|
|
|
629
636
|
const parentWidth = this.getParentNodeWidth();
|
|
630
|
-
this.scaleTableDebounced(
|
|
637
|
+
this.scaleTableDebounced({
|
|
638
|
+
layoutChanged: layoutChanged,
|
|
639
|
+
parentWidth: parentWidth,
|
|
640
|
+
});
|
|
631
641
|
};
|
|
632
642
|
|
|
633
643
|
private updateTableContainerWidth = () => {
|
|
@@ -671,12 +681,15 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
671
681
|
if (!isValidPosition(pos, state)) {
|
|
672
682
|
return;
|
|
673
683
|
}
|
|
674
|
-
|
|
684
|
+
|
|
685
|
+
const parentNodeWith = getParentNodeWidth(
|
|
675
686
|
pos,
|
|
676
687
|
state,
|
|
677
688
|
containerWidth,
|
|
678
689
|
options && options.isFullWidthModeEnabled,
|
|
679
690
|
);
|
|
691
|
+
|
|
692
|
+
return getParentWidthWithoutPadding(parentNodeWith, pos, state);
|
|
680
693
|
};
|
|
681
694
|
|
|
682
695
|
private updateParentWidth = (width?: number) => {
|
|
@@ -33,7 +33,7 @@ export const scaleTable =
|
|
|
33
33
|
return false;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const { node, start, parentWidth } = options;
|
|
36
|
+
const { node, start, parentWidth, layoutChanged } = options;
|
|
37
37
|
|
|
38
38
|
// If a table has not been resized yet, columns should be auto.
|
|
39
39
|
if (hasTableBeenResized(node) === false) {
|
|
@@ -65,7 +65,11 @@ export const scaleTable =
|
|
|
65
65
|
// TODO: ED-8995
|
|
66
66
|
// We need to do this check to reduce the number of race conditions when working with tables.
|
|
67
67
|
// This metadata is been used in the sendTransaction function in the Collab plugin
|
|
68
|
-
|
|
68
|
+
/* Added !layoutChanged check here to solve unnecessary scroll bar after publish when click on breakout button multiple times and publish
|
|
69
|
+
scaleTable is only called once every time a breakout button is clicked, so it is safe not to add the meta 'scaleTable' to the tr.
|
|
70
|
+
Leaving the tr.setMeta('scaleTable', true) here for race conditions that we aren't aware of.
|
|
71
|
+
*/
|
|
72
|
+
!layoutChanged && tr.setMeta('scaleTable', true);
|
|
69
73
|
dispatch(tr);
|
|
70
74
|
return true;
|
|
71
75
|
}
|