@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
|
@@ -30,7 +30,6 @@ import TableColumnAddRightIcon from '@atlaskit/icon/core/table-column-add-right'
|
|
|
30
30
|
import TableColumnDeleteIcon from '@atlaskit/icon/core/table-column-delete';
|
|
31
31
|
import TableRowAddBelowIcon from '@atlaskit/icon/core/table-row-add-below';
|
|
32
32
|
import TableRowDeleteIcon from '@atlaskit/icon/core/table-row-delete';
|
|
33
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
34
33
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
35
34
|
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, setFocusToCellMenu, toggleContextualMenu } from '../../commands';
|
|
36
35
|
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics } from '../../commands-with-analytics';
|
|
@@ -89,16 +88,14 @@ export class ContextualMenu extends Component {
|
|
|
89
88
|
isDragAndDropEnabled
|
|
90
89
|
} = getPluginState(editorView.state);
|
|
91
90
|
if (allowBackgroundColor) {
|
|
92
|
-
var _node$attrs, _node$attrs2
|
|
91
|
+
var _node$attrs, _node$attrs2;
|
|
93
92
|
const node = isOpen && targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
94
93
|
const background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
95
94
|
let selectedRowIndex;
|
|
96
95
|
let selectedColumnIndex;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
101
|
-
}
|
|
96
|
+
const selectedRowAndColumnFromPalette = getSelectedRowAndColumnFromPalette(cellBackgroundColorPalette, background, colorPalletteColumns);
|
|
97
|
+
selectedRowIndex = selectedRowAndColumnFromPalette.selectedRowIndex;
|
|
98
|
+
selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
102
99
|
return {
|
|
103
100
|
content: isDragAndDropEnabled ? formatMessage(messages.backgroundColor) : formatMessage(messages.cellBackground),
|
|
104
101
|
value: {
|
|
@@ -122,7 +119,7 @@ export class ContextualMenu extends Component {
|
|
|
122
119
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
123
120
|
,
|
|
124
121
|
className: isDragAndDropEnabled ? ClassName.CONTEXTUAL_MENU_ICON_SMALL : ClassName.CONTEXTUAL_MENU_ICON
|
|
125
|
-
}),
|
|
122
|
+
}), isSubmenuOpen && jsx("div", {
|
|
126
123
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
127
124
|
className: ClassName.CONTEXTUAL_SUBMENU,
|
|
128
125
|
ref: this.handleSubMenuRef
|
|
@@ -152,22 +149,8 @@ export class ContextualMenu extends Component {
|
|
|
152
149
|
paletteColorTooltipMessages: backgroundPaletteTooltipMessages,
|
|
153
150
|
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
154
151
|
}
|
|
155
|
-
})))
|
|
156
|
-
|
|
157
|
-
jsx("div", {
|
|
158
|
-
className: ClassName.CONTEXTUAL_SUBMENU,
|
|
159
|
-
ref: this.handleSubMenuRef
|
|
160
|
-
}, jsx(ColorPalette, {
|
|
161
|
-
cols: 7,
|
|
162
|
-
onClick: this.setColor,
|
|
163
|
-
selectedColor: (node === null || node === void 0 ? void 0 : (_node$attrs3 = node.attrs) === null || _node$attrs3 === void 0 ? void 0 : _node$attrs3.background) || '#ffffff',
|
|
164
|
-
paletteOptions: {
|
|
165
|
-
palette: cellBackgroundColorPalette,
|
|
166
|
-
paletteColorTooltipMessages: backgroundPaletteTooltipMessages,
|
|
167
|
-
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
168
|
-
}
|
|
169
|
-
}))),
|
|
170
|
-
'aria-expanded': fg('platform_editor_a11y_table_context_menu') ? isSubmenuOpen : undefined
|
|
152
|
+
})))),
|
|
153
|
+
'aria-expanded': isSubmenuOpen
|
|
171
154
|
};
|
|
172
155
|
}
|
|
173
156
|
});
|
|
@@ -541,7 +524,7 @@ export class ContextualMenu extends Component {
|
|
|
541
524
|
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
542
525
|
// context menu opened by keyboard and any item except 'background' activated
|
|
543
526
|
// or color has been chosen from color palette
|
|
544
|
-
if (isCellMenuOpenByKeyboard && (item.value.name !== 'background' || item.value.name === 'background' && this.state.isSubmenuOpen)
|
|
527
|
+
if (isCellMenuOpenByKeyboard && (item.value.name !== 'background' || item.value.name === 'background' && this.state.isSubmenuOpen)) {
|
|
545
528
|
const {
|
|
546
529
|
tr
|
|
547
530
|
} = state;
|
|
@@ -615,7 +598,7 @@ export class ContextualMenu extends Component {
|
|
|
615
598
|
// 1st time when user chooses the background color item.
|
|
616
599
|
// 2nd when color has been chosen from color palette.
|
|
617
600
|
// here we are handling the 1st call relying on the isSubmenuOpen state value
|
|
618
|
-
if (isCellMenuOpenByKeyboard && !this.state.isSubmenuOpen
|
|
601
|
+
if (isCellMenuOpenByKeyboard && !this.state.isSubmenuOpen) {
|
|
619
602
|
this.setState({
|
|
620
603
|
isSubmenuOpen: true
|
|
621
604
|
});
|
|
@@ -648,41 +631,34 @@ export class ContextualMenu extends Component {
|
|
|
648
631
|
},
|
|
649
632
|
isCellMenuOpenByKeyboard
|
|
650
633
|
} = this.props;
|
|
651
|
-
if (
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
if (
|
|
657
|
-
if (
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
event.preventDefault();
|
|
662
|
-
}
|
|
663
|
-
toggleContextualMenu()(state, dispatch);
|
|
664
|
-
this.setState({
|
|
665
|
-
isSubmenuOpen: false
|
|
666
|
-
});
|
|
667
|
-
setFocusToCellMenu(false)(state, dispatch);
|
|
668
|
-
dom.focus();
|
|
634
|
+
if (payload) {
|
|
635
|
+
const {
|
|
636
|
+
event
|
|
637
|
+
} = payload;
|
|
638
|
+
if (event && event instanceof KeyboardEvent) {
|
|
639
|
+
if (!this.state.isSubmenuOpen) {
|
|
640
|
+
if (arrowsList.has(event.key)) {
|
|
641
|
+
// preventing default behavior for avoiding cursor jump to next/previous table column
|
|
642
|
+
// when left/right arrow pressed.
|
|
643
|
+
event.preventDefault();
|
|
669
644
|
}
|
|
670
|
-
} else {
|
|
671
|
-
// mouse click outside
|
|
672
645
|
toggleContextualMenu()(state, dispatch);
|
|
673
646
|
this.setState({
|
|
674
647
|
isSubmenuOpen: false
|
|
675
648
|
});
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
649
|
+
setFocusToCellMenu(false)(state, dispatch);
|
|
650
|
+
dom.focus();
|
|
651
|
+
}
|
|
652
|
+
} else {
|
|
653
|
+
// mouse click outside
|
|
654
|
+
toggleContextualMenu()(state, dispatch);
|
|
655
|
+
this.setState({
|
|
656
|
+
isSubmenuOpen: false
|
|
657
|
+
});
|
|
658
|
+
if (isCellMenuOpenByKeyboard) {
|
|
659
|
+
setFocusToCellMenu(false)(state, dispatch);
|
|
679
660
|
}
|
|
680
661
|
}
|
|
681
|
-
} else {
|
|
682
|
-
toggleContextualMenu()(state, dispatch);
|
|
683
|
-
this.setState({
|
|
684
|
-
isSubmenuOpen: false
|
|
685
|
-
});
|
|
686
662
|
}
|
|
687
663
|
});
|
|
688
664
|
_defineProperty(this, "handleItemMouseEnter", ({
|
|
@@ -747,20 +723,18 @@ export class ContextualMenu extends Component {
|
|
|
747
723
|
});
|
|
748
724
|
}
|
|
749
725
|
componentDidMount() {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
this.
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
});
|
|
763
|
-
}
|
|
726
|
+
// ArrowKeyNavigationProvider in DropdownMenu expects that menu handle will stay focused
|
|
727
|
+
// until user pressed ArrowDown.
|
|
728
|
+
// Behavior above fails the A11Y requirement about first item in menu should be focused immediately.
|
|
729
|
+
// so here is triggering componentDidUpdate inside dropdown to set focus on first element
|
|
730
|
+
const {
|
|
731
|
+
isCellMenuOpenByKeyboard
|
|
732
|
+
} = this.props;
|
|
733
|
+
if (isCellMenuOpenByKeyboard) {
|
|
734
|
+
this.setState({
|
|
735
|
+
...this.state,
|
|
736
|
+
isOpenAllowed: isCellMenuOpenByKeyboard
|
|
737
|
+
});
|
|
764
738
|
}
|
|
765
739
|
}
|
|
766
740
|
render() {
|
|
@@ -777,11 +751,7 @@ export class ContextualMenu extends Component {
|
|
|
777
751
|
} = getPluginState(editorView.state);
|
|
778
752
|
const items = isDragAndDropEnabled ? this.createNewContextMenuItems() : this.createOriginalContextMenuItems();
|
|
779
753
|
let isOpenAllowed = false;
|
|
780
|
-
|
|
781
|
-
isOpenAllowed = isCellMenuOpenByKeyboard ? this.state.isOpenAllowed : isOpen;
|
|
782
|
-
} else {
|
|
783
|
-
isOpenAllowed = isOpen;
|
|
784
|
-
}
|
|
754
|
+
isOpenAllowed = isCellMenuOpenByKeyboard ? this.state.isOpenAllowed : isOpen;
|
|
785
755
|
return jsx("div", {
|
|
786
756
|
"data-testid": "table-cell-contextual-menu",
|
|
787
757
|
onMouseLeave: this.closeSubmenu,
|
|
@@ -793,7 +763,7 @@ export class ContextualMenu extends Component {
|
|
|
793
763
|
,
|
|
794
764
|
arrowKeyNavigationProviderOptions: {
|
|
795
765
|
type: ArrowKeyNavigationType.MENU,
|
|
796
|
-
disableArrowKeyNavigation: isCellMenuOpenByKeyboard
|
|
766
|
+
disableArrowKeyNavigation: !isCellMenuOpenByKeyboard || this.state.isSubmenuOpen
|
|
797
767
|
},
|
|
798
768
|
items: items,
|
|
799
769
|
isOpen: isOpenAllowed,
|
|
@@ -803,15 +773,15 @@ export class ContextualMenu extends Component {
|
|
|
803
773
|
onMouseLeave: this.handleItemMouseLeave,
|
|
804
774
|
fitHeight: 188,
|
|
805
775
|
fitWidth: isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth,
|
|
806
|
-
shouldFocusFirstItem:
|
|
776
|
+
shouldFocusFirstItem: () => {
|
|
807
777
|
return Boolean(isCellMenuOpenByKeyboard);
|
|
808
|
-
}
|
|
778
|
+
},
|
|
809
779
|
boundariesElement: boundariesElement,
|
|
810
780
|
offset: offset,
|
|
811
781
|
section: isDragAndDropEnabled ? {
|
|
812
782
|
hasSeparator: true
|
|
813
783
|
} : undefined,
|
|
814
|
-
allowEnterDefaultBehavior:
|
|
784
|
+
allowEnterDefaultBehavior: this.state.isSubmenuOpen
|
|
815
785
|
}));
|
|
816
786
|
}
|
|
817
787
|
}
|
|
@@ -12,7 +12,6 @@ import { injectIntl } from 'react-intl-next';
|
|
|
12
12
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
13
13
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
14
14
|
import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
15
|
-
import { withOuterListeners } from '@atlaskit/editor-common/ui';
|
|
16
15
|
import { backgroundPaletteTooltipMessages, cellBackgroundColorPalette, ColorPalette, getSelectedRowAndColumnFromPalette } from '@atlaskit/editor-common/ui-color';
|
|
17
16
|
import { ArrowKeyNavigationProvider, ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu';
|
|
18
17
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
@@ -176,7 +175,6 @@ const convertToDropdownItems = (dragMenuConfig, formatMessage, tableSortColumnRe
|
|
|
176
175
|
menuCallback
|
|
177
176
|
};
|
|
178
177
|
};
|
|
179
|
-
const ColorPaletteWithListeners = withOuterListeners(ColorPalette);
|
|
180
178
|
const DragMenu = /*#__PURE__*/React.memo(({
|
|
181
179
|
direction = 'row',
|
|
182
180
|
index,
|
|
@@ -303,7 +301,7 @@ const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
303
301
|
},
|
|
304
302
|
isPopupPositioned: true,
|
|
305
303
|
isOpenedByKeyboard: isKeyboardModeActive
|
|
306
|
-
}, jsx(
|
|
304
|
+
}, jsx(ColorPalette, {
|
|
307
305
|
cols: colorPalletteColumns,
|
|
308
306
|
onClick: color => {
|
|
309
307
|
setColor(color);
|
package/dist/esm/plugin.js
CHANGED
|
@@ -13,7 +13,6 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
13
13
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
14
14
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
15
15
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
16
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
16
|
import { insertTableWithSize } from './commands/insert';
|
|
18
17
|
import { pluginConfig } from './create-plugin-config';
|
|
19
18
|
import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analytics/plugin';
|
|
@@ -386,7 +385,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
386
385
|
isCellMenuOpenByKeyboard = _ref20.isCellMenuOpenByKeyboard;
|
|
387
386
|
var allowControls = pluginConfig.allowControls;
|
|
388
387
|
var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
389
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard
|
|
388
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
390
389
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
391
390
|
editorView: editorView,
|
|
392
391
|
tableNode: tableNode,
|
|
@@ -2,7 +2,6 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import { addColumnAfter, addColumnAfterVO, addColumnBefore, addColumnBeforeVO, addRowAfter, addRowAfterVO, addRowBefore, addRowBeforeVO, backspace, bindKeymapWithCommand, decreaseMediaSize, deleteColumn, deleteRow, escape, focusToContextMenuTrigger, increaseMediaSize, moveColumnLeft, moveColumnRight, moveLeft, moveRight, moveRowDown, moveRowUp, nextCell, previousCell, startColumnResizing, toggleTable } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
4
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { goToNextCell, moveCursorBackward, setFocusToCellMenu } from '../commands';
|
|
7
6
|
import { addRowAroundSelection, changeColumnWidthByStepWithAnalytics, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut, deleteTableIfSelectedWithAnalytics, emptyMultipleCellsWithAnalytics } from '../commands-with-analytics';
|
|
8
7
|
import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
@@ -76,9 +75,7 @@ export function keymapPlugin(getEditorContainerWidth, api, editorAnalyticsAPI, d
|
|
|
76
75
|
ariaNotify: ariaNotifyPlugin,
|
|
77
76
|
getIntl: getIntl
|
|
78
77
|
}), list);
|
|
79
|
-
|
|
80
|
-
bindKeymapWithCommand(focusToContextMenuTrigger.common, setFocusToCellMenu(), list);
|
|
81
|
-
}
|
|
78
|
+
bindKeymapWithCommand(focusToContextMenuTrigger.common, setFocusToCellMenu(), list);
|
|
82
79
|
return keymap(list);
|
|
83
80
|
}
|
|
84
81
|
export default keymapPlugin;
|
|
@@ -16,7 +16,6 @@ import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
|
16
16
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
17
17
|
import { akEditorSmallZIndex } from '@atlaskit/editor-shared-styles';
|
|
18
18
|
import ExpandIcon from '@atlaskit/icon/utility/migration/chevron-down';
|
|
19
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
19
|
import { toggleContextualMenu } from '../../commands';
|
|
21
20
|
import { TableCssClassName as ClassName } from '../../types';
|
|
22
21
|
import FixedButton from './FixedButton';
|
|
@@ -49,13 +48,11 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
49
48
|
var targetCellRef;
|
|
50
49
|
targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
51
50
|
useEffect(function () {
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
toggleContextualMenu()(state, dispatch);
|
|
58
|
-
}
|
|
51
|
+
if (isCellMenuOpenByKeyboard && !isContextualMenuOpen) {
|
|
52
|
+
var state = editorView.state,
|
|
53
|
+
dispatch = editorView.dispatch;
|
|
54
|
+
// open the menu when the keyboard shortcut is pressed
|
|
55
|
+
toggleContextualMenu()(state, dispatch);
|
|
59
56
|
}
|
|
60
57
|
}, [isCellMenuOpenByKeyboard, isContextualMenuOpen, editorView]);
|
|
61
58
|
if (!targetCellRef || !(targetCellRef instanceof HTMLElement)) {
|
|
@@ -74,7 +71,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
74
71
|
className: ClassName.CONTEXTUAL_MENU_BUTTON,
|
|
75
72
|
selected: isContextualMenuOpen,
|
|
76
73
|
title: labelCellOptions,
|
|
77
|
-
keymap:
|
|
74
|
+
keymap: focusToContextMenuTrigger,
|
|
78
75
|
onClick: handleClick,
|
|
79
76
|
iconBefore: jsx(ExpandIcon, {
|
|
80
77
|
label: "",
|
|
@@ -82,7 +79,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
82
79
|
isFacadeDisabled: true
|
|
83
80
|
}),
|
|
84
81
|
"aria-label": labelCellOptions,
|
|
85
|
-
"aria-expanded":
|
|
82
|
+
"aria-expanded": isContextualMenuOpen
|
|
86
83
|
}));
|
|
87
84
|
var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
88
85
|
if (stickyHeader && parentSticky && tableWrapper) {
|
|
@@ -41,7 +41,6 @@ import TableColumnAddRightIcon from '@atlaskit/icon/core/table-column-add-right'
|
|
|
41
41
|
import TableColumnDeleteIcon from '@atlaskit/icon/core/table-column-delete';
|
|
42
42
|
import TableRowAddBelowIcon from '@atlaskit/icon/core/table-row-add-below';
|
|
43
43
|
import TableRowDeleteIcon from '@atlaskit/icon/core/table-row-delete';
|
|
44
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
45
44
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
46
45
|
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, setFocusToCellMenu, toggleContextualMenu } from '../../commands';
|
|
47
46
|
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics } from '../../commands-with-analytics';
|
|
@@ -99,16 +98,14 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
99
98
|
targetCellPosition = _getPluginState.targetCellPosition,
|
|
100
99
|
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
101
100
|
if (allowBackgroundColor) {
|
|
102
|
-
var _node$attrs, _node$attrs2
|
|
101
|
+
var _node$attrs, _node$attrs2;
|
|
103
102
|
var node = isOpen && targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
104
103
|
var background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
105
104
|
var selectedRowIndex;
|
|
106
105
|
var selectedColumnIndex;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
111
|
-
}
|
|
106
|
+
var selectedRowAndColumnFromPalette = getSelectedRowAndColumnFromPalette(cellBackgroundColorPalette, background, colorPalletteColumns);
|
|
107
|
+
selectedRowIndex = selectedRowAndColumnFromPalette.selectedRowIndex;
|
|
108
|
+
selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
112
109
|
return {
|
|
113
110
|
content: isDragAndDropEnabled ? formatMessage(messages.backgroundColor) : formatMessage(messages.cellBackground),
|
|
114
111
|
value: {
|
|
@@ -132,7 +129,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
132
129
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
133
130
|
,
|
|
134
131
|
className: isDragAndDropEnabled ? ClassName.CONTEXTUAL_MENU_ICON_SMALL : ClassName.CONTEXTUAL_MENU_ICON
|
|
135
|
-
}),
|
|
132
|
+
}), isSubmenuOpen && jsx("div", {
|
|
136
133
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
137
134
|
className: ClassName.CONTEXTUAL_SUBMENU,
|
|
138
135
|
ref: _this.handleSubMenuRef
|
|
@@ -162,22 +159,8 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
162
159
|
paletteColorTooltipMessages: backgroundPaletteTooltipMessages,
|
|
163
160
|
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
164
161
|
}
|
|
165
|
-
})))
|
|
166
|
-
|
|
167
|
-
jsx("div", {
|
|
168
|
-
className: ClassName.CONTEXTUAL_SUBMENU,
|
|
169
|
-
ref: _this.handleSubMenuRef
|
|
170
|
-
}, jsx(ColorPalette, {
|
|
171
|
-
cols: 7,
|
|
172
|
-
onClick: _this.setColor,
|
|
173
|
-
selectedColor: (node === null || node === void 0 || (_node$attrs3 = node.attrs) === null || _node$attrs3 === void 0 ? void 0 : _node$attrs3.background) || '#ffffff',
|
|
174
|
-
paletteOptions: {
|
|
175
|
-
palette: cellBackgroundColorPalette,
|
|
176
|
-
paletteColorTooltipMessages: backgroundPaletteTooltipMessages,
|
|
177
|
-
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
178
|
-
}
|
|
179
|
-
}))),
|
|
180
|
-
'aria-expanded': fg('platform_editor_a11y_table_context_menu') ? isSubmenuOpen : undefined
|
|
162
|
+
})))),
|
|
163
|
+
'aria-expanded': isSubmenuOpen
|
|
181
164
|
};
|
|
182
165
|
}
|
|
183
166
|
});
|
|
@@ -503,7 +486,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
503
486
|
tableWithFixedColumnWidthsOption = _ref4$tableWithFixedC === void 0 ? false : _ref4$tableWithFixedC;
|
|
504
487
|
// context menu opened by keyboard and any item except 'background' activated
|
|
505
488
|
// or color has been chosen from color palette
|
|
506
|
-
if (isCellMenuOpenByKeyboard && (item.value.name !== 'background' || item.value.name === 'background' && _this.state.isSubmenuOpen)
|
|
489
|
+
if (isCellMenuOpenByKeyboard && (item.value.name !== 'background' || item.value.name === 'background' && _this.state.isSubmenuOpen)) {
|
|
507
490
|
var tr = state.tr;
|
|
508
491
|
tr.setMeta(tablePluginKey, {
|
|
509
492
|
type: 'SET_CELL_MENU_OPEN',
|
|
@@ -572,7 +555,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
572
555
|
// 1st time when user chooses the background color item.
|
|
573
556
|
// 2nd when color has been chosen from color palette.
|
|
574
557
|
// here we are handling the 1st call relying on the isSubmenuOpen state value
|
|
575
|
-
if (isCellMenuOpenByKeyboard && !_this.state.isSubmenuOpen
|
|
558
|
+
if (isCellMenuOpenByKeyboard && !_this.state.isSubmenuOpen) {
|
|
576
559
|
_this.setState({
|
|
577
560
|
isSubmenuOpen: true
|
|
578
561
|
});
|
|
@@ -601,39 +584,32 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
601
584
|
dispatch = _this$props12$editorV.dispatch,
|
|
602
585
|
dom = _this$props12$editorV.dom,
|
|
603
586
|
isCellMenuOpenByKeyboard = _this$props12.isCellMenuOpenByKeyboard;
|
|
604
|
-
if (
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
if (
|
|
608
|
-
if (
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
event.preventDefault();
|
|
613
|
-
}
|
|
614
|
-
toggleContextualMenu()(state, dispatch);
|
|
615
|
-
_this.setState({
|
|
616
|
-
isSubmenuOpen: false
|
|
617
|
-
});
|
|
618
|
-
setFocusToCellMenu(false)(state, dispatch);
|
|
619
|
-
dom.focus();
|
|
587
|
+
if (payload) {
|
|
588
|
+
var event = payload.event;
|
|
589
|
+
if (event && event instanceof KeyboardEvent) {
|
|
590
|
+
if (!_this.state.isSubmenuOpen) {
|
|
591
|
+
if (arrowsList.has(event.key)) {
|
|
592
|
+
// preventing default behavior for avoiding cursor jump to next/previous table column
|
|
593
|
+
// when left/right arrow pressed.
|
|
594
|
+
event.preventDefault();
|
|
620
595
|
}
|
|
621
|
-
} else {
|
|
622
|
-
// mouse click outside
|
|
623
596
|
toggleContextualMenu()(state, dispatch);
|
|
624
597
|
_this.setState({
|
|
625
598
|
isSubmenuOpen: false
|
|
626
599
|
});
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
600
|
+
setFocusToCellMenu(false)(state, dispatch);
|
|
601
|
+
dom.focus();
|
|
602
|
+
}
|
|
603
|
+
} else {
|
|
604
|
+
// mouse click outside
|
|
605
|
+
toggleContextualMenu()(state, dispatch);
|
|
606
|
+
_this.setState({
|
|
607
|
+
isSubmenuOpen: false
|
|
608
|
+
});
|
|
609
|
+
if (isCellMenuOpenByKeyboard) {
|
|
610
|
+
setFocusToCellMenu(false)(state, dispatch);
|
|
630
611
|
}
|
|
631
612
|
}
|
|
632
|
-
} else {
|
|
633
|
-
toggleContextualMenu()(state, dispatch);
|
|
634
|
-
_this.setState({
|
|
635
|
-
isSubmenuOpen: false
|
|
636
|
-
});
|
|
637
613
|
}
|
|
638
614
|
});
|
|
639
615
|
_defineProperty(_assertThisInitialized(_this), "handleItemMouseEnter", function (_ref5) {
|
|
@@ -693,17 +669,15 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
693
669
|
_createClass(ContextualMenu, [{
|
|
694
670
|
key: "componentDidMount",
|
|
695
671
|
value: function componentDidMount() {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
}));
|
|
706
|
-
}
|
|
672
|
+
// ArrowKeyNavigationProvider in DropdownMenu expects that menu handle will stay focused
|
|
673
|
+
// until user pressed ArrowDown.
|
|
674
|
+
// Behavior above fails the A11Y requirement about first item in menu should be focused immediately.
|
|
675
|
+
// so here is triggering componentDidUpdate inside dropdown to set focus on first element
|
|
676
|
+
var isCellMenuOpenByKeyboard = this.props.isCellMenuOpenByKeyboard;
|
|
677
|
+
if (isCellMenuOpenByKeyboard) {
|
|
678
|
+
this.setState(_objectSpread(_objectSpread({}, this.state), {}, {
|
|
679
|
+
isOpenAllowed: isCellMenuOpenByKeyboard
|
|
680
|
+
}));
|
|
707
681
|
}
|
|
708
682
|
}
|
|
709
683
|
}, {
|
|
@@ -720,11 +694,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
720
694
|
isDragAndDropEnabled = _getPluginState13.isDragAndDropEnabled;
|
|
721
695
|
var items = isDragAndDropEnabled ? this.createNewContextMenuItems() : this.createOriginalContextMenuItems();
|
|
722
696
|
var isOpenAllowed = false;
|
|
723
|
-
|
|
724
|
-
isOpenAllowed = isCellMenuOpenByKeyboard ? this.state.isOpenAllowed : isOpen;
|
|
725
|
-
} else {
|
|
726
|
-
isOpenAllowed = isOpen;
|
|
727
|
-
}
|
|
697
|
+
isOpenAllowed = isCellMenuOpenByKeyboard ? this.state.isOpenAllowed : isOpen;
|
|
728
698
|
return jsx("div", {
|
|
729
699
|
"data-testid": "table-cell-contextual-menu",
|
|
730
700
|
onMouseLeave: this.closeSubmenu,
|
|
@@ -736,7 +706,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
736
706
|
,
|
|
737
707
|
arrowKeyNavigationProviderOptions: {
|
|
738
708
|
type: ArrowKeyNavigationType.MENU,
|
|
739
|
-
disableArrowKeyNavigation: isCellMenuOpenByKeyboard
|
|
709
|
+
disableArrowKeyNavigation: !isCellMenuOpenByKeyboard || this.state.isSubmenuOpen
|
|
740
710
|
},
|
|
741
711
|
items: items,
|
|
742
712
|
isOpen: isOpenAllowed,
|
|
@@ -746,15 +716,15 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
746
716
|
onMouseLeave: this.handleItemMouseLeave,
|
|
747
717
|
fitHeight: 188,
|
|
748
718
|
fitWidth: isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth,
|
|
749
|
-
shouldFocusFirstItem:
|
|
719
|
+
shouldFocusFirstItem: function shouldFocusFirstItem() {
|
|
750
720
|
return Boolean(isCellMenuOpenByKeyboard);
|
|
751
|
-
}
|
|
721
|
+
},
|
|
752
722
|
boundariesElement: boundariesElement,
|
|
753
723
|
offset: offset,
|
|
754
724
|
section: isDragAndDropEnabled ? {
|
|
755
725
|
hasSeparator: true
|
|
756
726
|
} : undefined,
|
|
757
|
-
allowEnterDefaultBehavior:
|
|
727
|
+
allowEnterDefaultBehavior: this.state.isSubmenuOpen
|
|
758
728
|
}));
|
|
759
729
|
}
|
|
760
730
|
}]);
|
|
@@ -14,7 +14,6 @@ import { injectIntl } from 'react-intl-next';
|
|
|
14
14
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
15
15
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
16
16
|
import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
17
|
-
import { withOuterListeners } from '@atlaskit/editor-common/ui';
|
|
18
17
|
import { backgroundPaletteTooltipMessages, cellBackgroundColorPalette, ColorPalette, getSelectedRowAndColumnFromPalette } from '@atlaskit/editor-common/ui-color';
|
|
19
18
|
import { ArrowKeyNavigationProvider, ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu';
|
|
20
19
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
@@ -182,7 +181,6 @@ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig, for
|
|
|
182
181
|
menuCallback: menuCallback
|
|
183
182
|
};
|
|
184
183
|
};
|
|
185
|
-
var ColorPaletteWithListeners = withOuterListeners(ColorPalette);
|
|
186
184
|
var DragMenu = /*#__PURE__*/React.memo(function (_ref) {
|
|
187
185
|
var _tableMap$hasMergedCe, _pluginConfig$allowBa;
|
|
188
186
|
var _ref$direction = _ref.direction,
|
|
@@ -300,7 +298,7 @@ var DragMenu = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
300
298
|
},
|
|
301
299
|
isPopupPositioned: true,
|
|
302
300
|
isOpenedByKeyboard: isKeyboardModeActive
|
|
303
|
-
}, jsx(
|
|
301
|
+
}, jsx(ColorPalette, {
|
|
304
302
|
cols: colorPalletteColumns,
|
|
305
303
|
onClick: function onClick(color) {
|
|
306
304
|
setColor(color);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.29.
|
|
3
|
+
"version": "7.29.8",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@atlaskit/adf-schema": "^42.3.1",
|
|
31
31
|
"@atlaskit/button": "^20.3.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.8.0",
|
|
33
|
-
"@atlaskit/editor-common": "^94.
|
|
33
|
+
"@atlaskit/editor-common": "^94.8.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.6.3",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
@@ -109,9 +109,6 @@
|
|
|
109
109
|
"platform_editor_dark_mode_cell_header_color_fix": {
|
|
110
110
|
"type": "boolean"
|
|
111
111
|
},
|
|
112
|
-
"platform_editor_a11y_table_context_menu": {
|
|
113
|
-
"type": "boolean"
|
|
114
|
-
},
|
|
115
112
|
"platform_editor_breakout_use_css": {
|
|
116
113
|
"type": "boolean"
|
|
117
114
|
},
|
package/src/plugin.tsx
CHANGED
|
@@ -39,7 +39,6 @@ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
|
39
39
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
40
40
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
41
41
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
42
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
43
42
|
|
|
44
43
|
import { insertTableWithSize } from './commands/insert';
|
|
45
44
|
import { pluginConfig } from './create-plugin-config';
|
|
@@ -576,9 +575,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
576
575
|
return (
|
|
577
576
|
<>
|
|
578
577
|
{targetCellPosition &&
|
|
579
|
-
(tableRef ||
|
|
580
|
-
(isCellMenuOpenByKeyboard &&
|
|
581
|
-
fg('platform_editor_a11y_table_context_menu'))) &&
|
|
578
|
+
(tableRef || isCellMenuOpenByKeyboard) &&
|
|
582
579
|
!isResizing &&
|
|
583
580
|
options &&
|
|
584
581
|
options.allowContextualMenu && (
|
package/src/pm-plugins/keymap.ts
CHANGED
|
@@ -34,7 +34,6 @@ import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
34
34
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
35
35
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
36
36
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
37
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
38
37
|
|
|
39
38
|
import { goToNextCell, moveCursorBackward, setFocusToCellMenu } from '../commands';
|
|
40
39
|
import {
|
|
@@ -317,6 +316,7 @@ export function keymapPlugin(
|
|
|
317
316
|
),
|
|
318
317
|
list,
|
|
319
318
|
);
|
|
319
|
+
|
|
320
320
|
bindKeymapWithCommand(
|
|
321
321
|
escape.common!,
|
|
322
322
|
stopKeyboardColumnResizing({
|
|
@@ -326,9 +326,7 @@ export function keymapPlugin(
|
|
|
326
326
|
list,
|
|
327
327
|
);
|
|
328
328
|
|
|
329
|
-
|
|
330
|
-
bindKeymapWithCommand(focusToContextMenuTrigger.common!, setFocusToCellMenu(), list);
|
|
331
|
-
}
|
|
329
|
+
bindKeymapWithCommand(focusToContextMenuTrigger.common!, setFocusToCellMenu(), list);
|
|
332
330
|
|
|
333
331
|
return keymap(list) as SafePlugin;
|
|
334
332
|
}
|