@atlaskit/editor-plugin-table 7.20.2 → 7.21.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 +17 -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/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/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/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/ui/FloatingContextualButton/index.tsx +7 -5
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -13
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
// TODO: Clean up ED-23976
|
|
4
|
+
import { createTableView } from './table';
|
|
5
|
+
import TableCell from './TableCell';
|
|
6
|
+
import TableRow from './TableRow';
|
|
7
|
+
export const lazyTableView = options => {
|
|
8
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
9
|
+
return (node, view, getPos) => {
|
|
10
|
+
return createTableView(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.isTableAlignmentEnabled);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const loader = () => {
|
|
14
|
+
const result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-table_nodeview" */
|
|
15
|
+
'./table').then(({
|
|
16
|
+
createTableView
|
|
17
|
+
}) => {
|
|
18
|
+
return (node, view, getPos, decorations, getNodeViewOptions) => {
|
|
19
|
+
const {
|
|
20
|
+
portalProviderAPI,
|
|
21
|
+
eventDispatcher,
|
|
22
|
+
getEditorContainerWidth,
|
|
23
|
+
getEditorFeatureFlags,
|
|
24
|
+
dispatchAnalyticsEvent,
|
|
25
|
+
pluginInjectionApi,
|
|
26
|
+
isTableAlignmentEnabled
|
|
27
|
+
} = getNodeViewOptions();
|
|
28
|
+
return createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isTableAlignmentEnabled);
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
return withLazyLoading({
|
|
34
|
+
nodeName: 'table',
|
|
35
|
+
getNodeViewOptions: () => options,
|
|
36
|
+
loader
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export const lazyTableCellView = options => {
|
|
40
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
41
|
+
return (node, view, getPos) => {
|
|
42
|
+
return new TableCell(node, view, getPos, options.eventDispatcher);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const loader = () => {
|
|
46
|
+
const result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-table_nodeview" */
|
|
47
|
+
'./TableCell').then(({
|
|
48
|
+
default: TableCell
|
|
49
|
+
}) => {
|
|
50
|
+
return (node, view, getPos, decorations, getNodeViewOptions) => {
|
|
51
|
+
const {
|
|
52
|
+
eventDispatcher
|
|
53
|
+
} = getNodeViewOptions();
|
|
54
|
+
return new TableCell(node, view, getPos, eventDispatcher);
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
return withLazyLoading({
|
|
60
|
+
nodeName: 'tableCell',
|
|
61
|
+
getNodeViewOptions: () => options,
|
|
62
|
+
loader
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
export const lazyTableHeaderView = options => {
|
|
66
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
67
|
+
return (node, view, getPos) => {
|
|
68
|
+
return new TableCell(node, view, getPos, options.eventDispatcher);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const loader = () => {
|
|
72
|
+
const result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-table-cell_nodeview" */
|
|
73
|
+
'./TableCell').then(({
|
|
74
|
+
default: TableCell
|
|
75
|
+
}) => {
|
|
76
|
+
return (node, view, getPos, decorations, getNodeViewOptions) => {
|
|
77
|
+
const {
|
|
78
|
+
eventDispatcher
|
|
79
|
+
} = getNodeViewOptions();
|
|
80
|
+
return new TableCell(node, view, getPos, eventDispatcher);
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
return result;
|
|
84
|
+
};
|
|
85
|
+
return withLazyLoading({
|
|
86
|
+
nodeName: 'tableHeader',
|
|
87
|
+
getNodeViewOptions: () => options,
|
|
88
|
+
loader
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
export const lazyTableRowView = options => {
|
|
92
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
93
|
+
return (node, view, getPos) => {
|
|
94
|
+
return new TableRow(node, view, getPos, options.eventDispatcher);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const loader = () => {
|
|
98
|
+
const result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-table-row_nodeview" */
|
|
99
|
+
'./TableRow').then(({
|
|
100
|
+
default: TableRow
|
|
101
|
+
}) => {
|
|
102
|
+
return (node, view, getPos, decorations, getNodeViewOptions) => {
|
|
103
|
+
const {
|
|
104
|
+
eventDispatcher
|
|
105
|
+
} = getNodeViewOptions();
|
|
106
|
+
return new TableRow(node, view, getPos, eventDispatcher);
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
return result;
|
|
110
|
+
};
|
|
111
|
+
return withLazyLoading({
|
|
112
|
+
nodeName: 'tableRow',
|
|
113
|
+
getNodeViewOptions: () => options,
|
|
114
|
+
loader
|
|
115
|
+
});
|
|
116
|
+
};
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -26,6 +26,7 @@ import { createPlugin as createStickyHeadersPlugin, findStickyHeaderForTable, pl
|
|
|
26
26
|
import { createPlugin as createTableOverflowAnalyticsPlugin } from './pm-plugins/table-analytics';
|
|
27
27
|
import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
|
|
28
28
|
import { createPlugin as createFlexiResizingPlugin, getPluginState as getFlexiResizingPlugin, pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
29
|
+
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
29
30
|
import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap';
|
|
30
31
|
import { createPlugin as createTableWidthPlugin, pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
|
|
31
32
|
import { createPlugin as createViewModeSortPlugin } from './pm-plugins/view-mode-sort';
|
|
@@ -42,6 +43,41 @@ const defaultGetEditorFeatureFlags = () => ({});
|
|
|
42
43
|
|
|
43
44
|
// TODO: duplicating type instead of importing media plugin causing a circular dependency
|
|
44
45
|
|
|
46
|
+
// TODO: ED-23944 Move this override to `toDOM` function on table adf-schema nodespec
|
|
47
|
+
const tableNodeSpecWithFixedToDOM = tableOptions => {
|
|
48
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
49
|
+
return table;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
...table,
|
|
53
|
+
toDOM: node => {
|
|
54
|
+
const attrs = {
|
|
55
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
56
|
+
'data-layout': node.attrs.layout,
|
|
57
|
+
'data-autosize': node.attrs.__autoSize,
|
|
58
|
+
'data-table-local-id': node.attrs.localId,
|
|
59
|
+
'data-table-width': node.attrs.width
|
|
60
|
+
};
|
|
61
|
+
let colgroup = '';
|
|
62
|
+
const {
|
|
63
|
+
allowColumnResizing
|
|
64
|
+
} = pluginConfig(tableOptions);
|
|
65
|
+
if (allowColumnResizing) {
|
|
66
|
+
colgroup = ['colgroup', {}, ...generateColgroup(node)];
|
|
67
|
+
}
|
|
68
|
+
return ['div', {
|
|
69
|
+
class: 'tableView-content-wrap'
|
|
70
|
+
}, ['div', {
|
|
71
|
+
class: 'pm-table-container'
|
|
72
|
+
}, ['div', {
|
|
73
|
+
class: 'pm-table-wrapper',
|
|
74
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
75
|
+
'data-layout': node.attrs.layout
|
|
76
|
+
}, ['table', attrs, colgroup, ['tbody', 0]]]]];
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
45
81
|
/**
|
|
46
82
|
* Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
47
83
|
* from `@atlaskit/editor-core`.
|
|
@@ -126,7 +162,7 @@ const tablesPlugin = ({
|
|
|
126
162
|
nodes() {
|
|
127
163
|
return [{
|
|
128
164
|
name: 'table',
|
|
129
|
-
node:
|
|
165
|
+
node: tableNodeSpecWithFixedToDOM(options === null || options === void 0 ? void 0 : options.tableOptions)
|
|
130
166
|
}, {
|
|
131
167
|
name: 'tableHeader',
|
|
132
168
|
node: tableHeader
|
|
@@ -357,7 +393,7 @@ const tablesPlugin = ({
|
|
|
357
393
|
allowControls
|
|
358
394
|
} = pluginConfig;
|
|
359
395
|
const stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
360
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard && fg('
|
|
396
|
+
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, {
|
|
361
397
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
362
398
|
editorView: editorView,
|
|
363
399
|
tableNode: tableNode,
|
|
@@ -67,7 +67,7 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
67
67
|
ariaNotify: ariaNotifyPlugin,
|
|
68
68
|
getIntl: getIntl
|
|
69
69
|
}), list);
|
|
70
|
-
if (fg('
|
|
70
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
71
71
|
bindKeymapWithCommand(focusToContextMenuTrigger.common, setFocusToCellMenu(), list);
|
|
72
72
|
}
|
|
73
73
|
return keymap(list);
|
|
@@ -11,9 +11,7 @@ import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../
|
|
|
11
11
|
import { stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
12
12
|
import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
13
13
|
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleMouseUp, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
|
|
14
|
-
import {
|
|
15
|
-
import TableCell from '../nodeviews/TableCell';
|
|
16
|
-
import TableRow from '../nodeviews/TableRow';
|
|
14
|
+
import { lazyTableCellView, lazyTableHeaderView, lazyTableRowView, lazyTableView } from '../nodeviews/lazy-node-views';
|
|
17
15
|
import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plugin';
|
|
18
16
|
import { fixTables, replaceSelectedTable } from '../transforms';
|
|
19
17
|
import { TableCssClassName as ClassName } from '../types';
|
|
@@ -256,10 +254,24 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
256
254
|
return false;
|
|
257
255
|
},
|
|
258
256
|
nodeViews: {
|
|
259
|
-
table: (
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
257
|
+
table: lazyTableView({
|
|
258
|
+
portalProviderAPI,
|
|
259
|
+
eventDispatcher,
|
|
260
|
+
getEditorContainerWidth,
|
|
261
|
+
getEditorFeatureFlags,
|
|
262
|
+
dispatchAnalyticsEvent,
|
|
263
|
+
pluginInjectionApi,
|
|
264
|
+
isTableAlignmentEnabled
|
|
265
|
+
}),
|
|
266
|
+
tableRow: lazyTableRowView({
|
|
267
|
+
eventDispatcher
|
|
268
|
+
}),
|
|
269
|
+
tableCell: lazyTableCellView({
|
|
270
|
+
eventDispatcher
|
|
271
|
+
}),
|
|
272
|
+
tableHeader: lazyTableHeaderView({
|
|
273
|
+
eventDispatcher
|
|
274
|
+
})
|
|
263
275
|
},
|
|
264
276
|
handleDOMEvents: {
|
|
265
277
|
focus: handleFocus,
|
|
@@ -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';
|
|
@@ -51,7 +52,7 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
51
52
|
let targetCellRef;
|
|
52
53
|
targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
53
54
|
useEffect(() => {
|
|
54
|
-
if (
|
|
55
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
55
56
|
if (isCellMenuOpenByKeyboard && !isContextualMenuOpen) {
|
|
56
57
|
const {
|
|
57
58
|
state,
|
|
@@ -78,12 +79,13 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
78
79
|
className: ClassName.CONTEXTUAL_MENU_BUTTON,
|
|
79
80
|
selected: isContextualMenuOpen,
|
|
80
81
|
title: labelCellOptions,
|
|
82
|
+
keymap: fg('platform_editor_a11y_table_context_menu') ? focusToContextMenuTrigger : undefined,
|
|
81
83
|
onClick: handleClick,
|
|
82
84
|
iconBefore: jsx(ExpandIcon, {
|
|
83
85
|
label: ""
|
|
84
86
|
}),
|
|
85
87
|
"aria-label": labelCellOptions,
|
|
86
|
-
"aria-expanded":
|
|
88
|
+
"aria-expanded": fg('platform_editor_a11y_table_context_menu') ? isContextualMenuOpen : undefined
|
|
87
89
|
}));
|
|
88
90
|
const parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
89
91
|
if (stickyHeader && parentSticky && tableWrapper) {
|
|
@@ -77,7 +77,7 @@ export class ContextualMenu extends Component {
|
|
|
77
77
|
const background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
78
78
|
let selectedRowIndex;
|
|
79
79
|
let selectedColumnIndex;
|
|
80
|
-
if (fg('
|
|
80
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
81
81
|
const selectedRowAndColumnFromPalette = getSelectedRowAndColumnFromPalette(cellBackgroundColorPalette, background, colorPalletteColumns);
|
|
82
82
|
selectedRowIndex = selectedRowAndColumnFromPalette.selectedRowIndex;
|
|
83
83
|
selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
@@ -105,7 +105,7 @@ export class ContextualMenu extends Component {
|
|
|
105
105
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
106
106
|
,
|
|
107
107
|
className: isDragAndDropEnabled ? ClassName.CONTEXTUAL_MENU_ICON_SMALL : ClassName.CONTEXTUAL_MENU_ICON
|
|
108
|
-
}), fg('
|
|
108
|
+
}), fg('platform_editor_a11y_table_context_menu') ? isSubmenuOpen && jsx("div", {
|
|
109
109
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
110
110
|
className: ClassName.CONTEXTUAL_SUBMENU,
|
|
111
111
|
ref: this.handleSubMenuRef
|
|
@@ -150,7 +150,7 @@ export class ContextualMenu extends Component {
|
|
|
150
150
|
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
151
151
|
}
|
|
152
152
|
}))),
|
|
153
|
-
'aria-expanded': fg('
|
|
153
|
+
'aria-expanded': fg('platform_editor_a11y_table_context_menu') ? isSubmenuOpen : undefined
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
});
|
|
@@ -500,7 +500,7 @@ export class ContextualMenu extends Component {
|
|
|
500
500
|
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
501
501
|
// context menu opened by keyboard and any item except 'background' activated
|
|
502
502
|
// or color has been chosen from color palette
|
|
503
|
-
if (isCellMenuOpenByKeyboard && (item.value.name !== 'background' || item.value.name === 'background' && this.state.isSubmenuOpen) && fg('
|
|
503
|
+
if (isCellMenuOpenByKeyboard && (item.value.name !== 'background' || item.value.name === 'background' && this.state.isSubmenuOpen) && fg('platform_editor_a11y_table_context_menu')) {
|
|
504
504
|
const {
|
|
505
505
|
tr
|
|
506
506
|
} = state;
|
|
@@ -572,7 +572,7 @@ export class ContextualMenu extends Component {
|
|
|
572
572
|
// 1st time when user chooses the background color item.
|
|
573
573
|
// 2nd when color has been chosen from color palette.
|
|
574
574
|
// here we are handling the 1st call relying on the isSubmenuOpen state value
|
|
575
|
-
if (isCellMenuOpenByKeyboard && !this.state.isSubmenuOpen && fg('
|
|
575
|
+
if (isCellMenuOpenByKeyboard && !this.state.isSubmenuOpen && fg('platform_editor_a11y_table_context_menu')) {
|
|
576
576
|
this.setState({
|
|
577
577
|
isSubmenuOpen: true
|
|
578
578
|
});
|
|
@@ -605,7 +605,7 @@ export class ContextualMenu extends Component {
|
|
|
605
605
|
},
|
|
606
606
|
isCellMenuOpenByKeyboard
|
|
607
607
|
} = this.props;
|
|
608
|
-
if (fg('
|
|
608
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
609
609
|
if (payload) {
|
|
610
610
|
const {
|
|
611
611
|
event
|
|
@@ -704,7 +704,7 @@ export class ContextualMenu extends Component {
|
|
|
704
704
|
});
|
|
705
705
|
}
|
|
706
706
|
componentDidMount() {
|
|
707
|
-
if (fg('
|
|
707
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
708
708
|
// ArrowKeyNavigationProvider in DropdownMenu expects that menu handle will stay focused
|
|
709
709
|
// until user pressed ArrowDown.
|
|
710
710
|
// Behavior above fails the A11Y requirement about first item in menu should be focused immediately.
|
|
@@ -734,7 +734,7 @@ export class ContextualMenu extends Component {
|
|
|
734
734
|
} = getPluginState(editorView.state);
|
|
735
735
|
const items = isDragAndDropEnabled ? this.createNewContextMenuItems() : this.createOriginalContextMenuItems();
|
|
736
736
|
let isOpenAllowed = false;
|
|
737
|
-
if (fg('
|
|
737
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
738
738
|
isOpenAllowed = isCellMenuOpenByKeyboard ? this.state.isOpenAllowed : isOpen;
|
|
739
739
|
} else {
|
|
740
740
|
isOpenAllowed = isOpen;
|
|
@@ -750,7 +750,7 @@ export class ContextualMenu extends Component {
|
|
|
750
750
|
,
|
|
751
751
|
arrowKeyNavigationProviderOptions: {
|
|
752
752
|
type: ArrowKeyNavigationType.MENU,
|
|
753
|
-
disableArrowKeyNavigation: isCellMenuOpenByKeyboard && !this.state.isSubmenuOpen && fg('
|
|
753
|
+
disableArrowKeyNavigation: isCellMenuOpenByKeyboard && !this.state.isSubmenuOpen && fg('platform_editor_a11y_table_context_menu') ? false : true
|
|
754
754
|
},
|
|
755
755
|
items: items,
|
|
756
756
|
isOpen: isOpenAllowed,
|
|
@@ -760,7 +760,7 @@ export class ContextualMenu extends Component {
|
|
|
760
760
|
onMouseLeave: this.handleItemMouseLeave,
|
|
761
761
|
fitHeight: 188,
|
|
762
762
|
fitWidth: isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth,
|
|
763
|
-
shouldFocusFirstItem: fg('
|
|
763
|
+
shouldFocusFirstItem: fg('platform_editor_a11y_table_context_menu') ? () => {
|
|
764
764
|
return Boolean(isCellMenuOpenByKeyboard);
|
|
765
765
|
} : undefined,
|
|
766
766
|
boundariesElement: boundariesElement,
|
|
@@ -768,7 +768,7 @@ export class ContextualMenu extends Component {
|
|
|
768
768
|
section: isDragAndDropEnabled ? {
|
|
769
769
|
hasSeparator: true
|
|
770
770
|
} : undefined,
|
|
771
|
-
allowEnterDefaultBehavior: fg('
|
|
771
|
+
allowEnterDefaultBehavior: fg('platform_editor_a11y_table_context_menu') ? this.state.isSubmenuOpen : false
|
|
772
772
|
}));
|
|
773
773
|
}
|
|
774
774
|
}
|
|
@@ -10,6 +10,7 @@ import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
|
10
10
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
11
11
|
import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
12
12
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
13
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
13
14
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
14
15
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
15
16
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
@@ -91,7 +92,7 @@ var getVisibleGuidelines = function getVisibleGuidelines(guidelines, containerWi
|
|
|
91
92
|
});
|
|
92
93
|
};
|
|
93
94
|
export var TableResizer = function TableResizer(_ref) {
|
|
94
|
-
var
|
|
95
|
+
var _editorView$state, _pluginInjectionApi$a2;
|
|
95
96
|
var children = _ref.children,
|
|
96
97
|
width = _ref.width,
|
|
97
98
|
maxWidth = _ref.maxWidth,
|
|
@@ -132,7 +133,29 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
132
133
|
setSnappingEnabled = _useState2[1];
|
|
133
134
|
var _useIntl = useIntl(),
|
|
134
135
|
formatMessage = _useIntl.formatMessage;
|
|
135
|
-
var
|
|
136
|
+
var currentSelection = (_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection;
|
|
137
|
+
var tableFromSelection = useMemo(function () {
|
|
138
|
+
return findTable(currentSelection);
|
|
139
|
+
}, [currentSelection]);
|
|
140
|
+
var tableFromSelectionPosition = tableFromSelection === null || tableFromSelection === void 0 ? void 0 : tableFromSelection.pos;
|
|
141
|
+
var isTableSelected = useMemo(function () {
|
|
142
|
+
// Avoid call getPos if there is no table in the current selection,
|
|
143
|
+
if (typeof tableFromSelectionPosition !== 'number') {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
var currentNodePosition;
|
|
147
|
+
try {
|
|
148
|
+
// The React Table and the ProseMirror can endup out-of-sync
|
|
149
|
+
// ProseMirror always assume the DOM is not managed by other framework
|
|
150
|
+
currentNodePosition = getPos();
|
|
151
|
+
} catch (e) {
|
|
152
|
+
logException(e, {
|
|
153
|
+
location: 'editor-plugin-table/table-resizer'
|
|
154
|
+
});
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
return tableFromSelectionPosition === currentNodePosition;
|
|
158
|
+
}, [tableFromSelectionPosition, getPos]);
|
|
136
159
|
var resizerMinWidth = getResizerMinWidth(node);
|
|
137
160
|
var handleSize = getResizerHandleHeight(tableRef);
|
|
138
161
|
var _useMeasureFramerate = useMeasureFramerate(),
|
|
@@ -2,6 +2,7 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { TableCssClassName as ClassName } from '../types';
|
|
6
7
|
export var TableStickyScrollbar = /*#__PURE__*/function () {
|
|
7
8
|
function TableStickyScrollbar(wrapper, view) {
|
|
@@ -16,7 +17,13 @@ export var TableStickyScrollbar = /*#__PURE__*/function () {
|
|
|
16
17
|
});
|
|
17
18
|
this.wrapper = wrapper;
|
|
18
19
|
this.view = view;
|
|
19
|
-
|
|
20
|
+
if (fg('platform_editor_lazy-node-views')) {
|
|
21
|
+
requestAnimationFrame(function () {
|
|
22
|
+
_this.init();
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
this.init();
|
|
26
|
+
}
|
|
20
27
|
}
|
|
21
28
|
_createClass(TableStickyScrollbar, [{
|
|
22
29
|
key: "dispose",
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
// TODO: Clean up ED-23976
|
|
4
|
+
import { createTableView } from './table';
|
|
5
|
+
import TableCell from './TableCell';
|
|
6
|
+
import TableRow from './TableRow';
|
|
7
|
+
export var lazyTableView = function lazyTableView(options) {
|
|
8
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
9
|
+
return function (node, view, getPos) {
|
|
10
|
+
return createTableView(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.isTableAlignmentEnabled);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
var loader = function loader() {
|
|
14
|
+
var result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-table_nodeview" */
|
|
15
|
+
'./table').then(function (_ref) {
|
|
16
|
+
var createTableView = _ref.createTableView;
|
|
17
|
+
return function (node, view, getPos, decorations, getNodeViewOptions) {
|
|
18
|
+
var _getNodeViewOptions = getNodeViewOptions(),
|
|
19
|
+
portalProviderAPI = _getNodeViewOptions.portalProviderAPI,
|
|
20
|
+
eventDispatcher = _getNodeViewOptions.eventDispatcher,
|
|
21
|
+
getEditorContainerWidth = _getNodeViewOptions.getEditorContainerWidth,
|
|
22
|
+
getEditorFeatureFlags = _getNodeViewOptions.getEditorFeatureFlags,
|
|
23
|
+
dispatchAnalyticsEvent = _getNodeViewOptions.dispatchAnalyticsEvent,
|
|
24
|
+
pluginInjectionApi = _getNodeViewOptions.pluginInjectionApi,
|
|
25
|
+
isTableAlignmentEnabled = _getNodeViewOptions.isTableAlignmentEnabled;
|
|
26
|
+
return createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isTableAlignmentEnabled);
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
return withLazyLoading({
|
|
32
|
+
nodeName: 'table',
|
|
33
|
+
getNodeViewOptions: function getNodeViewOptions() {
|
|
34
|
+
return options;
|
|
35
|
+
},
|
|
36
|
+
loader: loader
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export var lazyTableCellView = function lazyTableCellView(options) {
|
|
40
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
41
|
+
return function (node, view, getPos) {
|
|
42
|
+
return new TableCell(node, view, getPos, options.eventDispatcher);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
var loader = function loader() {
|
|
46
|
+
var result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-table_nodeview" */
|
|
47
|
+
'./TableCell').then(function (_ref2) {
|
|
48
|
+
var TableCell = _ref2.default;
|
|
49
|
+
return function (node, view, getPos, decorations, getNodeViewOptions) {
|
|
50
|
+
var _getNodeViewOptions2 = getNodeViewOptions(),
|
|
51
|
+
eventDispatcher = _getNodeViewOptions2.eventDispatcher;
|
|
52
|
+
return new TableCell(node, view, getPos, eventDispatcher);
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
return withLazyLoading({
|
|
58
|
+
nodeName: 'tableCell',
|
|
59
|
+
getNodeViewOptions: function getNodeViewOptions() {
|
|
60
|
+
return options;
|
|
61
|
+
},
|
|
62
|
+
loader: loader
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
export var lazyTableHeaderView = function lazyTableHeaderView(options) {
|
|
66
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
67
|
+
return function (node, view, getPos) {
|
|
68
|
+
return new TableCell(node, view, getPos, options.eventDispatcher);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
var loader = function loader() {
|
|
72
|
+
var result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-table-cell_nodeview" */
|
|
73
|
+
'./TableCell').then(function (_ref3) {
|
|
74
|
+
var TableCell = _ref3.default;
|
|
75
|
+
return function (node, view, getPos, decorations, getNodeViewOptions) {
|
|
76
|
+
var _getNodeViewOptions3 = getNodeViewOptions(),
|
|
77
|
+
eventDispatcher = _getNodeViewOptions3.eventDispatcher;
|
|
78
|
+
return new TableCell(node, view, getPos, eventDispatcher);
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
return result;
|
|
82
|
+
};
|
|
83
|
+
return withLazyLoading({
|
|
84
|
+
nodeName: 'tableHeader',
|
|
85
|
+
getNodeViewOptions: function getNodeViewOptions() {
|
|
86
|
+
return options;
|
|
87
|
+
},
|
|
88
|
+
loader: loader
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
export var lazyTableRowView = function lazyTableRowView(options) {
|
|
92
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
93
|
+
return function (node, view, getPos) {
|
|
94
|
+
return new TableRow(node, view, getPos, options.eventDispatcher);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
var loader = function loader() {
|
|
98
|
+
var result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-table-row_nodeview" */
|
|
99
|
+
'./TableRow').then(function (_ref4) {
|
|
100
|
+
var TableRow = _ref4.default;
|
|
101
|
+
return function (node, view, getPos, decorations, getNodeViewOptions) {
|
|
102
|
+
var _getNodeViewOptions4 = getNodeViewOptions(),
|
|
103
|
+
eventDispatcher = _getNodeViewOptions4.eventDispatcher;
|
|
104
|
+
return new TableRow(node, view, getPos, eventDispatcher);
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
return result;
|
|
108
|
+
};
|
|
109
|
+
return withLazyLoading({
|
|
110
|
+
nodeName: 'tableRow',
|
|
111
|
+
getNodeViewOptions: function getNodeViewOptions() {
|
|
112
|
+
return options;
|
|
113
|
+
},
|
|
114
|
+
loader: loader
|
|
115
|
+
});
|
|
116
|
+
};
|
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);
|