@atlaskit/editor-plugin-table 7.5.4 → 7.5.5
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 +7 -0
- package/dist/cjs/commands/column-resize.js +3 -3
- package/dist/cjs/commands/delete.js +2 -2
- package/dist/cjs/commands/insert.js +15 -15
- package/dist/cjs/commands-with-analytics.js +7 -7
- package/dist/cjs/event-handlers.js +2 -2
- package/dist/cjs/nodeviews/TableComponent.js +46 -59
- package/dist/cjs/nodeviews/TableContainer.js +5 -5
- package/dist/cjs/nodeviews/TableResizer.js +12 -12
- package/dist/cjs/nodeviews/table.js +9 -9
- package/dist/cjs/plugin.js +58 -56
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/cjs/pm-plugins/keymap.js +6 -8
- package/dist/cjs/pm-plugins/main.js +4 -6
- package/dist/cjs/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +11 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/cjs/pm-plugins/table-width.js +6 -2
- package/dist/cjs/toolbar.js +21 -21
- package/dist/cjs/transforms/column-width.js +4 -4
- package/dist/cjs/transforms/delete-columns.js +2 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +6 -6
- package/dist/cjs/ui/FloatingInsertButton/index.js +6 -7
- package/dist/cjs/utils/create.js +2 -5
- package/dist/cjs/utils/drag-menu.js +4 -4
- package/dist/es2019/commands/column-resize.js +3 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +12 -12
- package/dist/es2019/commands-with-analytics.js +6 -6
- package/dist/es2019/event-handlers.js +2 -2
- package/dist/es2019/nodeviews/TableComponent.js +25 -36
- package/dist/es2019/nodeviews/TableContainer.js +5 -5
- package/dist/es2019/nodeviews/TableResizer.js +12 -12
- package/dist/es2019/nodeviews/table.js +9 -9
- package/dist/es2019/plugin.js +17 -17
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +6 -6
- package/dist/es2019/pm-plugins/keymap.js +5 -8
- package/dist/es2019/pm-plugins/main.js +3 -5
- package/dist/es2019/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +5 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +3 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -13
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/es2019/pm-plugins/table-width.js +6 -2
- package/dist/es2019/toolbar.js +15 -15
- package/dist/es2019/transforms/column-width.js +5 -5
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +9 -12
- package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +5 -5
- package/dist/es2019/ui/FloatingInsertButton/index.js +5 -6
- package/dist/es2019/utils/create.js +2 -5
- package/dist/es2019/utils/drag-menu.js +4 -4
- package/dist/esm/commands/column-resize.js +3 -3
- package/dist/esm/commands/delete.js +2 -2
- package/dist/esm/commands/insert.js +15 -15
- package/dist/esm/commands-with-analytics.js +7 -7
- package/dist/esm/event-handlers.js +2 -2
- package/dist/esm/nodeviews/TableComponent.js +45 -58
- package/dist/esm/nodeviews/TableContainer.js +5 -5
- package/dist/esm/nodeviews/TableResizer.js +12 -12
- package/dist/esm/nodeviews/table.js +9 -9
- package/dist/esm/plugin.js +58 -56
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/esm/pm-plugins/keymap.js +6 -8
- package/dist/esm/pm-plugins/main.js +4 -6
- package/dist/esm/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +4 -3
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -14
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/esm/pm-plugins/table-width.js +6 -2
- package/dist/esm/toolbar.js +21 -21
- package/dist/esm/transforms/column-width.js +5 -5
- package/dist/esm/transforms/delete-columns.js +2 -2
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/esm/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +6 -6
- package/dist/esm/ui/FloatingInsertButton/index.js +6 -7
- package/dist/esm/utils/create.js +2 -5
- package/dist/esm/utils/drag-menu.js +4 -4
- 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 +7 -7
- package/dist/types/commands-with-analytics.d.ts +3 -3
- package/dist/types/event-handlers.d.ts +1 -1
- package/dist/types/nodeviews/TableComponent.d.ts +2 -3
- package/dist/types/nodeviews/TableContainer.d.ts +4 -4
- package/dist/types/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- 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 +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types/pm-plugins/table-width.d.ts +1 -2
- 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/types.d.ts +1 -0
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types/utils/create.d.ts +1 -2
- 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 +7 -7
- 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/TableComponent.d.ts +2 -3
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -4
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- 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 +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -2
- 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/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types-ts4.5/utils/create.d.ts +1 -2
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +2 -2
- package/src/commands/column-resize.ts +4 -3
- package/src/commands/delete.ts +2 -2
- package/src/commands/insert.ts +15 -27
- package/src/commands-with-analytics.ts +6 -9
- package/src/event-handlers.ts +2 -2
- package/src/nodeviews/TableComponent.tsx +31 -46
- package/src/nodeviews/TableContainer.tsx +7 -7
- package/src/nodeviews/TableResizer.tsx +14 -14
- package/src/nodeviews/table.tsx +6 -5
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +12 -28
- package/src/pm-plugins/drag-and-drop/plugin.ts +10 -15
- package/src/pm-plugins/keymap.ts +6 -13
- package/src/pm-plugins/main.ts +3 -3
- package/src/pm-plugins/sticky-headers/plugin.ts +2 -11
- package/src/pm-plugins/table-resizing/event-handlers.ts +6 -4
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +1 -1
- package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +5 -2
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -13
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +14 -14
- package/src/pm-plugins/table-width.ts +4 -6
- package/src/toolbar.tsx +16 -19
- package/src/transforms/column-width.ts +7 -6
- package/src/transforms/delete-columns.ts +2 -2
- package/src/types.ts +1 -0
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -16
- package/src/ui/FloatingContextualMenu/index.tsx +0 -2
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -3
- package/src/ui/FloatingDragMenu/index.tsx +4 -8
- package/src/ui/FloatingInsertButton/index.tsx +11 -22
- package/src/utils/create.ts +2 -5
- package/src/utils/drag-menu.ts +7 -12
package/dist/es2019/toolbar.js
CHANGED
|
@@ -80,7 +80,7 @@ export const getToolbarMenuConfig = (config, state, {
|
|
|
80
80
|
// with native widgets. It's enabled via a plugin config.
|
|
81
81
|
export const getToolbarCellOptionsConfig = (editorState, editorView, initialSelectionRect, {
|
|
82
82
|
formatMessage
|
|
83
|
-
}, getEditorContainerWidth, editorAnalyticsAPI,
|
|
83
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => {
|
|
84
84
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
85
85
|
const {
|
|
86
86
|
top,
|
|
@@ -98,7 +98,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
98
98
|
const selectionRect = getClosestSelectionRect(state);
|
|
99
99
|
const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
100
100
|
if (index) {
|
|
101
|
-
insertColumnWithAnalytics(
|
|
101
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
102
102
|
}
|
|
103
103
|
return true;
|
|
104
104
|
},
|
|
@@ -177,7 +177,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
177
177
|
}];
|
|
178
178
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
|
|
179
179
|
var _newResizeStateWithAn;
|
|
180
|
-
const newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth,
|
|
180
|
+
const newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled) : undefined;
|
|
181
181
|
const wouldChange = (_newResizeStateWithAn = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn !== void 0 ? _newResizeStateWithAn : false;
|
|
182
182
|
const distributeColumnWidths = (state, dispatch) => {
|
|
183
183
|
if (newResizeStateWithAnalytics) {
|
|
@@ -297,12 +297,12 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
297
297
|
const nodeType = state.schema.nodes.table;
|
|
298
298
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
299
299
|
const {
|
|
300
|
-
|
|
301
|
-
} =
|
|
300
|
+
isTableScalingEnabled = false
|
|
301
|
+
} = getPluginState(state);
|
|
302
302
|
let cellItems;
|
|
303
|
-
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(
|
|
303
|
+
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled);
|
|
304
304
|
let columnSettingsItems;
|
|
305
|
-
columnSettingsItems = pluginState.isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI,
|
|
305
|
+
columnSettingsItems = pluginState.isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled) : [];
|
|
306
306
|
const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
|
|
307
307
|
|
|
308
308
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -391,24 +391,24 @@ const separator = hidden => {
|
|
|
391
391
|
hidden: hidden
|
|
392
392
|
};
|
|
393
393
|
};
|
|
394
|
-
const getCellItems = (
|
|
394
|
+
const getCellItems = (state, view, {
|
|
395
395
|
formatMessage
|
|
396
|
-
}, getEditorContainerWidth, editorAnalyticsAPI,
|
|
396
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => {
|
|
397
397
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
398
398
|
if (initialSelectionRect) {
|
|
399
399
|
const cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
400
400
|
formatMessage
|
|
401
|
-
}, getEditorContainerWidth, editorAnalyticsAPI,
|
|
401
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled);
|
|
402
402
|
return [cellOptions, separator(cellOptions.hidden)];
|
|
403
403
|
}
|
|
404
404
|
return [];
|
|
405
405
|
};
|
|
406
|
-
export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI,
|
|
406
|
+
export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => (state, dispatch, editorView) => {
|
|
407
407
|
const selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
408
408
|
if (!editorView || !selectionOrTableRect) {
|
|
409
409
|
return false;
|
|
410
410
|
}
|
|
411
|
-
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth,
|
|
411
|
+
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
412
412
|
if (newResizeStateWithAnalytics) {
|
|
413
413
|
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
414
414
|
return true;
|
|
@@ -420,14 +420,14 @@ export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI,
|
|
|
420
420
|
// fixed column button should be in this function call in the future
|
|
421
421
|
const getColumnSettingItems = (editorState, editorView, {
|
|
422
422
|
formatMessage
|
|
423
|
-
}, getEditorContainerWidth, editorAnalyticsAPI,
|
|
423
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => {
|
|
424
424
|
var _newResizeStateWithAn2, _pluginState$pluginCo3;
|
|
425
425
|
const pluginState = getPluginState(editorState);
|
|
426
426
|
const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
|
|
427
427
|
if (!selectionOrTableRect || !editorView) {
|
|
428
428
|
return [];
|
|
429
429
|
}
|
|
430
|
-
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth,
|
|
430
|
+
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
431
431
|
const wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
|
|
432
432
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
|
|
433
433
|
return [{
|
|
@@ -435,7 +435,7 @@ const getColumnSettingItems = (editorState, editorView, {
|
|
|
435
435
|
type: 'button',
|
|
436
436
|
title: formatMessage(messages.distributeColumns),
|
|
437
437
|
icon: DistributeColumnIcon,
|
|
438
|
-
onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI,
|
|
438
|
+
onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled)(state, dispatch, view),
|
|
439
439
|
disabled: !wouldChange
|
|
440
440
|
}, {
|
|
441
441
|
type: 'separator'
|
|
@@ -2,7 +2,7 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
2
2
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
3
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
4
4
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
|
-
import {
|
|
5
|
+
import { getTableContainerElementWidth, getTableElementWidth, hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
6
6
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
7
7
|
import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
8
8
|
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
@@ -85,7 +85,7 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
|
85
85
|
* @param view
|
|
86
86
|
* @returns Updated transaction with rescaled columns for a given table
|
|
87
87
|
*/
|
|
88
|
-
export const rescaleColumns = (
|
|
88
|
+
export const rescaleColumns = (isTableScalingEnabled = false) => (table, view) => tr => {
|
|
89
89
|
if (!view) {
|
|
90
90
|
return tr;
|
|
91
91
|
}
|
|
@@ -102,11 +102,11 @@ export const rescaleColumns = (tablePreserveWidth = false) => (table, view) => t
|
|
|
102
102
|
possibleMaxWidth: 0,
|
|
103
103
|
isResized
|
|
104
104
|
};
|
|
105
|
-
if (
|
|
105
|
+
if (isTableScalingEnabled) {
|
|
106
106
|
previousTableInfo = {
|
|
107
107
|
// TODO - ensure correct width is returned when table doesn't have a width value
|
|
108
108
|
width: getTableElementWidth(table.node),
|
|
109
|
-
possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width') ?
|
|
109
|
+
possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width') ? getTableContainerElementWidth(table.node) : getTableContainerElementWidth(table.node) - insertColumnButtonOffset,
|
|
110
110
|
isResized
|
|
111
111
|
};
|
|
112
112
|
} else {
|
|
@@ -162,7 +162,7 @@ export const rescaleColumns = (tablePreserveWidth = false) => (table, view) => t
|
|
|
162
162
|
tableRef,
|
|
163
163
|
domAtPos,
|
|
164
164
|
maxSize: previousTableInfo.possibleMaxWidth,
|
|
165
|
-
|
|
165
|
+
isTableScalingEnabled
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
// 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,
|
|
195
|
+
export const deleteColumns = (rect, allowCustomStep, view, isTableScalingEnabled = 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, tablePreserveWidth =
|
|
|
204
204
|
}
|
|
205
205
|
const table = findTable(updatedTr.selection);
|
|
206
206
|
if (table) {
|
|
207
|
-
updatedTr = rescaleColumns(
|
|
207
|
+
updatedTr = rescaleColumns(isTableScalingEnabled)(table, view)(updatedTr);
|
|
208
208
|
}
|
|
209
209
|
return updatedTr;
|
|
210
210
|
};
|
|
@@ -302,11 +302,11 @@ export class ContextualMenu extends Component {
|
|
|
302
302
|
}
|
|
303
303
|
} = getPluginState(editorView.state);
|
|
304
304
|
if (allowDistributeColumns && (!isDragAndDropEnabled || !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))) {
|
|
305
|
-
var
|
|
305
|
+
var _newResizeState$chang;
|
|
306
306
|
const {
|
|
307
|
-
|
|
308
|
-
} = (
|
|
309
|
-
const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth,
|
|
307
|
+
isTableScalingEnabled = false
|
|
308
|
+
} = getPluginState(editorView.state);
|
|
309
|
+
const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
310
310
|
const wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
|
|
311
311
|
return {
|
|
312
312
|
content: formatMessage(messages.distributeColumns),
|
|
@@ -400,8 +400,7 @@ export class ContextualMenu extends Component {
|
|
|
400
400
|
editorView,
|
|
401
401
|
selectionRect,
|
|
402
402
|
editorAnalyticsAPI,
|
|
403
|
-
getEditorContainerWidth
|
|
404
|
-
getEditorFeatureFlags
|
|
403
|
+
getEditorContainerWidth
|
|
405
404
|
} = this.props;
|
|
406
405
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
407
406
|
const {
|
|
@@ -409,11 +408,9 @@ export class ContextualMenu extends Component {
|
|
|
409
408
|
dispatch
|
|
410
409
|
} = editorView;
|
|
411
410
|
const {
|
|
412
|
-
targetCellPosition
|
|
411
|
+
targetCellPosition,
|
|
412
|
+
isTableScalingEnabled = false
|
|
413
413
|
} = getPluginState(state);
|
|
414
|
-
const {
|
|
415
|
-
tablePreserveWidth = false
|
|
416
|
-
} = (getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags()) || {};
|
|
417
414
|
switch (item.value.name) {
|
|
418
415
|
case 'sort_column_desc':
|
|
419
416
|
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect.left, SortOrder.DESC)(state, dispatch);
|
|
@@ -432,7 +429,7 @@ export class ContextualMenu extends Component {
|
|
|
432
429
|
this.toggleOpen();
|
|
433
430
|
break;
|
|
434
431
|
case 'distribute_columns':
|
|
435
|
-
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth,
|
|
432
|
+
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
436
433
|
if (newResizeStateWithAnalytics) {
|
|
437
434
|
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, newResizeStateWithAnalytics)(state, dispatch);
|
|
438
435
|
this.toggleOpen();
|
|
@@ -443,7 +440,7 @@ export class ContextualMenu extends Component {
|
|
|
443
440
|
this.toggleOpen();
|
|
444
441
|
break;
|
|
445
442
|
case 'insert_column':
|
|
446
|
-
insertColumnWithAnalytics(
|
|
443
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
447
444
|
this.toggleOpen();
|
|
448
445
|
break;
|
|
449
446
|
case 'insert_row':
|
|
@@ -16,8 +16,7 @@ const FloatingContextualMenu = ({
|
|
|
16
16
|
isOpen,
|
|
17
17
|
pluginConfig,
|
|
18
18
|
editorAnalyticsAPI,
|
|
19
|
-
getEditorContainerWidth
|
|
20
|
-
getEditorFeatureFlags
|
|
19
|
+
getEditorContainerWidth
|
|
21
20
|
}) => {
|
|
22
21
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
23
22
|
const {
|
|
@@ -69,8 +68,7 @@ const FloatingContextualMenu = ({
|
|
|
69
68
|
selectionRect: selectionRect,
|
|
70
69
|
boundariesElement: boundariesElement,
|
|
71
70
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
72
|
-
getEditorContainerWidth: getEditorContainerWidth
|
|
73
|
-
getEditorFeatureFlags: getEditorFeatureFlags
|
|
71
|
+
getEditorContainerWidth: getEditorContainerWidth
|
|
74
72
|
})));
|
|
75
73
|
};
|
|
76
74
|
FloatingContextualMenu.displayName = 'FloatingContextualMenu';
|
|
@@ -176,7 +176,7 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
176
176
|
mountPoint,
|
|
177
177
|
scrollableElement,
|
|
178
178
|
boundariesElement,
|
|
179
|
-
|
|
179
|
+
isTableScalingEnabled
|
|
180
180
|
}) => {
|
|
181
181
|
var _pluginConfig$allowBa;
|
|
182
182
|
const {
|
|
@@ -196,7 +196,7 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
196
196
|
const shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
197
197
|
const hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
198
198
|
const allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
199
|
-
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired,
|
|
199
|
+
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled);
|
|
200
200
|
const {
|
|
201
201
|
menuItems,
|
|
202
202
|
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 { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
5
6
|
import { dragMenuDropdownWidth, tablePopupMenuFitHeight } from '../consts';
|
|
6
7
|
import DragMenu from './DragMenu';
|
|
7
8
|
const FloatingDragMenu = ({
|
|
@@ -17,8 +18,7 @@ const FloatingDragMenu = ({
|
|
|
17
18
|
getEditorContainerWidth,
|
|
18
19
|
editorAnalyticsAPI,
|
|
19
20
|
stickyHeaders,
|
|
20
|
-
pluginConfig
|
|
21
|
-
getEditorFeatureFlags
|
|
21
|
+
pluginConfig
|
|
22
22
|
}) => {
|
|
23
23
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
24
24
|
return null;
|
|
@@ -30,8 +30,8 @@ const FloatingDragMenu = ({
|
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
32
|
const {
|
|
33
|
-
|
|
34
|
-
} =
|
|
33
|
+
isTableScalingEnabled = false
|
|
34
|
+
} = getPluginState(editorView.state);
|
|
35
35
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
36
36
|
alignX: direction === 'row' ? 'right' : undefined,
|
|
37
37
|
alignY: direction === 'row' ? 'start' : undefined,
|
|
@@ -65,7 +65,7 @@ const FloatingDragMenu = ({
|
|
|
65
65
|
mountPoint: mountPoint,
|
|
66
66
|
boundariesElement: boundariesElement,
|
|
67
67
|
scrollableElement: scrollableElement,
|
|
68
|
-
|
|
68
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
69
69
|
}));
|
|
70
70
|
};
|
|
71
71
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -11,6 +11,7 @@ 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
13
|
import { insertColumnWithAnalytics, insertRowWithAnalytics } from '../../commands-with-analytics';
|
|
14
|
+
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
14
15
|
import { TableCssClassName as ClassName } from '../../types';
|
|
15
16
|
import { checkIfNumberColumnEnabled } from '../../utils';
|
|
16
17
|
import getPopupOptions from './getPopupOptions';
|
|
@@ -173,20 +174,18 @@ export class FloatingInsertButton extends React.Component {
|
|
|
173
174
|
const {
|
|
174
175
|
editorView,
|
|
175
176
|
insertColumnButtonIndex,
|
|
176
|
-
editorAnalyticsAPI
|
|
177
|
-
getEditorContainerWidth
|
|
177
|
+
editorAnalyticsAPI
|
|
178
178
|
} = this.props;
|
|
179
179
|
if (typeof insertColumnButtonIndex !== 'undefined') {
|
|
180
|
-
var _this$props$getEditor, _this$props;
|
|
181
180
|
event.preventDefault();
|
|
182
181
|
const {
|
|
183
|
-
|
|
184
|
-
} = (
|
|
182
|
+
isTableScalingEnabled = false
|
|
183
|
+
} = getPluginState(editorView.state);
|
|
185
184
|
const {
|
|
186
185
|
state,
|
|
187
186
|
dispatch
|
|
188
187
|
} = editorView;
|
|
189
|
-
insertColumnWithAnalytics(
|
|
188
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
190
189
|
}
|
|
191
190
|
}
|
|
192
191
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { createTable } from '@atlaskit/editor-tables/utils';
|
|
2
2
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
3
|
-
export const createTableWithWidth = (
|
|
4
|
-
|
|
5
|
-
tablePreserveWidth = false
|
|
6
|
-
} = (getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags()) || {};
|
|
7
|
-
if (tablePreserveWidth && isFullWidthModeEnabled) {
|
|
3
|
+
export const createTableWithWidth = (isTableScalingEnabled, isFullWidthModeEnabled, createTableProps) => schema => {
|
|
4
|
+
if (isTableScalingEnabled && isFullWidthModeEnabled) {
|
|
8
5
|
return createTable({
|
|
9
6
|
schema,
|
|
10
7
|
tableWidth: TABLE_MAX_WIDTH,
|
|
@@ -58,7 +58,7 @@ const defaultSelectionRect = {
|
|
|
58
58
|
right: 0,
|
|
59
59
|
bottom: 0
|
|
60
60
|
};
|
|
61
|
-
export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired,
|
|
61
|
+
export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired, isTableScalingEnabled = false) => {
|
|
62
62
|
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
63
63
|
const addOptions = direction === 'row' ? [{
|
|
64
64
|
label: 'above',
|
|
@@ -138,7 +138,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
138
138
|
moveCursorToInsertedRow: true
|
|
139
139
|
})(state, dispatch);
|
|
140
140
|
} else {
|
|
141
|
-
insertColumnWithAnalytics(
|
|
141
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
142
142
|
}
|
|
143
143
|
return true;
|
|
144
144
|
},
|
|
@@ -150,7 +150,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
150
150
|
onClick: (state, dispatch) => {
|
|
151
151
|
const selectionRect = getClosestSelectionRect(state);
|
|
152
152
|
if (selectionRect) {
|
|
153
|
-
const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth,
|
|
153
|
+
const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
154
154
|
if (newResizeState) {
|
|
155
155
|
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, newResizeState)(state, dispatch);
|
|
156
156
|
return true;
|
|
@@ -176,7 +176,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
176
176
|
if (direction === 'row') {
|
|
177
177
|
deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect, !!isHeaderRowRequired)(state, dispatch);
|
|
178
178
|
} else {
|
|
179
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI,
|
|
179
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect)(state, dispatch, editorView);
|
|
180
180
|
}
|
|
181
181
|
return true;
|
|
182
182
|
},
|
|
@@ -122,7 +122,7 @@ export var activateNextResizeArea = function activateNextResizeArea(direction) {
|
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
124
|
export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize, getEditorContainerWidth) {
|
|
125
|
-
var
|
|
125
|
+
var isTableScalingEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
126
126
|
return function (state, dispatch, view) {
|
|
127
127
|
var customTr = state.tr;
|
|
128
128
|
var fakeDispatch = function fakeDispatch(tr) {
|
|
@@ -172,14 +172,14 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize,
|
|
|
172
172
|
tableRef: dom,
|
|
173
173
|
start: tableStartPosition,
|
|
174
174
|
domAtPos: domAtPos,
|
|
175
|
-
|
|
175
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
176
176
|
});
|
|
177
177
|
updateControls()(state);
|
|
178
178
|
var selectionRect = getSelectionRect(state.selection);
|
|
179
179
|
var selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
180
180
|
// only selected (or selected - 1) columns should be distributed
|
|
181
181
|
var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
182
|
-
var newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined,
|
|
182
|
+
var newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, isTableScalingEnabled);
|
|
183
183
|
customTr = updateColumnWidths(newResizeState, originalTable, tableStartPosition)(customTr);
|
|
184
184
|
if (dispatch) {
|
|
185
185
|
dispatch(customTr);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
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
|
-
var
|
|
4
|
+
var isTableScalingEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
5
5
|
return function (state, dispatch, view) {
|
|
6
|
-
var tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view,
|
|
6
|
+
var tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view, isTableScalingEnabled)(state.tr);
|
|
7
7
|
if (dispatch) {
|
|
8
8
|
dispatch(tr);
|
|
9
9
|
return true;
|
|
@@ -20,8 +20,8 @@ function addColumnAtCustomStep(column) {
|
|
|
20
20
|
return tr;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
export function addColumnAt(
|
|
24
|
-
var
|
|
23
|
+
export function addColumnAt() {
|
|
24
|
+
var isTableScalingEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
25
25
|
return function (column) {
|
|
26
26
|
var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
27
27
|
var view = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -35,7 +35,7 @@ export function addColumnAt(getEditorContainerWidth) {
|
|
|
35
35
|
var table = findTable(updatedTr.selection);
|
|
36
36
|
if (table) {
|
|
37
37
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
38
|
-
updatedTr = rescaleColumns(
|
|
38
|
+
updatedTr = rescaleColumns(isTableScalingEnabled)(table, view)(updatedTr);
|
|
39
39
|
}
|
|
40
40
|
if (getBooleanFF('platform.editor.table.analytics-plugin-moved-event') && view) {
|
|
41
41
|
updatedTr = updateRowOrColumnMovedTransform({
|
|
@@ -52,8 +52,8 @@ export function addColumnAt(getEditorContainerWidth) {
|
|
|
52
52
|
|
|
53
53
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
54
54
|
// Command to add a column before the column with the selection.
|
|
55
|
-
export var addColumnBefore = function addColumnBefore(
|
|
56
|
-
var
|
|
55
|
+
export var addColumnBefore = function addColumnBefore() {
|
|
56
|
+
var isTableScalingEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
57
57
|
return function (state, dispatch, view) {
|
|
58
58
|
var table = findTable(state.selection);
|
|
59
59
|
if (!table) {
|
|
@@ -61,7 +61,7 @@ export var addColumnBefore = function addColumnBefore(getEditorContainerWidth) {
|
|
|
61
61
|
}
|
|
62
62
|
if (dispatch) {
|
|
63
63
|
var rect = selectedRect(state);
|
|
64
|
-
dispatch(addColumnAt(
|
|
64
|
+
dispatch(addColumnAt(isTableScalingEnabled)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
65
65
|
}
|
|
66
66
|
return true;
|
|
67
67
|
};
|
|
@@ -69,7 +69,7 @@ export var addColumnBefore = function addColumnBefore(getEditorContainerWidth) {
|
|
|
69
69
|
|
|
70
70
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
71
71
|
// Command to add a column after the column with the selection.
|
|
72
|
-
export var addColumnAfter = function addColumnAfter(
|
|
72
|
+
export var addColumnAfter = function addColumnAfter(isTableScalingEnabled) {
|
|
73
73
|
return function (state, dispatch, view) {
|
|
74
74
|
var table = findTable(state.selection);
|
|
75
75
|
if (!table) {
|
|
@@ -77,16 +77,16 @@ export var addColumnAfter = function addColumnAfter(getEditorContainerWidth) {
|
|
|
77
77
|
}
|
|
78
78
|
if (dispatch) {
|
|
79
79
|
var rect = selectedRect(state);
|
|
80
|
-
dispatch(addColumnAt(
|
|
80
|
+
dispatch(addColumnAt(isTableScalingEnabled)(rect.right, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
81
81
|
}
|
|
82
82
|
return true;
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
|
-
export var insertColumn = function insertColumn(
|
|
86
|
-
var
|
|
85
|
+
export var insertColumn = function insertColumn() {
|
|
86
|
+
var isTableScalingEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
87
87
|
return function (column) {
|
|
88
88
|
return function (state, dispatch, view) {
|
|
89
|
-
var tr = addColumnAt(
|
|
89
|
+
var tr = addColumnAt(isTableScalingEnabled)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
90
90
|
var table = findTable(tr.selection);
|
|
91
91
|
if (!table) {
|
|
92
92
|
return false;
|
|
@@ -135,20 +135,20 @@ export var insertRow = function insertRow(row, moveCursorToTheNewRow) {
|
|
|
135
135
|
return true;
|
|
136
136
|
};
|
|
137
137
|
};
|
|
138
|
-
export var createTable = function createTable(
|
|
138
|
+
export var createTable = function createTable(isTableScalingEnabled, isFullWidthModeEnabled) {
|
|
139
139
|
return function (state, dispatch) {
|
|
140
|
-
var table = createTableWithWidth(
|
|
140
|
+
var table = createTableWithWidth(isTableScalingEnabled, isFullWidthModeEnabled)(state.schema);
|
|
141
141
|
if (dispatch) {
|
|
142
142
|
dispatch(safeInsert(table)(state.tr).scrollIntoView());
|
|
143
143
|
}
|
|
144
144
|
return true;
|
|
145
145
|
};
|
|
146
146
|
};
|
|
147
|
-
export var insertTableWithSize = function insertTableWithSize(isFullWidthModeEnabled,
|
|
147
|
+
export var insertTableWithSize = function insertTableWithSize(isFullWidthModeEnabled, isTableScalingEnabled, editorAnalyticsAPI) {
|
|
148
148
|
return function (rowsCount, colsCount, inputMethod) {
|
|
149
149
|
return function (_ref) {
|
|
150
150
|
var tr = _ref.tr;
|
|
151
|
-
var tableNode = createTableWithWidth(
|
|
151
|
+
var tableNode = createTableWithWidth(isTableScalingEnabled, isFullWidthModeEnabled, {
|
|
152
152
|
rowsCount: rowsCount,
|
|
153
153
|
colsCount: colsCount
|
|
154
154
|
})(tr.doc.type.schema);
|
|
@@ -184,7 +184,7 @@ export var insertRowWithAnalytics = function insertRowWithAnalytics(editorAnalyt
|
|
|
184
184
|
};
|
|
185
185
|
};
|
|
186
186
|
export var changeColumnWidthByStepWithAnalytics = function changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI) {
|
|
187
|
-
return function (stepSize, getEditorContainerWidth,
|
|
187
|
+
return function (stepSize, getEditorContainerWidth, isTableScalingEnabled, inputMethod) {
|
|
188
188
|
return withEditorAnalyticsAPI(function (state) {
|
|
189
189
|
var _getSelectedTableInfo2 = getSelectedTableInfo(state.selection),
|
|
190
190
|
table = _getSelectedTableInfo2.table,
|
|
@@ -206,11 +206,11 @@ export var changeColumnWidthByStepWithAnalytics = function changeColumnWidthBySt
|
|
|
206
206
|
totalColumnCount: totalColumnCount
|
|
207
207
|
}
|
|
208
208
|
};
|
|
209
|
-
})(editorAnalyticsAPI)(changeColumnWidthByStep(stepSize, getEditorContainerWidth,
|
|
209
|
+
})(editorAnalyticsAPI)(changeColumnWidthByStep(stepSize, getEditorContainerWidth, isTableScalingEnabled));
|
|
210
210
|
};
|
|
211
211
|
};
|
|
212
|
-
export var insertColumnWithAnalytics = function insertColumnWithAnalytics(
|
|
213
|
-
var
|
|
212
|
+
export var insertColumnWithAnalytics = function insertColumnWithAnalytics(editorAnalyticsAPI) {
|
|
213
|
+
var isTableScalingEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
214
214
|
return function (inputMethod, position) {
|
|
215
215
|
return withEditorAnalyticsAPI(function (state) {
|
|
216
216
|
var _getSelectedTableInfo3 = getSelectedTableInfo(state.selection),
|
|
@@ -228,7 +228,7 @@ export var insertColumnWithAnalytics = function insertColumnWithAnalytics(getEdi
|
|
|
228
228
|
},
|
|
229
229
|
eventType: EVENT_TYPE.TRACK
|
|
230
230
|
};
|
|
231
|
-
})(editorAnalyticsAPI)(insertColumn(
|
|
231
|
+
})(editorAnalyticsAPI)(insertColumn(isTableScalingEnabled)(position));
|
|
232
232
|
};
|
|
233
233
|
};
|
|
234
234
|
export var deleteRowsWithAnalytics = function deleteRowsWithAnalytics(editorAnalyticsAPI) {
|
|
@@ -260,7 +260,7 @@ export var deleteRowsWithAnalytics = function deleteRowsWithAnalytics(editorAnal
|
|
|
260
260
|
};
|
|
261
261
|
};
|
|
262
262
|
export var deleteColumnsWithAnalytics = function deleteColumnsWithAnalytics(editorAnalyticsAPI) {
|
|
263
|
-
var
|
|
263
|
+
var isTableScalingEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
264
264
|
return function (inputMethod, rect) {
|
|
265
265
|
return withEditorAnalyticsAPI(function (_ref6) {
|
|
266
266
|
var selection = _ref6.selection;
|
|
@@ -280,7 +280,7 @@ export var deleteColumnsWithAnalytics = function deleteColumnsWithAnalytics(edit
|
|
|
280
280
|
},
|
|
281
281
|
eventType: EVENT_TYPE.TRACK
|
|
282
282
|
};
|
|
283
|
-
})(editorAnalyticsAPI)(deleteColumnsCommand(rect,
|
|
283
|
+
})(editorAnalyticsAPI)(deleteColumnsCommand(rect, isTableScalingEnabled));
|
|
284
284
|
};
|
|
285
285
|
};
|
|
286
286
|
export var deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = function deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI) {
|
|
@@ -328,7 +328,7 @@ export function handleTripleClick(view, pos) {
|
|
|
328
328
|
return false;
|
|
329
329
|
}
|
|
330
330
|
export var handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI, editorView) {
|
|
331
|
-
var
|
|
331
|
+
var isTableScalingEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
332
332
|
var oldSelection = oldState.tr.selection;
|
|
333
333
|
var tr = newState.tr;
|
|
334
334
|
if (oldSelection instanceof CellSelection) {
|
|
@@ -371,7 +371,7 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
|
|
|
371
371
|
isHeaderRowRequired = _getPluginState9.pluginConfig.isHeaderRowRequired;
|
|
372
372
|
tr = deleteRows(rect, isHeaderRowRequired)(tr);
|
|
373
373
|
} else if (tr.selection.isColSelection()) {
|
|
374
|
-
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView,
|
|
374
|
+
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView, isTableScalingEnabled)(tr);
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
}
|