@atlaskit/editor-plugin-table 12.2.6 → 12.2.7
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 +8 -0
- package/package.json +4 -4
- package/afm-cc/tsconfig.json +0 -123
- package/afm-dev-agents/tsconfig.json +0 -123
- package/afm-jira/tsconfig.json +0 -123
- package/afm-passionfruit/tsconfig.json +0 -123
- package/afm-post-office/tsconfig.json +0 -123
- package/afm-rovo-extension/tsconfig.json +0 -123
- package/afm-townsquare/tsconfig.json +0 -123
- package/afm-volt/tsconfig.json +0 -114
- package/build/tsconfig.json +0 -23
- package/docs/0-intro.tsx +0 -57
- package/src/index.ts +0 -21
- package/src/nodeviews/ExternalDropTargets.tsx +0 -91
- package/src/nodeviews/OverflowShadowsObserver.ts +0 -156
- package/src/nodeviews/TableCell.ts +0 -134
- package/src/nodeviews/TableComponent.tsx +0 -1590
- package/src/nodeviews/TableComponentWithSharedState.tsx +0 -278
- package/src/nodeviews/TableContainer.tsx +0 -926
- package/src/nodeviews/TableNodeViewBase.ts +0 -29
- package/src/nodeviews/TableResizer.tsx +0 -884
- package/src/nodeviews/TableRow.ts +0 -830
- package/src/nodeviews/TableStickyScrollbar.ts +0 -211
- package/src/nodeviews/__mocks__/OverflowShadowsObserver.ts +0 -15
- package/src/nodeviews/__mocks__/OverridableMock.ts +0 -26
- package/src/nodeviews/table-container-styles.ts +0 -9
- package/src/nodeviews/table-node-views.ts +0 -76
- package/src/nodeviews/table.tsx +0 -530
- package/src/nodeviews/toDOM.ts +0 -244
- package/src/nodeviews/types.ts +0 -36
- package/src/nodeviews/update-overflow-shadows.ts +0 -11
- package/src/pm-plugins/analytics/actions.ts +0 -21
- package/src/pm-plugins/analytics/commands.ts +0 -47
- package/src/pm-plugins/analytics/plugin-factory.ts +0 -9
- package/src/pm-plugins/analytics/plugin-key.ts +0 -5
- package/src/pm-plugins/analytics/plugin.ts +0 -80
- package/src/pm-plugins/analytics/reducer.ts +0 -27
- package/src/pm-plugins/analytics/types.ts +0 -20
- package/src/pm-plugins/analytics/utils/moved-event.ts +0 -51
- package/src/pm-plugins/commands/clear.ts +0 -43
- package/src/pm-plugins/commands/collapse.ts +0 -17
- package/src/pm-plugins/commands/column-resize.ts +0 -478
- package/src/pm-plugins/commands/commands-with-analytics.ts +0 -715
- package/src/pm-plugins/commands/delete.ts +0 -42
- package/src/pm-plugins/commands/display-mode.ts +0 -18
- package/src/pm-plugins/commands/go-to-next-cell.ts +0 -198
- package/src/pm-plugins/commands/hover.ts +0 -242
- package/src/pm-plugins/commands/index.ts +0 -51
- package/src/pm-plugins/commands/insert.ts +0 -438
- package/src/pm-plugins/commands/misc.ts +0 -811
- package/src/pm-plugins/commands/referentiality.ts +0 -15
- package/src/pm-plugins/commands/selection.ts +0 -537
- package/src/pm-plugins/commands/sort.ts +0 -102
- package/src/pm-plugins/commands/split-cell.ts +0 -28
- package/src/pm-plugins/commands/toggle.ts +0 -109
- package/src/pm-plugins/create-plugin-config.ts +0 -17
- package/src/pm-plugins/decorations/plugin.ts +0 -107
- package/src/pm-plugins/decorations/utils/column-controls.ts +0 -91
- package/src/pm-plugins/decorations/utils/column-resizing.ts +0 -71
- package/src/pm-plugins/decorations/utils/compose-decorations.ts +0 -9
- package/src/pm-plugins/decorations/utils/types.ts +0 -16
- package/src/pm-plugins/default-table-selection.ts +0 -14
- package/src/pm-plugins/drag-and-drop/actions.ts +0 -48
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +0 -222
- package/src/pm-plugins/drag-and-drop/commands.ts +0 -194
- package/src/pm-plugins/drag-and-drop/consts.ts +0 -7
- package/src/pm-plugins/drag-and-drop/plugin-factory.ts +0 -33
- package/src/pm-plugins/drag-and-drop/plugin-key.ts +0 -5
- package/src/pm-plugins/drag-and-drop/plugin.ts +0 -398
- package/src/pm-plugins/drag-and-drop/reducer.ts +0 -38
- package/src/pm-plugins/drag-and-drop/types.ts +0 -18
- package/src/pm-plugins/drag-and-drop/utils/autoscrollers.ts +0 -49
- package/src/pm-plugins/drag-and-drop/utils/getDragBehaviour.ts +0 -9
- package/src/pm-plugins/drag-and-drop/utils/monitor.ts +0 -73
- package/src/pm-plugins/handlers.ts +0 -161
- package/src/pm-plugins/keymap.ts +0 -436
- package/src/pm-plugins/main.ts +0 -433
- package/src/pm-plugins/plugin-factory.ts +0 -42
- package/src/pm-plugins/plugin-key.ts +0 -8
- package/src/pm-plugins/reducer.ts +0 -145
- package/src/pm-plugins/safari-delete-composition-text-issue-workaround.ts +0 -102
- package/src/pm-plugins/sticky-headers/commands.ts +0 -8
- package/src/pm-plugins/sticky-headers/plugin-key.ts +0 -5
- package/src/pm-plugins/sticky-headers/plugin-state.ts +0 -52
- package/src/pm-plugins/sticky-headers/plugin.ts +0 -12
- package/src/pm-plugins/sticky-headers/types.ts +0 -20
- package/src/pm-plugins/sticky-headers/util.ts +0 -18
- package/src/pm-plugins/table-analytics.ts +0 -100
- package/src/pm-plugins/table-local-id.ts +0 -213
- package/src/pm-plugins/table-resizing/commands.ts +0 -116
- package/src/pm-plugins/table-resizing/event-handlers.ts +0 -352
- package/src/pm-plugins/table-resizing/plugin-factory.ts +0 -29
- package/src/pm-plugins/table-resizing/plugin-key.ts +0 -5
- package/src/pm-plugins/table-resizing/plugin.ts +0 -94
- package/src/pm-plugins/table-resizing/reducer.ts +0 -37
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +0 -306
- package/src/pm-plugins/table-resizing/utils/column-state.ts +0 -120
- package/src/pm-plugins/table-resizing/utils/consts.ts +0 -11
- package/src/pm-plugins/table-resizing/utils/content-width.ts +0 -118
- package/src/pm-plugins/table-resizing/utils/dom.ts +0 -132
- package/src/pm-plugins/table-resizing/utils/misc.ts +0 -282
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +0 -34
- package/src/pm-plugins/table-resizing/utils/resize-logic.ts +0 -289
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +0 -417
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +0 -290
- package/src/pm-plugins/table-resizing/utils/types.ts +0 -25
- package/src/pm-plugins/table-resizing/utils/unit-to-number.ts +0 -1
- package/src/pm-plugins/table-selection-keymap.ts +0 -64
- package/src/pm-plugins/table-size-selector.ts +0 -39
- package/src/pm-plugins/table-width-in-comment-fix.ts +0 -113
- package/src/pm-plugins/table-width.ts +0 -153
- package/src/pm-plugins/transforms/column-width.ts +0 -249
- package/src/pm-plugins/transforms/delete-columns.ts +0 -281
- package/src/pm-plugins/transforms/delete-rows.ts +0 -154
- package/src/pm-plugins/transforms/fix-tables.ts +0 -249
- package/src/pm-plugins/transforms/merge.ts +0 -301
- package/src/pm-plugins/transforms/replace-table.ts +0 -38
- package/src/pm-plugins/transforms/split.ts +0 -90
- package/src/pm-plugins/utils/alignment.ts +0 -33
- package/src/pm-plugins/utils/analytics.ts +0 -238
- package/src/pm-plugins/utils/collapse.ts +0 -93
- package/src/pm-plugins/utils/column-controls.ts +0 -250
- package/src/pm-plugins/utils/create.ts +0 -64
- package/src/pm-plugins/utils/decoration.ts +0 -672
- package/src/pm-plugins/utils/dom.ts +0 -251
- package/src/pm-plugins/utils/drag-menu.tsx +0 -491
- package/src/pm-plugins/utils/get-allow-add-column-custom-step.ts +0 -10
- package/src/pm-plugins/utils/guidelines.ts +0 -30
- package/src/pm-plugins/utils/merged-cells.ts +0 -239
- package/src/pm-plugins/utils/nodes.ts +0 -162
- package/src/pm-plugins/utils/paste.ts +0 -386
- package/src/pm-plugins/utils/row-controls.ts +0 -211
- package/src/pm-plugins/utils/selection.ts +0 -17
- package/src/pm-plugins/utils/snapping.ts +0 -136
- package/src/pm-plugins/utils/table.ts +0 -60
- package/src/pm-plugins/utils/update-plugin-state-decorations.ts +0 -13
- package/src/pm-plugins/view-mode-sort/consts.ts +0 -3
- package/src/pm-plugins/view-mode-sort/index.ts +0 -291
- package/src/pm-plugins/view-mode-sort/plugin-key.ts +0 -7
- package/src/pm-plugins/view-mode-sort/types.ts +0 -23
- package/src/pm-plugins/view-mode-sort/utils.ts +0 -136
- package/src/tablePlugin.tsx +0 -971
- package/src/tablePluginType.ts +0 -102
- package/src/types/index.ts +0 -592
- package/src/ui/ColumnResizeWidget/index.tsx +0 -61
- package/src/ui/ContentComponent.tsx +0 -311
- package/src/ui/DragHandle/HandleIconComponent.tsx +0 -21
- package/src/ui/DragHandle/index.tsx +0 -391
- package/src/ui/DragPreview/index.tsx +0 -51
- package/src/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.tsx +0 -59
- package/src/ui/FloatingContextualButton/FixedButton.tsx +0 -203
- package/src/ui/FloatingContextualButton/index.tsx +0 -168
- package/src/ui/FloatingContextualButton/styles.ts +0 -69
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +0 -931
- package/src/ui/FloatingContextualMenu/index.tsx +0 -141
- package/src/ui/FloatingContextualMenu/styles.ts +0 -77
- package/src/ui/FloatingDeleteButton/DeleteButton.tsx +0 -54
- package/src/ui/FloatingDeleteButton/getPopUpOptions.ts +0 -65
- package/src/ui/FloatingDeleteButton/index.tsx +0 -383
- package/src/ui/FloatingDeleteButton/types.ts +0 -3
- package/src/ui/FloatingDragMenu/DragMenu.tsx +0 -668
- package/src/ui/FloatingDragMenu/DropdownMenu.tsx +0 -221
- package/src/ui/FloatingDragMenu/index.tsx +0 -136
- package/src/ui/FloatingDragMenu/styles.ts +0 -83
- package/src/ui/FloatingInsertButton/InsertButton.tsx +0 -263
- package/src/ui/FloatingInsertButton/getPopupOptions.ts +0 -131
- package/src/ui/FloatingInsertButton/index.tsx +0 -314
- package/src/ui/FloatingToolbarLabel/FloatingToolbarLabel.tsx +0 -31
- package/src/ui/SizeSelector/index.tsx +0 -74
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +0 -397
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +0 -105
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +0 -63
- package/src/ui/TableFloatingColumnControls/index.tsx +0 -151
- package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +0 -106
- package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +0 -143
- package/src/ui/TableFloatingControls/CornerControls/types.ts +0 -12
- package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +0 -88
- package/src/ui/TableFloatingControls/NumberColumn/index.tsx +0 -175
- package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +0 -131
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -429
- package/src/ui/TableFloatingControls/RowDropTarget/index.tsx +0 -96
- package/src/ui/TableFloatingControls/index.tsx +0 -275
- package/src/ui/TableFullWidthLabel/index.tsx +0 -38
- package/src/ui/common-styles.ts +0 -1218
- package/src/ui/consts.ts +0 -109
- package/src/ui/event-handlers.ts +0 -662
- package/src/ui/global-styles.tsx +0 -55
- package/src/ui/hooks/useInternalTablePluginStateSelector.ts +0 -38
- package/src/ui/icons/AddColLeftIcon.tsx +0 -37
- package/src/ui/icons/AddColRightIcon.tsx +0 -37
- package/src/ui/icons/AddRowAboveIcon.tsx +0 -22
- package/src/ui/icons/AddRowBelowIcon.tsx +0 -39
- package/src/ui/icons/DragHandleDisabledIcon.tsx +0 -25
- package/src/ui/icons/DragHandleIcon.tsx +0 -16
- package/src/ui/icons/DragInMotionIcon.tsx +0 -54
- package/src/ui/icons/MergeCellsIcon.tsx +0 -26
- package/src/ui/icons/MinimisedHandle.tsx +0 -15
- package/src/ui/icons/SortingIconWrapper.tsx +0 -43
- package/src/ui/icons/SplitCellIcon.tsx +0 -34
- package/src/ui/toolbar.tsx +0 -1153
- package/src/ui/ui-styles.ts +0 -960
- package/tsconfig.app.json +0 -135
- package/tsconfig.dev.json +0 -54
- package/tsconfig.json +0 -18
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
-
|
|
3
|
-
import type { ColumnState } from './column-state';
|
|
4
|
-
|
|
5
|
-
export interface ResizeState {
|
|
6
|
-
cols: ColumnState[];
|
|
7
|
-
widths: number[];
|
|
8
|
-
maxSize: number;
|
|
9
|
-
overflow: boolean;
|
|
10
|
-
tableWidth: number;
|
|
11
|
-
isScaled?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export interface ResizeStateWithAnalytics {
|
|
14
|
-
resizeState: ResizeState;
|
|
15
|
-
table: ContentNodeWithPos;
|
|
16
|
-
changed: boolean;
|
|
17
|
-
attributes: {
|
|
18
|
-
position: number;
|
|
19
|
-
count: number;
|
|
20
|
-
totalRowCount: number;
|
|
21
|
-
totalColumnCount: number;
|
|
22
|
-
widthsBefore: number[];
|
|
23
|
-
widthsAfter: number[];
|
|
24
|
-
};
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const unitToNumber = (unit: string | null): number => (unit ? parseInt(unit, 10) : 0);
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { type IntlShape } from 'react-intl-next/src/types';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
bindKeymapArrayWithCommand,
|
|
5
|
-
bindKeymapWithCommand,
|
|
6
|
-
moveLeft,
|
|
7
|
-
moveRight,
|
|
8
|
-
selectColumn,
|
|
9
|
-
selectRow,
|
|
10
|
-
selectTable,
|
|
11
|
-
shiftArrowUp,
|
|
12
|
-
} from '@atlaskit/editor-common/keymaps';
|
|
13
|
-
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
14
|
-
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
15
|
-
|
|
16
|
-
import { type PluginInjectionAPI } from '../types';
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
arrowLeftFromTable,
|
|
20
|
-
arrowRightFromTable,
|
|
21
|
-
modASelectTable,
|
|
22
|
-
selectColumns,
|
|
23
|
-
selectRows,
|
|
24
|
-
shiftArrowUpFromTable,
|
|
25
|
-
} from './commands/selection';
|
|
26
|
-
|
|
27
|
-
export function tableSelectionKeymapPlugin(
|
|
28
|
-
pluginInjectionApi?: PluginInjectionAPI,
|
|
29
|
-
getIntl?: () => IntlShape,
|
|
30
|
-
): SafePlugin {
|
|
31
|
-
const list = {};
|
|
32
|
-
const editorSelectionAPI = pluginInjectionApi?.selection;
|
|
33
|
-
const ariaNotifyPlugin = pluginInjectionApi?.accessibilityUtils?.actions.ariaNotify;
|
|
34
|
-
|
|
35
|
-
// Ignored via go/ees005
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
37
|
-
bindKeymapWithCommand(moveRight.common!, arrowRightFromTable(editorSelectionAPI)(), list);
|
|
38
|
-
|
|
39
|
-
// Ignored via go/ees005
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
41
|
-
bindKeymapWithCommand(moveLeft.common!, arrowLeftFromTable(editorSelectionAPI)(), list);
|
|
42
|
-
|
|
43
|
-
bindKeymapArrayWithCommand(
|
|
44
|
-
selectColumn,
|
|
45
|
-
selectColumns(editorSelectionAPI, ariaNotifyPlugin, getIntl)(true),
|
|
46
|
-
list,
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
bindKeymapArrayWithCommand(
|
|
50
|
-
selectRow,
|
|
51
|
-
selectRows(editorSelectionAPI, ariaNotifyPlugin, getIntl)(true),
|
|
52
|
-
list,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
// Ignored via go/ees005
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
57
|
-
bindKeymapWithCommand(shiftArrowUp.common!, shiftArrowUpFromTable(editorSelectionAPI)(), list);
|
|
58
|
-
|
|
59
|
-
// Ignored via go/ees005
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
61
|
-
bindKeymapWithCommand(selectTable.common!, modASelectTable(editorSelectionAPI)(), list);
|
|
62
|
-
|
|
63
|
-
return keymap(list) as SafePlugin;
|
|
64
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
|
|
5
|
-
type SizeSelectorPluginState = {
|
|
6
|
-
isSelectorOpen: boolean;
|
|
7
|
-
targetRef?: HTMLElement;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const pluginKey = new PluginKey<SizeSelectorPluginState>('tableSizeSelectorPlugin');
|
|
11
|
-
|
|
12
|
-
export const createPlugin = (dispatch: Dispatch) => {
|
|
13
|
-
return new SafePlugin<SizeSelectorPluginState>({
|
|
14
|
-
key: pluginKey,
|
|
15
|
-
state: {
|
|
16
|
-
init: () => ({
|
|
17
|
-
isSelectorOpen: false,
|
|
18
|
-
}),
|
|
19
|
-
apply: (tr, currentPluginState) => {
|
|
20
|
-
const meta = tr.getMeta(pluginKey);
|
|
21
|
-
|
|
22
|
-
if (meta) {
|
|
23
|
-
const keys = Object.keys(meta) as Array<keyof SizeSelectorPluginState>;
|
|
24
|
-
const changed = keys.some((key) => {
|
|
25
|
-
return currentPluginState[key] !== meta[key];
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
if (changed) {
|
|
29
|
-
const newState = { ...currentPluginState, ...meta };
|
|
30
|
-
|
|
31
|
-
dispatch(pluginKey, newState);
|
|
32
|
-
return newState;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return currentPluginState;
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Existing legacy tables in Comment editor have set attributes:
|
|
3
|
-
- width = 760
|
|
4
|
-
- layout = 'default'.
|
|
5
|
-
|
|
6
|
-
When "Support Table in Comment" FF is enabled, table resizing (and table alignment in Confluence comments) is turned.
|
|
7
|
-
It results in (ED-24795) all exising tables being set 760px width. Instead they all should inherit width from
|
|
8
|
-
the editor container until a user decided to edit their old comment and set a custom table width themselves.
|
|
9
|
-
|
|
10
|
-
This plugin exists to fix the described issue. It ensures that once "Support Table in Comment" FF turned on,
|
|
11
|
-
existing tables continue to inherit the width of editor container and are 'left-aligned' by default.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import rafSchedule from 'raf-schd';
|
|
15
|
-
|
|
16
|
-
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
17
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
18
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
19
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
20
|
-
import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
21
|
-
|
|
22
|
-
import { ALIGN_START } from './utils/alignment';
|
|
23
|
-
|
|
24
|
-
type TableWidthInCommentFixPluginState = {
|
|
25
|
-
documentHasLoadedOnce: boolean;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const pluginKey = new PluginKey<TableWidthInCommentFixPluginState>(
|
|
29
|
-
'tableWidthInCommentFixPlugin',
|
|
30
|
-
);
|
|
31
|
-
const getPluginState = (state: EditorState): TableWidthInCommentFixPluginState | undefined | null =>
|
|
32
|
-
state && pluginKey.getState(state);
|
|
33
|
-
|
|
34
|
-
const createPlugin = (dispatch: Dispatch, isTableAlignmentEnabled: boolean) => {
|
|
35
|
-
return new SafePlugin({
|
|
36
|
-
key: pluginKey,
|
|
37
|
-
state: {
|
|
38
|
-
init() {
|
|
39
|
-
return {
|
|
40
|
-
documentHasLoadedOnce: false,
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
apply(tr, pluginState) {
|
|
44
|
-
const meta = tr.getMeta(pluginKey);
|
|
45
|
-
if (meta) {
|
|
46
|
-
const keys = Object.keys(meta) as Array<keyof TableWidthInCommentFixPluginState>;
|
|
47
|
-
const changed = keys.some((key) => {
|
|
48
|
-
return pluginState[key] !== meta[key];
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
if (changed) {
|
|
52
|
-
const newState = { ...pluginState, ...meta };
|
|
53
|
-
|
|
54
|
-
dispatch(pluginKey, newState);
|
|
55
|
-
return newState;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return pluginState;
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
view: () => {
|
|
63
|
-
return {
|
|
64
|
-
update(editorView) {
|
|
65
|
-
const { state } = editorView;
|
|
66
|
-
const pluginState = getPluginState(state);
|
|
67
|
-
if (!pluginState) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const { documentHasLoadedOnce } = pluginState;
|
|
71
|
-
|
|
72
|
-
if (documentHasLoadedOnce) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const { table } = state.schema.nodes;
|
|
77
|
-
rafSchedule(() => {
|
|
78
|
-
const tr = editorView.state.tr;
|
|
79
|
-
let tableWidthAndLayoutUpdated = false;
|
|
80
|
-
editorView.state.doc.descendants((node, pos) => {
|
|
81
|
-
const isTable = node.type === table;
|
|
82
|
-
const width = node.attrs.width;
|
|
83
|
-
const layout = node.attrs.layout;
|
|
84
|
-
if (isTable && width === akEditorDefaultLayoutWidth && layout === 'default') {
|
|
85
|
-
tableWidthAndLayoutUpdated = true;
|
|
86
|
-
tr.setNodeMarkup(pos, undefined, {
|
|
87
|
-
...node.attrs,
|
|
88
|
-
width: null,
|
|
89
|
-
layout: isTableAlignmentEnabled ? ALIGN_START : 'default',
|
|
90
|
-
});
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
// Returning false here because don't need to change nested tables
|
|
94
|
-
return false;
|
|
95
|
-
});
|
|
96
|
-
if (tableWidthAndLayoutUpdated) {
|
|
97
|
-
tr.setMeta('addToHistory', false);
|
|
98
|
-
editorView.dispatch(tr);
|
|
99
|
-
}
|
|
100
|
-
})();
|
|
101
|
-
|
|
102
|
-
editorView.dispatch(
|
|
103
|
-
state.tr.setMeta(pluginKey, {
|
|
104
|
-
documentHasLoadedOnce: true,
|
|
105
|
-
}),
|
|
106
|
-
);
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export { createPlugin };
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A plugin for handle table custom widths
|
|
3
|
-
* Has login to scan the document, add width value to table's width attribute when necessary
|
|
4
|
-
* Also holds resizing state to hide / show table controls
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
8
|
-
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
9
|
-
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
10
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
11
|
-
import { isReplaceDocOperation } from '@atlaskit/editor-common/utils/document';
|
|
12
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
13
|
-
import {
|
|
14
|
-
akEditorDefaultLayoutWidth,
|
|
15
|
-
akEditorFullWidthLayoutWidth,
|
|
16
|
-
akEditorWideLayoutWidth,
|
|
17
|
-
} from '@atlaskit/editor-shared-styles';
|
|
18
|
-
|
|
19
|
-
import { TABLE_MAX_WIDTH } from './table-resizing/utils/consts';
|
|
20
|
-
import { ALIGN_START } from './utils/alignment';
|
|
21
|
-
|
|
22
|
-
type TableWidthPluginState = {
|
|
23
|
-
resizing: boolean;
|
|
24
|
-
tableLocalId: string;
|
|
25
|
-
tableRef: HTMLTableElement | null;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const pluginKey = new PluginKey<TableWidthPluginState>('tableWidthPlugin');
|
|
29
|
-
|
|
30
|
-
const createPlugin = (
|
|
31
|
-
dispatch: Dispatch,
|
|
32
|
-
dispatchAnalyticsEvent: DispatchAnalyticsEvent,
|
|
33
|
-
fullWidthEnabled: boolean,
|
|
34
|
-
isTableScalingEnabled: boolean,
|
|
35
|
-
isTableAlignmentEnabled: boolean,
|
|
36
|
-
isCommentEditor: boolean,
|
|
37
|
-
) => {
|
|
38
|
-
return new SafePlugin({
|
|
39
|
-
key: pluginKey,
|
|
40
|
-
state: {
|
|
41
|
-
init() {
|
|
42
|
-
return {
|
|
43
|
-
resizing: false,
|
|
44
|
-
tableLocalId: '',
|
|
45
|
-
tableRef: null,
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
apply(tr, pluginState) {
|
|
49
|
-
const meta = tr.getMeta(pluginKey);
|
|
50
|
-
if (meta) {
|
|
51
|
-
const keys = Object.keys(meta) as Array<keyof TableWidthPluginState>;
|
|
52
|
-
const changed = keys.some((key) => {
|
|
53
|
-
return pluginState[key] !== meta[key];
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (changed) {
|
|
57
|
-
const newState = { ...pluginState, ...meta };
|
|
58
|
-
|
|
59
|
-
dispatch(pluginKey, newState);
|
|
60
|
-
return newState;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return pluginState;
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
appendTransaction: (transactions, oldState, newState) => {
|
|
68
|
-
// When document first load in Confluence, initially it is an empty document
|
|
69
|
-
// and Collab service triggers a transaction to replace the empty document with the real document that should be rendered.
|
|
70
|
-
// what we need to do is to add width attr to all tables in the real document
|
|
71
|
-
// isReplaceDocumentOperation is checking if the transaction is the one that replace the empty document with the real document
|
|
72
|
-
const isReplaceDocumentOperation = isReplaceDocOperation(transactions, oldState);
|
|
73
|
-
|
|
74
|
-
const referentialityTr = transactions.find((tr) => tr.getMeta('referentialityTableInserted'));
|
|
75
|
-
|
|
76
|
-
const shouldPatchTableWidth = fullWidthEnabled && isTableScalingEnabled;
|
|
77
|
-
const shouldPatchTableAlignment = fullWidthEnabled && isTableAlignmentEnabled;
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
!isReplaceDocumentOperation &&
|
|
81
|
-
((!shouldPatchTableWidth && !shouldPatchTableAlignment) || !referentialityTr)
|
|
82
|
-
) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const { table } = newState.schema.nodes;
|
|
87
|
-
const tr = newState.tr;
|
|
88
|
-
|
|
89
|
-
if (isReplaceDocumentOperation && !isCommentEditor) {
|
|
90
|
-
newState.doc.forEach((node, offset) => {
|
|
91
|
-
if (node.type === table) {
|
|
92
|
-
const width = node.attrs.width;
|
|
93
|
-
const layout = node.attrs.layout;
|
|
94
|
-
|
|
95
|
-
if (!width && layout) {
|
|
96
|
-
let tableWidthCal;
|
|
97
|
-
|
|
98
|
-
if (fullWidthEnabled) {
|
|
99
|
-
tableWidthCal = akEditorFullWidthLayoutWidth;
|
|
100
|
-
} else {
|
|
101
|
-
switch (layout) {
|
|
102
|
-
case 'wide':
|
|
103
|
-
tableWidthCal = akEditorWideLayoutWidth;
|
|
104
|
-
break;
|
|
105
|
-
case 'full-width':
|
|
106
|
-
tableWidthCal = akEditorFullWidthLayoutWidth;
|
|
107
|
-
break;
|
|
108
|
-
// when in fix-width appearance, no need to assign value to table width attr
|
|
109
|
-
// as when table is created, width attr is null by default, table rendered using layout attr
|
|
110
|
-
default:
|
|
111
|
-
tableWidthCal = akEditorDefaultLayoutWidth;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const { width, ...rest } = node.attrs;
|
|
117
|
-
|
|
118
|
-
if (tableWidthCal) {
|
|
119
|
-
tr.step(
|
|
120
|
-
new SetAttrsStep(offset, {
|
|
121
|
-
width: tableWidthCal,
|
|
122
|
-
...rest,
|
|
123
|
-
}),
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (referentialityTr) {
|
|
132
|
-
referentialityTr.steps.forEach((step) => {
|
|
133
|
-
step.getMap().forEach((_, __, newStart, newEnd) => {
|
|
134
|
-
newState.doc.nodesBetween(newStart, newEnd, (node, pos) => {
|
|
135
|
-
if (node.type === table) {
|
|
136
|
-
if (shouldPatchTableWidth && node.attrs.width !== TABLE_MAX_WIDTH) {
|
|
137
|
-
tr.setNodeAttribute(pos, 'width', TABLE_MAX_WIDTH);
|
|
138
|
-
}
|
|
139
|
-
if (shouldPatchTableAlignment) {
|
|
140
|
-
tr.setNodeAttribute(pos, 'layout', ALIGN_START);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return tr;
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export { createPlugin };
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import type { CellAttributes } from '@atlaskit/adf-schema';
|
|
2
|
-
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
3
|
-
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
|
-
import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
-
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
|
-
|
|
11
|
-
import type { PluginInjectionAPI } from '../../types';
|
|
12
|
-
import { isMinCellWidthTable, hasTableBeenResized } from '../table-resizing/utils/colgroup';
|
|
13
|
-
import { getTableContainerElementWidth, getTableElementWidth } from '../table-resizing/utils/misc';
|
|
14
|
-
import { getResizeState } from '../table-resizing/utils/resize-state';
|
|
15
|
-
import { scaleTableTo } from '../table-resizing/utils/scale-table';
|
|
16
|
-
import type { ResizeState } from '../table-resizing/utils/types';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
|
|
20
|
-
* @param resizeState
|
|
21
|
-
* @param table
|
|
22
|
-
* @param start
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
export const updateColumnWidths =
|
|
26
|
-
(
|
|
27
|
-
resizeState: ResizeState,
|
|
28
|
-
table: PMNode,
|
|
29
|
-
start: number,
|
|
30
|
-
api: PluginInjectionAPI | undefined | null,
|
|
31
|
-
) =>
|
|
32
|
-
(tr: Transaction): Transaction => {
|
|
33
|
-
const map = TableMap.get(table);
|
|
34
|
-
const updatedCellsAttrs: { [key: number]: CellAttributes } = {};
|
|
35
|
-
const steps: Array<AttrStep> = [];
|
|
36
|
-
|
|
37
|
-
// calculating new attributes for each cell
|
|
38
|
-
for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
39
|
-
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
40
|
-
let { width } = resizeState.cols[columnIndex];
|
|
41
|
-
if (resizeState.isScaled) {
|
|
42
|
-
// Ensure that the width is an integer if the table has been scaled
|
|
43
|
-
width = Math.floor(width);
|
|
44
|
-
}
|
|
45
|
-
const mapIndex = rowIndex * map.width + columnIndex;
|
|
46
|
-
const cellPos = map.map[mapIndex];
|
|
47
|
-
const attrs = updatedCellsAttrs[cellPos] || {
|
|
48
|
-
// Ignored via go/ees005
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
50
|
-
...table.nodeAt(cellPos)!.attrs,
|
|
51
|
-
};
|
|
52
|
-
const colspan = attrs.colspan || 1;
|
|
53
|
-
|
|
54
|
-
if (attrs.colwidth && attrs.colwidth.length > colspan) {
|
|
55
|
-
attrs.colwidth = attrs.colwidth.slice(0, colspan);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Rowspanning cell that has already been handled
|
|
59
|
-
if (rowIndex && map.map[mapIndex] === map.map[mapIndex - map.width]) {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
const colspanIndex = colspan === 1 ? 0 : columnIndex - map.colCount(cellPos);
|
|
63
|
-
if (attrs.colwidth && attrs.colwidth[colspanIndex] === width) {
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
let colwidths = attrs.colwidth
|
|
68
|
-
? attrs.colwidth.slice()
|
|
69
|
-
: Array.from({ length: colspan }, (_) => 0);
|
|
70
|
-
|
|
71
|
-
colwidths[colspanIndex] = width;
|
|
72
|
-
if (colwidths.length > colspan) {
|
|
73
|
-
colwidths = colwidths.slice(0, colspan);
|
|
74
|
-
}
|
|
75
|
-
updatedCellsAttrs[cellPos] = {
|
|
76
|
-
...attrs,
|
|
77
|
-
colwidth: colwidths.includes(0) ? undefined : colwidths,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// updating all cells with new attributes
|
|
83
|
-
const seen: { [key: number]: boolean } = {};
|
|
84
|
-
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
85
|
-
for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
86
|
-
const mapIndex = rowIndex * map.width + columnIndex;
|
|
87
|
-
const pos = map.map[mapIndex];
|
|
88
|
-
const cell = table.nodeAt(pos);
|
|
89
|
-
if (!seen[pos] && cell) {
|
|
90
|
-
if (updatedCellsAttrs[pos]) {
|
|
91
|
-
steps.push(
|
|
92
|
-
new AttrStep(
|
|
93
|
-
pos + start,
|
|
94
|
-
'colwidth',
|
|
95
|
-
updatedCellsAttrs[pos].colwidth === undefined
|
|
96
|
-
? null
|
|
97
|
-
: updatedCellsAttrs[pos].colwidth,
|
|
98
|
-
),
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
seen[pos] = true;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (api?.batchAttributeUpdates && fg('platform_editor_batch_steps_table')) {
|
|
107
|
-
const batchStep = api.batchAttributeUpdates.actions.batchSteps({ steps, doc: tr.doc });
|
|
108
|
-
tr.step(batchStep);
|
|
109
|
-
} else {
|
|
110
|
-
steps.forEach((s) => {
|
|
111
|
-
tr.step(s);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return tr;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* This function is called when user inserts/deletes a column in a table to;
|
|
120
|
-
* - rescale all columns (if the table did not overflow before the insertion)
|
|
121
|
-
* - and update column widths.
|
|
122
|
-
*
|
|
123
|
-
* This is done manually to avoid a multi-dispatch in TableComponent. See [ED-8288].
|
|
124
|
-
* @param table
|
|
125
|
-
* @param view
|
|
126
|
-
* @returns Updated transaction with rescaled columns for a given table
|
|
127
|
-
*/
|
|
128
|
-
export const rescaleColumns =
|
|
129
|
-
(
|
|
130
|
-
isTableScalingEnabled = false,
|
|
131
|
-
isTableFixedColumnWidthsOptionEnabled = false,
|
|
132
|
-
shouldUseIncreasedScalingPercent = false,
|
|
133
|
-
api: PluginInjectionAPI | undefined | null,
|
|
134
|
-
isCommentEditor = false,
|
|
135
|
-
) =>
|
|
136
|
-
(table: ContentNodeWithPos, view: EditorView | undefined) =>
|
|
137
|
-
(tr: Transaction): Transaction => {
|
|
138
|
-
if (!view) {
|
|
139
|
-
return tr;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const newTable = tr.doc.nodeAt(table.pos);
|
|
143
|
-
const domAtPos = view.domAtPos.bind(view);
|
|
144
|
-
const maybeTable = domAtPos(table.start).node;
|
|
145
|
-
const maybeTableElement = maybeTable instanceof HTMLElement ? maybeTable : null;
|
|
146
|
-
const tableRef = maybeTableElement?.closest('table');
|
|
147
|
-
|
|
148
|
-
if (!tableRef || !newTable) {
|
|
149
|
-
return tr;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const isResized = hasTableBeenResized(table.node);
|
|
153
|
-
|
|
154
|
-
let previousTableInfo = {
|
|
155
|
-
width: 0,
|
|
156
|
-
possibleMaxWidth: 0,
|
|
157
|
-
isResized,
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const tableDepth = view.state.doc.resolve(table.pos).depth;
|
|
161
|
-
let shouldScale = isTableScalingEnabled && tableDepth === 0;
|
|
162
|
-
|
|
163
|
-
if (shouldScale && isTableFixedColumnWidthsOptionEnabled) {
|
|
164
|
-
shouldScale = newTable.attrs.displayMode !== 'fixed';
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (shouldScale) {
|
|
168
|
-
previousTableInfo = {
|
|
169
|
-
width: getTableElementWidth(table.node),
|
|
170
|
-
possibleMaxWidth: getTableContainerElementWidth(table.node),
|
|
171
|
-
isResized,
|
|
172
|
-
};
|
|
173
|
-
} else {
|
|
174
|
-
previousTableInfo = {
|
|
175
|
-
// when table is resized the tableRef client width will be 1px larger than colGroup, which is used in calculations
|
|
176
|
-
width: isResized ? tableRef.clientWidth - 1 : tableRef.clientWidth,
|
|
177
|
-
/** the is the width the table can reach before overflowing */
|
|
178
|
-
possibleMaxWidth: tableRef?.parentElement?.clientWidth || 0,
|
|
179
|
-
isResized,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// determine the new table, based on new width
|
|
184
|
-
const newTableInfo = {
|
|
185
|
-
noOfColumns: TableMap.get(newTable).width,
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
if (!newTableInfo.noOfColumns || newTableInfo.noOfColumns <= 0) {
|
|
189
|
-
return tr;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const averageColumnWidth = previousTableInfo.width / newTableInfo.noOfColumns;
|
|
193
|
-
|
|
194
|
-
// If the table has not been resized (i.e. all columns will have the same width) and every column width is bigger than the minimum column width
|
|
195
|
-
// we skip updating the size of columns here.
|
|
196
|
-
if (!previousTableInfo.isResized && averageColumnWidth > tableCellMinWidth) {
|
|
197
|
-
return tr;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const wasTableInOverflow = previousTableInfo.width > previousTableInfo.possibleMaxWidth;
|
|
201
|
-
|
|
202
|
-
// If the table has not been resized, and each column width is smaller than the minimum column width
|
|
203
|
-
// Or if the table has been resized, but each column width is either 48px or null
|
|
204
|
-
// we update the table to have 48px for each column
|
|
205
|
-
if (
|
|
206
|
-
(!previousTableInfo.isResized && averageColumnWidth <= tableCellMinWidth) ||
|
|
207
|
-
(previousTableInfo.isResized && isMinCellWidthTable(table.node))
|
|
208
|
-
) {
|
|
209
|
-
const widths = new Array(newTableInfo.noOfColumns).fill(tableCellMinWidth);
|
|
210
|
-
const cols = widths.map((_, index) => ({
|
|
211
|
-
width: tableCellMinWidth,
|
|
212
|
-
minWidth: tableCellMinWidth,
|
|
213
|
-
index,
|
|
214
|
-
}));
|
|
215
|
-
|
|
216
|
-
const minWidthResizeState = {
|
|
217
|
-
cols,
|
|
218
|
-
widths,
|
|
219
|
-
maxSize: previousTableInfo.possibleMaxWidth,
|
|
220
|
-
tableWidth: previousTableInfo.width,
|
|
221
|
-
overflow: wasTableInOverflow,
|
|
222
|
-
};
|
|
223
|
-
return updateColumnWidths(minWidthResizeState, table.node, table.start, api)(tr);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
let resizeState = getResizeState({
|
|
227
|
-
minWidth: tableCellMinWidth,
|
|
228
|
-
table: table.node,
|
|
229
|
-
start: table.start,
|
|
230
|
-
tableRef,
|
|
231
|
-
domAtPos,
|
|
232
|
-
maxSize: previousTableInfo.possibleMaxWidth,
|
|
233
|
-
isTableScalingEnabled: shouldScale,
|
|
234
|
-
shouldUseIncreasedScalingPercent,
|
|
235
|
-
isCommentEditor,
|
|
236
|
-
});
|
|
237
|
-
// Two scenarios that require scaling:
|
|
238
|
-
// 1. If the new table width will result in the table going into overflow
|
|
239
|
-
// we resize the cells to avoid it (e.g. adding a column)
|
|
240
|
-
// 2. If the new table width will be shorter than the parent width, scale columns to fit parent
|
|
241
|
-
if (
|
|
242
|
-
(!wasTableInOverflow && resizeState.overflow) ||
|
|
243
|
-
resizeState.tableWidth < resizeState.maxSize
|
|
244
|
-
) {
|
|
245
|
-
resizeState = scaleTableTo(resizeState, previousTableInfo.possibleMaxWidth);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return updateColumnWidths(resizeState, table.node, table.start, api)(tr);
|
|
249
|
-
};
|