@atlaskit/editor-plugin-table 7.29.6 → 7.29.8
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 +17 -0
- package/afm-cc/tsconfig.json +1 -2
- package/dist/cjs/plugin.js +1 -2
- package/dist/cjs/pm-plugins/keymap.js +1 -4
- package/dist/cjs/ui/FloatingContextualButton/index.js +7 -10
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +42 -72
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +1 -3
- package/dist/es2019/plugin.js +1 -2
- package/dist/es2019/pm-plugins/keymap.js +1 -4
- package/dist/es2019/ui/FloatingContextualButton/index.js +9 -12
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +47 -77
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +1 -3
- package/dist/esm/plugin.js +1 -2
- package/dist/esm/pm-plugins/keymap.js +1 -4
- package/dist/esm/ui/FloatingContextualButton/index.js +7 -10
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +42 -72
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +1 -3
- package/package.json +2 -5
- package/src/plugin.tsx +1 -4
- package/src/pm-plugins/keymap.ts +2 -4
- package/src/ui/FloatingContextualButton/index.tsx +6 -13
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +81 -127
- package/src/ui/FloatingDragMenu/DragMenu.tsx +1 -4
|
@@ -21,7 +21,6 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
|
21
21
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
22
22
|
import { akEditorSmallZIndex } from '@atlaskit/editor-shared-styles';
|
|
23
23
|
import ExpandIcon from '@atlaskit/icon/utility/migration/chevron-down';
|
|
24
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
25
24
|
|
|
26
25
|
import { toggleContextualMenu } from '../../commands';
|
|
27
26
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
@@ -77,12 +76,10 @@ const FloatingContextualButtonInner = React.memo((props: Props & WrappedComponen
|
|
|
77
76
|
targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
78
77
|
|
|
79
78
|
useEffect(() => {
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
toggleContextualMenu()(state, dispatch);
|
|
85
|
-
}
|
|
79
|
+
if (isCellMenuOpenByKeyboard && !isContextualMenuOpen) {
|
|
80
|
+
const { state, dispatch } = editorView;
|
|
81
|
+
// open the menu when the keyboard shortcut is pressed
|
|
82
|
+
toggleContextualMenu()(state, dispatch);
|
|
86
83
|
}
|
|
87
84
|
}, [isCellMenuOpenByKeyboard, isContextualMenuOpen, editorView]);
|
|
88
85
|
|
|
@@ -106,15 +103,11 @@ const FloatingContextualButtonInner = React.memo((props: Props & WrappedComponen
|
|
|
106
103
|
className={ClassName.CONTEXTUAL_MENU_BUTTON}
|
|
107
104
|
selected={isContextualMenuOpen}
|
|
108
105
|
title={labelCellOptions}
|
|
109
|
-
keymap={
|
|
110
|
-
fg('platform_editor_a11y_table_context_menu') ? focusToContextMenuTrigger : undefined
|
|
111
|
-
}
|
|
106
|
+
keymap={focusToContextMenuTrigger}
|
|
112
107
|
onClick={handleClick}
|
|
113
108
|
iconBefore={<ExpandIcon label="" color="currentColor" isFacadeDisabled={true} />}
|
|
114
109
|
aria-label={labelCellOptions}
|
|
115
|
-
aria-expanded={
|
|
116
|
-
fg('platform_editor_a11y_table_context_menu') ? isContextualMenuOpen : undefined
|
|
117
|
-
}
|
|
110
|
+
aria-expanded={isContextualMenuOpen}
|
|
118
111
|
/>
|
|
119
112
|
</div>
|
|
120
113
|
);
|
|
@@ -53,7 +53,6 @@ import TableColumnAddRightIcon from '@atlaskit/icon/core/table-column-add-right'
|
|
|
53
53
|
import TableColumnDeleteIcon from '@atlaskit/icon/core/table-column-delete';
|
|
54
54
|
import TableRowAddBelowIcon from '@atlaskit/icon/core/table-row-add-below';
|
|
55
55
|
import TableRowDeleteIcon from '@atlaskit/icon/core/table-row-delete';
|
|
56
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
57
56
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
58
57
|
|
|
59
58
|
import {
|
|
@@ -138,18 +137,16 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
138
137
|
private dropdownMenuRef = React.createRef<HTMLDivElement>();
|
|
139
138
|
|
|
140
139
|
componentDidMount() {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
152
|
-
}
|
|
140
|
+
// ArrowKeyNavigationProvider in DropdownMenu expects that menu handle will stay focused
|
|
141
|
+
// until user pressed ArrowDown.
|
|
142
|
+
// Behavior above fails the A11Y requirement about first item in menu should be focused immediately.
|
|
143
|
+
// so here is triggering componentDidUpdate inside dropdown to set focus on first element
|
|
144
|
+
const { isCellMenuOpenByKeyboard } = this.props;
|
|
145
|
+
if (isCellMenuOpenByKeyboard) {
|
|
146
|
+
this.setState({
|
|
147
|
+
...this.state,
|
|
148
|
+
isOpenAllowed: isCellMenuOpenByKeyboard,
|
|
149
|
+
});
|
|
153
150
|
}
|
|
154
151
|
}
|
|
155
152
|
|
|
@@ -162,11 +159,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
162
159
|
: this.createOriginalContextMenuItems();
|
|
163
160
|
let isOpenAllowed = false;
|
|
164
161
|
|
|
165
|
-
|
|
166
|
-
isOpenAllowed = isCellMenuOpenByKeyboard ? this.state.isOpenAllowed : isOpen;
|
|
167
|
-
} else {
|
|
168
|
-
isOpenAllowed = isOpen;
|
|
169
|
-
}
|
|
162
|
+
isOpenAllowed = isCellMenuOpenByKeyboard ? this.state.isOpenAllowed : isOpen;
|
|
170
163
|
|
|
171
164
|
return (
|
|
172
165
|
<div
|
|
@@ -180,12 +173,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
180
173
|
//Disabling key navigation now as it works only partially
|
|
181
174
|
arrowKeyNavigationProviderOptions={{
|
|
182
175
|
type: ArrowKeyNavigationType.MENU,
|
|
183
|
-
disableArrowKeyNavigation:
|
|
184
|
-
isCellMenuOpenByKeyboard &&
|
|
185
|
-
!this.state.isSubmenuOpen &&
|
|
186
|
-
fg('platform_editor_a11y_table_context_menu')
|
|
187
|
-
? false
|
|
188
|
-
: true,
|
|
176
|
+
disableArrowKeyNavigation: !isCellMenuOpenByKeyboard || this.state.isSubmenuOpen,
|
|
189
177
|
}}
|
|
190
178
|
items={items}
|
|
191
179
|
isOpen={isOpenAllowed}
|
|
@@ -197,19 +185,13 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
197
185
|
fitWidth={
|
|
198
186
|
isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth
|
|
199
187
|
}
|
|
200
|
-
shouldFocusFirstItem={
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return Boolean(isCellMenuOpenByKeyboard);
|
|
204
|
-
}
|
|
205
|
-
: undefined
|
|
206
|
-
}
|
|
188
|
+
shouldFocusFirstItem={() => {
|
|
189
|
+
return Boolean(isCellMenuOpenByKeyboard);
|
|
190
|
+
}}
|
|
207
191
|
boundariesElement={boundariesElement}
|
|
208
192
|
offset={offset}
|
|
209
193
|
section={isDragAndDropEnabled ? { hasSeparator: true } : undefined}
|
|
210
|
-
allowEnterDefaultBehavior={
|
|
211
|
-
fg('platform_editor_a11y_table_context_menu') ? this.state.isSubmenuOpen : false
|
|
212
|
-
}
|
|
194
|
+
allowEnterDefaultBehavior={this.state.isSubmenuOpen}
|
|
213
195
|
/>
|
|
214
196
|
</div>
|
|
215
197
|
);
|
|
@@ -248,15 +230,13 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
248
230
|
let selectedRowIndex;
|
|
249
231
|
let selectedColumnIndex;
|
|
250
232
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
259
|
-
}
|
|
233
|
+
const selectedRowAndColumnFromPalette = getSelectedRowAndColumnFromPalette(
|
|
234
|
+
cellBackgroundColorPalette,
|
|
235
|
+
background!,
|
|
236
|
+
colorPalletteColumns,
|
|
237
|
+
);
|
|
238
|
+
selectedRowIndex = selectedRowAndColumnFromPalette.selectedRowIndex;
|
|
239
|
+
selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
260
240
|
return {
|
|
261
241
|
content: isDragAndDropEnabled
|
|
262
242
|
? formatMessage(messages.backgroundColor)
|
|
@@ -285,62 +265,46 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
285
265
|
: ClassName.CONTEXTUAL_MENU_ICON
|
|
286
266
|
}
|
|
287
267
|
/>
|
|
288
|
-
{
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
)
|
|
326
|
-
: isSubmenuOpen && (
|
|
327
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
328
|
-
<div className={ClassName.CONTEXTUAL_SUBMENU} ref={this.handleSubMenuRef}>
|
|
329
|
-
<ColorPalette
|
|
330
|
-
cols={7}
|
|
331
|
-
onClick={this.setColor}
|
|
332
|
-
selectedColor={node?.attrs?.background || '#ffffff'}
|
|
333
|
-
paletteOptions={{
|
|
334
|
-
palette: cellBackgroundColorPalette,
|
|
335
|
-
paletteColorTooltipMessages: backgroundPaletteTooltipMessages,
|
|
336
|
-
hexToPaletteColor: hexToEditorBackgroundPaletteColor,
|
|
337
|
-
}}
|
|
338
|
-
/>
|
|
339
|
-
</div>
|
|
340
|
-
)}
|
|
268
|
+
{isSubmenuOpen && (
|
|
269
|
+
<div
|
|
270
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
271
|
+
className={ClassName.CONTEXTUAL_SUBMENU}
|
|
272
|
+
ref={this.handleSubMenuRef}
|
|
273
|
+
>
|
|
274
|
+
<ArrowKeyNavigationProvider
|
|
275
|
+
type={ArrowKeyNavigationType.COLOR}
|
|
276
|
+
selectedRowIndex={selectedRowIndex || 0}
|
|
277
|
+
selectedColumnIndex={selectedColumnIndex || 0}
|
|
278
|
+
handleClose={() => {
|
|
279
|
+
this.setState({ isSubmenuOpen: false });
|
|
280
|
+
if (this.dropdownMenuRef && this.dropdownMenuRef.current) {
|
|
281
|
+
const focusableItems = this.dropdownMenuRef.current.querySelectorAll(
|
|
282
|
+
'div[tabindex="-1"]:not([disabled])',
|
|
283
|
+
) as NodeListOf<HTMLElement>;
|
|
284
|
+
if (focusableItems && focusableItems.length) {
|
|
285
|
+
focusableItems[0].focus();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}}
|
|
289
|
+
isPopupPositioned={true}
|
|
290
|
+
isOpenedByKeyboard={isCellMenuOpenByKeyboard!}
|
|
291
|
+
>
|
|
292
|
+
<ColorPalette
|
|
293
|
+
cols={7}
|
|
294
|
+
onClick={this.setColor}
|
|
295
|
+
selectedColor={node?.attrs?.background || '#ffffff'}
|
|
296
|
+
paletteOptions={{
|
|
297
|
+
palette: cellBackgroundColorPalette,
|
|
298
|
+
paletteColorTooltipMessages: backgroundPaletteTooltipMessages,
|
|
299
|
+
hexToPaletteColor: hexToEditorBackgroundPaletteColor,
|
|
300
|
+
}}
|
|
301
|
+
/>
|
|
302
|
+
</ArrowKeyNavigationProvider>
|
|
303
|
+
</div>
|
|
304
|
+
)}
|
|
341
305
|
</div>
|
|
342
306
|
),
|
|
343
|
-
'aria-expanded':
|
|
307
|
+
'aria-expanded': isSubmenuOpen,
|
|
344
308
|
} as MenuItem;
|
|
345
309
|
}
|
|
346
310
|
};
|
|
@@ -700,8 +664,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
700
664
|
if (
|
|
701
665
|
isCellMenuOpenByKeyboard &&
|
|
702
666
|
(item.value.name !== 'background' ||
|
|
703
|
-
(item.value.name === 'background' && this.state.isSubmenuOpen))
|
|
704
|
-
fg('platform_editor_a11y_table_context_menu')
|
|
667
|
+
(item.value.name === 'background' && this.state.isSubmenuOpen))
|
|
705
668
|
) {
|
|
706
669
|
const { tr } = state;
|
|
707
670
|
tr.setMeta(tablePluginKey, {
|
|
@@ -821,11 +784,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
821
784
|
// 1st time when user chooses the background color item.
|
|
822
785
|
// 2nd when color has been chosen from color palette.
|
|
823
786
|
// here we are handling the 1st call relying on the isSubmenuOpen state value
|
|
824
|
-
if (
|
|
825
|
-
isCellMenuOpenByKeyboard &&
|
|
826
|
-
!this.state.isSubmenuOpen &&
|
|
827
|
-
fg('platform_editor_a11y_table_context_menu')
|
|
828
|
-
) {
|
|
787
|
+
if (isCellMenuOpenByKeyboard && !this.state.isSubmenuOpen) {
|
|
829
788
|
this.setState({ isSubmenuOpen: true });
|
|
830
789
|
}
|
|
831
790
|
break;
|
|
@@ -855,34 +814,29 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
855
814
|
isCellMenuOpenByKeyboard,
|
|
856
815
|
} = this.props;
|
|
857
816
|
|
|
858
|
-
if (
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
if (
|
|
862
|
-
if (
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
event.preventDefault();
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
toggleContextualMenu()(state, dispatch);
|
|
870
|
-
this.setState({ isSubmenuOpen: false });
|
|
871
|
-
setFocusToCellMenu(false)(state, dispatch);
|
|
872
|
-
dom.focus();
|
|
817
|
+
if (payload) {
|
|
818
|
+
const { event } = payload;
|
|
819
|
+
if (event && event instanceof KeyboardEvent) {
|
|
820
|
+
if (!this.state.isSubmenuOpen) {
|
|
821
|
+
if (arrowsList.has(event.key)) {
|
|
822
|
+
// preventing default behavior for avoiding cursor jump to next/previous table column
|
|
823
|
+
// when left/right arrow pressed.
|
|
824
|
+
event.preventDefault();
|
|
873
825
|
}
|
|
874
|
-
|
|
875
|
-
// mouse click outside
|
|
826
|
+
|
|
876
827
|
toggleContextualMenu()(state, dispatch);
|
|
877
828
|
this.setState({ isSubmenuOpen: false });
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
829
|
+
setFocusToCellMenu(false)(state, dispatch);
|
|
830
|
+
dom.focus();
|
|
831
|
+
}
|
|
832
|
+
} else {
|
|
833
|
+
// mouse click outside
|
|
834
|
+
toggleContextualMenu()(state, dispatch);
|
|
835
|
+
this.setState({ isSubmenuOpen: false });
|
|
836
|
+
if (isCellMenuOpenByKeyboard) {
|
|
837
|
+
setFocusToCellMenu(false)(state, dispatch);
|
|
881
838
|
}
|
|
882
839
|
}
|
|
883
|
-
} else {
|
|
884
|
-
toggleContextualMenu()(state, dispatch);
|
|
885
|
-
this.setState({ isSubmenuOpen: false });
|
|
886
840
|
}
|
|
887
841
|
};
|
|
888
842
|
|
|
@@ -16,7 +16,6 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
16
16
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
17
17
|
import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
18
18
|
import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
19
|
-
import { withOuterListeners } from '@atlaskit/editor-common/ui';
|
|
20
19
|
import {
|
|
21
20
|
backgroundPaletteTooltipMessages,
|
|
22
21
|
cellBackgroundColorPalette,
|
|
@@ -264,8 +263,6 @@ const convertToDropdownItems = (
|
|
|
264
263
|
return { menuItems, menuCallback };
|
|
265
264
|
};
|
|
266
265
|
|
|
267
|
-
const ColorPaletteWithListeners = withOuterListeners(ColorPalette);
|
|
268
|
-
|
|
269
266
|
const DragMenu = React.memo(
|
|
270
267
|
({
|
|
271
268
|
direction = 'row',
|
|
@@ -413,7 +410,7 @@ const DragMenu = React.memo(
|
|
|
413
410
|
isPopupPositioned={true}
|
|
414
411
|
isOpenedByKeyboard={isKeyboardModeActive}
|
|
415
412
|
>
|
|
416
|
-
<
|
|
413
|
+
<ColorPalette
|
|
417
414
|
cols={colorPalletteColumns}
|
|
418
415
|
onClick={(color) => {
|
|
419
416
|
setColor(color);
|