@atlaskit/editor-plugin-table 4.1.0 → 4.2.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 +13 -0
- package/dist/cjs/plugins/table/commands/delete.js +18 -0
- package/dist/cjs/plugins/table/commands-with-analytics.js +2 -7
- package/dist/cjs/plugins/table/event-handlers.js +2 -2
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +27 -9
- package/dist/cjs/plugins/table/pm-plugins/main.js +1 -1
- package/dist/cjs/plugins/table/transforms/column-width.js +110 -5
- package/dist/cjs/plugins/table/transforms/delete-columns.js +16 -6
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +1 -1
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/es2019/plugins/table/commands/delete.js +10 -0
- package/dist/es2019/plugins/table/commands-with-analytics.js +3 -8
- package/dist/es2019/plugins/table/event-handlers.js +2 -2
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +27 -9
- package/dist/es2019/plugins/table/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/table/transforms/column-width.js +105 -5
- package/dist/es2019/plugins/table/transforms/delete-columns.js +16 -5
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +1 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +0 -1
- package/dist/esm/plugins/table/commands/delete.js +12 -0
- package/dist/esm/plugins/table/commands-with-analytics.js +3 -8
- package/dist/esm/plugins/table/event-handlers.js +2 -2
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +27 -9
- package/dist/esm/plugins/table/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/table/transforms/column-width.js +111 -5
- package/dist/esm/plugins/table/transforms/delete-columns.js +16 -6
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +1 -1
- package/dist/esm/plugins/table/ui/common-styles.js +1 -1
- package/dist/types/plugins/table/commands/delete.d.ts +3 -0
- package/dist/types/plugins/table/event-handlers.d.ts +1 -1
- package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +3 -3
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types/plugins/table/transforms/column-width.d.ts +25 -6
- package/dist/types/plugins/table/transforms/delete-columns.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDeleteButton/index.d.ts +4 -4
- package/dist/types-ts4.5/plugins/table/commands/delete.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +3 -3
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/transforms/column-width.d.ts +25 -6
- package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +4 -4
- package/package.json +8 -2
- package/src/__tests__/unit/commands.ts +1 -0
- package/src/__tests__/unit/transforms/delete-columns.ts +406 -105
- package/src/__tests__/unit/undo-redo.ts +1 -1
- package/src/plugins/table/commands/delete.ts +20 -0
- package/src/plugins/table/commands-with-analytics.ts +3 -10
- package/src/plugins/table/event-handlers.ts +6 -1
- package/src/plugins/table/nodeviews/TableContainer.tsx +189 -159
- package/src/plugins/table/pm-plugins/main.ts +7 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +1 -1
- package/src/plugins/table/transforms/column-width.ts +155 -15
- package/src/plugins/table/transforms/delete-columns.ts +23 -6
- package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +1 -1
- package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +7 -6
- package/src/plugins/table/ui/common-styles.ts +0 -1
|
@@ -4,12 +4,15 @@ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics
|
|
|
4
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
8
|
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
8
9
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
10
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
12
|
|
|
11
13
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
12
14
|
|
|
15
|
+
import { rescaleColumns } from './column-width';
|
|
13
16
|
import { splitCellsInColumns } from './split';
|
|
14
17
|
|
|
15
18
|
const deleteColumnsCustomStep =
|
|
@@ -247,13 +250,27 @@ function fixRowSpans(table: PMNode): PMNode | null {
|
|
|
247
250
|
}
|
|
248
251
|
|
|
249
252
|
export const deleteColumns =
|
|
250
|
-
(rect: Rect,
|
|
251
|
-
(tr: Transaction)
|
|
252
|
-
tr
|
|
253
|
+
(rect: Rect, allowCustomStep: boolean, view?: EditorView) =>
|
|
254
|
+
(tr: Transaction) => {
|
|
255
|
+
let updatedTr = tr;
|
|
256
|
+
updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
253
257
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.DELETED_COLUMN,
|
|
254
258
|
});
|
|
255
|
-
|
|
256
|
-
|
|
259
|
+
|
|
260
|
+
if (allowCustomStep) {
|
|
261
|
+
updatedTr = deleteColumnsCustomStep(rect)(updatedTr);
|
|
262
|
+
} else {
|
|
263
|
+
updatedTr = deleteColumnsLegacy(rect)(updatedTr);
|
|
264
|
+
}
|
|
265
|
+
const table = findTable(updatedTr.selection);
|
|
266
|
+
if (
|
|
267
|
+
getBooleanFF(
|
|
268
|
+
'platform.editor.table-update-colwidths-after-column-is-deleted',
|
|
269
|
+
)
|
|
270
|
+
) {
|
|
271
|
+
if (table) {
|
|
272
|
+
updatedTr = rescaleColumns()(table, view)(updatedTr);
|
|
273
|
+
}
|
|
257
274
|
}
|
|
258
|
-
return
|
|
275
|
+
return updatedTr;
|
|
259
276
|
};
|
|
@@ -434,7 +434,7 @@ export class ContextualMenu extends Component<
|
|
|
434
434
|
deleteColumnsWithAnalytics(editorAnalyticsAPI)(
|
|
435
435
|
INPUT_METHOD.CONTEXT_MENU,
|
|
436
436
|
selectionRect,
|
|
437
|
-
)(state, dispatch);
|
|
437
|
+
)(state, dispatch, editorView);
|
|
438
438
|
this.toggleOpen();
|
|
439
439
|
break;
|
|
440
440
|
case 'delete_row':
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { SyntheticEvent } from 'react';
|
|
2
|
+
import React, { Component } from 'react';
|
|
2
3
|
|
|
3
4
|
import { createPortal } from 'react-dom';
|
|
4
5
|
|
|
@@ -6,8 +7,8 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
6
7
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
7
8
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
8
9
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
9
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
10
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
10
|
+
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
11
12
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
12
13
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
13
14
|
import {
|
|
@@ -21,7 +22,7 @@ import {
|
|
|
21
22
|
deleteRowsWithAnalytics,
|
|
22
23
|
} from '../../commands-with-analytics';
|
|
23
24
|
import { getPluginState as getTablePluginState } from '../../pm-plugins/plugin-factory';
|
|
24
|
-
import { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
25
|
+
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
25
26
|
import { TableCssClassName as ClassName } from '../../types';
|
|
26
27
|
import {
|
|
27
28
|
getColumnDeleteButtonParams,
|
|
@@ -34,7 +35,7 @@ import tableMessages from '../messages';
|
|
|
34
35
|
|
|
35
36
|
import DeleteButton from './DeleteButton';
|
|
36
37
|
import getPopupOptions from './getPopUpOptions';
|
|
37
|
-
import { CellSelectionType } from './types';
|
|
38
|
+
import type { CellSelectionType } from './types';
|
|
38
39
|
|
|
39
40
|
export interface Props {
|
|
40
41
|
editorView: EditorView;
|
|
@@ -278,7 +279,7 @@ class FloatingDeleteButton extends Component<Props, State> {
|
|
|
278
279
|
deleteColumnsWithAnalytics(editorAnalyticsAPI)(
|
|
279
280
|
INPUT_METHOD.BUTTON,
|
|
280
281
|
rect,
|
|
281
|
-
)(state, dispatch);
|
|
282
|
+
)(state, dispatch, this.props.editorView);
|
|
282
283
|
return;
|
|
283
284
|
}
|
|
284
285
|
case 'row': {
|