@atlaskit/editor-plugin-table 7.3.4 → 7.3.5
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 +7 -0
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +1 -1
- package/dist/cjs/utils/drag-menu.js +20 -16
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +1 -1
- package/dist/es2019/utils/drag-menu.js +18 -16
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +1 -1
- package/dist/esm/utils/drag-menu.js +18 -14
- package/dist/types/commands-with-analytics.d.ts +7 -7
- package/dist/types/types.d.ts +1 -1
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands-with-analytics.d.ts +7 -7
- package/dist/types-ts4.5/types.d.ts +1 -1
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +3 -3
- package/src/commands-with-analytics.ts +20 -7
- package/src/types.ts +2 -1
- package/src/ui/FloatingDragMenu/DragMenu.tsx +1 -0
- package/src/utils/drag-menu.ts +44 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.3.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#72850](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/72850) [`5099580a0330`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5099580a0330) - Adds analytics for sort options in table's Drag handle menu
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 7.3.4
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -201,7 +201,7 @@ var DragMenu = exports.DragMenu = /*#__PURE__*/_react.default.memo(function (_re
|
|
|
201
201
|
var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
202
202
|
var hasMergedCellsInTable = (0, _utils3.getMergedCellsPositions)(state.tr).length > 0;
|
|
203
203
|
var allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
204
|
-
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI);
|
|
204
|
+
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired);
|
|
205
205
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig, formatMessage, selectionRect),
|
|
206
206
|
menuItems = _convertToDropdownIte.menuItems,
|
|
207
207
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
@@ -18,13 +18,10 @@ var _layoutThreeEqual = _interopRequireDefault(require("@atlaskit/icon/glyph/edi
|
|
|
18
18
|
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
19
19
|
var _chevronDoubleDown = _interopRequireDefault(require("@atlaskit/icon/glyph/hipchat/chevron-double-down"));
|
|
20
20
|
var _chevronDoubleUp = _interopRequireDefault(require("@atlaskit/icon/glyph/hipchat/chevron-double-up"));
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var _commandsWithAnalytics = require("../pm-plugins/drag-and-drop/commands-with-analytics");
|
|
24
|
-
var _commands2 = require("../pm-plugins/table-resizing/commands");
|
|
21
|
+
var _commandsWithAnalytics = require("../commands-with-analytics");
|
|
22
|
+
var _commandsWithAnalytics2 = require("../pm-plugins/drag-and-drop/commands-with-analytics");
|
|
25
23
|
var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
|
|
26
24
|
var _toolbar = require("../toolbar");
|
|
27
|
-
var _transforms = require("../transforms");
|
|
28
25
|
var _icons = require("../ui/icons");
|
|
29
26
|
var _mergedCells = require("./merged-cells");
|
|
30
27
|
var _selection = require("./selection");
|
|
@@ -65,7 +62,13 @@ var isDistributeColumnsEnabled = function isDistributeColumnsEnabled(state) {
|
|
|
65
62
|
}
|
|
66
63
|
return false;
|
|
67
64
|
};
|
|
68
|
-
var
|
|
65
|
+
var defaultSelectionRect = {
|
|
66
|
+
left: 0,
|
|
67
|
+
top: 0,
|
|
68
|
+
right: 0,
|
|
69
|
+
bottom: 0
|
|
70
|
+
};
|
|
71
|
+
var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired) {
|
|
69
72
|
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
70
73
|
var addOptions = direction === 'row' ? [{
|
|
71
74
|
label: 'above',
|
|
@@ -146,9 +149,12 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
146
149
|
icon: icon,
|
|
147
150
|
onClick: function onClick(state, dispatch) {
|
|
148
151
|
if (direction === 'row') {
|
|
149
|
-
(0,
|
|
152
|
+
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, {
|
|
153
|
+
index: (index !== null && index !== void 0 ? index : 0) + offset,
|
|
154
|
+
moveCursorToInsertedRow: true
|
|
155
|
+
})(state, dispatch);
|
|
150
156
|
} else {
|
|
151
|
-
(0,
|
|
157
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(getEditorContainerWidth, editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
152
158
|
}
|
|
153
159
|
return true;
|
|
154
160
|
},
|
|
@@ -163,9 +169,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
163
169
|
if (selectionRect) {
|
|
164
170
|
var newResizeState = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
|
|
165
171
|
if (newResizeState) {
|
|
166
|
-
|
|
167
|
-
table = newResizeState.table;
|
|
168
|
-
(0, _commands2.distributeColumnsWidths)(resizeState, table)(state, dispatch);
|
|
172
|
+
(0, _commandsWithAnalytics.distributeColumnsWidthsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, newResizeState)(state, dispatch);
|
|
169
173
|
return true;
|
|
170
174
|
}
|
|
171
175
|
return false;
|
|
@@ -177,7 +181,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
177
181
|
id: 'clear_cells',
|
|
178
182
|
title: 'Clear cells',
|
|
179
183
|
onClick: function onClick(state, dispatch) {
|
|
180
|
-
(0,
|
|
184
|
+
(0, _commandsWithAnalytics.emptyMultipleCellsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition)(state, dispatch);
|
|
181
185
|
return true;
|
|
182
186
|
},
|
|
183
187
|
icon: _crossCircle.default,
|
|
@@ -187,9 +191,9 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
187
191
|
title: "Delete ".concat(direction),
|
|
188
192
|
onClick: function onClick(state, dispatch) {
|
|
189
193
|
if (direction === 'row') {
|
|
190
|
-
|
|
194
|
+
(0, _commandsWithAnalytics.deleteRowsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect, !!isHeaderRowRequired)(state, dispatch);
|
|
191
195
|
} else {
|
|
192
|
-
(0,
|
|
196
|
+
(0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect)(state, dispatch, editorView);
|
|
193
197
|
}
|
|
194
198
|
return true;
|
|
195
199
|
},
|
|
@@ -210,7 +214,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
210
214
|
onClick: function onClick(state, dispatch) {
|
|
211
215
|
if (canMove) {
|
|
212
216
|
requestAnimationFrame(function () {
|
|
213
|
-
(0,
|
|
217
|
+
(0, _commandsWithAnalytics2.moveSourceWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, "table-".concat(direction), getOriginIndexes(selectionRect), getTargetIndex(selectionRect))(editorView.state, editorView.dispatch);
|
|
214
218
|
});
|
|
215
219
|
return true;
|
|
216
220
|
}
|
|
@@ -228,7 +232,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
228
232
|
disabled: hasMergedCellsInTable,
|
|
229
233
|
icon: icon,
|
|
230
234
|
onClick: function onClick(state, dispatch) {
|
|
231
|
-
(0,
|
|
235
|
+
(0, _commandsWithAnalytics.sortColumnWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, index !== null && index !== void 0 ? index : 0, order)(state, dispatch);
|
|
232
236
|
return true;
|
|
233
237
|
}
|
|
234
238
|
};
|
|
@@ -190,7 +190,7 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
190
190
|
const shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
191
191
|
const hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
192
192
|
const allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
193
|
-
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI);
|
|
193
|
+
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired);
|
|
194
194
|
const {
|
|
195
195
|
menuItems,
|
|
196
196
|
menuCallback
|
|
@@ -10,13 +10,10 @@ import EditorLayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three
|
|
|
10
10
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
11
11
|
import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-down';
|
|
12
12
|
import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
|
|
13
|
-
import {
|
|
14
|
-
import { deleteColumnsCommand } from '../commands/delete';
|
|
13
|
+
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, sortColumnWithAnalytics } from '../commands-with-analytics';
|
|
15
14
|
import { moveSourceWithAnalytics } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
16
|
-
import { distributeColumnsWidths } from '../pm-plugins/table-resizing/commands';
|
|
17
15
|
import { getNewResizeStateFromSelectedColumns } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
18
16
|
import { getClosestSelectionRect } from '../toolbar';
|
|
19
|
-
import { deleteRows } from '../transforms';
|
|
20
17
|
import { AddColLeftIcon, AddColRightIcon, AddRowAboveIcon, AddRowBelowIcon } from '../ui/icons';
|
|
21
18
|
import { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsWithColumnNextToColumnIndex, hasMergedCellsWithRowNextToRowIndex } from './merged-cells';
|
|
22
19
|
import { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
|
|
@@ -55,7 +52,13 @@ const isDistributeColumnsEnabled = state => {
|
|
|
55
52
|
}
|
|
56
53
|
return false;
|
|
57
54
|
};
|
|
58
|
-
|
|
55
|
+
const defaultSelectionRect = {
|
|
56
|
+
left: 0,
|
|
57
|
+
top: 0,
|
|
58
|
+
right: 0,
|
|
59
|
+
bottom: 0
|
|
60
|
+
};
|
|
61
|
+
export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired) => {
|
|
59
62
|
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
60
63
|
const addOptions = direction === 'row' ? [{
|
|
61
64
|
label: 'above',
|
|
@@ -130,9 +133,12 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
130
133
|
icon,
|
|
131
134
|
onClick: (state, dispatch) => {
|
|
132
135
|
if (direction === 'row') {
|
|
133
|
-
|
|
136
|
+
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, {
|
|
137
|
+
index: (index !== null && index !== void 0 ? index : 0) + offset,
|
|
138
|
+
moveCursorToInsertedRow: true
|
|
139
|
+
})(state, dispatch);
|
|
134
140
|
} else {
|
|
135
|
-
|
|
141
|
+
insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
136
142
|
}
|
|
137
143
|
return true;
|
|
138
144
|
},
|
|
@@ -146,11 +152,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
146
152
|
if (selectionRect) {
|
|
147
153
|
const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
|
|
148
154
|
if (newResizeState) {
|
|
149
|
-
|
|
150
|
-
resizeState,
|
|
151
|
-
table
|
|
152
|
-
} = newResizeState;
|
|
153
|
-
distributeColumnsWidths(resizeState, table)(state, dispatch);
|
|
155
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, newResizeState)(state, dispatch);
|
|
154
156
|
return true;
|
|
155
157
|
}
|
|
156
158
|
return false;
|
|
@@ -162,7 +164,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
162
164
|
id: 'clear_cells',
|
|
163
165
|
title: 'Clear cells',
|
|
164
166
|
onClick: (state, dispatch) => {
|
|
165
|
-
|
|
167
|
+
emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition)(state, dispatch);
|
|
166
168
|
return true;
|
|
167
169
|
},
|
|
168
170
|
icon: CrossCircleIcon,
|
|
@@ -172,9 +174,9 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
172
174
|
title: `Delete ${direction}`,
|
|
173
175
|
onClick: (state, dispatch) => {
|
|
174
176
|
if (direction === 'row') {
|
|
175
|
-
|
|
177
|
+
deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect, !!isHeaderRowRequired)(state, dispatch);
|
|
176
178
|
} else {
|
|
177
|
-
|
|
179
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect)(state, dispatch, editorView);
|
|
178
180
|
}
|
|
179
181
|
return true;
|
|
180
182
|
},
|
|
@@ -212,7 +214,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
212
214
|
disabled: hasMergedCellsInTable,
|
|
213
215
|
icon,
|
|
214
216
|
onClick: (state, dispatch) => {
|
|
215
|
-
|
|
217
|
+
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, index !== null && index !== void 0 ? index : 0, order)(state, dispatch);
|
|
216
218
|
return true;
|
|
217
219
|
}
|
|
218
220
|
}))].filter(Boolean);
|
|
@@ -190,7 +190,7 @@ export var DragMenu = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
190
190
|
var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
191
191
|
var hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
192
192
|
var allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
193
|
-
var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI);
|
|
193
|
+
var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired);
|
|
194
194
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig, formatMessage, selectionRect),
|
|
195
195
|
menuItems = _convertToDropdownIte.menuItems,
|
|
196
196
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
@@ -11,13 +11,10 @@ import EditorLayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three
|
|
|
11
11
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
12
12
|
import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-down';
|
|
13
13
|
import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
|
|
14
|
-
import {
|
|
15
|
-
import { deleteColumnsCommand } from '../commands/delete';
|
|
14
|
+
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, sortColumnWithAnalytics } from '../commands-with-analytics';
|
|
16
15
|
import { moveSourceWithAnalytics } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
17
|
-
import { distributeColumnsWidths } from '../pm-plugins/table-resizing/commands';
|
|
18
16
|
import { getNewResizeStateFromSelectedColumns } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
19
17
|
import { getClosestSelectionRect } from '../toolbar';
|
|
20
|
-
import { deleteRows } from '../transforms';
|
|
21
18
|
import { AddColLeftIcon, AddColRightIcon, AddRowAboveIcon, AddRowBelowIcon } from '../ui/icons';
|
|
22
19
|
import { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsWithColumnNextToColumnIndex, hasMergedCellsWithRowNextToRowIndex } from './merged-cells';
|
|
23
20
|
import { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
|
|
@@ -58,7 +55,13 @@ var isDistributeColumnsEnabled = function isDistributeColumnsEnabled(state) {
|
|
|
58
55
|
}
|
|
59
56
|
return false;
|
|
60
57
|
};
|
|
61
|
-
|
|
58
|
+
var defaultSelectionRect = {
|
|
59
|
+
left: 0,
|
|
60
|
+
top: 0,
|
|
61
|
+
right: 0,
|
|
62
|
+
bottom: 0
|
|
63
|
+
};
|
|
64
|
+
export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired) {
|
|
62
65
|
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
63
66
|
var addOptions = direction === 'row' ? [{
|
|
64
67
|
label: 'above',
|
|
@@ -139,9 +142,12 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
|
|
|
139
142
|
icon: icon,
|
|
140
143
|
onClick: function onClick(state, dispatch) {
|
|
141
144
|
if (direction === 'row') {
|
|
142
|
-
|
|
145
|
+
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, {
|
|
146
|
+
index: (index !== null && index !== void 0 ? index : 0) + offset,
|
|
147
|
+
moveCursorToInsertedRow: true
|
|
148
|
+
})(state, dispatch);
|
|
143
149
|
} else {
|
|
144
|
-
|
|
150
|
+
insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
145
151
|
}
|
|
146
152
|
return true;
|
|
147
153
|
},
|
|
@@ -156,9 +162,7 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
|
|
|
156
162
|
if (selectionRect) {
|
|
157
163
|
var newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
|
|
158
164
|
if (newResizeState) {
|
|
159
|
-
|
|
160
|
-
table = newResizeState.table;
|
|
161
|
-
distributeColumnsWidths(resizeState, table)(state, dispatch);
|
|
165
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, newResizeState)(state, dispatch);
|
|
162
166
|
return true;
|
|
163
167
|
}
|
|
164
168
|
return false;
|
|
@@ -170,7 +174,7 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
|
|
|
170
174
|
id: 'clear_cells',
|
|
171
175
|
title: 'Clear cells',
|
|
172
176
|
onClick: function onClick(state, dispatch) {
|
|
173
|
-
|
|
177
|
+
emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition)(state, dispatch);
|
|
174
178
|
return true;
|
|
175
179
|
},
|
|
176
180
|
icon: CrossCircleIcon,
|
|
@@ -180,9 +184,9 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
|
|
|
180
184
|
title: "Delete ".concat(direction),
|
|
181
185
|
onClick: function onClick(state, dispatch) {
|
|
182
186
|
if (direction === 'row') {
|
|
183
|
-
|
|
187
|
+
deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect, !!isHeaderRowRequired)(state, dispatch);
|
|
184
188
|
} else {
|
|
185
|
-
|
|
189
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect)(state, dispatch, editorView);
|
|
186
190
|
}
|
|
187
191
|
return true;
|
|
188
192
|
},
|
|
@@ -221,7 +225,7 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
|
|
|
221
225
|
disabled: hasMergedCellsInTable,
|
|
222
226
|
icon: icon,
|
|
223
227
|
onClick: function onClick(state, dispatch) {
|
|
224
|
-
|
|
228
|
+
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, index !== null && index !== void 0 ? index : 0, order)(state, dispatch);
|
|
225
229
|
return true;
|
|
226
230
|
}
|
|
227
231
|
};
|
|
@@ -5,15 +5,15 @@ import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/t
|
|
|
5
5
|
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import type { ResizeStateWithAnalytics } from './pm-plugins/table-resizing/utils';
|
|
7
7
|
import type { InsertRowMethods, InsertRowOptions, RowInsertPosition } from './types';
|
|
8
|
-
export declare const emptyMultipleCellsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB, targetCellPosition?: number) => Command;
|
|
8
|
+
export declare const emptyMultipleCellsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition?: number) => Command;
|
|
9
9
|
export declare const mergeCellsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | null | undefined) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) => Command;
|
|
10
10
|
export declare const splitCellWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) => Command;
|
|
11
|
-
export declare const setColorWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB, cellColor: string, targetCellPosition?: number) => Command;
|
|
11
|
+
export declare const setColorWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, cellColor: string, targetCellPosition?: number) => Command;
|
|
12
12
|
export declare const addRowAroundSelection: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (side: RowInsertPosition) => Command;
|
|
13
13
|
export declare const insertRowWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: InsertRowMethods, options: InsertRowOptions) => Command;
|
|
14
|
-
export declare const insertColumnWithAnalytics: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB, position: number) => Command;
|
|
15
|
-
export declare const deleteRowsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT, rect: Rect, isHeaderRowRequired: boolean) => Command;
|
|
16
|
-
export declare const deleteColumnsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT, rect: Rect) => Command;
|
|
14
|
+
export declare const insertColumnWithAnalytics: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, position: number) => Command;
|
|
15
|
+
export declare const deleteRowsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TABLE_CONTEXT_MENU, rect: Rect, isHeaderRowRequired: boolean) => Command;
|
|
16
|
+
export declare const deleteColumnsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TABLE_CONTEXT_MENU, rect: Rect) => Command;
|
|
17
17
|
export declare const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
18
18
|
export declare const deleteTableWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
19
19
|
export declare const deleteTableIfSelectedWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.FLOATING_TB | INPUT_METHOD.KEYBOARD) => Command;
|
|
@@ -21,6 +21,6 @@ export declare const toggleHeaderRowWithAnalytics: (editorAnalyticsAPI: EditorAn
|
|
|
21
21
|
export declare const toggleHeaderColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
22
22
|
export declare const toggleNumberColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
23
23
|
export declare const toggleTableLayoutWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
24
|
-
export declare const sortColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB, columnIndex: number, sortOrder: SortOrder) => Command;
|
|
25
|
-
export declare const distributeColumnsWidthsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB, { resizeState, table, attributes }: ResizeStateWithAnalytics) => Command;
|
|
24
|
+
export declare const sortColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, columnIndex: number, sortOrder: SortOrder) => Command;
|
|
25
|
+
export declare const distributeColumnsWidthsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, { resizeState, table, attributes }: ResizeStateWithAnalytics) => Command;
|
|
26
26
|
export declare const wrapTableInExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface InsertRowOptions {
|
|
|
26
26
|
moveCursorToInsertedRow: boolean;
|
|
27
27
|
}
|
|
28
28
|
export type PluginInjectionAPI = ExtractInjectionAPI<typeof tablePlugin>;
|
|
29
|
-
export type InsertRowMethods = INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB;
|
|
29
|
+
export type InsertRowMethods = INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU;
|
|
30
30
|
export interface PluginConfig {
|
|
31
31
|
advanced?: boolean;
|
|
32
32
|
allowBackgroundColor?: boolean;
|
|
@@ -13,4 +13,4 @@ export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
|
13
13
|
icon?: React.ComponentType<IconProps>;
|
|
14
14
|
keymap?: string;
|
|
15
15
|
}
|
|
16
|
-
export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, hasMergedCellsInTable: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect, editorAnalyticsAPI?: EditorAnalyticsAPI) => DragMenuConfig[];
|
|
16
|
+
export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, hasMergedCellsInTable: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect, editorAnalyticsAPI?: EditorAnalyticsAPI, isHeaderRowRequired?: boolean) => DragMenuConfig[];
|
|
@@ -5,15 +5,15 @@ import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/t
|
|
|
5
5
|
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import type { ResizeStateWithAnalytics } from './pm-plugins/table-resizing/utils';
|
|
7
7
|
import type { InsertRowMethods, InsertRowOptions, RowInsertPosition } from './types';
|
|
8
|
-
export declare const emptyMultipleCellsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB, targetCellPosition?: number) => Command;
|
|
8
|
+
export declare const emptyMultipleCellsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition?: number) => Command;
|
|
9
9
|
export declare const mergeCellsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | null | undefined) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) => Command;
|
|
10
10
|
export declare const splitCellWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) => Command;
|
|
11
|
-
export declare const setColorWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB, cellColor: string, targetCellPosition?: number) => Command;
|
|
11
|
+
export declare const setColorWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, cellColor: string, targetCellPosition?: number) => Command;
|
|
12
12
|
export declare const addRowAroundSelection: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (side: RowInsertPosition) => Command;
|
|
13
13
|
export declare const insertRowWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: InsertRowMethods, options: InsertRowOptions) => Command;
|
|
14
|
-
export declare const insertColumnWithAnalytics: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB, position: number) => Command;
|
|
15
|
-
export declare const deleteRowsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT, rect: Rect, isHeaderRowRequired: boolean) => Command;
|
|
16
|
-
export declare const deleteColumnsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT, rect: Rect) => Command;
|
|
14
|
+
export declare const insertColumnWithAnalytics: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, position: number) => Command;
|
|
15
|
+
export declare const deleteRowsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TABLE_CONTEXT_MENU, rect: Rect, isHeaderRowRequired: boolean) => Command;
|
|
16
|
+
export declare const deleteColumnsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TABLE_CONTEXT_MENU, rect: Rect) => Command;
|
|
17
17
|
export declare const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
18
18
|
export declare const deleteTableWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
19
19
|
export declare const deleteTableIfSelectedWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.FLOATING_TB | INPUT_METHOD.KEYBOARD) => Command;
|
|
@@ -21,6 +21,6 @@ export declare const toggleHeaderRowWithAnalytics: (editorAnalyticsAPI: EditorAn
|
|
|
21
21
|
export declare const toggleHeaderColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
22
22
|
export declare const toggleNumberColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
23
23
|
export declare const toggleTableLayoutWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
24
|
-
export declare const sortColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB, columnIndex: number, sortOrder: SortOrder) => Command;
|
|
25
|
-
export declare const distributeColumnsWidthsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB, { resizeState, table, attributes }: ResizeStateWithAnalytics) => Command;
|
|
24
|
+
export declare const sortColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, columnIndex: number, sortOrder: SortOrder) => Command;
|
|
25
|
+
export declare const distributeColumnsWidthsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, { resizeState, table, attributes }: ResizeStateWithAnalytics) => Command;
|
|
26
26
|
export declare const wrapTableInExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
@@ -26,7 +26,7 @@ export interface InsertRowOptions {
|
|
|
26
26
|
moveCursorToInsertedRow: boolean;
|
|
27
27
|
}
|
|
28
28
|
export type PluginInjectionAPI = ExtractInjectionAPI<typeof tablePlugin>;
|
|
29
|
-
export type InsertRowMethods = INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB;
|
|
29
|
+
export type InsertRowMethods = INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU;
|
|
30
30
|
export interface PluginConfig {
|
|
31
31
|
advanced?: boolean;
|
|
32
32
|
allowBackgroundColor?: boolean;
|
|
@@ -13,4 +13,4 @@ export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
|
13
13
|
icon?: React.ComponentType<IconProps>;
|
|
14
14
|
keymap?: string;
|
|
15
15
|
}
|
|
16
|
-
export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, hasMergedCellsInTable: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect, editorAnalyticsAPI?: EditorAnalyticsAPI) => DragMenuConfig[];
|
|
16
|
+
export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, hasMergedCellsInTable: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect, editorAnalyticsAPI?: EditorAnalyticsAPI, isHeaderRowRequired?: boolean) => DragMenuConfig[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.5",
|
|
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.5.1",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.0.13",
|
|
33
|
-
"@atlaskit/editor-common": "^77.
|
|
33
|
+
"@atlaskit/editor-common": "^77.5.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.5.2",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-content-insertion": "^1.0.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@atlaskit/primitives": "^2.0.0",
|
|
50
50
|
"@atlaskit/theme": "^12.6.0",
|
|
51
51
|
"@atlaskit/toggle": "^13.0.0",
|
|
52
|
-
"@atlaskit/tokens": "^1.
|
|
52
|
+
"@atlaskit/tokens": "^1.37.0",
|
|
53
53
|
"@atlaskit/tooltip": "^18.1.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
55
55
|
"@emotion/react": "^11.7.1",
|
|
@@ -73,7 +73,8 @@ export const emptyMultipleCellsWithAnalytics =
|
|
|
73
73
|
inputMethod:
|
|
74
74
|
| INPUT_METHOD.CONTEXT_MENU
|
|
75
75
|
| INPUT_METHOD.KEYBOARD
|
|
76
|
-
| INPUT_METHOD.FLOATING_TB
|
|
76
|
+
| INPUT_METHOD.FLOATING_TB
|
|
77
|
+
| INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
77
78
|
targetCellPosition?: number,
|
|
78
79
|
) =>
|
|
79
80
|
withEditorAnalyticsAPI(({ selection }) => {
|
|
@@ -164,7 +165,10 @@ export const splitCellWithAnalytics =
|
|
|
164
165
|
export const setColorWithAnalytics =
|
|
165
166
|
(editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
|
|
166
167
|
(
|
|
167
|
-
inputMethod:
|
|
168
|
+
inputMethod:
|
|
169
|
+
| INPUT_METHOD.CONTEXT_MENU
|
|
170
|
+
| INPUT_METHOD.FLOATING_TB
|
|
171
|
+
| INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
168
172
|
cellColor: string,
|
|
169
173
|
targetCellPosition?: number,
|
|
170
174
|
) =>
|
|
@@ -257,7 +261,8 @@ export const insertColumnWithAnalytics =
|
|
|
257
261
|
| INPUT_METHOD.CONTEXT_MENU
|
|
258
262
|
| INPUT_METHOD.BUTTON
|
|
259
263
|
| INPUT_METHOD.SHORTCUT
|
|
260
|
-
| INPUT_METHOD.FLOATING_TB
|
|
264
|
+
| INPUT_METHOD.FLOATING_TB
|
|
265
|
+
| INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
261
266
|
position: number,
|
|
262
267
|
) =>
|
|
263
268
|
withEditorAnalyticsAPI((state) => {
|
|
@@ -285,7 +290,8 @@ export const deleteRowsWithAnalytics =
|
|
|
285
290
|
| INPUT_METHOD.CONTEXT_MENU
|
|
286
291
|
| INPUT_METHOD.BUTTON
|
|
287
292
|
| INPUT_METHOD.FLOATING_TB
|
|
288
|
-
| INPUT_METHOD.SHORTCUT
|
|
293
|
+
| INPUT_METHOD.SHORTCUT
|
|
294
|
+
| INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
289
295
|
rect: Rect,
|
|
290
296
|
isHeaderRowRequired: boolean,
|
|
291
297
|
) =>
|
|
@@ -320,7 +326,8 @@ export const deleteColumnsWithAnalytics =
|
|
|
320
326
|
| INPUT_METHOD.CONTEXT_MENU
|
|
321
327
|
| INPUT_METHOD.BUTTON
|
|
322
328
|
| INPUT_METHOD.FLOATING_TB
|
|
323
|
-
| INPUT_METHOD.SHORTCUT
|
|
329
|
+
| INPUT_METHOD.SHORTCUT
|
|
330
|
+
| INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
324
331
|
rect: Rect,
|
|
325
332
|
) =>
|
|
326
333
|
withEditorAnalyticsAPI(({ selection }) => {
|
|
@@ -500,7 +507,10 @@ export const toggleTableLayoutWithAnalytics = (
|
|
|
500
507
|
export const sortColumnWithAnalytics =
|
|
501
508
|
(editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
|
|
502
509
|
(
|
|
503
|
-
inputMethod:
|
|
510
|
+
inputMethod:
|
|
511
|
+
| INPUT_METHOD.CONTEXT_MENU
|
|
512
|
+
| INPUT_METHOD.FLOATING_TB
|
|
513
|
+
| INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
504
514
|
columnIndex: number,
|
|
505
515
|
sortOrder: SortOrder,
|
|
506
516
|
) =>
|
|
@@ -526,7 +536,10 @@ export const sortColumnWithAnalytics =
|
|
|
526
536
|
export const distributeColumnsWidthsWithAnalytics =
|
|
527
537
|
(editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
|
|
528
538
|
(
|
|
529
|
-
inputMethod:
|
|
539
|
+
inputMethod:
|
|
540
|
+
| INPUT_METHOD.CONTEXT_MENU
|
|
541
|
+
| INPUT_METHOD.FLOATING_TB
|
|
542
|
+
| INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
530
543
|
{ resizeState, table, attributes }: ResizeStateWithAnalytics,
|
|
531
544
|
) => {
|
|
532
545
|
return withEditorAnalyticsAPI(() => {
|
package/src/types.ts
CHANGED
|
@@ -40,7 +40,8 @@ export type InsertRowMethods =
|
|
|
40
40
|
| INPUT_METHOD.BUTTON
|
|
41
41
|
| INPUT_METHOD.SHORTCUT
|
|
42
42
|
| INPUT_METHOD.KEYBOARD
|
|
43
|
-
| INPUT_METHOD.FLOATING_TB
|
|
43
|
+
| INPUT_METHOD.FLOATING_TB
|
|
44
|
+
| INPUT_METHOD.TABLE_CONTEXT_MENU;
|
|
44
45
|
|
|
45
46
|
export interface PluginConfig {
|
|
46
47
|
advanced?: boolean;
|
package/src/utils/drag-menu.ts
CHANGED
|
@@ -39,17 +39,17 @@ import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-d
|
|
|
39
39
|
import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
|
|
40
40
|
|
|
41
41
|
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
deleteColumnsWithAnalytics,
|
|
43
|
+
deleteRowsWithAnalytics,
|
|
44
|
+
distributeColumnsWidthsWithAnalytics,
|
|
45
|
+
emptyMultipleCellsWithAnalytics,
|
|
46
|
+
insertColumnWithAnalytics,
|
|
47
|
+
insertRowWithAnalytics,
|
|
48
|
+
sortColumnWithAnalytics,
|
|
49
|
+
} from '../commands-with-analytics';
|
|
48
50
|
import { moveSourceWithAnalytics } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
49
|
-
import { distributeColumnsWidths } from '../pm-plugins/table-resizing/commands';
|
|
50
51
|
import { getNewResizeStateFromSelectedColumns } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
51
52
|
import { getClosestSelectionRect } from '../toolbar';
|
|
52
|
-
import { deleteRows } from '../transforms';
|
|
53
53
|
import type { DraggableData, DraggableType, TableDirection } from '../types';
|
|
54
54
|
import {
|
|
55
55
|
AddColLeftIcon,
|
|
@@ -145,6 +145,8 @@ export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
|
145
145
|
keymap?: string;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
const defaultSelectionRect = { left: 0, top: 0, right: 0, bottom: 0 };
|
|
149
|
+
|
|
148
150
|
export const getDragMenuConfig = (
|
|
149
151
|
direction: TableDirection,
|
|
150
152
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
@@ -156,6 +158,7 @@ export const getDragMenuConfig = (
|
|
|
156
158
|
targetCellPosition?: number,
|
|
157
159
|
selectionRect?: Rect,
|
|
158
160
|
editorAnalyticsAPI?: EditorAnalyticsAPI,
|
|
161
|
+
isHeaderRowRequired?: boolean,
|
|
159
162
|
): DragMenuConfig[] => {
|
|
160
163
|
const addOptions =
|
|
161
164
|
direction === 'row'
|
|
@@ -282,9 +285,18 @@ export const getDragMenuConfig = (
|
|
|
282
285
|
icon,
|
|
283
286
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
284
287
|
if (direction === 'row') {
|
|
285
|
-
|
|
288
|
+
insertRowWithAnalytics(editorAnalyticsAPI)(
|
|
289
|
+
INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
290
|
+
{
|
|
291
|
+
index: (index ?? 0) + offset,
|
|
292
|
+
moveCursorToInsertedRow: true,
|
|
293
|
+
},
|
|
294
|
+
)(state, dispatch);
|
|
286
295
|
} else {
|
|
287
|
-
|
|
296
|
+
insertColumnWithAnalytics(
|
|
297
|
+
getEditorContainerWidth,
|
|
298
|
+
editorAnalyticsAPI,
|
|
299
|
+
)(INPUT_METHOD.TABLE_CONTEXT_MENU, (index ?? 0) + offset)(
|
|
288
300
|
state,
|
|
289
301
|
dispatch,
|
|
290
302
|
editorView,
|
|
@@ -310,8 +322,10 @@ export const getDragMenuConfig = (
|
|
|
310
322
|
);
|
|
311
323
|
|
|
312
324
|
if (newResizeState) {
|
|
313
|
-
|
|
314
|
-
|
|
325
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(
|
|
326
|
+
INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
327
|
+
newResizeState,
|
|
328
|
+
)(state, dispatch);
|
|
315
329
|
return true;
|
|
316
330
|
}
|
|
317
331
|
return false;
|
|
@@ -325,7 +339,10 @@ export const getDragMenuConfig = (
|
|
|
325
339
|
id: 'clear_cells',
|
|
326
340
|
title: 'Clear cells',
|
|
327
341
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
328
|
-
|
|
342
|
+
emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(
|
|
343
|
+
INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
344
|
+
targetCellPosition,
|
|
345
|
+
)(state, dispatch);
|
|
329
346
|
return true;
|
|
330
347
|
},
|
|
331
348
|
icon: CrossCircleIcon,
|
|
@@ -336,9 +353,16 @@ export const getDragMenuConfig = (
|
|
|
336
353
|
title: `Delete ${direction}`,
|
|
337
354
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
338
355
|
if (direction === 'row') {
|
|
339
|
-
|
|
356
|
+
deleteRowsWithAnalytics(editorAnalyticsAPI)(
|
|
357
|
+
INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
358
|
+
selectionRect ?? defaultSelectionRect,
|
|
359
|
+
!!isHeaderRowRequired,
|
|
360
|
+
)(state, dispatch);
|
|
340
361
|
} else {
|
|
341
|
-
|
|
362
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI)(
|
|
363
|
+
INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
364
|
+
selectionRect ?? defaultSelectionRect,
|
|
365
|
+
)(state, dispatch, editorView);
|
|
342
366
|
}
|
|
343
367
|
return true;
|
|
344
368
|
},
|
|
@@ -375,7 +399,11 @@ export const getDragMenuConfig = (
|
|
|
375
399
|
disabled: hasMergedCellsInTable,
|
|
376
400
|
icon,
|
|
377
401
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
378
|
-
|
|
402
|
+
sortColumnWithAnalytics(editorAnalyticsAPI)(
|
|
403
|
+
INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
404
|
+
index ?? 0,
|
|
405
|
+
order,
|
|
406
|
+
)(state, dispatch);
|
|
379
407
|
return true;
|
|
380
408
|
},
|
|
381
409
|
})),
|