@atlaskit/editor-plugin-table 17.3.20 → 17.3.22
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 +16 -0
- package/dist/cjs/pm-plugins/commands/insert.js +2 -5
- package/dist/cjs/pm-plugins/utils/paste.js +32 -47
- package/dist/cjs/tablePlugin.js +2 -4
- package/dist/cjs/ui/DragHandle/index.js +10 -6
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
- package/dist/cjs/ui/FloatingDeleteButton/DeleteButton.js +6 -7
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -0
- package/dist/cjs/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +6 -7
- package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +5 -6
- package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +22 -14
- package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +7 -6
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +2 -0
- package/dist/cjs/ui/TableFloatingControls/index.js +1 -0
- package/dist/es2019/pm-plugins/commands/insert.js +2 -5
- package/dist/es2019/pm-plugins/utils/paste.js +32 -47
- package/dist/es2019/tablePlugin.js +2 -4
- package/dist/es2019/ui/DragHandle/index.js +10 -6
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
- package/dist/es2019/ui/FloatingDeleteButton/DeleteButton.js +6 -7
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -0
- package/dist/es2019/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +6 -7
- package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +5 -6
- package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +18 -14
- package/dist/es2019/ui/TableFloatingControls/RowControls/ClassicControls.js +5 -6
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +2 -0
- package/dist/es2019/ui/TableFloatingControls/index.js +1 -0
- package/dist/esm/pm-plugins/commands/insert.js +2 -5
- package/dist/esm/pm-plugins/utils/paste.js +32 -47
- package/dist/esm/tablePlugin.js +2 -4
- package/dist/esm/ui/DragHandle/index.js +10 -6
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
- package/dist/esm/ui/FloatingDeleteButton/DeleteButton.js +6 -7
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -0
- package/dist/esm/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +6 -7
- package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +5 -6
- package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +22 -14
- package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +7 -6
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +2 -0
- package/dist/esm/ui/TableFloatingControls/index.js +1 -0
- package/dist/types/ui/DragHandle/index.d.ts +3 -1
- package/dist/types-ts4.5/ui/DragHandle/index.d.ts +3 -1
- package/package.json +3 -3
|
@@ -28,6 +28,8 @@ const DragHandleComponent = ({
|
|
|
28
28
|
previewHeight,
|
|
29
29
|
onMouseOver,
|
|
30
30
|
onMouseOut,
|
|
31
|
+
onFocus,
|
|
32
|
+
onBlur,
|
|
31
33
|
toggleDragMenu,
|
|
32
34
|
hoveredCell,
|
|
33
35
|
onClick,
|
|
@@ -195,19 +197,21 @@ const DragHandleComponent = ({
|
|
|
195
197
|
"data-testid": "table-drag-handle-button",
|
|
196
198
|
"aria-label": formatMessage(isRow ? messages.rowDragHandle : messages.columnDragHandle),
|
|
197
199
|
"aria-expanded": isDragMenuOpen && isDragMenuTarget ? 'true' : 'false',
|
|
198
|
-
"aria-haspopup": "menu"
|
|
199
|
-
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
200
|
-
,
|
|
200
|
+
"aria-haspopup": "menu",
|
|
201
201
|
onMouseOver: e => {
|
|
202
202
|
setIsHovered(true);
|
|
203
203
|
onMouseOver && onMouseOver(e);
|
|
204
|
-
}
|
|
205
|
-
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
206
|
-
,
|
|
204
|
+
},
|
|
207
205
|
onMouseOut: e => {
|
|
208
206
|
setIsHovered(false);
|
|
209
207
|
onMouseOut && onMouseOut(e);
|
|
210
208
|
},
|
|
209
|
+
onFocus: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? e => {
|
|
210
|
+
onFocus && onFocus(e);
|
|
211
|
+
} : undefined,
|
|
212
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? e => {
|
|
213
|
+
onBlur && onBlur(e);
|
|
214
|
+
} : undefined,
|
|
211
215
|
onMouseUp: e => {
|
|
212
216
|
// return focus to editor so copying table selections whilst still works, i cannot call e.preventDefault in a mousemove event as this stops dragstart events from firing
|
|
213
217
|
// -> this is bad for a11y but is the current standard new copy/paste keyboard shortcuts should be introduced instead
|
|
@@ -31,6 +31,7 @@ import TableRowAddBelowIcon from '@atlaskit/icon/core/table-row-add-below';
|
|
|
31
31
|
import TableRowDeleteIcon from '@atlaskit/icon/core/table-row-delete';
|
|
32
32
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
33
33
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
34
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
34
35
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
35
36
|
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, setFocusToCellMenu, toggleContextualMenu } from '../../pm-plugins/commands';
|
|
36
37
|
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics } from '../../pm-plugins/commands/commands-with-analytics';
|
|
@@ -807,10 +808,9 @@ export class ContextualMenu extends Component {
|
|
|
807
808
|
userIntent: "tableContextualMenuPopupOpen",
|
|
808
809
|
api: api
|
|
809
810
|
}, jsx("div", {
|
|
810
|
-
"data-testid": "table-cell-contextual-menu"
|
|
811
|
-
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
812
|
-
,
|
|
811
|
+
"data-testid": "table-cell-contextual-menu",
|
|
813
812
|
onMouseLeave: this.closeSubmenu,
|
|
813
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? this.closeSubmenu : undefined,
|
|
814
814
|
ref: this.dropdownMenuRef
|
|
815
815
|
}, jsx(DropdownMenu
|
|
816
816
|
//This needs be removed when the a11y is completely handled
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { injectIntl } from 'react-intl-next';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { TableCssClassName as ClassName } from '../../types';
|
|
4
5
|
const DeleteButton = ({
|
|
5
6
|
style,
|
|
@@ -15,13 +16,11 @@ const DeleteButton = ({
|
|
|
15
16
|
className: ClassName.CONTROLS_DELETE_BUTTON_WRAP
|
|
16
17
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
17
18
|
,
|
|
18
|
-
style: style
|
|
19
|
-
|
|
20
|
-
,
|
|
21
|
-
onMouseEnter:
|
|
22
|
-
|
|
23
|
-
,
|
|
24
|
-
onMouseLeave: onMouseLeave
|
|
19
|
+
style: style,
|
|
20
|
+
onMouseEnter: onMouseEnter,
|
|
21
|
+
onMouseLeave: onMouseLeave,
|
|
22
|
+
onFocus: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? onMouseEnter : undefined,
|
|
23
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? onMouseLeave : undefined
|
|
25
24
|
}, /*#__PURE__*/React.createElement("button", {
|
|
26
25
|
type: "button",
|
|
27
26
|
"aria-label": formatMessage(removeLabel, {
|
|
@@ -6,6 +6,7 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
6
6
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
7
7
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
8
8
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
9
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
10
|
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../pm-plugins/commands';
|
|
10
11
|
import { toggleDragMenuWithAnalytics } from '../../../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
11
12
|
import { getRowsParams } from '../../../pm-plugins/utils/row-controls';
|
|
@@ -186,6 +187,8 @@ export const ColumnControls = ({
|
|
|
186
187
|
onClick: handleClick,
|
|
187
188
|
onMouseOver: handleMouseOver,
|
|
188
189
|
onMouseOut: handleMouseOut,
|
|
190
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? handleMouseOut : undefined,
|
|
191
|
+
onFocus: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? handleMouseOver : undefined,
|
|
189
192
|
toggleDragMenu: toggleDragMenuHandler,
|
|
190
193
|
editorView: editorView
|
|
191
194
|
}));
|
|
@@ -5,6 +5,7 @@ import { injectIntl } from 'react-intl-next';
|
|
|
5
5
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
7
|
import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
|
|
8
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
9
|
import { clearHoverSelection, hoverTable } from '../../../pm-plugins/commands';
|
|
9
10
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
10
11
|
// Ignored via go/ees005
|
|
@@ -82,13 +83,11 @@ class CornerControlComponent extends Component {
|
|
|
82
83
|
className: classnames(ClassName.CONTROLS_CORNER_BUTTON, {
|
|
83
84
|
danger: isActive && isInDanger
|
|
84
85
|
}),
|
|
85
|
-
onClick: this.selectTable
|
|
86
|
-
|
|
87
|
-
,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
,
|
|
91
|
-
onMouseOut: this.clearHoverSelection
|
|
86
|
+
onClick: this.selectTable,
|
|
87
|
+
onMouseOver: this.hoverTable,
|
|
88
|
+
onMouseOut: this.clearHoverSelection,
|
|
89
|
+
onFocus: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? this.hoverTable : undefined,
|
|
90
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? this.clearHoverSelection : undefined
|
|
92
91
|
}), !isHeaderRowEnabled &&
|
|
93
92
|
/*#__PURE__*/
|
|
94
93
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -4,6 +4,7 @@ import { injectIntl } from 'react-intl-next';
|
|
|
4
4
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
import { clearHoverSelection } from '../../../pm-plugins/commands';
|
|
8
9
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
9
10
|
const DragCornerControlsComponent = ({
|
|
@@ -49,10 +50,9 @@ const DragCornerControlsComponent = ({
|
|
|
49
50
|
}),
|
|
50
51
|
"aria-label": formatMessage(messages.cornerControl),
|
|
51
52
|
type: "button",
|
|
52
|
-
onClick: handleOnClick
|
|
53
|
-
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
54
|
-
,
|
|
53
|
+
onClick: handleOnClick,
|
|
55
54
|
onMouseOut: handleMouseOut,
|
|
55
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? handleMouseOut : undefined,
|
|
56
56
|
contentEditable: false
|
|
57
57
|
}, /*#__PURE__*/React.createElement("div", {
|
|
58
58
|
className: ClassName.DRAG_CORNER_BUTTON_INNER
|
|
@@ -110,10 +110,9 @@ const DragCornerControlsComponentWithSelection = ({
|
|
|
110
110
|
}),
|
|
111
111
|
"aria-label": formatMessage(messages.cornerControl),
|
|
112
112
|
type: "button",
|
|
113
|
-
onClick: handleOnClick
|
|
114
|
-
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
115
|
-
,
|
|
113
|
+
onClick: handleOnClick,
|
|
116
114
|
onMouseOut: handleMouseOut,
|
|
115
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? handleMouseOut : undefined,
|
|
117
116
|
contentEditable: false
|
|
118
117
|
}, /*#__PURE__*/React.createElement("div", {
|
|
119
118
|
className: ClassName.DRAG_CORNER_BUTTON_INNER
|
|
@@ -4,6 +4,7 @@ import classnames from 'classnames';
|
|
|
4
4
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
5
5
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { isRowSelected } from '@atlaskit/editor-tables/utils';
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
import { clearHoverSelection } from '../../../pm-plugins/commands';
|
|
8
9
|
import { getRowHeights } from '../../../pm-plugins/utils/row-controls';
|
|
9
10
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
@@ -134,16 +135,14 @@ export default class NumberColumn extends Component {
|
|
|
134
135
|
"data-index": index
|
|
135
136
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
136
137
|
,
|
|
137
|
-
style: this.getCellStyles(index, rowHeight)
|
|
138
|
-
|
|
139
|
-
,
|
|
138
|
+
style: this.getCellStyles(index, rowHeight),
|
|
139
|
+
onFocus: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? () => updateCellHoverLocation(index) : undefined,
|
|
140
140
|
onMouseOver: () => updateCellHoverLocation(index)
|
|
141
|
-
}, hasHeaderRow ? index > 0 ? index : null : index + 1) :
|
|
142
|
-
/*#__PURE__*/
|
|
143
|
-
// eslint-disable-next-line @atlassian/a11y/click-events-have-key-events, @atlassian/a11y/interactive-element-not-keyboard-focusable, @atlassian/a11y/no-static-element-interactions
|
|
144
|
-
React.createElement("div", {
|
|
141
|
+
}, hasHeaderRow ? index > 0 ? index : null : index + 1) : /*#__PURE__*/React.createElement("div", {
|
|
145
142
|
// Ignored via go/ees005
|
|
143
|
+
role: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? 'button' : undefined
|
|
146
144
|
// eslint-disable-next-line react/no-array-index-key
|
|
145
|
+
,
|
|
147
146
|
key: `wrapper-${index}`
|
|
148
147
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
149
148
|
,
|
|
@@ -152,13 +151,18 @@ export default class NumberColumn extends Component {
|
|
|
152
151
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
153
152
|
,
|
|
154
153
|
style: this.getCellStyles(index, rowHeight),
|
|
155
|
-
onClick: event => this.selectRow(index, event)
|
|
156
|
-
|
|
157
|
-
,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
154
|
+
onClick: event => this.selectRow(index, event),
|
|
155
|
+
onFocus: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? () => this.hoverRows(index) : undefined,
|
|
156
|
+
onMouseOver: () => this.hoverRows(index),
|
|
157
|
+
tabIndex: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? 0 : undefined,
|
|
158
|
+
onKeyDown: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? event => {
|
|
159
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
this.selectRow(index, event);
|
|
162
|
+
}
|
|
163
|
+
} : undefined,
|
|
164
|
+
onMouseOut: this.clearHoverSelection,
|
|
165
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? this.clearHoverSelection : undefined
|
|
162
166
|
}, hasHeaderRow ? index > 0 ? index : null : index + 1)));
|
|
163
167
|
}
|
|
164
168
|
}
|
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
3
|
import { injectIntl } from 'react-intl-next';
|
|
4
4
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
6
|
import { clearHoverSelection } from '../../../pm-plugins/commands';
|
|
6
7
|
import { getRowClassNames, getRowHeights, getRowsParams } from '../../../pm-plugins/utils/row-controls';
|
|
7
8
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
@@ -81,13 +82,11 @@ class RowControlsComponent extends Component {
|
|
|
81
82
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
82
83
|
,
|
|
83
84
|
className: `${ClassName.ROW_CONTROLS_BUTTON} ${ClassName.CONTROLS_BUTTON}`,
|
|
84
|
-
onClick: event => this.props.selectRow(startIndex, event.shiftKey)
|
|
85
|
-
|
|
86
|
-
,
|
|
87
|
-
onMouseOver: () => this.props.hoverRows([startIndex])
|
|
88
|
-
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
89
|
-
,
|
|
85
|
+
onClick: event => this.props.selectRow(startIndex, event.shiftKey),
|
|
86
|
+
onMouseOver: () => this.props.hoverRows([startIndex]),
|
|
87
|
+
onFocus: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? () => this.props.hoverRows([startIndex]) : undefined,
|
|
90
88
|
onMouseOut: this.clearHoverSelection,
|
|
89
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? this.clearHoverSelection : undefined,
|
|
91
90
|
"data-start-index": startIndex,
|
|
92
91
|
"data-end-index": endIndex
|
|
93
92
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -175,6 +175,8 @@ export const DragControls = ({
|
|
|
175
175
|
onClick: handleClick,
|
|
176
176
|
onMouseOver: handleMouseOver,
|
|
177
177
|
onMouseOut: handleMouseOut,
|
|
178
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? handleMouseOut : undefined,
|
|
179
|
+
onFocus: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? handleMouseOver : undefined,
|
|
178
180
|
toggleDragMenu: toggleDragMenuHandler,
|
|
179
181
|
editorView: editorView
|
|
180
182
|
}));
|
|
@@ -109,6 +109,7 @@ export const TableFloatingControls = ({
|
|
|
109
109
|
className: wrapperClassName,
|
|
110
110
|
css: [expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow') && !fg('platform_editor_table_sticky_header_patch_7') && styles]
|
|
111
111
|
}, jsx("div", {
|
|
112
|
+
role: "none",
|
|
112
113
|
onMouseDown: e => !isDragAndDropEnabled && e.preventDefault()
|
|
113
114
|
}, isNumberColumnEnabled ? jsx(NumberColumn, {
|
|
114
115
|
editorView: editorView,
|
|
@@ -9,7 +9,6 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
9
9
|
import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
10
10
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
11
11
|
import { addColumnAt as addColumnAtPMUtils, addRowAt, findTable, selectedRect } from '@atlaskit/editor-tables/utils';
|
|
12
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
12
|
import { updateRowOrColumnMovedTransform } from '../analytics/commands';
|
|
14
13
|
import { META_KEYS } from '../table-analytics';
|
|
15
14
|
import { rescaleColumns } from '../transforms/column-width';
|
|
@@ -266,10 +265,8 @@ export var insertTableWithNestingSupport = function insertTableWithNestingSuppor
|
|
|
266
265
|
var insertAt;
|
|
267
266
|
var isNestedTable = false;
|
|
268
267
|
if (hasParentNodeOfType(schema.nodes.table)(tr.selection) && isNestedTablesSupported(schema)) {
|
|
269
|
-
// If
|
|
270
|
-
if (
|
|
271
|
-
exposure: true
|
|
272
|
-
}) || getParentOfTypeCount(schema.nodes.table)(tr.selection.$from) > 1) {
|
|
268
|
+
// If trying to nest deeper than one level, we insert the table after the top table
|
|
269
|
+
if (getParentOfTypeCount(schema.nodes.table)(tr.selection.$from) > 1) {
|
|
273
270
|
var positionAfterTopTable = getPositionAfterTopParentNodeOfType(schema.nodes.table)(tr.selection.$from);
|
|
274
271
|
if (!positionAfterTopTable) {
|
|
275
272
|
return tr;
|
|
@@ -8,7 +8,6 @@ import { Slice, Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
|
8
8
|
import { flatten, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
9
9
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
11
|
import { getPluginState } from '../plugin-factory';
|
|
13
12
|
|
|
14
13
|
// lifts up the content of each cell, returning an array of nodes
|
|
@@ -68,17 +67,16 @@ export var removeTableFromLastChild = function removeTableFromLastChild(node, i,
|
|
|
68
67
|
return i === fragment.childCount - 1 ? unwrapContentFromTable(node) : node;
|
|
69
68
|
};
|
|
70
69
|
export var transformSliceToRemoveNestedTables = function transformSliceToRemoveNestedTables(slice, schema, selection) {
|
|
71
|
-
var isNestingAllowed = editorExperiment('nested-tables-in-tables', true);
|
|
72
70
|
var _schema$nodes2 = schema.nodes,
|
|
73
71
|
table = _schema$nodes2.table,
|
|
74
72
|
tableCell = _schema$nodes2.tableCell,
|
|
75
73
|
tableHeader = _schema$nodes2.tableHeader;
|
|
76
74
|
var openEnd = slice.openEnd;
|
|
77
75
|
var newFragment = flatmap(slice.content, function (node, i, fragment) {
|
|
78
|
-
var _slice$content$firstC;
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
var allowedTableNesting =
|
|
76
|
+
var _slice$content$firstC, _slice$content$lastCh;
|
|
77
|
+
// We allow default nesting of 2 to support
|
|
78
|
+
// two levels of nesting in nodes that support table nesting already such as layoutSection and expands
|
|
79
|
+
var allowedTableNesting = 2;
|
|
82
80
|
var isCellSelection = selection instanceof CellSelection;
|
|
83
81
|
var isPasteInTable = hasParentNodeOfType([table, tableCell, tableHeader])(selection);
|
|
84
82
|
var isPasteInNestedTable = getParentOfTypeCount(schema.nodes.table)(selection.$from) > 1;
|
|
@@ -86,55 +84,42 @@ export var transformSliceToRemoveNestedTables = function transformSliceToRemoveN
|
|
|
86
84
|
|
|
87
85
|
// Pasted content only contains a table and no other content
|
|
88
86
|
var isCellPaste = isPasteInTable && slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === table && (!isPasteFullTableInsideEmptyCellEnabled || slice.openStart !== 0 && slice.openEnd !== 0);
|
|
89
|
-
if (isNestingAllowed) {
|
|
90
|
-
var _slice$content$lastCh;
|
|
91
|
-
// if nesting is allowed we bump up the default nesting allowance to 2 to support
|
|
92
|
-
// two levels of nesting in nodes that support table nesting already such as layoutSection and expands
|
|
93
|
-
allowedTableNesting = 2;
|
|
94
87
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
// if paste is inside a table, allow no further nesting
|
|
100
|
-
if (isPasteInTable) {
|
|
101
|
-
allowedTableNesting = 0;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// unless we are pasting inside a nested table, then bounce back to 1 level
|
|
105
|
-
// because editor-plugin-paste will lift the table to the parent table (just below it)
|
|
106
|
-
if (isPasteInNestedTable) {
|
|
107
|
-
allowedTableNesting = 1;
|
|
108
|
-
}
|
|
88
|
+
// however if pasted content is a table, allow just one level
|
|
89
|
+
if (node.type === schema.nodes.table) {
|
|
90
|
+
allowedTableNesting = 1;
|
|
109
91
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
allowedTableNesting = 1;
|
|
114
|
-
if (isPasteInNestedTable) {
|
|
115
|
-
allowedTableNesting = 0;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
92
|
+
// if paste is inside a table, allow no further nesting
|
|
93
|
+
if (isPasteInTable) {
|
|
94
|
+
allowedTableNesting = 0;
|
|
118
95
|
}
|
|
119
96
|
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (slice.openEnd >= 7 &&
|
|
125
|
-
// depth of a nested table cell
|
|
126
|
-
slice.content.childCount > 1 && ((_slice$content$lastCh = slice.content.lastChild) === null || _slice$content$lastCh === void 0 ? void 0 : _slice$content$lastCh.type) === table && isPasteInTable) {
|
|
127
|
-
// re-point the slice's openEnd to non-nested table cell depth
|
|
128
|
-
openEnd = 4;
|
|
97
|
+
// unless we are pasting inside a nested table, then bounce back to 1 level
|
|
98
|
+
// because editor-plugin-paste will lift the table to the parent table (just below it)
|
|
99
|
+
if (isPasteInNestedTable) {
|
|
100
|
+
allowedTableNesting = 1;
|
|
129
101
|
}
|
|
130
|
-
} else {
|
|
131
|
-
// for layouts and expands, we start with 1 level of nesting as set above
|
|
132
102
|
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
103
|
+
// paste of table cells into a table cell - content is spread across multiple cells
|
|
104
|
+
// by editor-tables so needs to be treated a little differently
|
|
105
|
+
if (isCellPaste || isCellSelection) {
|
|
106
|
+
allowedTableNesting = 1;
|
|
107
|
+
if (isPasteInNestedTable) {
|
|
108
|
+
allowedTableNesting = 0;
|
|
109
|
+
}
|
|
136
110
|
}
|
|
137
111
|
}
|
|
112
|
+
|
|
113
|
+
// Prevent invalid openEnd after pasting tables with a selection that ends inside a nested table cell.
|
|
114
|
+
// If the slice ends with a selection that ends inside a nested table, and we paste inside a table we
|
|
115
|
+
// need to adjust the openEnd because it is no longer correct. If we don't, Prosemirror fires an exception
|
|
116
|
+
// because it iterates to a non-existent depth and the transform will not be applied
|
|
117
|
+
if (slice.openEnd >= 7 &&
|
|
118
|
+
// depth of a nested table cell
|
|
119
|
+
slice.content.childCount > 1 && ((_slice$content$lastCh = slice.content.lastChild) === null || _slice$content$lastCh === void 0 ? void 0 : _slice$content$lastCh.type) === table && isPasteInTable) {
|
|
120
|
+
// re-point the slice's openEnd to non-nested table cell depth
|
|
121
|
+
openEnd = 4;
|
|
122
|
+
}
|
|
138
123
|
if (isCellSelection && !isCellPaste) {
|
|
139
124
|
// if pasting into a cell selection, we need to flatten the parent table as well
|
|
140
125
|
return _unwrapNestedTables(Fragment.fromArray([node]), schema, allowedTableNesting);
|
package/dist/esm/tablePlugin.js
CHANGED
|
@@ -565,10 +565,8 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
565
565
|
var tr = state.tr;
|
|
566
566
|
// If the cursor is inside a table
|
|
567
567
|
if (hasParentNodeOfType(state.schema.nodes.table)(state.selection) && options !== null && options !== void 0 && (_options$tableOptions6 = options.tableOptions) !== null && _options$tableOptions6 !== void 0 && _options$tableOptions6.allowNestedTables) {
|
|
568
|
-
// If
|
|
569
|
-
if (
|
|
570
|
-
exposure: true
|
|
571
|
-
}) || getParentOfTypeCount(state.schema.nodes.table)(state.selection.$from) > 1) {
|
|
568
|
+
// If trying to nest deeper than one level, we insert the table after the top table
|
|
569
|
+
if (getParentOfTypeCount(state.schema.nodes.table)(state.selection.$from) > 1) {
|
|
572
570
|
// Nesting is too deep insert table after the top parent table
|
|
573
571
|
var positionAfterTopTable = getPositionAfterTopParentNodeOfType(state.schema.nodes.table)(state.selection.$from);
|
|
574
572
|
tr = safeInsert(tableNode, positionAfterTopTable)(tr);
|
|
@@ -33,6 +33,8 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
33
33
|
previewHeight = _ref.previewHeight,
|
|
34
34
|
_onMouseOver = _ref.onMouseOver,
|
|
35
35
|
_onMouseOut = _ref.onMouseOut,
|
|
36
|
+
onFocus = _ref.onFocus,
|
|
37
|
+
onBlur = _ref.onBlur,
|
|
36
38
|
toggleDragMenu = _ref.toggleDragMenu,
|
|
37
39
|
hoveredCell = _ref.hoveredCell,
|
|
38
40
|
onClick = _ref.onClick,
|
|
@@ -194,19 +196,21 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
194
196
|
"data-testid": "table-drag-handle-button",
|
|
195
197
|
"aria-label": formatMessage(isRow ? messages.rowDragHandle : messages.columnDragHandle),
|
|
196
198
|
"aria-expanded": isDragMenuOpen && isDragMenuTarget ? 'true' : 'false',
|
|
197
|
-
"aria-haspopup": "menu"
|
|
198
|
-
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
199
|
-
,
|
|
199
|
+
"aria-haspopup": "menu",
|
|
200
200
|
onMouseOver: function onMouseOver(e) {
|
|
201
201
|
setIsHovered(true);
|
|
202
202
|
_onMouseOver && _onMouseOver(e);
|
|
203
|
-
}
|
|
204
|
-
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
205
|
-
,
|
|
203
|
+
},
|
|
206
204
|
onMouseOut: function onMouseOut(e) {
|
|
207
205
|
setIsHovered(false);
|
|
208
206
|
_onMouseOut && _onMouseOut(e);
|
|
209
207
|
},
|
|
208
|
+
onFocus: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? function (e) {
|
|
209
|
+
onFocus && onFocus(e);
|
|
210
|
+
} : undefined,
|
|
211
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? function (e) {
|
|
212
|
+
onBlur && onBlur(e);
|
|
213
|
+
} : undefined,
|
|
210
214
|
onMouseUp: function onMouseUp(e) {
|
|
211
215
|
// return focus to editor so copying table selections whilst still works, i cannot call e.preventDefault in a mousemove event as this stops dragstart events from firing
|
|
212
216
|
// -> this is bad for a11y but is the current standard new copy/paste keyboard shortcuts should be introduced instead
|
|
@@ -41,6 +41,7 @@ import TableRowAddBelowIcon from '@atlaskit/icon/core/table-row-add-below';
|
|
|
41
41
|
import TableRowDeleteIcon from '@atlaskit/icon/core/table-row-delete';
|
|
42
42
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
43
43
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
44
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
44
45
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
45
46
|
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, setFocusToCellMenu, toggleContextualMenu } from '../../pm-plugins/commands';
|
|
46
47
|
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics } from '../../pm-plugins/commands/commands-with-analytics';
|
|
@@ -743,10 +744,9 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
743
744
|
userIntent: "tableContextualMenuPopupOpen",
|
|
744
745
|
api: api
|
|
745
746
|
}, jsx("div", {
|
|
746
|
-
"data-testid": "table-cell-contextual-menu"
|
|
747
|
-
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
748
|
-
,
|
|
747
|
+
"data-testid": "table-cell-contextual-menu",
|
|
749
748
|
onMouseLeave: this.closeSubmenu,
|
|
749
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? this.closeSubmenu : undefined,
|
|
750
750
|
ref: this.dropdownMenuRef
|
|
751
751
|
}, jsx(DropdownMenu
|
|
752
752
|
//This needs be removed when the a11y is completely handled
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { injectIntl } from 'react-intl-next';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { TableCssClassName as ClassName } from '../../types';
|
|
4
5
|
var DeleteButton = function DeleteButton(_ref) {
|
|
5
6
|
var style = _ref.style,
|
|
@@ -13,13 +14,11 @@ var DeleteButton = function DeleteButton(_ref) {
|
|
|
13
14
|
className: ClassName.CONTROLS_DELETE_BUTTON_WRAP
|
|
14
15
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
15
16
|
,
|
|
16
|
-
style: style
|
|
17
|
-
|
|
18
|
-
,
|
|
19
|
-
onMouseEnter:
|
|
20
|
-
|
|
21
|
-
,
|
|
22
|
-
onMouseLeave: onMouseLeave
|
|
17
|
+
style: style,
|
|
18
|
+
onMouseEnter: onMouseEnter,
|
|
19
|
+
onMouseLeave: onMouseLeave,
|
|
20
|
+
onFocus: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? onMouseEnter : undefined,
|
|
21
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? onMouseLeave : undefined
|
|
23
22
|
}, /*#__PURE__*/React.createElement("button", {
|
|
24
23
|
type: "button",
|
|
25
24
|
"aria-label": formatMessage(removeLabel, {
|
|
@@ -6,6 +6,7 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
6
6
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
7
7
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
8
8
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
9
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
10
|
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../pm-plugins/commands';
|
|
10
11
|
import { toggleDragMenuWithAnalytics } from '../../../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
11
12
|
import { getRowsParams } from '../../../pm-plugins/utils/row-controls';
|
|
@@ -181,6 +182,8 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
181
182
|
onClick: handleClick,
|
|
182
183
|
onMouseOver: handleMouseOver,
|
|
183
184
|
onMouseOut: handleMouseOut,
|
|
185
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? handleMouseOut : undefined,
|
|
186
|
+
onFocus: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? handleMouseOver : undefined,
|
|
184
187
|
toggleDragMenu: toggleDragMenuHandler,
|
|
185
188
|
editorView: editorView
|
|
186
189
|
}));
|
|
@@ -12,6 +12,7 @@ import { injectIntl } from 'react-intl-next';
|
|
|
12
12
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
13
13
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
14
14
|
import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
|
|
15
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
16
|
import { clearHoverSelection, hoverTable } from '../../../pm-plugins/commands';
|
|
16
17
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
17
18
|
// Ignored via go/ees005
|
|
@@ -89,13 +90,11 @@ var CornerControlComponent = /*#__PURE__*/function (_Component) {
|
|
|
89
90
|
className: classnames(ClassName.CONTROLS_CORNER_BUTTON, {
|
|
90
91
|
danger: isActive && isInDanger
|
|
91
92
|
}),
|
|
92
|
-
onClick: this.selectTable
|
|
93
|
-
|
|
94
|
-
,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
,
|
|
98
|
-
onMouseOut: this.clearHoverSelection
|
|
93
|
+
onClick: this.selectTable,
|
|
94
|
+
onMouseOver: this.hoverTable,
|
|
95
|
+
onMouseOut: this.clearHoverSelection,
|
|
96
|
+
onFocus: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? this.hoverTable : undefined,
|
|
97
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? this.clearHoverSelection : undefined
|
|
99
98
|
}), !isHeaderRowEnabled &&
|
|
100
99
|
/*#__PURE__*/
|
|
101
100
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -4,6 +4,7 @@ import { injectIntl } from 'react-intl-next';
|
|
|
4
4
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
import { clearHoverSelection } from '../../../pm-plugins/commands';
|
|
8
9
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
9
10
|
var DragCornerControlsComponent = function DragCornerControlsComponent(_ref) {
|
|
@@ -40,10 +41,9 @@ var DragCornerControlsComponent = function DragCornerControlsComponent(_ref) {
|
|
|
40
41
|
}),
|
|
41
42
|
"aria-label": formatMessage(messages.cornerControl),
|
|
42
43
|
type: "button",
|
|
43
|
-
onClick: handleOnClick
|
|
44
|
-
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
45
|
-
,
|
|
44
|
+
onClick: handleOnClick,
|
|
46
45
|
onMouseOut: handleMouseOut,
|
|
46
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? handleMouseOut : undefined,
|
|
47
47
|
contentEditable: false
|
|
48
48
|
}, /*#__PURE__*/React.createElement("div", {
|
|
49
49
|
className: ClassName.DRAG_CORNER_BUTTON_INNER
|
|
@@ -93,10 +93,9 @@ var DragCornerControlsComponentWithSelection = function DragCornerControlsCompon
|
|
|
93
93
|
}),
|
|
94
94
|
"aria-label": formatMessage(messages.cornerControl),
|
|
95
95
|
type: "button",
|
|
96
|
-
onClick: handleOnClick
|
|
97
|
-
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
98
|
-
,
|
|
96
|
+
onClick: handleOnClick,
|
|
99
97
|
onMouseOut: handleMouseOut,
|
|
98
|
+
onBlur: expValEquals('platform_editor_table_a11y_eslint_fix', 'isEnabled', true) ? handleMouseOut : undefined,
|
|
100
99
|
contentEditable: false
|
|
101
100
|
}, /*#__PURE__*/React.createElement("div", {
|
|
102
101
|
className: ClassName.DRAG_CORNER_BUTTON_INNER
|