@atlaskit/editor-plugin-table 5.4.11 → 5.4.13
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 +15 -0
- package/dist/cjs/plugins/table/event-handlers.js +10 -4
- package/dist/cjs/plugins/table/toolbar.js +3 -6
- package/dist/cjs/plugins/table/ui/ColumnResizeWidget/index.js +3 -6
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +12 -6
- package/dist/cjs/plugins/table/ui/DragPreview/index.js +2 -0
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +7 -10
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +10 -11
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +3 -6
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +4 -7
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +1 -4
- package/dist/cjs/plugins/table/utils/column-controls.js +63 -1
- package/dist/cjs/plugins/table/utils/index.js +12 -0
- package/dist/es2019/plugins/table/event-handlers.js +11 -5
- package/dist/es2019/plugins/table/toolbar.js +3 -5
- package/dist/es2019/plugins/table/ui/ColumnResizeWidget/index.js +3 -5
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +11 -4
- package/dist/es2019/plugins/table/ui/DragPreview/index.js +2 -0
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +7 -9
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +9 -11
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +3 -5
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +4 -6
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +1 -4
- package/dist/es2019/plugins/table/utils/column-controls.js +62 -0
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/event-handlers.js +11 -5
- package/dist/esm/plugins/table/toolbar.js +3 -5
- package/dist/esm/plugins/table/ui/ColumnResizeWidget/index.js +3 -5
- package/dist/esm/plugins/table/ui/DragHandle/index.js +11 -5
- package/dist/esm/plugins/table/ui/DragPreview/index.js +2 -0
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +7 -9
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +9 -11
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +3 -5
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +4 -6
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +1 -4
- package/dist/esm/plugins/table/utils/column-controls.js +62 -0
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/utils/column-controls.d.ts +3 -0
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/utils/column-controls.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +4 -4
- package/src/__tests__/unit/utils/column-controls.ts +145 -1
- package/src/plugins/table/event-handlers.ts +22 -4
- package/src/plugins/table/ui/DragHandle/index.tsx +30 -21
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +1 -5
- package/src/plugins/table/utils/column-controls.ts +81 -0
- package/src/plugins/table/utils/index.ts +2 -0
- package/src/__tests__/integration/block-node-selection.ts +0 -165
|
@@ -100,8 +100,10 @@ export const DragHandle = ({
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells]);
|
|
103
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
104
|
-
className: classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance,
|
|
103
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
104
|
+
className: classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, ClassName.CONTROLS_BUTTON, appearance, {
|
|
105
|
+
[ClassName.DRAG_HANDLE_DISABLED]: isDragAndDropEnabled && hasMergedCells
|
|
106
|
+
}),
|
|
105
107
|
ref: dragHandleDivRef,
|
|
106
108
|
style: {
|
|
107
109
|
transform: direction === 'column' ? 'none' : 'rotate(90deg)',
|
|
@@ -110,9 +112,14 @@ export const DragHandle = ({
|
|
|
110
112
|
"data-testid": "table-floating-column-controls-drag-handle",
|
|
111
113
|
onMouseOver: onMouseOver,
|
|
112
114
|
onMouseOut: onMouseOut,
|
|
113
|
-
onMouseUp:
|
|
115
|
+
onMouseUp: e => {
|
|
116
|
+
// 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
|
|
117
|
+
// -> this is bad for a11y but is the current standard new copy/paste keyboard shortcuts should be introduced instead
|
|
118
|
+
editorView.focus();
|
|
119
|
+
onMouseUp && onMouseUp(e);
|
|
120
|
+
},
|
|
114
121
|
onClick: onClick
|
|
115
|
-
}, /*#__PURE__*/React.createElement(HandleIconComponent, handleIconProps), previewContainer && previewWidth !== undefined && previewHeight !== undefined && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(DragPreview, {
|
|
122
|
+
}, /*#__PURE__*/React.createElement(HandleIconComponent, handleIconProps)), previewContainer && previewWidth !== undefined && previewHeight !== undefined && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(DragPreview, {
|
|
116
123
|
direction: direction,
|
|
117
124
|
width: previewWidth,
|
|
118
125
|
height: previewHeight
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
2
|
import { injectIntl } from 'react-intl-next';
|
|
5
3
|
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
6
4
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
@@ -50,25 +48,25 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
50
48
|
return null;
|
|
51
49
|
}
|
|
52
50
|
const labelCellOptions = formatMessage(messages.cellOptions);
|
|
53
|
-
const button =
|
|
51
|
+
const button = /*#__PURE__*/React.createElement("div", {
|
|
54
52
|
css: theme => [tableFloatingCellButtonStyles({
|
|
55
53
|
theme
|
|
56
54
|
}), isContextualMenuOpen && tableFloatingCellButtonSelectedStyles({
|
|
57
55
|
theme
|
|
58
56
|
})]
|
|
59
|
-
},
|
|
57
|
+
}, /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
60
58
|
className: ClassName.CONTEXTUAL_MENU_BUTTON,
|
|
61
59
|
selected: isContextualMenuOpen,
|
|
62
60
|
title: labelCellOptions,
|
|
63
61
|
onClick: handleClick,
|
|
64
|
-
iconBefore:
|
|
62
|
+
iconBefore: /*#__PURE__*/React.createElement(ExpandIcon, {
|
|
65
63
|
label: ""
|
|
66
64
|
}),
|
|
67
65
|
"aria-label": labelCellOptions
|
|
68
66
|
}));
|
|
69
67
|
const parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
70
68
|
if (stickyHeader && parentSticky && tableWrapper) {
|
|
71
|
-
return
|
|
69
|
+
return /*#__PURE__*/React.createElement(FixedButton, {
|
|
72
70
|
offset: BUTTON_OFFSET,
|
|
73
71
|
stickyHeader: stickyHeader,
|
|
74
72
|
tableWrapper: tableWrapper,
|
|
@@ -78,7 +76,7 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
78
76
|
isContextualMenuOpen: isContextualMenuOpen
|
|
79
77
|
}, button);
|
|
80
78
|
}
|
|
81
|
-
return
|
|
79
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
82
80
|
alignX: "right",
|
|
83
81
|
alignY: "start",
|
|
84
82
|
target: targetCellRef,
|
|
@@ -93,9 +91,9 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
93
91
|
});
|
|
94
92
|
const FloatingContextualButton = injectIntl(FloatingContextualButtonInner);
|
|
95
93
|
export default function (props) {
|
|
96
|
-
return
|
|
94
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
97
95
|
component: ACTION_SUBJECT.FLOATING_CONTEXTUAL_BUTTON,
|
|
98
96
|
dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
|
|
99
97
|
fallbackComponent: null
|
|
100
|
-
},
|
|
98
|
+
}, /*#__PURE__*/React.createElement(FloatingContextualButton, props));
|
|
101
99
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
/** @jsx jsx */
|
|
3
2
|
import { Component } from 'react';
|
|
4
|
-
import { jsx } from '@emotion/react';
|
|
5
3
|
import { injectIntl } from 'react-intl-next';
|
|
6
4
|
import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
7
5
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
@@ -75,15 +73,15 @@ export class ContextualMenu extends Component {
|
|
|
75
73
|
value: {
|
|
76
74
|
name: 'background'
|
|
77
75
|
},
|
|
78
|
-
elemAfter:
|
|
76
|
+
elemAfter: /*#__PURE__*/React.createElement("div", {
|
|
79
77
|
className: DropdownMenuSharedCssClassName.SUBMENU
|
|
80
|
-
},
|
|
78
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
81
79
|
css: cellColourPreviewStyles(background),
|
|
82
80
|
className: ClassName.CONTEXTUAL_MENU_ICON
|
|
83
|
-
}), isSubmenuOpen &&
|
|
81
|
+
}), isSubmenuOpen && /*#__PURE__*/React.createElement("div", {
|
|
84
82
|
className: ClassName.CONTEXTUAL_SUBMENU,
|
|
85
83
|
ref: this.handleSubMenuRef
|
|
86
|
-
},
|
|
84
|
+
}, /*#__PURE__*/React.createElement(ColorPalette, {
|
|
87
85
|
cols: 7,
|
|
88
86
|
onClick: this.setColor,
|
|
89
87
|
selectedColor: background,
|
|
@@ -100,7 +98,7 @@ export class ContextualMenu extends Component {
|
|
|
100
98
|
value: {
|
|
101
99
|
name: 'insert_column'
|
|
102
100
|
},
|
|
103
|
-
elemAfter:
|
|
101
|
+
elemAfter: /*#__PURE__*/React.createElement("div", {
|
|
104
102
|
css: shortcutStyle
|
|
105
103
|
}, tooltip(addColumnAfter))
|
|
106
104
|
});
|
|
@@ -109,7 +107,7 @@ export class ContextualMenu extends Component {
|
|
|
109
107
|
value: {
|
|
110
108
|
name: 'insert_row'
|
|
111
109
|
},
|
|
112
|
-
elemAfter:
|
|
110
|
+
elemAfter: /*#__PURE__*/React.createElement("div", {
|
|
113
111
|
css: shortcutStyle
|
|
114
112
|
}, tooltip(addRowAfter))
|
|
115
113
|
});
|
|
@@ -193,7 +191,7 @@ export class ContextualMenu extends Component {
|
|
|
193
191
|
value: {
|
|
194
192
|
name: 'clear'
|
|
195
193
|
},
|
|
196
|
-
elemAfter:
|
|
194
|
+
elemAfter: /*#__PURE__*/React.createElement("div", {
|
|
197
195
|
css: shortcutStyle
|
|
198
196
|
}, tooltip(backspace))
|
|
199
197
|
});
|
|
@@ -375,10 +373,10 @@ export class ContextualMenu extends Component {
|
|
|
375
373
|
if (!items) {
|
|
376
374
|
return null;
|
|
377
375
|
}
|
|
378
|
-
return
|
|
376
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
379
377
|
"data-testid": "table-cell-contextual-menu",
|
|
380
378
|
onMouseLeave: this.closeSubmenu
|
|
381
|
-
},
|
|
379
|
+
}, /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
382
380
|
mountTo: mountPoint
|
|
383
381
|
//This needs be removed when the a11y is completely handled
|
|
384
382
|
//Disabling key navigation now as it works only partially
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react';
|
|
3
1
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
4
2
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
3
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
@@ -38,7 +36,7 @@ const FloatingContextualMenu = ({
|
|
|
38
36
|
return null;
|
|
39
37
|
}
|
|
40
38
|
const parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
41
|
-
return
|
|
39
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
42
40
|
alignX: "right",
|
|
43
41
|
alignY: "top",
|
|
44
42
|
target: targetCellRef,
|
|
@@ -54,9 +52,9 @@ const FloatingContextualMenu = ({
|
|
|
54
52
|
forcePlacement: true,
|
|
55
53
|
offset: [-7, 0],
|
|
56
54
|
stick: true
|
|
57
|
-
},
|
|
55
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
58
56
|
css: tablePopupStyles
|
|
59
|
-
},
|
|
57
|
+
}, /*#__PURE__*/React.createElement(ContextualMenu, {
|
|
60
58
|
editorView: editorView,
|
|
61
59
|
offset: [contextualMenuTriggerSize / 2, -contextualMenuTriggerSize],
|
|
62
60
|
isOpen: isOpen,
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react';
|
|
3
1
|
import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
4
2
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
5
3
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
@@ -26,15 +24,15 @@ const convertToDropdownItems = dragMenuConfig => {
|
|
|
26
24
|
name: item.id
|
|
27
25
|
},
|
|
28
26
|
isDisabled: item.disabled,
|
|
29
|
-
elemBefore: item.icon ?
|
|
27
|
+
elemBefore: item.icon ? /*#__PURE__*/React.createElement("div", {
|
|
30
28
|
style: {
|
|
31
29
|
marginRight: "var(--ds-space-negative-075, -6px)",
|
|
32
30
|
display: 'flex'
|
|
33
31
|
}
|
|
34
|
-
},
|
|
32
|
+
}, /*#__PURE__*/React.createElement(item.icon, {
|
|
35
33
|
label: item.title
|
|
36
34
|
})) : undefined,
|
|
37
|
-
elemAfter: item.keymap ?
|
|
35
|
+
elemAfter: item.keymap ? /*#__PURE__*/React.createElement("div", {
|
|
38
36
|
css: shortcutStyle
|
|
39
37
|
}, item.keymap) : undefined
|
|
40
38
|
});
|
|
@@ -137,7 +135,7 @@ export const DragMenu = ({
|
|
|
137
135
|
if (!menuItems) {
|
|
138
136
|
return null;
|
|
139
137
|
}
|
|
140
|
-
return
|
|
138
|
+
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
141
139
|
mountTo: mountPoint
|
|
142
140
|
//This needs be removed when the a11y is completely handled
|
|
143
141
|
//Disabling key navigation now as it works only partially
|
|
@@ -70,14 +70,11 @@ export const TableFloatingColumnControls = ({
|
|
|
70
70
|
}
|
|
71
71
|
return [0];
|
|
72
72
|
}, [tableRef, tableRect.height]);
|
|
73
|
-
if (!tableRef) {
|
|
73
|
+
if (!tableRef || !tableActive) {
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
76
|
const colWidths = getColumnsWidths(editorView);
|
|
77
77
|
const stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
|
|
78
|
-
if (!tableActive) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
78
|
return /*#__PURE__*/React.createElement("div", {
|
|
82
79
|
className: ClassName.DRAG_COLUMN_CONTROLS_WRAPPER,
|
|
83
80
|
"data-testid": "table-floating-column-controls-wrapper"
|
|
@@ -159,4 +159,66 @@ export const colWidthsForRow = tr => {
|
|
|
159
159
|
const visualColCount = rowColSpans.reduce((acc, val) => acc + val, 0);
|
|
160
160
|
const pctWidths = rowColSpans.map(cellColSpan => cellColSpan / visualColCount * 100);
|
|
161
161
|
return pctWidths.map(pct => `${pct}%`).join(' ');
|
|
162
|
+
};
|
|
163
|
+
export const convertHTMLCellIndexToColumnIndex = (htmlColIndex, htmlRowIndex, tableMap) => {
|
|
164
|
+
// Same numbers (positions) in tableMap.map array mean that there are merged cells.
|
|
165
|
+
// Cells can be merged across columns. So we need to check if the cell on the left and current cell have the same value.
|
|
166
|
+
// Cells can be merged acroll rows. So we need to check if the cell above has the same value as current cell.
|
|
167
|
+
// When cell has the same value as the cell above it or the cell to the left of it, html cellIndex won't count it a separete column.
|
|
168
|
+
const width = tableMap.width;
|
|
169
|
+
const map = tableMap.map;
|
|
170
|
+
let htmlColCount = 0;
|
|
171
|
+
if (htmlRowIndex === 0) {
|
|
172
|
+
for (let colIndex = 0; colIndex < width; colIndex++) {
|
|
173
|
+
if (colIndex === 0 || map[colIndex] !== map[colIndex - 1]) {
|
|
174
|
+
htmlColCount++;
|
|
175
|
+
}
|
|
176
|
+
if (htmlColCount - 1 === htmlColIndex) {
|
|
177
|
+
return colIndex;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
for (let colIndex = 0; colIndex < width; colIndex++) {
|
|
182
|
+
const currentCellMapIndex = htmlRowIndex * width + colIndex;
|
|
183
|
+
const cellAboveMapIndex = (htmlRowIndex - 1) * width + colIndex;
|
|
184
|
+
if (colIndex > 0) {
|
|
185
|
+
if (map[currentCellMapIndex] !== map[currentCellMapIndex - 1] && map[currentCellMapIndex] !== map[cellAboveMapIndex]) {
|
|
186
|
+
htmlColCount++;
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
if (map[currentCellMapIndex] !== map[cellAboveMapIndex]) {
|
|
190
|
+
htmlColCount++;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (htmlColCount - 1 === htmlColIndex) {
|
|
194
|
+
return colIndex;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return 0;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// When first row has merged cells, our converted column index needs to be mapped.
|
|
202
|
+
export const getColumnIndexMappedToColumnIndexInFirstRow = (convertedColIndex, htmlRowIndex, tableMap) => {
|
|
203
|
+
const width = tableMap.width;
|
|
204
|
+
const map = tableMap.map;
|
|
205
|
+
const mapColIndexToFistRowColIndex = [];
|
|
206
|
+
let htmlColCounFirstRow = 0;
|
|
207
|
+
let colSpan = 0;
|
|
208
|
+
if (htmlRowIndex === 0) {
|
|
209
|
+
return convertedColIndex;
|
|
210
|
+
}
|
|
211
|
+
for (let colIndex = 0; colIndex < width; colIndex++) {
|
|
212
|
+
if (colIndex === 0 || map[colIndex] !== map[colIndex - 1]) {
|
|
213
|
+
if (colSpan > 0) {
|
|
214
|
+
htmlColCounFirstRow += colSpan;
|
|
215
|
+
colSpan = 0;
|
|
216
|
+
}
|
|
217
|
+
htmlColCounFirstRow++;
|
|
218
|
+
} else if (map[colIndex] === map[colIndex - 1]) {
|
|
219
|
+
colSpan++;
|
|
220
|
+
}
|
|
221
|
+
mapColIndexToFistRowColIndex[colIndex] = htmlColCounFirstRow - 1;
|
|
222
|
+
}
|
|
223
|
+
return mapColIndexToFistRowColIndex[convertedColIndex];
|
|
162
224
|
};
|
|
@@ -3,7 +3,7 @@ export { findControlsHoverDecoration, createControlsHoverDecoration, createColum
|
|
|
3
3
|
export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
|
|
4
4
|
export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
|
|
5
5
|
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler } from './dom';
|
|
6
|
-
export { getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames } from './column-controls';
|
|
6
|
+
export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, getColumnIndexMappedToColumnIndexInFirstRow } from './column-controls';
|
|
7
7
|
export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow } from './row-controls';
|
|
8
8
|
export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
|
|
9
9
|
export { getMergedCellsPositions } from './table';
|
|
@@ -11,7 +11,7 @@ import { getPluginState } from './pm-plugins/plugin-factory';
|
|
|
11
11
|
import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
|
|
12
12
|
import { deleteColumns, deleteRows } from './transforms';
|
|
13
13
|
import { RESIZE_HANDLE_AREA_DECORATION_GAP } from './types';
|
|
14
|
-
import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isDragColumnFloatingInsertDot, isDragCornerButton, isDragRowFloatingInsertDot, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from './utils';
|
|
14
|
+
import { convertHTMLCellIndexToColumnIndex, getColumnIndexMappedToColumnIndexInFirstRow, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isDragColumnFloatingInsertDot, isDragCornerButton, isDragRowFloatingInsertDot, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from './utils';
|
|
15
15
|
import { getAllowAddColumnCustomStep } from './utils/get-allow-add-column-custom-step';
|
|
16
16
|
var isFocusingCalendar = function isFocusingCalendar(event) {
|
|
17
17
|
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
|
|
@@ -339,13 +339,19 @@ var trackCellLocation = function trackCellLocation(view, mouseEvent) {
|
|
|
339
339
|
if (!maybeTableCell || !tableRef) {
|
|
340
340
|
return;
|
|
341
341
|
}
|
|
342
|
-
var
|
|
342
|
+
var htmlColIndex = maybeTableCell.cellIndex;
|
|
343
343
|
var rowElement = closestElement(target, 'tr');
|
|
344
|
-
var
|
|
344
|
+
var htmlRowIndex = rowElement && rowElement.rowIndex;
|
|
345
345
|
var colHeight = tableRef.offsetHeight;
|
|
346
346
|
var colWidth = maybeTableCell.offsetWidth;
|
|
347
|
-
|
|
348
|
-
|
|
347
|
+
var tableMap = tableNode && TableMap.get(tableNode);
|
|
348
|
+
var colIndex = htmlColIndex;
|
|
349
|
+
if (tableMap) {
|
|
350
|
+
var convertedColIndex = convertHTMLCellIndexToColumnIndex(htmlColIndex, htmlRowIndex, tableMap);
|
|
351
|
+
colIndex = getColumnIndexMappedToColumnIndexInFirstRow(convertedColIndex, htmlRowIndex, tableMap);
|
|
352
|
+
}
|
|
353
|
+
if (hoveredCell.colIndex !== colIndex || hoveredCell.rowIndex !== htmlRowIndex || hoveredCell.colWidth !== colWidth || hoveredCell.colHeight !== colHeight) {
|
|
354
|
+
hoverCell(htmlRowIndex, colIndex, colWidth, colHeight)(view.state, view.dispatch);
|
|
349
355
|
}
|
|
350
356
|
};
|
|
351
357
|
export var withCellTracking = function withCellTracking(eventHandler, elementContentRects) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react';
|
|
3
1
|
import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
4
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
3
|
import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
@@ -87,7 +85,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
87
85
|
},
|
|
88
86
|
selected: false,
|
|
89
87
|
disabled: false,
|
|
90
|
-
elemAfter:
|
|
88
|
+
elemAfter: /*#__PURE__*/React.createElement("div", {
|
|
91
89
|
css: shortcutStyle
|
|
92
90
|
}, tooltip(addColumnAfter))
|
|
93
91
|
}, {
|
|
@@ -106,7 +104,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
106
104
|
},
|
|
107
105
|
selected: false,
|
|
108
106
|
disabled: false,
|
|
109
|
-
elemAfter:
|
|
107
|
+
elemAfter: /*#__PURE__*/React.createElement("div", {
|
|
110
108
|
css: shortcutStyle
|
|
111
109
|
}, tooltip(addRowAfter))
|
|
112
110
|
}, {
|
|
@@ -238,7 +236,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
238
236
|
},
|
|
239
237
|
selected: false,
|
|
240
238
|
disabled: false,
|
|
241
|
-
elemAfter:
|
|
239
|
+
elemAfter: /*#__PURE__*/React.createElement("div", {
|
|
242
240
|
css: shortcutStyle
|
|
243
241
|
}, tooltip(backspace))
|
|
244
242
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
/** @jsx jsx */
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import { jsx } from '@emotion/react';
|
|
5
3
|
import { useIntl } from 'react-intl-next';
|
|
6
4
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
5
|
import Tooltip from '@atlaskit/tooltip';
|
|
@@ -13,20 +11,20 @@ export var ColumnResizeWidget = function ColumnResizeWidget(_ref) {
|
|
|
13
11
|
var _useIntl = useIntl(),
|
|
14
12
|
formatMessage = _useIntl.formatMessage;
|
|
15
13
|
if (!includeTooltip) {
|
|
16
|
-
return
|
|
14
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
17
15
|
className: TableCssClassName.RESIZE_HANDLE_DECORATION,
|
|
18
16
|
"data-start-index": startIndex,
|
|
19
17
|
"data-end-index": endIndex
|
|
20
18
|
});
|
|
21
19
|
}
|
|
22
|
-
return
|
|
20
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
23
21
|
content: formatMessage(messages.adjustColumns),
|
|
24
22
|
hideTooltipOnClick: true,
|
|
25
23
|
hideTooltipOnMouseDown: true,
|
|
26
24
|
position: "mouse",
|
|
27
25
|
mousePosition: "auto-start"
|
|
28
26
|
}, function (tooltipProps) {
|
|
29
|
-
return
|
|
27
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
30
28
|
className: TableCssClassName.RESIZE_HANDLE_DECORATION,
|
|
31
29
|
"data-start-index": startIndex,
|
|
32
30
|
"data-end-index": endIndex
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
4
|
import classnames from 'classnames';
|
|
@@ -21,7 +22,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
21
22
|
previewHeight = _ref.previewHeight,
|
|
22
23
|
onMouseOver = _ref.onMouseOver,
|
|
23
24
|
onMouseOut = _ref.onMouseOut,
|
|
24
|
-
|
|
25
|
+
_onMouseUp = _ref.onMouseUp,
|
|
25
26
|
onClick = _ref.onClick,
|
|
26
27
|
editorView = _ref.editorView;
|
|
27
28
|
var dragHandleDivRef = useRef(null);
|
|
@@ -102,8 +103,8 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells]);
|
|
105
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
106
|
-
className: classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, isDragAndDropEnabled && hasMergedCells
|
|
106
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
107
|
+
className: classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, ClassName.CONTROLS_BUTTON, appearance, _defineProperty({}, ClassName.DRAG_HANDLE_DISABLED, isDragAndDropEnabled && hasMergedCells)),
|
|
107
108
|
ref: dragHandleDivRef,
|
|
108
109
|
style: {
|
|
109
110
|
transform: direction === 'column' ? 'none' : 'rotate(90deg)',
|
|
@@ -112,9 +113,14 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
112
113
|
"data-testid": "table-floating-column-controls-drag-handle",
|
|
113
114
|
onMouseOver: onMouseOver,
|
|
114
115
|
onMouseOut: onMouseOut,
|
|
115
|
-
onMouseUp: onMouseUp
|
|
116
|
+
onMouseUp: function onMouseUp(e) {
|
|
117
|
+
// 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
|
|
118
|
+
// -> this is bad for a11y but is the current standard new copy/paste keyboard shortcuts should be introduced instead
|
|
119
|
+
editorView.focus();
|
|
120
|
+
_onMouseUp && _onMouseUp(e);
|
|
121
|
+
},
|
|
116
122
|
onClick: onClick
|
|
117
|
-
}, /*#__PURE__*/React.createElement(HandleIconComponent, handleIconProps), previewContainer && previewWidth !== undefined && previewHeight !== undefined && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(DragPreview, {
|
|
123
|
+
}, /*#__PURE__*/React.createElement(HandleIconComponent, handleIconProps)), previewContainer && previewWidth !== undefined && previewHeight !== undefined && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(DragPreview, {
|
|
118
124
|
direction: direction,
|
|
119
125
|
width: previewWidth,
|
|
120
126
|
height: previewHeight
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
2
|
import { injectIntl } from 'react-intl-next';
|
|
5
3
|
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
6
4
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
@@ -44,7 +42,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
44
42
|
return null;
|
|
45
43
|
}
|
|
46
44
|
var labelCellOptions = formatMessage(messages.cellOptions);
|
|
47
|
-
var button =
|
|
45
|
+
var button = /*#__PURE__*/React.createElement("div", {
|
|
48
46
|
css: function css(theme) {
|
|
49
47
|
return [tableFloatingCellButtonStyles({
|
|
50
48
|
theme: theme
|
|
@@ -52,19 +50,19 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
52
50
|
theme: theme
|
|
53
51
|
})];
|
|
54
52
|
}
|
|
55
|
-
},
|
|
53
|
+
}, /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
56
54
|
className: ClassName.CONTEXTUAL_MENU_BUTTON,
|
|
57
55
|
selected: isContextualMenuOpen,
|
|
58
56
|
title: labelCellOptions,
|
|
59
57
|
onClick: handleClick,
|
|
60
|
-
iconBefore:
|
|
58
|
+
iconBefore: /*#__PURE__*/React.createElement(ExpandIcon, {
|
|
61
59
|
label: ""
|
|
62
60
|
}),
|
|
63
61
|
"aria-label": labelCellOptions
|
|
64
62
|
}));
|
|
65
63
|
var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
66
64
|
if (stickyHeader && parentSticky && tableWrapper) {
|
|
67
|
-
return
|
|
65
|
+
return /*#__PURE__*/React.createElement(FixedButton, {
|
|
68
66
|
offset: BUTTON_OFFSET,
|
|
69
67
|
stickyHeader: stickyHeader,
|
|
70
68
|
tableWrapper: tableWrapper,
|
|
@@ -74,7 +72,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
74
72
|
isContextualMenuOpen: isContextualMenuOpen
|
|
75
73
|
}, button);
|
|
76
74
|
}
|
|
77
|
-
return
|
|
75
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
78
76
|
alignX: "right",
|
|
79
77
|
alignY: "start",
|
|
80
78
|
target: targetCellRef,
|
|
@@ -89,9 +87,9 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
89
87
|
});
|
|
90
88
|
var FloatingContextualButton = injectIntl(FloatingContextualButtonInner);
|
|
91
89
|
export default function (props) {
|
|
92
|
-
return
|
|
90
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
93
91
|
component: ACTION_SUBJECT.FLOATING_CONTEXTUAL_BUTTON,
|
|
94
92
|
dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
|
|
95
93
|
fallbackComponent: null
|
|
96
|
-
},
|
|
94
|
+
}, /*#__PURE__*/React.createElement(FloatingContextualButton, props));
|
|
97
95
|
}
|
|
@@ -9,9 +9,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
9
9
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
/** @jsx jsx */
|
|
13
12
|
import { Component } from 'react';
|
|
14
|
-
import { jsx } from '@emotion/react';
|
|
15
13
|
import { injectIntl } from 'react-intl-next';
|
|
16
14
|
import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
17
15
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
@@ -82,15 +80,15 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
82
80
|
value: {
|
|
83
81
|
name: 'background'
|
|
84
82
|
},
|
|
85
|
-
elemAfter:
|
|
83
|
+
elemAfter: /*#__PURE__*/React.createElement("div", {
|
|
86
84
|
className: DropdownMenuSharedCssClassName.SUBMENU
|
|
87
|
-
},
|
|
85
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
88
86
|
css: cellColourPreviewStyles(background),
|
|
89
87
|
className: ClassName.CONTEXTUAL_MENU_ICON
|
|
90
|
-
}), isSubmenuOpen &&
|
|
88
|
+
}), isSubmenuOpen && /*#__PURE__*/React.createElement("div", {
|
|
91
89
|
className: ClassName.CONTEXTUAL_SUBMENU,
|
|
92
90
|
ref: _this.handleSubMenuRef
|
|
93
|
-
},
|
|
91
|
+
}, /*#__PURE__*/React.createElement(ColorPalette, {
|
|
94
92
|
cols: 7,
|
|
95
93
|
onClick: _this.setColor,
|
|
96
94
|
selectedColor: background,
|
|
@@ -107,7 +105,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
107
105
|
value: {
|
|
108
106
|
name: 'insert_column'
|
|
109
107
|
},
|
|
110
|
-
elemAfter:
|
|
108
|
+
elemAfter: /*#__PURE__*/React.createElement("div", {
|
|
111
109
|
css: shortcutStyle
|
|
112
110
|
}, tooltip(addColumnAfter))
|
|
113
111
|
});
|
|
@@ -116,7 +114,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
116
114
|
value: {
|
|
117
115
|
name: 'insert_row'
|
|
118
116
|
},
|
|
119
|
-
elemAfter:
|
|
117
|
+
elemAfter: /*#__PURE__*/React.createElement("div", {
|
|
120
118
|
css: shortcutStyle
|
|
121
119
|
}, tooltip(addRowAfter))
|
|
122
120
|
});
|
|
@@ -196,7 +194,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
196
194
|
value: {
|
|
197
195
|
name: 'clear'
|
|
198
196
|
},
|
|
199
|
-
elemAfter:
|
|
197
|
+
elemAfter: /*#__PURE__*/React.createElement("div", {
|
|
200
198
|
css: shortcutStyle
|
|
201
199
|
}, tooltip(backspace))
|
|
202
200
|
});
|
|
@@ -358,10 +356,10 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
358
356
|
if (!items) {
|
|
359
357
|
return null;
|
|
360
358
|
}
|
|
361
|
-
return
|
|
359
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
362
360
|
"data-testid": "table-cell-contextual-menu",
|
|
363
361
|
onMouseLeave: this.closeSubmenu
|
|
364
|
-
},
|
|
362
|
+
}, /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
365
363
|
mountTo: mountPoint
|
|
366
364
|
//This needs be removed when the a11y is completely handled
|
|
367
365
|
//Disabling key navigation now as it works only partially
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react';
|
|
3
1
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
4
2
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
3
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
@@ -34,7 +32,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
34
32
|
return null;
|
|
35
33
|
}
|
|
36
34
|
var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
37
|
-
return
|
|
35
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
38
36
|
alignX: "right",
|
|
39
37
|
alignY: "top",
|
|
40
38
|
target: targetCellRef,
|
|
@@ -50,9 +48,9 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
50
48
|
forcePlacement: true,
|
|
51
49
|
offset: [-7, 0],
|
|
52
50
|
stick: true
|
|
53
|
-
},
|
|
51
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
54
52
|
css: tablePopupStyles
|
|
55
|
-
},
|
|
53
|
+
}, /*#__PURE__*/React.createElement(ContextualMenu, {
|
|
56
54
|
editorView: editorView,
|
|
57
55
|
offset: [contextualMenuTriggerSize / 2, -contextualMenuTriggerSize],
|
|
58
56
|
isOpen: isOpen,
|