@atlaskit/editor-plugin-table 7.16.17 → 7.16.19
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 +21 -0
- package/dist/cjs/commands/column-resize.js +4 -3
- package/dist/cjs/commands/delete.js +3 -2
- package/dist/cjs/commands/insert.js +12 -8
- package/dist/cjs/commands-with-analytics.js +10 -7
- package/dist/cjs/event-handlers.js +3 -2
- package/dist/cjs/nodeviews/TableComponent.js +32 -19
- package/dist/cjs/nodeviews/TableContainer.js +4 -0
- package/dist/cjs/nodeviews/TableResizer.js +8 -7
- package/dist/cjs/nodeviews/table.js +6 -4
- package/dist/cjs/plugin.js +9 -6
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +12 -13
- package/dist/cjs/pm-plugins/keymap.js +11 -9
- package/dist/cjs/pm-plugins/main.js +4 -1
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +10 -9
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +4 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +4 -3
- package/dist/cjs/toolbar.js +54 -37
- package/dist/cjs/transforms/column-width.js +3 -3
- package/dist/cjs/transforms/delete-columns.js +3 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +21 -15
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +6 -3
- package/dist/cjs/ui/FloatingInsertButton/index.js +7 -8
- package/dist/cjs/utils/drag-menu.js +5 -4
- package/dist/es2019/commands/column-resize.js +4 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +8 -8
- package/dist/es2019/commands-with-analytics.js +9 -8
- package/dist/es2019/event-handlers.js +2 -2
- package/dist/es2019/nodeviews/TableComponent.js +28 -17
- package/dist/es2019/nodeviews/TableContainer.js +4 -0
- package/dist/es2019/nodeviews/TableResizer.js +9 -8
- package/dist/es2019/nodeviews/table.js +5 -4
- package/dist/es2019/plugin.js +9 -6
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +7 -10
- package/dist/es2019/pm-plugins/keymap.js +9 -9
- package/dist/es2019/pm-plugins/main.js +4 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +10 -9
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +4 -4
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +4 -4
- package/dist/es2019/toolbar.js +51 -39
- package/dist/es2019/transforms/column-width.js +2 -3
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +12 -7
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +5 -3
- package/dist/es2019/ui/FloatingInsertButton/index.js +6 -8
- package/dist/es2019/utils/drag-menu.js +4 -4
- package/dist/esm/commands/column-resize.js +4 -3
- package/dist/esm/commands/delete.js +3 -2
- package/dist/esm/commands/insert.js +12 -8
- package/dist/esm/commands-with-analytics.js +10 -7
- package/dist/esm/event-handlers.js +3 -2
- package/dist/esm/nodeviews/TableComponent.js +32 -19
- package/dist/esm/nodeviews/TableContainer.js +4 -0
- package/dist/esm/nodeviews/TableResizer.js +9 -8
- package/dist/esm/nodeviews/table.js +6 -4
- package/dist/esm/plugin.js +9 -6
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +12 -13
- package/dist/esm/pm-plugins/keymap.js +11 -9
- package/dist/esm/pm-plugins/main.js +4 -1
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +10 -9
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +4 -3
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +4 -3
- package/dist/esm/toolbar.js +54 -37
- package/dist/esm/transforms/column-width.js +3 -3
- package/dist/esm/transforms/delete-columns.js +3 -2
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +21 -15
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +6 -3
- package/dist/esm/ui/FloatingInsertButton/index.js +7 -8
- package/dist/esm/utils/drag-menu.js +5 -4
- package/dist/types/commands/column-resize.d.ts +2 -1
- package/dist/types/commands/delete.d.ts +1 -1
- package/dist/types/commands/insert.d.ts +4 -4
- package/dist/types/commands-with-analytics.d.ts +4 -4
- package/dist/types/event-handlers.d.ts +1 -1
- package/dist/types/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/nodeviews/table.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -1
- package/dist/types/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +1 -1
- package/dist/types/toolbar.d.ts +5 -5
- package/dist/types/transforms/column-width.d.ts +1 -1
- package/dist/types/transforms/delete-columns.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -0
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/column-resize.d.ts +2 -1
- package/dist/types-ts4.5/commands/delete.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +4 -4
- package/dist/types-ts4.5/commands-with-analytics.d.ts +4 -4
- package/dist/types-ts4.5/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +1 -1
- package/dist/types-ts4.5/toolbar.d.ts +5 -5
- package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
- package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -0
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +5 -8
- package/src/commands/column-resize.ts +6 -6
- package/src/commands/delete.ts +7 -1
- package/src/commands/insert.ts +33 -5
- package/src/commands-with-analytics.ts +14 -2
- package/src/event-handlers.ts +2 -0
- package/src/nodeviews/TableComponent.tsx +28 -28
- package/src/nodeviews/TableContainer.tsx +6 -0
- package/src/nodeviews/TableResizer.tsx +16 -6
- package/src/nodeviews/table.tsx +4 -2
- package/src/plugin.tsx +17 -7
- package/src/pm-plugins/drag-and-drop/plugin.ts +26 -13
- package/src/pm-plugins/keymap.ts +30 -4
- package/src/pm-plugins/main.ts +2 -0
- package/src/pm-plugins/table-resizing/event-handlers.ts +12 -14
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +5 -5
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +6 -4
- package/src/toolbar.tsx +97 -40
- package/src/transforms/column-width.ts +7 -3
- package/src/transforms/delete-columns.ts +6 -2
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +12 -4
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -0
- package/src/ui/FloatingDragMenu/index.tsx +4 -4
- package/src/ui/FloatingInsertButton/index.tsx +12 -9
- package/src/utils/drag-menu.ts +13 -4
|
@@ -8,7 +8,7 @@ import { addRowAroundSelection, changeColumnWidthByStepWithAnalytics, deleteSele
|
|
|
8
8
|
import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
9
9
|
import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand, createTable } from '../commands/insert';
|
|
10
10
|
import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
11
|
-
export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isTableAlignmentEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl, shouldUseIncreasedScalingPercent) {
|
|
11
|
+
export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isTableAlignmentEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl, isCellBackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent) {
|
|
12
12
|
var _pluginInjectionApi$a;
|
|
13
13
|
const list = {};
|
|
14
14
|
const ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
|
|
@@ -21,13 +21,13 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
21
21
|
// Add row/column shortcuts
|
|
22
22
|
bindKeymapWithCommand(addRowBefore.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
|
|
23
23
|
bindKeymapWithCommand(addRowAfter.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
|
|
24
|
-
bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(isTableScalingEnabled, shouldUseIncreasedScalingPercent), list);
|
|
25
|
-
bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(isTableScalingEnabled, shouldUseIncreasedScalingPercent), list);
|
|
24
|
+
bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
25
|
+
bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
26
26
|
if (getBooleanFF('platform.editor.a11y-help-dialog-shortcut-keys-position_aghfg')) {
|
|
27
27
|
bindKeymapWithCommand(addRowBeforeVO.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
|
|
28
28
|
bindKeymapWithCommand(addRowAfterVO.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
|
|
29
|
-
bindKeymapWithCommand(addColumnBeforeVO.common, addColumnBeforeCommand(isTableScalingEnabled), list);
|
|
30
|
-
bindKeymapWithCommand(addColumnAfterVO.common, addColumnAfterCommand(isTableScalingEnabled), list);
|
|
29
|
+
bindKeymapWithCommand(addColumnBeforeVO.common, addColumnBeforeCommand(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
30
|
+
bindKeymapWithCommand(addColumnAfterVO.common, addColumnAfterCommand(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
31
31
|
}
|
|
32
32
|
if (dragAndDropEnabled) {
|
|
33
33
|
// Move row/column shortcuts
|
|
@@ -44,8 +44,8 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
44
44
|
bindKeymapWithCommand(moveColumnRight.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-column', 1), list);
|
|
45
45
|
|
|
46
46
|
// Delete row/column shortcuts
|
|
47
|
-
bindKeymapWithCommand(deleteColumn.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent), list);
|
|
48
|
-
bindKeymapWithCommand(deleteRow.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent), list);
|
|
47
|
+
bindKeymapWithCommand(deleteColumn.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
48
|
+
bindKeymapWithCommand(deleteRow.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
49
49
|
}
|
|
50
50
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
51
51
|
bindKeymapWithCommand(startColumnResizing.common, initiateKeyboardColumnResizing({
|
|
@@ -62,8 +62,8 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
62
62
|
ariaNotify: ariaNotifyPlugin,
|
|
63
63
|
getIntl: getIntl
|
|
64
64
|
}), list);
|
|
65
|
-
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(-10, getEditorContainerWidth, isTableScalingEnabled, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
66
|
-
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(10, getEditorContainerWidth, isTableScalingEnabled, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
65
|
+
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(-10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
66
|
+
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
67
67
|
bindKeymapWithCommand(escape.common, stopKeyboardColumnResizing({
|
|
68
68
|
ariaNotify: ariaNotifyPlugin,
|
|
69
69
|
getIntl: getIntl
|
|
@@ -75,8 +75,11 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
if (tr) {
|
|
78
|
+
const {
|
|
79
|
+
tableWithFixedColumnWidthsOption = false
|
|
80
|
+
} = getEditorFeatureFlags();
|
|
78
81
|
// "fixTables" removes empty rows as we don't allow that in schema
|
|
79
|
-
const updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI, editorViewRef || undefined, isTableScalingEnabled, shouldUseIncreasedScalingPercent);
|
|
82
|
+
const updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI, editorViewRef || undefined, isTableScalingEnabled, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent);
|
|
80
83
|
return fixTables(updatedTr) || updatedTr;
|
|
81
84
|
}
|
|
82
85
|
if (transactions.find(tr => tr.docChanged)) {
|
|
@@ -50,8 +50,11 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
50
50
|
getEditorContainerWidth
|
|
51
51
|
});
|
|
52
52
|
let shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
53
|
-
const
|
|
54
|
-
|
|
53
|
+
const {
|
|
54
|
+
tableWithFixedColumnWidthsOption = false
|
|
55
|
+
} = getEditorFeatureFlags();
|
|
56
|
+
const isTableScalingWithFixedColumnWidthsOptionEnabled = isTableScalingEnabled && tableWithFixedColumnWidthsOption;
|
|
57
|
+
if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
|
|
55
58
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
56
59
|
}
|
|
57
60
|
const resizeState = getResizeState({
|
|
@@ -62,7 +65,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
62
65
|
start,
|
|
63
66
|
domAtPos,
|
|
64
67
|
isTableScalingEnabled: shouldScale,
|
|
65
|
-
shouldUseIncreasedScalingPercent:
|
|
68
|
+
shouldUseIncreasedScalingPercent: isTableScalingWithFixedColumnWidthsOptionEnabled && getBooleanFF('platform.editor.table.use-increased-scaling-percent')
|
|
66
69
|
});
|
|
67
70
|
if (evenColumns({
|
|
68
71
|
resizeState,
|
|
@@ -147,8 +150,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
147
150
|
// only selected (or selected - 1) columns should be distributed
|
|
148
151
|
const resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
149
152
|
let shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
150
|
-
|
|
151
|
-
if (isTableScalingEnabledWithLockButton) {
|
|
153
|
+
if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
|
|
152
154
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
153
155
|
}
|
|
154
156
|
const resizedDelta = clientX - startX;
|
|
@@ -157,7 +159,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
157
159
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
158
160
|
tr.setNodeAttribute(start - 1, 'width', newResizeState.tableWidth);
|
|
159
161
|
} else {
|
|
160
|
-
const newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, shouldScale,
|
|
162
|
+
const newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, shouldScale, isTableScalingWithFixedColumnWidthsOptionEnabled && getBooleanFF('platform.editor.table.use-increased-scaling-percent'));
|
|
161
163
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
162
164
|
}
|
|
163
165
|
if (colIndex === map.width - 1) {
|
|
@@ -231,9 +233,8 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
231
233
|
const map = TableMap.get(table);
|
|
232
234
|
const colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
233
235
|
let shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
if (isTableScalingEnabledWithLockButton) {
|
|
236
|
+
const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
237
|
+
if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
|
|
237
238
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
238
239
|
}
|
|
239
240
|
if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
@@ -273,7 +273,7 @@ export const normaliseTableLayout = input => {
|
|
|
273
273
|
return 'default';
|
|
274
274
|
}
|
|
275
275
|
};
|
|
276
|
-
export const getNewResizeStateFromSelectedColumns = (rect, state, domAtPos, getEditorContainerWidth, isTableScalingEnabled = false) => {
|
|
276
|
+
export const getNewResizeStateFromSelectedColumns = (rect, state, domAtPos, getEditorContainerWidth, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false) => {
|
|
277
277
|
// Fail early so that we don't do complex calculations for no reason
|
|
278
278
|
const numColumnsSelected = rect.right - rect.left;
|
|
279
279
|
if (numColumnsSelected <= 1) {
|
|
@@ -308,8 +308,8 @@ export const getNewResizeStateFromSelectedColumns = (rect, state, domAtPos, getE
|
|
|
308
308
|
});
|
|
309
309
|
let resizeState;
|
|
310
310
|
let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
311
|
+
const isTableScalingWithFixedColumnWidthsOptionEnabled = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled;
|
|
312
|
+
if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
|
|
313
313
|
isTableScalingEnabledOnCurrentTable = table.node.attrs.displayMode !== 'fixed';
|
|
314
314
|
}
|
|
315
315
|
resizeState = getResizeState({
|
|
@@ -320,7 +320,7 @@ export const getNewResizeStateFromSelectedColumns = (rect, state, domAtPos, getE
|
|
|
320
320
|
start: table.start,
|
|
321
321
|
domAtPos,
|
|
322
322
|
isTableScalingEnabled: isTableScalingEnabledOnCurrentTable,
|
|
323
|
-
shouldUseIncreasedScalingPercent:
|
|
323
|
+
shouldUseIncreasedScalingPercent: isTableScalingWithFixedColumnWidthsOptionEnabled && getBooleanFF('platform.editor.table.use-increased-scaling-percent')
|
|
324
324
|
});
|
|
325
325
|
const newResizeState = evenSelectedColumnsWidths(resizeState, rect);
|
|
326
326
|
const widthsBefore = resizeState.widths;
|
|
@@ -98,7 +98,7 @@ export function scaleTableTo(state, maxSize) {
|
|
|
98
98
|
}
|
|
99
99
|
return adjustColumnsWidths(newState, maxSize);
|
|
100
100
|
}
|
|
101
|
-
export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEnabled = false) => {
|
|
101
|
+
export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEnabled = false, isTableWithFixedColumnWidthsOptionEnabled = false) => {
|
|
102
102
|
const {
|
|
103
103
|
node,
|
|
104
104
|
start,
|
|
@@ -113,8 +113,8 @@ export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEna
|
|
|
113
113
|
tableRef.style.width = `${width}px`;
|
|
114
114
|
}
|
|
115
115
|
let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
116
|
+
const isTableScalingWithFixedColumnWidthsOptionEnabled = isTableScalingEnabled && isTableWithFixedColumnWidthsOptionEnabled;
|
|
117
|
+
if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
|
|
118
118
|
isTableScalingEnabledOnCurrentTable = isTableScalingEnabled && node.attrs.displayMode !== 'fixed';
|
|
119
119
|
}
|
|
120
120
|
// If the table hasn't been resize, the colgroup 48px width values will gracefully scale down.
|
|
@@ -123,7 +123,7 @@ export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEna
|
|
|
123
123
|
syncStickyRowToTable(tableRef);
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
const shouldUseIncreasedScalingPercent =
|
|
126
|
+
const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
127
127
|
const resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, false,
|
|
128
128
|
// Here isTableScalingEnabled = false
|
|
129
129
|
shouldUseIncreasedScalingPercent) : scale(tableRef, options, domAtPos, false, shouldUseIncreasedScalingPercent);
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -23,6 +23,7 @@ import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTa
|
|
|
23
23
|
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, setTableAlignmentWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleFixedColumnWidthsOptionAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
|
|
24
24
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
25
25
|
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
26
|
+
import { getStaticTableScalingPercent } from './pm-plugins/table-resizing/utils/misc';
|
|
26
27
|
import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
|
|
27
28
|
import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
|
|
28
29
|
import { canMergeCells } from './transforms';
|
|
@@ -81,6 +82,7 @@ export const getToolbarMenuConfig = (config, state, {
|
|
|
81
82
|
type: optionItem
|
|
82
83
|
}
|
|
83
84
|
}];
|
|
85
|
+
const tableOptionsDropdownWidth = isTableScalingWithFixedColumnWidthsOptionShown ? 192 : undefined;
|
|
84
86
|
if (state.isDragAndDropEnabled) {
|
|
85
87
|
return {
|
|
86
88
|
id: 'editor.table.tableOptions',
|
|
@@ -90,7 +92,7 @@ export const getToolbarMenuConfig = (config, state, {
|
|
|
90
92
|
title: formatMessage(messages.tableOptions),
|
|
91
93
|
hidden: options.every(option => option.hidden),
|
|
92
94
|
options,
|
|
93
|
-
dropdownWidth:
|
|
95
|
+
dropdownWidth: tableOptionsDropdownWidth
|
|
94
96
|
};
|
|
95
97
|
} else {
|
|
96
98
|
return {
|
|
@@ -100,7 +102,7 @@ export const getToolbarMenuConfig = (config, state, {
|
|
|
100
102
|
title: formatMessage(messages.tableOptions),
|
|
101
103
|
hidden: options.every(option => option.hidden),
|
|
102
104
|
options,
|
|
103
|
-
dropdownWidth:
|
|
105
|
+
dropdownWidth: tableOptionsDropdownWidth
|
|
104
106
|
};
|
|
105
107
|
}
|
|
106
108
|
};
|
|
@@ -110,7 +112,7 @@ export const getToolbarMenuConfig = (config, state, {
|
|
|
110
112
|
// with native widgets. It's enabled via a plugin config.
|
|
111
113
|
export const getToolbarCellOptionsConfig = (editorState, editorView, initialSelectionRect, {
|
|
112
114
|
formatMessage
|
|
113
|
-
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) => {
|
|
115
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false, isCellBackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => {
|
|
114
116
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
115
117
|
const {
|
|
116
118
|
top,
|
|
@@ -128,7 +130,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
128
130
|
const selectionRect = getClosestSelectionRect(state);
|
|
129
131
|
const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
130
132
|
if (index) {
|
|
131
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
133
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
132
134
|
}
|
|
133
135
|
return true;
|
|
134
136
|
},
|
|
@@ -164,7 +166,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
164
166
|
onClick: (state, dispatch, view) => {
|
|
165
167
|
const selectionRect = getClosestSelectionRect(state);
|
|
166
168
|
if (selectionRect) {
|
|
167
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
|
|
169
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
|
|
168
170
|
}
|
|
169
171
|
return true;
|
|
170
172
|
},
|
|
@@ -207,7 +209,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
207
209
|
}];
|
|
208
210
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
|
|
209
211
|
var _newResizeStateWithAn;
|
|
210
|
-
const newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled) : undefined;
|
|
212
|
+
const newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled) : undefined;
|
|
211
213
|
const wouldChange = (_newResizeStateWithAn = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn !== void 0 ? _newResizeStateWithAn : false;
|
|
212
214
|
const distributeColumnWidths = (state, dispatch) => {
|
|
213
215
|
if (newResizeStateWithAnalytics) {
|
|
@@ -315,26 +317,38 @@ export const getClosestSelectionOrTableRect = state => {
|
|
|
315
317
|
const tableRect = new Rect(0, 0, map.width, map.height);
|
|
316
318
|
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
|
|
317
319
|
};
|
|
318
|
-
export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options,
|
|
320
|
+
export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => config => (state, intl) => {
|
|
319
321
|
const tableObject = findTable(state.selection);
|
|
320
322
|
const pluginState = getPluginState(state);
|
|
321
323
|
const resizeState = tableResizingPluginKey.getState(state);
|
|
322
324
|
const tableWidthState = tableWidthPluginKey.getState(state);
|
|
325
|
+
const isTableScalingEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) || false;
|
|
323
326
|
|
|
324
327
|
// We don't want to show floating toolbar while resizing the table
|
|
325
328
|
const isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
326
329
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
327
330
|
const nodeType = state.schema.nodes.table;
|
|
328
331
|
const isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
|
|
329
|
-
const isTableScalingWithFixedColumnWidthsOptionShown =
|
|
332
|
+
const isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
|
|
330
333
|
const areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
|
|
334
|
+
const editorView = getEditorView();
|
|
335
|
+
const getDomRef = editorView => {
|
|
336
|
+
let element;
|
|
337
|
+
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
338
|
+
const parent = findParentDomRefOfType(nodeType, domAtPos)(state.selection);
|
|
339
|
+
if (parent) {
|
|
340
|
+
const tableRef = parent.querySelector('table') || undefined;
|
|
341
|
+
if (tableRef) {
|
|
342
|
+
element = closestElement(tableRef, `.${TableCssClassName.TABLE_NODE_WRAPPER}`) || undefined;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return element;
|
|
346
|
+
};
|
|
331
347
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown, areTableColumWidthsFixed);
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
let columnSettingsItems;
|
|
337
|
-
columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) : [];
|
|
348
|
+
const alignmentMenu = options !== null && options !== void 0 && options.isTableAlignmentEnabled && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent) : [];
|
|
349
|
+
const isCellBackgroundDuplicated = getEditorFeatureFlags().tableDuplicateCellColouring || false;
|
|
350
|
+
const cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, editorView, intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent);
|
|
351
|
+
const columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, editorView, intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled) : [];
|
|
338
352
|
const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView);
|
|
339
353
|
|
|
340
354
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -354,18 +368,6 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
354
368
|
onConfirm: (isChecked = false) => clickWithCheckboxHandler(isChecked, tableObject.node)
|
|
355
369
|
});
|
|
356
370
|
}
|
|
357
|
-
const getDomRef = editorView => {
|
|
358
|
-
let element;
|
|
359
|
-
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
360
|
-
const parent = findParentDomRefOfType(nodeType, domAtPos)(state.selection);
|
|
361
|
-
if (parent) {
|
|
362
|
-
const tableRef = parent.querySelector('table') || undefined;
|
|
363
|
-
if (tableRef) {
|
|
364
|
-
element = closestElement(tableRef, `.${TableCssClassName.TABLE_NODE_WRAPPER}`) || undefined;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
return element;
|
|
368
|
-
};
|
|
369
371
|
const {
|
|
370
372
|
stickyScrollbar
|
|
371
373
|
} = getEditorFeatureFlags();
|
|
@@ -426,22 +428,22 @@ const separator = hidden => {
|
|
|
426
428
|
};
|
|
427
429
|
const getCellItems = (state, view, {
|
|
428
430
|
formatMessage
|
|
429
|
-
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) => {
|
|
431
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false, isCellBackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => {
|
|
430
432
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
431
433
|
if (initialSelectionRect) {
|
|
432
434
|
const cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
433
435
|
formatMessage
|
|
434
|
-
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent);
|
|
436
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent);
|
|
435
437
|
return [cellOptions, separator(cellOptions.hidden)];
|
|
436
438
|
}
|
|
437
439
|
return [];
|
|
438
440
|
};
|
|
439
|
-
export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => (state, dispatch, editorView) => {
|
|
441
|
+
export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false) => (state, dispatch, editorView) => {
|
|
440
442
|
const selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
441
443
|
if (!editorView || !selectionOrTableRect) {
|
|
442
444
|
return false;
|
|
443
445
|
}
|
|
444
|
-
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
446
|
+
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled);
|
|
445
447
|
if (newResizeStateWithAnalytics) {
|
|
446
448
|
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
447
449
|
return true;
|
|
@@ -453,14 +455,14 @@ export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI,
|
|
|
453
455
|
// fixed column button should be in this function call in the future
|
|
454
456
|
const getColumnSettingItems = (editorState, editorView, {
|
|
455
457
|
formatMessage
|
|
456
|
-
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => {
|
|
458
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false) => {
|
|
457
459
|
var _newResizeStateWithAn2, _pluginState$pluginCo3;
|
|
458
460
|
const pluginState = getPluginState(editorState);
|
|
459
461
|
const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
|
|
460
462
|
if (!selectionOrTableRect || !editorView) {
|
|
461
463
|
return [];
|
|
462
464
|
}
|
|
463
|
-
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
465
|
+
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled);
|
|
464
466
|
const wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
|
|
465
467
|
const items = [];
|
|
466
468
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
|
|
@@ -469,7 +471,7 @@ const getColumnSettingItems = (editorState, editorView, {
|
|
|
469
471
|
type: 'button',
|
|
470
472
|
title: formatMessage(messages.distributeColumns),
|
|
471
473
|
icon: DistributeColumnIcon,
|
|
472
|
-
onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled)(state, dispatch, view),
|
|
474
|
+
onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled)(state, dispatch, view),
|
|
473
475
|
disabled: !wouldChange
|
|
474
476
|
});
|
|
475
477
|
}
|
|
@@ -539,7 +541,7 @@ const highlightColumnsHandler = (state, dispatch) => {
|
|
|
539
541
|
};
|
|
540
542
|
export const getAlignmentOptionsConfig = (editorState, {
|
|
541
543
|
formatMessage
|
|
542
|
-
}, editorAnalyticsAPI, getEditorContainerWidth) => {
|
|
544
|
+
}, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent) => {
|
|
543
545
|
const tableObject = findTable(editorState.selection);
|
|
544
546
|
if (!tableObject) {
|
|
545
547
|
return [];
|
|
@@ -573,7 +575,7 @@ export const getAlignmentOptionsConfig = (editorState, {
|
|
|
573
575
|
title: formatMessage(layoutToMessages[value]),
|
|
574
576
|
selected: normaliseAlignment(currentLayout) === value,
|
|
575
577
|
onClick: setTableAlignmentWithAnalytics(editorAnalyticsAPI)(value, currentLayout, INPUT_METHOD.FLOATING_TB, CHANGE_ALIGNMENT_REASON.TOOLBAR_OPTION_CHANGED),
|
|
576
|
-
...(isLayoutOptionDisabled(tableObject.node, getEditorContainerWidth) && {
|
|
578
|
+
...(isLayoutOptionDisabled(tableObject.node, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent) && {
|
|
577
579
|
disabled: value !== 'center'
|
|
578
580
|
})
|
|
579
581
|
};
|
|
@@ -602,10 +604,20 @@ export const getSelectedAlignmentIcon = (alignmentIcons, selectedNode) => {
|
|
|
602
604
|
const selectedAlignment = selectedNode.attrs.layout;
|
|
603
605
|
return alignmentIcons.find(icon => icon.value === normaliseAlignment(selectedAlignment));
|
|
604
606
|
};
|
|
605
|
-
export const isLayoutOptionDisabled = (selectedNode, getEditorContainerWidth) => {
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
|
|
607
|
+
export const isLayoutOptionDisabled = (selectedNode, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent) => {
|
|
608
|
+
const {
|
|
609
|
+
lineLength
|
|
610
|
+
} = getEditorContainerWidth();
|
|
611
|
+
let tableContainerWidth = getTableContainerWidth(selectedNode);
|
|
612
|
+
|
|
613
|
+
// table may be scaled, use the scale percent to calculate the table width
|
|
614
|
+
if (editorView) {
|
|
615
|
+
const tableWrapper = getDomRef(editorView);
|
|
616
|
+
const tableWrapperWidth = (tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.clientWidth) || tableContainerWidth;
|
|
617
|
+
const scalePercent = getStaticTableScalingPercent(selectedNode, tableWrapperWidth, shouldUseIncreasedScalingPercent);
|
|
618
|
+
tableContainerWidth = tableContainerWidth * scalePercent;
|
|
619
|
+
}
|
|
620
|
+
if (selectedNode && lineLength && tableContainerWidth > lineLength) {
|
|
609
621
|
return true;
|
|
610
622
|
}
|
|
611
623
|
return false;
|
|
@@ -88,7 +88,7 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
|
88
88
|
* @param view
|
|
89
89
|
* @returns Updated transaction with rescaled columns for a given table
|
|
90
90
|
*/
|
|
91
|
-
export const rescaleColumns = (isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) => (table, view) => tr => {
|
|
91
|
+
export const rescaleColumns = (isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => (table, view) => tr => {
|
|
92
92
|
if (!view) {
|
|
93
93
|
return tr;
|
|
94
94
|
}
|
|
@@ -108,7 +108,7 @@ export const rescaleColumns = (isTableScalingEnabled = false, shouldUseIncreased
|
|
|
108
108
|
};
|
|
109
109
|
const tableDepth = view.state.doc.resolve(table.pos).depth;
|
|
110
110
|
let shouldScale = isTableScalingEnabled && tableDepth === 0;
|
|
111
|
-
if (shouldScale &&
|
|
111
|
+
if (shouldScale && isTableFixedColumnWidthsOptionEnabled) {
|
|
112
112
|
shouldScale = newTable.attrs.displayMode !== 'fixed';
|
|
113
113
|
}
|
|
114
114
|
if (shouldScale) {
|
|
@@ -173,7 +173,6 @@ export const rescaleColumns = (isTableScalingEnabled = false, shouldUseIncreased
|
|
|
173
173
|
isTableScalingEnabled: shouldScale,
|
|
174
174
|
shouldUseIncreasedScalingPercent
|
|
175
175
|
});
|
|
176
|
-
|
|
177
176
|
// Two scenarios that require scaling:
|
|
178
177
|
// 1. If the new table width will result in the table going into overflow
|
|
179
178
|
// we resize the cells to avoid it (e.g. adding a column)
|
|
@@ -192,7 +192,7 @@ function fixRowSpans(table) {
|
|
|
192
192
|
}
|
|
193
193
|
return table.type.createChecked(table.attrs, rows, table.marks);
|
|
194
194
|
}
|
|
195
|
-
export const deleteColumns = (rect, allowCustomStep, view, isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) => tr => {
|
|
195
|
+
export const deleteColumns = (rect, allowCustomStep, view, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => tr => {
|
|
196
196
|
let updatedTr = tr;
|
|
197
197
|
updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
198
198
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.DELETED_COLUMN
|
|
@@ -204,7 +204,7 @@ export const deleteColumns = (rect, allowCustomStep, view, isTableScalingEnabled
|
|
|
204
204
|
}
|
|
205
205
|
const table = findTable(updatedTr.selection);
|
|
206
206
|
if (table) {
|
|
207
|
-
updatedTr = rescaleColumns(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(table, view)(updatedTr);
|
|
207
|
+
updatedTr = rescaleColumns(isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(table, view)(updatedTr);
|
|
208
208
|
}
|
|
209
209
|
return updatedTr;
|
|
210
210
|
};
|
|
@@ -298,7 +298,8 @@ export class ContextualMenu extends Component {
|
|
|
298
298
|
formatMessage
|
|
299
299
|
},
|
|
300
300
|
editorView,
|
|
301
|
-
getEditorContainerWidth
|
|
301
|
+
getEditorContainerWidth,
|
|
302
|
+
getEditorFeatureFlags
|
|
302
303
|
} = this.props;
|
|
303
304
|
const {
|
|
304
305
|
isDragAndDropEnabled,
|
|
@@ -311,7 +312,10 @@ export class ContextualMenu extends Component {
|
|
|
311
312
|
const {
|
|
312
313
|
isTableScalingEnabled = false
|
|
313
314
|
} = getPluginState(editorView.state);
|
|
314
|
-
const
|
|
315
|
+
const {
|
|
316
|
+
tableWithFixedColumnWidthsOption = false
|
|
317
|
+
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
318
|
+
const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, tableWithFixedColumnWidthsOption);
|
|
315
319
|
const wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
|
|
316
320
|
return {
|
|
317
321
|
content: formatMessage(messages.distributeColumns),
|
|
@@ -418,9 +422,10 @@ export class ContextualMenu extends Component {
|
|
|
418
422
|
isTableScalingEnabled = false
|
|
419
423
|
} = getPluginState(state);
|
|
420
424
|
const {
|
|
421
|
-
tableDuplicateCellColouring = false
|
|
425
|
+
tableDuplicateCellColouring = false,
|
|
426
|
+
tableWithFixedColumnWidthsOption = false
|
|
422
427
|
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
423
|
-
const shouldUseIncreasedScalingPercent = isTableScalingEnabled &&
|
|
428
|
+
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && tableWithFixedColumnWidthsOption && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
424
429
|
switch (item.value.name) {
|
|
425
430
|
case 'sort_column_desc':
|
|
426
431
|
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect.left, SortOrder.DESC)(state, dispatch);
|
|
@@ -439,7 +444,7 @@ export class ContextualMenu extends Component {
|
|
|
439
444
|
this.toggleOpen();
|
|
440
445
|
break;
|
|
441
446
|
case 'distribute_columns':
|
|
442
|
-
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
447
|
+
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, tableWithFixedColumnWidthsOption);
|
|
443
448
|
if (newResizeStateWithAnalytics) {
|
|
444
449
|
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, newResizeStateWithAnalytics)(state, dispatch);
|
|
445
450
|
this.toggleOpen();
|
|
@@ -450,7 +455,7 @@ export class ContextualMenu extends Component {
|
|
|
450
455
|
this.toggleOpen();
|
|
451
456
|
break;
|
|
452
457
|
case 'insert_column':
|
|
453
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring, shouldUseIncreasedScalingPercent)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
458
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
454
459
|
this.toggleOpen();
|
|
455
460
|
break;
|
|
456
461
|
case 'insert_row':
|
|
@@ -461,7 +466,7 @@ export class ContextualMenu extends Component {
|
|
|
461
466
|
this.toggleOpen();
|
|
462
467
|
break;
|
|
463
468
|
case 'delete_column':
|
|
464
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch, editorView);
|
|
469
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent)(INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch, editorView);
|
|
465
470
|
this.toggleOpen();
|
|
466
471
|
break;
|
|
467
472
|
case 'delete_row':
|
|
@@ -178,7 +178,8 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
178
178
|
boundariesElement,
|
|
179
179
|
isTableScalingEnabled,
|
|
180
180
|
tableDuplicateCellColouring,
|
|
181
|
-
shouldUseIncreasedScalingPercent
|
|
181
|
+
shouldUseIncreasedScalingPercent,
|
|
182
|
+
isTableFixedColumnWidthsOptionEnabled
|
|
182
183
|
}) => {
|
|
183
184
|
var _pluginConfig$allowBa;
|
|
184
185
|
const {
|
|
@@ -206,7 +207,7 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
206
207
|
hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
207
208
|
}
|
|
208
209
|
const allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
209
|
-
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled, tableDuplicateCellColouring, shouldUseIncreasedScalingPercent);
|
|
210
|
+
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled, tableDuplicateCellColouring, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent);
|
|
210
211
|
const {
|
|
211
212
|
menuItems,
|
|
212
213
|
menuCallback
|
|
@@ -32,9 +32,10 @@ const FloatingDragMenu = ({
|
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
34
|
const {
|
|
35
|
-
tableDuplicateCellColouring = false
|
|
35
|
+
tableDuplicateCellColouring = false,
|
|
36
|
+
tableWithFixedColumnWidthsOption = false
|
|
36
37
|
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
37
|
-
const shouldUseIncreasedScalingPercent = isTableScalingEnabled &&
|
|
38
|
+
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && tableWithFixedColumnWidthsOption && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
38
39
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
39
40
|
alignX: direction === 'row' ? 'right' : undefined,
|
|
40
41
|
alignY: direction === 'row' ? 'start' : undefined,
|
|
@@ -70,7 +71,8 @@ const FloatingDragMenu = ({
|
|
|
70
71
|
scrollableElement: scrollableElement,
|
|
71
72
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
72
73
|
tableDuplicateCellColouring: tableDuplicateCellColouring,
|
|
73
|
-
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent
|
|
74
|
+
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
|
|
75
|
+
isTableFixedColumnWidthsOptionEnabled: tableWithFixedColumnWidthsOption
|
|
74
76
|
}));
|
|
75
77
|
};
|
|
76
78
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -12,7 +12,6 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
12
12
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
13
13
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
14
14
|
import { insertColumnWithAnalytics, insertRowWithAnalytics } from '../../commands-with-analytics';
|
|
15
|
-
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
16
15
|
import { TableCssClassName as ClassName } from '../../types';
|
|
17
16
|
import { checkIfNumberColumnEnabled } from '../../utils';
|
|
18
17
|
import getPopupOptions from './getPopupOptions';
|
|
@@ -178,22 +177,21 @@ export class FloatingInsertButton extends React.Component {
|
|
|
178
177
|
editorView,
|
|
179
178
|
insertColumnButtonIndex,
|
|
180
179
|
editorAnalyticsAPI,
|
|
181
|
-
getEditorFeatureFlags
|
|
180
|
+
getEditorFeatureFlags,
|
|
181
|
+
isTableScalingEnabled
|
|
182
182
|
} = this.props;
|
|
183
183
|
if (typeof insertColumnButtonIndex !== 'undefined') {
|
|
184
184
|
event.preventDefault();
|
|
185
185
|
const {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
189
|
-
const {
|
|
190
|
-
tableDuplicateCellColouring = false
|
|
186
|
+
tableDuplicateCellColouring = false,
|
|
187
|
+
tableWithFixedColumnWidthsOption = false
|
|
191
188
|
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
189
|
+
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && tableWithFixedColumnWidthsOption && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
192
190
|
const {
|
|
193
191
|
state,
|
|
194
192
|
dispatch
|
|
195
193
|
} = editorView;
|
|
196
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring, shouldUseIncreasedScalingPercent)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
194
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
197
|
}
|