@atlaskit/editor-plugin-table 7.4.9 → 7.5.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 +12 -0
- package/dist/cjs/commands/column-resize.js +4 -2
- package/dist/cjs/commands/delete.js +2 -1
- package/dist/cjs/commands/insert.js +6 -3
- package/dist/cjs/commands-with-analytics.js +4 -2
- package/dist/cjs/event-handlers.js +2 -1
- package/dist/cjs/nodeviews/TableComponent.js +116 -47
- package/dist/cjs/nodeviews/TableContainer.js +8 -4
- package/dist/cjs/nodeviews/TableResizer.js +6 -5
- package/dist/cjs/nodeviews/table.js +12 -4
- package/dist/cjs/plugin.js +50 -47
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +9 -6
- package/dist/cjs/pm-plugins/keymap.js +6 -3
- package/dist/cjs/pm-plugins/main.js +4 -1
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +7 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +32 -11
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +24 -0
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +20 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +2 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +52 -11
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +19 -8
- package/dist/cjs/toolbar.js +17 -10
- package/dist/cjs/transforms/column-width.js +22 -7
- package/dist/cjs/transforms/delete-columns.js +2 -1
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +45 -38
- package/dist/cjs/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +7 -2
- package/dist/cjs/ui/FloatingInsertButton/index.js +5 -1
- package/dist/cjs/utils/create.js +1 -1
- package/dist/cjs/utils/drag-menu.js +4 -3
- package/dist/es2019/commands/column-resize.js +4 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +6 -6
- package/dist/es2019/commands-with-analytics.js +4 -4
- package/dist/es2019/event-handlers.js +2 -2
- package/dist/es2019/nodeviews/TableComponent.js +77 -8
- package/dist/es2019/nodeviews/TableContainer.js +8 -4
- package/dist/es2019/nodeviews/TableResizer.js +6 -5
- package/dist/es2019/nodeviews/table.js +12 -4
- package/dist/es2019/plugin.js +14 -8
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +7 -4
- package/dist/es2019/pm-plugins/keymap.js +6 -3
- package/dist/es2019/pm-plugins/main.js +4 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +7 -3
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +31 -12
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +20 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +47 -10
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +19 -12
- package/dist/es2019/toolbar.js +15 -12
- package/dist/es2019/transforms/column-width.js +24 -10
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +12 -5
- package/dist/es2019/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +7 -2
- package/dist/es2019/ui/FloatingInsertButton/index.js +5 -1
- package/dist/es2019/utils/create.js +1 -1
- package/dist/es2019/utils/drag-menu.js +4 -4
- package/dist/esm/commands/column-resize.js +4 -2
- package/dist/esm/commands/delete.js +2 -1
- package/dist/esm/commands/insert.js +6 -3
- package/dist/esm/commands-with-analytics.js +4 -2
- package/dist/esm/event-handlers.js +2 -1
- package/dist/esm/nodeviews/TableComponent.js +118 -49
- package/dist/esm/nodeviews/TableContainer.js +8 -4
- package/dist/esm/nodeviews/TableResizer.js +6 -5
- package/dist/esm/nodeviews/table.js +12 -4
- package/dist/esm/plugin.js +50 -47
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +9 -6
- package/dist/esm/pm-plugins/keymap.js +6 -3
- package/dist/esm/pm-plugins/main.js +4 -1
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +7 -3
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +32 -11
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +22 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +2 -1
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +52 -11
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +19 -8
- package/dist/esm/toolbar.js +17 -10
- package/dist/esm/transforms/column-width.js +23 -8
- package/dist/esm/transforms/delete-columns.js +2 -1
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +45 -38
- package/dist/esm/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +7 -2
- package/dist/esm/ui/FloatingInsertButton/index.js +5 -1
- package/dist/esm/utils/create.js +1 -1
- package/dist/esm/utils/drag-menu.js +4 -3
- package/dist/types/commands/column-resize.d.ts +1 -1
- package/dist/types/commands/delete.d.ts +1 -1
- package/dist/types/commands/insert.d.ts +3 -3
- package/dist/types/commands-with-analytics.d.ts +2 -2
- package/dist/types/event-handlers.d.ts +1 -1
- package/dist/types/nodeviews/TableComponent.d.ts +3 -0
- package/dist/types/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/nodeviews/table.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +3 -2
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +7 -0
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -3
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types/toolbar.d.ts +2 -2
- package/dist/types/transforms/column-width.d.ts +1 -1
- package/dist/types/transforms/delete-columns.d.ts +1 -1
- package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
- package/dist/types/ui/FloatingInsertButton/index.d.ts +2 -1
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
- package/dist/types-ts4.5/commands/delete.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +3 -3
- package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -2
- package/dist/types-ts4.5/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +3 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +3 -2
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -3
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types-ts4.5/toolbar.d.ts +2 -2
- package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
- package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +2 -1
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/docs/0-intro.tsx +3 -2
- package/package.json +2 -2
- package/src/commands/column-resize.ts +3 -0
- package/src/commands/delete.ts +2 -1
- package/src/commands/insert.ts +15 -6
- package/src/commands-with-analytics.ts +9 -3
- package/src/event-handlers.ts +2 -0
- package/src/nodeviews/TableComponent.tsx +91 -5
- package/src/nodeviews/TableContainer.tsx +7 -1
- package/src/nodeviews/TableResizer.tsx +7 -1
- package/src/nodeviews/table.tsx +15 -10
- package/src/plugin.tsx +17 -5
- package/src/pm-plugins/drag-and-drop/plugin.ts +16 -8
- package/src/pm-plugins/keymap.ts +11 -3
- package/src/pm-plugins/main.ts +3 -0
- package/src/pm-plugins/table-resizing/event-handlers.ts +11 -1
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +49 -17
- package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +8 -1
- package/src/pm-plugins/table-resizing/utils/misc.ts +25 -1
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +2 -1
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +56 -11
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +24 -6
- package/src/toolbar.tsx +18 -5
- package/src/transforms/column-width.ts +33 -11
- package/src/transforms/delete-columns.ts +7 -2
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +20 -5
- package/src/ui/FloatingContextualMenu/index.tsx +2 -0
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -0
- package/src/ui/FloatingDragMenu/index.tsx +9 -1
- package/src/ui/FloatingInsertButton/index.tsx +17 -5
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +4 -1
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +4 -1
- package/src/utils/create.ts +1 -3
- package/src/utils/drag-menu.ts +4 -1
- package/tsconfig.dev.json +1 -1
package/src/toolbar.tsx
CHANGED
|
@@ -169,6 +169,7 @@ export const getToolbarCellOptionsConfig = (
|
|
|
169
169
|
{ formatMessage }: ToolbarMenuContext,
|
|
170
170
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
171
171
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
172
|
+
tablePreserveWidth = false,
|
|
172
173
|
): FloatingToolbarDropdown<Command> => {
|
|
173
174
|
const { top, bottom, right, left } = initialSelectionRect;
|
|
174
175
|
const numberOfColumns = right - left;
|
|
@@ -190,6 +191,7 @@ export const getToolbarCellOptionsConfig = (
|
|
|
190
191
|
insertColumnWithAnalytics(
|
|
191
192
|
getEditorContainerWidth,
|
|
192
193
|
editorAnalyticsAPI,
|
|
194
|
+
tablePreserveWidth,
|
|
193
195
|
)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
194
196
|
}
|
|
195
197
|
return true;
|
|
@@ -292,6 +294,7 @@ export const getToolbarCellOptionsConfig = (
|
|
|
292
294
|
editorState,
|
|
293
295
|
editorView.domAtPos.bind(editorView),
|
|
294
296
|
getEditorContainerWidth,
|
|
297
|
+
tablePreserveWidth,
|
|
295
298
|
)
|
|
296
299
|
: undefined;
|
|
297
300
|
const wouldChange = newResizeStateWithAnalytics?.changed ?? false;
|
|
@@ -459,6 +462,8 @@ export const getToolbarConfig =
|
|
|
459
462
|
editorAnalyticsAPI,
|
|
460
463
|
);
|
|
461
464
|
|
|
465
|
+
const { tablePreserveWidth = false } = getEditorFeatureFlags();
|
|
466
|
+
|
|
462
467
|
let cellItems: Array<FloatingToolbarItem<Command>>;
|
|
463
468
|
cellItems = pluginState.isDragAndDropEnabled
|
|
464
469
|
? []
|
|
@@ -469,6 +474,7 @@ export const getToolbarConfig =
|
|
|
469
474
|
intl,
|
|
470
475
|
getEditorContainerWidth,
|
|
471
476
|
editorAnalyticsAPI,
|
|
477
|
+
tablePreserveWidth,
|
|
472
478
|
);
|
|
473
479
|
|
|
474
480
|
let columnSettingsItems;
|
|
@@ -481,6 +487,7 @@ export const getToolbarConfig =
|
|
|
481
487
|
intl,
|
|
482
488
|
getEditorContainerWidth,
|
|
483
489
|
editorAnalyticsAPI,
|
|
490
|
+
tablePreserveWidth,
|
|
484
491
|
)
|
|
485
492
|
: [];
|
|
486
493
|
const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
|
|
@@ -606,6 +613,7 @@ const getCellItems = (
|
|
|
606
613
|
{ formatMessage }: ToolbarMenuContext,
|
|
607
614
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
608
615
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
616
|
+
tablePreserveWidth = false,
|
|
609
617
|
): Array<FloatingToolbarItem<Command>> => {
|
|
610
618
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
611
619
|
if (initialSelectionRect) {
|
|
@@ -616,6 +624,7 @@ const getCellItems = (
|
|
|
616
624
|
{ formatMessage },
|
|
617
625
|
getEditorContainerWidth,
|
|
618
626
|
editorAnalyticsAPI,
|
|
627
|
+
tablePreserveWidth,
|
|
619
628
|
);
|
|
620
629
|
return [cellOptions, separator(cellOptions.hidden!)];
|
|
621
630
|
}
|
|
@@ -626,6 +635,7 @@ export const getDistributeConfig =
|
|
|
626
635
|
(
|
|
627
636
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
628
637
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
638
|
+
tablePreserveWidth = false,
|
|
629
639
|
): Command =>
|
|
630
640
|
(state, dispatch, editorView) => {
|
|
631
641
|
const selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
@@ -637,6 +647,7 @@ export const getDistributeConfig =
|
|
|
637
647
|
state,
|
|
638
648
|
editorView.domAtPos.bind(editorView),
|
|
639
649
|
getEditorContainerWidth,
|
|
650
|
+
tablePreserveWidth,
|
|
640
651
|
);
|
|
641
652
|
|
|
642
653
|
if (newResizeStateWithAnalytics) {
|
|
@@ -657,6 +668,7 @@ const getColumnSettingItems = (
|
|
|
657
668
|
{ formatMessage }: ToolbarMenuContext,
|
|
658
669
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
659
670
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
671
|
+
tablePreserveWidth = false,
|
|
660
672
|
): Array<FloatingToolbarItem<Command>> => {
|
|
661
673
|
const pluginState = getPluginState(editorState);
|
|
662
674
|
const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
|
|
@@ -670,6 +682,7 @@ const getColumnSettingItems = (
|
|
|
670
682
|
editorState,
|
|
671
683
|
editorView.domAtPos.bind(editorView),
|
|
672
684
|
getEditorContainerWidth,
|
|
685
|
+
tablePreserveWidth,
|
|
673
686
|
);
|
|
674
687
|
|
|
675
688
|
const wouldChange = newResizeStateWithAnalytics?.changed ?? false;
|
|
@@ -685,11 +698,11 @@ const getColumnSettingItems = (
|
|
|
685
698
|
title: formatMessage(messages.distributeColumns),
|
|
686
699
|
icon: DistributeColumnIcon,
|
|
687
700
|
onClick: (state, dispatch, view) =>
|
|
688
|
-
getDistributeConfig(
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
),
|
|
701
|
+
getDistributeConfig(
|
|
702
|
+
getEditorContainerWidth,
|
|
703
|
+
editorAnalyticsAPI,
|
|
704
|
+
tablePreserveWidth,
|
|
705
|
+
)(state, dispatch, view),
|
|
693
706
|
disabled: !wouldChange,
|
|
694
707
|
},
|
|
695
708
|
{
|
|
@@ -9,7 +9,11 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
9
9
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
|
|
11
11
|
import type { ResizeState } from '../pm-plugins/table-resizing/utils';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
getTableContainerElement,
|
|
14
|
+
getTableElementWidth,
|
|
15
|
+
hasTableBeenResized,
|
|
16
|
+
} from '../pm-plugins/table-resizing/utils';
|
|
13
17
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
14
18
|
import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
15
19
|
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
@@ -104,7 +108,7 @@ export const updateColumnWidths =
|
|
|
104
108
|
* @returns Updated transaction with rescaled columns for a given table
|
|
105
109
|
*/
|
|
106
110
|
export const rescaleColumns =
|
|
107
|
-
() =>
|
|
111
|
+
(tablePreserveWidth = false) =>
|
|
108
112
|
(table: ContentNodeWithPos, view: EditorView | undefined) =>
|
|
109
113
|
(tr: Transaction): Transaction => {
|
|
110
114
|
if (!view) {
|
|
@@ -121,18 +125,35 @@ export const rescaleColumns =
|
|
|
121
125
|
}
|
|
122
126
|
|
|
123
127
|
const isResized = hasTableBeenResized(table.node);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
/** the is the width the table can reach before overflowing */
|
|
129
|
-
possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width')
|
|
130
|
-
? tableRef?.parentElement?.clientWidth || 0
|
|
131
|
-
: (tableRef?.parentElement?.clientWidth || 0) -
|
|
132
|
-
insertColumnButtonOffset,
|
|
128
|
+
|
|
129
|
+
let previousTableInfo = {
|
|
130
|
+
width: 0,
|
|
131
|
+
possibleMaxWidth: 0,
|
|
133
132
|
isResized,
|
|
134
133
|
};
|
|
135
134
|
|
|
135
|
+
if (tablePreserveWidth) {
|
|
136
|
+
previousTableInfo = {
|
|
137
|
+
// TODO - ensure correct width is returned when table doesn't have a width value
|
|
138
|
+
width: getTableElementWidth(table.node),
|
|
139
|
+
possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width')
|
|
140
|
+
? getTableContainerElement(table.node)
|
|
141
|
+
: getTableContainerElement(table.node) - insertColumnButtonOffset,
|
|
142
|
+
isResized,
|
|
143
|
+
};
|
|
144
|
+
} else {
|
|
145
|
+
previousTableInfo = {
|
|
146
|
+
// when table is resized the tableRef client width will be 1px larger than colGroup, which is used in calculations
|
|
147
|
+
width: isResized ? tableRef.clientWidth - 1 : tableRef.clientWidth,
|
|
148
|
+
/** the is the width the table can reach before overflowing */
|
|
149
|
+
possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width')
|
|
150
|
+
? tableRef?.parentElement?.clientWidth || 0
|
|
151
|
+
: (tableRef?.parentElement?.clientWidth || 0) -
|
|
152
|
+
insertColumnButtonOffset,
|
|
153
|
+
isResized,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
136
157
|
// determine the new table, based on new width
|
|
137
158
|
const newTableInfo = {
|
|
138
159
|
noOfColumns: TableMap.get(newTable).width,
|
|
@@ -195,6 +216,7 @@ export const rescaleColumns =
|
|
|
195
216
|
tableRef,
|
|
196
217
|
domAtPos,
|
|
197
218
|
maxSize: previousTableInfo.possibleMaxWidth,
|
|
219
|
+
tablePreserveWidth,
|
|
198
220
|
});
|
|
199
221
|
|
|
200
222
|
// Two scenarios that require scaling:
|
|
@@ -249,7 +249,12 @@ function fixRowSpans(table: PMNode): PMNode | null {
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
export const deleteColumns =
|
|
252
|
-
(
|
|
252
|
+
(
|
|
253
|
+
rect: Rect,
|
|
254
|
+
allowCustomStep: boolean,
|
|
255
|
+
view?: EditorView,
|
|
256
|
+
tablePreserveWidth = false,
|
|
257
|
+
) =>
|
|
253
258
|
(tr: Transaction) => {
|
|
254
259
|
let updatedTr = tr;
|
|
255
260
|
updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
@@ -264,7 +269,7 @@ export const deleteColumns =
|
|
|
264
269
|
const table = findTable(updatedTr.selection);
|
|
265
270
|
|
|
266
271
|
if (table) {
|
|
267
|
-
updatedTr = rescaleColumns()(table, view)(updatedTr);
|
|
272
|
+
updatedTr = rescaleColumns(tablePreserveWidth)(table, view)(updatedTr);
|
|
268
273
|
}
|
|
269
274
|
return updatedTr;
|
|
270
275
|
};
|
|
@@ -23,7 +23,10 @@ import {
|
|
|
23
23
|
} from '@atlaskit/editor-common/keymaps';
|
|
24
24
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
25
25
|
import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
26
|
-
import type {
|
|
26
|
+
import type {
|
|
27
|
+
GetEditorContainerWidth,
|
|
28
|
+
GetEditorFeatureFlags,
|
|
29
|
+
} from '@atlaskit/editor-common/types';
|
|
27
30
|
import {
|
|
28
31
|
backgroundPaletteTooltipMessages,
|
|
29
32
|
cellBackgroundColorPalette,
|
|
@@ -99,6 +102,7 @@ export interface Props {
|
|
|
99
102
|
offset?: Array<number>;
|
|
100
103
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
101
104
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
105
|
+
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
export interface State {
|
|
@@ -464,11 +468,14 @@ export class ContextualMenu extends Component<
|
|
|
464
468
|
(!isDragAndDropEnabled ||
|
|
465
469
|
!getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))
|
|
466
470
|
) {
|
|
471
|
+
const { tablePreserveWidth = false } =
|
|
472
|
+
this.props.getEditorFeatureFlags?.() || {};
|
|
467
473
|
const newResizeState = getNewResizeStateFromSelectedColumns(
|
|
468
474
|
selectionRect,
|
|
469
475
|
editorView.state,
|
|
470
476
|
editorView.domAtPos.bind(editorView),
|
|
471
477
|
getEditorContainerWidth,
|
|
478
|
+
tablePreserveWidth,
|
|
472
479
|
);
|
|
473
480
|
|
|
474
481
|
const wouldChange = newResizeState?.changed ?? false;
|
|
@@ -583,10 +590,12 @@ export class ContextualMenu extends Component<
|
|
|
583
590
|
selectionRect,
|
|
584
591
|
editorAnalyticsAPI,
|
|
585
592
|
getEditorContainerWidth,
|
|
593
|
+
getEditorFeatureFlags,
|
|
586
594
|
} = this.props;
|
|
587
595
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
588
596
|
const { state, dispatch } = editorView;
|
|
589
597
|
const { targetCellPosition } = getPluginState(state);
|
|
598
|
+
const { tablePreserveWidth = false } = getEditorFeatureFlags?.() || {};
|
|
590
599
|
|
|
591
600
|
switch (item.value.name) {
|
|
592
601
|
case 'sort_column_desc':
|
|
@@ -626,6 +635,7 @@ export class ContextualMenu extends Component<
|
|
|
626
635
|
state,
|
|
627
636
|
editorView.domAtPos.bind(editorView),
|
|
628
637
|
getEditorContainerWidth,
|
|
638
|
+
tablePreserveWidth,
|
|
629
639
|
);
|
|
630
640
|
|
|
631
641
|
if (newResizeStateWithAnalytics) {
|
|
@@ -644,10 +654,15 @@ export class ContextualMenu extends Component<
|
|
|
644
654
|
this.toggleOpen();
|
|
645
655
|
break;
|
|
646
656
|
case 'insert_column':
|
|
647
|
-
insertColumnWithAnalytics(
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
657
|
+
insertColumnWithAnalytics(
|
|
658
|
+
getEditorContainerWidth,
|
|
659
|
+
editorAnalyticsAPI,
|
|
660
|
+
tablePreserveWidth,
|
|
661
|
+
)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(
|
|
662
|
+
state,
|
|
663
|
+
dispatch,
|
|
664
|
+
editorView,
|
|
665
|
+
);
|
|
651
666
|
this.toggleOpen();
|
|
652
667
|
break;
|
|
653
668
|
case 'insert_row':
|
|
@@ -53,6 +53,7 @@ const FloatingContextualMenu = ({
|
|
|
53
53
|
pluginConfig,
|
|
54
54
|
editorAnalyticsAPI,
|
|
55
55
|
getEditorContainerWidth,
|
|
56
|
+
getEditorFeatureFlags,
|
|
56
57
|
}: Props) => {
|
|
57
58
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
58
59
|
const { targetCellPosition, isDragAndDropEnabled } = getPluginState(
|
|
@@ -122,6 +123,7 @@ const FloatingContextualMenu = ({
|
|
|
122
123
|
boundariesElement={boundariesElement}
|
|
123
124
|
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
124
125
|
getEditorContainerWidth={getEditorContainerWidth}
|
|
126
|
+
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
125
127
|
/>
|
|
126
128
|
</div>
|
|
127
129
|
</Popup>
|
|
@@ -101,6 +101,7 @@ type DragMenuProps = {
|
|
|
101
101
|
mountPoint?: HTMLElement;
|
|
102
102
|
boundariesElement?: HTMLElement;
|
|
103
103
|
scrollableElement?: HTMLElement;
|
|
104
|
+
tablePreserveWidth?: boolean;
|
|
104
105
|
};
|
|
105
106
|
|
|
106
107
|
type PluralOptionType = 'noOfCols' | 'noOfRows' | 'noOfCells' | null;
|
|
@@ -279,6 +280,7 @@ export const DragMenu = React.memo(
|
|
|
279
280
|
mountPoint,
|
|
280
281
|
scrollableElement,
|
|
281
282
|
boundariesElement,
|
|
283
|
+
tablePreserveWidth,
|
|
282
284
|
}: DragMenuProps & WrappedComponentProps) => {
|
|
283
285
|
const { state, dispatch } = editorView;
|
|
284
286
|
const { selection } = state;
|
|
@@ -311,6 +313,7 @@ export const DragMenu = React.memo(
|
|
|
311
313
|
selectionRect,
|
|
312
314
|
editorAnalyticsAPI,
|
|
313
315
|
pluginConfig?.isHeaderRowRequired,
|
|
316
|
+
tablePreserveWidth,
|
|
314
317
|
);
|
|
315
318
|
|
|
316
319
|
const { menuItems, menuCallback } = convertToDropdownItems(
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
GetEditorContainerWidth,
|
|
6
|
+
GetEditorFeatureFlags,
|
|
7
|
+
} from '@atlaskit/editor-common/types';
|
|
5
8
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
6
9
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
7
10
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -32,6 +35,7 @@ export interface Props {
|
|
|
32
35
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
33
36
|
stickyHeaders?: RowStickyState;
|
|
34
37
|
pluginConfig?: PluginConfig;
|
|
38
|
+
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
const FloatingDragMenu = ({
|
|
@@ -48,6 +52,7 @@ const FloatingDragMenu = ({
|
|
|
48
52
|
editorAnalyticsAPI,
|
|
49
53
|
stickyHeaders,
|
|
50
54
|
pluginConfig,
|
|
55
|
+
getEditorFeatureFlags,
|
|
51
56
|
}: Props) => {
|
|
52
57
|
if (
|
|
53
58
|
!isOpen ||
|
|
@@ -72,6 +77,8 @@ const FloatingDragMenu = ({
|
|
|
72
77
|
return null;
|
|
73
78
|
}
|
|
74
79
|
|
|
80
|
+
const { tablePreserveWidth = false } = getEditorFeatureFlags();
|
|
81
|
+
|
|
75
82
|
return (
|
|
76
83
|
<Popup
|
|
77
84
|
alignX={direction === 'row' ? 'right' : undefined}
|
|
@@ -110,6 +117,7 @@ const FloatingDragMenu = ({
|
|
|
110
117
|
mountPoint={mountPoint}
|
|
111
118
|
boundariesElement={boundariesElement}
|
|
112
119
|
scrollableElement={scrollableElement}
|
|
120
|
+
tablePreserveWidth={tablePreserveWidth}
|
|
113
121
|
/>
|
|
114
122
|
</Popup>
|
|
115
123
|
);
|
|
@@ -15,7 +15,10 @@ import {
|
|
|
15
15
|
EVENT_TYPE,
|
|
16
16
|
INPUT_METHOD,
|
|
17
17
|
} from '@atlaskit/editor-common/analytics';
|
|
18
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
GetEditorContainerWidth,
|
|
20
|
+
GetEditorFeatureFlags,
|
|
21
|
+
} from '@atlaskit/editor-common/types';
|
|
19
22
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
20
23
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
21
24
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -52,6 +55,7 @@ export interface Props {
|
|
|
52
55
|
hasStickyHeaders?: boolean;
|
|
53
56
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
54
57
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
58
|
+
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
export class FloatingInsertButton extends React.Component<
|
|
@@ -284,11 +288,19 @@ export class FloatingInsertButton extends React.Component<
|
|
|
284
288
|
if (typeof insertColumnButtonIndex !== 'undefined') {
|
|
285
289
|
event.preventDefault();
|
|
286
290
|
|
|
291
|
+
const { tablePreserveWidth = false } =
|
|
292
|
+
this.props.getEditorFeatureFlags?.() || {};
|
|
293
|
+
|
|
287
294
|
const { state, dispatch } = editorView;
|
|
288
|
-
insertColumnWithAnalytics(
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
295
|
+
insertColumnWithAnalytics(
|
|
296
|
+
getEditorContainerWidth,
|
|
297
|
+
editorAnalyticsAPI,
|
|
298
|
+
tablePreserveWidth,
|
|
299
|
+
)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(
|
|
300
|
+
state,
|
|
301
|
+
dispatch,
|
|
302
|
+
editorView,
|
|
303
|
+
);
|
|
292
304
|
}
|
|
293
305
|
}
|
|
294
306
|
}
|
|
@@ -159,7 +159,10 @@ export const ColumnControls = ({
|
|
|
159
159
|
}, [editorView, tableActive]);
|
|
160
160
|
|
|
161
161
|
const toggleDragMenuHandler = useCallback(
|
|
162
|
-
(
|
|
162
|
+
(
|
|
163
|
+
trigger: TriggerType,
|
|
164
|
+
event: MouseEvent<HTMLButtonElement, globalThis.MouseEvent> | undefined,
|
|
165
|
+
) => {
|
|
163
166
|
const { state, dispatch } = editorView;
|
|
164
167
|
if (event?.shiftKey) {
|
|
165
168
|
return;
|
|
@@ -114,7 +114,10 @@ const DragControlsComponent = ({
|
|
|
114
114
|
}, [editorView]);
|
|
115
115
|
|
|
116
116
|
const toggleDragMenuHandler = useCallback(
|
|
117
|
-
(
|
|
117
|
+
(
|
|
118
|
+
trigger: TriggerType,
|
|
119
|
+
event: MouseEvent<HTMLButtonElement, globalThis.MouseEvent> | undefined,
|
|
120
|
+
) => {
|
|
118
121
|
if (event?.shiftKey) {
|
|
119
122
|
return;
|
|
120
123
|
}
|
package/src/utils/create.ts
CHANGED
|
@@ -14,9 +14,7 @@ export const createTableWithWidth =
|
|
|
14
14
|
},
|
|
15
15
|
) =>
|
|
16
16
|
(schema: Schema) => {
|
|
17
|
-
const { tablePreserveWidth = false } = getEditorFeatureFlags
|
|
18
|
-
? getEditorFeatureFlags()
|
|
19
|
-
: {};
|
|
17
|
+
const { tablePreserveWidth = false } = getEditorFeatureFlags?.() || {};
|
|
20
18
|
|
|
21
19
|
if (tablePreserveWidth && isFullWidthModeEnabled) {
|
|
22
20
|
return createTable({
|
package/src/utils/drag-menu.ts
CHANGED
|
@@ -159,6 +159,7 @@ export const getDragMenuConfig = (
|
|
|
159
159
|
selectionRect?: Rect,
|
|
160
160
|
editorAnalyticsAPI?: EditorAnalyticsAPI,
|
|
161
161
|
isHeaderRowRequired?: boolean,
|
|
162
|
+
tablePreserveWidth = false,
|
|
162
163
|
): DragMenuConfig[] => {
|
|
163
164
|
const addOptions =
|
|
164
165
|
direction === 'row'
|
|
@@ -296,6 +297,7 @@ export const getDragMenuConfig = (
|
|
|
296
297
|
insertColumnWithAnalytics(
|
|
297
298
|
getEditorContainerWidth,
|
|
298
299
|
editorAnalyticsAPI,
|
|
300
|
+
tablePreserveWidth,
|
|
299
301
|
)(INPUT_METHOD.TABLE_CONTEXT_MENU, (index ?? 0) + offset)(
|
|
300
302
|
state,
|
|
301
303
|
dispatch,
|
|
@@ -319,6 +321,7 @@ export const getDragMenuConfig = (
|
|
|
319
321
|
state,
|
|
320
322
|
editorView.domAtPos.bind(editorView),
|
|
321
323
|
getEditorContainerWidth,
|
|
324
|
+
tablePreserveWidth,
|
|
322
325
|
);
|
|
323
326
|
|
|
324
327
|
if (newResizeState) {
|
|
@@ -359,7 +362,7 @@ export const getDragMenuConfig = (
|
|
|
359
362
|
!!isHeaderRowRequired,
|
|
360
363
|
)(state, dispatch);
|
|
361
364
|
} else {
|
|
362
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI)(
|
|
365
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI, tablePreserveWidth)(
|
|
363
366
|
INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
364
367
|
selectionRect ?? defaultSelectionRect,
|
|
365
368
|
)(state, dispatch, editorView);
|
package/tsconfig.dev.json
CHANGED