@atlaskit/editor-plugin-table 7.18.2 → 7.18.4
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/commands/column-resize.js +0 -12
- package/dist/cjs/commands/go-to-next-cell.js +8 -11
- package/dist/cjs/commands/index.js +6 -0
- package/dist/cjs/commands/misc.js +15 -1
- package/dist/cjs/commands/selection.js +4 -11
- package/dist/cjs/event-handlers.js +7 -11
- package/dist/cjs/plugin.js +7 -4
- package/dist/cjs/pm-plugins/keymap.js +22 -21
- package/dist/cjs/pm-plugins/main.js +26 -30
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +13 -21
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +8 -11
- package/dist/cjs/reducer.js +1 -0
- package/dist/cjs/ui/FloatingContextualButton/index.js +18 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +170 -35
- package/dist/cjs/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/es2019/commands/column-resize.js +0 -12
- package/dist/es2019/commands/go-to-next-cell.js +8 -11
- package/dist/es2019/commands/index.js +1 -1
- package/dist/es2019/commands/misc.js +9 -1
- package/dist/es2019/commands/selection.js +4 -11
- package/dist/es2019/event-handlers.js +8 -12
- package/dist/es2019/plugin.js +7 -4
- package/dist/es2019/pm-plugins/keymap.js +24 -23
- package/dist/es2019/pm-plugins/main.js +27 -31
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +13 -21
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +9 -12
- package/dist/es2019/reducer.js +1 -0
- package/dist/es2019/ui/FloatingContextualButton/index.js +17 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +159 -24
- package/dist/es2019/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/esm/commands/column-resize.js +0 -12
- package/dist/esm/commands/go-to-next-cell.js +8 -11
- package/dist/esm/commands/index.js +1 -1
- package/dist/esm/commands/misc.js +14 -0
- package/dist/esm/commands/selection.js +4 -11
- package/dist/esm/event-handlers.js +7 -11
- package/dist/esm/plugin.js +7 -4
- package/dist/esm/pm-plugins/keymap.js +24 -23
- package/dist/esm/pm-plugins/main.js +26 -30
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +13 -21
- package/dist/esm/pm-plugins/table-resizing/plugin.js +8 -11
- package/dist/esm/reducer.js +1 -0
- package/dist/esm/ui/FloatingContextualButton/index.js +15 -2
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +171 -40
- package/dist/esm/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/misc.d.ts +1 -0
- package/dist/types/types.d.ts +6 -0
- package/dist/types/ui/FloatingContextualButton/index.d.ts +1 -0
- package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +7 -3
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +2 -1
- package/dist/types-ts4.5/commands/index.d.ts +1 -1
- package/dist/types-ts4.5/commands/misc.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +6 -0
- package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +7 -3
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +2 -1
- package/package.json +4 -4
- package/src/commands/column-resize.ts +0 -14
- package/src/commands/go-to-next-cell.ts +7 -10
- package/src/commands/index.ts +1 -0
- package/src/commands/misc.ts +13 -0
- package/src/commands/selection.ts +4 -11
- package/src/event-handlers.ts +6 -12
- package/src/plugin.tsx +6 -1
- package/src/pm-plugins/keymap.ts +65 -62
- package/src/pm-plugins/main.ts +27 -31
- package/src/pm-plugins/table-resizing/event-handlers.ts +11 -19
- package/src/pm-plugins/table-resizing/plugin.ts +7 -10
- package/src/reducer.ts +1 -0
- package/src/types.ts +8 -1
- package/src/ui/FloatingContextualButton/index.tsx +19 -1
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +207 -30
- package/src/ui/FloatingContextualMenu/index.tsx +3 -0
|
@@ -65,9 +65,6 @@ export var initiateKeyboardColumnResizing = function initiateKeyboardColumnResiz
|
|
|
65
65
|
var ariaNotify = _ref.ariaNotify,
|
|
66
66
|
getIntl = _ref.getIntl;
|
|
67
67
|
return function (state, dispatch, view) {
|
|
68
|
-
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
68
|
var selection = state.selection;
|
|
72
69
|
var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
73
70
|
var cell = findCellClosestToPos(selection.$from);
|
|
@@ -87,9 +84,6 @@ export var activateNextResizeArea = function activateNextResizeArea(_ref2) {
|
|
|
87
84
|
ariaNotify = _ref2.ariaNotify,
|
|
88
85
|
getIntl = _ref2.getIntl;
|
|
89
86
|
return function (state, dispatch, view) {
|
|
90
|
-
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
87
|
var _ref3 = getTableResizingPluginState(state) || {},
|
|
94
88
|
resizeHandlePos = _ref3.resizeHandlePos;
|
|
95
89
|
// If No resizing has initiated, skip to regular handler
|
|
@@ -162,9 +156,6 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(_ref4) {
|
|
|
162
156
|
var fakeDispatch = function fakeDispatch(tr) {
|
|
163
157
|
customTr = tr;
|
|
164
158
|
};
|
|
165
|
-
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
159
|
var _getTableResizingPlug = getTableResizingPluginState(state),
|
|
169
160
|
resizeHandlePos = _getTableResizingPlug.resizeHandlePos;
|
|
170
161
|
var cell = findCellClosestToPos(state.selection.$from);
|
|
@@ -252,9 +243,6 @@ export var stopKeyboardColumnResizing = function stopKeyboardColumnResizing(_ref
|
|
|
252
243
|
getIntl = _ref5.getIntl,
|
|
253
244
|
originalTr = _ref5.originalTr;
|
|
254
245
|
return function (state, dispatch) {
|
|
255
|
-
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
246
|
var customTr = originalTr || state.tr;
|
|
259
247
|
var fakeDispatch = function fakeDispatch(tr) {
|
|
260
248
|
customTr = tr;
|
|
@@ -4,7 +4,6 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
4
4
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import { goToNextCell as baseGotoNextCell, findTable } from '@atlaskit/editor-tables/utils';
|
|
7
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { insertRowWithAnalytics } from '../commands-with-analytics';
|
|
9
8
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
10
9
|
import { stopKeyboardColumnResizing } from './column-resize';
|
|
@@ -13,20 +12,18 @@ var TAB_BACKWARD_DIRECTION = -1;
|
|
|
13
12
|
export var goToNextCell = function goToNextCell(editorAnalyticsAPI, ariaNotify, getIntl) {
|
|
14
13
|
return function (direction) {
|
|
15
14
|
return function (state, dispatch, view) {
|
|
15
|
+
var _getPluginState;
|
|
16
16
|
var table = findTable(state.selection);
|
|
17
17
|
if (!table) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})(state, dispatch, view);
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
20
|
+
var isColumnResizing = (_getPluginState = getPluginState(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.isKeyboardResize;
|
|
21
|
+
if (isColumnResizing) {
|
|
22
|
+
stopKeyboardColumnResizing({
|
|
23
|
+
ariaNotify: ariaNotify,
|
|
24
|
+
getIntl: getIntl
|
|
25
|
+
})(state, dispatch, view);
|
|
26
|
+
return true;
|
|
30
27
|
}
|
|
31
28
|
var map = TableMap.get(table.node);
|
|
32
29
|
var _state$schema$nodes = state.schema.nodes,
|
|
@@ -2,7 +2,7 @@ export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clear
|
|
|
2
2
|
export { insertColumn, insertRow, createTable } from './insert';
|
|
3
3
|
export { getNextLayout, toggleContextualMenu, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './toggle';
|
|
4
4
|
export { clearMultipleCells } from './clear';
|
|
5
|
-
export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, updateWidthToWidest } from './misc';
|
|
5
|
+
export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, updateWidthToWidest, setFocusToCellMenu } from './misc';
|
|
6
6
|
export { sortByColumn } from './sort';
|
|
7
7
|
export { goToNextCell } from './go-to-next-cell';
|
|
8
8
|
export { removeDescendantNodes } from './referentiality';
|
|
@@ -619,4 +619,18 @@ export var setTableAlignmentWithTableContentWithPos = function setTableAlignment
|
|
|
619
619
|
tr.setNodeMarkup(tableNodeWithPos.pos, undefined, nextTableAttrs).setMeta('scrollIntoView', false);
|
|
620
620
|
return tr;
|
|
621
621
|
};
|
|
622
|
+
};
|
|
623
|
+
export var setFocusToCellMenu = function setFocusToCellMenu() {
|
|
624
|
+
var isCellMenuOpenByKeyboard = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
625
|
+
var originalTr = arguments.length > 1 ? arguments[1] : undefined;
|
|
626
|
+
return createCommand(function () {
|
|
627
|
+
return {
|
|
628
|
+
type: 'SET_CELL_MENU_OPEN',
|
|
629
|
+
data: {
|
|
630
|
+
isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
}, function (tr) {
|
|
634
|
+
return (originalTr || tr).setMeta('addToHistory', false);
|
|
635
|
+
});
|
|
622
636
|
};
|
|
@@ -3,7 +3,6 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
5
|
import { findTable, isColumnSelected, isRowSelected, isTableSelected, selectedRect } from '@atlaskit/editor-tables/utils';
|
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
import { selectColumn, selectRow } from '../commands/misc';
|
|
8
7
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
9
8
|
import { getClosestSelectionRect } from '../toolbar';
|
|
@@ -196,11 +195,8 @@ var arrowLeftFromText = function arrowLeftFromText(editorSelectionAPI) {
|
|
|
196
195
|
var table = findTable(selection);
|
|
197
196
|
if (table) {
|
|
198
197
|
var $from = selection.$from;
|
|
199
|
-
var
|
|
200
|
-
|
|
201
|
-
var columResizePluginState = getPluginState(state) || {};
|
|
202
|
-
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
203
|
-
}
|
|
198
|
+
var columResizePluginState = getPluginState(state) || {};
|
|
199
|
+
var isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
204
200
|
if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
|
|
205
201
|
// + 3 for: row, cell & paragraph nodes
|
|
206
202
|
editorSelectionAPI && !isColumnResizing) {
|
|
@@ -230,11 +226,8 @@ var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
|
|
|
230
226
|
var table = findTable(selection);
|
|
231
227
|
if (table) {
|
|
232
228
|
var $to = selection.$to;
|
|
233
|
-
var
|
|
234
|
-
|
|
235
|
-
var columResizePluginState = getPluginState(state) || {};
|
|
236
|
-
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
237
|
-
}
|
|
229
|
+
var columResizePluginState = getPluginState(state) || {};
|
|
230
|
+
var isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
238
231
|
if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 &&
|
|
239
232
|
// + 3 for: row, cell & paragraph nodes
|
|
240
233
|
!isColumnResizing) {
|
|
@@ -190,17 +190,13 @@ export var handleMouseOut = function handleMouseOut(view, mouseEvent) {
|
|
|
190
190
|
if (isResizeHandleDecoration(target) && !isResizeHandleDecoration(relatedTarget)) {
|
|
191
191
|
var _state2 = view.state,
|
|
192
192
|
_dispatch3 = view.dispatch;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if
|
|
197
|
-
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
return hideResizeHandleLine()(_state2, _dispatch3);
|
|
201
|
-
} else {
|
|
202
|
-
return hideResizeHandleLine()(_state2, _dispatch3);
|
|
193
|
+
var _getPluginState3 = getPluginState(_state2),
|
|
194
|
+
isKeyboardResize = _getPluginState3.isKeyboardResize;
|
|
195
|
+
if (isKeyboardResize) {
|
|
196
|
+
// no need to hide decoration if column resizing started by keyboard
|
|
197
|
+
return false;
|
|
203
198
|
}
|
|
199
|
+
return hideResizeHandleLine()(_state2, _dispatch3);
|
|
204
200
|
}
|
|
205
201
|
return false;
|
|
206
202
|
};
|
|
@@ -293,7 +289,7 @@ var handleMouseMoveDebounce = rafSchedule(function (view, event, offsetX) {
|
|
|
293
289
|
var _getPluginState8 = getPluginState(_state4),
|
|
294
290
|
resizeHandleColumnIndex = _getPluginState8.resizeHandleColumnIndex,
|
|
295
291
|
resizeHandleRowIndex = _getPluginState8.resizeHandleRowIndex;
|
|
296
|
-
var isKeyboardResize =
|
|
292
|
+
var isKeyboardResize = getPluginState(_state4).isKeyboardResize;
|
|
297
293
|
var tableCell = closestElement(element, 'td, th');
|
|
298
294
|
var cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
299
295
|
var rect = findCellRectClosestToPos(_state4.doc.resolve(cellStartPosition));
|
package/dist/esm/plugin.js
CHANGED
|
@@ -349,10 +349,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
349
349
|
isHeaderColumnEnabled = _ref18.isHeaderColumnEnabled,
|
|
350
350
|
isHeaderRowEnabled = _ref18.isHeaderRowEnabled,
|
|
351
351
|
isDragAndDropEnabled = _ref18.isDragAndDropEnabled,
|
|
352
|
-
tableWrapperTarget = _ref18.tableWrapperTarget
|
|
352
|
+
tableWrapperTarget = _ref18.tableWrapperTarget,
|
|
353
|
+
isCellMenuOpenByKeyboard = _ref18.isCellMenuOpenByKeyboard;
|
|
353
354
|
var allowControls = pluginConfig.allowControls;
|
|
354
355
|
var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
355
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
356
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || getBooleanFF('platform.editor.a11y-table-context-menu_y4c9c') && isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
356
357
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
357
358
|
editorView: editorView,
|
|
358
359
|
tableNode: tableNode,
|
|
@@ -362,7 +363,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
362
363
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
363
364
|
isContextualMenuOpen: isContextualMenuOpen,
|
|
364
365
|
stickyHeader: stickyHeader,
|
|
365
|
-
tableWrapper: tableWrapperTarget
|
|
366
|
+
tableWrapper: tableWrapperTarget,
|
|
367
|
+
isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard
|
|
366
368
|
}), allowControls && /*#__PURE__*/React.createElement(FloatingInsertButton, {
|
|
367
369
|
tableNode: tableNode,
|
|
368
370
|
tableRef: tableRef,
|
|
@@ -390,7 +392,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
390
392
|
pluginConfig: pluginConfig,
|
|
391
393
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
392
394
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
393
|
-
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
395
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
|
|
396
|
+
isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard
|
|
394
397
|
}), isDragAndDropEnabled && /*#__PURE__*/React.createElement(FloatingDragMenu, {
|
|
395
398
|
editorView: editorView,
|
|
396
399
|
mountPoint: popupsMountPoint,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { addColumnAfter, addColumnAfterVO, addColumnBefore, addColumnBeforeVO, addRowAfter, addRowAfterVO, addRowBefore, addRowBeforeVO, backspace, bindKeymapWithCommand, decreaseMediaSize, deleteColumn, deleteRow, escape, increaseMediaSize, moveColumnLeft, moveColumnRight, moveLeft, moveRight, moveRowDown, moveRowUp, nextCell, previousCell, startColumnResizing, toggleTable } from '@atlaskit/editor-common/keymaps';
|
|
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
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
|
-
import { goToNextCell, moveCursorBackward } from '../commands';
|
|
6
|
+
import { goToNextCell, moveCursorBackward, setFocusToCellMenu } from '../commands';
|
|
7
7
|
import { addRowAroundSelection, changeColumnWidthByStepWithAnalytics, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut, deleteTableIfSelectedWithAnalytics, emptyMultipleCellsWithAnalytics } from '../commands-with-analytics';
|
|
8
8
|
import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
9
9
|
import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand, createTable } from '../commands/insert';
|
|
@@ -55,27 +55,28 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
55
55
|
bindKeymapWithCommand(deleteColumn.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
56
56
|
bindKeymapWithCommand(deleteRow.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
58
|
+
bindKeymapWithCommand(startColumnResizing.common, initiateKeyboardColumnResizing({
|
|
59
|
+
ariaNotify: ariaNotifyPlugin,
|
|
60
|
+
getIntl: getIntl
|
|
61
|
+
}), list);
|
|
62
|
+
bindKeymapWithCommand(moveRight.common, activateNextResizeArea({
|
|
63
|
+
direction: 1,
|
|
64
|
+
ariaNotify: ariaNotifyPlugin,
|
|
65
|
+
getIntl: getIntl
|
|
66
|
+
}), list);
|
|
67
|
+
bindKeymapWithCommand(moveLeft.common, activateNextResizeArea({
|
|
68
|
+
direction: -1,
|
|
69
|
+
ariaNotify: ariaNotifyPlugin,
|
|
70
|
+
getIntl: getIntl
|
|
71
|
+
}), list);
|
|
72
|
+
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(-10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
73
|
+
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
74
|
+
bindKeymapWithCommand(escape.common, stopKeyboardColumnResizing({
|
|
75
|
+
ariaNotify: ariaNotifyPlugin,
|
|
76
|
+
getIntl: getIntl
|
|
77
|
+
}), list);
|
|
78
|
+
if (getBooleanFF('platform.editor.a11y-table-context-menu_y4c9c')) {
|
|
79
|
+
bindKeymapWithCommand(focusToContextMenuTrigger.common, setFocusToCellMenu(), list);
|
|
79
80
|
}
|
|
80
81
|
return keymap(list);
|
|
81
82
|
}
|
|
@@ -110,31 +110,29 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
110
110
|
tableRef = parent.querySelector('table') || undefined;
|
|
111
111
|
}
|
|
112
112
|
var tableNode = findTable(state.selection);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// Jump to another table
|
|
126
|
-
stopKeyboardColumnResizing({
|
|
127
|
-
ariaNotify: ariaNotifyPlugin,
|
|
128
|
-
getIntl: getIntl
|
|
129
|
-
})(state, dispatch);
|
|
130
|
-
}
|
|
131
|
-
} else if (!tableNode) {
|
|
132
|
-
// selection outside of table
|
|
113
|
+
// when keyboard cursor leaves the table we need to stop column resizing
|
|
114
|
+
var pluginPrevState = getPluginState(prevState);
|
|
115
|
+
var isStopKeyboardColumResizing = pluginPrevState.isResizeHandleWidgetAdded && pluginPrevState.isKeyboardResize;
|
|
116
|
+
if (isStopKeyboardColumResizing) {
|
|
117
|
+
var isTableNodesDifferent = (pluginPrevState === null || pluginPrevState === void 0 ? void 0 : pluginPrevState.tableNode) !== (tableNode === null || tableNode === void 0 ? void 0 : tableNode.node);
|
|
118
|
+
if (pluginPrevState !== null && pluginPrevState !== void 0 && pluginPrevState.tableNode && tableNode && isTableNodesDifferent) {
|
|
119
|
+
var oldRowsNumber = TableMap.get(pluginPrevState.tableNode).height;
|
|
120
|
+
var newRowsNumber = TableMap.get(tableNode.node).height;
|
|
121
|
+
if (oldRowsNumber !== newRowsNumber ||
|
|
122
|
+
// Add/delete row
|
|
123
|
+
tableNode.node.attrs.localId !== pluginPrevState.tableNode.attrs.localId) {
|
|
124
|
+
// Jump to another table
|
|
133
125
|
stopKeyboardColumnResizing({
|
|
134
126
|
ariaNotify: ariaNotifyPlugin,
|
|
135
127
|
getIntl: getIntl
|
|
136
128
|
})(state, dispatch);
|
|
137
129
|
}
|
|
130
|
+
} else if (!tableNode) {
|
|
131
|
+
// selection outside of table
|
|
132
|
+
stopKeyboardColumnResizing({
|
|
133
|
+
ariaNotify: ariaNotifyPlugin,
|
|
134
|
+
getIntl: getIntl
|
|
135
|
+
})(state, dispatch);
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
138
|
}
|
|
@@ -236,16 +234,14 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
236
234
|
handleTextInput: function handleTextInput(view, _from, _to, text) {
|
|
237
235
|
var state = view.state,
|
|
238
236
|
dispatch = view.dispatch;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
237
|
+
var _getPluginState = getPluginState(state),
|
|
238
|
+
isKeyboardResize = _getPluginState.isKeyboardResize;
|
|
239
|
+
if (isKeyboardResize) {
|
|
240
|
+
stopKeyboardColumnResizing({
|
|
241
|
+
ariaNotify: ariaNotifyPlugin,
|
|
242
|
+
getIntl: getIntl
|
|
243
|
+
})(state, dispatch);
|
|
244
|
+
return false;
|
|
249
245
|
}
|
|
250
246
|
var tr = replaceSelectedTable(state, text, INPUT_METHOD.KEYBOARD, editorAnalyticsAPI);
|
|
251
247
|
if (tr.selectionSet) {
|
|
@@ -109,15 +109,11 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
109
109
|
|
|
110
110
|
// If we let go in the same place we started, don't need to do anything.
|
|
111
111
|
if (dragging && clientX === dragging.startX) {
|
|
112
|
-
if (
|
|
113
|
-
if
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return stopKeyboardColumnResizing({})(state, dispatch, view);
|
|
118
|
-
} else {
|
|
119
|
-
return stopResizing()(state, dispatch);
|
|
120
|
-
}
|
|
112
|
+
if (isKeyboardResize || !isTableHovered) {
|
|
113
|
+
/** if column resize had started via keyboard but continued by mouse
|
|
114
|
+
* or mouse pointer leaves the table but mouse button still pressed
|
|
115
|
+
*/
|
|
116
|
+
return stopKeyboardColumnResizing({})(state, dispatch, view);
|
|
121
117
|
} else {
|
|
122
118
|
return stopResizing()(state, dispatch);
|
|
123
119
|
}
|
|
@@ -184,17 +180,13 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
184
180
|
}
|
|
185
181
|
})(tr);
|
|
186
182
|
}
|
|
187
|
-
if (
|
|
188
|
-
if
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
})(state, dispatch, view);
|
|
195
|
-
} else {
|
|
196
|
-
return stopResizing(tr)(state, dispatch);
|
|
197
|
-
}
|
|
183
|
+
if (isKeyboardResize || !isTableHovered) {
|
|
184
|
+
/** if column resize had started via keyboard but continued by mouse
|
|
185
|
+
* or mouse pointer leaves the table but mouse button still pressed
|
|
186
|
+
*/
|
|
187
|
+
return stopKeyboardColumnResizing({
|
|
188
|
+
originalTr: tr
|
|
189
|
+
})(state, dispatch, view);
|
|
198
190
|
} else {
|
|
199
191
|
return stopResizing(tr)(state, dispatch);
|
|
200
192
|
}
|
|
@@ -209,7 +201,7 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
209
201
|
resizeHandlePos = _getPluginState2.resizeHandlePos;
|
|
210
202
|
var _getTablePluginState3 = getTablePluginState(state),
|
|
211
203
|
isTableHovered = _getTablePluginState3.isTableHovered;
|
|
212
|
-
if (!which || !dragging || resizeHandlePos === null || !pointsAtCell(state.doc.resolve(resizeHandlePos)) || !isTableHovered
|
|
204
|
+
if (!which || !dragging || resizeHandlePos === null || !pointsAtCell(state.doc.resolve(resizeHandlePos)) || !isTableHovered) {
|
|
213
205
|
return finish(event);
|
|
214
206
|
}
|
|
215
207
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { TableCssClassName as ClassName } from '../../types';
|
|
6
5
|
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
7
6
|
import { setResizeHandlePos } from './commands';
|
|
@@ -37,16 +36,14 @@ export function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorF
|
|
|
37
36
|
var _getPluginState = getPluginState(state),
|
|
38
37
|
dragging = _getPluginState.dragging;
|
|
39
38
|
var isColumnKeyboardResizeStarted = false;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
isColumnKeyboardResizeStarted = isKeyboardResize;
|
|
49
|
-
}
|
|
39
|
+
/*
|
|
40
|
+
We need to start listening mouse events if column resize started from keyboard.
|
|
41
|
+
This will allow continue resizing via mouse
|
|
42
|
+
*/
|
|
43
|
+
var _getTablePluginState = getTablePluginState(state),
|
|
44
|
+
isKeyboardResize = _getTablePluginState.isKeyboardResize;
|
|
45
|
+
if (isKeyboardResize) {
|
|
46
|
+
isColumnKeyboardResizeStarted = isKeyboardResize;
|
|
50
47
|
}
|
|
51
48
|
if (resizeHandlePos !== null && (!dragging || isColumnKeyboardResizeStarted)) {
|
|
52
49
|
if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled || false, editorAnalyticsAPI, isNewColumnResizingEnabled)) {
|
package/dist/esm/reducer.js
CHANGED
|
@@ -95,6 +95,7 @@ export default (function (pluginState, action) {
|
|
|
95
95
|
case 'HOVER_CELL':
|
|
96
96
|
case 'SHOW_RESIZE_HANDLE_LINE':
|
|
97
97
|
case 'SET_EDITOR_FOCUS':
|
|
98
|
+
case 'SET_CELL_MENU_OPEN':
|
|
98
99
|
return _objectSpread(_objectSpread({}, pluginState), action.data);
|
|
99
100
|
default:
|
|
100
101
|
return pluginState;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
@@ -12,6 +12,7 @@ import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
|
12
12
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
13
13
|
import { akEditorSmallZIndex } from '@atlaskit/editor-shared-styles';
|
|
14
14
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
15
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
15
16
|
import { toggleContextualMenu } from '../../commands';
|
|
16
17
|
import { TableCssClassName as ClassName } from '../../types';
|
|
17
18
|
import FixedButton from './FixedButton';
|
|
@@ -25,6 +26,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
25
26
|
stickyHeader = props.stickyHeader,
|
|
26
27
|
tableWrapper = props.tableWrapper,
|
|
27
28
|
targetCellPosition = props.targetCellPosition,
|
|
29
|
+
isCellMenuOpenByKeyboard = props.isCellMenuOpenByKeyboard,
|
|
28
30
|
formatMessage = props.intl.formatMessage; // : Props & WrappedComponentProps
|
|
29
31
|
|
|
30
32
|
var handleClick = function handleClick() {
|
|
@@ -42,6 +44,16 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
42
44
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
43
45
|
var targetCellRef;
|
|
44
46
|
targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
if (getBooleanFF('platform.editor.a11y-table-context-menu_y4c9c')) {
|
|
49
|
+
if (isCellMenuOpenByKeyboard && !isContextualMenuOpen) {
|
|
50
|
+
var state = editorView.state,
|
|
51
|
+
dispatch = editorView.dispatch;
|
|
52
|
+
// open the menu when the keyboard shortcut is pressed
|
|
53
|
+
toggleContextualMenu()(state, dispatch);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, [isCellMenuOpenByKeyboard, isContextualMenuOpen, editorView]);
|
|
45
57
|
if (!targetCellRef || !(targetCellRef instanceof HTMLElement)) {
|
|
46
58
|
return null;
|
|
47
59
|
}
|
|
@@ -62,7 +74,8 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
62
74
|
iconBefore: jsx(ExpandIcon, {
|
|
63
75
|
label: ""
|
|
64
76
|
}),
|
|
65
|
-
"aria-label": labelCellOptions
|
|
77
|
+
"aria-label": labelCellOptions,
|
|
78
|
+
"aria-expanded": getBooleanFF('platform.editor.a11y-table-context-menu_y4c9c') ? isContextualMenuOpen : undefined
|
|
66
79
|
}));
|
|
67
80
|
var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
68
81
|
if (stickyHeader && parentSticky && tableWrapper) {
|