@atlaskit/editor-plugin-table 7.16.13 → 7.16.15
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/commands/column-resize.js +6 -3
- package/dist/cjs/commands/delete.js +2 -1
- package/dist/cjs/commands/insert.js +8 -5
- package/dist/cjs/commands/misc.js +17 -1
- package/dist/cjs/commands-with-analytics.js +6 -4
- package/dist/cjs/event-handlers.js +2 -1
- package/dist/cjs/nodeviews/TableComponent.js +21 -10
- package/dist/cjs/nodeviews/TableContainer.js +7 -3
- package/dist/cjs/nodeviews/TableResizer.js +3 -2
- package/dist/cjs/plugin.js +4 -3
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +4 -2
- package/dist/cjs/pm-plugins/keymap.js +5 -4
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -7
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +6 -5
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +2 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +6 -0
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +6 -4
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +5 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +13 -8
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +17 -9
- package/dist/cjs/toolbar.js +10 -5
- package/dist/cjs/transforms/column-width.js +3 -1
- package/dist/cjs/transforms/delete-columns.js +2 -1
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +4 -2
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +4 -1
- package/dist/cjs/ui/FloatingInsertButton/index.js +3 -1
- package/dist/cjs/utils/drag-menu.js +2 -1
- package/dist/es2019/commands/column-resize.js +6 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +8 -8
- package/dist/es2019/commands/misc.js +17 -1
- package/dist/es2019/commands-with-analytics.js +6 -6
- package/dist/es2019/event-handlers.js +2 -2
- package/dist/es2019/nodeviews/TableComponent.js +21 -10
- package/dist/es2019/nodeviews/TableContainer.js +7 -3
- package/dist/es2019/nodeviews/TableResizer.js +3 -2
- package/dist/es2019/plugin.js +4 -3
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +4 -2
- package/dist/es2019/pm-plugins/keymap.js +5 -5
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +12 -7
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +6 -6
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +1 -0
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +7 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +5 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -8
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +17 -12
- package/dist/es2019/toolbar.js +10 -8
- package/dist/es2019/transforms/column-width.js +3 -2
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +4 -2
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +4 -1
- package/dist/es2019/ui/FloatingInsertButton/index.js +3 -1
- package/dist/es2019/utils/drag-menu.js +2 -2
- package/dist/esm/commands/column-resize.js +6 -3
- package/dist/esm/commands/delete.js +2 -1
- package/dist/esm/commands/insert.js +8 -5
- package/dist/esm/commands/misc.js +17 -1
- package/dist/esm/commands-with-analytics.js +6 -4
- package/dist/esm/event-handlers.js +2 -1
- package/dist/esm/nodeviews/TableComponent.js +21 -10
- package/dist/esm/nodeviews/TableContainer.js +7 -3
- package/dist/esm/nodeviews/TableResizer.js +3 -2
- package/dist/esm/plugin.js +4 -3
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +4 -2
- package/dist/esm/pm-plugins/keymap.js +5 -4
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -7
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +6 -5
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +1 -0
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +7 -5
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +5 -3
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -8
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +17 -9
- package/dist/esm/toolbar.js +10 -5
- package/dist/esm/transforms/column-width.js +3 -1
- package/dist/esm/transforms/delete-columns.js +2 -1
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +4 -2
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +4 -1
- package/dist/esm/ui/FloatingInsertButton/index.js +3 -1
- package/dist/esm/utils/drag-menu.js +2 -1
- package/dist/types/commands/delete.d.ts +1 -1
- package/dist/types/commands/insert.d.ts +4 -4
- package/dist/types/commands-with-analytics.d.ts +3 -3
- package/dist/types/event-handlers.d.ts +1 -1
- package/dist/types/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +3 -2
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
- 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/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/delete.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +4 -4
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -3
- package/dist/types-ts4.5/event-handlers.d.ts +1 -1
- 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/pm-plugins/keymap.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- 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 +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +3 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
- 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/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +4 -1
- package/src/commands/column-resize.ts +9 -3
- package/src/commands/delete.ts +2 -1
- package/src/commands/insert.ts +31 -12
- package/src/commands/misc.ts +20 -4
- package/src/commands-with-analytics.ts +24 -8
- package/src/event-handlers.ts +2 -0
- package/src/nodeviews/TableComponent.tsx +41 -12
- package/src/nodeviews/TableContainer.tsx +6 -0
- package/src/nodeviews/TableResizer.tsx +4 -0
- package/src/plugin.tsx +9 -0
- package/src/pm-plugins/drag-and-drop/plugin.ts +13 -4
- package/src/pm-plugins/keymap.ts +17 -4
- package/src/pm-plugins/main.ts +2 -0
- package/src/pm-plugins/table-resizing/event-handlers.ts +21 -10
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +14 -4
- package/src/pm-plugins/table-resizing/utils/consts.ts +1 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +1 -0
- package/src/pm-plugins/table-resizing/utils/misc.ts +24 -5
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +11 -4
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +17 -6
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +32 -9
- package/src/toolbar.tsx +18 -10
- package/src/transforms/column-width.ts +2 -1
- package/src/transforms/delete-columns.ts +11 -2
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +12 -5
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -0
- package/src/ui/FloatingDragMenu/index.tsx +7 -0
- package/src/ui/FloatingInsertButton/index.tsx +7 -0
- package/src/utils/drag-menu.ts +2 -0
|
@@ -11,7 +11,7 @@ import { hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
|
11
11
|
import { syncStickyRowToTable } from './dom';
|
|
12
12
|
// Base function to trigger the actual scale on a table node.
|
|
13
13
|
// Will only resize/scale if a table has been previously resized.
|
|
14
|
-
export const scale = (tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable = false) => {
|
|
14
|
+
export const scale = (tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable = false, shouldUseIncreasedScalingPercent = false) => {
|
|
15
15
|
const {
|
|
16
16
|
node,
|
|
17
17
|
containerWidth,
|
|
@@ -49,11 +49,12 @@ export const scale = (tableRef, options, domAtPos, isTableScalingEnabledOnCurren
|
|
|
49
49
|
tableRef,
|
|
50
50
|
start,
|
|
51
51
|
domAtPos,
|
|
52
|
-
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable
|
|
52
|
+
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable,
|
|
53
|
+
shouldUseIncreasedScalingPercent
|
|
53
54
|
});
|
|
54
55
|
return scaleTableTo(resizeState, newWidth);
|
|
55
56
|
};
|
|
56
|
-
export const scaleWithParent = (tableRef, parentWidth, table, start, domAtPos, isTableScalingEnabledOnCurrentTable = false) => {
|
|
57
|
+
export const scaleWithParent = (tableRef, parentWidth, table, start, domAtPos, isTableScalingEnabledOnCurrentTable = false, shouldUseIncreasedScalingPercent = false) => {
|
|
57
58
|
const resizeState = getResizeState({
|
|
58
59
|
minWidth: tableCellMinWidth,
|
|
59
60
|
maxSize: parentWidth,
|
|
@@ -61,7 +62,8 @@ export const scaleWithParent = (tableRef, parentWidth, table, start, domAtPos, i
|
|
|
61
62
|
tableRef,
|
|
62
63
|
start,
|
|
63
64
|
domAtPos,
|
|
64
|
-
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable
|
|
65
|
+
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable,
|
|
66
|
+
shouldUseIncreasedScalingPercent
|
|
65
67
|
});
|
|
66
68
|
if (table.attrs.isNumberColumnEnabled) {
|
|
67
69
|
parentWidth -= akEditorTableNumberColumnWidth;
|
|
@@ -111,7 +113,8 @@ export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEna
|
|
|
111
113
|
tableRef.style.width = `${width}px`;
|
|
112
114
|
}
|
|
113
115
|
let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
114
|
-
|
|
116
|
+
const isTableScalingEnabledWithLockButton = isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
|
|
117
|
+
if (isTableScalingEnabledWithLockButton) {
|
|
115
118
|
isTableScalingEnabledOnCurrentTable = isTableScalingEnabled && node.attrs.displayMode !== 'fixed';
|
|
116
119
|
}
|
|
117
120
|
// If the table hasn't been resize, the colgroup 48px width values will gracefully scale down.
|
|
@@ -120,15 +123,17 @@ export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEna
|
|
|
120
123
|
syncStickyRowToTable(tableRef);
|
|
121
124
|
return;
|
|
122
125
|
}
|
|
123
|
-
const
|
|
124
|
-
|
|
126
|
+
const shouldUseIncreasedScalingPercent = isTableScalingEnabledWithLockButton && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
127
|
+
const resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, false,
|
|
128
|
+
// Here isTableScalingEnabled = false
|
|
129
|
+
shouldUseIncreasedScalingPercent) : scale(tableRef, options, domAtPos, false, shouldUseIncreasedScalingPercent);
|
|
125
130
|
if (resizeState) {
|
|
126
|
-
updateColgroup(resizeState, tableRef, node, false);
|
|
131
|
+
updateColgroup(resizeState, tableRef, node, false, shouldUseIncreasedScalingPercent);
|
|
127
132
|
}
|
|
128
133
|
};
|
|
129
134
|
|
|
130
135
|
// Scale the table to meet new requirements (col, layout change etc)
|
|
131
|
-
export const scaleTable = (tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable = false) => tr => {
|
|
136
|
+
export const scaleTable = (tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable = false, shouldUseIncreasedScalingPercent = false) => tr => {
|
|
132
137
|
if (!tableRef) {
|
|
133
138
|
return tr;
|
|
134
139
|
}
|
|
@@ -143,16 +148,16 @@ export const scaleTable = (tableRef, options, domAtPos, isTableScalingEnabledOnC
|
|
|
143
148
|
// If its not a re-sized table, we still want to re-create cols
|
|
144
149
|
// To force reflow of columns upon delete.
|
|
145
150
|
if (!isTableScalingEnabledOnCurrentTable) {
|
|
146
|
-
insertColgroupFromNode(tableRef, node);
|
|
151
|
+
insertColgroupFromNode(tableRef, node, false, undefined, shouldUseIncreasedScalingPercent);
|
|
147
152
|
}
|
|
148
153
|
tr.setMeta('scrollIntoView', false);
|
|
149
154
|
return tr;
|
|
150
155
|
}
|
|
151
156
|
let resizeState;
|
|
152
157
|
if (parentWidth) {
|
|
153
|
-
resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos, isTableScalingEnabledOnCurrentTable);
|
|
158
|
+
resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos, isTableScalingEnabledOnCurrentTable, shouldUseIncreasedScalingPercent);
|
|
154
159
|
} else {
|
|
155
|
-
resizeState = scale(tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable);
|
|
160
|
+
resizeState = scale(tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable, shouldUseIncreasedScalingPercent);
|
|
156
161
|
}
|
|
157
162
|
if (resizeState) {
|
|
158
163
|
tr = updateColumnWidths(resizeState, node, start)(tr);
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -5,6 +5,7 @@ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
|
5
5
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
7
7
|
import commonMessages, { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
8
|
+
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
8
9
|
import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
9
10
|
import { closestElement, getChildrenInfo, getNodeName, isReferencedSource } from '@atlaskit/editor-common/utils';
|
|
10
11
|
import { findParentDomRefOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -99,7 +100,7 @@ export const getToolbarMenuConfig = (config, state, {
|
|
|
99
100
|
// with native widgets. It's enabled via a plugin config.
|
|
100
101
|
export const getToolbarCellOptionsConfig = (editorState, editorView, initialSelectionRect, {
|
|
101
102
|
formatMessage
|
|
102
|
-
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => {
|
|
103
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) => {
|
|
103
104
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
104
105
|
const {
|
|
105
106
|
top,
|
|
@@ -117,7 +118,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
117
118
|
const selectionRect = getClosestSelectionRect(state);
|
|
118
119
|
const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
119
120
|
if (index) {
|
|
120
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
121
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
121
122
|
}
|
|
122
123
|
return true;
|
|
123
124
|
},
|
|
@@ -153,7 +154,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
153
154
|
onClick: (state, dispatch, view) => {
|
|
154
155
|
const selectionRect = getClosestSelectionRect(state);
|
|
155
156
|
if (selectionRect) {
|
|
156
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
|
|
157
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
|
|
157
158
|
}
|
|
158
159
|
return true;
|
|
159
160
|
},
|
|
@@ -304,7 +305,7 @@ export const getClosestSelectionOrTableRect = state => {
|
|
|
304
305
|
const tableRect = new Rect(0, 0, map.width, map.height);
|
|
305
306
|
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
|
|
306
307
|
};
|
|
307
|
-
export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) => config => (state, intl) => {
|
|
308
|
+
export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options, shouldUseIncreasedScalingPercent = false) => config => (state, intl) => {
|
|
308
309
|
const tableObject = findTable(state.selection);
|
|
309
310
|
const pluginState = getPluginState(state);
|
|
310
311
|
const resizeState = tableResizingPluginKey.getState(state);
|
|
@@ -319,7 +320,7 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
319
320
|
const isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
|
|
320
321
|
alignmentMenu = options !== null && options !== void 0 && options.isTableAlignmentEnabled && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth) : [];
|
|
321
322
|
let cellItems;
|
|
322
|
-
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled);
|
|
323
|
+
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, shouldUseIncreasedScalingPercent);
|
|
323
324
|
let columnSettingsItems;
|
|
324
325
|
columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) : [];
|
|
325
326
|
const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView);
|
|
@@ -413,12 +414,12 @@ const separator = hidden => {
|
|
|
413
414
|
};
|
|
414
415
|
const getCellItems = (state, view, {
|
|
415
416
|
formatMessage
|
|
416
|
-
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => {
|
|
417
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) => {
|
|
417
418
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
418
419
|
if (initialSelectionRect) {
|
|
419
420
|
const cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
420
421
|
formatMessage
|
|
421
|
-
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled);
|
|
422
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent);
|
|
422
423
|
return [cellOptions, separator(cellOptions.hidden)];
|
|
423
424
|
}
|
|
424
425
|
return [];
|
|
@@ -629,7 +630,8 @@ export const getSelectedAlignmentIcon = (alignmentIcons, selectedNode) => {
|
|
|
629
630
|
};
|
|
630
631
|
export const isLayoutOptionDisabled = (selectedNode, getEditorContainerWidth) => {
|
|
631
632
|
const lineLength = getEditorContainerWidth().lineLength;
|
|
632
|
-
|
|
633
|
+
const tableWidth = getTableContainerWidth(selectedNode);
|
|
634
|
+
if (selectedNode && lineLength && tableWidth > lineLength) {
|
|
633
635
|
return true;
|
|
634
636
|
}
|
|
635
637
|
return false;
|
|
@@ -88,7 +88,7 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
|
88
88
|
* @param view
|
|
89
89
|
* @returns Updated transaction with rescaled columns for a given table
|
|
90
90
|
*/
|
|
91
|
-
export const rescaleColumns = (isTableScalingEnabled = false) => (table, view) => tr => {
|
|
91
|
+
export const rescaleColumns = (isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) => (table, view) => tr => {
|
|
92
92
|
if (!view) {
|
|
93
93
|
return tr;
|
|
94
94
|
}
|
|
@@ -170,7 +170,8 @@ export const rescaleColumns = (isTableScalingEnabled = false) => (table, view) =
|
|
|
170
170
|
tableRef,
|
|
171
171
|
domAtPos,
|
|
172
172
|
maxSize: previousTableInfo.possibleMaxWidth,
|
|
173
|
-
isTableScalingEnabled: shouldScale
|
|
173
|
+
isTableScalingEnabled: shouldScale,
|
|
174
|
+
shouldUseIncreasedScalingPercent
|
|
174
175
|
});
|
|
175
176
|
|
|
176
177
|
// Two scenarios that require scaling:
|
|
@@ -192,7 +192,7 @@ function fixRowSpans(table) {
|
|
|
192
192
|
}
|
|
193
193
|
return table.type.createChecked(table.attrs, rows, table.marks);
|
|
194
194
|
}
|
|
195
|
-
export const deleteColumns = (rect, allowCustomStep, view, isTableScalingEnabled = false) => tr => {
|
|
195
|
+
export const deleteColumns = (rect, allowCustomStep, view, isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) => tr => {
|
|
196
196
|
let updatedTr = tr;
|
|
197
197
|
updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
198
198
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.DELETED_COLUMN
|
|
@@ -204,7 +204,7 @@ export const deleteColumns = (rect, allowCustomStep, view, isTableScalingEnabled
|
|
|
204
204
|
}
|
|
205
205
|
const table = findTable(updatedTr.selection);
|
|
206
206
|
if (table) {
|
|
207
|
-
updatedTr = rescaleColumns(isTableScalingEnabled)(table, view)(updatedTr);
|
|
207
|
+
updatedTr = rescaleColumns(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(table, view)(updatedTr);
|
|
208
208
|
}
|
|
209
209
|
return updatedTr;
|
|
210
210
|
};
|
|
@@ -18,6 +18,7 @@ import { splitCell } from '@atlaskit/editor-tables/utils';
|
|
|
18
18
|
import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
|
|
19
19
|
import EditorBackgroundColorIcon from '@atlaskit/icon/glyph/editor/background-color';
|
|
20
20
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
21
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
21
22
|
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, toggleContextualMenu } from '../../commands';
|
|
22
23
|
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics } from '../../commands-with-analytics';
|
|
23
24
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
@@ -419,6 +420,7 @@ export class ContextualMenu extends Component {
|
|
|
419
420
|
const {
|
|
420
421
|
tableDuplicateCellColouring = false
|
|
421
422
|
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
423
|
+
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
422
424
|
switch (item.value.name) {
|
|
423
425
|
case 'sort_column_desc':
|
|
424
426
|
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect.left, SortOrder.DESC)(state, dispatch);
|
|
@@ -448,7 +450,7 @@ export class ContextualMenu extends Component {
|
|
|
448
450
|
this.toggleOpen();
|
|
449
451
|
break;
|
|
450
452
|
case 'insert_column':
|
|
451
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
453
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring, shouldUseIncreasedScalingPercent)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
452
454
|
this.toggleOpen();
|
|
453
455
|
break;
|
|
454
456
|
case 'insert_row':
|
|
@@ -459,7 +461,7 @@ export class ContextualMenu extends Component {
|
|
|
459
461
|
this.toggleOpen();
|
|
460
462
|
break;
|
|
461
463
|
case 'delete_column':
|
|
462
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch, editorView);
|
|
464
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch, editorView);
|
|
463
465
|
this.toggleOpen();
|
|
464
466
|
break;
|
|
465
467
|
case 'delete_row':
|
|
@@ -177,7 +177,8 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
177
177
|
scrollableElement,
|
|
178
178
|
boundariesElement,
|
|
179
179
|
isTableScalingEnabled,
|
|
180
|
-
tableDuplicateCellColouring
|
|
180
|
+
tableDuplicateCellColouring,
|
|
181
|
+
shouldUseIncreasedScalingPercent
|
|
181
182
|
}) => {
|
|
182
183
|
var _pluginConfig$allowBa;
|
|
183
184
|
const {
|
|
@@ -205,7 +206,7 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
205
206
|
hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
206
207
|
}
|
|
207
208
|
const allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
208
|
-
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled, tableDuplicateCellColouring);
|
|
209
|
+
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled, tableDuplicateCellColouring, shouldUseIncreasedScalingPercent);
|
|
209
210
|
const {
|
|
210
211
|
menuItems,
|
|
211
212
|
menuCallback
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
3
3
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { dragMenuDropdownWidth, tablePopupMenuFitHeight } from '../consts';
|
|
6
7
|
import DragMenu from './DragMenu';
|
|
7
8
|
const FloatingDragMenu = ({
|
|
@@ -33,6 +34,7 @@ const FloatingDragMenu = ({
|
|
|
33
34
|
const {
|
|
34
35
|
tableDuplicateCellColouring = false
|
|
35
36
|
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
37
|
+
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
36
38
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
37
39
|
alignX: direction === 'row' ? 'right' : undefined,
|
|
38
40
|
alignY: direction === 'row' ? 'start' : undefined,
|
|
@@ -67,7 +69,8 @@ const FloatingDragMenu = ({
|
|
|
67
69
|
boundariesElement: boundariesElement,
|
|
68
70
|
scrollableElement: scrollableElement,
|
|
69
71
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
70
|
-
tableDuplicateCellColouring: tableDuplicateCellColouring
|
|
72
|
+
tableDuplicateCellColouring: tableDuplicateCellColouring,
|
|
73
|
+
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent
|
|
71
74
|
}));
|
|
72
75
|
};
|
|
73
76
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -10,6 +10,7 @@ import { akEditorTableCellOnStickyHeaderZIndex } from '@atlaskit/editor-shared-s
|
|
|
10
10
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
11
11
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
12
12
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
13
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { insertColumnWithAnalytics, insertRowWithAnalytics } from '../../commands-with-analytics';
|
|
14
15
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
15
16
|
import { TableCssClassName as ClassName } from '../../types';
|
|
@@ -184,6 +185,7 @@ export class FloatingInsertButton extends React.Component {
|
|
|
184
185
|
const {
|
|
185
186
|
isTableScalingEnabled = false
|
|
186
187
|
} = getPluginState(editorView.state);
|
|
188
|
+
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
187
189
|
const {
|
|
188
190
|
tableDuplicateCellColouring = false
|
|
189
191
|
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
@@ -191,7 +193,7 @@ export class FloatingInsertButton extends React.Component {
|
|
|
191
193
|
state,
|
|
192
194
|
dispatch
|
|
193
195
|
} = editorView;
|
|
194
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
196
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring, shouldUseIncreasedScalingPercent)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
199
|
}
|
|
@@ -65,7 +65,7 @@ const defaultSelectionRect = {
|
|
|
65
65
|
right: 0,
|
|
66
66
|
bottom: 0
|
|
67
67
|
};
|
|
68
|
-
export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired, isTableScalingEnabled = false, tableDuplicateCellColouring = false) => {
|
|
68
|
+
export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired, isTableScalingEnabled = false, tableDuplicateCellColouring = false, shouldUseIncreasedScalingPercent = false) => {
|
|
69
69
|
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
70
70
|
const addOptions = direction === 'row' ? [{
|
|
71
71
|
label: 'above',
|
|
@@ -145,7 +145,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
145
145
|
moveCursorToInsertedRow: true
|
|
146
146
|
})(state, dispatch);
|
|
147
147
|
} else {
|
|
148
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring)(INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
148
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring, shouldUseIncreasedScalingPercent)(INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
149
149
|
}
|
|
150
150
|
return true;
|
|
151
151
|
},
|
|
@@ -205,9 +205,11 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(_ref4) {
|
|
|
205
205
|
getEditorContainerWidth: getEditorContainerWidth
|
|
206
206
|
});
|
|
207
207
|
var isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
208
|
-
|
|
208
|
+
var isTableScalingEnabledWithLockButton = isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
|
|
209
|
+
if (isTableScalingEnabledWithLockButton) {
|
|
209
210
|
isTableScalingEnabledOnCurrentTable = originalTable.attrs.displayMode !== 'fixed';
|
|
210
211
|
}
|
|
212
|
+
var shouldUseIncreasedScalingPercent = isTableScalingEnabledWithLockButton && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
211
213
|
var initialResizeState = getResizeState({
|
|
212
214
|
minWidth: tableCellMinWidth,
|
|
213
215
|
maxSize: maxSize,
|
|
@@ -215,14 +217,15 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(_ref4) {
|
|
|
215
217
|
tableRef: dom,
|
|
216
218
|
start: tableStartPosition,
|
|
217
219
|
domAtPos: domAtPos,
|
|
218
|
-
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable
|
|
220
|
+
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable,
|
|
221
|
+
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent
|
|
219
222
|
});
|
|
220
223
|
updateControls()(state);
|
|
221
224
|
var selectionRect = getSelectionRect(state.selection);
|
|
222
225
|
var selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
223
226
|
// only selected (or selected - 1) columns should be distributed
|
|
224
227
|
var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
225
|
-
var newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, isTableScalingEnabled);
|
|
228
|
+
var newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, isTableScalingEnabled, shouldUseIncreasedScalingPercent);
|
|
226
229
|
customTr = updateColumnWidths(newResizeState, originalTable, tableStartPosition)(customTr);
|
|
227
230
|
if (dispatch) {
|
|
228
231
|
dispatch(customTr);
|
|
@@ -2,8 +2,9 @@ import { deleteColumns } from '../transforms/delete-columns';
|
|
|
2
2
|
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
3
3
|
export var deleteColumnsCommand = function deleteColumnsCommand(rect) {
|
|
4
4
|
var isTableScalingEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
5
|
+
var shouldUseIncreasedScalingPercent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
5
6
|
return function (state, dispatch, view) {
|
|
6
|
-
var tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view, isTableScalingEnabled)(state.tr);
|
|
7
|
+
var tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view, isTableScalingEnabled, shouldUseIncreasedScalingPercent)(state.tr);
|
|
7
8
|
if (dispatch) {
|
|
8
9
|
dispatch(tr);
|
|
9
10
|
return true;
|
|
@@ -22,6 +22,7 @@ function addColumnAtCustomStep(column) {
|
|
|
22
22
|
export function addColumnAt() {
|
|
23
23
|
var isTableScalingEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
24
24
|
var isCellBackgroundDuplicated = arguments.length > 1 ? arguments[1] : undefined;
|
|
25
|
+
var shouldUseIncreasedScalingPercent = arguments.length > 2 ? arguments[2] : undefined;
|
|
25
26
|
return function (column) {
|
|
26
27
|
var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
27
28
|
var view = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -35,7 +36,7 @@ export function addColumnAt() {
|
|
|
35
36
|
var table = findTable(updatedTr.selection);
|
|
36
37
|
if (table) {
|
|
37
38
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
38
|
-
updatedTr = rescaleColumns(isTableScalingEnabled)(table, view)(updatedTr);
|
|
39
|
+
updatedTr = rescaleColumns(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(table, view)(updatedTr);
|
|
39
40
|
}
|
|
40
41
|
if (view) {
|
|
41
42
|
updatedTr = updateRowOrColumnMovedTransform({
|
|
@@ -54,6 +55,7 @@ export function addColumnAt() {
|
|
|
54
55
|
// Command to add a column before the column with the selection.
|
|
55
56
|
export var addColumnBefore = function addColumnBefore() {
|
|
56
57
|
var isTableScalingEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
58
|
+
var shouldUseIncreasedScalingPercent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
57
59
|
return function (state, dispatch, view) {
|
|
58
60
|
var table = findTable(state.selection);
|
|
59
61
|
if (!table) {
|
|
@@ -61,7 +63,7 @@ export var addColumnBefore = function addColumnBefore() {
|
|
|
61
63
|
}
|
|
62
64
|
if (dispatch) {
|
|
63
65
|
var rect = selectedRect(state);
|
|
64
|
-
dispatch(addColumnAt(isTableScalingEnabled)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
66
|
+
dispatch(addColumnAt(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
65
67
|
}
|
|
66
68
|
return true;
|
|
67
69
|
};
|
|
@@ -69,7 +71,7 @@ export var addColumnBefore = function addColumnBefore() {
|
|
|
69
71
|
|
|
70
72
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
71
73
|
// Command to add a column after the column with the selection.
|
|
72
|
-
export var addColumnAfter = function addColumnAfter(isTableScalingEnabled) {
|
|
74
|
+
export var addColumnAfter = function addColumnAfter(isTableScalingEnabled, shouldUseIncreasedScalingPercent) {
|
|
73
75
|
return function (state, dispatch, view) {
|
|
74
76
|
var table = findTable(state.selection);
|
|
75
77
|
if (!table) {
|
|
@@ -77,7 +79,7 @@ export var addColumnAfter = function addColumnAfter(isTableScalingEnabled) {
|
|
|
77
79
|
}
|
|
78
80
|
if (dispatch) {
|
|
79
81
|
var rect = selectedRect(state);
|
|
80
|
-
dispatch(addColumnAt(isTableScalingEnabled)(rect.right, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
82
|
+
dispatch(addColumnAt(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(rect.right, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
81
83
|
}
|
|
82
84
|
return true;
|
|
83
85
|
};
|
|
@@ -85,9 +87,10 @@ export var addColumnAfter = function addColumnAfter(isTableScalingEnabled) {
|
|
|
85
87
|
export var insertColumn = function insertColumn() {
|
|
86
88
|
var isTableScalingEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
87
89
|
var isCellBackgroundDuplicated = arguments.length > 1 ? arguments[1] : undefined;
|
|
90
|
+
var shouldUseIncreasedScalingPercent = arguments.length > 2 ? arguments[2] : undefined;
|
|
88
91
|
return function (column) {
|
|
89
92
|
return function (state, dispatch, view) {
|
|
90
|
-
var tr = addColumnAt(isTableScalingEnabled, isCellBackgroundDuplicated)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
93
|
+
var tr = addColumnAt(isTableScalingEnabled, isCellBackgroundDuplicated, shouldUseIncreasedScalingPercent)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
91
94
|
var table = findTable(tr.selection);
|
|
92
95
|
if (!table) {
|
|
93
96
|
return false;
|
|
@@ -3,6 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
5
|
import isEqual from 'lodash/isEqual';
|
|
6
|
+
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
6
7
|
import { closestElement, isParagraph, isTextSelection, mapSlice } from '@atlaskit/editor-common/utils';
|
|
7
8
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
9
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
@@ -590,6 +591,13 @@ export var setTableAlignment = function setTableAlignment(newAlignment) {
|
|
|
590
591
|
var nextTableAttrs = _objectSpread(_objectSpread({}, tableObject.node.attrs), {}, {
|
|
591
592
|
layout: newAlignment
|
|
592
593
|
});
|
|
594
|
+
|
|
595
|
+
// table uses old breakout values in layout attribute to determine width
|
|
596
|
+
// but that information is lost when alignment changes, so we need to ensure we retain that info
|
|
597
|
+
if (!tableObject.node.attrs.width) {
|
|
598
|
+
var tableWidth = getTableContainerWidth(tableObject.node);
|
|
599
|
+
nextTableAttrs.width = tableWidth;
|
|
600
|
+
}
|
|
593
601
|
tr.setNodeMarkup(tableObject.pos, undefined, nextTableAttrs).setMeta('scrollIntoView', false);
|
|
594
602
|
return tr;
|
|
595
603
|
};
|
|
@@ -597,9 +605,17 @@ export var setTableAlignment = function setTableAlignment(newAlignment) {
|
|
|
597
605
|
export var setTableAlignmentWithTableContentWithPos = function setTableAlignmentWithTableContentWithPos(newAlignment, tableNodeWithPos) {
|
|
598
606
|
return function (_ref3) {
|
|
599
607
|
var tr = _ref3.tr;
|
|
600
|
-
var
|
|
608
|
+
var table = tableNodeWithPos.node;
|
|
609
|
+
var nextTableAttrs = _objectSpread(_objectSpread({}, table.attrs), {}, {
|
|
601
610
|
layout: newAlignment
|
|
602
611
|
});
|
|
612
|
+
|
|
613
|
+
// table uses old breakout values in layout attribute to determine width
|
|
614
|
+
// but that information is lost when alignment changes, so we need to ensure we retain that info
|
|
615
|
+
if (!table.attrs.width) {
|
|
616
|
+
var tableWidth = getTableContainerWidth(table);
|
|
617
|
+
nextTableAttrs.width = tableWidth;
|
|
618
|
+
}
|
|
603
619
|
tr.setNodeMarkup(tableNodeWithPos.pos, undefined, nextTableAttrs).setMeta('scrollIntoView', false);
|
|
604
620
|
return tr;
|
|
605
621
|
};
|
|
@@ -221,6 +221,7 @@ export var changeColumnWidthByStepWithAnalytics = function changeColumnWidthBySt
|
|
|
221
221
|
export var insertColumnWithAnalytics = function insertColumnWithAnalytics(editorAnalyticsAPI) {
|
|
222
222
|
var isTableScalingEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
223
223
|
var isCellbackgroundDuplicated = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
224
|
+
var shouldUseIncreasedScalingPercent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
224
225
|
return function (inputMethod, position) {
|
|
225
226
|
return withEditorAnalyticsAPI(function (state) {
|
|
226
227
|
var _getSelectedTableInfo3 = getSelectedTableInfo(state.selection),
|
|
@@ -238,7 +239,7 @@ export var insertColumnWithAnalytics = function insertColumnWithAnalytics(editor
|
|
|
238
239
|
},
|
|
239
240
|
eventType: EVENT_TYPE.TRACK
|
|
240
241
|
};
|
|
241
|
-
})(editorAnalyticsAPI)(insertColumn(isTableScalingEnabled, isCellbackgroundDuplicated)(position));
|
|
242
|
+
})(editorAnalyticsAPI)(insertColumn(isTableScalingEnabled, isCellbackgroundDuplicated, shouldUseIncreasedScalingPercent)(position));
|
|
242
243
|
};
|
|
243
244
|
};
|
|
244
245
|
export var deleteRowsWithAnalytics = function deleteRowsWithAnalytics(editorAnalyticsAPI) {
|
|
@@ -271,6 +272,7 @@ export var deleteRowsWithAnalytics = function deleteRowsWithAnalytics(editorAnal
|
|
|
271
272
|
};
|
|
272
273
|
export var deleteColumnsWithAnalytics = function deleteColumnsWithAnalytics(editorAnalyticsAPI) {
|
|
273
274
|
var isTableScalingEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
275
|
+
var shouldUseIncreasedScalingPercent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
274
276
|
return function (inputMethod, rect) {
|
|
275
277
|
return withEditorAnalyticsAPI(function (_ref6) {
|
|
276
278
|
var selection = _ref6.selection;
|
|
@@ -290,10 +292,10 @@ export var deleteColumnsWithAnalytics = function deleteColumnsWithAnalytics(edit
|
|
|
290
292
|
},
|
|
291
293
|
eventType: EVENT_TYPE.TRACK
|
|
292
294
|
};
|
|
293
|
-
})(editorAnalyticsAPI)(deleteColumnsCommand(rect, isTableScalingEnabled));
|
|
295
|
+
})(editorAnalyticsAPI)(deleteColumnsCommand(rect, isTableScalingEnabled, shouldUseIncreasedScalingPercent));
|
|
294
296
|
};
|
|
295
297
|
};
|
|
296
|
-
export var deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = function deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI) {
|
|
298
|
+
export var deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = function deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent) {
|
|
297
299
|
return function (state, dispatch) {
|
|
298
300
|
var selection = state.selection;
|
|
299
301
|
var isCellSelection = selection instanceof CellSelection;
|
|
@@ -311,7 +313,7 @@ export var deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = function delete
|
|
|
311
313
|
var isHeaderRowRequired = pluginConfig.isHeaderRowRequired || false;
|
|
312
314
|
return deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, rect, isHeaderRowRequired)(state, dispatch);
|
|
313
315
|
} else if (selectionType === 'column') {
|
|
314
|
-
return deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, rect)(state, dispatch);
|
|
316
|
+
return deleteColumnsWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.SHORTCUT, rect)(state, dispatch);
|
|
315
317
|
} else {
|
|
316
318
|
return false;
|
|
317
319
|
}
|
|
@@ -345,6 +345,7 @@ export function handleTripleClick(view, pos) {
|
|
|
345
345
|
}
|
|
346
346
|
export var handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI, editorView) {
|
|
347
347
|
var isTableScalingEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
348
|
+
var shouldUseIncreasedScalingPercent = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
348
349
|
var oldSelection = oldState.tr.selection;
|
|
349
350
|
var tr = newState.tr;
|
|
350
351
|
if (oldSelection instanceof CellSelection) {
|
|
@@ -387,7 +388,7 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
|
|
|
387
388
|
isHeaderRowRequired = _getPluginState9.pluginConfig.isHeaderRowRequired;
|
|
388
389
|
tr = deleteRows(rect, isHeaderRowRequired)(tr);
|
|
389
390
|
} else if (tr.selection.isColSelection()) {
|
|
390
|
-
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView, isTableScalingEnabled)(tr);
|
|
391
|
+
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView, isTableScalingEnabled, shouldUseIncreasedScalingPercent)(tr);
|
|
391
392
|
}
|
|
392
393
|
}
|
|
393
394
|
}
|