@atlaskit/editor-plugin-table 5.5.9 → 5.5.11
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 +15 -0
- package/dist/cjs/plugins/table/commands/misc.js +3 -3
- package/dist/cjs/plugins/table/pm-plugins/analytics/plugin.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +12 -0
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +2 -1
- package/dist/cjs/plugins/table/utils/drag-menu.js +2 -1
- package/dist/es2019/plugins/table/commands/misc.js +3 -3
- package/dist/es2019/plugins/table/pm-plugins/analytics/plugin.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +13 -0
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/es2019/plugins/table/utils/drag-menu.js +2 -1
- package/dist/esm/plugins/table/commands/misc.js +3 -3
- package/dist/esm/plugins/table/pm-plugins/analytics/plugin.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +12 -0
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/esm/plugins/table/utils/drag-menu.js +2 -1
- package/dist/types/plugins/table/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +1 -1
- package/package.json +5 -5
- package/src/plugins/table/commands/misc.ts +4 -3
- package/src/plugins/table/pm-plugins/analytics/plugin.ts +1 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +12 -0
- package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +4 -0
- package/src/plugins/table/utils/drag-menu.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.5.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#60830](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60830) [`5472a318103f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5472a318103f) - force colgroup to update after column drop to ensure the correct column width is shown
|
|
8
|
+
- [#60767](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60767) [`737f3666a35d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/737f3666a35d) - Ensure the target that is being pasted is a table
|
|
9
|
+
- [#60717](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60717) [`15f7bd8c548a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/15f7bd8c548a) - disable sort in drag menu when there is merged cell in table
|
|
10
|
+
|
|
11
|
+
## 5.5.10
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#60808](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60808) [`f509a21be124`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f509a21be124) - ED-21506: @atlaskit/adf-schema upgraded to 35.1.1 to support renderer for MBE
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 5.5.9
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -185,17 +185,17 @@ var getTableElementMoveTypeBySlice = exports.getTableElementMoveTypeBySlice = fu
|
|
|
185
185
|
var _state$schema$nodes = state.schema.nodes,
|
|
186
186
|
tableRow = _state$schema$nodes.tableRow,
|
|
187
187
|
table = _state$schema$nodes.table;
|
|
188
|
+
var currentTable = (0, _utils2.findTable)(state.tr.selection);
|
|
188
189
|
|
|
189
190
|
// check if copied slice is a table or table row
|
|
190
|
-
if (!slice.content.firstChild || slice.content.firstChild.type !== table && slice.content.firstChild.type !== tableRow) {
|
|
191
|
-
return;
|
|
191
|
+
if (!slice.content.firstChild || slice.content.firstChild.type !== table && slice.content.firstChild.type !== tableRow || !currentTable) {
|
|
192
|
+
return undefined;
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
// if the slice only contains one table row, assume it's a row
|
|
195
196
|
if (slice.content.childCount === 1 && slice.content.firstChild.type === tableRow) {
|
|
196
197
|
return 'row';
|
|
197
198
|
}
|
|
198
|
-
var currentTable = (0, _utils2.findTable)(state.tr.selection);
|
|
199
199
|
var map = _tableMap.TableMap.get(currentTable.node);
|
|
200
200
|
var slicedMap = _tableMap.TableMap.get(slice.content.firstChild);
|
|
201
201
|
return map.width === slicedMap.width ? 'row' : map.height === slicedMap.height ? 'column' : undefined;
|
|
@@ -45,7 +45,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
|
|
|
45
45
|
var type = (0, _misc.getTableElementMoveTypeBySlice)(slice, state);
|
|
46
46
|
|
|
47
47
|
// if the selection wasn't in the first cell of a row or column, don't count it
|
|
48
|
-
if (!(0, _misc.isInsideFirstCellOfRowOrColumn)(state.selection, type)) {
|
|
48
|
+
if (!type || !(0, _misc.isInsideFirstCellOfRowOrColumn)(state.selection, type)) {
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
var count = (0, _misc.countCellsInSlice)(slice, schema, type);
|
|
@@ -15,6 +15,7 @@ var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
|
15
15
|
var _utils2 = require("../../utils");
|
|
16
16
|
var _pluginFactory = require("../plugin-factory");
|
|
17
17
|
var _pluginKey = require("../plugin-key");
|
|
18
|
+
var _utils3 = require("../table-resizing/utils");
|
|
18
19
|
var _actions = require("./actions");
|
|
19
20
|
var _commands = require("./commands");
|
|
20
21
|
var _consts = require("./consts");
|
|
@@ -189,6 +190,17 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
189
190
|
sourceIndex = _sourceIndexes[0];
|
|
190
191
|
requestAnimationFrame(function () {
|
|
191
192
|
(0, _commands.moveSource)(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
|
|
193
|
+
|
|
194
|
+
// force a colgroup update here, otherwise dropped columns don't have
|
|
195
|
+
// the correct width immediately after the drop
|
|
196
|
+
if (sourceType === 'table-column') {
|
|
197
|
+
var _getTablePluginState5 = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
198
|
+
tableRef = _getTablePluginState5.tableRef,
|
|
199
|
+
tableNode = _getTablePluginState5.tableNode;
|
|
200
|
+
if (tableRef && tableNode) {
|
|
201
|
+
(0, _utils3.insertColgroupFromNode)(tableRef, tableNode);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
192
204
|
editorView.focus();
|
|
193
205
|
});
|
|
194
206
|
}
|
|
@@ -84,7 +84,8 @@ var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
|
84
84
|
var selectionRect = (0, _utils.isSelectionType)(selection, 'cell') ? (0, _utils.getSelectionRect)(selection) : (0, _utils.findCellRectClosestToPos)(selection.$from);
|
|
85
85
|
var hasMergedCells = direction === 'row' ? _utils2.hasMergedCellsInRow : _utils2.hasMergedCellsInColumn;
|
|
86
86
|
var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
87
|
-
var
|
|
87
|
+
var hasMergedCellsInTable = (0, _utils2.getMergedCellsPositions)(state.tr).length > 0;
|
|
88
|
+
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect);
|
|
88
89
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
|
|
89
90
|
menuItems = _convertToDropdownIte.menuItems,
|
|
90
91
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
@@ -42,7 +42,7 @@ var isDistributeColumnsEnabled = function isDistributeColumnsEnabled(state) {
|
|
|
42
42
|
}
|
|
43
43
|
return false;
|
|
44
44
|
};
|
|
45
|
-
var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, editorView, tableMap, index, targetCellPosition, selectionRect) {
|
|
45
|
+
var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect) {
|
|
46
46
|
var addOptions = direction === 'row' ? [{
|
|
47
47
|
label: 'above',
|
|
48
48
|
offset: 0,
|
|
@@ -190,6 +190,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
190
190
|
return {
|
|
191
191
|
id: "sort_column_".concat(order),
|
|
192
192
|
title: "Sort ".concat(label),
|
|
193
|
+
disabled: hasMergedCellsInTable,
|
|
193
194
|
icon: icon,
|
|
194
195
|
onClick: function onClick(state, dispatch) {
|
|
195
196
|
(0, _commands.sortByColumn)(index, order)(state, dispatch);
|
|
@@ -191,17 +191,17 @@ export const getTableElementMoveTypeBySlice = (slice, state) => {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
} = state;
|
|
194
|
+
const currentTable = findTable(state.tr.selection);
|
|
194
195
|
|
|
195
196
|
// check if copied slice is a table or table row
|
|
196
|
-
if (!slice.content.firstChild || slice.content.firstChild.type !== table && slice.content.firstChild.type !== tableRow) {
|
|
197
|
-
return;
|
|
197
|
+
if (!slice.content.firstChild || slice.content.firstChild.type !== table && slice.content.firstChild.type !== tableRow || !currentTable) {
|
|
198
|
+
return undefined;
|
|
198
199
|
}
|
|
199
200
|
|
|
200
201
|
// if the slice only contains one table row, assume it's a row
|
|
201
202
|
if (slice.content.childCount === 1 && slice.content.firstChild.type === tableRow) {
|
|
202
203
|
return 'row';
|
|
203
204
|
}
|
|
204
|
-
const currentTable = findTable(state.tr.selection);
|
|
205
205
|
const map = TableMap.get(currentTable.node);
|
|
206
206
|
const slicedMap = TableMap.get(slice.content.firstChild);
|
|
207
207
|
return map.width === slicedMap.width ? 'row' : map.height === slicedMap.height ? 'column' : undefined;
|
|
@@ -41,7 +41,7 @@ export const createPlugin = (dispatch, dispatchAnalyticsEvent) => new SafePlugin
|
|
|
41
41
|
const type = getTableElementMoveTypeBySlice(slice, state);
|
|
42
42
|
|
|
43
43
|
// if the selection wasn't in the first cell of a row or column, don't count it
|
|
44
|
-
if (!isInsideFirstCellOfRowOrColumn(state.selection, type)) {
|
|
44
|
+
if (!type || !isInsideFirstCellOfRowOrColumn(state.selection, type)) {
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
const count = countCellsInSlice(slice, schema, type);
|
|
@@ -6,6 +6,7 @@ import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/el
|
|
|
6
6
|
import { findNearestCellIndexToPoint, hasMergedCellsInBetween } from '../../utils';
|
|
7
7
|
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
8
8
|
import { pluginKey as tablePluginKey } from '../plugin-key';
|
|
9
|
+
import { insertColgroupFromNode } from '../table-resizing/utils';
|
|
9
10
|
import { DragAndDropActionType } from './actions';
|
|
10
11
|
import { clearDropTarget, moveSource, setDropTarget, toggleDragMenu } from './commands';
|
|
11
12
|
import { DRAGGABLE_TABLE_NODE_SIZE_LIMIT, DropTargetType } from './consts';
|
|
@@ -190,6 +191,18 @@ export const createPlugin = (dispatch, eventDispatcher) => {
|
|
|
190
191
|
const [sourceIndex] = sourceIndexes;
|
|
191
192
|
requestAnimationFrame(() => {
|
|
192
193
|
moveSource(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
|
|
194
|
+
|
|
195
|
+
// force a colgroup update here, otherwise dropped columns don't have
|
|
196
|
+
// the correct width immediately after the drop
|
|
197
|
+
if (sourceType === 'table-column') {
|
|
198
|
+
const {
|
|
199
|
+
tableRef,
|
|
200
|
+
tableNode
|
|
201
|
+
} = getTablePluginState(editorView.state);
|
|
202
|
+
if (tableRef && tableNode) {
|
|
203
|
+
insertColgroupFromNode(tableRef, tableNode);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
193
206
|
editorView.focus();
|
|
194
207
|
});
|
|
195
208
|
}
|
|
@@ -7,7 +7,7 @@ import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@at
|
|
|
7
7
|
import { clearHoverSelection, hoverColumns, hoverRows } from '../../commands';
|
|
8
8
|
import { toggleDragMenu } from '../../pm-plugins/drag-and-drop/commands';
|
|
9
9
|
import { getPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
10
|
-
import { getSelectedColumnIndexes, getSelectedRowIndexes, hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
10
|
+
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes, hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
11
11
|
import { getDragMenuConfig } from '../../utils/drag-menu';
|
|
12
12
|
import { dragMenuDropdownWidth } from '../consts';
|
|
13
13
|
const groupedDragMenuConfig = [['add_row_above', 'add_row_below', 'add_column_left', 'add_column_right', 'distribute_columns', 'clear_cells', 'delete_row', 'delete_column'], ['move_column_left', 'move_column_right', 'move_row_up', 'move_row_down'], ['sort_column_asc', 'sort_column_desc']];
|
|
@@ -75,7 +75,8 @@ export const DragMenu = ({
|
|
|
75
75
|
const selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
76
76
|
const hasMergedCells = direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
|
|
77
77
|
const shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
78
|
-
const
|
|
78
|
+
const hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
79
|
+
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect);
|
|
79
80
|
const {
|
|
80
81
|
menuItems,
|
|
81
82
|
menuCallback
|
|
@@ -28,7 +28,7 @@ const isDistributeColumnsEnabled = state => {
|
|
|
28
28
|
}
|
|
29
29
|
return false;
|
|
30
30
|
};
|
|
31
|
-
export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, editorView, tableMap, index, targetCellPosition, selectionRect) => {
|
|
31
|
+
export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect) => {
|
|
32
32
|
const addOptions = direction === 'row' ? [{
|
|
33
33
|
label: 'above',
|
|
34
34
|
offset: 0,
|
|
@@ -172,6 +172,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, e
|
|
|
172
172
|
}) => ({
|
|
173
173
|
id: `sort_column_${order}`,
|
|
174
174
|
title: `Sort ${label}`,
|
|
175
|
+
disabled: hasMergedCellsInTable,
|
|
175
176
|
icon,
|
|
176
177
|
onClick: (state, dispatch) => {
|
|
177
178
|
sortByColumn(index, order)(state, dispatch);
|
|
@@ -178,17 +178,17 @@ export var getTableElementMoveTypeBySlice = function getTableElementMoveTypeBySl
|
|
|
178
178
|
var _state$schema$nodes = state.schema.nodes,
|
|
179
179
|
tableRow = _state$schema$nodes.tableRow,
|
|
180
180
|
table = _state$schema$nodes.table;
|
|
181
|
+
var currentTable = findTable(state.tr.selection);
|
|
181
182
|
|
|
182
183
|
// check if copied slice is a table or table row
|
|
183
|
-
if (!slice.content.firstChild || slice.content.firstChild.type !== table && slice.content.firstChild.type !== tableRow) {
|
|
184
|
-
return;
|
|
184
|
+
if (!slice.content.firstChild || slice.content.firstChild.type !== table && slice.content.firstChild.type !== tableRow || !currentTable) {
|
|
185
|
+
return undefined;
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
// if the slice only contains one table row, assume it's a row
|
|
188
189
|
if (slice.content.childCount === 1 && slice.content.firstChild.type === tableRow) {
|
|
189
190
|
return 'row';
|
|
190
191
|
}
|
|
191
|
-
var currentTable = findTable(state.tr.selection);
|
|
192
192
|
var map = TableMap.get(currentTable.node);
|
|
193
193
|
var slicedMap = TableMap.get(slice.content.firstChild);
|
|
194
194
|
return map.width === slicedMap.width ? 'row' : map.height === slicedMap.height ? 'column' : undefined;
|
|
@@ -39,7 +39,7 @@ export var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent
|
|
|
39
39
|
var type = getTableElementMoveTypeBySlice(slice, state);
|
|
40
40
|
|
|
41
41
|
// if the selection wasn't in the first cell of a row or column, don't count it
|
|
42
|
-
if (!isInsideFirstCellOfRowOrColumn(state.selection, type)) {
|
|
42
|
+
if (!type || !isInsideFirstCellOfRowOrColumn(state.selection, type)) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
var count = countCellsInSlice(slice, schema, type);
|
|
@@ -10,6 +10,7 @@ import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/el
|
|
|
10
10
|
import { findNearestCellIndexToPoint, hasMergedCellsInBetween } from '../../utils';
|
|
11
11
|
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
12
12
|
import { pluginKey as tablePluginKey } from '../plugin-key';
|
|
13
|
+
import { insertColgroupFromNode } from '../table-resizing/utils';
|
|
13
14
|
import { DragAndDropActionType } from './actions';
|
|
14
15
|
import { clearDropTarget, moveSource, setDropTarget, toggleDragMenu } from './commands';
|
|
15
16
|
import { DRAGGABLE_TABLE_NODE_SIZE_LIMIT, DropTargetType } from './consts';
|
|
@@ -182,6 +183,17 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
|
|
|
182
183
|
sourceIndex = _sourceIndexes[0];
|
|
183
184
|
requestAnimationFrame(function () {
|
|
184
185
|
moveSource(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
|
|
186
|
+
|
|
187
|
+
// force a colgroup update here, otherwise dropped columns don't have
|
|
188
|
+
// the correct width immediately after the drop
|
|
189
|
+
if (sourceType === 'table-column') {
|
|
190
|
+
var _getTablePluginState5 = getTablePluginState(editorView.state),
|
|
191
|
+
tableRef = _getTablePluginState5.tableRef,
|
|
192
|
+
tableNode = _getTablePluginState5.tableNode;
|
|
193
|
+
if (tableRef && tableNode) {
|
|
194
|
+
insertColgroupFromNode(tableRef, tableNode);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
185
197
|
editorView.focus();
|
|
186
198
|
});
|
|
187
199
|
}
|
|
@@ -8,7 +8,7 @@ import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@at
|
|
|
8
8
|
import { clearHoverSelection, hoverColumns, hoverRows } from '../../commands';
|
|
9
9
|
import { toggleDragMenu } from '../../pm-plugins/drag-and-drop/commands';
|
|
10
10
|
import { getPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
11
|
-
import { getSelectedColumnIndexes, getSelectedRowIndexes, hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
11
|
+
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes, hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
12
12
|
import { getDragMenuConfig } from '../../utils/drag-menu';
|
|
13
13
|
import { dragMenuDropdownWidth } from '../consts';
|
|
14
14
|
var groupedDragMenuConfig = [['add_row_above', 'add_row_below', 'add_column_left', 'add_column_right', 'distribute_columns', 'clear_cells', 'delete_row', 'delete_column'], ['move_column_left', 'move_column_right', 'move_row_up', 'move_row_down'], ['sort_column_asc', 'sort_column_desc']];
|
|
@@ -76,7 +76,8 @@ export var DragMenu = function DragMenu(_ref) {
|
|
|
76
76
|
var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
77
77
|
var hasMergedCells = direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
|
|
78
78
|
var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
79
|
-
var
|
|
79
|
+
var hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
80
|
+
var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect);
|
|
80
81
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
|
|
81
82
|
menuItems = _convertToDropdownIte.menuItems,
|
|
82
83
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
@@ -35,7 +35,7 @@ var isDistributeColumnsEnabled = function isDistributeColumnsEnabled(state) {
|
|
|
35
35
|
}
|
|
36
36
|
return false;
|
|
37
37
|
};
|
|
38
|
-
export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, editorView, tableMap, index, targetCellPosition, selectionRect) {
|
|
38
|
+
export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect) {
|
|
39
39
|
var addOptions = direction === 'row' ? [{
|
|
40
40
|
label: 'above',
|
|
41
41
|
offset: 0,
|
|
@@ -183,6 +183,7 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
|
|
|
183
183
|
return {
|
|
184
184
|
id: "sort_column_".concat(order),
|
|
185
185
|
title: "Sort ".concat(label),
|
|
186
|
+
disabled: hasMergedCellsInTable,
|
|
186
187
|
icon: icon,
|
|
187
188
|
onClick: function onClick(state, dispatch) {
|
|
188
189
|
sortByColumn(index, order)(state, dispatch);
|
|
@@ -8,4 +8,4 @@ export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
|
8
8
|
icon?: React.ComponentType<IconProps>;
|
|
9
9
|
keymap?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect) => DragMenuConfig[];
|
|
11
|
+
export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, hasMergedCellsInTable: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect) => DragMenuConfig[];
|
|
@@ -8,4 +8,4 @@ export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
|
8
8
|
icon?: React.ComponentType<IconProps>;
|
|
9
9
|
keymap?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect) => DragMenuConfig[];
|
|
11
|
+
export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, hasMergedCellsInTable: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect) => DragMenuConfig[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.11",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"releaseModel": "continuous"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@atlaskit/adf-schema": "^35.1.
|
|
31
|
-
"@atlaskit/custom-steps": "^0.0.
|
|
30
|
+
"@atlaskit/adf-schema": "^35.1.1",
|
|
31
|
+
"@atlaskit/custom-steps": "^0.0.9",
|
|
32
32
|
"@atlaskit/editor-common": "^76.26.0",
|
|
33
33
|
"@atlaskit/editor-palette": "1.5.2",
|
|
34
34
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"@atlaskit/pragmatic-drag-and-drop": "^0.25.0",
|
|
45
45
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^0.8.0",
|
|
46
46
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^0.12.0",
|
|
47
|
-
"@atlaskit/primitives": "^1.
|
|
47
|
+
"@atlaskit/primitives": "^1.15.0",
|
|
48
48
|
"@atlaskit/theme": "^12.6.0",
|
|
49
|
-
"@atlaskit/tokens": "^1.
|
|
49
|
+
"@atlaskit/tokens": "^1.30.0",
|
|
50
50
|
"@atlaskit/tooltip": "^18.0.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0",
|
|
52
52
|
"@emotion/react": "^11.7.1",
|
|
@@ -283,14 +283,16 @@ export const getTableElementMoveTypeBySlice = (
|
|
|
283
283
|
nodes: { tableRow, table },
|
|
284
284
|
},
|
|
285
285
|
} = state;
|
|
286
|
+
const currentTable = findTable(state.tr.selection);
|
|
286
287
|
|
|
287
288
|
// check if copied slice is a table or table row
|
|
288
289
|
if (
|
|
289
290
|
!slice.content.firstChild ||
|
|
290
291
|
(slice.content.firstChild.type !== table &&
|
|
291
|
-
slice.content.firstChild.type !== tableRow)
|
|
292
|
+
slice.content.firstChild.type !== tableRow) ||
|
|
293
|
+
!currentTable
|
|
292
294
|
) {
|
|
293
|
-
return;
|
|
295
|
+
return undefined;
|
|
294
296
|
}
|
|
295
297
|
|
|
296
298
|
// if the slice only contains one table row, assume it's a row
|
|
@@ -301,7 +303,6 @@ export const getTableElementMoveTypeBySlice = (
|
|
|
301
303
|
return 'row';
|
|
302
304
|
}
|
|
303
305
|
|
|
304
|
-
const currentTable = findTable(state.tr.selection)!;
|
|
305
306
|
const map = TableMap.get(currentTable.node);
|
|
306
307
|
const slicedMap = TableMap.get(slice.content.firstChild);
|
|
307
308
|
|
|
@@ -59,7 +59,7 @@ export const createPlugin = (
|
|
|
59
59
|
const type = getTableElementMoveTypeBySlice(slice, state);
|
|
60
60
|
|
|
61
61
|
// if the selection wasn't in the first cell of a row or column, don't count it
|
|
62
|
-
if (!isInsideFirstCellOfRowOrColumn(state.selection, type)) {
|
|
62
|
+
if (!type || !isInsideFirstCellOfRowOrColumn(state.selection, type)) {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
} from '../../utils';
|
|
17
17
|
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
18
18
|
import { pluginKey as tablePluginKey } from '../plugin-key';
|
|
19
|
+
import { insertColgroupFromNode } from '../table-resizing/utils';
|
|
19
20
|
|
|
20
21
|
import { DragAndDropActionType } from './actions';
|
|
21
22
|
import {
|
|
@@ -236,6 +237,17 @@ export const createPlugin = (
|
|
|
236
237
|
tr,
|
|
237
238
|
)(editorView.state, editorView.dispatch);
|
|
238
239
|
|
|
240
|
+
// force a colgroup update here, otherwise dropped columns don't have
|
|
241
|
+
// the correct width immediately after the drop
|
|
242
|
+
if (sourceType === 'table-column') {
|
|
243
|
+
const { tableRef, tableNode } = getTablePluginState(
|
|
244
|
+
editorView.state,
|
|
245
|
+
);
|
|
246
|
+
if (tableRef && tableNode) {
|
|
247
|
+
insertColgroupFromNode(tableRef, tableNode);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
239
251
|
editorView.focus();
|
|
240
252
|
});
|
|
241
253
|
},
|
|
@@ -27,6 +27,7 @@ import { toggleDragMenu } from '../../pm-plugins/drag-and-drop/commands';
|
|
|
27
27
|
import { getPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
28
28
|
import type { PluginConfig, TableDirection } from '../../types';
|
|
29
29
|
import {
|
|
30
|
+
getMergedCellsPositions,
|
|
30
31
|
getSelectedColumnIndexes,
|
|
31
32
|
getSelectedRowIndexes,
|
|
32
33
|
hasMergedCellsInColumn,
|
|
@@ -136,10 +137,13 @@ export const DragMenu = ({
|
|
|
136
137
|
const shouldMoveDisabled =
|
|
137
138
|
index !== undefined && hasMergedCells(index)(selection);
|
|
138
139
|
|
|
140
|
+
const hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
141
|
+
|
|
139
142
|
const dragMenuConfig = getDragMenuConfig(
|
|
140
143
|
direction,
|
|
141
144
|
getEditorContainerWidth,
|
|
142
145
|
!!canDrag && !shouldMoveDisabled,
|
|
146
|
+
hasMergedCellsInTable,
|
|
143
147
|
editorView,
|
|
144
148
|
tableMap,
|
|
145
149
|
index,
|
|
@@ -73,6 +73,7 @@ export const getDragMenuConfig = (
|
|
|
73
73
|
direction: TableDirection,
|
|
74
74
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
75
75
|
canDrag: boolean,
|
|
76
|
+
hasMergedCellsInTable: boolean,
|
|
76
77
|
editorView: EditorView,
|
|
77
78
|
tableMap?: TableMap,
|
|
78
79
|
index?: number,
|
|
@@ -248,6 +249,7 @@ export const getDragMenuConfig = (
|
|
|
248
249
|
...sortOptions.map(({ label, order, icon }) => ({
|
|
249
250
|
id: `sort_column_${order}`,
|
|
250
251
|
title: `Sort ${label}`,
|
|
252
|
+
disabled: hasMergedCellsInTable,
|
|
251
253
|
icon,
|
|
252
254
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
253
255
|
sortByColumn(index!, order)(state, dispatch);
|