@atlaskit/editor-plugin-table 0.1.2 → 0.2.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 +21 -0
- package/dist/cjs/plugins/table/commands/misc.js +4 -2
- package/dist/cjs/plugins/table/create-plugin-config.js +0 -1
- package/dist/cjs/plugins/table/event-handlers.js +5 -6
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +2 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +3 -5
- package/dist/cjs/plugins/table/reducer.js +3 -2
- package/dist/cjs/plugins/table/types.js +2 -1
- package/dist/cjs/plugins/table/ui/common-styles.js +8 -1
- package/dist/cjs/plugins/table/ui/ui-styles.js +4 -4
- package/dist/cjs/plugins/table/utils/column-controls.js +1 -1
- package/dist/cjs/plugins/table/utils/decoration.js +16 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/commands/misc.js +4 -2
- package/dist/es2019/plugins/table/create-plugin-config.js +0 -1
- package/dist/es2019/plugins/table/event-handlers.js +6 -7
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-resizing.js +2 -2
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +3 -8
- package/dist/es2019/plugins/table/reducer.js +3 -2
- package/dist/es2019/plugins/table/types.js +2 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +16 -17
- package/dist/es2019/plugins/table/ui/ui-styles.js +67 -24
- package/dist/es2019/plugins/table/utils/column-controls.js +1 -1
- package/dist/es2019/plugins/table/utils/decoration.js +16 -5
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/commands/misc.js +4 -2
- package/dist/esm/plugins/table/create-plugin-config.js +0 -1
- package/dist/esm/plugins/table/event-handlers.js +6 -7
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-resizing.js +2 -2
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +3 -8
- package/dist/esm/plugins/table/reducer.js +3 -2
- package/dist/esm/plugins/table/types.js +2 -1
- package/dist/esm/plugins/table/ui/common-styles.js +8 -1
- package/dist/esm/plugins/table/ui/ui-styles.js +5 -5
- package/dist/esm/plugins/table/utils/column-controls.js +1 -1
- package/dist/esm/plugins/table/utils/decoration.js +16 -5
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/commands/misc.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +1 -1
- package/dist/types/plugins/table/types.d.ts +3 -1
- package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
- package/package.json +2 -2
- package/src/__tests__/unit/event-handlers.ts +1 -1
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +5 -4
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +8 -0
- package/src/__tests__/visual-regression/__fixtures__/sticky-header-with-horizontal-scroll.json +5228 -0
- package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-1-snap.png +3 -0
- 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 +3 -0
- package/src/__tests__/visual-regression/cell-options-menu.ts +110 -99
- package/src/__tests__/visual-regression/index.ts +56 -44
- package/src/__tests__/visual-regression/sticky-header.ts +55 -0
- package/src/plugins/table/commands/misc.ts +10 -2
- package/src/plugins/table/create-plugin-config.ts +0 -1
- package/src/plugins/table/event-handlers.ts +9 -7
- package/src/plugins/table/pm-plugins/decorations/utils/column-resizing.ts +4 -2
- package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +5 -11
- package/src/plugins/table/reducer.ts +3 -1
- package/src/plugins/table/types.ts +7 -2
- package/src/plugins/table/ui/common-styles.ts +16 -20
- package/src/plugins/table/ui/ui-styles.ts +66 -25
- package/src/plugins/table/utils/column-controls.ts +1 -1
- package/src/plugins/table/utils/decoration.ts +17 -4
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
tableCellDeleteColor,
|
|
29
29
|
tableBorderDeleteColor,
|
|
30
30
|
tableToolbarDeleteColor,
|
|
31
|
-
lineMarkerOffsetFromColumnControls,
|
|
32
31
|
lineMarkerSize,
|
|
33
32
|
columnControlsDecorationHeight,
|
|
34
33
|
columnControlsZIndex,
|
|
@@ -39,7 +38,6 @@ import {
|
|
|
39
38
|
tableToolbarSize,
|
|
40
39
|
tableInsertColumnButtonSize,
|
|
41
40
|
tableDeleteButtonSize,
|
|
42
|
-
tableControlsSpacing,
|
|
43
41
|
} from './consts';
|
|
44
42
|
|
|
45
43
|
import { TableCssClassName as ClassName } from '../types';
|
|
@@ -211,13 +209,6 @@ export const columnControlsLineMarker = (props: ThemeProps) => css`
|
|
|
211
209
|
tr:first-of-type
|
|
212
210
|
th {
|
|
213
211
|
position: relative;
|
|
214
|
-
|
|
215
|
-
&::before {
|
|
216
|
-
content: ' ';
|
|
217
|
-
${Marker(props)};
|
|
218
|
-
top: -${tableToolbarSize + lineMarkerOffsetFromColumnControls}px;
|
|
219
|
-
right: -${lineMarkerSize / 2}px;
|
|
220
|
-
}
|
|
221
212
|
}
|
|
222
213
|
`;
|
|
223
214
|
|
|
@@ -281,11 +272,6 @@ export const OverflowShadow = (props: ThemeProps) => css`
|
|
|
281
272
|
border-left: 1px solid ${tableBorderColor(props)};
|
|
282
273
|
}
|
|
283
274
|
}
|
|
284
|
-
.${ClassName.WITH_CONTROLS}.${ClassName.TABLE_STICKY} {
|
|
285
|
-
.${ClassName.TABLE_RIGHT_SHADOW}, .${ClassName.TABLE_LEFT_SHADOW} {
|
|
286
|
-
top: ${tableControlsSpacing}px;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
275
|
`;
|
|
290
276
|
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
291
277
|
|
|
@@ -320,6 +306,18 @@ export const columnControlsDecoration = (props: ThemeProps) => css`
|
|
|
320
306
|
top: -${columnControlsDecorationHeight + tableCellBorderWidth}px;
|
|
321
307
|
height: ${columnControlsDecorationHeight}px;
|
|
322
308
|
|
|
309
|
+
&::before {
|
|
310
|
+
content: ' ';
|
|
311
|
+
background-color: ${tableBorderColor(props)};
|
|
312
|
+
position: absolute;
|
|
313
|
+
height: ${lineMarkerSize}px;
|
|
314
|
+
width: ${lineMarkerSize}px;
|
|
315
|
+
border-radius: 50%;
|
|
316
|
+
pointer-events: none;
|
|
317
|
+
top: 2px;
|
|
318
|
+
right: -1px;
|
|
319
|
+
}
|
|
320
|
+
|
|
323
321
|
&::after {
|
|
324
322
|
content: ' ';
|
|
325
323
|
|
|
@@ -341,6 +339,18 @@ export const columnControlsDecoration = (props: ThemeProps) => css`
|
|
|
341
339
|
}
|
|
342
340
|
}
|
|
343
341
|
|
|
342
|
+
div.${ClassName.WITH_CONTROLS}>.${ClassName.ROW_CONTROLS_WRAPPER}::after {
|
|
343
|
+
content: ' ';
|
|
344
|
+
background-color: ${tableBorderColor(props)};
|
|
345
|
+
position: absolute;
|
|
346
|
+
height: ${lineMarkerSize}px;
|
|
347
|
+
width: ${lineMarkerSize}px;
|
|
348
|
+
border-radius: 50%;
|
|
349
|
+
pointer-events: none;
|
|
350
|
+
top: -${tableToolbarSize + tableCellBorderWidth}px;
|
|
351
|
+
right: -1px;
|
|
352
|
+
}
|
|
353
|
+
|
|
344
354
|
.${ClassName.WITH_CONTROLS} .${ClassName.COLUMN_CONTROLS_DECORATIONS} {
|
|
345
355
|
display: block;
|
|
346
356
|
}
|
|
@@ -431,17 +441,48 @@ export const resizeHandle = css`
|
|
|
431
441
|
z-index: ${resizeHandlerZIndex};
|
|
432
442
|
}
|
|
433
443
|
|
|
434
|
-
td.${ClassName.WITH_RESIZE_LINE}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
444
|
+
td.${ClassName.WITH_RESIZE_LINE}::before {
|
|
445
|
+
content: ' ';
|
|
446
|
+
position: absolute;
|
|
447
|
+
left: -2px;
|
|
448
|
+
top: -1px;
|
|
449
|
+
width: ${resizeLineWidth}px;
|
|
450
|
+
height: calc(100% + 2px);
|
|
451
|
+
background-color: ${tableBorderSelectedColor};
|
|
452
|
+
z-index: ${columnControlsZIndex * 2};
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
th.${ClassName.WITH_RESIZE_LINE}::before {
|
|
456
|
+
content: ' ';
|
|
457
|
+
left: -2px;
|
|
458
|
+
position: absolute;
|
|
459
|
+
width: ${resizeLineWidth}px;
|
|
460
|
+
height: calc(100% + ${tableToolbarSize + tableCellBorderWidth}px);
|
|
461
|
+
background-color: ${tableBorderSelectedColor};
|
|
462
|
+
z-index: ${columnControlsZIndex * 2};
|
|
463
|
+
top: -${tableToolbarSize + tableCellBorderWidth}px;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
td.${ClassName.WITH_RESIZE_LINE_LAST_COLUMN}::before {
|
|
467
|
+
content: ' ';
|
|
468
|
+
position: absolute;
|
|
469
|
+
right: -1px;
|
|
470
|
+
top: -1px;
|
|
471
|
+
width: ${resizeLineWidth}px;
|
|
472
|
+
height: calc(100% + 2px);
|
|
473
|
+
background-color: ${tableBorderSelectedColor};
|
|
474
|
+
z-index: ${columnControlsZIndex * 2};
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
th.${ClassName.WITH_RESIZE_LINE_LAST_COLUMN}::before {
|
|
478
|
+
content: ' ';
|
|
479
|
+
right: -1px;
|
|
480
|
+
position: absolute;
|
|
481
|
+
width: ${resizeLineWidth}px;
|
|
482
|
+
height: calc(100% + ${tableToolbarSize + tableCellBorderWidth}px);
|
|
483
|
+
background-color: ${tableBorderSelectedColor};
|
|
484
|
+
z-index: ${columnControlsZIndex * 2};
|
|
485
|
+
top: -${tableToolbarSize + tableCellBorderWidth}px;
|
|
445
486
|
}
|
|
446
487
|
|
|
447
488
|
table
|
|
@@ -195,7 +195,7 @@ export const colWidthsForRow = (
|
|
|
195
195
|
if (copyTarget) {
|
|
196
196
|
// either from the first row while it's still in the table
|
|
197
197
|
const cellInfos = maphElem(copyTarget, (cell) => ({
|
|
198
|
-
width: cell.
|
|
198
|
+
width: cell.getBoundingClientRect().width,
|
|
199
199
|
colspan: Number(cell.getAttribute('colspan') || 1),
|
|
200
200
|
colwidth: cell.dataset.colwidth,
|
|
201
201
|
}));
|
|
@@ -291,6 +291,7 @@ const makeArray = (n: number) => Array.from(Array(n).keys());
|
|
|
291
291
|
*/
|
|
292
292
|
export const createResizeHandleDecoration = (
|
|
293
293
|
tr: Transaction | ReadonlyTransaction,
|
|
294
|
+
rowIndexTarget: number,
|
|
294
295
|
columnEndIndexTarget: Omit<CellColumnPositioning, 'left'>,
|
|
295
296
|
): [Decoration[], Decoration[]] => {
|
|
296
297
|
const emptyResult: [Decoration[], Decoration[]] = [[], []];
|
|
@@ -361,6 +362,10 @@ export const createResizeHandleDecoration = (
|
|
|
361
362
|
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
362
363
|
const seen: { [key: number]: boolean } = {};
|
|
363
364
|
|
|
365
|
+
if (rowIndex !== rowIndexTarget) {
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
|
|
364
369
|
for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
365
370
|
const cellPosition = map.map[map.width * rowIndex + columnIndex];
|
|
366
371
|
if (seen[cellPosition]) {
|
|
@@ -456,16 +461,24 @@ export const createColumnLineResize = (
|
|
|
456
461
|
return [];
|
|
457
462
|
}
|
|
458
463
|
|
|
459
|
-
|
|
464
|
+
let columnIndex = cellColumnPositioning.right;
|
|
460
465
|
const map = TableMap.get(table.node);
|
|
461
466
|
|
|
467
|
+
const isLastColumn = columnIndex === map.width;
|
|
468
|
+
if (isLastColumn) {
|
|
469
|
+
columnIndex -= 1;
|
|
470
|
+
}
|
|
471
|
+
const decorationClassName = isLastColumn
|
|
472
|
+
? ClassName.WITH_RESIZE_LINE_LAST_COLUMN
|
|
473
|
+
: ClassName.WITH_RESIZE_LINE;
|
|
474
|
+
|
|
462
475
|
const cellPositions = makeArray(map.height)
|
|
463
476
|
.map((rowIndex) => map.map[map.width * rowIndex + columnIndex])
|
|
464
477
|
.filter((cellPosition, rowIndex) => {
|
|
465
|
-
if (
|
|
478
|
+
if (isLastColumn) {
|
|
466
479
|
return true; // If is the last column no filter applied
|
|
467
480
|
}
|
|
468
|
-
const nextPosition = map.map[map.width * rowIndex + columnIndex
|
|
481
|
+
const nextPosition = map.map[map.width * rowIndex + columnIndex - 1];
|
|
469
482
|
return cellPosition !== nextPosition; // Removed it if next position is merged
|
|
470
483
|
});
|
|
471
484
|
|
|
@@ -484,7 +497,7 @@ export const createColumnLineResize = (
|
|
|
484
497
|
cell.pos,
|
|
485
498
|
cell.pos + cell.node.nodeSize,
|
|
486
499
|
{
|
|
487
|
-
class:
|
|
500
|
+
class: decorationClassName,
|
|
488
501
|
},
|
|
489
502
|
{
|
|
490
503
|
key: `${TableDecorations.COLUMN_RESIZING_HANDLE_LINE}_${cellColumnPositioning.right}_${index}`,
|