@atlaskit/editor-plugin-table 5.7.9 → 5.7.10
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 +8 -0
- package/dist/cjs/nodeviews/ExternalDropTargets.js +2 -1
- package/dist/cjs/pm-plugins/drag-and-drop/commands.js +3 -3
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +2 -1
- package/dist/cjs/types.js +6 -1
- package/dist/cjs/ui/DragHandle/index.js +1 -1
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
- package/dist/cjs/ui/ui-styles.js +6 -2
- package/dist/cjs/utils/decoration.js +14 -4
- package/dist/es2019/nodeviews/ExternalDropTargets.js +2 -1
- package/dist/es2019/pm-plugins/drag-and-drop/commands.js +3 -3
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +2 -1
- package/dist/es2019/types.js +6 -1
- package/dist/es2019/ui/DragHandle/index.js +1 -1
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -2
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
- package/dist/es2019/ui/ui-styles.js +108 -65
- package/dist/es2019/utils/decoration.js +14 -4
- package/dist/esm/nodeviews/ExternalDropTargets.js +2 -1
- package/dist/esm/pm-plugins/drag-and-drop/commands.js +3 -3
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +2 -1
- package/dist/esm/types.js +6 -1
- package/dist/esm/ui/DragHandle/index.js +1 -1
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -2
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
- package/dist/esm/ui/ui-styles.js +7 -3
- package/dist/esm/utils/decoration.js +14 -4
- package/dist/types/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types/types.d.ts +5 -0
- package/dist/types/utils/decoration.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +5 -0
- package/dist/types-ts4.5/utils/decoration.d.ts +2 -2
- package/package.json +4 -4
- package/src/__tests__/unit/analytics.ts +5 -1
- package/src/__tests__/unit/ui/RowDragControls.tsx +5 -4
- package/src/nodeviews/ExternalDropTargets.tsx +1 -0
- package/src/pm-plugins/drag-and-drop/commands.ts +3 -2
- package/src/pm-plugins/drag-and-drop/plugin.ts +10 -4
- package/src/types.ts +6 -0
- package/src/ui/DragHandle/index.tsx +1 -1
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +35 -37
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +33 -33
- package/src/ui/ui-styles.ts +115 -64
- package/src/utils/decoration.ts +27 -8
|
@@ -17,7 +17,7 @@ export var getDecorations = function getDecorations(state) {
|
|
|
17
17
|
export var updatePluginStateDecorations = function updatePluginStateDecorations(state, decorations, key) {
|
|
18
18
|
return updateDecorations(state.doc, getDecorations(state), decorations, key);
|
|
19
19
|
};
|
|
20
|
-
export var setDropTarget = function setDropTarget(type, index, tr) {
|
|
20
|
+
export var setDropTarget = function setDropTarget(type, index, hasMergedCells, tr) {
|
|
21
21
|
return createCommand(function (state) {
|
|
22
22
|
var _getPluginState = getPluginState(state),
|
|
23
23
|
dropTargetType = _getPluginState.dropTargetType,
|
|
@@ -27,9 +27,9 @@ export var setDropTarget = function setDropTarget(type, index, tr) {
|
|
|
27
27
|
}
|
|
28
28
|
var decorationSet = DecorationSet.empty;
|
|
29
29
|
if (type === 'column') {
|
|
30
|
-
decorationSet = updatePluginStateDecorations(state, createColumnInsertLine(index, state.selection), TableDecorations.COLUMN_INSERT_LINE);
|
|
30
|
+
decorationSet = updatePluginStateDecorations(state, createColumnInsertLine(index, state.selection, hasMergedCells), TableDecorations.COLUMN_INSERT_LINE);
|
|
31
31
|
} else if (type === 'row') {
|
|
32
|
-
decorationSet = updatePluginStateDecorations(state, createRowInsertLine(index, state.selection), TableDecorations.ROW_INSERT_LINE);
|
|
32
|
+
decorationSet = updatePluginStateDecorations(state, createRowInsertLine(index, state.selection, hasMergedCells), TableDecorations.ROW_INSERT_LINE);
|
|
33
33
|
}
|
|
34
34
|
return {
|
|
35
35
|
type: DragAndDropActionType.SET_DROP_TARGET,
|
|
@@ -131,7 +131,8 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher, edito
|
|
|
131
131
|
var sourceType = data.sourceType,
|
|
132
132
|
targetAdjustedIndex = data.targetAdjustedIndex;
|
|
133
133
|
var dropTargetType = sourceType === 'table-row' ? DropTargetType.ROW : DropTargetType.COLUMN;
|
|
134
|
-
|
|
134
|
+
var hasMergedCells = hasMergedCellsInBetween([targetAdjustedIndex - 1, targetAdjustedIndex], dropTargetType)(editorView.state.selection);
|
|
135
|
+
setDropTarget(dropTargetType, targetAdjustedIndex, hasMergedCells)(editorView.state, editorView.dispatch);
|
|
135
136
|
},
|
|
136
137
|
onDrop: function onDrop(event) {
|
|
137
138
|
var _cell$row, _cell$col;
|
package/dist/esm/types.js
CHANGED
|
@@ -134,12 +134,17 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
|
|
|
134
134
|
TOP_LEFT_CELL: 'table > tbody > tr:nth-child(2) > td:nth-child(1)',
|
|
135
135
|
LAST_ITEM_IN_CELL: "".concat(tablePrefixSelector, "-last-item-in-cell"),
|
|
136
136
|
WITH_COLUMN_INSERT_LINE: "".concat(tablePrefixSelector, "-column-insert-line"),
|
|
137
|
+
WITH_COLUMN_INSERT_LINE_INACTIVE: "".concat(tablePrefixSelector, "-column-insert-line__inactive"),
|
|
137
138
|
WITH_FIRST_COLUMN_INSERT_LINE: "".concat(tablePrefixSelector, "-first-column-insert-line"),
|
|
139
|
+
WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE: "".concat(tablePrefixSelector, "-first-column-insert-line__inactive"),
|
|
138
140
|
WITH_LAST_COLUMN_INSERT_LINE: "".concat(tablePrefixSelector, "-last-column-insert-line"),
|
|
141
|
+
WITH_LAST_COLUMN_INSERT_LINE_INACTIVE: "".concat(tablePrefixSelector, "-last-column-insert-line__inactive"),
|
|
139
142
|
WITH_RESIZE_LINE: "".concat(tablePrefixSelector, "-column-resize-line"),
|
|
140
143
|
WITH_RESIZE_LINE_LAST_COLUMN: "".concat(tablePrefixSelector, "-column-resize-line-last-column"),
|
|
141
144
|
WITH_ROW_INSERT_LINE: "".concat(tablePrefixSelector, "-row-insert-line"),
|
|
142
|
-
|
|
145
|
+
WITH_ROW_INSERT_LINE_INACTIVE: "".concat(tablePrefixSelector, "-row-insert-line__inactive"),
|
|
146
|
+
WITH_LAST_ROW_INSERT_LINE: "".concat(tablePrefixSelector, "-last-row-insert-line"),
|
|
147
|
+
WITH_LAST_ROW_INSERT_LINE_INACTIVE: "".concat(tablePrefixSelector, "-last-row-insert-line__inactive")
|
|
143
148
|
});
|
|
144
149
|
export var ShadowEvent = /*#__PURE__*/function (ShadowEvent) {
|
|
145
150
|
ShadowEvent["SHOW_BEFORE_SHADOW"] = "showBeforeShadow";
|
|
@@ -113,7 +113,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
113
113
|
style: {
|
|
114
114
|
transform: direction === 'column' ? 'none' : 'rotate(90deg)'
|
|
115
115
|
},
|
|
116
|
-
"data-testid": "table-
|
|
116
|
+
"data-testid": "table-drag-handle-button",
|
|
117
117
|
onMouseOver: onMouseOver,
|
|
118
118
|
onMouseOut: onMouseOut,
|
|
119
119
|
onMouseUp: function onMouseUp(e) {
|
|
@@ -144,7 +144,7 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
144
144
|
|
|
145
145
|
// this indexes are used to calculate the drag and drop source
|
|
146
146
|
var indexes = isColumnsSelected ? isHover ? colIndexes : selectedColIndexes : colIndexes;
|
|
147
|
-
return
|
|
147
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
148
148
|
key: type,
|
|
149
149
|
style: {
|
|
150
150
|
gridColumn: isSelecting ? selectedColumnPosition : gridColumnPosition,
|
|
@@ -156,7 +156,7 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
156
156
|
zIndex: 99
|
|
157
157
|
},
|
|
158
158
|
"data-column-control-index": hoveredCell.colIndex,
|
|
159
|
-
"data-testid":
|
|
159
|
+
"data-testid": "table-floating-column-".concat(isSelecting ? selectedColIndexes[0] : colIndex, "-drag-handle")
|
|
160
160
|
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
161
161
|
isDragMenuTarget: !isHover,
|
|
162
162
|
direction: "column",
|
|
@@ -130,7 +130,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
130
130
|
var currentSelectionAppearance = isRowsSelected ? isInDanger ? 'danger' : 'selected' : hoveredAppearance;
|
|
131
131
|
var isSelecting = isRowsSelected && !isHover;
|
|
132
132
|
var indexes = isRowsSelected ? isHover ? rowIndexes : selectedRowIndexes : rowIndexes;
|
|
133
|
-
return
|
|
133
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
134
134
|
key: type,
|
|
135
135
|
style: {
|
|
136
136
|
gridRow: isSelecting ? selectedRowPosition : gridRowPosition,
|
|
@@ -140,7 +140,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
140
140
|
position: 'relative',
|
|
141
141
|
right: '-0.5px'
|
|
142
142
|
},
|
|
143
|
-
"data-testid":
|
|
143
|
+
"data-testid": "table-floating-row-".concat(isSelecting ? selectedRowIndexes[0] : rowIndex, "-drag-handle")
|
|
144
144
|
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
145
145
|
isDragMenuTarget: !isHover,
|
|
146
146
|
direction: "row",
|
package/dist/esm/ui/ui-styles.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33;
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33, _templateObject34, _templateObject35, _templateObject36, _templateObject37;
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { tableCellBorderWidth, tableMarginTop, tableMarginTopWithControl } from '@atlaskit/editor-common/styles';
|
|
5
|
-
import { akEditorShadowZIndex, akEditorTableNumberColumnWidth, akEditorUnitZIndex } from '@atlaskit/editor-shared-styles';
|
|
5
|
+
import { akEditorShadowZIndex, akEditorTableBorder, akEditorTableNumberColumnWidth, akEditorUnitZIndex } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { B300, N0, N300, N40A, N60A, Y200, Y50 } from '@atlaskit/theme/colors';
|
|
8
8
|
import { TableCssClassName as ClassName } from '../types';
|
|
@@ -112,6 +112,10 @@ export var resizeHandle = function resizeHandle() {
|
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
// Drag and Drop: drop target insert line
|
|
115
|
+
var tableCellColumnInsertLineStyles = css(_templateObject33 || (_templateObject33 = _taggedTemplateLiteral(["\n content: ' ';\n position: absolute;\n height: calc(100% + ", "px);\n width: ", "px;\n z-index: ", ";\n"])), tableCellBorderWidth * 2, insertLineWidth, columnControlsZIndex * 2);
|
|
116
|
+
var tableCellRowInsertLineStyles = css(_templateObject34 || (_templateObject34 = _taggedTemplateLiteral(["\n content: ' ';\n position: absolute;\n left: ", ";\n height: ", "px;\n width: calc(100% + ", "px);\n z-index: ", ";\n"])), "var(--ds-space-negative-025, -2px)", insertLineWidth, tableCellBorderWidth * 2, columnControlsZIndex * 2);
|
|
117
|
+
var insertLineActiveColor = css(_templateObject35 || (_templateObject35 = _taggedTemplateLiteral(["\n background-color: ", ";\n"])), tableBorderSelectedColor);
|
|
118
|
+
var insertLineInactiveColor = css(_templateObject36 || (_templateObject36 = _taggedTemplateLiteral(["\n background-color: ", ";\n"])), "var(--ds-background-accent-gray-subtler, ".concat(akEditorTableBorder, ")"));
|
|
115
119
|
export var insertLine = function insertLine() {
|
|
116
|
-
return css(
|
|
120
|
+
return css(_templateObject37 || (_templateObject37 = _taggedTemplateLiteral(["\n .", " {\n td.", "::before {\n ", "\n left: -1px;\n top: -1px;\n ", "\n }\n\n td.", "::before {\n ", "\n left: -1px;\n top: -1px;\n ", "\n }\n\n th.", "::before {\n ", "\n left: -1px;\n top: -", "px;\n ", "\n }\n\n th.", "::before {\n ", "\n left: -1px;\n top: -", "px;\n ", "\n }\n\n td.", "::before {\n ", "\n left: ", ";\n top: -1px;\n ", "\n }\n\n td.", "::before {\n ", "\n left: ", ";\n top: -1px;\n ", "\n }\n\n th.", "::before {\n ", "\n left: ", ";\n top: -", "px;\n ", "\n }\n\n th.", "::before {\n ", "\n left: ", ";\n top: -", "px;\n ", "\n }\n\n td.", "::before {\n ", "\n right: -1px;\n top: -1px;\n ", "\n }\n\n td.", "::before {\n ", "\n right: -1px;\n top: -1px;\n ", "\n }\n\n th.", "::before {\n ", "\n right: -1px;\n top: -", "px;\n ", "\n }\n\n th.", "::before {\n ", "\n right: -1px;\n top: -", "px;\n ", "\n }\n\n td.", "::before {\n ", "\n top: -1px;\n ", "\n }\n\n td.", "::before {\n ", "\n top: -1px;\n ", "\n }\n\n th.", "::before {\n ", "\n top: -1px;\n ", "\n }\n\n th.", "::before {\n ", "\n top: -1px;\n ", "\n }\n\n td.", "::before {\n ", "\n bottom: 0;\n ", "\n }\n\n td.", "::before {\n ", "\n bottom: 0;\n ", "\n }\n\n th.", "::before {\n ", "\n bottom: 0;\n ", "\n }\n\n th.", "::before {\n ", "\n bottom: 0;\n ", "\n }\n }\n"])), ClassName.TABLE_CONTAINER, ClassName.WITH_FIRST_COLUMN_INSERT_LINE, tableCellColumnInsertLineStyles, insertLineActiveColor, ClassName.WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE, tableCellColumnInsertLineStyles, insertLineInactiveColor, ClassName.WITH_FIRST_COLUMN_INSERT_LINE, tableCellColumnInsertLineStyles, tableCellBorderWidth, insertLineActiveColor, ClassName.WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE, tableCellColumnInsertLineStyles, tableCellBorderWidth, insertLineInactiveColor, ClassName.WITH_COLUMN_INSERT_LINE, tableCellColumnInsertLineStyles, "var(--ds-space-negative-025, -2px)", insertLineActiveColor, ClassName.WITH_COLUMN_INSERT_LINE_INACTIVE, tableCellColumnInsertLineStyles, "var(--ds-space-negative-025, -2px)", insertLineInactiveColor, ClassName.WITH_COLUMN_INSERT_LINE, tableCellColumnInsertLineStyles, "var(--ds-space-negative-025, -2px)", tableCellBorderWidth, insertLineActiveColor, ClassName.WITH_COLUMN_INSERT_LINE_INACTIVE, tableCellColumnInsertLineStyles, "var(--ds-space-negative-025, -2px)", tableCellBorderWidth, insertLineInactiveColor, ClassName.WITH_LAST_COLUMN_INSERT_LINE, tableCellColumnInsertLineStyles, insertLineActiveColor, ClassName.WITH_LAST_COLUMN_INSERT_LINE_INACTIVE, tableCellColumnInsertLineStyles, insertLineInactiveColor, ClassName.WITH_LAST_COLUMN_INSERT_LINE, tableCellColumnInsertLineStyles, tableCellBorderWidth, insertLineActiveColor, ClassName.WITH_LAST_COLUMN_INSERT_LINE_INACTIVE, tableCellColumnInsertLineStyles, tableCellBorderWidth, insertLineInactiveColor, ClassName.WITH_ROW_INSERT_LINE, tableCellRowInsertLineStyles, insertLineActiveColor, ClassName.WITH_ROW_INSERT_LINE_INACTIVE, tableCellRowInsertLineStyles, insertLineInactiveColor, ClassName.WITH_ROW_INSERT_LINE, tableCellRowInsertLineStyles, insertLineActiveColor, ClassName.WITH_ROW_INSERT_LINE_INACTIVE, tableCellRowInsertLineStyles, insertLineInactiveColor, ClassName.WITH_LAST_ROW_INSERT_LINE, tableCellRowInsertLineStyles, insertLineActiveColor, ClassName.WITH_LAST_ROW_INSERT_LINE_INACTIVE, tableCellRowInsertLineStyles, insertLineInactiveColor, ClassName.WITH_LAST_ROW_INSERT_LINE, tableCellRowInsertLineStyles, insertLineActiveColor, ClassName.WITH_LAST_ROW_INSERT_LINE_INACTIVE, tableCellRowInsertLineStyles, insertLineInactiveColor);
|
|
117
121
|
};
|
|
@@ -453,7 +453,7 @@ export var createColumnLineResize = function createColumnLineResize(selection, c
|
|
|
453
453
|
});
|
|
454
454
|
}).filter(nonNullable);
|
|
455
455
|
};
|
|
456
|
-
export var createColumnInsertLine = function createColumnInsertLine(columnIndex, selection) {
|
|
456
|
+
export var createColumnInsertLine = function createColumnInsertLine(columnIndex, selection, hasMergedCells) {
|
|
457
457
|
var table = findTable(selection);
|
|
458
458
|
if (!table) {
|
|
459
459
|
return [];
|
|
@@ -464,7 +464,12 @@ export var createColumnInsertLine = function createColumnInsertLine(columnIndex,
|
|
|
464
464
|
if (isLastColumn) {
|
|
465
465
|
columnIndex -= 1;
|
|
466
466
|
}
|
|
467
|
-
var decorationClassName
|
|
467
|
+
var decorationClassName;
|
|
468
|
+
if (hasMergedCells) {
|
|
469
|
+
decorationClassName = isFirstColumn ? ClassName.WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE : isLastColumn ? ClassName.WITH_LAST_COLUMN_INSERT_LINE_INACTIVE : ClassName.WITH_COLUMN_INSERT_LINE_INACTIVE;
|
|
470
|
+
} else {
|
|
471
|
+
decorationClassName = isFirstColumn ? ClassName.WITH_FIRST_COLUMN_INSERT_LINE : isLastColumn ? ClassName.WITH_LAST_COLUMN_INSERT_LINE : ClassName.WITH_COLUMN_INSERT_LINE;
|
|
472
|
+
}
|
|
468
473
|
var cellPositions = makeArray(map.height).map(function (rowIndex) {
|
|
469
474
|
return map.map[map.width * rowIndex + columnIndex];
|
|
470
475
|
}).filter(function (cellPosition, rowIndex) {
|
|
@@ -493,7 +498,7 @@ export var createColumnInsertLine = function createColumnInsertLine(columnIndex,
|
|
|
493
498
|
});
|
|
494
499
|
}).filter(nonNullable);
|
|
495
500
|
};
|
|
496
|
-
export var createRowInsertLine = function createRowInsertLine(rowIndex, selection) {
|
|
501
|
+
export var createRowInsertLine = function createRowInsertLine(rowIndex, selection, hasMergedCells) {
|
|
497
502
|
var table = findTable(selection);
|
|
498
503
|
if (!table) {
|
|
499
504
|
return [];
|
|
@@ -507,7 +512,12 @@ export var createRowInsertLine = function createRowInsertLine(rowIndex, selectio
|
|
|
507
512
|
if (!cells) {
|
|
508
513
|
return [];
|
|
509
514
|
}
|
|
510
|
-
var decorationClassName
|
|
515
|
+
var decorationClassName;
|
|
516
|
+
if (hasMergedCells) {
|
|
517
|
+
decorationClassName = isLastRow ? ClassName.WITH_LAST_ROW_INSERT_LINE_INACTIVE : ClassName.WITH_ROW_INSERT_LINE_INACTIVE;
|
|
518
|
+
} else {
|
|
519
|
+
decorationClassName = isLastRow ? ClassName.WITH_LAST_ROW_INSERT_LINE : ClassName.WITH_ROW_INSERT_LINE;
|
|
520
|
+
}
|
|
511
521
|
return cells.map(function (cell, index) {
|
|
512
522
|
if (!cell || !cell.node) {
|
|
513
523
|
return;
|
|
@@ -6,7 +6,7 @@ import { TableDecorations } from '../../types';
|
|
|
6
6
|
import { DropTargetType } from './consts';
|
|
7
7
|
export declare const getDecorations: (state: EditorState) => DecorationSet;
|
|
8
8
|
export declare const updatePluginStateDecorations: (state: EditorState, decorations: Decoration[], key: TableDecorations) => DecorationSet;
|
|
9
|
-
export declare const setDropTarget: (type: DropTargetType, index: number, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
|
|
9
|
+
export declare const setDropTarget: (type: DropTargetType, index: number, hasMergedCells: boolean, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
|
|
10
10
|
export declare const clearDropTarget: (tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
|
|
11
11
|
export declare const moveSource: (sourceType: DraggableType, sourceIndex: number, targetIndex: number, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
|
|
12
12
|
export declare const toggleDragMenu: (isDragMenuOpen: boolean | undefined, direction?: TableDirection, index?: number) => import("@atlaskit/editor-common/types").Command;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -338,12 +338,17 @@ export declare const TableCssClassName: {
|
|
|
338
338
|
TOP_LEFT_CELL: string;
|
|
339
339
|
LAST_ITEM_IN_CELL: string;
|
|
340
340
|
WITH_COLUMN_INSERT_LINE: string;
|
|
341
|
+
WITH_COLUMN_INSERT_LINE_INACTIVE: string;
|
|
341
342
|
WITH_FIRST_COLUMN_INSERT_LINE: string;
|
|
343
|
+
WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE: string;
|
|
342
344
|
WITH_LAST_COLUMN_INSERT_LINE: string;
|
|
345
|
+
WITH_LAST_COLUMN_INSERT_LINE_INACTIVE: string;
|
|
343
346
|
WITH_RESIZE_LINE: string;
|
|
344
347
|
WITH_RESIZE_LINE_LAST_COLUMN: string;
|
|
345
348
|
WITH_ROW_INSERT_LINE: string;
|
|
349
|
+
WITH_ROW_INSERT_LINE_INACTIVE: string;
|
|
346
350
|
WITH_LAST_ROW_INSERT_LINE: string;
|
|
351
|
+
WITH_LAST_ROW_INSERT_LINE_INACTIVE: string;
|
|
347
352
|
TABLE_CONTAINER: string;
|
|
348
353
|
TABLE_NODE_WRAPPER: string;
|
|
349
354
|
TABLE_LEFT_SHADOW: string;
|
|
@@ -14,5 +14,5 @@ export declare const createColumnControlsDecoration: (selection: Selection) => D
|
|
|
14
14
|
export declare const updateDecorations: (node: PmNode, decorationSet: DecorationSet, decorations: Decoration[], key: TableDecorations) => DecorationSet;
|
|
15
15
|
export declare const createResizeHandleDecoration: (tr: Transaction | ReadonlyTransaction, rowIndexTarget: number, columnEndIndexTarget: Omit<CellColumnPositioning, 'left'>, includeTooltip: boolean | undefined, getIntl: () => IntlShape) => [Decoration[], Decoration[]];
|
|
16
16
|
export declare const createColumnLineResize: (selection: Selection, cellColumnPositioning: Omit<CellColumnPositioning, 'left'>) => Decoration[];
|
|
17
|
-
export declare const createColumnInsertLine: (columnIndex: number, selection: Selection) => Decoration[];
|
|
18
|
-
export declare const createRowInsertLine: (rowIndex: number, selection: Selection) => Decoration[];
|
|
17
|
+
export declare const createColumnInsertLine: (columnIndex: number, selection: Selection, hasMergedCells: boolean) => Decoration[];
|
|
18
|
+
export declare const createRowInsertLine: (rowIndex: number, selection: Selection, hasMergedCells: boolean) => Decoration[];
|
|
@@ -6,7 +6,7 @@ import { TableDecorations } from '../../types';
|
|
|
6
6
|
import { DropTargetType } from './consts';
|
|
7
7
|
export declare const getDecorations: (state: EditorState) => DecorationSet;
|
|
8
8
|
export declare const updatePluginStateDecorations: (state: EditorState, decorations: Decoration[], key: TableDecorations) => DecorationSet;
|
|
9
|
-
export declare const setDropTarget: (type: DropTargetType, index: number, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
|
|
9
|
+
export declare const setDropTarget: (type: DropTargetType, index: number, hasMergedCells: boolean, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
|
|
10
10
|
export declare const clearDropTarget: (tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
|
|
11
11
|
export declare const moveSource: (sourceType: DraggableType, sourceIndex: number, targetIndex: number, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
|
|
12
12
|
export declare const toggleDragMenu: (isDragMenuOpen: boolean | undefined, direction?: TableDirection, index?: number) => import("@atlaskit/editor-common/types").Command;
|
|
@@ -338,12 +338,17 @@ export declare const TableCssClassName: {
|
|
|
338
338
|
TOP_LEFT_CELL: string;
|
|
339
339
|
LAST_ITEM_IN_CELL: string;
|
|
340
340
|
WITH_COLUMN_INSERT_LINE: string;
|
|
341
|
+
WITH_COLUMN_INSERT_LINE_INACTIVE: string;
|
|
341
342
|
WITH_FIRST_COLUMN_INSERT_LINE: string;
|
|
343
|
+
WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE: string;
|
|
342
344
|
WITH_LAST_COLUMN_INSERT_LINE: string;
|
|
345
|
+
WITH_LAST_COLUMN_INSERT_LINE_INACTIVE: string;
|
|
343
346
|
WITH_RESIZE_LINE: string;
|
|
344
347
|
WITH_RESIZE_LINE_LAST_COLUMN: string;
|
|
345
348
|
WITH_ROW_INSERT_LINE: string;
|
|
349
|
+
WITH_ROW_INSERT_LINE_INACTIVE: string;
|
|
346
350
|
WITH_LAST_ROW_INSERT_LINE: string;
|
|
351
|
+
WITH_LAST_ROW_INSERT_LINE_INACTIVE: string;
|
|
347
352
|
TABLE_CONTAINER: string;
|
|
348
353
|
TABLE_NODE_WRAPPER: string;
|
|
349
354
|
TABLE_LEFT_SHADOW: string;
|
|
@@ -17,5 +17,5 @@ export declare const createResizeHandleDecoration: (tr: Transaction | ReadonlyTr
|
|
|
17
17
|
Decoration[]
|
|
18
18
|
];
|
|
19
19
|
export declare const createColumnLineResize: (selection: Selection, cellColumnPositioning: Omit<CellColumnPositioning, 'left'>) => Decoration[];
|
|
20
|
-
export declare const createColumnInsertLine: (columnIndex: number, selection: Selection) => Decoration[];
|
|
21
|
-
export declare const createRowInsertLine: (rowIndex: number, selection: Selection) => Decoration[];
|
|
20
|
+
export declare const createColumnInsertLine: (columnIndex: number, selection: Selection, hasMergedCells: boolean) => Decoration[];
|
|
21
|
+
export declare const createRowInsertLine: (rowIndex: number, selection: Selection, hasMergedCells: boolean) => Decoration[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "5.7.
|
|
3
|
+
"version": "5.7.10",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^35.3.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.0.11",
|
|
33
|
-
"@atlaskit/editor-common": "^76.
|
|
33
|
+
"@atlaskit/editor-common": "^76.37.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.5.2",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
36
36
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@atlaskit/pragmatic-drag-and-drop": "^0.25.0",
|
|
46
46
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^0.8.0",
|
|
47
47
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^0.12.0",
|
|
48
|
-
"@atlaskit/primitives": "^1.
|
|
48
|
+
"@atlaskit/primitives": "^1.17.0",
|
|
49
49
|
"@atlaskit/theme": "^12.6.0",
|
|
50
50
|
"@atlaskit/tokens": "^1.33.0",
|
|
51
51
|
"@atlaskit/tooltip": "^18.1.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|
|
68
68
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
69
69
|
"@atlaskit/editor-plugin-grid": "^0.3.0",
|
|
70
|
-
"@atlaskit/editor-plugin-hyperlink": "^0.
|
|
70
|
+
"@atlaskit/editor-plugin-hyperlink": "^0.8.0",
|
|
71
71
|
"@atlaskit/visual-regression": "*",
|
|
72
72
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
73
73
|
"@atlassian/feature-flags-test-utils": "^0.1.2",
|
|
@@ -802,7 +802,11 @@ describe('Table analytic events', () => {
|
|
|
802
802
|
beforeEach(() => {
|
|
803
803
|
editorView = editor(defaultTableDoc).editorView;
|
|
804
804
|
// Note: we cannot clean a drop target, util one has been set.
|
|
805
|
-
setDropTarget(
|
|
805
|
+
setDropTarget(
|
|
806
|
+
'column',
|
|
807
|
+
0,
|
|
808
|
+
false,
|
|
809
|
+
)(editorView.state, editorView.dispatch);
|
|
806
810
|
});
|
|
807
811
|
|
|
808
812
|
it.each([
|
|
@@ -30,10 +30,9 @@ import {
|
|
|
30
30
|
|
|
31
31
|
import tablePlugin from '../../../plugin';
|
|
32
32
|
import { pluginKey } from '../../../pm-plugins/plugin-key';
|
|
33
|
-
// import { TableCssClassName as ClassName } from '../../../types';
|
|
34
33
|
import { DragControls } from '../../../ui/TableFloatingControls/RowControls';
|
|
35
34
|
|
|
36
|
-
describe('
|
|
35
|
+
describe('RowDragControls', () => {
|
|
37
36
|
const createEditor = createProsemirrorEditorFactory();
|
|
38
37
|
|
|
39
38
|
const editor = (doc: DocBuilder, tableOptions = {}) =>
|
|
@@ -81,7 +80,9 @@ describe('NumberColumn', () => {
|
|
|
81
80
|
</IntlProvider>,
|
|
82
81
|
);
|
|
83
82
|
|
|
84
|
-
const dragHandle = screen.getAllByTestId(
|
|
83
|
+
const dragHandle = screen.getAllByTestId(
|
|
84
|
+
/^table-floating-row-\d-drag-handle$/,
|
|
85
|
+
);
|
|
85
86
|
|
|
86
87
|
expect(dragHandle.length).toBe(1);
|
|
87
88
|
});
|
|
@@ -120,7 +121,7 @@ describe('NumberColumn', () => {
|
|
|
120
121
|
);
|
|
121
122
|
|
|
122
123
|
const dragHandle = screen.queryAllByTestId(
|
|
123
|
-
|
|
124
|
+
/^table-floating-row-\d-drag-handle$/,
|
|
124
125
|
);
|
|
125
126
|
|
|
126
127
|
expect(dragHandle.length).toBe(0);
|
|
@@ -41,6 +41,7 @@ export const updatePluginStateDecorations = (
|
|
|
41
41
|
export const setDropTarget = (
|
|
42
42
|
type: DropTargetType,
|
|
43
43
|
index: number,
|
|
44
|
+
hasMergedCells: boolean,
|
|
44
45
|
tr?: Transaction,
|
|
45
46
|
) =>
|
|
46
47
|
createCommand(
|
|
@@ -54,13 +55,13 @@ export const setDropTarget = (
|
|
|
54
55
|
if (type === 'column') {
|
|
55
56
|
decorationSet = updatePluginStateDecorations(
|
|
56
57
|
state,
|
|
57
|
-
createColumnInsertLine(index, state.selection),
|
|
58
|
+
createColumnInsertLine(index, state.selection, hasMergedCells),
|
|
58
59
|
TableDecorations.COLUMN_INSERT_LINE,
|
|
59
60
|
);
|
|
60
61
|
} else if (type === 'row') {
|
|
61
62
|
decorationSet = updatePluginStateDecorations(
|
|
62
63
|
state,
|
|
63
|
-
createRowInsertLine(index, state.selection),
|
|
64
|
+
createRowInsertLine(index, state.selection, hasMergedCells),
|
|
64
65
|
TableDecorations.ROW_INSERT_LINE,
|
|
65
66
|
);
|
|
66
67
|
}
|
|
@@ -163,10 +163,16 @@ export const createPlugin = (
|
|
|
163
163
|
? DropTargetType.ROW
|
|
164
164
|
: DropTargetType.COLUMN;
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
);
|
|
166
|
+
const hasMergedCells = hasMergedCellsInBetween(
|
|
167
|
+
[targetAdjustedIndex - 1, targetAdjustedIndex],
|
|
168
|
+
dropTargetType,
|
|
169
|
+
)(editorView.state.selection);
|
|
170
|
+
|
|
171
|
+
setDropTarget(
|
|
172
|
+
dropTargetType,
|
|
173
|
+
targetAdjustedIndex,
|
|
174
|
+
hasMergedCells,
|
|
175
|
+
)(editorView.state, editorView.dispatch);
|
|
170
176
|
},
|
|
171
177
|
onDrop(event) {
|
|
172
178
|
const data = getDraggableDataFromEvent(event);
|
package/src/types.ts
CHANGED
|
@@ -383,14 +383,20 @@ export const TableCssClassName = {
|
|
|
383
383
|
LAST_ITEM_IN_CELL: `${tablePrefixSelector}-last-item-in-cell`,
|
|
384
384
|
|
|
385
385
|
WITH_COLUMN_INSERT_LINE: `${tablePrefixSelector}-column-insert-line`,
|
|
386
|
+
WITH_COLUMN_INSERT_LINE_INACTIVE: `${tablePrefixSelector}-column-insert-line__inactive`,
|
|
386
387
|
WITH_FIRST_COLUMN_INSERT_LINE: `${tablePrefixSelector}-first-column-insert-line`,
|
|
388
|
+
WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE: `${tablePrefixSelector}-first-column-insert-line__inactive`,
|
|
389
|
+
|
|
387
390
|
WITH_LAST_COLUMN_INSERT_LINE: `${tablePrefixSelector}-last-column-insert-line`,
|
|
391
|
+
WITH_LAST_COLUMN_INSERT_LINE_INACTIVE: `${tablePrefixSelector}-last-column-insert-line__inactive`,
|
|
388
392
|
|
|
389
393
|
WITH_RESIZE_LINE: `${tablePrefixSelector}-column-resize-line`,
|
|
390
394
|
WITH_RESIZE_LINE_LAST_COLUMN: `${tablePrefixSelector}-column-resize-line-last-column`,
|
|
391
395
|
|
|
392
396
|
WITH_ROW_INSERT_LINE: `${tablePrefixSelector}-row-insert-line`,
|
|
397
|
+
WITH_ROW_INSERT_LINE_INACTIVE: `${tablePrefixSelector}-row-insert-line__inactive`,
|
|
393
398
|
WITH_LAST_ROW_INSERT_LINE: `${tablePrefixSelector}-last-row-insert-line`,
|
|
399
|
+
WITH_LAST_ROW_INSERT_LINE_INACTIVE: `${tablePrefixSelector}-last-row-insert-line__inactive`,
|
|
394
400
|
};
|
|
395
401
|
|
|
396
402
|
export interface ToolbarMenuConfig {
|
|
@@ -153,7 +153,7 @@ export const DragHandle = ({
|
|
|
153
153
|
style={{
|
|
154
154
|
transform: direction === 'column' ? 'none' : 'rotate(90deg)',
|
|
155
155
|
}}
|
|
156
|
-
data-testid="table-
|
|
156
|
+
data-testid="table-drag-handle-button"
|
|
157
157
|
onMouseOver={onMouseOver}
|
|
158
158
|
onMouseOut={onMouseOut}
|
|
159
159
|
onMouseUp={(e) => {
|
|
@@ -239,43 +239,41 @@ export const ColumnControls = ({
|
|
|
239
239
|
: colIndexes;
|
|
240
240
|
|
|
241
241
|
return (
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
</div>
|
|
278
|
-
)
|
|
242
|
+
<div
|
|
243
|
+
key={type}
|
|
244
|
+
style={{
|
|
245
|
+
gridColumn: isSelecting ? selectedColumnPosition : gridColumnPosition,
|
|
246
|
+
display: 'flex',
|
|
247
|
+
justifyContent: 'center',
|
|
248
|
+
alignItems: 'center',
|
|
249
|
+
height: 'fit-content',
|
|
250
|
+
placeSelf: 'center',
|
|
251
|
+
zIndex: 99,
|
|
252
|
+
}}
|
|
253
|
+
data-column-control-index={hoveredCell.colIndex}
|
|
254
|
+
data-testid={`table-floating-column-${
|
|
255
|
+
isSelecting ? selectedColIndexes[0] : colIndex!
|
|
256
|
+
}-drag-handle`}
|
|
257
|
+
>
|
|
258
|
+
<DragHandle
|
|
259
|
+
isDragMenuTarget={!isHover}
|
|
260
|
+
direction="column"
|
|
261
|
+
tableLocalId={localId || ''}
|
|
262
|
+
indexes={indexes}
|
|
263
|
+
forceDefaultHandle={isHover ? false : isColumnsSelected}
|
|
264
|
+
previewWidth={colWidths?.[colIndex!] ?? tableCellMinWidth}
|
|
265
|
+
previewHeight={previewHeight}
|
|
266
|
+
appearance={
|
|
267
|
+
isSelecting ? currentSelectionAppearance : hoveredAppearance
|
|
268
|
+
}
|
|
269
|
+
onClick={handleClick}
|
|
270
|
+
onMouseOver={handleMouseOver}
|
|
271
|
+
onMouseOut={handleMouseOut}
|
|
272
|
+
onMouseUp={handleMouseUp}
|
|
273
|
+
editorView={editorView}
|
|
274
|
+
canDrag={canDrag}
|
|
275
|
+
/>
|
|
276
|
+
</div>
|
|
279
277
|
);
|
|
280
278
|
};
|
|
281
279
|
|
|
@@ -228,39 +228,39 @@ const DragControlsComponent = ({
|
|
|
228
228
|
: rowIndexes;
|
|
229
229
|
|
|
230
230
|
return (
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
231
|
+
<div
|
|
232
|
+
key={type}
|
|
233
|
+
style={{
|
|
234
|
+
gridRow: isSelecting ? selectedRowPosition : gridRowPosition,
|
|
235
|
+
gridColumn: '2',
|
|
236
|
+
// DragHandle uses `transform: rotate(90)`, which doesn't affect its parent (this div) causing the width of this element to be the true height of the drag handle
|
|
237
|
+
width: '9px',
|
|
238
|
+
position: 'relative',
|
|
239
|
+
right: '-0.5px',
|
|
240
|
+
}}
|
|
241
|
+
data-testid={`table-floating-row-${
|
|
242
|
+
isSelecting ? selectedRowIndexes[0] : rowIndex
|
|
243
|
+
}-drag-handle`}
|
|
244
|
+
>
|
|
245
|
+
<DragHandle
|
|
246
|
+
isDragMenuTarget={!isHover}
|
|
247
|
+
direction="row"
|
|
248
|
+
tableLocalId={currentNodeLocalId}
|
|
249
|
+
indexes={indexes}
|
|
250
|
+
forceDefaultHandle={isHover ? false : isRowsSelected}
|
|
251
|
+
previewWidth={tableWidth}
|
|
252
|
+
previewHeight={rowHeights[rowIndex!]}
|
|
253
|
+
appearance={
|
|
254
|
+
isSelecting ? currentSelectionAppearance : hoveredAppearance
|
|
255
|
+
}
|
|
256
|
+
onClick={handleClick}
|
|
257
|
+
onMouseOver={handleMouseOver}
|
|
258
|
+
onMouseOut={handleMouseOut}
|
|
259
|
+
onMouseUp={onMouseUp}
|
|
260
|
+
editorView={editorView}
|
|
261
|
+
canDrag={canDrag}
|
|
262
|
+
/>
|
|
263
|
+
</div>
|
|
264
264
|
);
|
|
265
265
|
};
|
|
266
266
|
|