@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
|
@@ -14,7 +14,7 @@ import { syncStickyRowToTable } from './dom';
|
|
|
14
14
|
// Base function to trigger the actual scale on a table node.
|
|
15
15
|
// Will only resize/scale if a table has been previously resized.
|
|
16
16
|
export var scale = function scale(tableRef, options, domAtPos) {
|
|
17
|
-
var
|
|
17
|
+
var isTableScalingEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
18
18
|
/**
|
|
19
19
|
* isBreakoutEnabled === true -> default center aligned
|
|
20
20
|
* isBreakoutEnabled === false -> full width mode
|
|
@@ -60,12 +60,12 @@ export var scale = function scale(tableRef, options, domAtPos) {
|
|
|
60
60
|
tableRef: tableRef,
|
|
61
61
|
start: start,
|
|
62
62
|
domAtPos: domAtPos,
|
|
63
|
-
|
|
63
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
64
64
|
});
|
|
65
65
|
return scaleTableTo(resizeState, newWidth);
|
|
66
66
|
};
|
|
67
67
|
export var scaleWithParent = function scaleWithParent(tableRef, parentWidth, table, start, domAtPos) {
|
|
68
|
-
var
|
|
68
|
+
var isTableScalingEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
69
69
|
var resizeState = getResizeState({
|
|
70
70
|
minWidth: tableCellMinWidth,
|
|
71
71
|
maxSize: parentWidth,
|
|
@@ -73,7 +73,7 @@ export var scaleWithParent = function scaleWithParent(tableRef, parentWidth, tab
|
|
|
73
73
|
tableRef: tableRef,
|
|
74
74
|
start: start,
|
|
75
75
|
domAtPos: domAtPos,
|
|
76
|
-
|
|
76
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
77
77
|
});
|
|
78
78
|
if (table.attrs.isNumberColumnEnabled) {
|
|
79
79
|
parentWidth -= akEditorTableNumberColumnWidth;
|
|
@@ -105,7 +105,7 @@ export function scaleTableTo(state, maxSize) {
|
|
|
105
105
|
return adjustColumnsWidths(newState, maxSize);
|
|
106
106
|
}
|
|
107
107
|
export var previewScaleTable = function previewScaleTable(tableRef, options, domAtPos) {
|
|
108
|
-
var
|
|
108
|
+
var isTableScalingEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
109
109
|
var node = options.node,
|
|
110
110
|
start = options.start,
|
|
111
111
|
parentWidth = options.parentWidth;
|
|
@@ -119,20 +119,20 @@ export var previewScaleTable = function previewScaleTable(tableRef, options, dom
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
// If the table hasn't been resize, the colgroup 48px width values will gracefully scale down.
|
|
122
|
-
// If we are scaling the table down with
|
|
123
|
-
if (!hasTableBeenResized(node) && !
|
|
122
|
+
// If we are scaling the table down with isTableScalingEnabled, the colgroup widths may be scaled to a value that is not 48px.
|
|
123
|
+
if (!hasTableBeenResized(node) && !isTableScalingEnabled) {
|
|
124
124
|
syncStickyRowToTable(tableRef);
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
|
-
var resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos,
|
|
127
|
+
var resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, isTableScalingEnabled) : scale(tableRef, options, domAtPos, isTableScalingEnabled);
|
|
128
128
|
if (resizeState) {
|
|
129
|
-
updateColgroup(resizeState, tableRef,
|
|
129
|
+
updateColgroup(resizeState, tableRef, node, isTableScalingEnabled);
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
|
|
133
133
|
// Scale the table to meet new requirements (col, layout change etc)
|
|
134
134
|
export var scaleTable = function scaleTable(tableRef, options, domAtPos) {
|
|
135
|
-
var
|
|
135
|
+
var isTableScalingEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
136
136
|
return function (tr) {
|
|
137
137
|
if (!tableRef) {
|
|
138
138
|
return tr;
|
|
@@ -145,7 +145,7 @@ export var scaleTable = function scaleTable(tableRef, options, domAtPos) {
|
|
|
145
145
|
if (hasTableBeenResized(node) === false) {
|
|
146
146
|
// If its not a re-sized table, we still want to re-create cols
|
|
147
147
|
// To force reflow of columns upon delete.
|
|
148
|
-
if (!
|
|
148
|
+
if (!isTableScalingEnabled) {
|
|
149
149
|
insertColgroupFromNode(tableRef, node);
|
|
150
150
|
}
|
|
151
151
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -153,9 +153,9 @@ export var scaleTable = function scaleTable(tableRef, options, domAtPos) {
|
|
|
153
153
|
}
|
|
154
154
|
var resizeState;
|
|
155
155
|
if (parentWidth) {
|
|
156
|
-
resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos,
|
|
156
|
+
resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos, isTableScalingEnabled);
|
|
157
157
|
} else {
|
|
158
|
-
resizeState = scale(tableRef, options, domAtPos,
|
|
158
|
+
resizeState = scale(tableRef, options, domAtPos, isTableScalingEnabled);
|
|
159
159
|
}
|
|
160
160
|
if (resizeState) {
|
|
161
161
|
tr = updateColumnWidths(resizeState, node, start)(tr);
|
|
@@ -16,9 +16,10 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
16
16
|
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
17
17
|
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
18
18
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
19
|
+
import { getPluginState } from './plugin-factory';
|
|
19
20
|
import { TABLE_MAX_WIDTH } from './table-resizing/utils';
|
|
20
21
|
export var pluginKey = new PluginKey('tableWidthPlugin');
|
|
21
|
-
var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, fullWidthEnabled
|
|
22
|
+
var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, fullWidthEnabled) {
|
|
22
23
|
return new SafePlugin({
|
|
23
24
|
key: pluginKey,
|
|
24
25
|
state: {
|
|
@@ -85,7 +86,10 @@ var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, fullW
|
|
|
85
86
|
var referentialityTr = transactions.find(function (tr) {
|
|
86
87
|
return tr.getMeta('referentialityTableInserted');
|
|
87
88
|
});
|
|
88
|
-
var
|
|
89
|
+
var _getPluginState = getPluginState(newState),
|
|
90
|
+
_getPluginState$isTab = _getPluginState.isTableScalingEnabled,
|
|
91
|
+
isTableScalingEnabled = _getPluginState$isTab === void 0 ? false : _getPluginState$isTab;
|
|
92
|
+
var shouldPatchTable = fullWidthEnabled && isTableScalingEnabled;
|
|
89
93
|
if (!isReplaceDocumentOperation && (!shouldPatchTable || !referentialityTr)) {
|
|
90
94
|
return null;
|
|
91
95
|
}
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -85,7 +85,7 @@ export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _
|
|
|
85
85
|
export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorState, editorView, initialSelectionRect, _ref2, getEditorContainerWidth, editorAnalyticsAPI) {
|
|
86
86
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
87
87
|
var formatMessage = _ref2.formatMessage;
|
|
88
|
-
var
|
|
88
|
+
var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
89
89
|
var top = initialSelectionRect.top,
|
|
90
90
|
bottom = initialSelectionRect.bottom,
|
|
91
91
|
right = initialSelectionRect.right,
|
|
@@ -100,7 +100,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
100
100
|
var selectionRect = getClosestSelectionRect(state);
|
|
101
101
|
var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
102
102
|
if (index) {
|
|
103
|
-
insertColumnWithAnalytics(
|
|
103
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
104
104
|
}
|
|
105
105
|
return true;
|
|
106
106
|
},
|
|
@@ -179,7 +179,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
179
179
|
}];
|
|
180
180
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
|
|
181
181
|
var _newResizeStateWithAn;
|
|
182
|
-
var newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth,
|
|
182
|
+
var newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled) : undefined;
|
|
183
183
|
var wouldChange = (_newResizeStateWithAn = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn !== void 0 ? _newResizeStateWithAn : false;
|
|
184
184
|
var distributeColumnWidths = function distributeColumnWidths(state, dispatch) {
|
|
185
185
|
if (newResizeStateWithAnalytics) {
|
|
@@ -299,13 +299,13 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
299
299
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
300
300
|
var nodeType = state.schema.nodes.table;
|
|
301
301
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
302
|
-
var
|
|
303
|
-
|
|
304
|
-
|
|
302
|
+
var _getPluginState2 = getPluginState(state),
|
|
303
|
+
_getPluginState2$isTa = _getPluginState2.isTableScalingEnabled,
|
|
304
|
+
isTableScalingEnabled = _getPluginState2$isTa === void 0 ? false : _getPluginState2$isTa;
|
|
305
305
|
var cellItems;
|
|
306
|
-
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(
|
|
306
|
+
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled);
|
|
307
307
|
var columnSettingsItems;
|
|
308
|
-
columnSettingsItems = pluginState.isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI,
|
|
308
|
+
columnSettingsItems = pluginState.isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled) : [];
|
|
309
309
|
var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
|
|
310
310
|
|
|
311
311
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -344,8 +344,8 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
344
344
|
}
|
|
345
345
|
return element;
|
|
346
346
|
};
|
|
347
|
-
var
|
|
348
|
-
stickyScrollbar =
|
|
347
|
+
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
348
|
+
stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
|
|
349
349
|
return {
|
|
350
350
|
title: 'Table floating controls',
|
|
351
351
|
getDomRef: getDomRef,
|
|
@@ -402,26 +402,26 @@ var separator = function separator(hidden) {
|
|
|
402
402
|
hidden: hidden
|
|
403
403
|
};
|
|
404
404
|
};
|
|
405
|
-
var getCellItems = function getCellItems(
|
|
405
|
+
var getCellItems = function getCellItems(state, view, _ref3, getEditorContainerWidth, editorAnalyticsAPI) {
|
|
406
406
|
var formatMessage = _ref3.formatMessage;
|
|
407
|
-
var
|
|
407
|
+
var isTableScalingEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
408
408
|
var initialSelectionRect = getClosestSelectionRect(state);
|
|
409
409
|
if (initialSelectionRect) {
|
|
410
410
|
var cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
411
411
|
formatMessage: formatMessage
|
|
412
|
-
}, getEditorContainerWidth, editorAnalyticsAPI,
|
|
412
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled);
|
|
413
413
|
return [cellOptions, separator(cellOptions.hidden)];
|
|
414
414
|
}
|
|
415
415
|
return [];
|
|
416
416
|
};
|
|
417
417
|
export var getDistributeConfig = function getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI) {
|
|
418
|
-
var
|
|
418
|
+
var isTableScalingEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
419
419
|
return function (state, dispatch, editorView) {
|
|
420
420
|
var selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
421
421
|
if (!editorView || !selectionOrTableRect) {
|
|
422
422
|
return false;
|
|
423
423
|
}
|
|
424
|
-
var newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth,
|
|
424
|
+
var newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
425
425
|
if (newResizeStateWithAnalytics) {
|
|
426
426
|
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
427
427
|
return true;
|
|
@@ -435,13 +435,13 @@ export var getDistributeConfig = function getDistributeConfig(getEditorContainer
|
|
|
435
435
|
var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI) {
|
|
436
436
|
var _newResizeStateWithAn2, _pluginState$pluginCo3;
|
|
437
437
|
var formatMessage = _ref4.formatMessage;
|
|
438
|
-
var
|
|
438
|
+
var isTableScalingEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
439
439
|
var pluginState = getPluginState(editorState);
|
|
440
440
|
var selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
|
|
441
441
|
if (!selectionOrTableRect || !editorView) {
|
|
442
442
|
return [];
|
|
443
443
|
}
|
|
444
|
-
var newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth,
|
|
444
|
+
var newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
445
445
|
var wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
|
|
446
446
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
|
|
447
447
|
return [{
|
|
@@ -450,7 +450,7 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
|
|
|
450
450
|
title: formatMessage(messages.distributeColumns),
|
|
451
451
|
icon: DistributeColumnIcon,
|
|
452
452
|
onClick: function onClick(state, dispatch, view) {
|
|
453
|
-
return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI,
|
|
453
|
+
return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled)(state, dispatch, view);
|
|
454
454
|
},
|
|
455
455
|
disabled: !wouldChange
|
|
456
456
|
}, {
|
|
@@ -462,9 +462,9 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
|
|
|
462
462
|
var getColorPicker = function getColorPicker(state, menu, _ref5, editorAnalyticsAPI) {
|
|
463
463
|
var _node$attrs;
|
|
464
464
|
var formatMessage = _ref5.formatMessage;
|
|
465
|
-
var
|
|
466
|
-
targetCellPosition =
|
|
467
|
-
pluginConfig =
|
|
465
|
+
var _getPluginState3 = getPluginState(state),
|
|
466
|
+
targetCellPosition = _getPluginState3.targetCellPosition,
|
|
467
|
+
pluginConfig = _getPluginState3.pluginConfig;
|
|
468
468
|
if (!pluginConfig.allowBackgroundColor) {
|
|
469
469
|
return [];
|
|
470
470
|
}
|
|
@@ -5,7 +5,7 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
5
5
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
7
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
|
-
import {
|
|
8
|
+
import { getTableContainerElementWidth, getTableElementWidth, hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
9
9
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
10
10
|
import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
11
11
|
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
@@ -88,7 +88,7 @@ export var updateColumnWidths = function updateColumnWidths(resizeState, table,
|
|
|
88
88
|
* @returns Updated transaction with rescaled columns for a given table
|
|
89
89
|
*/
|
|
90
90
|
export var rescaleColumns = function rescaleColumns() {
|
|
91
|
-
var
|
|
91
|
+
var isTableScalingEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
92
92
|
return function (table, view) {
|
|
93
93
|
return function (tr) {
|
|
94
94
|
if (!view) {
|
|
@@ -107,11 +107,11 @@ export var rescaleColumns = function rescaleColumns() {
|
|
|
107
107
|
possibleMaxWidth: 0,
|
|
108
108
|
isResized: isResized
|
|
109
109
|
};
|
|
110
|
-
if (
|
|
110
|
+
if (isTableScalingEnabled) {
|
|
111
111
|
previousTableInfo = {
|
|
112
112
|
// TODO - ensure correct width is returned when table doesn't have a width value
|
|
113
113
|
width: getTableElementWidth(table.node),
|
|
114
|
-
possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width') ?
|
|
114
|
+
possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width') ? getTableContainerElementWidth(table.node) : getTableContainerElementWidth(table.node) - insertColumnButtonOffset,
|
|
115
115
|
isResized: isResized
|
|
116
116
|
};
|
|
117
117
|
} else {
|
|
@@ -169,7 +169,7 @@ export var rescaleColumns = function rescaleColumns() {
|
|
|
169
169
|
tableRef: tableRef,
|
|
170
170
|
domAtPos: domAtPos,
|
|
171
171
|
maxSize: previousTableInfo.possibleMaxWidth,
|
|
172
|
-
|
|
172
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
173
173
|
});
|
|
174
174
|
|
|
175
175
|
// Two scenarios that require scaling:
|
|
@@ -205,7 +205,7 @@ function fixRowSpans(table) {
|
|
|
205
205
|
return table.type.createChecked(table.attrs, rows, table.marks);
|
|
206
206
|
}
|
|
207
207
|
export var deleteColumns = function deleteColumns(rect, allowCustomStep, view) {
|
|
208
|
-
var
|
|
208
|
+
var isTableScalingEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
209
209
|
return function (tr) {
|
|
210
210
|
var updatedTr = tr;
|
|
211
211
|
updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
@@ -218,7 +218,7 @@ export var deleteColumns = function deleteColumns(rect, allowCustomStep, view) {
|
|
|
218
218
|
}
|
|
219
219
|
var table = findTable(updatedTr.selection);
|
|
220
220
|
if (table) {
|
|
221
|
-
updatedTr = rescaleColumns(
|
|
221
|
+
updatedTr = rescaleColumns(isTableScalingEnabled)(table, view)(updatedTr);
|
|
222
222
|
}
|
|
223
223
|
return updatedTr;
|
|
224
224
|
};
|
|
@@ -274,11 +274,11 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
274
274
|
isDragAndDropEnabled = _getPluginState8.isDragAndDropEnabled,
|
|
275
275
|
allowDistributeColumns = _getPluginState8.pluginConfig.allowDistributeColumns;
|
|
276
276
|
if (allowDistributeColumns && (!isDragAndDropEnabled || !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))) {
|
|
277
|
-
var
|
|
278
|
-
var
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
var newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth,
|
|
277
|
+
var _newResizeState$chang;
|
|
278
|
+
var _getPluginState9 = getPluginState(editorView.state),
|
|
279
|
+
_getPluginState9$isTa = _getPluginState9.isTableScalingEnabled,
|
|
280
|
+
isTableScalingEnabled = _getPluginState9$isTa === void 0 ? false : _getPluginState9$isTa;
|
|
281
|
+
var newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
282
282
|
var wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
|
|
283
283
|
return {
|
|
284
284
|
content: formatMessage(messages.distributeColumns),
|
|
@@ -291,12 +291,12 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
291
291
|
return null;
|
|
292
292
|
});
|
|
293
293
|
_defineProperty(_assertThisInitialized(_this), "createSortColumnItems", function () {
|
|
294
|
-
var _this$
|
|
295
|
-
formatMessage = _this$
|
|
296
|
-
editorView = _this$
|
|
297
|
-
allowColumnSorting = _this$
|
|
298
|
-
var
|
|
299
|
-
isDragAndDropEnabled =
|
|
294
|
+
var _this$props9 = _this.props,
|
|
295
|
+
formatMessage = _this$props9.intl.formatMessage,
|
|
296
|
+
editorView = _this$props9.editorView,
|
|
297
|
+
allowColumnSorting = _this$props9.allowColumnSorting;
|
|
298
|
+
var _getPluginState10 = getPluginState(editorView.state),
|
|
299
|
+
isDragAndDropEnabled = _getPluginState10.isDragAndDropEnabled;
|
|
300
300
|
if (allowColumnSorting && (!isDragAndDropEnabled || !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))) {
|
|
301
301
|
var hasMergedCellsInTable = getMergedCellsPositions(editorView.state.tr).length > 0;
|
|
302
302
|
var warning = hasMergedCellsInTable ? {
|
|
@@ -360,22 +360,20 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
360
360
|
items[1].items.push(deleteRowItem);
|
|
361
361
|
return items;
|
|
362
362
|
});
|
|
363
|
-
_defineProperty(_assertThisInitialized(_this), "onMenuItemActivated", function (
|
|
364
|
-
var item =
|
|
365
|
-
var _this$
|
|
366
|
-
editorView = _this$
|
|
367
|
-
selectionRect = _this$
|
|
368
|
-
editorAnalyticsAPI = _this$
|
|
369
|
-
getEditorContainerWidth = _this$
|
|
370
|
-
getEditorFeatureFlags = _this$props11.getEditorFeatureFlags;
|
|
363
|
+
_defineProperty(_assertThisInitialized(_this), "onMenuItemActivated", function (_ref) {
|
|
364
|
+
var item = _ref.item;
|
|
365
|
+
var _this$props10 = _this.props,
|
|
366
|
+
editorView = _this$props10.editorView,
|
|
367
|
+
selectionRect = _this$props10.selectionRect,
|
|
368
|
+
editorAnalyticsAPI = _this$props10.editorAnalyticsAPI,
|
|
369
|
+
getEditorContainerWidth = _this$props10.getEditorContainerWidth;
|
|
371
370
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
372
371
|
var state = editorView.state,
|
|
373
372
|
dispatch = editorView.dispatch;
|
|
374
|
-
var
|
|
375
|
-
targetCellPosition =
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
tablePreserveWidth = _ref3$tablePreserveWi === void 0 ? false : _ref3$tablePreserveWi;
|
|
373
|
+
var _getPluginState11 = getPluginState(state),
|
|
374
|
+
targetCellPosition = _getPluginState11.targetCellPosition,
|
|
375
|
+
_getPluginState11$isT = _getPluginState11.isTableScalingEnabled,
|
|
376
|
+
isTableScalingEnabled = _getPluginState11$isT === void 0 ? false : _getPluginState11$isT;
|
|
379
377
|
switch (item.value.name) {
|
|
380
378
|
case 'sort_column_desc':
|
|
381
379
|
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect.left, SortOrder.DESC)(state, dispatch);
|
|
@@ -394,7 +392,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
394
392
|
_this.toggleOpen();
|
|
395
393
|
break;
|
|
396
394
|
case 'distribute_columns':
|
|
397
|
-
var newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth,
|
|
395
|
+
var newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
398
396
|
if (newResizeStateWithAnalytics) {
|
|
399
397
|
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, newResizeStateWithAnalytics)(state, dispatch);
|
|
400
398
|
_this.toggleOpen();
|
|
@@ -405,7 +403,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
405
403
|
_this.toggleOpen();
|
|
406
404
|
break;
|
|
407
405
|
case 'insert_column':
|
|
408
|
-
insertColumnWithAnalytics(
|
|
406
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
409
407
|
_this.toggleOpen();
|
|
410
408
|
break;
|
|
411
409
|
case 'insert_row':
|
|
@@ -420,19 +418,19 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
420
418
|
_this.toggleOpen();
|
|
421
419
|
break;
|
|
422
420
|
case 'delete_row':
|
|
423
|
-
var
|
|
424
|
-
isHeaderRowRequired =
|
|
421
|
+
var _getPluginState12 = getPluginState(state),
|
|
422
|
+
isHeaderRowRequired = _getPluginState12.pluginConfig.isHeaderRowRequired;
|
|
425
423
|
deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect, !!isHeaderRowRequired)(state, dispatch);
|
|
426
424
|
_this.toggleOpen();
|
|
427
425
|
break;
|
|
428
426
|
}
|
|
429
427
|
});
|
|
430
428
|
_defineProperty(_assertThisInitialized(_this), "toggleOpen", function () {
|
|
431
|
-
var _this$
|
|
432
|
-
isOpen = _this$
|
|
433
|
-
_this$
|
|
434
|
-
state = _this$
|
|
435
|
-
dispatch = _this$
|
|
429
|
+
var _this$props11 = _this.props,
|
|
430
|
+
isOpen = _this$props11.isOpen,
|
|
431
|
+
_this$props11$editorV = _this$props11.editorView,
|
|
432
|
+
state = _this$props11$editorV.state,
|
|
433
|
+
dispatch = _this$props11$editorV.dispatch;
|
|
436
434
|
toggleContextualMenu()(state, dispatch);
|
|
437
435
|
if (!isOpen) {
|
|
438
436
|
_this.setState({
|
|
@@ -449,13 +447,13 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
449
447
|
isSubmenuOpen: false
|
|
450
448
|
});
|
|
451
449
|
});
|
|
452
|
-
_defineProperty(_assertThisInitialized(_this), "handleItemMouseEnter", function (
|
|
453
|
-
var item =
|
|
454
|
-
var _this$
|
|
455
|
-
_this$
|
|
456
|
-
state = _this$
|
|
457
|
-
dispatch = _this$
|
|
458
|
-
selectionRect = _this$
|
|
450
|
+
_defineProperty(_assertThisInitialized(_this), "handleItemMouseEnter", function (_ref2) {
|
|
451
|
+
var item = _ref2.item;
|
|
452
|
+
var _this$props12 = _this.props,
|
|
453
|
+
_this$props12$editorV = _this$props12.editorView,
|
|
454
|
+
state = _this$props12$editorV.state,
|
|
455
|
+
dispatch = _this$props12$editorV.dispatch,
|
|
456
|
+
selectionRect = _this$props12.selectionRect;
|
|
459
457
|
if (item.value.name === 'background') {
|
|
460
458
|
if (!_this.state.isSubmenuOpen) {
|
|
461
459
|
_this.setState({
|
|
@@ -473,8 +471,8 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
473
471
|
hoverMergedCells()(state, dispatch);
|
|
474
472
|
}
|
|
475
473
|
});
|
|
476
|
-
_defineProperty(_assertThisInitialized(_this), "handleItemMouseLeave", function (
|
|
477
|
-
var item =
|
|
474
|
+
_defineProperty(_assertThisInitialized(_this), "handleItemMouseLeave", function (_ref3) {
|
|
475
|
+
var item = _ref3.item;
|
|
478
476
|
var _this$props$editorVie2 = _this.props.editorView,
|
|
479
477
|
state = _this$props$editorVie2.state,
|
|
480
478
|
dispatch = _this$props$editorVie2.dispatch;
|
|
@@ -493,12 +491,12 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
493
491
|
}
|
|
494
492
|
});
|
|
495
493
|
_defineProperty(_assertThisInitialized(_this), "setColor", function (color) {
|
|
496
|
-
var _this$
|
|
497
|
-
editorView = _this$
|
|
498
|
-
editorAnalyticsAPI = _this$
|
|
494
|
+
var _this$props13 = _this.props,
|
|
495
|
+
editorView = _this$props13.editorView,
|
|
496
|
+
editorAnalyticsAPI = _this$props13.editorAnalyticsAPI;
|
|
499
497
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
500
|
-
var
|
|
501
|
-
targetCellPosition =
|
|
498
|
+
var _getPluginState13 = getPluginState(editorView.state),
|
|
499
|
+
targetCellPosition = _getPluginState13.targetCellPosition;
|
|
502
500
|
var state = editorView.state,
|
|
503
501
|
dispatch = editorView.dispatch;
|
|
504
502
|
setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, color, targetCellPosition)(state, dispatch);
|
|
@@ -509,14 +507,14 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
509
507
|
_createClass(ContextualMenu, [{
|
|
510
508
|
key: "render",
|
|
511
509
|
value: function render() {
|
|
512
|
-
var _this$
|
|
513
|
-
isOpen = _this$
|
|
514
|
-
mountPoint = _this$
|
|
515
|
-
offset = _this$
|
|
516
|
-
boundariesElement = _this$
|
|
517
|
-
editorView = _this$
|
|
518
|
-
var
|
|
519
|
-
isDragAndDropEnabled =
|
|
510
|
+
var _this$props14 = this.props,
|
|
511
|
+
isOpen = _this$props14.isOpen,
|
|
512
|
+
mountPoint = _this$props14.mountPoint,
|
|
513
|
+
offset = _this$props14.offset,
|
|
514
|
+
boundariesElement = _this$props14.boundariesElement,
|
|
515
|
+
editorView = _this$props14.editorView;
|
|
516
|
+
var _getPluginState14 = getPluginState(editorView.state),
|
|
517
|
+
isDragAndDropEnabled = _getPluginState14.isDragAndDropEnabled;
|
|
520
518
|
var items = isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? this.createNewContextMenuItems() : this.createOriginalContextMenuItems();
|
|
521
519
|
return jsx("div", {
|
|
522
520
|
"data-testid": "table-cell-contextual-menu",
|
|
@@ -16,8 +16,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
16
16
|
isOpen = _ref.isOpen,
|
|
17
17
|
pluginConfig = _ref.pluginConfig,
|
|
18
18
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
19
|
-
getEditorContainerWidth = _ref.getEditorContainerWidth
|
|
20
|
-
getEditorFeatureFlags = _ref.getEditorFeatureFlags;
|
|
19
|
+
getEditorContainerWidth = _ref.getEditorContainerWidth;
|
|
21
20
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
22
21
|
var _getPluginState = getPluginState(editorView.state),
|
|
23
22
|
targetCellPosition = _getPluginState.targetCellPosition,
|
|
@@ -65,8 +64,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
65
64
|
selectionRect: selectionRect,
|
|
66
65
|
boundariesElement: boundariesElement,
|
|
67
66
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
68
|
-
getEditorContainerWidth: getEditorContainerWidth
|
|
69
|
-
getEditorFeatureFlags: getEditorFeatureFlags
|
|
67
|
+
getEditorContainerWidth: getEditorContainerWidth
|
|
70
68
|
})));
|
|
71
69
|
};
|
|
72
70
|
FloatingContextualMenu.displayName = 'FloatingContextualMenu';
|
|
@@ -180,7 +180,7 @@ export var DragMenu = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
180
180
|
mountPoint = _ref.mountPoint,
|
|
181
181
|
scrollableElement = _ref.scrollableElement,
|
|
182
182
|
boundariesElement = _ref.boundariesElement,
|
|
183
|
-
|
|
183
|
+
isTableScalingEnabled = _ref.isTableScalingEnabled;
|
|
184
184
|
var state = editorView.state,
|
|
185
185
|
dispatch = editorView.dispatch;
|
|
186
186
|
var selection = state.selection;
|
|
@@ -196,7 +196,7 @@ export var DragMenu = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
196
196
|
var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
197
197
|
var hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
198
198
|
var allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
199
|
-
var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired,
|
|
199
|
+
var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled);
|
|
200
200
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig, formatMessage, selectionRect),
|
|
201
201
|
menuItems = _convertToDropdownIte.menuItems,
|
|
202
202
|
menuCallback = _convertToDropdownIte.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
|
var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
@@ -17,8 +18,7 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
17
18
|
getEditorContainerWidth = _ref.getEditorContainerWidth,
|
|
18
19
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
19
20
|
stickyHeaders = _ref.stickyHeaders,
|
|
20
|
-
pluginConfig = _ref.pluginConfig
|
|
21
|
-
getEditorFeatureFlags = _ref.getEditorFeatureFlags;
|
|
21
|
+
pluginConfig = _ref.pluginConfig;
|
|
22
22
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
@@ -28,9 +28,9 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
28
28
|
if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
var _getPluginState = getPluginState(editorView.state),
|
|
32
|
+
_getPluginState$isTab = _getPluginState.isTableScalingEnabled,
|
|
33
|
+
isTableScalingEnabled = _getPluginState$isTab === void 0 ? false : _getPluginState$isTab;
|
|
34
34
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
35
35
|
alignX: direction === 'row' ? 'right' : undefined,
|
|
36
36
|
alignY: direction === 'row' ? 'start' : undefined,
|
|
@@ -64,7 +64,7 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
64
64
|
mountPoint: mountPoint,
|
|
65
65
|
boundariesElement: boundariesElement,
|
|
66
66
|
scrollableElement: scrollableElement,
|
|
67
|
-
|
|
67
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
68
68
|
}));
|
|
69
69
|
};
|
|
70
70
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -19,6 +19,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
19
19
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
20
20
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
21
21
|
import { insertColumnWithAnalytics, insertRowWithAnalytics } from '../../commands-with-analytics';
|
|
22
|
+
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
22
23
|
import { TableCssClassName as ClassName } from '../../types';
|
|
23
24
|
import { checkIfNumberColumnEnabled } from '../../utils';
|
|
24
25
|
import getPopupOptions from './getPopupOptions';
|
|
@@ -185,17 +186,15 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
185
186
|
var _this$props4 = this.props,
|
|
186
187
|
editorView = _this$props4.editorView,
|
|
187
188
|
insertColumnButtonIndex = _this$props4.insertColumnButtonIndex,
|
|
188
|
-
editorAnalyticsAPI = _this$props4.editorAnalyticsAPI
|
|
189
|
-
getEditorContainerWidth = _this$props4.getEditorContainerWidth;
|
|
189
|
+
editorAnalyticsAPI = _this$props4.editorAnalyticsAPI;
|
|
190
190
|
if (typeof insertColumnButtonIndex !== 'undefined') {
|
|
191
|
-
var _this$props$getEditor, _this$props5;
|
|
192
191
|
event.preventDefault();
|
|
193
|
-
var
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
var _getPluginState = getPluginState(editorView.state),
|
|
193
|
+
_getPluginState$isTab = _getPluginState.isTableScalingEnabled,
|
|
194
|
+
isTableScalingEnabled = _getPluginState$isTab === void 0 ? false : _getPluginState$isTab;
|
|
196
195
|
var state = editorView.state,
|
|
197
196
|
dispatch = editorView.dispatch;
|
|
198
|
-
insertColumnWithAnalytics(
|
|
197
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
199
198
|
}
|
|
200
199
|
}
|
|
201
200
|
}]);
|
package/dist/esm/utils/create.js
CHANGED
|
@@ -3,12 +3,9 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
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; }
|
|
4
4
|
import { createTable } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
6
|
-
export var createTableWithWidth = function createTableWithWidth(
|
|
6
|
+
export var createTableWithWidth = function createTableWithWidth(isTableScalingEnabled, isFullWidthModeEnabled, createTableProps) {
|
|
7
7
|
return function (schema) {
|
|
8
|
-
|
|
9
|
-
_ref$tablePreserveWid = _ref.tablePreserveWidth,
|
|
10
|
-
tablePreserveWidth = _ref$tablePreserveWid === void 0 ? false : _ref$tablePreserveWid;
|
|
11
|
-
if (tablePreserveWidth && isFullWidthModeEnabled) {
|
|
8
|
+
if (isTableScalingEnabled && isFullWidthModeEnabled) {
|
|
12
9
|
return createTable(_objectSpread({
|
|
13
10
|
schema: schema,
|
|
14
11
|
tableWidth: TABLE_MAX_WIDTH
|