@atlaskit/editor-plugin-table 5.5.11 → 5.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/plugins/table/commands/insert.js +17 -2
- package/dist/cjs/plugins/table/index.js +5 -1
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +4 -1
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +8 -11
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
- package/dist/es2019/plugins/table/commands/insert.js +15 -1
- package/dist/es2019/plugins/table/index.js +5 -1
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +3 -0
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +8 -11
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
- package/dist/esm/plugins/table/commands/insert.js +16 -1
- package/dist/esm/plugins/table/index.js +5 -1
- package/dist/esm/plugins/table/ui/DragHandle/index.js +4 -1
- package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +8 -11
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
- package/dist/types/plugins/table/commands/insert.d.ts +3 -1
- package/dist/types/plugins/table/index.d.ts +5 -1
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/insert.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/index.d.ts +5 -1
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/unit/ui/FloatingDragMenu.tsx +10 -13
- package/src/plugins/table/commands/insert.ts +26 -0
- package/src/plugins/table/index.tsx +16 -0
- package/src/plugins/table/ui/DragHandle/index.tsx +8 -0
- package/src/plugins/table/ui/FloatingDragMenu/index.tsx +16 -16
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +2 -5
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +2 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.5.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#60425](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60425) [`0caaaa7105f9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0caaaa7105f9) - [ux] Fix drag menu position and anchor element
|
|
8
|
+
|
|
9
|
+
## 5.5.12
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#60612](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60612) [`7edc766361a2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7edc766361a2) - Created an EditorCommad on table plugin to insert a table of custom size
|
|
14
|
+
|
|
3
15
|
## 5.5.11
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.addColumnAfter = void 0;
|
|
7
7
|
exports.addColumnAt = addColumnAt;
|
|
8
|
-
exports.insertRow = exports.insertColumn = exports.createTable = exports.addColumnBefore = void 0;
|
|
8
|
+
exports.insertTableWithSize = exports.insertRow = exports.insertColumn = exports.createTable = exports.addColumnBefore = void 0;
|
|
9
9
|
var _customSteps = require("@atlaskit/custom-steps");
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -154,4 +154,19 @@ var createTable = exports.createTable = function createTable() {
|
|
|
154
154
|
return true;
|
|
155
155
|
};
|
|
156
156
|
};
|
|
157
|
-
// #endregion
|
|
157
|
+
// #endregion
|
|
158
|
+
|
|
159
|
+
var insertTableWithSize = exports.insertTableWithSize = function insertTableWithSize(editorAnalyticsAPI) {
|
|
160
|
+
return function (rowsCount, colsCount, inputMethod) {
|
|
161
|
+
return function (_ref) {
|
|
162
|
+
var tr = _ref.tr;
|
|
163
|
+
var tableNode = (0, _utils2.createTable)({
|
|
164
|
+
schema: tr.doc.type.schema,
|
|
165
|
+
rowsCount: rowsCount,
|
|
166
|
+
colsCount: colsCount
|
|
167
|
+
});
|
|
168
|
+
var newTr = (0, _utils.safeInsert)(tableNode)(tr).scrollIntoView();
|
|
169
|
+
return newTr;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
};
|
|
@@ -18,6 +18,7 @@ var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
|
|
|
18
18
|
var _pmPlugins = require("@atlaskit/editor-tables/pm-plugins");
|
|
19
19
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
20
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
|
+
var _insert = require("./commands/insert");
|
|
21
22
|
var _createPluginConfig = require("./create-plugin-config");
|
|
22
23
|
var _plugin = require("./pm-plugins/analytics/plugin");
|
|
23
24
|
var _pluginKey = require("./pm-plugins/analytics/plugin-key");
|
|
@@ -49,7 +50,7 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
|
49
50
|
* from `@atlaskit/editor-core`.
|
|
50
51
|
*/
|
|
51
52
|
var tablesPlugin = function tablesPlugin(_ref) {
|
|
52
|
-
var _api$analytics;
|
|
53
|
+
var _api$analytics, _api$analytics2;
|
|
53
54
|
var options = _ref.config,
|
|
54
55
|
api = _ref.api;
|
|
55
56
|
var editorViewRef = {
|
|
@@ -84,6 +85,9 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
87
|
},
|
|
88
|
+
commands: {
|
|
89
|
+
insertTableWithSize: (0, _insert.insertTableWithSize)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
90
|
+
},
|
|
87
91
|
nodes: function nodes() {
|
|
88
92
|
var tableNode = options !== null && options !== void 0 && options.tableResizingEnabled ? _adfSchema.tableWithCustomWidth : _adfSchema.table;
|
|
89
93
|
return [{
|
|
@@ -22,7 +22,8 @@ var _HandleIconComponent = require("./HandleIconComponent");
|
|
|
22
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
24
|
var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
25
|
-
var
|
|
25
|
+
var isDragMenuTarget = _ref.isDragMenuTarget,
|
|
26
|
+
tableLocalId = _ref.tableLocalId,
|
|
26
27
|
_ref$direction = _ref.direction,
|
|
27
28
|
direction = _ref$direction === void 0 ? 'row' : _ref$direction,
|
|
28
29
|
_ref$appearance = _ref.appearance,
|
|
@@ -114,7 +115,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
117
|
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells, _canDrag]);
|
|
118
|
+
var showDragMenuAnchorId = direction === 'row' ? 'drag-handle-button-row' : 'drag-handle-button-column';
|
|
117
119
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
|
120
|
+
id: isDragMenuTarget ? showDragMenuAnchorId : undefined,
|
|
118
121
|
className: (0, _classnames2.default)(_types.TableCssClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, (0, _defineProperty2.default)({}, _types.TableCssClassName.DRAG_HANDLE_DISABLED, !_canDrag || hasMergedCells)),
|
|
119
122
|
ref: dragHandleDivRef,
|
|
120
123
|
style: {
|
|
@@ -7,9 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
10
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
|
-
var
|
|
11
|
+
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
13
12
|
var _consts = require("../consts");
|
|
14
13
|
var _DragMenu = require("./DragMenu");
|
|
15
14
|
var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
@@ -18,7 +17,6 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
18
17
|
scrollableElement = _ref.scrollableElement,
|
|
19
18
|
editorView = _ref.editorView,
|
|
20
19
|
isOpen = _ref.isOpen,
|
|
21
|
-
tableRef = _ref.tableRef,
|
|
22
20
|
tableNode = _ref.tableNode,
|
|
23
21
|
direction = _ref.direction,
|
|
24
22
|
index = _ref.index,
|
|
@@ -28,18 +26,17 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
28
26
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
29
27
|
return null;
|
|
30
28
|
}
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
if (!targetCellRef) {
|
|
29
|
+
var targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
|
|
30
|
+
if (!targetHandleRef || !(editorView.state.selection instanceof _cellSelection.CellSelection)) {
|
|
34
31
|
return null;
|
|
35
32
|
}
|
|
36
|
-
var
|
|
37
|
-
|
|
33
|
+
var offset = direction === 'row' ? [-9, 6] : [0, -7];
|
|
34
|
+
|
|
38
35
|
// TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
|
|
39
36
|
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
40
|
-
alignX: direction === 'row' ? '
|
|
41
|
-
alignY:
|
|
42
|
-
target:
|
|
37
|
+
alignX: direction === 'row' ? 'right' : undefined,
|
|
38
|
+
alignY: direction === 'row' ? 'start' : undefined,
|
|
39
|
+
target: targetHandleRef,
|
|
43
40
|
mountTo: mountPoint,
|
|
44
41
|
boundariesElement: boundariesElement,
|
|
45
42
|
scrollableElement: scrollableElement,
|
|
@@ -138,8 +138,9 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
138
138
|
zIndex: 99
|
|
139
139
|
},
|
|
140
140
|
"data-column-control-index": hoveredCell.colIndex,
|
|
141
|
-
"data-testid":
|
|
141
|
+
"data-testid": 'table-floating-column-control'
|
|
142
142
|
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
143
|
+
isDragMenuTarget: !isHover,
|
|
143
144
|
direction: "column",
|
|
144
145
|
tableLocalId: localId || '',
|
|
145
146
|
indexes: indexes,
|
|
@@ -150,8 +150,9 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
150
150
|
position: 'relative',
|
|
151
151
|
right: '-0.5px'
|
|
152
152
|
},
|
|
153
|
-
"data-testid":
|
|
153
|
+
"data-testid": 'table-floating-row-drag-handle'
|
|
154
154
|
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
155
|
+
isDragMenuTarget: !isHover,
|
|
155
156
|
direction: "row",
|
|
156
157
|
tableLocalId: currentNodeLocalId,
|
|
157
158
|
indexes: indexes,
|
|
@@ -133,4 +133,18 @@ export const createTable = () => (state, dispatch) => {
|
|
|
133
133
|
}
|
|
134
134
|
return true;
|
|
135
135
|
};
|
|
136
|
-
// #endregion
|
|
136
|
+
// #endregion
|
|
137
|
+
|
|
138
|
+
export const insertTableWithSize = editorAnalyticsAPI => (rowsCount, colsCount, inputMethod) => {
|
|
139
|
+
return ({
|
|
140
|
+
tr
|
|
141
|
+
}) => {
|
|
142
|
+
const tableNode = createTableNode({
|
|
143
|
+
schema: tr.doc.type.schema,
|
|
144
|
+
rowsCount: rowsCount,
|
|
145
|
+
colsCount: colsCount
|
|
146
|
+
});
|
|
147
|
+
const newTr = safeInsert(tableNode)(tr).scrollIntoView();
|
|
148
|
+
return newTr;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
@@ -11,6 +11,7 @@ import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
|
11
11
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
12
12
|
import { createTable } from '@atlaskit/editor-tables/utils';
|
|
13
13
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
14
|
+
import { insertTableWithSize } from './commands/insert';
|
|
14
15
|
import { pluginConfig } from './create-plugin-config';
|
|
15
16
|
import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analytics/plugin';
|
|
16
17
|
import { pluginKey as tableAnalyticsPluginKey } from './pm-plugins/analytics/plugin-key';
|
|
@@ -43,7 +44,7 @@ const tablesPlugin = ({
|
|
|
43
44
|
config: options,
|
|
44
45
|
api
|
|
45
46
|
}) => {
|
|
46
|
-
var _api$analytics;
|
|
47
|
+
var _api$analytics, _api$analytics2;
|
|
47
48
|
const editorViewRef = {
|
|
48
49
|
current: null
|
|
49
50
|
};
|
|
@@ -74,6 +75,9 @@ const tablesPlugin = ({
|
|
|
74
75
|
})) !== null && _api$contentInsertion !== void 0 ? _api$contentInsertion : false;
|
|
75
76
|
}
|
|
76
77
|
},
|
|
78
|
+
commands: {
|
|
79
|
+
insertTableWithSize: insertTableWithSize(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
80
|
+
},
|
|
77
81
|
nodes() {
|
|
78
82
|
const tableNode = options !== null && options !== void 0 && options.tableResizingEnabled ? tableWithCustomWidth : table;
|
|
79
83
|
return [{
|
|
@@ -10,6 +10,7 @@ import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
|
10
10
|
import { DragPreview } from '../DragPreview';
|
|
11
11
|
import { HandleIconComponent } from './HandleIconComponent';
|
|
12
12
|
export const DragHandle = ({
|
|
13
|
+
isDragMenuTarget,
|
|
13
14
|
tableLocalId,
|
|
14
15
|
direction = 'row',
|
|
15
16
|
appearance = 'default',
|
|
@@ -98,7 +99,9 @@ export const DragHandle = ({
|
|
|
98
99
|
});
|
|
99
100
|
}
|
|
100
101
|
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells, canDrag]);
|
|
102
|
+
const showDragMenuAnchorId = direction === 'row' ? 'drag-handle-button-row' : 'drag-handle-button-column';
|
|
101
103
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
104
|
+
id: isDragMenuTarget ? showDragMenuAnchorId : undefined,
|
|
102
105
|
className: classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, {
|
|
103
106
|
[ClassName.DRAG_HANDLE_DISABLED]: !canDrag || hasMergedCells
|
|
104
107
|
}),
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
3
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
3
|
import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
5
|
-
import {
|
|
4
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
6
5
|
import { dragMenuDropdownWidth } from '../consts';
|
|
7
6
|
import { DragMenu } from './DragMenu';
|
|
8
7
|
const FloatingDragMenu = ({
|
|
@@ -11,7 +10,6 @@ const FloatingDragMenu = ({
|
|
|
11
10
|
scrollableElement,
|
|
12
11
|
editorView,
|
|
13
12
|
isOpen,
|
|
14
|
-
tableRef,
|
|
15
13
|
tableNode,
|
|
16
14
|
direction,
|
|
17
15
|
index,
|
|
@@ -22,18 +20,17 @@ const FloatingDragMenu = ({
|
|
|
22
20
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
23
21
|
return null;
|
|
24
22
|
}
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
if (!targetCellRef) {
|
|
23
|
+
const targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
|
|
24
|
+
if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) {
|
|
28
25
|
return null;
|
|
29
26
|
}
|
|
30
|
-
const
|
|
31
|
-
|
|
27
|
+
const offset = direction === 'row' ? [-9, 6] : [0, -7];
|
|
28
|
+
|
|
32
29
|
// TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
|
|
33
30
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
34
|
-
alignX: direction === 'row' ? '
|
|
35
|
-
alignY:
|
|
36
|
-
target:
|
|
31
|
+
alignX: direction === 'row' ? 'right' : undefined,
|
|
32
|
+
alignY: direction === 'row' ? 'start' : undefined,
|
|
33
|
+
target: targetHandleRef,
|
|
37
34
|
mountTo: mountPoint,
|
|
38
35
|
boundariesElement: boundariesElement,
|
|
39
36
|
scrollableElement: scrollableElement,
|
|
@@ -136,8 +136,9 @@ export const ColumnControls = ({
|
|
|
136
136
|
zIndex: 99
|
|
137
137
|
},
|
|
138
138
|
"data-column-control-index": hoveredCell.colIndex,
|
|
139
|
-
"data-testid":
|
|
139
|
+
"data-testid": 'table-floating-column-control'
|
|
140
140
|
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
141
|
+
isDragMenuTarget: !isHover,
|
|
141
142
|
direction: "column",
|
|
142
143
|
tableLocalId: localId || '',
|
|
143
144
|
indexes: indexes,
|
|
@@ -140,8 +140,9 @@ const DragControlsComponent = ({
|
|
|
140
140
|
position: 'relative',
|
|
141
141
|
right: '-0.5px'
|
|
142
142
|
},
|
|
143
|
-
"data-testid":
|
|
143
|
+
"data-testid": 'table-floating-row-drag-handle'
|
|
144
144
|
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
145
|
+
isDragMenuTarget: !isHover,
|
|
145
146
|
direction: "row",
|
|
146
147
|
tableLocalId: currentNodeLocalId,
|
|
147
148
|
indexes: indexes,
|
|
@@ -145,4 +145,19 @@ export var createTable = function createTable() {
|
|
|
145
145
|
return true;
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
|
-
// #endregion
|
|
148
|
+
// #endregion
|
|
149
|
+
|
|
150
|
+
export var insertTableWithSize = function insertTableWithSize(editorAnalyticsAPI) {
|
|
151
|
+
return function (rowsCount, colsCount, inputMethod) {
|
|
152
|
+
return function (_ref) {
|
|
153
|
+
var tr = _ref.tr;
|
|
154
|
+
var tableNode = createTableNode({
|
|
155
|
+
schema: tr.doc.type.schema,
|
|
156
|
+
rowsCount: rowsCount,
|
|
157
|
+
colsCount: colsCount
|
|
158
|
+
});
|
|
159
|
+
var newTr = safeInsert(tableNode)(tr).scrollIntoView();
|
|
160
|
+
return newTr;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
@@ -11,6 +11,7 @@ import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
|
11
11
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
12
12
|
import { createTable } from '@atlaskit/editor-tables/utils';
|
|
13
13
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
14
|
+
import { insertTableWithSize } from './commands/insert';
|
|
14
15
|
import { pluginConfig } from './create-plugin-config';
|
|
15
16
|
import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analytics/plugin';
|
|
16
17
|
import { pluginKey as tableAnalyticsPluginKey } from './pm-plugins/analytics/plugin-key';
|
|
@@ -42,7 +43,7 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
|
42
43
|
* from `@atlaskit/editor-core`.
|
|
43
44
|
*/
|
|
44
45
|
var tablesPlugin = function tablesPlugin(_ref) {
|
|
45
|
-
var _api$analytics;
|
|
46
|
+
var _api$analytics, _api$analytics2;
|
|
46
47
|
var options = _ref.config,
|
|
47
48
|
api = _ref.api;
|
|
48
49
|
var editorViewRef = {
|
|
@@ -77,6 +78,9 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
80
|
},
|
|
81
|
+
commands: {
|
|
82
|
+
insertTableWithSize: insertTableWithSize(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
83
|
+
},
|
|
80
84
|
nodes: function nodes() {
|
|
81
85
|
var tableNode = options !== null && options !== void 0 && options.tableResizingEnabled ? tableWithCustomWidth : table;
|
|
82
86
|
return [{
|
|
@@ -12,7 +12,8 @@ import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
|
12
12
|
import { DragPreview } from '../DragPreview';
|
|
13
13
|
import { HandleIconComponent } from './HandleIconComponent';
|
|
14
14
|
export var DragHandle = function DragHandle(_ref) {
|
|
15
|
-
var
|
|
15
|
+
var isDragMenuTarget = _ref.isDragMenuTarget,
|
|
16
|
+
tableLocalId = _ref.tableLocalId,
|
|
16
17
|
_ref$direction = _ref.direction,
|
|
17
18
|
direction = _ref$direction === void 0 ? 'row' : _ref$direction,
|
|
18
19
|
_ref$appearance = _ref.appearance,
|
|
@@ -104,7 +105,9 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells, _canDrag]);
|
|
108
|
+
var showDragMenuAnchorId = direction === 'row' ? 'drag-handle-button-row' : 'drag-handle-button-column';
|
|
107
109
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
110
|
+
id: isDragMenuTarget ? showDragMenuAnchorId : undefined,
|
|
108
111
|
className: classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, _defineProperty({}, ClassName.DRAG_HANDLE_DISABLED, !_canDrag || hasMergedCells)),
|
|
109
112
|
ref: dragHandleDivRef,
|
|
110
113
|
style: {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
3
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
3
|
import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
5
|
-
import {
|
|
4
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
6
5
|
import { dragMenuDropdownWidth } from '../consts';
|
|
7
6
|
import { DragMenu } from './DragMenu';
|
|
8
7
|
var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
@@ -11,7 +10,6 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
11
10
|
scrollableElement = _ref.scrollableElement,
|
|
12
11
|
editorView = _ref.editorView,
|
|
13
12
|
isOpen = _ref.isOpen,
|
|
14
|
-
tableRef = _ref.tableRef,
|
|
15
13
|
tableNode = _ref.tableNode,
|
|
16
14
|
direction = _ref.direction,
|
|
17
15
|
index = _ref.index,
|
|
@@ -21,18 +19,17 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
21
19
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
22
20
|
return null;
|
|
23
21
|
}
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
if (!targetCellRef) {
|
|
22
|
+
var targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
|
|
23
|
+
if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) {
|
|
27
24
|
return null;
|
|
28
25
|
}
|
|
29
|
-
var
|
|
30
|
-
|
|
26
|
+
var offset = direction === 'row' ? [-9, 6] : [0, -7];
|
|
27
|
+
|
|
31
28
|
// TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
|
|
32
29
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
33
|
-
alignX: direction === 'row' ? '
|
|
34
|
-
alignY:
|
|
35
|
-
target:
|
|
30
|
+
alignX: direction === 'row' ? 'right' : undefined,
|
|
31
|
+
alignY: direction === 'row' ? 'start' : undefined,
|
|
32
|
+
target: targetHandleRef,
|
|
36
33
|
mountTo: mountPoint,
|
|
37
34
|
boundariesElement: boundariesElement,
|
|
38
35
|
scrollableElement: scrollableElement,
|
|
@@ -129,8 +129,9 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
129
129
|
zIndex: 99
|
|
130
130
|
},
|
|
131
131
|
"data-column-control-index": hoveredCell.colIndex,
|
|
132
|
-
"data-testid":
|
|
132
|
+
"data-testid": 'table-floating-column-control'
|
|
133
133
|
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
134
|
+
isDragMenuTarget: !isHover,
|
|
134
135
|
direction: "column",
|
|
135
136
|
tableLocalId: localId || '',
|
|
136
137
|
indexes: indexes,
|
|
@@ -140,8 +140,9 @@ 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-drag-handle'
|
|
144
144
|
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
145
|
+
isDragMenuTarget: !isHover,
|
|
145
146
|
direction: "row",
|
|
146
147
|
tableLocalId: currentNodeLocalId,
|
|
147
148
|
indexes: indexes,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, EditorCommand, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
5
|
export declare function addColumnAt(getEditorContainerWidth: GetEditorContainerWidth): (column: number, allowAddColumnCustomStep: boolean | undefined, view: EditorView | undefined) => (tr: Transaction) => Transaction;
|
|
@@ -7,3 +8,4 @@ export declare const addColumnAfter: (getEditorContainerWidth: GetEditorContaine
|
|
|
7
8
|
export declare const insertColumn: (getEditorContainerWidth: GetEditorContainerWidth) => (column: number) => Command;
|
|
8
9
|
export declare const insertRow: (row: number, moveCursorToTheNewRow: boolean) => Command;
|
|
9
10
|
export declare const createTable: () => Command;
|
|
11
|
+
export declare const insertTableWithSize: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER | INPUT_METHOD.ASCII | INPUT_METHOD.TYPEAHEAD) => EditorCommand;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { Command, EditorCommand, GetEditorFeatureFlags, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
5
|
import type { ContentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
5
6
|
import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
@@ -22,6 +23,9 @@ export type TablePlugin = NextEditorPlugin<'table', {
|
|
|
22
23
|
actions: {
|
|
23
24
|
insertTable: InsertTableAction;
|
|
24
25
|
};
|
|
26
|
+
commands: {
|
|
27
|
+
insertTableWithSize: (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER | INPUT_METHOD.ASCII | INPUT_METHOD.TYPEAHEAD) => EditorCommand;
|
|
28
|
+
};
|
|
25
29
|
dependencies: [
|
|
26
30
|
AnalyticsPlugin,
|
|
27
31
|
ContentInsertionPlugin,
|
|
@@ -16,6 +16,7 @@ type DragHandleProps = {
|
|
|
16
16
|
onMouseUp?: MouseEventHandler;
|
|
17
17
|
editorView: EditorView;
|
|
18
18
|
canDrag?: boolean;
|
|
19
|
+
isDragMenuTarget: boolean;
|
|
19
20
|
};
|
|
20
|
-
export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, forceDefaultHandle, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, canDrag, }: DragHandleProps) => JSX.Element;
|
|
21
|
+
export declare const DragHandle: ({ isDragMenuTarget, tableLocalId, direction, appearance, indexes, forceDefaultHandle, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, canDrag, }: DragHandleProps) => JSX.Element;
|
|
21
22
|
export {};
|
|
@@ -18,7 +18,7 @@ export interface Props {
|
|
|
18
18
|
canDrag?: boolean;
|
|
19
19
|
}
|
|
20
20
|
declare const FloatingDragMenu: {
|
|
21
|
-
({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen,
|
|
21
|
+
({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, }: Props): JSX.Element | null;
|
|
22
22
|
displayName: string;
|
|
23
23
|
};
|
|
24
24
|
export default FloatingDragMenu;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, EditorCommand, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
5
|
export declare function addColumnAt(getEditorContainerWidth: GetEditorContainerWidth): (column: number, allowAddColumnCustomStep: boolean | undefined, view: EditorView | undefined) => (tr: Transaction) => Transaction;
|
|
@@ -7,3 +8,4 @@ export declare const addColumnAfter: (getEditorContainerWidth: GetEditorContaine
|
|
|
7
8
|
export declare const insertColumn: (getEditorContainerWidth: GetEditorContainerWidth) => (column: number) => Command;
|
|
8
9
|
export declare const insertRow: (row: number, moveCursorToTheNewRow: boolean) => Command;
|
|
9
10
|
export declare const createTable: () => Command;
|
|
11
|
+
export declare const insertTableWithSize: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER | INPUT_METHOD.ASCII | INPUT_METHOD.TYPEAHEAD) => EditorCommand;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { Command, EditorCommand, GetEditorFeatureFlags, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
5
|
import type { ContentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
5
6
|
import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
@@ -22,6 +23,9 @@ export type TablePlugin = NextEditorPlugin<'table', {
|
|
|
22
23
|
actions: {
|
|
23
24
|
insertTable: InsertTableAction;
|
|
24
25
|
};
|
|
26
|
+
commands: {
|
|
27
|
+
insertTableWithSize: (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER | INPUT_METHOD.ASCII | INPUT_METHOD.TYPEAHEAD) => EditorCommand;
|
|
28
|
+
};
|
|
25
29
|
dependencies: [
|
|
26
30
|
AnalyticsPlugin,
|
|
27
31
|
ContentInsertionPlugin,
|
|
@@ -16,6 +16,7 @@ type DragHandleProps = {
|
|
|
16
16
|
onMouseUp?: MouseEventHandler;
|
|
17
17
|
editorView: EditorView;
|
|
18
18
|
canDrag?: boolean;
|
|
19
|
+
isDragMenuTarget: boolean;
|
|
19
20
|
};
|
|
20
|
-
export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, forceDefaultHandle, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, canDrag, }: DragHandleProps) => JSX.Element;
|
|
21
|
+
export declare const DragHandle: ({ isDragMenuTarget, tableLocalId, direction, appearance, indexes, forceDefaultHandle, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, canDrag, }: DragHandleProps) => JSX.Element;
|
|
21
22
|
export {};
|
|
@@ -18,7 +18,7 @@ export interface Props {
|
|
|
18
18
|
canDrag?: boolean;
|
|
19
19
|
}
|
|
20
20
|
declare const FloatingDragMenu: {
|
|
21
|
-
({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen,
|
|
21
|
+
({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, }: Props): JSX.Element | null;
|
|
22
22
|
displayName: string;
|
|
23
23
|
};
|
|
24
24
|
export default FloatingDragMenu;
|
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
import { ffTest } from '@atlassian/feature-flags-test-utils';
|
|
34
34
|
|
|
35
35
|
import tablePlugin from '../../../plugins/table-plugin';
|
|
36
|
-
import
|
|
36
|
+
import { DragMenu } from '../../../plugins/table/ui/FloatingDragMenu/DragMenu';
|
|
37
37
|
|
|
38
38
|
describe('FloatingDragMenu', () => {
|
|
39
39
|
const createEditor = createProsemirrorEditorFactory();
|
|
@@ -72,14 +72,13 @@ describe('FloatingDragMenu', () => {
|
|
|
72
72
|
editorRef,
|
|
73
73
|
}}
|
|
74
74
|
>
|
|
75
|
-
<
|
|
75
|
+
<DragMenu
|
|
76
76
|
editorView={editorView}
|
|
77
|
-
isOpen
|
|
77
|
+
isOpen={true}
|
|
78
78
|
getEditorContainerWidth={jest.fn()}
|
|
79
79
|
tableRef={tableRef as HTMLTableElement}
|
|
80
80
|
tableNode={tableNode?.node}
|
|
81
81
|
direction="row"
|
|
82
|
-
targetCellPosition={1}
|
|
83
82
|
/>
|
|
84
83
|
</ReactEditorViewContext.Provider>,
|
|
85
84
|
);
|
|
@@ -98,14 +97,13 @@ describe('FloatingDragMenu', () => {
|
|
|
98
97
|
editorRef,
|
|
99
98
|
}}
|
|
100
99
|
>
|
|
101
|
-
<
|
|
100
|
+
<DragMenu
|
|
102
101
|
editorView={editorView}
|
|
103
|
-
isOpen
|
|
102
|
+
isOpen={true}
|
|
104
103
|
getEditorContainerWidth={jest.fn()}
|
|
105
104
|
tableRef={tableRef as HTMLTableElement}
|
|
106
105
|
tableNode={tableNode?.node}
|
|
107
106
|
direction="row"
|
|
108
|
-
targetCellPosition={1}
|
|
109
107
|
/>
|
|
110
108
|
</ReactEditorViewContext.Provider>,
|
|
111
109
|
);
|
|
@@ -127,14 +125,14 @@ describe('FloatingDragMenu', () => {
|
|
|
127
125
|
editorRef,
|
|
128
126
|
}}
|
|
129
127
|
>
|
|
130
|
-
<
|
|
128
|
+
<div id="drag-handle-button-row">dragmenu anchor</div>
|
|
129
|
+
<DragMenu
|
|
131
130
|
editorView={editorView}
|
|
132
|
-
isOpen
|
|
131
|
+
isOpen={true}
|
|
133
132
|
getEditorContainerWidth={jest.fn()}
|
|
134
133
|
tableRef={tableRef as HTMLTableElement}
|
|
135
134
|
tableNode={tableNode?.node}
|
|
136
135
|
direction="row"
|
|
137
|
-
targetCellPosition={1}
|
|
138
136
|
/>
|
|
139
137
|
</ReactEditorViewContext.Provider>,
|
|
140
138
|
);
|
|
@@ -163,14 +161,13 @@ describe('FloatingDragMenu', () => {
|
|
|
163
161
|
editorRef,
|
|
164
162
|
}}
|
|
165
163
|
>
|
|
166
|
-
<
|
|
164
|
+
<DragMenu
|
|
167
165
|
editorView={editorView}
|
|
168
|
-
isOpen
|
|
166
|
+
isOpen={true}
|
|
169
167
|
getEditorContainerWidth={jest.fn()}
|
|
170
168
|
tableRef={tableRef as HTMLTableElement}
|
|
171
169
|
tableNode={tableNode?.node}
|
|
172
170
|
direction="column"
|
|
173
|
-
targetCellPosition={1}
|
|
174
171
|
/>
|
|
175
172
|
</ReactEditorViewContext.Provider>,
|
|
176
173
|
);
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
// #region Imports
|
|
2
2
|
import { AddColumnStep } from '@atlaskit/custom-steps';
|
|
3
|
+
import type {
|
|
4
|
+
EditorAnalyticsAPI,
|
|
5
|
+
INPUT_METHOD,
|
|
6
|
+
} from '@atlaskit/editor-common/analytics';
|
|
3
7
|
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
4
8
|
import type {
|
|
5
9
|
Command,
|
|
10
|
+
EditorCommand,
|
|
6
11
|
GetEditorContainerWidth,
|
|
7
12
|
} from '@atlaskit/editor-common/types';
|
|
8
13
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -201,3 +206,24 @@ export const createTable = (): Command => (state, dispatch) => {
|
|
|
201
206
|
return true;
|
|
202
207
|
};
|
|
203
208
|
// #endregion
|
|
209
|
+
|
|
210
|
+
export const insertTableWithSize =
|
|
211
|
+
(editorAnalyticsAPI: EditorAnalyticsAPI | undefined) =>
|
|
212
|
+
(
|
|
213
|
+
rowsCount: number,
|
|
214
|
+
colsCount: number,
|
|
215
|
+
inputMethod?:
|
|
216
|
+
| INPUT_METHOD.PICKER
|
|
217
|
+
| INPUT_METHOD.ASCII
|
|
218
|
+
| INPUT_METHOD.TYPEAHEAD,
|
|
219
|
+
): EditorCommand => {
|
|
220
|
+
return ({ tr }) => {
|
|
221
|
+
const tableNode = createTableNode({
|
|
222
|
+
schema: tr.doc.type.schema,
|
|
223
|
+
rowsCount: rowsCount,
|
|
224
|
+
colsCount: colsCount,
|
|
225
|
+
});
|
|
226
|
+
const newTr = safeInsert(tableNode)(tr).scrollIntoView();
|
|
227
|
+
return newTr;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
@@ -23,6 +23,7 @@ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/
|
|
|
23
23
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
24
24
|
import type {
|
|
25
25
|
Command,
|
|
26
|
+
EditorCommand,
|
|
26
27
|
EditorPlugin,
|
|
27
28
|
GetEditorContainerWidth,
|
|
28
29
|
GetEditorFeatureFlags,
|
|
@@ -41,6 +42,7 @@ import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
|
41
42
|
import { createTable } from '@atlaskit/editor-tables/utils';
|
|
42
43
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
43
44
|
|
|
45
|
+
import { insertTableWithSize } from './commands/insert';
|
|
44
46
|
import { pluginConfig } from './create-plugin-config';
|
|
45
47
|
import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analytics/plugin';
|
|
46
48
|
import { pluginKey as tableAnalyticsPluginKey } from './pm-plugins/analytics/plugin-key';
|
|
@@ -78,6 +80,7 @@ import FloatingDragMenu from './ui/FloatingDragMenu';
|
|
|
78
80
|
import FloatingInsertButton from './ui/FloatingInsertButton';
|
|
79
81
|
import LayoutButton from './ui/LayoutButton';
|
|
80
82
|
import { isLayoutSupported } from './utils';
|
|
83
|
+
|
|
81
84
|
export interface TablePluginOptions {
|
|
82
85
|
tableOptions: PluginConfig;
|
|
83
86
|
// experimental custom table resizing experience, set inside editor-core behind a feature flag
|
|
@@ -103,6 +106,16 @@ export type TablePlugin = NextEditorPlugin<
|
|
|
103
106
|
actions: {
|
|
104
107
|
insertTable: InsertTableAction;
|
|
105
108
|
};
|
|
109
|
+
commands: {
|
|
110
|
+
insertTableWithSize: (
|
|
111
|
+
rowsCount: number,
|
|
112
|
+
colsCount: number,
|
|
113
|
+
inputMethod?:
|
|
114
|
+
| INPUT_METHOD.PICKER
|
|
115
|
+
| INPUT_METHOD.ASCII
|
|
116
|
+
| INPUT_METHOD.TYPEAHEAD,
|
|
117
|
+
) => EditorCommand;
|
|
118
|
+
};
|
|
106
119
|
dependencies: [
|
|
107
120
|
AnalyticsPlugin,
|
|
108
121
|
ContentInsertionPlugin,
|
|
@@ -152,6 +165,9 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
152
165
|
);
|
|
153
166
|
},
|
|
154
167
|
},
|
|
168
|
+
commands: {
|
|
169
|
+
insertTableWithSize: insertTableWithSize(api?.analytics?.actions),
|
|
170
|
+
},
|
|
155
171
|
|
|
156
172
|
nodes() {
|
|
157
173
|
const tableNode = options?.tableResizingEnabled
|
|
@@ -33,9 +33,11 @@ type DragHandleProps = {
|
|
|
33
33
|
onMouseUp?: MouseEventHandler;
|
|
34
34
|
editorView: EditorView;
|
|
35
35
|
canDrag?: boolean;
|
|
36
|
+
isDragMenuTarget: boolean; // this is identify which current handle component is
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
export const DragHandle = ({
|
|
40
|
+
isDragMenuTarget,
|
|
39
41
|
tableLocalId,
|
|
40
42
|
direction = 'row',
|
|
41
43
|
appearance = 'default',
|
|
@@ -131,9 +133,15 @@ export const DragHandle = ({
|
|
|
131
133
|
canDrag,
|
|
132
134
|
]);
|
|
133
135
|
|
|
136
|
+
const showDragMenuAnchorId =
|
|
137
|
+
direction === 'row'
|
|
138
|
+
? 'drag-handle-button-row'
|
|
139
|
+
: 'drag-handle-button-column';
|
|
140
|
+
|
|
134
141
|
return (
|
|
135
142
|
<>
|
|
136
143
|
<button
|
|
144
|
+
id={isDragMenuTarget ? showDragMenuAnchorId : undefined}
|
|
137
145
|
className={classnames(
|
|
138
146
|
ClassName.DRAG_HANDLE_BUTTON_CONTAINER,
|
|
139
147
|
appearance,
|
|
@@ -3,10 +3,9 @@ import React from 'react';
|
|
|
3
3
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
4
4
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
5
5
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
7
6
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
7
|
import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
9
|
-
import {
|
|
8
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
10
9
|
|
|
11
10
|
import type { TableDirection } from '../../types';
|
|
12
11
|
import { dragMenuDropdownWidth } from '../consts';
|
|
@@ -34,7 +33,6 @@ const FloatingDragMenu = ({
|
|
|
34
33
|
scrollableElement,
|
|
35
34
|
editorView,
|
|
36
35
|
isOpen,
|
|
37
|
-
tableRef,
|
|
38
36
|
tableNode,
|
|
39
37
|
direction,
|
|
40
38
|
index,
|
|
@@ -50,24 +48,26 @@ const FloatingDragMenu = ({
|
|
|
50
48
|
return null;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
const targetHandleRef =
|
|
52
|
+
direction === 'row'
|
|
53
|
+
? document.querySelector('#drag-handle-button-row')
|
|
54
|
+
: document.querySelector('#drag-handle-button-column');
|
|
55
|
+
|
|
56
|
+
if (
|
|
57
|
+
!targetHandleRef ||
|
|
58
|
+
!(editorView.state.selection instanceof CellSelection)
|
|
59
|
+
) {
|
|
56
60
|
return null;
|
|
57
61
|
}
|
|
58
|
-
|
|
59
|
-
const offset =
|
|
60
|
-
|
|
61
|
-
? [7, 0]
|
|
62
|
-
: index === (tableMap?.width || 1) - 1
|
|
63
|
-
? [14, 0]
|
|
64
|
-
: [-14, 0];
|
|
62
|
+
|
|
63
|
+
const offset = direction === 'row' ? [-9, 6] : [0, -7];
|
|
64
|
+
|
|
65
65
|
// TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
|
|
66
66
|
return (
|
|
67
67
|
<Popup
|
|
68
|
-
alignX={direction === 'row' ? '
|
|
69
|
-
alignY=
|
|
70
|
-
target={
|
|
68
|
+
alignX={direction === 'row' ? 'right' : undefined}
|
|
69
|
+
alignY={direction === 'row' ? 'start' : undefined}
|
|
70
|
+
target={targetHandleRef as HTMLElement}
|
|
71
71
|
mountTo={mountPoint}
|
|
72
72
|
boundariesElement={boundariesElement}
|
|
73
73
|
scrollableElement={scrollableElement}
|
|
@@ -217,13 +217,10 @@ export const ColumnControls = ({
|
|
|
217
217
|
zIndex: 99,
|
|
218
218
|
}}
|
|
219
219
|
data-column-control-index={hoveredCell.colIndex}
|
|
220
|
-
data-testid={
|
|
221
|
-
isHover
|
|
222
|
-
? 'table-floating-column-control-hover'
|
|
223
|
-
: 'table-floating-column-control'
|
|
224
|
-
}
|
|
220
|
+
data-testid={'table-floating-column-control'}
|
|
225
221
|
>
|
|
226
222
|
<DragHandle
|
|
223
|
+
isDragMenuTarget={!isHover}
|
|
227
224
|
direction="column"
|
|
228
225
|
tableLocalId={localId || ''}
|
|
229
226
|
indexes={indexes}
|
|
@@ -239,13 +239,10 @@ const DragControlsComponent = ({
|
|
|
239
239
|
position: 'relative',
|
|
240
240
|
right: '-0.5px',
|
|
241
241
|
}}
|
|
242
|
-
data-testid={
|
|
243
|
-
isHover
|
|
244
|
-
? 'table-floating-row-drag-handle-hover'
|
|
245
|
-
: 'table-floating-row-drag-handle'
|
|
246
|
-
}
|
|
242
|
+
data-testid={'table-floating-row-drag-handle'}
|
|
247
243
|
>
|
|
248
244
|
<DragHandle
|
|
245
|
+
isDragMenuTarget={!isHover}
|
|
249
246
|
direction="row"
|
|
250
247
|
tableLocalId={currentNodeLocalId}
|
|
251
248
|
indexes={indexes}
|