@atlaskit/editor-plugin-table 7.19.11 → 7.20.0
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 +28 -0
- package/dist/cjs/commands/column-resize.js +1 -1
- package/dist/cjs/commands/selection.js +25 -4
- package/dist/cjs/nodeviews/table.js +2 -4
- package/dist/cjs/plugin.js +59 -56
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +23 -9
- package/dist/cjs/pm-plugins/keymap.js +6 -6
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/pm-plugins/table-selection-keymap.js +6 -3
- package/dist/cjs/toolbar.js +8 -5
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +5 -3
- package/dist/cjs/ui/TableFloatingControls/index.js +8 -2
- package/dist/cjs/utils/drag-menu.js +5 -1
- package/dist/es2019/commands/column-resize.js +2 -2
- package/dist/es2019/commands/selection.js +25 -4
- package/dist/es2019/nodeviews/table.js +3 -5
- package/dist/es2019/plugin.js +11 -7
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +18 -3
- package/dist/es2019/pm-plugins/keymap.js +7 -7
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/es2019/pm-plugins/table-selection-keymap.js +6 -3
- package/dist/es2019/toolbar.js +8 -5
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +6 -4
- package/dist/es2019/ui/TableFloatingControls/index.js +9 -3
- package/dist/es2019/utils/drag-menu.js +6 -2
- package/dist/esm/commands/column-resize.js +2 -2
- package/dist/esm/commands/selection.js +25 -4
- package/dist/esm/nodeviews/table.js +3 -5
- package/dist/esm/plugin.js +60 -57
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +23 -9
- package/dist/esm/pm-plugins/keymap.js +7 -7
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/esm/pm-plugins/table-selection-keymap.js +6 -3
- package/dist/esm/toolbar.js +8 -5
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +6 -4
- package/dist/esm/ui/TableFloatingControls/index.js +9 -3
- package/dist/esm/utils/drag-menu.js +5 -1
- package/dist/types/commands/selection.d.ts +4 -2
- package/dist/types/nodeviews/table.d.ts +1 -2
- package/dist/types/nodeviews/types.d.ts +1 -3
- package/dist/types/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +4 -2
- package/dist/types/pm-plugins/main.d.ts +1 -2
- package/dist/types/pm-plugins/table-selection-keymap.d.ts +3 -3
- package/dist/types/toolbar.d.ts +2 -2
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +3 -1
- package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types/utils/drag-menu.d.ts +2 -1
- package/dist/types-ts4.5/commands/selection.d.ts +4 -2
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -2
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -3
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +4 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -2
- package/dist/types-ts4.5/pm-plugins/table-selection-keymap.d.ts +3 -3
- package/dist/types-ts4.5/toolbar.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +3 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types-ts4.5/utils/drag-menu.d.ts +2 -1
- package/package.json +8 -5
- package/src/commands/column-resize.ts +2 -2
- package/src/commands/selection.ts +49 -4
- package/src/nodeviews/table.tsx +3 -10
- package/src/nodeviews/types.ts +1 -3
- package/src/plugin.tsx +8 -7
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +43 -3
- package/src/pm-plugins/keymap.ts +23 -7
- package/src/pm-plugins/main.ts +3 -4
- package/src/pm-plugins/table-selection-keymap.ts +18 -6
- package/src/toolbar.tsx +7 -1
- package/src/ui/FloatingDragMenu/DragMenu.tsx +7 -0
- package/src/ui/FloatingDragMenu/index.tsx +9 -2
- package/src/ui/TableFloatingControls/index.tsx +12 -4
- package/src/utils/drag-menu.ts +8 -1
|
@@ -9,9 +9,11 @@ exports.default = exports.TableFloatingControls = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
11
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
|
+
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
12
13
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _commands = require("../../commands");
|
|
14
15
|
var _types = require("../../types");
|
|
16
|
+
var _nodes = require("../../utils/nodes");
|
|
15
17
|
var _CornerControls = require("./CornerControls");
|
|
16
18
|
var _FloatingControlsWithSelection = require("./FloatingControlsWithSelection");
|
|
17
19
|
var _NumberColumn = _interopRequireDefault(require("./NumberColumn"));
|
|
@@ -19,6 +21,7 @@ var _RowControls = require("./RowControls");
|
|
|
19
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
23
|
var TableFloatingControls = exports.TableFloatingControls = function TableFloatingControls(_ref) {
|
|
24
|
+
var _findTable;
|
|
22
25
|
var editorView = _ref.editorView,
|
|
23
26
|
tableRef = _ref.tableRef,
|
|
24
27
|
tableNode = _ref.tableNode,
|
|
@@ -79,6 +82,9 @@ var TableFloatingControls = exports.TableFloatingControls = function TableFloati
|
|
|
79
82
|
}
|
|
80
83
|
var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
|
|
81
84
|
var wrapperClassName = isDragAndDropEnabled ? _types.TableCssClassName.DRAG_ROW_CONTROLS_WRAPPER : _types.TableCssClassName.ROW_CONTROLS_WRAPPER;
|
|
85
|
+
var tablePos = (_findTable = (0, _utils2.findTable)(editorView.state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos;
|
|
86
|
+
var isNested = tablePos !== undefined && (0, _nodes.isTableNested)(editorView.state, tablePos);
|
|
87
|
+
var shouldShowCornerControls = (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24041') ? !(featureFlagsState !== null && featureFlagsState !== void 0 && featureFlagsState.elementDragAndDrop) || isNested : !(featureFlagsState !== null && featureFlagsState !== void 0 && featureFlagsState.elementDragAndDrop);
|
|
82
88
|
return (
|
|
83
89
|
/*#__PURE__*/
|
|
84
90
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -101,7 +107,7 @@ var TableFloatingControls = exports.TableFloatingControls = function TableFloati
|
|
|
101
107
|
updateCellHoverLocation: updateCellHoverLocation,
|
|
102
108
|
stickyTop: stickyTop,
|
|
103
109
|
isDragAndDropEnabled: isDragAndDropEnabled
|
|
104
|
-
}) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null,
|
|
110
|
+
}) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, shouldShowCornerControls && ((0, _platformFeatureFlags.fg)('platform.editor.table.use-shared-state-hook') ? /*#__PURE__*/_react.default.createElement(_CornerControls.DragCornerControlsWithSelection, {
|
|
105
111
|
editorView: editorView,
|
|
106
112
|
tableRef: tableRef,
|
|
107
113
|
isInDanger: isInDanger,
|
|
@@ -126,7 +132,7 @@ var TableFloatingControls = exports.TableFloatingControls = function TableFloati
|
|
|
126
132
|
selectRow: _selectRow,
|
|
127
133
|
selectRows: _selectRows,
|
|
128
134
|
updateCellHoverLocation: updateCellHoverLocation
|
|
129
|
-
})) : (0, _platformFeatureFlags.
|
|
135
|
+
})) : (0, _platformFeatureFlags.fg)('platform.editor.table.use-shared-state-hook') ? /*#__PURE__*/_react.default.createElement(_FloatingControlsWithSelection.FloatingControlsWithSelection, {
|
|
130
136
|
editorView: editorView,
|
|
131
137
|
tableRef: tableRef,
|
|
132
138
|
isInDanger: isInDanger,
|
|
@@ -20,6 +20,7 @@ var _chevronDoubleDown = _interopRequireDefault(require("@atlaskit/icon/glyph/hi
|
|
|
20
20
|
var _chevronDoubleUp = _interopRequireDefault(require("@atlaskit/icon/glyph/hipchat/chevron-double-up"));
|
|
21
21
|
var _commandsWithAnalytics = require("../commands-with-analytics");
|
|
22
22
|
var _commandsWithAnalytics2 = require("../pm-plugins/drag-and-drop/commands-with-analytics");
|
|
23
|
+
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
23
24
|
var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
|
|
24
25
|
var _toolbar = require("../toolbar");
|
|
25
26
|
var _icons = require("../ui/icons");
|
|
@@ -74,7 +75,10 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
74
75
|
var isTableFixedColumnWidthsOptionEnabled = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : false;
|
|
75
76
|
var shouldUseIncreasedScalingPercent = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : false;
|
|
76
77
|
var tableSortColumnReorder = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : false;
|
|
78
|
+
var ariaNotifyPlugin = arguments.length > 15 ? arguments[15] : undefined;
|
|
77
79
|
var selection = editorView.state.selection;
|
|
80
|
+
var _getTablePluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
81
|
+
getIntl = _getTablePluginState.getIntl;
|
|
78
82
|
var addOptions = direction === 'row' ? [{
|
|
79
83
|
label: 'above',
|
|
80
84
|
offset: 0,
|
|
@@ -233,7 +237,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
233
237
|
onClick: function onClick(state, dispatch) {
|
|
234
238
|
if (canMove) {
|
|
235
239
|
requestAnimationFrame(function () {
|
|
236
|
-
(0, _commandsWithAnalytics2.moveSourceWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, "table-".concat(direction), getOriginIndexes(selectionRect), getTargetIndex(selectionRect))(editorView.state, editorView.dispatch);
|
|
240
|
+
(0, _commandsWithAnalytics2.moveSourceWithAnalytics)(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, "table-".concat(direction), getOriginIndexes(selectionRect), getTargetIndex(selectionRect))(editorView.state, editorView.dispatch);
|
|
237
241
|
});
|
|
238
242
|
return true;
|
|
239
243
|
}
|
|
@@ -2,7 +2,7 @@ import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
|
2
2
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { TableMap } from '@atlaskit/editor-tables';
|
|
4
4
|
import { findCellClosestToPos, findCellRectClosestToPos, findTableClosestToPos, getSelectionRect, isSelectionType, nextCell } from '@atlaskit/editor-tables/utils';
|
|
5
|
-
import {
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { getDecorations } from '../pm-plugins/decorations/plugin';
|
|
7
7
|
import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../pm-plugins/decorations/utils';
|
|
8
8
|
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -198,7 +198,7 @@ export const changeColumnWidthByStep = ({
|
|
|
198
198
|
if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
|
|
199
199
|
isTableScalingEnabledOnCurrentTable = originalTable.attrs.displayMode !== 'fixed';
|
|
200
200
|
}
|
|
201
|
-
const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled &&
|
|
201
|
+
const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && fg('platform.editor.table.use-increased-scaling-percent');
|
|
202
202
|
const initialResizeState = getResizeState({
|
|
203
203
|
minWidth: tableCellMinWidth,
|
|
204
204
|
maxSize,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
1
2
|
import { GapCursorSelection, isSelectionAtEndOfNode, isSelectionAtStartOfNode, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
|
|
2
3
|
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
@@ -68,7 +69,7 @@ const arrowRightFromCellSelection = editorSelectionAPI => selection => (state, d
|
|
|
68
69
|
}
|
|
69
70
|
return false;
|
|
70
71
|
};
|
|
71
|
-
export const selectColumns = editorSelectionAPI => (triggeredByKeyboard = false) => (state, dispatch) => {
|
|
72
|
+
export const selectColumns = (editorSelectionAPI, ariaNotify, getIntl) => (triggeredByKeyboard = false) => (state, dispatch) => {
|
|
72
73
|
const {
|
|
73
74
|
selection
|
|
74
75
|
} = state;
|
|
@@ -82,11 +83,21 @@ export const selectColumns = editorSelectionAPI => (triggeredByKeyboard = false)
|
|
|
82
83
|
})(state, dispatch);
|
|
83
84
|
}
|
|
84
85
|
if (table && rect) {
|
|
85
|
-
|
|
86
|
+
const selectColumnCommand = selectColumn(rect.left, undefined, triggeredByKeyboard)(state, dispatch);
|
|
87
|
+
const map = TableMap.get(table.node);
|
|
88
|
+
if (ariaNotify && getIntl) {
|
|
89
|
+
ariaNotify(getIntl().formatMessage(messages.columnSelected, {
|
|
90
|
+
index: rect.left + 1,
|
|
91
|
+
total: map.width
|
|
92
|
+
}), {
|
|
93
|
+
priority: 'important'
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return selectColumnCommand;
|
|
86
97
|
}
|
|
87
98
|
return false;
|
|
88
99
|
};
|
|
89
|
-
export const selectRows = editorSelectionAPI => (triggeredByKeyboard = false) => (state, dispatch) => {
|
|
100
|
+
export const selectRows = (editorSelectionAPI, ariaNotify, getIntl) => (triggeredByKeyboard = false) => (state, dispatch) => {
|
|
90
101
|
const {
|
|
91
102
|
selection
|
|
92
103
|
} = state;
|
|
@@ -100,7 +111,17 @@ export const selectRows = editorSelectionAPI => (triggeredByKeyboard = false) =>
|
|
|
100
111
|
})(state, dispatch);
|
|
101
112
|
}
|
|
102
113
|
if (table && rect) {
|
|
103
|
-
|
|
114
|
+
const selectRowCommand = selectRow(rect.top, undefined, triggeredByKeyboard)(state, dispatch);
|
|
115
|
+
const map = TableMap.get(table.node);
|
|
116
|
+
if (ariaNotify && getIntl) {
|
|
117
|
+
ariaNotify(getIntl().formatMessage(messages.rowSelected, {
|
|
118
|
+
index: rect.top + 1,
|
|
119
|
+
total: map.height
|
|
120
|
+
}), {
|
|
121
|
+
priority: 'important'
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return selectRowCommand;
|
|
104
125
|
}
|
|
105
126
|
return false;
|
|
106
127
|
};
|
|
@@ -6,7 +6,7 @@ import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
|
6
6
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
7
7
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
8
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
|
-
import {
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { pluginConfig as getPluginConfig } from '../create-plugin-config';
|
|
11
11
|
import { pluginKey as tableDragAndDropPluginKey } from '../pm-plugins/drag-and-drop';
|
|
12
12
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -53,7 +53,7 @@ const toDOM = (node, props) => {
|
|
|
53
53
|
};
|
|
54
54
|
export default class TableView extends ReactNodeView {
|
|
55
55
|
constructor(props) {
|
|
56
|
-
super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props
|
|
56
|
+
super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
|
|
57
57
|
_defineProperty(this, "getNode", () => {
|
|
58
58
|
return this.node;
|
|
59
59
|
});
|
|
@@ -99,7 +99,7 @@ export default class TableView extends ReactNodeView {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
render(props, forwardRef) {
|
|
102
|
-
if (
|
|
102
|
+
if (fg('platform.editor.table.use-shared-state-hook')) {
|
|
103
103
|
return /*#__PURE__*/React.createElement(TableComponentWithSharedState, {
|
|
104
104
|
forwardRef: forwardRef,
|
|
105
105
|
getNode: this.getNode,
|
|
@@ -264,7 +264,6 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
264
264
|
allowColumnResizing,
|
|
265
265
|
allowControls
|
|
266
266
|
} = getPluginConfig(pluginConfig);
|
|
267
|
-
const hasIntlContext = true;
|
|
268
267
|
return new TableView({
|
|
269
268
|
node,
|
|
270
269
|
view,
|
|
@@ -285,7 +284,6 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
285
284
|
getEditorContainerWidth,
|
|
286
285
|
getEditorFeatureFlags,
|
|
287
286
|
dispatchAnalyticsEvent,
|
|
288
|
-
hasIntlContext,
|
|
289
287
|
pluginInjectionApi
|
|
290
288
|
}).init();
|
|
291
289
|
};
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -10,7 +10,7 @@ import { browser } from '@atlaskit/editor-common/utils';
|
|
|
10
10
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
11
11
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
12
12
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
13
|
-
import {
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
14
|
import { insertTableWithSize } from './commands/insert';
|
|
15
15
|
import { pluginConfig } from './create-plugin-config';
|
|
16
16
|
import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analytics/plugin';
|
|
@@ -50,7 +50,7 @@ const tablesPlugin = ({
|
|
|
50
50
|
config: options,
|
|
51
51
|
api
|
|
52
52
|
}) => {
|
|
53
|
-
var _api$analytics, _options$getEditorFea, _options$getEditorFea2, _api$analytics2;
|
|
53
|
+
var _api$analytics, _api$accessibilityUti, _options$getEditorFea, _options$getEditorFea2, _api$analytics2;
|
|
54
54
|
const editorViewRef = {
|
|
55
55
|
current: null
|
|
56
56
|
};
|
|
@@ -61,8 +61,9 @@ const tablesPlugin = ({
|
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
63
|
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
64
|
+
const ariaNotifyPlugin = api === null || api === void 0 ? void 0 : (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify;
|
|
64
65
|
const isTableFixedColumnWidthsOptionEnabled = (options === null || options === void 0 ? void 0 : (_options$getEditorFea = options.getEditorFeatureFlags) === null || _options$getEditorFea === void 0 ? void 0 : _options$getEditorFea.call(options).tableWithFixedColumnWidthsOption) || false;
|
|
65
|
-
const shouldUseIncreasedScalingPercent = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && isTableFixedColumnWidthsOptionEnabled &&
|
|
66
|
+
const shouldUseIncreasedScalingPercent = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && isTableFixedColumnWidthsOptionEnabled && fg('platform.editor.table.use-increased-scaling-percent');
|
|
66
67
|
const isCellBackgroundDuplicated = (options === null || options === void 0 ? void 0 : (_options$getEditorFea2 = options.getEditorFeatureFlags) === null || _options$getEditorFea2 === void 0 ? void 0 : _options$getEditorFea2.call(options).tableDuplicateCellColouring) || false;
|
|
67
68
|
return {
|
|
68
69
|
name: 'table',
|
|
@@ -200,7 +201,9 @@ const tablesPlugin = ({
|
|
|
200
201
|
}
|
|
201
202
|
}, {
|
|
202
203
|
name: 'tableSelectionKeymap',
|
|
203
|
-
plugin: (
|
|
204
|
+
plugin: ({
|
|
205
|
+
getIntl
|
|
206
|
+
}) => tableSelectionKeymapPlugin(api, getIntl)
|
|
204
207
|
}, {
|
|
205
208
|
name: 'tableEditing',
|
|
206
209
|
plugin: () => {
|
|
@@ -241,7 +244,7 @@ const tablesPlugin = ({
|
|
|
241
244
|
}, {
|
|
242
245
|
name: 'tableViewModeSort',
|
|
243
246
|
plugin: () => {
|
|
244
|
-
return
|
|
247
|
+
return api !== null && api !== void 0 && api.editorViewMode && fg('platform.editor.table.live-pages-sorting_4malx') ? createViewModeSortPlugin(api.editorViewMode) : undefined;
|
|
245
248
|
}
|
|
246
249
|
}, {
|
|
247
250
|
name: 'tableLocalId',
|
|
@@ -354,7 +357,7 @@ const tablesPlugin = ({
|
|
|
354
357
|
allowControls
|
|
355
358
|
} = pluginConfig;
|
|
356
359
|
const stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
357
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef ||
|
|
360
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard && fg('platform.editor.a11y-table-context-menu_y4c9c')) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
358
361
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
359
362
|
editorView: editorView,
|
|
360
363
|
tableNode: tableNode,
|
|
@@ -410,7 +413,8 @@ const tablesPlugin = ({
|
|
|
410
413
|
stickyHeaders: stickyHeader,
|
|
411
414
|
pluginConfig: pluginConfig,
|
|
412
415
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
413
|
-
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
416
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
|
|
417
|
+
ariaNotifyPlugin: ariaNotifyPlugin
|
|
414
418
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
415
419
|
editorView: editorView,
|
|
416
420
|
selection: editorView.state.selection,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_STATUS } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
2
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
3
4
|
import { findCellRectClosestToPos, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
4
5
|
import { getSelectedColumnIndexes, getSelectedRowIndexes, getSelectedTableInfo } from '../../utils';
|
|
@@ -35,7 +36,7 @@ export const clearDropTargetWithAnalytics = editorAnalyticsAPI => (inputMethod,
|
|
|
35
36
|
return true;
|
|
36
37
|
});
|
|
37
38
|
};
|
|
38
|
-
export const moveSourceWithAnalytics = editorAnalyticsAPI => (inputMethod, sourceType, sourceIndexes, targetIndex, tr) => {
|
|
39
|
+
export const moveSourceWithAnalytics = (editorAnalyticsAPI, ariaNotify, getIntl) => (inputMethod, sourceType, sourceIndexes, targetIndex, tr) => {
|
|
39
40
|
return withEditorAnalyticsAPI(({
|
|
40
41
|
selection
|
|
41
42
|
}) => {
|
|
@@ -64,11 +65,25 @@ export const moveSourceWithAnalytics = editorAnalyticsAPI => (inputMethod, sourc
|
|
|
64
65
|
})(editorAnalyticsAPI)((state, dispatch) => {
|
|
65
66
|
if (dispatch) {
|
|
66
67
|
moveSource(sourceType, sourceIndexes, targetIndex, tr)(state, dispatch);
|
|
68
|
+
// Only considering single row/column movement for screen reader as only single row/column selection is supported via keyboard atm.
|
|
69
|
+
if ((inputMethod === INPUT_METHOD.TABLE_CONTEXT_MENU || INPUT_METHOD.SHORTCUT) && sourceIndexes.length === 1 && ariaNotify && getIntl) {
|
|
70
|
+
const direction = sourceIndexes[0] > targetIndex ? -1 : 1; // -1 for left/up , 1 for right/down
|
|
71
|
+
const {
|
|
72
|
+
totalRowCount,
|
|
73
|
+
totalColumnCount
|
|
74
|
+
} = getSelectedTableInfo(state.selection);
|
|
75
|
+
ariaNotify(getIntl().formatMessage(sourceType === 'table-row' ? direction > 0 ? messages.rowMovedDown : messages.rowMovedUp : direction > 0 ? messages.columnMovedRight : messages.columnMovedLeft, {
|
|
76
|
+
index: targetIndex + 1,
|
|
77
|
+
total: sourceType === 'table-row' ? totalRowCount : totalColumnCount
|
|
78
|
+
}), {
|
|
79
|
+
priority: 'important'
|
|
80
|
+
});
|
|
81
|
+
}
|
|
67
82
|
}
|
|
68
83
|
return true;
|
|
69
84
|
});
|
|
70
85
|
};
|
|
71
|
-
export const moveSourceWithAnalyticsViaShortcut = editorAnalyticsAPI => (sourceType, direction) => (state, dispatch) => {
|
|
86
|
+
export const moveSourceWithAnalyticsViaShortcut = (editorAnalyticsAPI, ariaNotify, getIntl) => (sourceType, direction) => (state, dispatch) => {
|
|
72
87
|
const {
|
|
73
88
|
selection
|
|
74
89
|
} = state;
|
|
@@ -90,7 +105,7 @@ export const moveSourceWithAnalyticsViaShortcut = editorAnalyticsAPI => (sourceT
|
|
|
90
105
|
return false;
|
|
91
106
|
}
|
|
92
107
|
const targetIndex = getTargetIndex(selectedIndexes, direction);
|
|
93
|
-
return moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, sourceType, selectedIndexes, targetIndex)(state, dispatch);
|
|
108
|
+
return moveSourceWithAnalytics(editorAnalyticsAPI, ariaNotify, getIntl)(INPUT_METHOD.SHORTCUT, sourceType, selectedIndexes, targetIndex)(state, dispatch);
|
|
94
109
|
};
|
|
95
110
|
export const cloneSourceWithAnalytics = editorAnalyticsAPI => (inputMethod, sourceType, sourceIndexes, targetIndex, targetDirection, tr) => {
|
|
96
111
|
return withEditorAnalyticsAPI(({
|
|
@@ -2,7 +2,7 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import { addColumnAfter, addColumnAfterVO, addColumnBefore, addColumnBeforeVO, addRowAfter, addRowAfterVO, addRowBefore, addRowBeforeVO, backspace, bindKeymapWithCommand, decreaseMediaSize, deleteColumn, deleteRow, escape, focusToContextMenuTrigger, increaseMediaSize, moveColumnLeft, moveColumnRight, moveLeft, moveRight, moveRowDown, moveRowUp, nextCell, previousCell, startColumnResizing, toggleTable } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
4
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
|
-
import {
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
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';
|
|
@@ -23,7 +23,7 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
23
23
|
bindKeymapWithCommand(addRowAfter.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
|
|
24
24
|
bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
25
25
|
bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
26
|
-
if (
|
|
26
|
+
if (fg('platform.editor.a11y-help-dialog-shortcut-keys-position_aghfg')) {
|
|
27
27
|
bindKeymapWithCommand(addRowBeforeVO.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
|
|
28
28
|
bindKeymapWithCommand(addRowAfterVO.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
|
|
29
29
|
bindKeymapWithCommand(addColumnBeforeVO.common, addColumnBeforeCommand(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
@@ -38,10 +38,10 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
38
38
|
* See ticket ED-22154 https://product-fabric.atlassian.net/browse/ED-22154
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
|
-
bindKeymapWithCommand(moveRowDown.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-row', 1), list);
|
|
42
|
-
bindKeymapWithCommand(moveRowUp.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-row', -1), list);
|
|
43
|
-
bindKeymapWithCommand(moveColumnLeft.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-column', -1), list);
|
|
44
|
-
bindKeymapWithCommand(moveColumnRight.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-column', 1), list);
|
|
41
|
+
bindKeymapWithCommand(moveRowDown.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)('table-row', 1), list);
|
|
42
|
+
bindKeymapWithCommand(moveRowUp.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)('table-row', -1), list);
|
|
43
|
+
bindKeymapWithCommand(moveColumnLeft.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)('table-column', -1), list);
|
|
44
|
+
bindKeymapWithCommand(moveColumnRight.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)('table-column', 1), list);
|
|
45
45
|
|
|
46
46
|
// Delete row/column shortcuts
|
|
47
47
|
bindKeymapWithCommand(deleteColumn.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
@@ -67,7 +67,7 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
67
67
|
ariaNotify: ariaNotifyPlugin,
|
|
68
68
|
getIntl: getIntl
|
|
69
69
|
}), list);
|
|
70
|
-
if (
|
|
70
|
+
if (fg('platform.editor.a11y-table-context-menu_y4c9c')) {
|
|
71
71
|
bindKeymapWithCommand(focusToContextMenuTrigger.common, setFocusToCellMenu(), list);
|
|
72
72
|
}
|
|
73
73
|
return keymap(list);
|
|
@@ -6,7 +6,7 @@ import { browser, closestElement } from '@atlaskit/editor-common/utils';
|
|
|
6
6
|
import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import { TableMap } from '@atlaskit/editor-tables';
|
|
8
8
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
9
|
-
import {
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
|
|
11
11
|
import { stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
12
12
|
import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
@@ -198,7 +198,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
// If a partial paste of nested expand, paste only nested-expand's content */
|
|
201
|
-
if (
|
|
201
|
+
if (fg('platform.editor.transform-slice-for-nested-expand')) {
|
|
202
202
|
slice = transformSliceToRemoveOpenNestedExpand(slice, schema);
|
|
203
203
|
}
|
|
204
204
|
return slice;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { bindKeymapArrayWithCommand, bindKeymapWithCommand, moveLeft, moveRight, selectColumn, selectRow, selectTable, shiftArrowUp } from '@atlaskit/editor-common/keymaps';
|
|
2
2
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
3
|
import { arrowLeftFromTable, arrowRightFromTable, modASelectTable, selectColumns, selectRows, shiftArrowUpFromTable } from '../commands/selection';
|
|
4
|
-
export function tableSelectionKeymapPlugin(
|
|
4
|
+
export function tableSelectionKeymapPlugin(pluginInjectionApi, getIntl) {
|
|
5
|
+
var _pluginInjectionApi$a;
|
|
5
6
|
const list = {};
|
|
7
|
+
const editorSelectionAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.selection;
|
|
8
|
+
const ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
|
|
6
9
|
bindKeymapWithCommand(moveRight.common, arrowRightFromTable(editorSelectionAPI)(), list);
|
|
7
10
|
bindKeymapWithCommand(moveLeft.common, arrowLeftFromTable(editorSelectionAPI)(), list);
|
|
8
|
-
bindKeymapArrayWithCommand(selectColumn, selectColumns(editorSelectionAPI)(true), list);
|
|
9
|
-
bindKeymapArrayWithCommand(selectRow, selectRows(editorSelectionAPI)(true), list);
|
|
11
|
+
bindKeymapArrayWithCommand(selectColumn, selectColumns(editorSelectionAPI, ariaNotifyPlugin, getIntl)(true), list);
|
|
12
|
+
bindKeymapArrayWithCommand(selectRow, selectRows(editorSelectionAPI, ariaNotifyPlugin, getIntl)(true), list);
|
|
10
13
|
bindKeymapWithCommand(shiftArrowUp.common, shiftArrowUpFromTable(editorSelectionAPI)(), list);
|
|
11
14
|
bindKeymapWithCommand(selectTable.common, modASelectTable(editorSelectionAPI)(), list);
|
|
12
15
|
return keymap(list);
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -351,7 +351,7 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
351
351
|
return element;
|
|
352
352
|
};
|
|
353
353
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown, areTableColumWidthsFixed);
|
|
354
|
-
const alignmentMenu = options !== null && options !== void 0 && options.isTableAlignmentEnabled && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent) : [];
|
|
354
|
+
const alignmentMenu = options !== null && options !== void 0 && options.isTableAlignmentEnabled && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.fullWidthEnabled) : [];
|
|
355
355
|
const isCellBackgroundDuplicated = getEditorFeatureFlags().tableDuplicateCellColouring || false;
|
|
356
356
|
const cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, editorView, intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent);
|
|
357
357
|
const columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, editorView, intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled) : [];
|
|
@@ -547,7 +547,7 @@ const highlightColumnsHandler = (state, dispatch) => {
|
|
|
547
547
|
};
|
|
548
548
|
export const getAlignmentOptionsConfig = (editorState, {
|
|
549
549
|
formatMessage
|
|
550
|
-
}, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent) => {
|
|
550
|
+
}, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, isFullWidthEditor) => {
|
|
551
551
|
const tableObject = findTable(editorState.selection);
|
|
552
552
|
if (!tableObject) {
|
|
553
553
|
return [];
|
|
@@ -581,7 +581,7 @@ export const getAlignmentOptionsConfig = (editorState, {
|
|
|
581
581
|
title: formatMessage(layoutToMessages[value]),
|
|
582
582
|
selected: normaliseAlignment(currentLayout) === value,
|
|
583
583
|
onClick: setTableAlignmentWithAnalytics(editorAnalyticsAPI)(value, currentLayout, INPUT_METHOD.FLOATING_TB, CHANGE_ALIGNMENT_REASON.TOOLBAR_OPTION_CHANGED),
|
|
584
|
-
...(isLayoutOptionDisabled(tableObject.node, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent) && {
|
|
584
|
+
...(isLayoutOptionDisabled(tableObject.node, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, isFullWidthEditor) && {
|
|
585
585
|
disabled: value !== 'center'
|
|
586
586
|
})
|
|
587
587
|
};
|
|
@@ -610,7 +610,7 @@ export const getSelectedAlignmentIcon = (alignmentIcons, selectedNode) => {
|
|
|
610
610
|
const selectedAlignment = selectedNode.attrs.layout;
|
|
611
611
|
return alignmentIcons.find(icon => icon.value === normaliseAlignment(selectedAlignment));
|
|
612
612
|
};
|
|
613
|
-
export const isLayoutOptionDisabled = (selectedNode, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent) => {
|
|
613
|
+
export const isLayoutOptionDisabled = (selectedNode, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, isFullWidthEditor) => {
|
|
614
614
|
const {
|
|
615
615
|
lineLength
|
|
616
616
|
} = getEditorContainerWidth();
|
|
@@ -623,7 +623,10 @@ export const isLayoutOptionDisabled = (selectedNode, getEditorContainerWidth, ge
|
|
|
623
623
|
const scalePercent = getStaticTableScalingPercent(selectedNode, tableWrapperWidth, shouldUseIncreasedScalingPercent);
|
|
624
624
|
tableContainerWidth = tableContainerWidth * scalePercent;
|
|
625
625
|
}
|
|
626
|
-
|
|
626
|
+
|
|
627
|
+
// If fixed-width editor, we disable 'left-alignment' when table width is 760px.
|
|
628
|
+
// tableContainerWidth +1 here because tableContainerWidth is 759 in fixed-width editor
|
|
629
|
+
if (selectedNode && !isFullWidthEditor && lineLength && tableContainerWidth + 1 >= lineLength) {
|
|
627
630
|
return true;
|
|
628
631
|
}
|
|
629
632
|
return false;
|
|
@@ -190,7 +190,8 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
190
190
|
tableDuplicateCellColouring,
|
|
191
191
|
shouldUseIncreasedScalingPercent,
|
|
192
192
|
isTableFixedColumnWidthsOptionEnabled,
|
|
193
|
-
tableSortColumnReorder
|
|
193
|
+
tableSortColumnReorder,
|
|
194
|
+
ariaNotifyPlugin
|
|
194
195
|
}) => {
|
|
195
196
|
var _tableMap$hasMergedCe, _pluginConfig$allowBa;
|
|
196
197
|
const {
|
|
@@ -208,7 +209,7 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
208
209
|
const selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
209
210
|
const hasMergedCellsInTable = (_tableMap$hasMergedCe = tableMap === null || tableMap === void 0 ? void 0 : tableMap.hasMergedCells()) !== null && _tableMap$hasMergedCe !== void 0 ? _tableMap$hasMergedCe : false;
|
|
210
211
|
const allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
211
|
-
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled, tableDuplicateCellColouring, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, tableSortColumnReorder);
|
|
212
|
+
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled, tableDuplicateCellColouring, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, tableSortColumnReorder, ariaNotifyPlugin);
|
|
212
213
|
const {
|
|
213
214
|
menuItems,
|
|
214
215
|
menuCallback
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
3
3
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
|
-
import {
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { dragMenuDropdownWidth, tablePopupMenuFitHeight } from '../consts';
|
|
7
7
|
import DragMenu from './DragMenu';
|
|
8
8
|
const FloatingDragMenu = ({
|
|
@@ -20,7 +20,8 @@ const FloatingDragMenu = ({
|
|
|
20
20
|
stickyHeaders,
|
|
21
21
|
pluginConfig,
|
|
22
22
|
isTableScalingEnabled,
|
|
23
|
-
getEditorFeatureFlags
|
|
23
|
+
getEditorFeatureFlags,
|
|
24
|
+
ariaNotifyPlugin
|
|
24
25
|
}) => {
|
|
25
26
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
26
27
|
return null;
|
|
@@ -36,7 +37,7 @@ const FloatingDragMenu = ({
|
|
|
36
37
|
tableWithFixedColumnWidthsOption = false,
|
|
37
38
|
tableSortColumnReorder = false
|
|
38
39
|
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
39
|
-
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && tableWithFixedColumnWidthsOption &&
|
|
40
|
+
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && tableWithFixedColumnWidthsOption && fg('platform.editor.table.use-increased-scaling-percent');
|
|
40
41
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
41
42
|
alignX: direction === 'row' ? 'right' : undefined,
|
|
42
43
|
alignY: direction === 'row' ? 'start' : undefined,
|
|
@@ -74,7 +75,8 @@ const FloatingDragMenu = ({
|
|
|
74
75
|
tableDuplicateCellColouring: tableDuplicateCellColouring,
|
|
75
76
|
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
|
|
76
77
|
isTableFixedColumnWidthsOptionEnabled: tableWithFixedColumnWidthsOption,
|
|
77
|
-
tableSortColumnReorder: tableSortColumnReorder
|
|
78
|
+
tableSortColumnReorder: tableSortColumnReorder,
|
|
79
|
+
ariaNotifyPlugin: ariaNotifyPlugin
|
|
78
80
|
}));
|
|
79
81
|
};
|
|
80
82
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
4
|
-
import {
|
|
4
|
+
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { hoverCell, hoverRows, selectRow, selectRows } from '../../commands';
|
|
6
7
|
import { TableCssClassName as ClassName } from '../../types';
|
|
8
|
+
import { isTableNested } from '../../utils/nodes';
|
|
7
9
|
import { CornerControls, DragCornerControls, DragCornerControlsWithSelection } from './CornerControls';
|
|
8
10
|
import { FloatingControlsWithSelection } from './FloatingControlsWithSelection';
|
|
9
11
|
import NumberColumn from './NumberColumn';
|
|
@@ -27,6 +29,7 @@ export const TableFloatingControls = ({
|
|
|
27
29
|
tableWrapperWidth,
|
|
28
30
|
api
|
|
29
31
|
}) => {
|
|
32
|
+
var _findTable;
|
|
30
33
|
const _selectRow = useCallback((row, expand) => {
|
|
31
34
|
const {
|
|
32
35
|
state,
|
|
@@ -79,6 +82,9 @@ export const TableFloatingControls = ({
|
|
|
79
82
|
}
|
|
80
83
|
const stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
|
|
81
84
|
const wrapperClassName = isDragAndDropEnabled ? ClassName.DRAG_ROW_CONTROLS_WRAPPER : ClassName.ROW_CONTROLS_WRAPPER;
|
|
85
|
+
const tablePos = (_findTable = findTable(editorView.state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos;
|
|
86
|
+
const isNested = tablePos !== undefined && isTableNested(editorView.state, tablePos);
|
|
87
|
+
const shouldShowCornerControls = fg('platform_editor_element_drag_and_drop_ed_24041') ? !(featureFlagsState !== null && featureFlagsState !== void 0 && featureFlagsState.elementDragAndDrop) || isNested : !(featureFlagsState !== null && featureFlagsState !== void 0 && featureFlagsState.elementDragAndDrop);
|
|
82
88
|
return (
|
|
83
89
|
/*#__PURE__*/
|
|
84
90
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -99,7 +105,7 @@ export const TableFloatingControls = ({
|
|
|
99
105
|
updateCellHoverLocation: updateCellHoverLocation,
|
|
100
106
|
stickyTop: stickyTop,
|
|
101
107
|
isDragAndDropEnabled: isDragAndDropEnabled
|
|
102
|
-
}) : null, tableActive && /*#__PURE__*/React.createElement(React.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
108
|
+
}) : null, tableActive && /*#__PURE__*/React.createElement(React.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/React.createElement(React.Fragment, null, shouldShowCornerControls && (fg('platform.editor.table.use-shared-state-hook') ? /*#__PURE__*/React.createElement(DragCornerControlsWithSelection, {
|
|
103
109
|
editorView: editorView,
|
|
104
110
|
tableRef: tableRef,
|
|
105
111
|
isInDanger: isInDanger,
|
|
@@ -124,7 +130,7 @@ export const TableFloatingControls = ({
|
|
|
124
130
|
selectRow: _selectRow,
|
|
125
131
|
selectRows: _selectRows,
|
|
126
132
|
updateCellHoverLocation: updateCellHoverLocation
|
|
127
|
-
})) :
|
|
133
|
+
})) : fg('platform.editor.table.use-shared-state-hook') ? /*#__PURE__*/React.createElement(FloatingControlsWithSelection, {
|
|
128
134
|
editorView: editorView,
|
|
129
135
|
tableRef: tableRef,
|
|
130
136
|
isInDanger: isInDanger,
|
|
@@ -12,6 +12,7 @@ import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-d
|
|
|
12
12
|
import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
|
|
13
13
|
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, sortColumnWithAnalytics } from '../commands-with-analytics';
|
|
14
14
|
import { moveSourceWithAnalytics } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
15
|
+
import { getPluginState as getTablePluginState } from '../pm-plugins/plugin-factory';
|
|
15
16
|
import { getNewResizeStateFromSelectedColumns } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
16
17
|
import { getClosestSelectionRect } from '../toolbar';
|
|
17
18
|
import { AddColLeftIcon, AddColRightIcon, AddRowAboveIcon, AddRowBelowIcon } from '../ui/icons';
|
|
@@ -57,11 +58,14 @@ const defaultSelectionRect = {
|
|
|
57
58
|
right: 0,
|
|
58
59
|
bottom: 0
|
|
59
60
|
};
|
|
60
|
-
export const getDragMenuConfig = (direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired, isTableScalingEnabled = false, tableDuplicateCellColouring = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, tableSortColumnReorder = false) => {
|
|
61
|
+
export const getDragMenuConfig = (direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired, isTableScalingEnabled = false, tableDuplicateCellColouring = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, tableSortColumnReorder = false, ariaNotifyPlugin) => {
|
|
61
62
|
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
62
63
|
const {
|
|
63
64
|
selection
|
|
64
65
|
} = editorView.state;
|
|
66
|
+
const {
|
|
67
|
+
getIntl
|
|
68
|
+
} = getTablePluginState(editorView.state);
|
|
65
69
|
const addOptions = direction === 'row' ? [{
|
|
66
70
|
label: 'above',
|
|
67
71
|
offset: 0,
|
|
@@ -210,7 +214,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, hasMergedC
|
|
|
210
214
|
onClick: (state, dispatch) => {
|
|
211
215
|
if (canMove) {
|
|
212
216
|
requestAnimationFrame(() => {
|
|
213
|
-
moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, `table-${direction}`, getOriginIndexes(selectionRect), getTargetIndex(selectionRect))(editorView.state, editorView.dispatch);
|
|
217
|
+
moveSourceWithAnalytics(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(INPUT_METHOD.TABLE_CONTEXT_MENU, `table-${direction}`, getOriginIndexes(selectionRect), getTargetIndex(selectionRect))(editorView.state, editorView.dispatch);
|
|
214
218
|
});
|
|
215
219
|
return true;
|
|
216
220
|
}
|
|
@@ -2,7 +2,7 @@ import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
|
2
2
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { TableMap } from '@atlaskit/editor-tables';
|
|
4
4
|
import { findCellClosestToPos, findCellRectClosestToPos, findTableClosestToPos, getSelectionRect, isSelectionType, nextCell } from '@atlaskit/editor-tables/utils';
|
|
5
|
-
import {
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { getDecorations } from '../pm-plugins/decorations/plugin';
|
|
7
7
|
import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../pm-plugins/decorations/utils';
|
|
8
8
|
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -197,7 +197,7 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(_ref4) {
|
|
|
197
197
|
if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
|
|
198
198
|
isTableScalingEnabledOnCurrentTable = originalTable.attrs.displayMode !== 'fixed';
|
|
199
199
|
}
|
|
200
|
-
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled &&
|
|
200
|
+
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && fg('platform.editor.table.use-increased-scaling-percent');
|
|
201
201
|
var initialResizeState = getResizeState({
|
|
202
202
|
minWidth: tableCellMinWidth,
|
|
203
203
|
maxSize: maxSize,
|