@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
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
4
|
-
import React, { useState } from 'react';
|
|
4
|
+
import React, { useCallback, useState } from 'react';
|
|
5
5
|
import { DropList, Popup } from '@atlaskit/editor-common/ui';
|
|
6
6
|
import { ArrowKeyNavigationProvider, ArrowKeyNavigationType, DropdownMenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
7
7
|
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
8
8
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
9
9
|
import { MenuGroup, Section } from '@atlaskit/menu';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { dragMenuDropdownWidth } from '../consts';
|
|
11
12
|
var DropListWithOutsideClickTargetRef = function DropListWithOutsideClickTargetRef(props) {
|
|
12
13
|
var setOutsideClickTargetRef = React.useContext(OutsideClickTargetRefContext);
|
|
@@ -22,7 +23,7 @@ export var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
22
23
|
section = _ref.section,
|
|
23
24
|
disableKeyboardHandling = _ref.disableKeyboardHandling,
|
|
24
25
|
onItemActivated = _ref.onItemActivated,
|
|
25
|
-
|
|
26
|
+
handleClose = _ref.handleClose,
|
|
26
27
|
onMouseEnter = _ref.onMouseEnter,
|
|
27
28
|
onMouseLeave = _ref.onMouseLeave,
|
|
28
29
|
fitWidth = _ref.fitWidth,
|
|
@@ -52,11 +53,11 @@ export var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
52
53
|
shouldFitContainer: true,
|
|
53
54
|
position: popupPlacement.join(' '),
|
|
54
55
|
handleClickOutside: function handleClickOutside() {
|
|
55
|
-
return
|
|
56
|
+
return handleClose('editor');
|
|
56
57
|
},
|
|
57
58
|
handleEscapeKeydown: function handleEscapeKeydown() {
|
|
58
59
|
if (!disableKeyboardHandling) {
|
|
59
|
-
|
|
60
|
+
handleClose('handle');
|
|
60
61
|
}
|
|
61
62
|
},
|
|
62
63
|
handleEnterKeydown: function handleEnterKeydown(e) {
|
|
@@ -94,6 +95,51 @@ export var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
94
95
|
}));
|
|
95
96
|
})));
|
|
96
97
|
};
|
|
98
|
+
var onClose = useCallback(function () {
|
|
99
|
+
return handleClose('handle');
|
|
100
|
+
}, [handleClose]);
|
|
101
|
+
var onSelection = useCallback(function (index) {
|
|
102
|
+
var results = items.flatMap(function (item) {
|
|
103
|
+
return 'items' in item ? item.items : item;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// onSelection is called when any focusable element is 'activated'
|
|
107
|
+
// this is an issue as some menu items have toggles, which cause the index value
|
|
108
|
+
// in the callback to be outside of array length.
|
|
109
|
+
// The logic below normalises the index value based on the number
|
|
110
|
+
// of menu items with 2 focusable elements, and adjusts the index to ensure
|
|
111
|
+
// the correct menu item is sent in onItemActivated callback
|
|
112
|
+
var keys = ['row_numbers', 'header_row', 'header_column'];
|
|
113
|
+
var doubleItemCount = 0;
|
|
114
|
+
var firstIndex = results.findIndex(function (value) {
|
|
115
|
+
var key = value.key;
|
|
116
|
+
return key !== undefined && keys.includes(key);
|
|
117
|
+
});
|
|
118
|
+
if (firstIndex === -1 || index <= firstIndex) {
|
|
119
|
+
onItemActivated && onItemActivated({
|
|
120
|
+
item: results[index]
|
|
121
|
+
});
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
for (var i = firstIndex; i < results.length; i += 1) {
|
|
125
|
+
var key = results[i].key;
|
|
126
|
+
if (key !== undefined && keys.includes(key)) {
|
|
127
|
+
doubleItemCount += 1;
|
|
128
|
+
}
|
|
129
|
+
if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
|
|
130
|
+
onItemActivated && onItemActivated({
|
|
131
|
+
item: results[i]
|
|
132
|
+
});
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
|
|
136
|
+
onItemActivated && onItemActivated({
|
|
137
|
+
item: results[i]
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}, [items, onItemActivated]);
|
|
97
143
|
return (
|
|
98
144
|
/*#__PURE__*/
|
|
99
145
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -118,57 +164,23 @@ export var DropdownMenu = function DropdownMenu(_ref) {
|
|
|
118
164
|
zIndex: akEditorFloatingPanelZIndex,
|
|
119
165
|
offset: [offsetX, offsetY],
|
|
120
166
|
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
|
|
121
|
-
},
|
|
167
|
+
}, fg('platform_editor_table_drag_menu_flickers_fix') ? /*#__PURE__*/React.createElement(ArrowKeyNavigationProvider, {
|
|
168
|
+
closeOnTab: !disableKeyboardHandling,
|
|
169
|
+
type: ArrowKeyNavigationType.MENU,
|
|
170
|
+
handleClose: onClose,
|
|
171
|
+
onSelection: onSelection
|
|
172
|
+
// disableKeyboardHandling is linked with isSubmenuOpen in DragMenu
|
|
173
|
+
// When isSubmenuOpen is true, the background color picker palette is open, and the picker is a ColorPaletteArrowKeyNavigationProvider
|
|
174
|
+
// At the same time the MenuArrowKeyNavigationProvider are renderer too, as it is the wrapper for all other DragMenu items
|
|
175
|
+
// In this case we want the ColorPaletteArrowKeyNavigationProvider to handle the keyboard event, not the MenuArrowKeyNavigationProvider
|
|
176
|
+
// Hence set disableArrowKeyNavigation to true when disableKeyboardHandling is true
|
|
177
|
+
,
|
|
178
|
+
disableArrowKeyNavigation: disableKeyboardHandling
|
|
179
|
+
}, innerMenu()) : disableKeyboardHandling ? innerMenu() : /*#__PURE__*/React.createElement(ArrowKeyNavigationProvider, {
|
|
122
180
|
closeOnTab: true,
|
|
123
181
|
type: ArrowKeyNavigationType.MENU,
|
|
124
|
-
handleClose:
|
|
125
|
-
|
|
126
|
-
},
|
|
127
|
-
onSelection: function onSelection(index) {
|
|
128
|
-
var results = items.flatMap(function (item) {
|
|
129
|
-
return 'items' in item ? item.items : item;
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// onSelection is called when any focusable element is 'activated'
|
|
133
|
-
// this is an issue as some menu items have toggles, which cause the index value
|
|
134
|
-
// in the callback to be outside of array length.
|
|
135
|
-
// The logic below normalises the index value based on the number
|
|
136
|
-
// of menu items with 2 focusable elements, and adjusts the index to ensure
|
|
137
|
-
// the correct menu item is sent in onItemActivated callback
|
|
138
|
-
var keys = ['row_numbers', 'header_row', 'header_column'];
|
|
139
|
-
var doubleItemCount = 0;
|
|
140
|
-
|
|
141
|
-
// Ignored via go/ees005
|
|
142
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
143
|
-
var firstIndex = results.findIndex(function (value) {
|
|
144
|
-
return keys.includes(value.key);
|
|
145
|
-
});
|
|
146
|
-
if (firstIndex === -1 || index <= firstIndex) {
|
|
147
|
-
onItemActivated && onItemActivated({
|
|
148
|
-
item: results[index]
|
|
149
|
-
});
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
for (var i = firstIndex; i < results.length; i += 1) {
|
|
153
|
-
// Ignored via go/ees005
|
|
154
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
155
|
-
if (keys.includes(results[i].key)) {
|
|
156
|
-
doubleItemCount += 1;
|
|
157
|
-
}
|
|
158
|
-
if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
|
|
159
|
-
onItemActivated && onItemActivated({
|
|
160
|
-
item: results[i]
|
|
161
|
-
});
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
|
|
165
|
-
onItemActivated && onItemActivated({
|
|
166
|
-
item: results[i]
|
|
167
|
-
});
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
182
|
+
handleClose: onClose,
|
|
183
|
+
onSelection: onSelection
|
|
172
184
|
}, innerMenu())))
|
|
173
185
|
);
|
|
174
186
|
};
|
package/dist/{types-ts4.5/nodeviews/lazy-node-views.d.ts → types/nodeviews/table-node-views.d.ts}
RENAMED
|
@@ -17,12 +17,12 @@ type TableViewOptions = {
|
|
|
17
17
|
isCommentEditor?: boolean;
|
|
18
18
|
isChromelessEditor?: boolean;
|
|
19
19
|
};
|
|
20
|
-
export declare const
|
|
20
|
+
export declare const tableView: (options: TableViewOptions) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => import("prosemirror-view").NodeView;
|
|
21
21
|
type TableCellViewOptions = {
|
|
22
22
|
eventDispatcher: EventDispatcher;
|
|
23
23
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
24
24
|
};
|
|
25
|
-
export declare const
|
|
26
|
-
export declare const
|
|
27
|
-
export declare const
|
|
25
|
+
export declare const tableCellView: (options: TableCellViewOptions) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell;
|
|
26
|
+
export declare const tableHeaderView: (options: TableCellViewOptions) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell;
|
|
27
|
+
export declare const tableRowView: (options: TableCellViewOptions) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => TableRow;
|
|
28
28
|
export {};
|
package/dist/{types/nodeviews/lazy-node-views.d.ts → types-ts4.5/nodeviews/table-node-views.d.ts}
RENAMED
|
@@ -17,12 +17,12 @@ type TableViewOptions = {
|
|
|
17
17
|
isCommentEditor?: boolean;
|
|
18
18
|
isChromelessEditor?: boolean;
|
|
19
19
|
};
|
|
20
|
-
export declare const
|
|
20
|
+
export declare const tableView: (options: TableViewOptions) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => import("prosemirror-view").NodeView;
|
|
21
21
|
type TableCellViewOptions = {
|
|
22
22
|
eventDispatcher: EventDispatcher;
|
|
23
23
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
24
24
|
};
|
|
25
|
-
export declare const
|
|
26
|
-
export declare const
|
|
27
|
-
export declare const
|
|
25
|
+
export declare const tableCellView: (options: TableCellViewOptions) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell;
|
|
26
|
+
export declare const tableHeaderView: (options: TableCellViewOptions) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell;
|
|
27
|
+
export declare const tableRowView: (options: TableCellViewOptions) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => TableRow;
|
|
28
28
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "10.11.
|
|
3
|
+
"version": "10.11.7",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@atlaskit/editor-plugin-batch-attribute-updates": "^2.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-content-insertion": "^2.1.0",
|
|
41
41
|
"@atlaskit/editor-plugin-editor-viewmode": "^4.0.0",
|
|
42
|
-
"@atlaskit/editor-plugin-extension": "5.5.
|
|
42
|
+
"@atlaskit/editor-plugin-extension": "5.5.2",
|
|
43
43
|
"@atlaskit/editor-plugin-guideline": "^2.0.0",
|
|
44
|
-
"@atlaskit/editor-plugin-interaction": "^
|
|
44
|
+
"@atlaskit/editor-plugin-interaction": "^2.0.0",
|
|
45
45
|
"@atlaskit/editor-plugin-selection": "^2.2.0",
|
|
46
46
|
"@atlaskit/editor-plugin-width": "^3.0.0",
|
|
47
47
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
|
|
56
56
|
"@atlaskit/primitives": "^14.8.0",
|
|
57
57
|
"@atlaskit/theme": "^18.0.0",
|
|
58
|
-
"@atlaskit/tmp-editor-statsig": "^5.
|
|
58
|
+
"@atlaskit/tmp-editor-statsig": "^5.7.0",
|
|
59
59
|
"@atlaskit/toggle": "^15.0.0",
|
|
60
|
-
"@atlaskit/tokens": "^
|
|
60
|
+
"@atlaskit/tokens": "^5.0.0",
|
|
61
61
|
"@atlaskit/tooltip": "^20.2.0",
|
|
62
62
|
"@babel/runtime": "^7.0.0",
|
|
63
63
|
"@emotion/react": "^11.7.1",
|
|
@@ -136,12 +136,6 @@
|
|
|
136
136
|
"platform_editor_live_page_prevent_table_recreation": {
|
|
137
137
|
"type": "boolean"
|
|
138
138
|
},
|
|
139
|
-
"platform_editor_disable_table_lnv": {
|
|
140
|
-
"type": "boolean"
|
|
141
|
-
},
|
|
142
|
-
"platform_editor_enable_table_lnv": {
|
|
143
|
-
"type": "boolean"
|
|
144
|
-
},
|
|
145
139
|
"nested_table_control_padding_with_css": {
|
|
146
140
|
"type": "boolean"
|
|
147
141
|
},
|
|
@@ -208,6 +202,9 @@
|
|
|
208
202
|
"platform_editor_fix_table_resizing_undo": {
|
|
209
203
|
"type": "boolean"
|
|
210
204
|
},
|
|
205
|
+
"platform_editor_table_drag_menu_flickers_fix": {
|
|
206
|
+
"type": "boolean"
|
|
207
|
+
},
|
|
211
208
|
"platform_editor_table_last_col_drag_handle_fix": {
|
|
212
209
|
"type": "boolean"
|
|
213
210
|
},
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
|
+
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
4
|
+
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
|
|
8
|
+
import type { PluginInjectionAPI } from '../types';
|
|
9
|
+
|
|
10
|
+
// TODO: ED-23976 - Clean up
|
|
11
|
+
import { createTableView } from './table';
|
|
12
|
+
import TableCell from './TableCell';
|
|
13
|
+
import TableRow from './TableRow';
|
|
14
|
+
|
|
15
|
+
type TableViewOptions = {
|
|
16
|
+
portalProviderAPI: PortalProviderAPI;
|
|
17
|
+
eventDispatcher: EventDispatcher;
|
|
18
|
+
getEditorContainerWidth: GetEditorContainerWidth;
|
|
19
|
+
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
20
|
+
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
21
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
22
|
+
isCommentEditor?: boolean;
|
|
23
|
+
isChromelessEditor?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const tableView = (options: TableViewOptions) => {
|
|
27
|
+
return (node: PMNode, view: EditorView, getPos: () => number | undefined) => {
|
|
28
|
+
return createTableView(
|
|
29
|
+
node,
|
|
30
|
+
view,
|
|
31
|
+
getPos,
|
|
32
|
+
options.portalProviderAPI,
|
|
33
|
+
options.eventDispatcher,
|
|
34
|
+
options.getEditorContainerWidth,
|
|
35
|
+
options.getEditorFeatureFlags,
|
|
36
|
+
options.dispatchAnalyticsEvent,
|
|
37
|
+
options.pluginInjectionApi,
|
|
38
|
+
options.isCommentEditor,
|
|
39
|
+
options.isChromelessEditor,
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type TableCellViewOptions = {
|
|
45
|
+
eventDispatcher: EventDispatcher;
|
|
46
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
47
|
+
};
|
|
48
|
+
export const tableCellView = (options: TableCellViewOptions) => {
|
|
49
|
+
return (node: PMNode, view: EditorView, getPos: () => number | undefined) => {
|
|
50
|
+
return new TableCell(
|
|
51
|
+
node,
|
|
52
|
+
view,
|
|
53
|
+
getPos,
|
|
54
|
+
options.eventDispatcher,
|
|
55
|
+
options.pluginInjectionApi?.analytics?.actions,
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const tableHeaderView = (options: TableCellViewOptions) => {
|
|
61
|
+
return (node: PMNode, view: EditorView, getPos: () => number | undefined) => {
|
|
62
|
+
return new TableCell(
|
|
63
|
+
node,
|
|
64
|
+
view,
|
|
65
|
+
getPos,
|
|
66
|
+
options.eventDispatcher,
|
|
67
|
+
options.pluginInjectionApi?.analytics?.actions,
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const tableRowView = (options: TableCellViewOptions) => {
|
|
73
|
+
return (node: PMNode, view: EditorView, getPos: () => number | undefined) => {
|
|
74
|
+
return new TableRow(node, view, getPos, options.eventDispatcher);
|
|
75
|
+
};
|
|
76
|
+
};
|
package/src/pm-plugins/main.ts
CHANGED
|
@@ -28,11 +28,11 @@ import { findTable } from '@atlaskit/editor-tables/utils';
|
|
|
28
28
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
29
29
|
|
|
30
30
|
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} from '../nodeviews/
|
|
31
|
+
tableCellView,
|
|
32
|
+
tableHeaderView,
|
|
33
|
+
tableRowView,
|
|
34
|
+
tableView,
|
|
35
|
+
} from '../nodeviews/table-node-views';
|
|
36
36
|
import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plugin';
|
|
37
37
|
import type {
|
|
38
38
|
InvalidNodeAttr,
|
|
@@ -135,7 +135,7 @@ export const createPlugin = (
|
|
|
135
135
|
isSSR() && fg('platform_editor_table_fallback_to_dom_on_ssr')
|
|
136
136
|
? undefined
|
|
137
137
|
: {
|
|
138
|
-
table:
|
|
138
|
+
table: tableView({
|
|
139
139
|
portalProviderAPI,
|
|
140
140
|
eventDispatcher,
|
|
141
141
|
getEditorContainerWidth,
|
|
@@ -145,9 +145,9 @@ export const createPlugin = (
|
|
|
145
145
|
isCommentEditor,
|
|
146
146
|
isChromelessEditor,
|
|
147
147
|
}),
|
|
148
|
-
tableRow:
|
|
149
|
-
tableCell:
|
|
150
|
-
tableHeader:
|
|
148
|
+
tableRow: tableRowView({ eventDispatcher }),
|
|
149
|
+
tableCell: tableCellView({ eventDispatcher, pluginInjectionApi }),
|
|
150
|
+
tableHeader: tableHeaderView({ eventDispatcher, pluginInjectionApi }),
|
|
151
151
|
};
|
|
152
152
|
return new SafePlugin({
|
|
153
153
|
state: state,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
|
-
import React, { useState } from 'react';
|
|
2
|
+
import React, { useCallback, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import { DropList, type DropListProps, Popup } from '@atlaskit/editor-common/ui';
|
|
5
5
|
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from '@atlaskit/editor-common/ui-react';
|
|
15
15
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
16
16
|
import { MenuGroup, Section } from '@atlaskit/menu';
|
|
17
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
18
|
|
|
18
19
|
import { dragMenuDropdownWidth } from '../consts';
|
|
19
20
|
|
|
@@ -123,6 +124,49 @@ export const DropdownMenu = ({
|
|
|
123
124
|
);
|
|
124
125
|
};
|
|
125
126
|
|
|
127
|
+
const onClose = useCallback(() => handleClose('handle'), [handleClose]);
|
|
128
|
+
const onSelection = useCallback(
|
|
129
|
+
(index: number) => {
|
|
130
|
+
const results = items.flatMap((item) => ('items' in item ? item.items : item));
|
|
131
|
+
|
|
132
|
+
// onSelection is called when any focusable element is 'activated'
|
|
133
|
+
// this is an issue as some menu items have toggles, which cause the index value
|
|
134
|
+
// in the callback to be outside of array length.
|
|
135
|
+
// The logic below normalises the index value based on the number
|
|
136
|
+
// of menu items with 2 focusable elements, and adjusts the index to ensure
|
|
137
|
+
// the correct menu item is sent in onItemActivated callback
|
|
138
|
+
const keys = ['row_numbers', 'header_row', 'header_column'];
|
|
139
|
+
let doubleItemCount = 0;
|
|
140
|
+
|
|
141
|
+
const firstIndex = results.findIndex((value) => {
|
|
142
|
+
const key = value.key;
|
|
143
|
+
return key !== undefined && keys.includes(key);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
if (firstIndex === -1 || index <= firstIndex) {
|
|
147
|
+
onItemActivated && onItemActivated({ item: results[index] });
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
for (let i = firstIndex; i < results.length; i += 1) {
|
|
152
|
+
const key = results[i].key;
|
|
153
|
+
if (key !== undefined && keys.includes(key)) {
|
|
154
|
+
doubleItemCount += 1;
|
|
155
|
+
}
|
|
156
|
+
if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
|
|
157
|
+
onItemActivated && onItemActivated({ item: results[i] });
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
|
|
162
|
+
onItemActivated && onItemActivated({ item: results[i] });
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
[items, onItemActivated],
|
|
168
|
+
);
|
|
169
|
+
|
|
126
170
|
return (
|
|
127
171
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
128
172
|
<div className="drag-dropdown-menu-wrapper">
|
|
@@ -144,51 +188,29 @@ export const DropdownMenu = ({
|
|
|
144
188
|
offset={[offsetX, offsetY]}
|
|
145
189
|
allowOutOfBounds // 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
|
|
146
190
|
>
|
|
147
|
-
{
|
|
191
|
+
{fg('platform_editor_table_drag_menu_flickers_fix') ? (
|
|
192
|
+
<ArrowKeyNavigationProvider
|
|
193
|
+
closeOnTab={!disableKeyboardHandling}
|
|
194
|
+
type={ArrowKeyNavigationType.MENU}
|
|
195
|
+
handleClose={onClose}
|
|
196
|
+
onSelection={onSelection}
|
|
197
|
+
// disableKeyboardHandling is linked with isSubmenuOpen in DragMenu
|
|
198
|
+
// When isSubmenuOpen is true, the background color picker palette is open, and the picker is a ColorPaletteArrowKeyNavigationProvider
|
|
199
|
+
// At the same time the MenuArrowKeyNavigationProvider are renderer too, as it is the wrapper for all other DragMenu items
|
|
200
|
+
// In this case we want the ColorPaletteArrowKeyNavigationProvider to handle the keyboard event, not the MenuArrowKeyNavigationProvider
|
|
201
|
+
// Hence set disableArrowKeyNavigation to true when disableKeyboardHandling is true
|
|
202
|
+
disableArrowKeyNavigation={disableKeyboardHandling}
|
|
203
|
+
>
|
|
204
|
+
{innerMenu()}
|
|
205
|
+
</ArrowKeyNavigationProvider>
|
|
206
|
+
) : disableKeyboardHandling ? (
|
|
148
207
|
innerMenu()
|
|
149
208
|
) : (
|
|
150
209
|
<ArrowKeyNavigationProvider
|
|
151
210
|
closeOnTab
|
|
152
211
|
type={ArrowKeyNavigationType.MENU}
|
|
153
|
-
handleClose={
|
|
154
|
-
onSelection={
|
|
155
|
-
const results = items.flatMap((item) => ('items' in item ? item.items : item));
|
|
156
|
-
|
|
157
|
-
// onSelection is called when any focusable element is 'activated'
|
|
158
|
-
// this is an issue as some menu items have toggles, which cause the index value
|
|
159
|
-
// in the callback to be outside of array length.
|
|
160
|
-
// The logic below normalises the index value based on the number
|
|
161
|
-
// of menu items with 2 focusable elements, and adjusts the index to ensure
|
|
162
|
-
// the correct menu item is sent in onItemActivated callback
|
|
163
|
-
const keys = ['row_numbers', 'header_row', 'header_column'];
|
|
164
|
-
let doubleItemCount = 0;
|
|
165
|
-
|
|
166
|
-
// Ignored via go/ees005
|
|
167
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
168
|
-
const firstIndex = results.findIndex((value) => keys.includes(value.key!));
|
|
169
|
-
|
|
170
|
-
if (firstIndex === -1 || index <= firstIndex) {
|
|
171
|
-
onItemActivated && onItemActivated({ item: results[index] });
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
for (let i = firstIndex; i < results.length; i += 1) {
|
|
176
|
-
// Ignored via go/ees005
|
|
177
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
178
|
-
if (keys.includes(results[i].key!)) {
|
|
179
|
-
doubleItemCount += 1;
|
|
180
|
-
}
|
|
181
|
-
if (firstIndex % 2 === 0 && index - doubleItemCount === i) {
|
|
182
|
-
onItemActivated && onItemActivated({ item: results[i] });
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (firstIndex % 2 === 1 && index - doubleItemCount === i) {
|
|
187
|
-
onItemActivated && onItemActivated({ item: results[i] });
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}}
|
|
212
|
+
handleClose={onClose}
|
|
213
|
+
onSelection={onSelection}
|
|
192
214
|
>
|
|
193
215
|
{innerMenu()}
|
|
194
216
|
</ArrowKeyNavigationProvider>
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.lazyTableView = exports.lazyTableRowView = exports.lazyTableHeaderView = exports.lazyTableCellView = void 0;
|
|
8
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
-
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
10
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
|
-
var _table = require("./table");
|
|
13
|
-
var _TableCell = _interopRequireDefault(require("./TableCell"));
|
|
14
|
-
var _TableRow = _interopRequireDefault(require("./TableRow"));
|
|
15
|
-
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" != (0, _typeof2.default)(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); } // TODO: ED-23976 - Clean up
|
|
16
|
-
var lazyTableView = exports.lazyTableView = function lazyTableView(options) {
|
|
17
|
-
// LNV tables were broken in concurrent mode - they were temporarily disabled to unblock concurrent mode.
|
|
18
|
-
// Enabling them again via the platform_editor_enable_table_lnv flag.
|
|
19
|
-
if ((0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false) || !(0, _platformFeatureFlags.fg)('platform_editor_enable_table_lnv') && (0, _platformFeatureFlags.fg)('platform_editor_disable_table_lnv')) {
|
|
20
|
-
return function (node, view, getPos) {
|
|
21
|
-
return (0, _table.createTableView)(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.isCommentEditor, options.isChromelessEditor);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
var loader = function loader() {
|
|
25
|
-
var result = Promise.resolve().then(function () {
|
|
26
|
-
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_editor-plugin-table_nodeview" */
|
|
27
|
-
'./table'));
|
|
28
|
-
}).then(function (_ref) {
|
|
29
|
-
var createTableView = _ref.createTableView;
|
|
30
|
-
return function (node, view, getPos, decorations, getNodeViewOptions) {
|
|
31
|
-
var _getNodeViewOptions = getNodeViewOptions(),
|
|
32
|
-
portalProviderAPI = _getNodeViewOptions.portalProviderAPI,
|
|
33
|
-
eventDispatcher = _getNodeViewOptions.eventDispatcher,
|
|
34
|
-
getEditorContainerWidth = _getNodeViewOptions.getEditorContainerWidth,
|
|
35
|
-
getEditorFeatureFlags = _getNodeViewOptions.getEditorFeatureFlags,
|
|
36
|
-
dispatchAnalyticsEvent = _getNodeViewOptions.dispatchAnalyticsEvent,
|
|
37
|
-
pluginInjectionApi = _getNodeViewOptions.pluginInjectionApi,
|
|
38
|
-
isCommentEditor = _getNodeViewOptions.isCommentEditor,
|
|
39
|
-
isChromelessEditor = _getNodeViewOptions.isChromelessEditor;
|
|
40
|
-
return createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isCommentEditor, isChromelessEditor);
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
return result;
|
|
44
|
-
};
|
|
45
|
-
return (0, _lazyNodeView.withLazyLoading)({
|
|
46
|
-
nodeName: 'table',
|
|
47
|
-
getNodeViewOptions: function getNodeViewOptions() {
|
|
48
|
-
return options;
|
|
49
|
-
},
|
|
50
|
-
loader: loader
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
var lazyTableCellView = exports.lazyTableCellView = function lazyTableCellView(options) {
|
|
54
|
-
// LNV tables were broken in concurrent mode - they were temporarily disabled to unblock concurrent mode.
|
|
55
|
-
// Enabling them again via the platform_editor_enable_table_lnv flag.
|
|
56
|
-
if ((0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false) || !(0, _platformFeatureFlags.fg)('platform_editor_enable_table_lnv') && (0, _platformFeatureFlags.fg)('platform_editor_disable_table_lnv')) {
|
|
57
|
-
return function (node, view, getPos) {
|
|
58
|
-
var _options$pluginInject;
|
|
59
|
-
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);
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
var loader = function loader() {
|
|
63
|
-
var result = Promise.resolve().then(function () {
|
|
64
|
-
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_editor-plugin-table_nodeview" */
|
|
65
|
-
'./TableCell'));
|
|
66
|
-
}).then(function (_ref2) {
|
|
67
|
-
var TableCell = _ref2.default;
|
|
68
|
-
return function (node, view, getPos, decorations, getNodeViewOptions) {
|
|
69
|
-
var _pluginInjectionApi$a;
|
|
70
|
-
var _getNodeViewOptions2 = getNodeViewOptions(),
|
|
71
|
-
eventDispatcher = _getNodeViewOptions2.eventDispatcher,
|
|
72
|
-
pluginInjectionApi = _getNodeViewOptions2.pluginInjectionApi;
|
|
73
|
-
return new TableCell(node, view, getPos, eventDispatcher, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions);
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
return result;
|
|
77
|
-
};
|
|
78
|
-
return (0, _lazyNodeView.withLazyLoading)({
|
|
79
|
-
nodeName: 'tableCell',
|
|
80
|
-
getNodeViewOptions: function getNodeViewOptions() {
|
|
81
|
-
return options;
|
|
82
|
-
},
|
|
83
|
-
loader: loader
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
var lazyTableHeaderView = exports.lazyTableHeaderView = function lazyTableHeaderView(options) {
|
|
87
|
-
// LNV tables were broken in concurrent mode - they were temporarily disabled to unblock concurrent mode.
|
|
88
|
-
// Enabling them again via the platform_editor_enable_table_lnv flag.
|
|
89
|
-
if ((0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false) || !(0, _platformFeatureFlags.fg)('platform_editor_enable_table_lnv') && (0, _platformFeatureFlags.fg)('platform_editor_disable_table_lnv')) {
|
|
90
|
-
return function (node, view, getPos) {
|
|
91
|
-
var _options$pluginInject2;
|
|
92
|
-
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);
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
var loader = function loader() {
|
|
96
|
-
var result = Promise.resolve().then(function () {
|
|
97
|
-
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_editor-plugin-table-cell_nodeview" */
|
|
98
|
-
'./TableCell'));
|
|
99
|
-
}).then(function (_ref3) {
|
|
100
|
-
var TableCell = _ref3.default;
|
|
101
|
-
return function (node, view, getPos, decorations, getNodeViewOptions) {
|
|
102
|
-
var _pluginInjectionApi$a2;
|
|
103
|
-
var _getNodeViewOptions3 = getNodeViewOptions(),
|
|
104
|
-
eventDispatcher = _getNodeViewOptions3.eventDispatcher,
|
|
105
|
-
pluginInjectionApi = _getNodeViewOptions3.pluginInjectionApi;
|
|
106
|
-
return new TableCell(node, view, getPos, eventDispatcher, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions);
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
return result;
|
|
110
|
-
};
|
|
111
|
-
return (0, _lazyNodeView.withLazyLoading)({
|
|
112
|
-
nodeName: 'tableHeader',
|
|
113
|
-
getNodeViewOptions: function getNodeViewOptions() {
|
|
114
|
-
return options;
|
|
115
|
-
},
|
|
116
|
-
loader: loader
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
var lazyTableRowView = exports.lazyTableRowView = function lazyTableRowView(options) {
|
|
120
|
-
// LNV tables were broken in concurrent mode - they were temporarily disabled to unblock concurrent mode.
|
|
121
|
-
// Enabling them again via the platform_editor_enable_table_lnv flag.
|
|
122
|
-
if ((0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false) || !(0, _platformFeatureFlags.fg)('platform_editor_enable_table_lnv') && (0, _platformFeatureFlags.fg)('platform_editor_disable_table_lnv')) {
|
|
123
|
-
return function (node, view, getPos) {
|
|
124
|
-
return new _TableRow.default(node, view, getPos, options.eventDispatcher);
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
var loader = function loader() {
|
|
128
|
-
var result = Promise.resolve().then(function () {
|
|
129
|
-
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_editor-plugin-table-row_nodeview" */
|
|
130
|
-
'./TableRow'));
|
|
131
|
-
}).then(function (_ref4) {
|
|
132
|
-
var TableRow = _ref4.default;
|
|
133
|
-
return function (node, view, getPos, decorations, getNodeViewOptions) {
|
|
134
|
-
var _getNodeViewOptions4 = getNodeViewOptions(),
|
|
135
|
-
eventDispatcher = _getNodeViewOptions4.eventDispatcher;
|
|
136
|
-
return new TableRow(node, view, getPos, eventDispatcher);
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
return result;
|
|
140
|
-
};
|
|
141
|
-
return (0, _lazyNodeView.withLazyLoading)({
|
|
142
|
-
nodeName: 'tableRow',
|
|
143
|
-
getNodeViewOptions: function getNodeViewOptions() {
|
|
144
|
-
return options;
|
|
145
|
-
},
|
|
146
|
-
loader: loader
|
|
147
|
-
});
|
|
148
|
-
};
|