@atlaskit/editor-plugin-table 7.20.2 → 7.21.1
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 +26 -0
- package/dist/cjs/nodeviews/TableResizer.js +25 -2
- package/dist/cjs/nodeviews/TableStickyScrollbar.js +8 -1
- package/dist/cjs/nodeviews/lazy-node-views.js +133 -0
- package/dist/cjs/plugin.js +39 -4
- package/dist/cjs/pm-plugins/keymap.js +1 -1
- package/dist/cjs/pm-plugins/main.js +19 -15
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +6 -5
- package/dist/cjs/ui/FloatingContextualButton/index.js +4 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +11 -11
- package/dist/es2019/nodeviews/TableResizer.js +25 -2
- package/dist/es2019/nodeviews/TableStickyScrollbar.js +8 -1
- package/dist/es2019/nodeviews/lazy-node-views.js +116 -0
- package/dist/es2019/plugin.js +38 -2
- package/dist/es2019/pm-plugins/keymap.js +1 -1
- package/dist/es2019/pm-plugins/main.js +19 -7
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +7 -6
- package/dist/es2019/ui/FloatingContextualButton/index.js +5 -3
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +11 -11
- package/dist/esm/nodeviews/TableResizer.js +25 -2
- package/dist/esm/nodeviews/TableStickyScrollbar.js +8 -1
- package/dist/esm/nodeviews/lazy-node-views.js +116 -0
- package/dist/esm/plugin.js +39 -4
- package/dist/esm/pm-plugins/keymap.js +1 -1
- package/dist/esm/pm-plugins/main.js +19 -15
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +7 -6
- package/dist/esm/ui/FloatingContextualButton/index.js +5 -3
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +11 -11
- package/dist/types/nodeviews/lazy-node-views.d.ts +26 -0
- package/dist/types-ts4.5/nodeviews/lazy-node-views.d.ts +26 -0
- package/package.json +6 -3
- package/src/nodeviews/TableResizer.tsx +26 -1
- package/src/nodeviews/TableStickyScrollbar.ts +8 -1
- package/src/nodeviews/lazy-node-views.ts +196 -0
- package/src/plugin.tsx +53 -2
- package/src/pm-plugins/keymap.ts +1 -1
- package/src/pm-plugins/main.ts +18 -19
- package/src/pm-plugins/table-resizing/event-handlers.ts +8 -6
- package/src/ui/FloatingContextualButton/index.tsx +7 -5
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -13
package/dist/esm/plugin.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
4
|
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; }
|
|
@@ -29,6 +30,7 @@ import { createPlugin as createStickyHeadersPlugin, findStickyHeaderForTable, pl
|
|
|
29
30
|
import { createPlugin as createTableOverflowAnalyticsPlugin } from './pm-plugins/table-analytics';
|
|
30
31
|
import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
|
|
31
32
|
import { createPlugin as createFlexiResizingPlugin, getPluginState as getFlexiResizingPlugin, pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
33
|
+
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
32
34
|
import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap';
|
|
33
35
|
import { createPlugin as createTableWidthPlugin, pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
|
|
34
36
|
import { createPlugin as createViewModeSortPlugin } from './pm-plugins/view-mode-sort';
|
|
@@ -47,6 +49,39 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
|
47
49
|
|
|
48
50
|
// TODO: duplicating type instead of importing media plugin causing a circular dependency
|
|
49
51
|
|
|
52
|
+
// TODO: ED-23944 Move this override to `toDOM` function on table adf-schema nodespec
|
|
53
|
+
var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(tableOptions) {
|
|
54
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
55
|
+
return table;
|
|
56
|
+
}
|
|
57
|
+
return _objectSpread(_objectSpread({}, table), {}, {
|
|
58
|
+
toDOM: function toDOM(node) {
|
|
59
|
+
var attrs = {
|
|
60
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
61
|
+
'data-layout': node.attrs.layout,
|
|
62
|
+
'data-autosize': node.attrs.__autoSize,
|
|
63
|
+
'data-table-local-id': node.attrs.localId,
|
|
64
|
+
'data-table-width': node.attrs.width
|
|
65
|
+
};
|
|
66
|
+
var colgroup = '';
|
|
67
|
+
var _pluginConfig = pluginConfig(tableOptions),
|
|
68
|
+
allowColumnResizing = _pluginConfig.allowColumnResizing;
|
|
69
|
+
if (allowColumnResizing) {
|
|
70
|
+
colgroup = ['colgroup', {}].concat(_toConsumableArray(generateColgroup(node)));
|
|
71
|
+
}
|
|
72
|
+
return ['div', {
|
|
73
|
+
class: 'tableView-content-wrap'
|
|
74
|
+
}, ['div', {
|
|
75
|
+
class: 'pm-table-container'
|
|
76
|
+
}, ['div', {
|
|
77
|
+
class: 'pm-table-wrapper',
|
|
78
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
79
|
+
'data-layout': node.attrs.layout
|
|
80
|
+
}, ['table', attrs, colgroup, ['tbody', 0]]]]];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
|
|
50
85
|
/**
|
|
51
86
|
* Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
52
87
|
* from `@atlaskit/editor-core`.
|
|
@@ -130,7 +165,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
130
165
|
nodes: function nodes() {
|
|
131
166
|
return [{
|
|
132
167
|
name: 'table',
|
|
133
|
-
node:
|
|
168
|
+
node: tableNodeSpecWithFixedToDOM(options === null || options === void 0 ? void 0 : options.tableOptions)
|
|
134
169
|
}, {
|
|
135
170
|
name: 'tableHeader',
|
|
136
171
|
node: tableHeader
|
|
@@ -173,8 +208,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
173
208
|
isTableScalingEnabled = _ref5.isTableScalingEnabled,
|
|
174
209
|
isNewColumnResizingEnabled = _ref5.isNewColumnResizingEnabled,
|
|
175
210
|
isTableAlignmentEnabled = _ref5.isTableAlignmentEnabled;
|
|
176
|
-
var
|
|
177
|
-
allowColumnResizing =
|
|
211
|
+
var _pluginConfig2 = pluginConfig(tableOptions),
|
|
212
|
+
allowColumnResizing = _pluginConfig2.allowColumnResizing;
|
|
178
213
|
return allowColumnResizing ? createFlexiResizingPlugin(dispatch, {
|
|
179
214
|
lastColumnResizable: !fullWidthEnabled
|
|
180
215
|
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, editorAnalyticsAPI, isTableScalingEnabled || false, isNewColumnResizingEnabled, isTableAlignmentEnabled) : undefined;
|
|
@@ -355,7 +390,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
355
390
|
isCellMenuOpenByKeyboard = _ref19.isCellMenuOpenByKeyboard;
|
|
356
391
|
var allowControls = pluginConfig.allowControls;
|
|
357
392
|
var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
358
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard && fg('
|
|
393
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard && fg('platform_editor_a11y_table_context_menu')) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
359
394
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
360
395
|
editorView: editorView,
|
|
361
396
|
tableNode: tableNode,
|
|
@@ -75,7 +75,7 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
75
75
|
ariaNotify: ariaNotifyPlugin,
|
|
76
76
|
getIntl: getIntl
|
|
77
77
|
}), list);
|
|
78
|
-
if (fg('
|
|
78
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
79
79
|
bindKeymapWithCommand(focusToContextMenuTrigger.common, setFocusToCellMenu(), list);
|
|
80
80
|
}
|
|
81
81
|
return keymap(list);
|
|
@@ -14,9 +14,7 @@ import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../
|
|
|
14
14
|
import { stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
15
15
|
import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
16
16
|
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleMouseUp, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
|
|
17
|
-
import {
|
|
18
|
-
import TableCell from '../nodeviews/TableCell';
|
|
19
|
-
import TableRow from '../nodeviews/TableRow';
|
|
17
|
+
import { lazyTableCellView, lazyTableHeaderView, lazyTableRowView, lazyTableView } from '../nodeviews/lazy-node-views';
|
|
20
18
|
import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plugin';
|
|
21
19
|
import { fixTables, replaceSelectedTable } from '../transforms';
|
|
22
20
|
import { TableCssClassName as ClassName } from '../types';
|
|
@@ -251,18 +249,24 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
251
249
|
return false;
|
|
252
250
|
},
|
|
253
251
|
nodeViews: {
|
|
254
|
-
table:
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
252
|
+
table: lazyTableView({
|
|
253
|
+
portalProviderAPI: portalProviderAPI,
|
|
254
|
+
eventDispatcher: eventDispatcher,
|
|
255
|
+
getEditorContainerWidth: getEditorContainerWidth,
|
|
256
|
+
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
257
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
258
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
259
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled
|
|
260
|
+
}),
|
|
261
|
+
tableRow: lazyTableRowView({
|
|
262
|
+
eventDispatcher: eventDispatcher
|
|
263
|
+
}),
|
|
264
|
+
tableCell: lazyTableCellView({
|
|
265
|
+
eventDispatcher: eventDispatcher
|
|
266
|
+
}),
|
|
267
|
+
tableHeader: lazyTableHeaderView({
|
|
268
|
+
eventDispatcher: eventDispatcher
|
|
269
|
+
})
|
|
266
270
|
},
|
|
267
271
|
handleDOMEvents: {
|
|
268
272
|
focus: handleFocus,
|
|
@@ -5,7 +5,7 @@ import { ACTION_SUBJECT, CHANGE_ALIGNMENT_REASON, EVENT_TYPE, INPUT_METHOD, TABL
|
|
|
5
5
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
6
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
7
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
8
|
-
import {
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { stopKeyboardColumnResizing } from '../../commands/column-resize';
|
|
10
10
|
import { updateResizeHandleDecorations } from '../../commands/misc';
|
|
11
11
|
import { updateColumnWidths } from '../../transforms';
|
|
@@ -68,7 +68,7 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
68
68
|
start: start,
|
|
69
69
|
domAtPos: domAtPos,
|
|
70
70
|
isTableScalingEnabled: shouldScale,
|
|
71
|
-
shouldUseIncreasedScalingPercent: isTableScalingWithFixedColumnWidthsOptionEnabled &&
|
|
71
|
+
shouldUseIncreasedScalingPercent: isTableScalingWithFixedColumnWidthsOptionEnabled && fg('platform.editor.table.use-increased-scaling-percent')
|
|
72
72
|
});
|
|
73
73
|
if (evenColumns({
|
|
74
74
|
resizeState: resizeState,
|
|
@@ -145,7 +145,7 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
145
145
|
_shouldScale = _shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
146
146
|
}
|
|
147
147
|
var resizedDelta = clientX - startX;
|
|
148
|
-
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled &&
|
|
148
|
+
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && fg('platform.editor.table.use-increased-scaling-percent');
|
|
149
149
|
if (isNewColumnResizingEnabled && !isTableNested(state, tablePos)) {
|
|
150
150
|
var newResizeState = resizeColumnAndTable(resizeState, colIndex, resizedDelta, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale,
|
|
151
151
|
// isTableScalingEnabled
|
|
@@ -234,17 +234,18 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
234
234
|
resizeHandlePos = _getPluginState2.resizeHandlePos;
|
|
235
235
|
var _getTablePluginState3 = getTablePluginState(state),
|
|
236
236
|
isTableHovered = _getTablePluginState3.isTableHovered;
|
|
237
|
-
|
|
237
|
+
var tablePos = state.doc.resolve(start).start(-1);
|
|
238
|
+
if (!which || !dragging || resizeHandlePos === null || !pointsAtCell(state.doc.resolve(resizeHandlePos)) || (!isNewColumnResizingEnabled || isTableNested(state, tablePos)) && !isTableHovered) {
|
|
238
239
|
return finish(event);
|
|
239
240
|
}
|
|
240
241
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
241
242
|
var table = $cell.node(-1);
|
|
242
|
-
|
|
243
|
+
// const tablePos = state.doc.resolve(start).start(-1);
|
|
243
244
|
var tableDepth = state.doc.resolve(tablePos).depth;
|
|
244
245
|
var map = TableMap.get(table);
|
|
245
246
|
var colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
246
247
|
var shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
247
|
-
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled &&
|
|
248
|
+
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && fg('platform.editor.table.use-increased-scaling-percent');
|
|
248
249
|
if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
|
|
249
250
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
250
251
|
}
|
|
@@ -6,13 +6,14 @@ import { jsx } from '@emotion/react';
|
|
|
6
6
|
import { injectIntl } from 'react-intl-next';
|
|
7
7
|
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
9
|
+
import { focusToContextMenuTrigger } from '@atlaskit/editor-common/keymaps';
|
|
9
10
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
11
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
11
12
|
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
12
13
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
13
14
|
import { akEditorSmallZIndex } from '@atlaskit/editor-shared-styles';
|
|
14
15
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
15
|
-
import {
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
17
|
import { toggleContextualMenu } from '../../commands';
|
|
17
18
|
import { TableCssClassName as ClassName } from '../../types';
|
|
18
19
|
import FixedButton from './FixedButton';
|
|
@@ -45,7 +46,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
45
46
|
var targetCellRef;
|
|
46
47
|
targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
47
48
|
useEffect(function () {
|
|
48
|
-
if (
|
|
49
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
49
50
|
if (isCellMenuOpenByKeyboard && !isContextualMenuOpen) {
|
|
50
51
|
var state = editorView.state,
|
|
51
52
|
dispatch = editorView.dispatch;
|
|
@@ -70,12 +71,13 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
70
71
|
className: ClassName.CONTEXTUAL_MENU_BUTTON,
|
|
71
72
|
selected: isContextualMenuOpen,
|
|
72
73
|
title: labelCellOptions,
|
|
74
|
+
keymap: fg('platform_editor_a11y_table_context_menu') ? focusToContextMenuTrigger : undefined,
|
|
73
75
|
onClick: handleClick,
|
|
74
76
|
iconBefore: jsx(ExpandIcon, {
|
|
75
77
|
label: ""
|
|
76
78
|
}),
|
|
77
79
|
"aria-label": labelCellOptions,
|
|
78
|
-
"aria-expanded":
|
|
80
|
+
"aria-expanded": fg('platform_editor_a11y_table_context_menu') ? isContextualMenuOpen : undefined
|
|
79
81
|
}));
|
|
80
82
|
var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
81
83
|
if (stickyHeader && parentSticky && tableWrapper) {
|
|
@@ -87,7 +87,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
87
87
|
var background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
88
88
|
var selectedRowIndex;
|
|
89
89
|
var selectedColumnIndex;
|
|
90
|
-
if (fg('
|
|
90
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
91
91
|
var selectedRowAndColumnFromPalette = getSelectedRowAndColumnFromPalette(cellBackgroundColorPalette, background, colorPalletteColumns);
|
|
92
92
|
selectedRowIndex = selectedRowAndColumnFromPalette.selectedRowIndex;
|
|
93
93
|
selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
@@ -115,7 +115,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
115
115
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
116
116
|
,
|
|
117
117
|
className: isDragAndDropEnabled ? ClassName.CONTEXTUAL_MENU_ICON_SMALL : ClassName.CONTEXTUAL_MENU_ICON
|
|
118
|
-
}), fg('
|
|
118
|
+
}), fg('platform_editor_a11y_table_context_menu') ? isSubmenuOpen && jsx("div", {
|
|
119
119
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
120
120
|
className: ClassName.CONTEXTUAL_SUBMENU,
|
|
121
121
|
ref: _this.handleSubMenuRef
|
|
@@ -160,7 +160,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
160
160
|
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
161
161
|
}
|
|
162
162
|
}))),
|
|
163
|
-
'aria-expanded': fg('
|
|
163
|
+
'aria-expanded': fg('platform_editor_a11y_table_context_menu') ? isSubmenuOpen : undefined
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
});
|
|
@@ -462,7 +462,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
462
462
|
tableWithFixedColumnWidthsOption = _ref4$tableWithFixedC === void 0 ? false : _ref4$tableWithFixedC;
|
|
463
463
|
// context menu opened by keyboard and any item except 'background' activated
|
|
464
464
|
// or color has been chosen from color palette
|
|
465
|
-
if (isCellMenuOpenByKeyboard && (item.value.name !== 'background' || item.value.name === 'background' && _this.state.isSubmenuOpen) && fg('
|
|
465
|
+
if (isCellMenuOpenByKeyboard && (item.value.name !== 'background' || item.value.name === 'background' && _this.state.isSubmenuOpen) && fg('platform_editor_a11y_table_context_menu')) {
|
|
466
466
|
var tr = state.tr;
|
|
467
467
|
tr.setMeta(tablePluginKey, {
|
|
468
468
|
type: 'SET_CELL_MENU_OPEN',
|
|
@@ -529,7 +529,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
529
529
|
// 1st time when user chooses the background color item.
|
|
530
530
|
// 2nd when color has been chosen from color palette.
|
|
531
531
|
// here we are handling the 1st call relying on the isSubmenuOpen state value
|
|
532
|
-
if (isCellMenuOpenByKeyboard && !_this.state.isSubmenuOpen && fg('
|
|
532
|
+
if (isCellMenuOpenByKeyboard && !_this.state.isSubmenuOpen && fg('platform_editor_a11y_table_context_menu')) {
|
|
533
533
|
_this.setState({
|
|
534
534
|
isSubmenuOpen: true
|
|
535
535
|
});
|
|
@@ -558,7 +558,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
558
558
|
dispatch = _this$props12$editorV.dispatch,
|
|
559
559
|
dom = _this$props12$editorV.dom,
|
|
560
560
|
isCellMenuOpenByKeyboard = _this$props12.isCellMenuOpenByKeyboard;
|
|
561
|
-
if (fg('
|
|
561
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
562
562
|
if (payload) {
|
|
563
563
|
var event = payload.event;
|
|
564
564
|
if (event && event instanceof KeyboardEvent) {
|
|
@@ -650,7 +650,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
650
650
|
_createClass(ContextualMenu, [{
|
|
651
651
|
key: "componentDidMount",
|
|
652
652
|
value: function componentDidMount() {
|
|
653
|
-
if (fg('
|
|
653
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
654
654
|
// ArrowKeyNavigationProvider in DropdownMenu expects that menu handle will stay focused
|
|
655
655
|
// until user pressed ArrowDown.
|
|
656
656
|
// Behavior above fails the A11Y requirement about first item in menu should be focused immediately.
|
|
@@ -677,7 +677,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
677
677
|
isDragAndDropEnabled = _getPluginState13.isDragAndDropEnabled;
|
|
678
678
|
var items = isDragAndDropEnabled ? this.createNewContextMenuItems() : this.createOriginalContextMenuItems();
|
|
679
679
|
var isOpenAllowed = false;
|
|
680
|
-
if (fg('
|
|
680
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
681
681
|
isOpenAllowed = isCellMenuOpenByKeyboard ? this.state.isOpenAllowed : isOpen;
|
|
682
682
|
} else {
|
|
683
683
|
isOpenAllowed = isOpen;
|
|
@@ -693,7 +693,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
693
693
|
,
|
|
694
694
|
arrowKeyNavigationProviderOptions: {
|
|
695
695
|
type: ArrowKeyNavigationType.MENU,
|
|
696
|
-
disableArrowKeyNavigation: isCellMenuOpenByKeyboard && !this.state.isSubmenuOpen && fg('
|
|
696
|
+
disableArrowKeyNavigation: isCellMenuOpenByKeyboard && !this.state.isSubmenuOpen && fg('platform_editor_a11y_table_context_menu') ? false : true
|
|
697
697
|
},
|
|
698
698
|
items: items,
|
|
699
699
|
isOpen: isOpenAllowed,
|
|
@@ -703,7 +703,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
703
703
|
onMouseLeave: this.handleItemMouseLeave,
|
|
704
704
|
fitHeight: 188,
|
|
705
705
|
fitWidth: isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth,
|
|
706
|
-
shouldFocusFirstItem: fg('
|
|
706
|
+
shouldFocusFirstItem: fg('platform_editor_a11y_table_context_menu') ? function () {
|
|
707
707
|
return Boolean(isCellMenuOpenByKeyboard);
|
|
708
708
|
} : undefined,
|
|
709
709
|
boundariesElement: boundariesElement,
|
|
@@ -711,7 +711,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
711
711
|
section: isDragAndDropEnabled ? {
|
|
712
712
|
hasSeparator: true
|
|
713
713
|
} : undefined,
|
|
714
|
-
allowEnterDefaultBehavior: fg('
|
|
714
|
+
allowEnterDefaultBehavior: fg('platform_editor_a11y_table_context_menu') ? this.state.isSubmenuOpen : false
|
|
715
715
|
}));
|
|
716
716
|
}
|
|
717
717
|
}]);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
|
+
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
4
|
+
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import type { PluginInjectionAPI } from '../types';
|
|
8
|
+
import TableCell from './TableCell';
|
|
9
|
+
import TableRow from './TableRow';
|
|
10
|
+
type TableViewOptions = {
|
|
11
|
+
portalProviderAPI: PortalProviderAPI;
|
|
12
|
+
eventDispatcher: EventDispatcher;
|
|
13
|
+
getEditorContainerWidth: GetEditorContainerWidth;
|
|
14
|
+
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
15
|
+
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
16
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
17
|
+
isTableAlignmentEnabled?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const lazyTableView: (options: TableViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor;
|
|
20
|
+
type TableCellViewOptions = {
|
|
21
|
+
eventDispatcher: EventDispatcher;
|
|
22
|
+
};
|
|
23
|
+
export declare const lazyTableCellView: (options: TableCellViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor | ((node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell);
|
|
24
|
+
export declare const lazyTableHeaderView: (options: TableCellViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor | ((node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell);
|
|
25
|
+
export declare const lazyTableRowView: (options: TableCellViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor | ((node: PMNode, view: EditorView, getPos: () => number | undefined) => TableRow);
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
|
+
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
4
|
+
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import type { PluginInjectionAPI } from '../types';
|
|
8
|
+
import TableCell from './TableCell';
|
|
9
|
+
import TableRow from './TableRow';
|
|
10
|
+
type TableViewOptions = {
|
|
11
|
+
portalProviderAPI: PortalProviderAPI;
|
|
12
|
+
eventDispatcher: EventDispatcher;
|
|
13
|
+
getEditorContainerWidth: GetEditorContainerWidth;
|
|
14
|
+
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
15
|
+
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
16
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
17
|
+
isTableAlignmentEnabled?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const lazyTableView: (options: TableViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor;
|
|
20
|
+
type TableCellViewOptions = {
|
|
21
|
+
eventDispatcher: EventDispatcher;
|
|
22
|
+
};
|
|
23
|
+
export declare const lazyTableCellView: (options: TableCellViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor | ((node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell);
|
|
24
|
+
export declare const lazyTableHeaderView: (options: TableCellViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor | ((node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell);
|
|
25
|
+
export declare const lazyTableRowView: (options: TableCellViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor | ((node: PMNode, view: EditorView, getPos: () => number | undefined) => TableRow);
|
|
26
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.21.1",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@atlaskit/adf-schema": "^39.0.3",
|
|
32
32
|
"@atlaskit/button": "^18.4.0",
|
|
33
33
|
"@atlaskit/custom-steps": "^0.4.0",
|
|
34
|
-
"@atlaskit/editor-common": "^86.
|
|
34
|
+
"@atlaskit/editor-common": "^86.2.0",
|
|
35
35
|
"@atlaskit/editor-palette": "1.6.0",
|
|
36
36
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.4.0",
|
|
@@ -102,6 +102,9 @@
|
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
104
|
"platform-feature-flags": {
|
|
105
|
+
"platform_editor_lazy-node-views": {
|
|
106
|
+
"type": "boolean"
|
|
107
|
+
},
|
|
105
108
|
"platform.editor.a11y-help-dialog-shortcut-keys-position_aghfg": {
|
|
106
109
|
"type": "boolean"
|
|
107
110
|
},
|
|
@@ -120,7 +123,7 @@
|
|
|
120
123
|
"platform.editor.table.editor-num-col-style-changes": {
|
|
121
124
|
"type": "boolean"
|
|
122
125
|
},
|
|
123
|
-
"
|
|
126
|
+
"platform_editor_a11y_table_context_menu": {
|
|
124
127
|
"type": "boolean"
|
|
125
128
|
},
|
|
126
129
|
"platform_editor_element_drag_and_drop_ed_24041": {
|
|
@@ -15,6 +15,7 @@ import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
|
15
15
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
16
16
|
import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
17
17
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
18
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
18
19
|
import type { HandleResize, HandleSize } from '@atlaskit/editor-common/resizer';
|
|
19
20
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
20
21
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
@@ -217,7 +218,31 @@ export const TableResizer = ({
|
|
|
217
218
|
|
|
218
219
|
const { formatMessage } = useIntl();
|
|
219
220
|
|
|
220
|
-
const
|
|
221
|
+
const currentSelection = editorView.state?.selection;
|
|
222
|
+
const tableFromSelection = useMemo(() => {
|
|
223
|
+
return findTable(currentSelection);
|
|
224
|
+
}, [currentSelection]);
|
|
225
|
+
const tableFromSelectionPosition = tableFromSelection?.pos;
|
|
226
|
+
const isTableSelected = useMemo(() => {
|
|
227
|
+
// Avoid call getPos if there is no table in the current selection,
|
|
228
|
+
if (typeof tableFromSelectionPosition !== 'number') {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
let currentNodePosition: number | undefined;
|
|
233
|
+
try {
|
|
234
|
+
// The React Table and the ProseMirror can endup out-of-sync
|
|
235
|
+
// ProseMirror always assume the DOM is not managed by other framework
|
|
236
|
+
currentNodePosition = getPos();
|
|
237
|
+
} catch (e) {
|
|
238
|
+
logException(e as Error, {
|
|
239
|
+
location: 'editor-plugin-table/table-resizer',
|
|
240
|
+
});
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return tableFromSelectionPosition === currentNodePosition;
|
|
245
|
+
}, [tableFromSelectionPosition, getPos]);
|
|
221
246
|
|
|
222
247
|
const resizerMinWidth = getResizerMinWidth(node);
|
|
223
248
|
const handleSize = getResizerHandleHeight(tableRef);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
2
2
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
|
|
4
5
|
import { TableCssClassName as ClassName } from '../types';
|
|
5
6
|
|
|
@@ -24,7 +25,13 @@ export class TableStickyScrollbar {
|
|
|
24
25
|
this.wrapper = wrapper;
|
|
25
26
|
this.view = view;
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
if (fg('platform_editor_lazy-node-views')) {
|
|
29
|
+
requestAnimationFrame(() => {
|
|
30
|
+
this.init();
|
|
31
|
+
});
|
|
32
|
+
} else {
|
|
33
|
+
this.init();
|
|
34
|
+
}
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
dispose() {
|