@atlaskit/editor-plugin-table 10.11.5 → 10.11.7
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 +18 -0
- package/dist/cjs/nodeviews/table-node-views.js +34 -0
- package/dist/cjs/pm-plugins/main.js +5 -5
- package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +64 -52
- package/dist/es2019/nodeviews/table-node-views.js +26 -0
- package/dist/es2019/pm-plugins/main.js +5 -5
- package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +58 -44
- package/dist/esm/nodeviews/table-node-views.js +26 -0
- package/dist/esm/pm-plugins/main.js +5 -5
- package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +65 -53
- package/dist/{types-ts4.5/nodeviews/lazy-node-views.d.ts → types/nodeviews/table-node-views.d.ts} +4 -4
- package/dist/{types/nodeviews/lazy-node-views.d.ts → types-ts4.5/nodeviews/table-node-views.d.ts} +4 -4
- package/package.json +8 -11
- package/src/nodeviews/table-node-views.ts +76 -0
- package/src/pm-plugins/main.ts +9 -9
- package/src/ui/FloatingDragMenu/DropdownMenu.tsx +63 -41
- package/dist/cjs/nodeviews/lazy-node-views.js +0 -148
- package/dist/es2019/nodeviews/lazy-node-views.js +0 -132
- package/dist/esm/nodeviews/lazy-node-views.js +0 -132
- package/src/nodeviews/lazy-node-views.ts +0 -246
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 10.11.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#164047](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/164047)
|
|
8
|
+
[`823d00b1d1429`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/823d00b1d1429) -
|
|
9
|
+
ED-27604: Fixed table drag menu flickers when hover background color menu
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 10.11.6
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#162726](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/162726)
|
|
17
|
+
[`05c3aa3d6cd0c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/05c3aa3d6cd0c) -
|
|
18
|
+
NOISSUE - Remove lazy node view for tables. Includes cleaning up the feature gates:
|
|
19
|
+
platform_editor_disable_table_lnv & platform_editor_enable_table_lnv.
|
|
20
|
+
|
|
3
21
|
## 10.11.5
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.tableView = exports.tableRowView = exports.tableHeaderView = exports.tableCellView = void 0;
|
|
8
|
+
var _table = require("./table");
|
|
9
|
+
var _TableCell = _interopRequireDefault(require("./TableCell"));
|
|
10
|
+
var _TableRow = _interopRequireDefault(require("./TableRow"));
|
|
11
|
+
// TODO: ED-23976 - Clean up
|
|
12
|
+
|
|
13
|
+
var tableView = exports.tableView = function tableView(options) {
|
|
14
|
+
return function (node, view, getPos) {
|
|
15
|
+
return (0, _table.createTableView)(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.isCommentEditor, options.isChromelessEditor);
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
var tableCellView = exports.tableCellView = function tableCellView(options) {
|
|
19
|
+
return function (node, view, getPos) {
|
|
20
|
+
var _options$pluginInject;
|
|
21
|
+
return new _TableCell.default(node, view, getPos, options.eventDispatcher, (_options$pluginInject = options.pluginInjectionApi) === null || _options$pluginInject === void 0 || (_options$pluginInject = _options$pluginInject.analytics) === null || _options$pluginInject === void 0 ? void 0 : _options$pluginInject.actions);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
var tableHeaderView = exports.tableHeaderView = function tableHeaderView(options) {
|
|
25
|
+
return function (node, view, getPos) {
|
|
26
|
+
var _options$pluginInject2;
|
|
27
|
+
return new _TableCell.default(node, view, getPos, options.eventDispatcher, (_options$pluginInject2 = options.pluginInjectionApi) === null || _options$pluginInject2 === void 0 || (_options$pluginInject2 = _options$pluginInject2.analytics) === null || _options$pluginInject2 === void 0 ? void 0 : _options$pluginInject2.actions);
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
var tableRowView = exports.tableRowView = function tableRowView(options) {
|
|
31
|
+
return function (node, view, getPos) {
|
|
32
|
+
return new _TableRow.default(node, view, getPos, options.eventDispatcher);
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -15,7 +15,7 @@ var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
|
15
15
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
16
16
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
17
17
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
|
-
var
|
|
18
|
+
var _tableNodeViews = require("../nodeviews/table-node-views");
|
|
19
19
|
var _plugin = require("../pm-plugins/decorations/plugin");
|
|
20
20
|
var _types = require("../types");
|
|
21
21
|
var _eventHandlers = require("../ui/event-handlers");
|
|
@@ -60,7 +60,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
60
60
|
return editorView.state;
|
|
61
61
|
};
|
|
62
62
|
var nodeViews = (0, _coreUtils.isSSR)() && (0, _platformFeatureFlags.fg)('platform_editor_table_fallback_to_dom_on_ssr') ? undefined : {
|
|
63
|
-
table: (0,
|
|
63
|
+
table: (0, _tableNodeViews.tableView)({
|
|
64
64
|
portalProviderAPI: portalProviderAPI,
|
|
65
65
|
eventDispatcher: eventDispatcher,
|
|
66
66
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
@@ -70,14 +70,14 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
70
70
|
isCommentEditor: isCommentEditor,
|
|
71
71
|
isChromelessEditor: isChromelessEditor
|
|
72
72
|
}),
|
|
73
|
-
tableRow: (0,
|
|
73
|
+
tableRow: (0, _tableNodeViews.tableRowView)({
|
|
74
74
|
eventDispatcher: eventDispatcher
|
|
75
75
|
}),
|
|
76
|
-
tableCell: (0,
|
|
76
|
+
tableCell: (0, _tableNodeViews.tableCellView)({
|
|
77
77
|
eventDispatcher: eventDispatcher,
|
|
78
78
|
pluginInjectionApi: pluginInjectionApi
|
|
79
79
|
}),
|
|
80
|
-
tableHeader: (0,
|
|
80
|
+
tableHeader: (0, _tableNodeViews.tableHeaderView)({
|
|
81
81
|
eventDispatcher: eventDispatcher,
|
|
82
82
|
pluginInjectionApi: pluginInjectionApi
|
|
83
83
|
})
|
|
@@ -14,6 +14,7 @@ var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
|
14
14
|
var _uiReact = require("@atlaskit/editor-common/ui-react");
|
|
15
15
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
16
16
|
var _menu = require("@atlaskit/menu");
|
|
17
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
18
|
var _consts = require("../consts");
|
|
18
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
19
20
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
@@ -32,7 +33,7 @@ var DropdownMenu = exports.DropdownMenu = function DropdownMenu(_ref) {
|
|
|
32
33
|
section = _ref.section,
|
|
33
34
|
disableKeyboardHandling = _ref.disableKeyboardHandling,
|
|
34
35
|
onItemActivated = _ref.onItemActivated,
|
|
35
|
-
|
|
36
|
+
handleClose = _ref.handleClose,
|
|
36
37
|
onMouseEnter = _ref.onMouseEnter,
|
|
37
38
|
onMouseLeave = _ref.onMouseLeave,
|
|
38
39
|
fitWidth = _ref.fitWidth,
|
|
@@ -62,11 +63,11 @@ var DropdownMenu = exports.DropdownMenu = function DropdownMenu(_ref) {
|
|
|
62
63
|
shouldFitContainer: true,
|
|
63
64
|
position: popupPlacement.join(' '),
|
|
64
65
|
handleClickOutside: function handleClickOutside() {
|
|
65
|
-
return
|
|
66
|
+
return handleClose('editor');
|
|
66
67
|
},
|
|
67
68
|
handleEscapeKeydown: function handleEscapeKeydown() {
|
|
68
69
|
if (!disableKeyboardHandling) {
|
|
69
|
-
|
|
70
|
+
handleClose('handle');
|
|
70
71
|
}
|
|
71
72
|
},
|
|
72
73
|
handleEnterKeydown: function handleEnterKeydown(e) {
|
|
@@ -104,6 +105,51 @@ var DropdownMenu = exports.DropdownMenu = function DropdownMenu(_ref) {
|
|
|
104
105
|
}));
|
|
105
106
|
})));
|
|
106
107
|
};
|
|
108
|
+
var onClose = (0, _react.useCallback)(function () {
|
|
109
|
+
return handleClose('handle');
|
|
110
|
+
}, [handleClose]);
|
|
111
|
+
var onSelection = (0, _react.useCallback)(function (index) {
|
|
112
|
+
var results = items.flatMap(function (item) {
|
|
113
|
+
return 'items' in item ? item.items : item;
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// onSelection is called when any focusable element is 'activated'
|
|
117
|
+
// this is an issue as some menu items have toggles, which cause the index value
|
|
118
|
+
// in the callback to be outside of array length.
|
|
119
|
+
// The logic below normalises the index value based on the number
|
|
120
|
+
// of menu items with 2 focusable elements, and adjusts the index to ensure
|
|
121
|
+
// the correct menu item is sent in onItemActivated callback
|
|
122
|
+
var keys = ['row_numbers', 'header_row', 'header_column'];
|
|
123
|
+
var doubleItemCount = 0;
|
|
124
|
+
var firstIndex = results.findIndex(function (value) {
|
|
125
|
+
var key = value.key;
|
|
126
|
+
return key !== undefined && keys.includes(key);
|
|
127
|
+
});
|
|
128
|
+
if (firstIndex === -1 || index <= firstIndex) {
|
|
129
|
+
onItemActivated && onItemActivated({
|
|
130
|
+
item: results[index]
|
|
131
|
+
});
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
for (var i = firstIndex; i < results.length; i += 1) {
|
|
135
|
+
var key = results[i].key;
|
|
136
|
+
if (key !== undefined && keys.includes(key)) {
|
|
137
|
+
doubleItemCount += 1;
|
|
138
|
+
}
|
|
139
|
+
if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
|
|
140
|
+
onItemActivated && onItemActivated({
|
|
141
|
+
item: results[i]
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
|
|
146
|
+
onItemActivated && onItemActivated({
|
|
147
|
+
item: results[i]
|
|
148
|
+
});
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}, [items, onItemActivated]);
|
|
107
153
|
return (
|
|
108
154
|
/*#__PURE__*/
|
|
109
155
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -128,57 +174,23 @@ var DropdownMenu = exports.DropdownMenu = function DropdownMenu(_ref) {
|
|
|
128
174
|
zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex,
|
|
129
175
|
offset: [offsetX, offsetY],
|
|
130
176
|
allowOutOfBounds: true // required as this popup is child of a parent popup, should be allowed to be out of bound of the parent popup, otherwise horizontal offset is not right
|
|
131
|
-
},
|
|
177
|
+
}, (0, _platformFeatureFlags.fg)('platform_editor_table_drag_menu_flickers_fix') ? /*#__PURE__*/_react.default.createElement(_uiMenu.ArrowKeyNavigationProvider, {
|
|
178
|
+
closeOnTab: !disableKeyboardHandling,
|
|
179
|
+
type: _uiMenu.ArrowKeyNavigationType.MENU,
|
|
180
|
+
handleClose: onClose,
|
|
181
|
+
onSelection: onSelection
|
|
182
|
+
// disableKeyboardHandling is linked with isSubmenuOpen in DragMenu
|
|
183
|
+
// When isSubmenuOpen is true, the background color picker palette is open, and the picker is a ColorPaletteArrowKeyNavigationProvider
|
|
184
|
+
// At the same time the MenuArrowKeyNavigationProvider are renderer too, as it is the wrapper for all other DragMenu items
|
|
185
|
+
// In this case we want the ColorPaletteArrowKeyNavigationProvider to handle the keyboard event, not the MenuArrowKeyNavigationProvider
|
|
186
|
+
// Hence set disableArrowKeyNavigation to true when disableKeyboardHandling is true
|
|
187
|
+
,
|
|
188
|
+
disableArrowKeyNavigation: disableKeyboardHandling
|
|
189
|
+
}, innerMenu()) : disableKeyboardHandling ? innerMenu() : /*#__PURE__*/_react.default.createElement(_uiMenu.ArrowKeyNavigationProvider, {
|
|
132
190
|
closeOnTab: true,
|
|
133
191
|
type: _uiMenu.ArrowKeyNavigationType.MENU,
|
|
134
|
-
handleClose:
|
|
135
|
-
|
|
136
|
-
},
|
|
137
|
-
onSelection: function onSelection(index) {
|
|
138
|
-
var results = items.flatMap(function (item) {
|
|
139
|
-
return 'items' in item ? item.items : item;
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// onSelection is called when any focusable element is 'activated'
|
|
143
|
-
// this is an issue as some menu items have toggles, which cause the index value
|
|
144
|
-
// in the callback to be outside of array length.
|
|
145
|
-
// The logic below normalises the index value based on the number
|
|
146
|
-
// of menu items with 2 focusable elements, and adjusts the index to ensure
|
|
147
|
-
// the correct menu item is sent in onItemActivated callback
|
|
148
|
-
var keys = ['row_numbers', 'header_row', 'header_column'];
|
|
149
|
-
var doubleItemCount = 0;
|
|
150
|
-
|
|
151
|
-
// Ignored via go/ees005
|
|
152
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
153
|
-
var firstIndex = results.findIndex(function (value) {
|
|
154
|
-
return keys.includes(value.key);
|
|
155
|
-
});
|
|
156
|
-
if (firstIndex === -1 || index <= firstIndex) {
|
|
157
|
-
onItemActivated && onItemActivated({
|
|
158
|
-
item: results[index]
|
|
159
|
-
});
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
for (var i = firstIndex; i < results.length; i += 1) {
|
|
163
|
-
// Ignored via go/ees005
|
|
164
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
165
|
-
if (keys.includes(results[i].key)) {
|
|
166
|
-
doubleItemCount += 1;
|
|
167
|
-
}
|
|
168
|
-
if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
|
|
169
|
-
onItemActivated && onItemActivated({
|
|
170
|
-
item: results[i]
|
|
171
|
-
});
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
|
|
175
|
-
onItemActivated && onItemActivated({
|
|
176
|
-
item: results[i]
|
|
177
|
-
});
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
192
|
+
handleClose: onClose,
|
|
193
|
+
onSelection: onSelection
|
|
182
194
|
}, innerMenu())))
|
|
183
195
|
);
|
|
184
196
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// TODO: ED-23976 - Clean up
|
|
2
|
+
import { createTableView } from './table';
|
|
3
|
+
import TableCell from './TableCell';
|
|
4
|
+
import TableRow from './TableRow';
|
|
5
|
+
export const tableView = options => {
|
|
6
|
+
return (node, view, getPos) => {
|
|
7
|
+
return createTableView(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.isCommentEditor, options.isChromelessEditor);
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export const tableCellView = options => {
|
|
11
|
+
return (node, view, getPos) => {
|
|
12
|
+
var _options$pluginInject, _options$pluginInject2;
|
|
13
|
+
return new TableCell(node, view, getPos, options.eventDispatcher, (_options$pluginInject = options.pluginInjectionApi) === null || _options$pluginInject === void 0 ? void 0 : (_options$pluginInject2 = _options$pluginInject.analytics) === null || _options$pluginInject2 === void 0 ? void 0 : _options$pluginInject2.actions);
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export const tableHeaderView = options => {
|
|
17
|
+
return (node, view, getPos) => {
|
|
18
|
+
var _options$pluginInject3, _options$pluginInject4;
|
|
19
|
+
return new TableCell(node, view, getPos, options.eventDispatcher, (_options$pluginInject3 = options.pluginInjectionApi) === null || _options$pluginInject3 === void 0 ? void 0 : (_options$pluginInject4 = _options$pluginInject3.analytics) === null || _options$pluginInject4 === void 0 ? void 0 : _options$pluginInject4.actions);
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export const tableRowView = options => {
|
|
23
|
+
return (node, view, getPos) => {
|
|
24
|
+
return new TableRow(node, view, getPos, options.eventDispatcher);
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -7,7 +7,7 @@ import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-p
|
|
|
7
7
|
import { TableMap } from '@atlaskit/editor-tables';
|
|
8
8
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
|
-
import {
|
|
10
|
+
import { tableCellView, tableHeaderView, tableRowView, tableView } from '../nodeviews/table-node-views';
|
|
11
11
|
import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plugin';
|
|
12
12
|
import { TableCssClassName as ClassName } from '../types';
|
|
13
13
|
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseUp, handleTripleClick, whenTableInFocus, withCellTracking } from '../ui/event-handlers';
|
|
@@ -51,7 +51,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
51
51
|
return editorView.state;
|
|
52
52
|
};
|
|
53
53
|
const nodeViews = isSSR() && fg('platform_editor_table_fallback_to_dom_on_ssr') ? undefined : {
|
|
54
|
-
table:
|
|
54
|
+
table: tableView({
|
|
55
55
|
portalProviderAPI,
|
|
56
56
|
eventDispatcher,
|
|
57
57
|
getEditorContainerWidth,
|
|
@@ -61,14 +61,14 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
61
61
|
isCommentEditor,
|
|
62
62
|
isChromelessEditor
|
|
63
63
|
}),
|
|
64
|
-
tableRow:
|
|
64
|
+
tableRow: tableRowView({
|
|
65
65
|
eventDispatcher
|
|
66
66
|
}),
|
|
67
|
-
tableCell:
|
|
67
|
+
tableCell: tableCellView({
|
|
68
68
|
eventDispatcher,
|
|
69
69
|
pluginInjectionApi
|
|
70
70
|
}),
|
|
71
|
-
tableHeader:
|
|
71
|
+
tableHeader: tableHeaderView({
|
|
72
72
|
eventDispatcher,
|
|
73
73
|
pluginInjectionApi
|
|
74
74
|
})
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
3
|
-
import React, { useState } from 'react';
|
|
3
|
+
import React, { useCallback, useState } from 'react';
|
|
4
4
|
import { DropList, Popup } from '@atlaskit/editor-common/ui';
|
|
5
5
|
import { ArrowKeyNavigationProvider, ArrowKeyNavigationType, DropdownMenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
6
6
|
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
7
7
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
8
8
|
import { MenuGroup, Section } from '@atlaskit/menu';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { dragMenuDropdownWidth } from '../consts';
|
|
10
11
|
const DropListWithOutsideClickTargetRef = props => {
|
|
11
12
|
const setOutsideClickTargetRef = React.useContext(OutsideClickTargetRefContext);
|
|
@@ -84,6 +85,47 @@ export const DropdownMenu = ({
|
|
|
84
85
|
});
|
|
85
86
|
})))));
|
|
86
87
|
};
|
|
88
|
+
const onClose = useCallback(() => handleClose('handle'), [handleClose]);
|
|
89
|
+
const onSelection = useCallback(index => {
|
|
90
|
+
const results = items.flatMap(item => 'items' in item ? item.items : item);
|
|
91
|
+
|
|
92
|
+
// onSelection is called when any focusable element is 'activated'
|
|
93
|
+
// this is an issue as some menu items have toggles, which cause the index value
|
|
94
|
+
// in the callback to be outside of array length.
|
|
95
|
+
// The logic below normalises the index value based on the number
|
|
96
|
+
// of menu items with 2 focusable elements, and adjusts the index to ensure
|
|
97
|
+
// the correct menu item is sent in onItemActivated callback
|
|
98
|
+
const keys = ['row_numbers', 'header_row', 'header_column'];
|
|
99
|
+
let doubleItemCount = 0;
|
|
100
|
+
const firstIndex = results.findIndex(value => {
|
|
101
|
+
const key = value.key;
|
|
102
|
+
return key !== undefined && keys.includes(key);
|
|
103
|
+
});
|
|
104
|
+
if (firstIndex === -1 || index <= firstIndex) {
|
|
105
|
+
onItemActivated && onItemActivated({
|
|
106
|
+
item: results[index]
|
|
107
|
+
});
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
for (let i = firstIndex; i < results.length; i += 1) {
|
|
111
|
+
const key = results[i].key;
|
|
112
|
+
if (key !== undefined && keys.includes(key)) {
|
|
113
|
+
doubleItemCount += 1;
|
|
114
|
+
}
|
|
115
|
+
if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
|
|
116
|
+
onItemActivated && onItemActivated({
|
|
117
|
+
item: results[i]
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
|
|
122
|
+
onItemActivated && onItemActivated({
|
|
123
|
+
item: results[i]
|
|
124
|
+
});
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}, [items, onItemActivated]);
|
|
87
129
|
return (
|
|
88
130
|
/*#__PURE__*/
|
|
89
131
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -108,51 +150,23 @@ export const DropdownMenu = ({
|
|
|
108
150
|
zIndex: akEditorFloatingPanelZIndex,
|
|
109
151
|
offset: [offsetX, offsetY],
|
|
110
152
|
allowOutOfBounds: true // required as this popup is child of a parent popup, should be allowed to be out of bound of the parent popup, otherwise horizontal offset is not right
|
|
111
|
-
},
|
|
153
|
+
}, fg('platform_editor_table_drag_menu_flickers_fix') ? /*#__PURE__*/React.createElement(ArrowKeyNavigationProvider, {
|
|
154
|
+
closeOnTab: !disableKeyboardHandling,
|
|
155
|
+
type: ArrowKeyNavigationType.MENU,
|
|
156
|
+
handleClose: onClose,
|
|
157
|
+
onSelection: onSelection
|
|
158
|
+
// disableKeyboardHandling is linked with isSubmenuOpen in DragMenu
|
|
159
|
+
// When isSubmenuOpen is true, the background color picker palette is open, and the picker is a ColorPaletteArrowKeyNavigationProvider
|
|
160
|
+
// At the same time the MenuArrowKeyNavigationProvider are renderer too, as it is the wrapper for all other DragMenu items
|
|
161
|
+
// In this case we want the ColorPaletteArrowKeyNavigationProvider to handle the keyboard event, not the MenuArrowKeyNavigationProvider
|
|
162
|
+
// Hence set disableArrowKeyNavigation to true when disableKeyboardHandling is true
|
|
163
|
+
,
|
|
164
|
+
disableArrowKeyNavigation: disableKeyboardHandling
|
|
165
|
+
}, innerMenu()) : disableKeyboardHandling ? innerMenu() : /*#__PURE__*/React.createElement(ArrowKeyNavigationProvider, {
|
|
112
166
|
closeOnTab: true,
|
|
113
167
|
type: ArrowKeyNavigationType.MENU,
|
|
114
|
-
handleClose:
|
|
115
|
-
onSelection:
|
|
116
|
-
const results = items.flatMap(item => 'items' in item ? item.items : item);
|
|
117
|
-
|
|
118
|
-
// onSelection is called when any focusable element is 'activated'
|
|
119
|
-
// this is an issue as some menu items have toggles, which cause the index value
|
|
120
|
-
// in the callback to be outside of array length.
|
|
121
|
-
// The logic below normalises the index value based on the number
|
|
122
|
-
// of menu items with 2 focusable elements, and adjusts the index to ensure
|
|
123
|
-
// the correct menu item is sent in onItemActivated callback
|
|
124
|
-
const keys = ['row_numbers', 'header_row', 'header_column'];
|
|
125
|
-
let doubleItemCount = 0;
|
|
126
|
-
|
|
127
|
-
// Ignored via go/ees005
|
|
128
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
129
|
-
const firstIndex = results.findIndex(value => keys.includes(value.key));
|
|
130
|
-
if (firstIndex === -1 || index <= firstIndex) {
|
|
131
|
-
onItemActivated && onItemActivated({
|
|
132
|
-
item: results[index]
|
|
133
|
-
});
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
for (let i = firstIndex; i < results.length; i += 1) {
|
|
137
|
-
// Ignored via go/ees005
|
|
138
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
139
|
-
if (keys.includes(results[i].key)) {
|
|
140
|
-
doubleItemCount += 1;
|
|
141
|
-
}
|
|
142
|
-
if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
|
|
143
|
-
onItemActivated && onItemActivated({
|
|
144
|
-
item: results[i]
|
|
145
|
-
});
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
|
|
149
|
-
onItemActivated && onItemActivated({
|
|
150
|
-
item: results[i]
|
|
151
|
-
});
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
168
|
+
handleClose: onClose,
|
|
169
|
+
onSelection: onSelection
|
|
156
170
|
}, innerMenu())))
|
|
157
171
|
);
|
|
158
172
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// TODO: ED-23976 - Clean up
|
|
2
|
+
import { createTableView } from './table';
|
|
3
|
+
import TableCell from './TableCell';
|
|
4
|
+
import TableRow from './TableRow';
|
|
5
|
+
export var tableView = function tableView(options) {
|
|
6
|
+
return function (node, view, getPos) {
|
|
7
|
+
return createTableView(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.isCommentEditor, options.isChromelessEditor);
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export var tableCellView = function tableCellView(options) {
|
|
11
|
+
return function (node, view, getPos) {
|
|
12
|
+
var _options$pluginInject;
|
|
13
|
+
return new TableCell(node, view, getPos, options.eventDispatcher, (_options$pluginInject = options.pluginInjectionApi) === null || _options$pluginInject === void 0 || (_options$pluginInject = _options$pluginInject.analytics) === null || _options$pluginInject === void 0 ? void 0 : _options$pluginInject.actions);
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export var tableHeaderView = function tableHeaderView(options) {
|
|
17
|
+
return function (node, view, getPos) {
|
|
18
|
+
var _options$pluginInject2;
|
|
19
|
+
return new TableCell(node, view, getPos, options.eventDispatcher, (_options$pluginInject2 = options.pluginInjectionApi) === null || _options$pluginInject2 === void 0 || (_options$pluginInject2 = _options$pluginInject2.analytics) === null || _options$pluginInject2 === void 0 ? void 0 : _options$pluginInject2.actions);
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export var tableRowView = function tableRowView(options) {
|
|
23
|
+
return function (node, view, getPos) {
|
|
24
|
+
return new TableRow(node, view, getPos, options.eventDispatcher);
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -10,7 +10,7 @@ import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-p
|
|
|
10
10
|
import { TableMap } from '@atlaskit/editor-tables';
|
|
11
11
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
12
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
|
-
import {
|
|
13
|
+
import { tableCellView, tableHeaderView, tableRowView, tableView } from '../nodeviews/table-node-views';
|
|
14
14
|
import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plugin';
|
|
15
15
|
import { TableCssClassName as ClassName } from '../types';
|
|
16
16
|
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseUp, handleTripleClick, whenTableInFocus, withCellTracking } from '../ui/event-handlers';
|
|
@@ -53,7 +53,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
53
53
|
return editorView.state;
|
|
54
54
|
};
|
|
55
55
|
var nodeViews = isSSR() && fg('platform_editor_table_fallback_to_dom_on_ssr') ? undefined : {
|
|
56
|
-
table:
|
|
56
|
+
table: tableView({
|
|
57
57
|
portalProviderAPI: portalProviderAPI,
|
|
58
58
|
eventDispatcher: eventDispatcher,
|
|
59
59
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
@@ -63,14 +63,14 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
63
63
|
isCommentEditor: isCommentEditor,
|
|
64
64
|
isChromelessEditor: isChromelessEditor
|
|
65
65
|
}),
|
|
66
|
-
tableRow:
|
|
66
|
+
tableRow: tableRowView({
|
|
67
67
|
eventDispatcher: eventDispatcher
|
|
68
68
|
}),
|
|
69
|
-
tableCell:
|
|
69
|
+
tableCell: tableCellView({
|
|
70
70
|
eventDispatcher: eventDispatcher,
|
|
71
71
|
pluginInjectionApi: pluginInjectionApi
|
|
72
72
|
}),
|
|
73
|
-
tableHeader:
|
|
73
|
+
tableHeader: tableHeaderView({
|
|
74
74
|
eventDispatcher: eventDispatcher,
|
|
75
75
|
pluginInjectionApi: pluginInjectionApi
|
|
76
76
|
})
|