@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
|
@@ -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,
|
|
@@ -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.0",
|
|
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.1.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() {
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
|
+
import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
|
|
4
|
+
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
5
|
+
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
7
|
+
import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
+
|
|
10
|
+
import type { PluginInjectionAPI } from '../types';
|
|
11
|
+
|
|
12
|
+
// TODO: Clean up ED-23976
|
|
13
|
+
import { createTableView } from './table';
|
|
14
|
+
import TableCell from './TableCell';
|
|
15
|
+
import TableRow from './TableRow';
|
|
16
|
+
|
|
17
|
+
type TableViewOptions = {
|
|
18
|
+
portalProviderAPI: PortalProviderAPI;
|
|
19
|
+
eventDispatcher: EventDispatcher;
|
|
20
|
+
getEditorContainerWidth: GetEditorContainerWidth;
|
|
21
|
+
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
22
|
+
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
23
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
24
|
+
isTableAlignmentEnabled?: boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const lazyTableView = (options: TableViewOptions) => {
|
|
28
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
29
|
+
return (node: PMNode, view: EditorView, getPos: () => number | undefined) => {
|
|
30
|
+
return createTableView(
|
|
31
|
+
node,
|
|
32
|
+
view,
|
|
33
|
+
getPos,
|
|
34
|
+
options.portalProviderAPI,
|
|
35
|
+
options.eventDispatcher,
|
|
36
|
+
options.getEditorContainerWidth,
|
|
37
|
+
options.getEditorFeatureFlags,
|
|
38
|
+
options.dispatchAnalyticsEvent,
|
|
39
|
+
options.pluginInjectionApi,
|
|
40
|
+
options.isTableAlignmentEnabled,
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const loader = () => {
|
|
46
|
+
const result = import(
|
|
47
|
+
/* webpackChunkName: "@atlaskit-internal_editor-plugin-table_nodeview" */
|
|
48
|
+
'./table'
|
|
49
|
+
).then(({ createTableView }) => {
|
|
50
|
+
return (
|
|
51
|
+
node: PMNode,
|
|
52
|
+
view: EditorView,
|
|
53
|
+
getPos: () => number | undefined,
|
|
54
|
+
decorations: readonly Decoration[],
|
|
55
|
+
getNodeViewOptions: () => TableViewOptions,
|
|
56
|
+
) => {
|
|
57
|
+
const {
|
|
58
|
+
portalProviderAPI,
|
|
59
|
+
eventDispatcher,
|
|
60
|
+
getEditorContainerWidth,
|
|
61
|
+
getEditorFeatureFlags,
|
|
62
|
+
dispatchAnalyticsEvent,
|
|
63
|
+
pluginInjectionApi,
|
|
64
|
+
isTableAlignmentEnabled,
|
|
65
|
+
} = getNodeViewOptions();
|
|
66
|
+
|
|
67
|
+
return createTableView(
|
|
68
|
+
node,
|
|
69
|
+
view,
|
|
70
|
+
getPos,
|
|
71
|
+
portalProviderAPI,
|
|
72
|
+
eventDispatcher,
|
|
73
|
+
getEditorContainerWidth,
|
|
74
|
+
getEditorFeatureFlags,
|
|
75
|
+
dispatchAnalyticsEvent,
|
|
76
|
+
pluginInjectionApi,
|
|
77
|
+
isTableAlignmentEnabled,
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return result;
|
|
83
|
+
};
|
|
84
|
+
return withLazyLoading({
|
|
85
|
+
nodeName: 'table',
|
|
86
|
+
getNodeViewOptions: () => options,
|
|
87
|
+
loader,
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type TableCellViewOptions = {
|
|
92
|
+
eventDispatcher: EventDispatcher;
|
|
93
|
+
};
|
|
94
|
+
export const lazyTableCellView = (options: TableCellViewOptions) => {
|
|
95
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
96
|
+
return (node: PMNode, view: EditorView, getPos: () => number | undefined) => {
|
|
97
|
+
return new TableCell(node, view, getPos, options.eventDispatcher);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const loader = () => {
|
|
102
|
+
const result = import(
|
|
103
|
+
/* webpackChunkName: "@atlaskit-internal_editor-plugin-table_nodeview" */
|
|
104
|
+
'./TableCell'
|
|
105
|
+
).then(({ default: TableCell }) => {
|
|
106
|
+
return (
|
|
107
|
+
node: PMNode,
|
|
108
|
+
view: EditorView,
|
|
109
|
+
getPos: () => number | undefined,
|
|
110
|
+
decorations: readonly Decoration[],
|
|
111
|
+
getNodeViewOptions: () => TableCellViewOptions,
|
|
112
|
+
) => {
|
|
113
|
+
const { eventDispatcher } = getNodeViewOptions();
|
|
114
|
+
|
|
115
|
+
return new TableCell(node, view, getPos, eventDispatcher);
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return result;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
return withLazyLoading({
|
|
123
|
+
nodeName: 'tableCell',
|
|
124
|
+
getNodeViewOptions: () => options,
|
|
125
|
+
loader,
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const lazyTableHeaderView = (options: TableCellViewOptions) => {
|
|
130
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
131
|
+
return (node: PMNode, view: EditorView, getPos: () => number | undefined) => {
|
|
132
|
+
return new TableCell(node, view, getPos, options.eventDispatcher);
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const loader = () => {
|
|
137
|
+
const result = import(
|
|
138
|
+
/* webpackChunkName: "@atlaskit-internal_editor-plugin-table-cell_nodeview" */
|
|
139
|
+
'./TableCell'
|
|
140
|
+
).then(({ default: TableCell }) => {
|
|
141
|
+
return (
|
|
142
|
+
node: PMNode,
|
|
143
|
+
view: EditorView,
|
|
144
|
+
getPos: () => number | undefined,
|
|
145
|
+
decorations: readonly Decoration[],
|
|
146
|
+
getNodeViewOptions: () => TableCellViewOptions,
|
|
147
|
+
) => {
|
|
148
|
+
const { eventDispatcher } = getNodeViewOptions();
|
|
149
|
+
|
|
150
|
+
return new TableCell(node, view, getPos, eventDispatcher);
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
return result;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
return withLazyLoading({
|
|
158
|
+
nodeName: 'tableHeader',
|
|
159
|
+
getNodeViewOptions: () => options,
|
|
160
|
+
loader,
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export const lazyTableRowView = (options: TableCellViewOptions) => {
|
|
165
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
166
|
+
return (node: PMNode, view: EditorView, getPos: () => number | undefined) => {
|
|
167
|
+
return new TableRow(node, view, getPos, options.eventDispatcher);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const loader = () => {
|
|
172
|
+
const result = import(
|
|
173
|
+
/* webpackChunkName: "@atlaskit-internal_editor-plugin-table-row_nodeview" */
|
|
174
|
+
'./TableRow'
|
|
175
|
+
).then(({ default: TableRow }) => {
|
|
176
|
+
return (
|
|
177
|
+
node: PMNode,
|
|
178
|
+
view: EditorView,
|
|
179
|
+
getPos: () => number | undefined,
|
|
180
|
+
decorations: readonly Decoration[],
|
|
181
|
+
getNodeViewOptions: () => TableCellViewOptions,
|
|
182
|
+
) => {
|
|
183
|
+
const { eventDispatcher } = getNodeViewOptions();
|
|
184
|
+
|
|
185
|
+
return new TableRow(node, view, getPos, eventDispatcher);
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
return result;
|
|
190
|
+
};
|
|
191
|
+
return withLazyLoading({
|
|
192
|
+
nodeName: 'tableRow',
|
|
193
|
+
getNodeViewOptions: () => options,
|
|
194
|
+
loader,
|
|
195
|
+
});
|
|
196
|
+
};
|
package/src/plugin.tsx
CHANGED
|
@@ -34,6 +34,7 @@ import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
|
34
34
|
import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
35
35
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
36
36
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
37
|
+
import type { DOMOutputSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
37
38
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
38
39
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
39
40
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
@@ -66,6 +67,7 @@ import {
|
|
|
66
67
|
getPluginState as getFlexiResizingPlugin,
|
|
67
68
|
pluginKey as tableResizingPluginKey,
|
|
68
69
|
} from './pm-plugins/table-resizing';
|
|
70
|
+
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
69
71
|
import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap';
|
|
70
72
|
import {
|
|
71
73
|
createPlugin as createTableWidthPlugin,
|
|
@@ -141,6 +143,55 @@ export type TablePlugin = NextEditorPlugin<
|
|
|
141
143
|
}
|
|
142
144
|
>;
|
|
143
145
|
|
|
146
|
+
// TODO: ED-23944 Move this override to `toDOM` function on table adf-schema nodespec
|
|
147
|
+
const tableNodeSpecWithFixedToDOM = (tableOptions?: PluginConfig): typeof table => {
|
|
148
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
149
|
+
return table;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
...table,
|
|
154
|
+
toDOM: (node: PMNode): DOMOutputSpec => {
|
|
155
|
+
const attrs = {
|
|
156
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
157
|
+
'data-layout': node.attrs.layout,
|
|
158
|
+
'data-autosize': node.attrs.__autoSize,
|
|
159
|
+
'data-table-local-id': node.attrs.localId,
|
|
160
|
+
'data-table-width': node.attrs.width,
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
let colgroup: DOMOutputSpec = '';
|
|
164
|
+
|
|
165
|
+
const { allowColumnResizing } = pluginConfig(tableOptions);
|
|
166
|
+
if (allowColumnResizing) {
|
|
167
|
+
colgroup = ['colgroup', {}, ...generateColgroup(node)];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return [
|
|
171
|
+
'div',
|
|
172
|
+
{
|
|
173
|
+
class: 'tableView-content-wrap',
|
|
174
|
+
},
|
|
175
|
+
[
|
|
176
|
+
'div',
|
|
177
|
+
{
|
|
178
|
+
class: 'pm-table-container',
|
|
179
|
+
},
|
|
180
|
+
[
|
|
181
|
+
'div',
|
|
182
|
+
{
|
|
183
|
+
class: 'pm-table-wrapper',
|
|
184
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
185
|
+
'data-layout': node.attrs.layout,
|
|
186
|
+
},
|
|
187
|
+
['table', attrs, colgroup, ['tbody', 0]],
|
|
188
|
+
],
|
|
189
|
+
],
|
|
190
|
+
];
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
|
|
144
195
|
/**
|
|
145
196
|
* Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
146
197
|
* from `@atlaskit/editor-core`.
|
|
@@ -245,7 +296,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
245
296
|
|
|
246
297
|
nodes() {
|
|
247
298
|
return [
|
|
248
|
-
{ name: 'table', node:
|
|
299
|
+
{ name: 'table', node: tableNodeSpecWithFixedToDOM(options?.tableOptions) },
|
|
249
300
|
{ name: 'tableHeader', node: tableHeader },
|
|
250
301
|
{ name: 'tableRow', node: tableRow },
|
|
251
302
|
{ name: 'tableCell', node: tableCell },
|
|
@@ -531,7 +582,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
531
582
|
{targetCellPosition &&
|
|
532
583
|
(tableRef ||
|
|
533
584
|
(isCellMenuOpenByKeyboard &&
|
|
534
|
-
fg('
|
|
585
|
+
fg('platform_editor_a11y_table_context_menu'))) &&
|
|
535
586
|
!isResizing &&
|
|
536
587
|
options &&
|
|
537
588
|
options.allowContextualMenu && (
|
package/src/pm-plugins/keymap.ts
CHANGED
|
@@ -313,7 +313,7 @@ export function keymapPlugin(
|
|
|
313
313
|
list,
|
|
314
314
|
);
|
|
315
315
|
|
|
316
|
-
if (fg('
|
|
316
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
317
317
|
bindKeymapWithCommand(focusToContextMenuTrigger.common!, setFocusToCellMenu(), list);
|
|
318
318
|
}
|
|
319
319
|
|