@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
|
@@ -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
|
|
package/src/pm-plugins/main.ts
CHANGED
|
@@ -51,9 +51,12 @@ import {
|
|
|
51
51
|
whenTableInFocus,
|
|
52
52
|
withCellTracking,
|
|
53
53
|
} from '../event-handlers';
|
|
54
|
-
import {
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
import {
|
|
55
|
+
lazyTableCellView,
|
|
56
|
+
lazyTableHeaderView,
|
|
57
|
+
lazyTableRowView,
|
|
58
|
+
lazyTableView,
|
|
59
|
+
} from '../nodeviews/lazy-node-views';
|
|
57
60
|
import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plugin';
|
|
58
61
|
import { fixTables, replaceSelectedTable } from '../transforms';
|
|
59
62
|
import type {
|
|
@@ -350,22 +353,18 @@ export const createPlugin = (
|
|
|
350
353
|
return false;
|
|
351
354
|
},
|
|
352
355
|
nodeViews: {
|
|
353
|
-
table: (
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
),
|
|
366
|
-
tableRow: (node, view, getPos) => new TableRow(node, view, getPos, eventDispatcher),
|
|
367
|
-
tableCell: (node, view, getPos) => new TableCell(node, view, getPos, eventDispatcher),
|
|
368
|
-
tableHeader: (node, view, getPos) => new TableCell(node, view, getPos, eventDispatcher),
|
|
356
|
+
table: lazyTableView({
|
|
357
|
+
portalProviderAPI,
|
|
358
|
+
eventDispatcher,
|
|
359
|
+
getEditorContainerWidth,
|
|
360
|
+
getEditorFeatureFlags,
|
|
361
|
+
dispatchAnalyticsEvent,
|
|
362
|
+
pluginInjectionApi,
|
|
363
|
+
isTableAlignmentEnabled,
|
|
364
|
+
}),
|
|
365
|
+
tableRow: lazyTableRowView({ eventDispatcher }),
|
|
366
|
+
tableCell: lazyTableCellView({ eventDispatcher }),
|
|
367
|
+
tableHeader: lazyTableHeaderView({ eventDispatcher }),
|
|
369
368
|
},
|
|
370
369
|
handleDOMEvents: {
|
|
371
370
|
focus: handleFocus,
|
|
@@ -13,7 +13,7 @@ import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/e
|
|
|
13
13
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
14
14
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
15
15
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
16
|
-
import {
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
17
|
|
|
18
18
|
import { stopKeyboardColumnResizing } from '../../commands/column-resize';
|
|
19
19
|
import { updateResizeHandleDecorations } from '../../commands/misc';
|
|
@@ -112,7 +112,7 @@ export const handleMouseDown = (
|
|
|
112
112
|
isTableScalingEnabled: shouldScale,
|
|
113
113
|
shouldUseIncreasedScalingPercent:
|
|
114
114
|
isTableScalingWithFixedColumnWidthsOptionEnabled &&
|
|
115
|
-
|
|
115
|
+
fg('platform.editor.table.use-increased-scaling-percent'),
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
if (
|
|
@@ -200,7 +200,7 @@ export const handleMouseDown = (
|
|
|
200
200
|
const resizedDelta = clientX - startX;
|
|
201
201
|
const shouldUseIncreasedScalingPercent =
|
|
202
202
|
isTableScalingWithFixedColumnWidthsOptionEnabled &&
|
|
203
|
-
|
|
203
|
+
fg('platform.editor.table.use-increased-scaling-percent');
|
|
204
204
|
if (isNewColumnResizingEnabled && !isTableNested(state, tablePos)) {
|
|
205
205
|
const newResizeState = resizeColumnAndTable(
|
|
206
206
|
resizeState,
|
|
@@ -311,19 +311,21 @@ export const handleMouseDown = (
|
|
|
311
311
|
const { state } = view;
|
|
312
312
|
const { dragging, resizeHandlePos } = getPluginState(state);
|
|
313
313
|
const { isTableHovered } = getTablePluginState(state);
|
|
314
|
+
const tablePos = state.doc.resolve(start).start(-1);
|
|
315
|
+
|
|
314
316
|
if (
|
|
315
317
|
!which ||
|
|
316
318
|
!dragging ||
|
|
317
319
|
resizeHandlePos === null ||
|
|
318
320
|
!pointsAtCell(state.doc.resolve(resizeHandlePos)) ||
|
|
319
|
-
!isTableHovered
|
|
321
|
+
((!isNewColumnResizingEnabled || isTableNested(state, tablePos)) && !isTableHovered)
|
|
320
322
|
) {
|
|
321
323
|
return finish(event);
|
|
322
324
|
}
|
|
323
325
|
|
|
324
326
|
const $cell = state.doc.resolve(resizeHandlePos);
|
|
325
327
|
const table = $cell.node(-1);
|
|
326
|
-
const tablePos = state.doc.resolve(start).start(-1);
|
|
328
|
+
// const tablePos = state.doc.resolve(start).start(-1);
|
|
327
329
|
const tableDepth = state.doc.resolve(tablePos).depth;
|
|
328
330
|
const map = TableMap.get(table);
|
|
329
331
|
const colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter!.attrs.colspan - 1;
|
|
@@ -332,7 +334,7 @@ export const handleMouseDown = (
|
|
|
332
334
|
|
|
333
335
|
const shouldUseIncreasedScalingPercent =
|
|
334
336
|
isTableScalingWithFixedColumnWidthsOptionEnabled &&
|
|
335
|
-
|
|
337
|
+
fg('platform.editor.table.use-increased-scaling-percent');
|
|
336
338
|
if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
|
|
337
339
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
338
340
|
}
|
|
@@ -9,6 +9,7 @@ import { injectIntl } from 'react-intl-next';
|
|
|
9
9
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
10
10
|
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
11
11
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
12
|
+
import { focusToContextMenuTrigger } from '@atlaskit/editor-common/keymaps';
|
|
12
13
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
13
14
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
14
15
|
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
@@ -17,7 +18,7 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
|
17
18
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
18
19
|
import { akEditorSmallZIndex } from '@atlaskit/editor-shared-styles';
|
|
19
20
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
20
|
-
import {
|
|
21
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
21
22
|
|
|
22
23
|
import { toggleContextualMenu } from '../../commands';
|
|
23
24
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
@@ -73,7 +74,7 @@ const FloatingContextualButtonInner = React.memo((props: Props & WrappedComponen
|
|
|
73
74
|
targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
74
75
|
|
|
75
76
|
useEffect(() => {
|
|
76
|
-
if (
|
|
77
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
77
78
|
if (isCellMenuOpenByKeyboard && !isContextualMenuOpen) {
|
|
78
79
|
const { state, dispatch } = editorView;
|
|
79
80
|
// open the menu when the keyboard shortcut is pressed
|
|
@@ -102,13 +103,14 @@ const FloatingContextualButtonInner = React.memo((props: Props & WrappedComponen
|
|
|
102
103
|
className={ClassName.CONTEXTUAL_MENU_BUTTON}
|
|
103
104
|
selected={isContextualMenuOpen}
|
|
104
105
|
title={labelCellOptions}
|
|
106
|
+
keymap={
|
|
107
|
+
fg('platform_editor_a11y_table_context_menu') ? focusToContextMenuTrigger : undefined
|
|
108
|
+
}
|
|
105
109
|
onClick={handleClick}
|
|
106
110
|
iconBefore={<ExpandIcon label="" />}
|
|
107
111
|
aria-label={labelCellOptions}
|
|
108
112
|
aria-expanded={
|
|
109
|
-
|
|
110
|
-
? isContextualMenuOpen
|
|
111
|
-
: undefined
|
|
113
|
+
fg('platform_editor_a11y_table_context_menu') ? isContextualMenuOpen : undefined
|
|
112
114
|
}
|
|
113
115
|
/>
|
|
114
116
|
</div>
|
|
@@ -117,7 +117,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
117
117
|
private dropdownMenuRef = React.createRef<HTMLDivElement>();
|
|
118
118
|
|
|
119
119
|
componentDidMount() {
|
|
120
|
-
if (fg('
|
|
120
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
121
121
|
// ArrowKeyNavigationProvider in DropdownMenu expects that menu handle will stay focused
|
|
122
122
|
// until user pressed ArrowDown.
|
|
123
123
|
// Behavior above fails the A11Y requirement about first item in menu should be focused immediately.
|
|
@@ -141,7 +141,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
141
141
|
: this.createOriginalContextMenuItems();
|
|
142
142
|
let isOpenAllowed = false;
|
|
143
143
|
|
|
144
|
-
if (fg('
|
|
144
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
145
145
|
isOpenAllowed = isCellMenuOpenByKeyboard ? this.state.isOpenAllowed : isOpen;
|
|
146
146
|
} else {
|
|
147
147
|
isOpenAllowed = isOpen;
|
|
@@ -162,7 +162,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
162
162
|
disableArrowKeyNavigation:
|
|
163
163
|
isCellMenuOpenByKeyboard &&
|
|
164
164
|
!this.state.isSubmenuOpen &&
|
|
165
|
-
fg('
|
|
165
|
+
fg('platform_editor_a11y_table_context_menu')
|
|
166
166
|
? false
|
|
167
167
|
: true,
|
|
168
168
|
}}
|
|
@@ -177,7 +177,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
177
177
|
isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth
|
|
178
178
|
}
|
|
179
179
|
shouldFocusFirstItem={
|
|
180
|
-
fg('
|
|
180
|
+
fg('platform_editor_a11y_table_context_menu')
|
|
181
181
|
? () => {
|
|
182
182
|
return Boolean(isCellMenuOpenByKeyboard);
|
|
183
183
|
}
|
|
@@ -187,7 +187,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
187
187
|
offset={offset}
|
|
188
188
|
section={isDragAndDropEnabled ? { hasSeparator: true } : undefined}
|
|
189
189
|
allowEnterDefaultBehavior={
|
|
190
|
-
fg('
|
|
190
|
+
fg('platform_editor_a11y_table_context_menu') ? this.state.isSubmenuOpen : false
|
|
191
191
|
}
|
|
192
192
|
/>
|
|
193
193
|
</div>
|
|
@@ -227,7 +227,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
227
227
|
let selectedRowIndex;
|
|
228
228
|
let selectedColumnIndex;
|
|
229
229
|
|
|
230
|
-
if (fg('
|
|
230
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
231
231
|
const selectedRowAndColumnFromPalette = getSelectedRowAndColumnFromPalette(
|
|
232
232
|
cellBackgroundColorPalette,
|
|
233
233
|
background!,
|
|
@@ -263,7 +263,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
263
263
|
: ClassName.CONTEXTUAL_MENU_ICON
|
|
264
264
|
}
|
|
265
265
|
/>
|
|
266
|
-
{fg('
|
|
266
|
+
{fg('platform_editor_a11y_table_context_menu')
|
|
267
267
|
? isSubmenuOpen && (
|
|
268
268
|
<div
|
|
269
269
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -318,9 +318,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
318
318
|
)}
|
|
319
319
|
</div>
|
|
320
320
|
),
|
|
321
|
-
'aria-expanded': fg('
|
|
322
|
-
? isSubmenuOpen
|
|
323
|
-
: undefined,
|
|
321
|
+
'aria-expanded': fg('platform_editor_a11y_table_context_menu') ? isSubmenuOpen : undefined,
|
|
324
322
|
} as MenuItem;
|
|
325
323
|
}
|
|
326
324
|
};
|
|
@@ -650,7 +648,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
650
648
|
isCellMenuOpenByKeyboard &&
|
|
651
649
|
(item.value.name !== 'background' ||
|
|
652
650
|
(item.value.name === 'background' && this.state.isSubmenuOpen)) &&
|
|
653
|
-
fg('
|
|
651
|
+
fg('platform_editor_a11y_table_context_menu')
|
|
654
652
|
) {
|
|
655
653
|
const { tr } = state;
|
|
656
654
|
tr.setMeta(tablePluginKey, {
|
|
@@ -767,7 +765,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
767
765
|
if (
|
|
768
766
|
isCellMenuOpenByKeyboard &&
|
|
769
767
|
!this.state.isSubmenuOpen &&
|
|
770
|
-
fg('
|
|
768
|
+
fg('platform_editor_a11y_table_context_menu')
|
|
771
769
|
) {
|
|
772
770
|
this.setState({ isSubmenuOpen: true });
|
|
773
771
|
}
|
|
@@ -798,7 +796,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
798
796
|
isCellMenuOpenByKeyboard,
|
|
799
797
|
} = this.props;
|
|
800
798
|
|
|
801
|
-
if (fg('
|
|
799
|
+
if (fg('platform_editor_a11y_table_context_menu')) {
|
|
802
800
|
if (payload) {
|
|
803
801
|
const { event } = payload;
|
|
804
802
|
if (event && event instanceof KeyboardEvent) {
|