@atlaskit/editor-plugin-table 15.3.14 → 15.3.16
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/TableRowNativeStickyWithFallback.js +785 -0
- package/dist/cjs/nodeviews/table-node-views.js +7 -1
- package/dist/cjs/types/index.js +2 -1
- package/dist/cjs/ui/common-styles.js +2 -2
- package/dist/cjs/ui/toolbar.js +47 -15
- package/dist/es2019/nodeviews/TableRowNativeStickyWithFallback.js +721 -0
- package/dist/es2019/nodeviews/table-node-views.js +7 -1
- package/dist/es2019/types/index.js +2 -1
- package/dist/es2019/ui/common-styles.js +11 -1
- package/dist/es2019/ui/toolbar.js +47 -18
- package/dist/esm/nodeviews/TableRowNativeStickyWithFallback.js +779 -0
- package/dist/esm/nodeviews/table-node-views.js +7 -1
- package/dist/esm/types/index.js +2 -1
- package/dist/esm/ui/common-styles.js +2 -2
- package/dist/esm/ui/toolbar.js +47 -15
- package/dist/types/nodeviews/TableRowNativeStickyWithFallback.d.ts +72 -0
- package/dist/types/nodeviews/table-node-views.d.ts +2 -1
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/ui/toolbar.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableRowNativeStickyWithFallback.d.ts +72 -0
- package/dist/types-ts4.5/nodeviews/table-node-views.d.ts +2 -1
- package/dist/types-ts4.5/types/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/toolbar.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
1
2
|
// TODO: ED-23976 - Clean up
|
|
2
3
|
import { createTableView } from './table';
|
|
3
4
|
import TableCell from './TableCell';
|
|
4
5
|
import TableRow from './TableRow';
|
|
6
|
+
import TableRowNativeStickyWithFallback from './TableRowNativeStickyWithFallback';
|
|
5
7
|
export const tableView = options => {
|
|
6
8
|
return (node, view, getPos) => {
|
|
7
9
|
return createTableView(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.isCommentEditor, options.isChromelessEditor);
|
|
@@ -21,6 +23,10 @@ export const tableHeaderView = options => {
|
|
|
21
23
|
};
|
|
22
24
|
export const tableRowView = options => {
|
|
23
25
|
return (node, view, getPos) => {
|
|
24
|
-
|
|
26
|
+
if (expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
|
|
27
|
+
return new TableRowNativeStickyWithFallback(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
|
|
28
|
+
} else {
|
|
29
|
+
return new TableRow(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
|
|
30
|
+
}
|
|
25
31
|
};
|
|
26
32
|
};
|
|
@@ -161,7 +161,8 @@ export const TableCssClassName = {
|
|
|
161
161
|
WITH_ROW_INSERT_LINE: `${tablePrefixSelector}-row-insert-line`,
|
|
162
162
|
WITH_ROW_INSERT_LINE_INACTIVE: `${tablePrefixSelector}-row-insert-line__inactive`,
|
|
163
163
|
WITH_LAST_ROW_INSERT_LINE: `${tablePrefixSelector}-last-row-insert-line`,
|
|
164
|
-
WITH_LAST_ROW_INSERT_LINE_INACTIVE: `${tablePrefixSelector}-last-row-insert-line__inactive
|
|
164
|
+
WITH_LAST_ROW_INSERT_LINE_INACTIVE: `${tablePrefixSelector}-last-row-insert-line__inactive`,
|
|
165
|
+
NATIVE_STICKY: `${tablePrefixSelector}-row-native-sticky`
|
|
165
166
|
};
|
|
166
167
|
export let ShadowEvent = /*#__PURE__*/function (ShadowEvent) {
|
|
167
168
|
ShadowEvent["SHOW_BEFORE_SHADOW"] = "showBeforeShadow";
|
|
@@ -212,7 +212,7 @@ const tableScrollInlineShadowStyles = () => {
|
|
|
212
212
|
return css`
|
|
213
213
|
.${ClassName.TABLE_SCROLL_INLINE_SHADOW} {
|
|
214
214
|
--editor-table-shadow-cover: #fff;
|
|
215
|
-
--editor-table-shadow-color: ${"var(--ds-shadow-overflow-spread, #
|
|
215
|
+
--editor-table-shadow-color: ${"var(--ds-shadow-overflow-spread, #1E1F2129)"};
|
|
216
216
|
--editor-table-shadow-size: ${"var(--ds-space-100, 8px)"};
|
|
217
217
|
background-image:
|
|
218
218
|
linear-gradient(to right, var(--editor-table-shadow-cover) 33%, transparent),
|
|
@@ -461,6 +461,12 @@ export const baseTableStyles = props => {
|
|
|
461
461
|
z-index: 1;
|
|
462
462
|
}
|
|
463
463
|
|
|
464
|
+
tr.${ClassName.NATIVE_STICKY} {
|
|
465
|
+
position: sticky;
|
|
466
|
+
top: 0;
|
|
467
|
+
z-index: ${akEditorTableCellOnStickyHeaderZIndex};
|
|
468
|
+
}
|
|
469
|
+
|
|
464
470
|
.${ClassName.WITH_CONTROLS} tr.sticky {
|
|
465
471
|
padding-top: ${tableControlsSpacing}px;
|
|
466
472
|
}
|
|
@@ -1108,6 +1114,10 @@ export const baseTableStyles = props => {
|
|
|
1108
1114
|
overflow-y: hidden;
|
|
1109
1115
|
position: relative;
|
|
1110
1116
|
}
|
|
1117
|
+
|
|
1118
|
+
.${ClassName.TABLE_NODE_WRAPPER}.${ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW} {
|
|
1119
|
+
overflow: visible;
|
|
1120
|
+
}
|
|
1111
1121
|
`;
|
|
1112
1122
|
};
|
|
1113
1123
|
|
|
@@ -129,7 +129,7 @@ export const getToolbarMenuConfig = (config, state, {
|
|
|
129
129
|
// with native widgets. It's enabled via a plugin config.
|
|
130
130
|
export const getToolbarCellOptionsConfig = (editorState, editorView, initialSelectionRect, {
|
|
131
131
|
formatMessage
|
|
132
|
-
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => {
|
|
132
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false, isLimitedModeEnabled = false) => {
|
|
133
133
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
134
134
|
const {
|
|
135
135
|
top,
|
|
@@ -230,15 +230,35 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
233
|
+
let wouldChange = true; // Default to enabled - show the button.
|
|
234
|
+
let newResizeStateWithAnalytics;
|
|
235
|
+
|
|
236
|
+
// Performance optimization: Skip expensive getTableScalingPercent() DOM query when limited mode is enabled.
|
|
237
|
+
// This avoids layout reflows on every transaction. Instead, button stays enabled and calculates on-demand when clicked.
|
|
238
|
+
if (!expValEquals('cc_editor_limited_mode_table_align_bttn', 'isEnabled', true) || !isLimitedModeEnabled) {
|
|
239
|
+
var _newResizeStateWithAn, _newResizeStateWithAn2;
|
|
240
|
+
newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, isCommentEditor) : undefined;
|
|
241
|
+
wouldChange = (_newResizeStateWithAn = (_newResizeStateWithAn2 = newResizeStateWithAnalytics) === null || _newResizeStateWithAn2 === void 0 ? void 0 : _newResizeStateWithAn2.changed) !== null && _newResizeStateWithAn !== void 0 ? _newResizeStateWithAn : false;
|
|
242
|
+
}
|
|
243
|
+
const distributeColumnWidths = (state, dispatch, view) => {
|
|
244
|
+
// When optimization is enabled, calculate on-demand when clicked
|
|
245
|
+
if (expValEquals('cc_editor_limited_mode_table_align_bttn', 'isEnabled', true) && isLimitedModeEnabled) {
|
|
246
|
+
if (view) {
|
|
247
|
+
const resizeState = getNewResizeStateFromSelectedColumns(initialSelectionRect, state, view.domAtPos.bind(view), getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, isCommentEditor);
|
|
248
|
+
if (resizeState) {
|
|
249
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI, api)(INPUT_METHOD.FLOATING_TB, resizeState)(state, dispatch);
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return false;
|
|
254
|
+
} else {
|
|
255
|
+
// Original behavior: use pre-calculated state
|
|
256
|
+
if (newResizeStateWithAnalytics) {
|
|
257
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI, api)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
return false;
|
|
240
261
|
}
|
|
241
|
-
return false;
|
|
242
262
|
};
|
|
243
263
|
options.push({
|
|
244
264
|
id: 'editor.table.distributeColumns',
|
|
@@ -389,7 +409,7 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
|
|
|
389
409
|
// We don't want to show floating toolbar while resizing the table
|
|
390
410
|
const isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
391
411
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
392
|
-
var _api$extension, _api$extension$shared, _api$extension2;
|
|
412
|
+
var _api$limitedMode$shar, _api$limitedMode, _api$limitedMode$shar2, _api$extension, _api$extension$shared, _api$extension2;
|
|
393
413
|
const isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
|
|
394
414
|
const isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
|
|
395
415
|
const areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
|
|
@@ -411,8 +431,9 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
|
|
|
411
431
|
};
|
|
412
432
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown, areTableColumWidthsFixed);
|
|
413
433
|
const alignmentMenu = config.allowTableAlignment && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth, editorView, shouldUseIncreasedScalingPercent, areAnyNewToolbarFlagsEnabled, options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor) : [];
|
|
414
|
-
const
|
|
415
|
-
const
|
|
434
|
+
const isLimitedModeEnabled = (_api$limitedMode$shar = api === null || api === void 0 ? void 0 : (_api$limitedMode = api.limitedMode) === null || _api$limitedMode === void 0 ? void 0 : (_api$limitedMode$shar2 = _api$limitedMode.sharedState.currentState()) === null || _api$limitedMode$shar2 === void 0 ? void 0 : _api$limitedMode$shar2.enabled) !== null && _api$limitedMode$shar !== void 0 ? _api$limitedMode$shar : false;
|
|
435
|
+
const cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor, isLimitedModeEnabled);
|
|
436
|
+
const columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor, isLimitedModeEnabled) : [];
|
|
416
437
|
const colorPicker = !areAnyNewToolbarFlagsEnabled ? getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView) : [];
|
|
417
438
|
|
|
418
439
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -556,12 +577,12 @@ const separator = hidden => {
|
|
|
556
577
|
};
|
|
557
578
|
const getCellItems = (state, view, {
|
|
558
579
|
formatMessage
|
|
559
|
-
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => {
|
|
580
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false, isLimitedModeEnabled = false) => {
|
|
560
581
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
561
582
|
if (initialSelectionRect) {
|
|
562
583
|
const cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
563
584
|
formatMessage
|
|
564
|
-
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor);
|
|
585
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isLimitedModeEnabled);
|
|
565
586
|
// Ignored via go/ees005
|
|
566
587
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
567
588
|
return [cellOptions, separator(cellOptions.hidden)];
|
|
@@ -585,15 +606,23 @@ const getDistributeConfig = (getEditorContainerWidth, api, editorAnalyticsAPI, i
|
|
|
585
606
|
// fixed column button should be in this function call in the future
|
|
586
607
|
const getColumnSettingItems = (editorState, editorView, {
|
|
587
608
|
formatMessage
|
|
588
|
-
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, isCommentEditor = false) => {
|
|
589
|
-
var
|
|
609
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, isCommentEditor = false, isLimitedModeEnabled = false) => {
|
|
610
|
+
var _pluginState$pluginCo3;
|
|
590
611
|
const pluginState = getPluginState(editorState);
|
|
591
612
|
const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
|
|
592
613
|
if (!selectionOrTableRect || !editorView) {
|
|
593
614
|
return [];
|
|
594
615
|
}
|
|
595
|
-
|
|
596
|
-
|
|
616
|
+
let wouldChange = true; // Default to enabled - show the button.
|
|
617
|
+
let newResizeStateWithAnalytics;
|
|
618
|
+
|
|
619
|
+
// Performance optimization: Skip expensive getTableScalingPercent() DOM query when limited mode is enabled.
|
|
620
|
+
// This avoids layout reflows on every transaction. Instead, button stays enabled and calculates on-demand when clicked.
|
|
621
|
+
if (!expValEquals('cc_editor_limited_mode_table_align_bttn', 'isEnabled', true) || !isLimitedModeEnabled) {
|
|
622
|
+
var _newResizeStateWithAn3, _newResizeStateWithAn4;
|
|
623
|
+
newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, isCommentEditor);
|
|
624
|
+
wouldChange = (_newResizeStateWithAn3 = (_newResizeStateWithAn4 = newResizeStateWithAnalytics) === null || _newResizeStateWithAn4 === void 0 ? void 0 : _newResizeStateWithAn4.changed) !== null && _newResizeStateWithAn3 !== void 0 ? _newResizeStateWithAn3 : false;
|
|
625
|
+
}
|
|
597
626
|
const items = [];
|
|
598
627
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
|
|
599
628
|
items.push({
|