@atlaskit/editor-plugin-table 5.4.7 → 5.4.9
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/commands/misc.js +14 -12
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -4
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +9 -3
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
- package/dist/cjs/plugins/table/types.js +2 -1
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +4 -1
- package/dist/cjs/plugins/table/ui/common-styles.js +6 -9
- package/dist/cjs/plugins/table/ui/ui-styles.js +12 -16
- package/dist/cjs/plugins/table/utils/decoration.js +20 -25
- package/dist/cjs/plugins/table/utils/drag-menu.js +2 -2
- package/dist/es2019/plugins/table/commands/misc.js +5 -4
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -4
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +9 -3
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
- package/dist/es2019/plugins/table/types.js +2 -1
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +4 -2
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +20 -20
- package/dist/es2019/plugins/table/ui/ui-styles.js +18 -21
- package/dist/es2019/plugins/table/utils/decoration.js +20 -25
- package/dist/es2019/plugins/table/utils/drag-menu.js +2 -2
- package/dist/esm/plugins/table/commands/misc.js +13 -13
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -4
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +9 -3
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
- package/dist/esm/plugins/table/types.js +2 -1
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +4 -2
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +4 -1
- package/dist/esm/plugins/table/ui/common-styles.js +6 -9
- package/dist/esm/plugins/table/ui/ui-styles.js +12 -16
- package/dist/esm/plugins/table/utils/decoration.js +20 -25
- package/dist/esm/plugins/table/utils/drag-menu.js +2 -2
- package/dist/types/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -2
- package/dist/types/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/decorations/utils/types.d.ts +10 -4
- package/dist/types/plugins/table/types.d.ts +2 -1
- package/dist/types/plugins/table/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/types.d.ts +10 -4
- package/dist/types-ts4.5/plugins/table/types.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/unit/event-handlers.ts +37 -38
- package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +46 -36
- package/src/plugins/table/commands/misc.ts +9 -7
- package/src/plugins/table/nodeviews/TableComponent.tsx +20 -22
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +7 -2
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +20 -11
- package/src/plugins/table/pm-plugins/decorations/utils/compose-decorations.ts +2 -4
- package/src/plugins/table/pm-plugins/decorations/utils/types.ts +14 -7
- package/src/plugins/table/types.ts +2 -1
- package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +12 -1
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +73 -67
- package/src/plugins/table/ui/common-styles.ts +20 -23
- package/src/plugins/table/ui/ui-styles.ts +18 -21
- package/src/plugins/table/utils/decoration.ts +27 -32
- package/src/plugins/table/utils/drag-menu.ts +8 -2
|
@@ -265,26 +265,6 @@ const tableStickyHeaderFirefoxFixStyle = (
|
|
|
265
265
|
}
|
|
266
266
|
};
|
|
267
267
|
|
|
268
|
-
const tableRowControlStyles = () => {
|
|
269
|
-
return getBooleanFF('platform.editor.table.drag-and-drop')
|
|
270
|
-
? css`
|
|
271
|
-
.${ClassName.ROW_CONTROLS_WRAPPER} {
|
|
272
|
-
position: absolute;
|
|
273
|
-
margin-top: ${tableMarginTop}px;
|
|
274
|
-
left: -${tableToolbarSize + 1}px;
|
|
275
|
-
z-index: ${rowControlsZIndex + 4};
|
|
276
|
-
}
|
|
277
|
-
`
|
|
278
|
-
: css`
|
|
279
|
-
.${ClassName.ROW_CONTROLS_WRAPPER} {
|
|
280
|
-
position: absolute;
|
|
281
|
-
/* top of corner control is table margin top - corner control height + 1 pixel of table border. */
|
|
282
|
-
top: ${tableMarginTop - cornerControlHeight + 1}px;
|
|
283
|
-
left: -${tableToolbarSize}px;
|
|
284
|
-
}
|
|
285
|
-
`;
|
|
286
|
-
};
|
|
287
|
-
|
|
288
268
|
const tableWrapperStyles = () => {
|
|
289
269
|
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
290
270
|
return css`
|
|
@@ -558,7 +538,8 @@ export const tableStyles = (
|
|
|
558
538
|
.less-padding {
|
|
559
539
|
padding: 0 ${tablePadding}px;
|
|
560
540
|
|
|
561
|
-
.${ClassName.
|
|
541
|
+
.${ClassName.DRAG_ROW_CONTROLS_WRAPPER},
|
|
542
|
+
.${ClassName.ROW_CONTROLS_WRAPPER} {
|
|
562
543
|
padding: 0 ${tablePadding}px;
|
|
563
544
|
|
|
564
545
|
// https://product-fabric.atlassian.net/browse/ED-16386
|
|
@@ -1056,8 +1037,24 @@ export const tableStyles = (
|
|
|
1056
1037
|
}
|
|
1057
1038
|
}
|
|
1058
1039
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1040
|
+
|
|
1041
|
+
// override for DnD controls
|
|
1042
|
+
.${ClassName.DRAG_ROW_CONTROLS_WRAPPER} {
|
|
1043
|
+
position: absolute;
|
|
1044
|
+
margin-top: ${tableMarginTop}px;
|
|
1045
|
+
left: -${tableToolbarSize + 1}px;
|
|
1046
|
+
z-index: ${rowControlsZIndex + 4};
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
.${ClassName.ROW_CONTROLS_WRAPPER} {
|
|
1050
|
+
position: absolute;
|
|
1051
|
+
/* top of corner control is table margin top - corner control height + 1 pixel of table border. */
|
|
1052
|
+
top: ${tableMarginTop - cornerControlHeight + 1}px;
|
|
1053
|
+
left: -${tableToolbarSize}px;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
.${ClassName.DRAG_ROW_CONTROLS_WRAPPER}.${ClassName.TABLE_LEFT_SHADOW},
|
|
1057
|
+
.${ClassName.ROW_CONTROLS_WRAPPER}.${ClassName.TABLE_LEFT_SHADOW} {
|
|
1061
1058
|
z-index: ${akEditorUnitZIndex};
|
|
1062
1059
|
}
|
|
1063
1060
|
|
|
@@ -500,27 +500,24 @@ export const floatingColumnControls = (props: ThemeProps) => {
|
|
|
500
500
|
};
|
|
501
501
|
|
|
502
502
|
export const rowControlsWrapperDotStyle = (props: ThemeProps) => {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
`;
|
|
523
|
-
}
|
|
503
|
+
return css`
|
|
504
|
+
// override for DnD controls
|
|
505
|
+
div.${ClassName.WITH_CONTROLS}>.${ClassName.DRAG_ROW_CONTROLS_WRAPPER}::after {
|
|
506
|
+
display: none;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
div.${ClassName.WITH_CONTROLS}>.${ClassName.ROW_CONTROLS_WRAPPER}::after {
|
|
510
|
+
content: ' ';
|
|
511
|
+
background-color: ${tableBorderColor(props)};
|
|
512
|
+
position: absolute;
|
|
513
|
+
height: ${lineMarkerSize}px;
|
|
514
|
+
width: ${lineMarkerSize}px;
|
|
515
|
+
border-radius: 50%;
|
|
516
|
+
pointer-events: none;
|
|
517
|
+
top: -${tableToolbarSize + tableCellBorderWidth}px;
|
|
518
|
+
right: -1px;
|
|
519
|
+
}
|
|
520
|
+
`;
|
|
524
521
|
};
|
|
525
522
|
|
|
526
523
|
export const columnControlsDecoration = (props: ThemeProps) => {
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
getCellsInRow,
|
|
23
23
|
getSelectionRect,
|
|
24
24
|
} from '@atlaskit/editor-tables/utils';
|
|
25
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
26
25
|
|
|
27
26
|
import type { Cell, CellColumnPositioning } from '../types';
|
|
28
27
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
@@ -219,37 +218,33 @@ export const createColumnControlsDecoration = (
|
|
|
219
218
|
): Decoration[] => {
|
|
220
219
|
const cells: ContentNodeWithPos[] = getCellsInRow(0)(selection) || [];
|
|
221
220
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
},
|
|
250
|
-
);
|
|
251
|
-
});
|
|
252
|
-
}
|
|
221
|
+
let index = 0;
|
|
222
|
+
return cells.map((cell) => {
|
|
223
|
+
const colspan = (cell.node.attrs as CellAttributes).colspan || 1;
|
|
224
|
+
// It's important these values are scoped locally as the widget callback could be executed anytime in the future
|
|
225
|
+
// and we want to avoid value leak
|
|
226
|
+
const startIndex = index;
|
|
227
|
+
const endIndex = startIndex + colspan;
|
|
228
|
+
|
|
229
|
+
// The next cell start index will commence from the current cell end index.
|
|
230
|
+
index = endIndex;
|
|
231
|
+
|
|
232
|
+
return Decoration.widget(
|
|
233
|
+
cell.pos + 1,
|
|
234
|
+
() => {
|
|
235
|
+
const element = document.createElement('div');
|
|
236
|
+
element.classList.add(ClassName.COLUMN_CONTROLS_DECORATIONS);
|
|
237
|
+
element.dataset.startIndex = `${startIndex}`;
|
|
238
|
+
element.dataset.endIndex = `${endIndex}`;
|
|
239
|
+
return element;
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
key: `${TableDecorations.COLUMN_CONTROLS_DECORATIONS}_${endIndex}`,
|
|
243
|
+
// this decoration should be the first one, even before gap cursor.
|
|
244
|
+
side: -100,
|
|
245
|
+
},
|
|
246
|
+
);
|
|
247
|
+
});
|
|
253
248
|
};
|
|
254
249
|
|
|
255
250
|
export const updateDecorations = (
|
|
@@ -57,6 +57,7 @@ export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
|
57
57
|
export const getDragMenuConfig = (
|
|
58
58
|
direction: TableDirection,
|
|
59
59
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
60
|
+
hasMergedCells: boolean,
|
|
60
61
|
tableMap?: TableMap,
|
|
61
62
|
index?: number,
|
|
62
63
|
targetCellPosition?: number,
|
|
@@ -95,7 +96,12 @@ export const getDragMenuConfig = (
|
|
|
95
96
|
const moveOptions =
|
|
96
97
|
direction === 'row'
|
|
97
98
|
? [
|
|
98
|
-
{
|
|
99
|
+
{
|
|
100
|
+
label: 'up',
|
|
101
|
+
offset: -1,
|
|
102
|
+
canMove: canDecrease,
|
|
103
|
+
icon: ArrowUpIcon,
|
|
104
|
+
},
|
|
99
105
|
{
|
|
100
106
|
label: 'down',
|
|
101
107
|
offset: 1,
|
|
@@ -190,7 +196,7 @@ export const getDragMenuConfig = (
|
|
|
190
196
|
...moveOptions.map(({ label, offset, canMove, icon }) => ({
|
|
191
197
|
id: `move_${direction}_${label}`,
|
|
192
198
|
title: `Move ${direction} ${label}`,
|
|
193
|
-
disabled: !canMove(index),
|
|
199
|
+
disabled: hasMergedCells || !canMove(index),
|
|
194
200
|
icon,
|
|
195
201
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
196
202
|
if (canMove(index)) {
|