@atlaskit/editor-plugin-table 7.16.18 → 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 +8 -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 +3 -2
- 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 +29 -20
- 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 +3 -2
- 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 +25 -22
- 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 +3 -2
- 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 +29 -20
- 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 +2 -5
- 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 +4 -0
- 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 +46 -12
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deleteColumns } from '../transforms/delete-columns';
|
|
2
2
|
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
3
|
-
export const deleteColumnsCommand = (rect, isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) => (state, dispatch, view) => {
|
|
4
|
-
const tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view, isTableScalingEnabled, shouldUseIncreasedScalingPercent)(state.tr);
|
|
3
|
+
export const deleteColumnsCommand = (rect, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => (state, dispatch, view) => {
|
|
4
|
+
const tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(state.tr);
|
|
5
5
|
if (dispatch) {
|
|
6
6
|
dispatch(tr);
|
|
7
7
|
return true;
|
|
@@ -19,7 +19,7 @@ function addColumnAtCustomStep(column) {
|
|
|
19
19
|
return tr;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
export function addColumnAt(isTableScalingEnabled = false, isCellBackgroundDuplicated, shouldUseIncreasedScalingPercent) {
|
|
22
|
+
export function addColumnAt(isTableScalingEnabled = false, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent) {
|
|
23
23
|
return (column, allowAddColumnCustomStep = false, view) => {
|
|
24
24
|
return tr => {
|
|
25
25
|
let updatedTr = tr;
|
|
@@ -31,7 +31,7 @@ export function addColumnAt(isTableScalingEnabled = false, isCellBackgroundDupli
|
|
|
31
31
|
const table = findTable(updatedTr.selection);
|
|
32
32
|
if (table) {
|
|
33
33
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
34
|
-
updatedTr = rescaleColumns(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(table, view)(updatedTr);
|
|
34
|
+
updatedTr = rescaleColumns(isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(table, view)(updatedTr);
|
|
35
35
|
}
|
|
36
36
|
if (view) {
|
|
37
37
|
updatedTr = updateRowOrColumnMovedTransform({
|
|
@@ -48,33 +48,33 @@ export function addColumnAt(isTableScalingEnabled = false, isCellBackgroundDupli
|
|
|
48
48
|
|
|
49
49
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
50
50
|
// Command to add a column before the column with the selection.
|
|
51
|
-
export const addColumnBefore = (isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) => (state, dispatch, view) => {
|
|
51
|
+
export const addColumnBefore = (isTableScalingEnabled = false, isCellBackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => (state, dispatch, view) => {
|
|
52
52
|
const table = findTable(state.selection);
|
|
53
53
|
if (!table) {
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
56
|
if (dispatch) {
|
|
57
57
|
let rect = selectedRect(state);
|
|
58
|
-
dispatch(addColumnAt(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
58
|
+
dispatch(addColumnAt(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
59
59
|
}
|
|
60
60
|
return true;
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
64
64
|
// Command to add a column after the column with the selection.
|
|
65
|
-
export const addColumnAfter = (isTableScalingEnabled, shouldUseIncreasedScalingPercent) => (state, dispatch, view) => {
|
|
65
|
+
export const addColumnAfter = (isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent) => (state, dispatch, view) => {
|
|
66
66
|
const table = findTable(state.selection);
|
|
67
67
|
if (!table) {
|
|
68
68
|
return false;
|
|
69
69
|
}
|
|
70
70
|
if (dispatch) {
|
|
71
71
|
let rect = selectedRect(state);
|
|
72
|
-
dispatch(addColumnAt(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(rect.right, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
72
|
+
dispatch(addColumnAt(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(rect.right, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
73
73
|
}
|
|
74
74
|
return true;
|
|
75
75
|
};
|
|
76
|
-
export const insertColumn = (isTableScalingEnabled = false, isCellBackgroundDuplicated, shouldUseIncreasedScalingPercent) => column => (state, dispatch, view) => {
|
|
77
|
-
let tr = addColumnAt(isTableScalingEnabled, isCellBackgroundDuplicated, shouldUseIncreasedScalingPercent)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
76
|
+
export const insertColumn = (isTableScalingEnabled = false, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent) => column => (state, dispatch, view) => {
|
|
77
|
+
let tr = addColumnAt(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
78
78
|
const table = findTable(tr.selection);
|
|
79
79
|
if (!table) {
|
|
80
80
|
return false;
|
|
@@ -171,7 +171,7 @@ export const insertRowWithAnalytics = (editorAnalyticsAPI, isCellbackgroundDupli
|
|
|
171
171
|
eventType: EVENT_TYPE.TRACK
|
|
172
172
|
};
|
|
173
173
|
})(editorAnalyticsAPI)(insertRow(options.index, options.moveCursorToInsertedRow, isCellbackgroundDuplicated));
|
|
174
|
-
export const changeColumnWidthByStepWithAnalytics = editorAnalyticsAPI => (stepSize, getEditorContainerWidth, isTableScalingEnabled, inputMethod, ariaNotify, getIntl) => withEditorAnalyticsAPI(state => {
|
|
174
|
+
export const changeColumnWidthByStepWithAnalytics = editorAnalyticsAPI => (stepSize, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, inputMethod, ariaNotify, getIntl) => withEditorAnalyticsAPI(state => {
|
|
175
175
|
const {
|
|
176
176
|
table,
|
|
177
177
|
totalRowCount,
|
|
@@ -199,11 +199,12 @@ export const changeColumnWidthByStepWithAnalytics = editorAnalyticsAPI => (stepS
|
|
|
199
199
|
})(editorAnalyticsAPI)(changeColumnWidthByStep({
|
|
200
200
|
stepSize: stepSize,
|
|
201
201
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
202
|
-
isTableScalingEnabled
|
|
202
|
+
isTableScalingEnabled,
|
|
203
|
+
isTableFixedColumnWidthsOptionEnabled,
|
|
203
204
|
ariaNotify: ariaNotify,
|
|
204
205
|
getIntl: getIntl
|
|
205
206
|
}));
|
|
206
|
-
export const insertColumnWithAnalytics = (editorAnalyticsAPI, isTableScalingEnabled = false, isCellbackgroundDuplicated = false, shouldUseIncreasedScalingPercent = false) => (inputMethod, position) => withEditorAnalyticsAPI(state => {
|
|
207
|
+
export const insertColumnWithAnalytics = (editorAnalyticsAPI, isTableScalingEnabled = false, isCellbackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => (inputMethod, position) => withEditorAnalyticsAPI(state => {
|
|
207
208
|
const {
|
|
208
209
|
totalRowCount,
|
|
209
210
|
totalColumnCount
|
|
@@ -220,7 +221,7 @@ export const insertColumnWithAnalytics = (editorAnalyticsAPI, isTableScalingEnab
|
|
|
220
221
|
},
|
|
221
222
|
eventType: EVENT_TYPE.TRACK
|
|
222
223
|
};
|
|
223
|
-
})(editorAnalyticsAPI)(insertColumn(isTableScalingEnabled, isCellbackgroundDuplicated, shouldUseIncreasedScalingPercent)(position));
|
|
224
|
+
})(editorAnalyticsAPI)(insertColumn(isTableScalingEnabled, isCellbackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(position));
|
|
224
225
|
export const deleteRowsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect, isHeaderRowRequired) => withEditorAnalyticsAPI(({
|
|
225
226
|
selection
|
|
226
227
|
}) => {
|
|
@@ -247,7 +248,7 @@ export const deleteRowsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect,
|
|
|
247
248
|
}
|
|
248
249
|
return true;
|
|
249
250
|
});
|
|
250
|
-
export const deleteColumnsWithAnalytics = (editorAnalyticsAPI, isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) => (inputMethod, rect) => withEditorAnalyticsAPI(({
|
|
251
|
+
export const deleteColumnsWithAnalytics = (editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => (inputMethod, rect) => withEditorAnalyticsAPI(({
|
|
251
252
|
selection
|
|
252
253
|
}) => {
|
|
253
254
|
const {
|
|
@@ -267,8 +268,8 @@ export const deleteColumnsWithAnalytics = (editorAnalyticsAPI, isTableScalingEna
|
|
|
267
268
|
},
|
|
268
269
|
eventType: EVENT_TYPE.TRACK
|
|
269
270
|
};
|
|
270
|
-
})(editorAnalyticsAPI)(deleteColumnsCommand(rect, isTableScalingEnabled, shouldUseIncreasedScalingPercent));
|
|
271
|
-
export const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = (editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent) => (state, dispatch) => {
|
|
271
|
+
})(editorAnalyticsAPI)(deleteColumnsCommand(rect, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent));
|
|
272
|
+
export const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = (editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent) => (state, dispatch) => {
|
|
272
273
|
const {
|
|
273
274
|
selection
|
|
274
275
|
} = state;
|
|
@@ -288,7 +289,7 @@ export const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = (editorAnalyt
|
|
|
288
289
|
const isHeaderRowRequired = pluginConfig.isHeaderRowRequired || false;
|
|
289
290
|
return deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, rect, isHeaderRowRequired)(state, dispatch);
|
|
290
291
|
} else if (selectionType === 'column') {
|
|
291
|
-
return deleteColumnsWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.SHORTCUT, rect)(state, dispatch);
|
|
292
|
+
return deleteColumnsWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.SHORTCUT, rect)(state, dispatch);
|
|
292
293
|
} else {
|
|
293
294
|
return false;
|
|
294
295
|
}
|
|
@@ -361,7 +361,7 @@ export function handleTripleClick(view, pos) {
|
|
|
361
361
|
}
|
|
362
362
|
return false;
|
|
363
363
|
}
|
|
364
|
-
export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI, editorView, isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) => {
|
|
364
|
+
export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI, editorView, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => {
|
|
365
365
|
const oldSelection = oldState.tr.selection;
|
|
366
366
|
let {
|
|
367
367
|
tr
|
|
@@ -410,7 +410,7 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI, editorV
|
|
|
410
410
|
} = getPluginState(newState);
|
|
411
411
|
tr = deleteRows(rect, isHeaderRowRequired)(tr);
|
|
412
412
|
} else if (tr.selection.isColSelection()) {
|
|
413
|
-
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView, isTableScalingEnabled, shouldUseIncreasedScalingPercent)(tr);
|
|
413
|
+
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(tr);
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
}
|
|
@@ -344,19 +344,20 @@ class TableComponent extends React.Component {
|
|
|
344
344
|
this === null || this === void 0 ? void 0 : (_this$table = this.table) === null || _this$table === void 0 ? void 0 : _this$table.addEventListener('mouseenter', this.handleMouseEnter);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
|
|
347
|
+
const {
|
|
348
|
+
tableWithFixedColumnWidthsOption = false,
|
|
349
|
+
stickyScrollbar
|
|
350
|
+
} = getEditorFeatureFlags();
|
|
351
|
+
if (isTableScalingEnabled && !tableWithFixedColumnWidthsOption) {
|
|
348
352
|
this.handleColgroupUpdates(true);
|
|
349
353
|
}
|
|
350
|
-
if (isTableScalingEnabled &&
|
|
354
|
+
if (isTableScalingEnabled && tableWithFixedColumnWidthsOption && getNode().attrs.displayMode !== 'fixed') {
|
|
351
355
|
this.handleColgroupUpdates(true);
|
|
352
356
|
}
|
|
353
357
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
354
358
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
355
359
|
passive: true
|
|
356
360
|
});
|
|
357
|
-
const {
|
|
358
|
-
stickyScrollbar
|
|
359
|
-
} = getEditorFeatureFlags();
|
|
360
361
|
if (stickyScrollbar) {
|
|
361
362
|
if (this.table) {
|
|
362
363
|
this.stickyScrollbar = new TableStickyScrollbar(this.wrapper, this.props.view);
|
|
@@ -441,7 +442,8 @@ class TableComponent extends React.Component {
|
|
|
441
442
|
containerWidth,
|
|
442
443
|
isResizing,
|
|
443
444
|
view,
|
|
444
|
-
getPos
|
|
445
|
+
getPos,
|
|
446
|
+
getEditorFeatureFlags
|
|
445
447
|
} = this.props;
|
|
446
448
|
if (!this.table) {
|
|
447
449
|
return;
|
|
@@ -475,8 +477,11 @@ class TableComponent extends React.Component {
|
|
|
475
477
|
const isColumnsDistributed = wasTableResized && !isTableResized;
|
|
476
478
|
const isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
477
479
|
const shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
+
const {
|
|
481
|
+
tableWithFixedColumnWidthsOption = false
|
|
482
|
+
} = getEditorFeatureFlags();
|
|
483
|
+
const isTableScalingWithFixedColumnWidthsOptionEnabled = ((_this$props$options = this.props.options) === null || _this$props$options === void 0 ? void 0 : _this$props$options.isTableScalingEnabled) && tableWithFixedColumnWidthsOption;
|
|
484
|
+
const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && getBooleanFF('platform.editor.table.use-increased-scaling-percent') || false;
|
|
480
485
|
if (force || !isResizing && shouldUpdateColgroup) {
|
|
481
486
|
var _this$props$options2;
|
|
482
487
|
const resizeState = getResizeState({
|
|
@@ -490,10 +495,10 @@ class TableComponent extends React.Component {
|
|
|
490
495
|
shouldUseIncreasedScalingPercent
|
|
491
496
|
});
|
|
492
497
|
let shouldScaleOnColgroupUpdate = false;
|
|
493
|
-
if ((_this$props$options2 = this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isTableScalingEnabled && !
|
|
498
|
+
if ((_this$props$options2 = this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isTableScalingEnabled && !tableWithFixedColumnWidthsOption) {
|
|
494
499
|
shouldScaleOnColgroupUpdate = true;
|
|
495
500
|
}
|
|
496
|
-
if (
|
|
501
|
+
if (isTableScalingWithFixedColumnWidthsOptionEnabled && tableNode.attrs.displayMode !== 'fixed') {
|
|
497
502
|
shouldScaleOnColgroupUpdate = true;
|
|
498
503
|
}
|
|
499
504
|
|
|
@@ -518,7 +523,8 @@ class TableComponent extends React.Component {
|
|
|
518
523
|
options,
|
|
519
524
|
isTableScalingEnabled,
|
|
520
525
|
// we could use options.isTableScalingEnabled here
|
|
521
|
-
getPos
|
|
526
|
+
getPos,
|
|
527
|
+
getEditorFeatureFlags
|
|
522
528
|
} = this.props;
|
|
523
529
|
let {
|
|
524
530
|
isInDanger
|
|
@@ -530,13 +536,16 @@ class TableComponent extends React.Component {
|
|
|
530
536
|
}
|
|
531
537
|
let shouldScale = false;
|
|
532
538
|
let shouldHandleColgroupUpdates = false;
|
|
533
|
-
|
|
539
|
+
const {
|
|
540
|
+
tableWithFixedColumnWidthsOption = false
|
|
541
|
+
} = getEditorFeatureFlags();
|
|
542
|
+
if (isTableScalingEnabled && !tableWithFixedColumnWidthsOption) {
|
|
534
543
|
shouldScale = true;
|
|
535
544
|
shouldHandleColgroupUpdates = true;
|
|
536
545
|
}
|
|
537
|
-
const
|
|
538
|
-
const shouldUseIncreasedScalingPercent =
|
|
539
|
-
if (
|
|
546
|
+
const isTableScalingWithFixedColumnWidthsOptionEnabled = isTableScalingEnabled && tableWithFixedColumnWidthsOption;
|
|
547
|
+
const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
548
|
+
if (isTableScalingWithFixedColumnWidthsOptionEnabled && getNode().attrs.displayMode !== 'fixed') {
|
|
540
549
|
shouldScale = true;
|
|
541
550
|
shouldHandleColgroupUpdates = true;
|
|
542
551
|
}
|
|
@@ -743,9 +752,10 @@ class TableComponent extends React.Component {
|
|
|
743
752
|
const isNested = isTableNested(view.state, tablePos);
|
|
744
753
|
const topStickyShadowPosition = isDragAndDropEnabled ? this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + 2 : this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2;
|
|
745
754
|
const {
|
|
746
|
-
stickyScrollbar
|
|
755
|
+
stickyScrollbar,
|
|
756
|
+
tableWithFixedColumnWidthsOption = false
|
|
747
757
|
} = getEditorFeatureFlags();
|
|
748
|
-
const shouldUseIncreasedScalingPercent = isTableScalingEnabled &&
|
|
758
|
+
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && tableWithFixedColumnWidthsOption && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
749
759
|
return /*#__PURE__*/React.createElement(TableContainer
|
|
750
760
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
751
761
|
, {
|
|
@@ -766,6 +776,7 @@ class TableComponent extends React.Component {
|
|
|
766
776
|
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
|
|
767
777
|
isResizing: isResizing,
|
|
768
778
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
779
|
+
isTableWithFixedColumnWidthsOptionEnabled: tableWithFixedColumnWidthsOption,
|
|
769
780
|
isWholeTableInDanger: isWholeTableInDanger,
|
|
770
781
|
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
771
782
|
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent
|
|
@@ -123,6 +123,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
123
123
|
tableWrapperHeight,
|
|
124
124
|
isWholeTableInDanger,
|
|
125
125
|
isTableScalingEnabled,
|
|
126
|
+
isTableWithFixedColumnWidthsOptionEnabled,
|
|
126
127
|
isTableAlignmentEnabled,
|
|
127
128
|
shouldUseIncreasedScalingPercent
|
|
128
129
|
}) => {
|
|
@@ -231,6 +232,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
231
232
|
isTableAlignmentEnabled,
|
|
232
233
|
isFullWidthModeEnabled,
|
|
233
234
|
isTableScalingEnabled,
|
|
235
|
+
isTableWithFixedColumnWidthsOptionEnabled,
|
|
234
236
|
isWholeTableInDanger,
|
|
235
237
|
shouldUseIncreasedScalingPercent,
|
|
236
238
|
pluginInjectionApi,
|
|
@@ -287,6 +289,7 @@ export const TableContainer = ({
|
|
|
287
289
|
isWholeTableInDanger,
|
|
288
290
|
isTableResizingEnabled,
|
|
289
291
|
isTableScalingEnabled,
|
|
292
|
+
isTableWithFixedColumnWidthsOptionEnabled,
|
|
290
293
|
isTableAlignmentEnabled,
|
|
291
294
|
shouldUseIncreasedScalingPercent
|
|
292
295
|
}) => {
|
|
@@ -305,6 +308,7 @@ export const TableContainer = ({
|
|
|
305
308
|
isResizing: isResizing,
|
|
306
309
|
pluginInjectionApi: pluginInjectionApi,
|
|
307
310
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
311
|
+
isTableWithFixedColumnWidthsOptionEnabled: isTableWithFixedColumnWidthsOptionEnabled,
|
|
308
312
|
isWholeTableInDanger: isWholeTableInDanger,
|
|
309
313
|
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
310
314
|
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent
|
|
@@ -105,6 +105,7 @@ export const TableResizer = ({
|
|
|
105
105
|
attachAnalyticsEvent,
|
|
106
106
|
displayGapCursor,
|
|
107
107
|
isTableScalingEnabled,
|
|
108
|
+
isTableWithFixedColumnWidthsOptionEnabled,
|
|
108
109
|
isTableAlignmentEnabled,
|
|
109
110
|
isWholeTableInDanger,
|
|
110
111
|
shouldUseIncreasedScalingPercent,
|
|
@@ -236,7 +237,7 @@ export const TableResizer = ({
|
|
|
236
237
|
prevNode: node,
|
|
237
238
|
start: pos + 1,
|
|
238
239
|
parentWidth: newWidth
|
|
239
|
-
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled);
|
|
240
|
+
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled, isTableWithFixedColumnWidthsOptionEnabled);
|
|
240
241
|
const editorContainerWidth = isFullWidthModeEnabled ? lineLength + 2 * akEditorGutterPaddingDynamic() : containerWidth;
|
|
241
242
|
const closestSnap = findClosestSnap(newWidth, isTableScalingEnabled ? defaultTablePreserveSnappingWidths(PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET, editorContainerWidth, excludeGuidelineConfig) : defaultSnappingWidths, isTableScalingEnabled ? defaultGuidelinesForPreserveTable(PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, editorContainerWidth, excludeGuidelineConfig) : defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE);
|
|
242
243
|
updateActiveGuidelines(closestSnap);
|
|
@@ -257,7 +258,7 @@ export const TableResizer = ({
|
|
|
257
258
|
}))(state, dispatch);
|
|
258
259
|
updateWidth(shouldUpdateWidthToWidest ? TABLE_MAX_WIDTH : newWidth);
|
|
259
260
|
return newWidth;
|
|
260
|
-
}, [countFrames, isTableScalingEnabled, isFullWidthModeEnabled, excludeGuidelineConfig, tableRef, node, editorView, updateActiveGuidelines, containerWidth, lineLength, updateWidth, getPos, switchToCenterAlignment]);
|
|
261
|
+
}, [countFrames, isTableScalingEnabled, isTableWithFixedColumnWidthsOptionEnabled, isFullWidthModeEnabled, excludeGuidelineConfig, tableRef, node, editorView, updateActiveGuidelines, containerWidth, lineLength, updateWidth, getPos, switchToCenterAlignment]);
|
|
261
262
|
const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
|
|
262
263
|
const handleResizeStop = useCallback((originalState, delta) => {
|
|
263
264
|
var _node$attrs$localId2, _node$attrs2;
|
|
@@ -61,13 +61,14 @@ export default class TableView extends ReactNodeView {
|
|
|
61
61
|
this.getPos = props.getPos;
|
|
62
62
|
this.eventDispatcher = props.eventDispatcher;
|
|
63
63
|
this.options = props.options;
|
|
64
|
+
this.getEditorFeatureFlags = props.getEditorFeatureFlags;
|
|
64
65
|
}
|
|
65
66
|
getContentDOM() {
|
|
66
67
|
const rendered = DOMSerializer.renderSpec(document, toDOM(this.node, this.reactComponentProps));
|
|
67
68
|
if (rendered.dom) {
|
|
68
|
-
var _this$options, _this$options2;
|
|
69
|
+
var _this$options, _this$options2, _this$getEditorFeatur;
|
|
69
70
|
this.table = rendered.dom;
|
|
70
|
-
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.isTableScalingEnabled) || (_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.isTableScalingEnabled &&
|
|
71
|
+
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.isTableScalingEnabled) || (_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.isTableScalingEnabled && (_this$getEditorFeatur = this.getEditorFeatureFlags) !== null && _this$getEditorFeatur !== void 0 && _this$getEditorFeatur.call(this).tableWithFixedColumnWidthsOption && this.node.attrs.displayMode === 'fixed') {
|
|
71
72
|
const tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos());
|
|
72
73
|
if (tableInlineWidth) {
|
|
73
74
|
handleInlineTableWidth(this.table, tableInlineWidth);
|
|
@@ -77,7 +78,7 @@ export default class TableView extends ReactNodeView {
|
|
|
77
78
|
return rendered;
|
|
78
79
|
}
|
|
79
80
|
setDomAttrs(node) {
|
|
80
|
-
var _this$options3, _this$options4;
|
|
81
|
+
var _this$options3, _this$options4, _this$getEditorFeatur2;
|
|
81
82
|
if (!this.table) {
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
@@ -87,7 +88,7 @@ export default class TableView extends ReactNodeView {
|
|
|
87
88
|
});
|
|
88
89
|
|
|
89
90
|
// Preserve Table Width cannot have inline width set on the table
|
|
90
|
-
if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.isTableScalingEnabled) || (_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.isTableScalingEnabled &&
|
|
91
|
+
if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.isTableScalingEnabled) || (_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.isTableScalingEnabled && (_this$getEditorFeatur2 = this.getEditorFeatureFlags) !== null && _this$getEditorFeatur2 !== void 0 && _this$getEditorFeatur2.call(this).tableWithFixedColumnWidthsOption && node.attrs.displayMode === 'fixed') {
|
|
91
92
|
var _tableWidthPluginKey$;
|
|
92
93
|
// handle inline style when table been resized
|
|
93
94
|
const tableInlineWidth = getInlineWidth(node, this.reactComponentProps.options, this.view.state, this.getPos());
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -50,7 +50,7 @@ const tablesPlugin = ({
|
|
|
50
50
|
config: options,
|
|
51
51
|
api
|
|
52
52
|
}) => {
|
|
53
|
-
var _api$analytics, _api$analytics2;
|
|
53
|
+
var _api$analytics, _options$getEditorFea, _options$getEditorFea2, _api$analytics2;
|
|
54
54
|
const editorViewRef = {
|
|
55
55
|
current: null
|
|
56
56
|
};
|
|
@@ -61,8 +61,10 @@ const tablesPlugin = ({
|
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
63
|
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
64
|
-
const
|
|
65
|
-
const shouldUseIncreasedScalingPercent =
|
|
64
|
+
const isTableFixedColumnWidthsOptionEnabled = (options === null || options === void 0 ? void 0 : (_options$getEditorFea = options.getEditorFeatureFlags) === null || _options$getEditorFea === void 0 ? void 0 : _options$getEditorFea.call(options).tableWithFixedColumnWidthsOption) || false;
|
|
65
|
+
const shouldUseIncreasedScalingPercent = options === null || options === void 0 ? void 0 : options.isTableScalingEnabled;
|
|
66
|
+
isTableFixedColumnWidthsOptionEnabled && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
67
|
+
const isCellBackgroundDuplicated = (options === null || options === void 0 ? void 0 : (_options$getEditorFea2 = options.getEditorFeatureFlags) === null || _options$getEditorFea2 === void 0 ? void 0 : _options$getEditorFea2.call(options).tableDuplicateCellColouring) || false;
|
|
66
68
|
return {
|
|
67
69
|
name: 'table',
|
|
68
70
|
// Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
|
|
@@ -193,7 +195,7 @@ const tablesPlugin = ({
|
|
|
193
195
|
isTableAlignmentEnabled = false,
|
|
194
196
|
fullWidthEnabled = false
|
|
195
197
|
} = options || {};
|
|
196
|
-
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, isTableAlignmentEnabled, fullWidthEnabled, api, getIntl, shouldUseIncreasedScalingPercent);
|
|
198
|
+
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, isTableAlignmentEnabled, fullWidthEnabled, api, getIntl, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent);
|
|
197
199
|
}
|
|
198
200
|
}, {
|
|
199
201
|
name: 'tableSelectionKeymap',
|
|
@@ -233,7 +235,7 @@ const tablesPlugin = ({
|
|
|
233
235
|
plugin: ({
|
|
234
236
|
dispatch
|
|
235
237
|
}) => {
|
|
236
|
-
return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, editorAnalyticsAPI) : undefined;
|
|
238
|
+
return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled) : undefined;
|
|
237
239
|
}
|
|
238
240
|
}, {
|
|
239
241
|
name: 'tableViewModeSort',
|
|
@@ -369,6 +371,7 @@ const tablesPlugin = ({
|
|
|
369
371
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
370
372
|
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
371
373
|
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
374
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
372
375
|
editorView: editorView,
|
|
373
376
|
mountPoint: popupsMountPoint,
|
|
374
377
|
boundariesElement: popupsBoundariesElement,
|
|
@@ -461,7 +464,7 @@ const tablesPlugin = ({
|
|
|
461
464
|
return tr;
|
|
462
465
|
}
|
|
463
466
|
}],
|
|
464
|
-
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options,
|
|
467
|
+
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
465
468
|
}
|
|
466
469
|
};
|
|
467
470
|
};
|
|
@@ -18,7 +18,7 @@ import { DropTargetType } from './consts';
|
|
|
18
18
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
19
19
|
import { pluginKey } from './plugin-key';
|
|
20
20
|
import { getDraggableDataFromEvent } from './utils/monitor';
|
|
21
|
-
const destroyFn = (editorView, editorAnalyticsAPI) => {
|
|
21
|
+
const destroyFn = (editorView, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled) => {
|
|
22
22
|
const editorPageScrollContainer = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
23
23
|
const rowAutoScrollers = editorPageScrollContainer ? [monitorForElements({
|
|
24
24
|
canMonitor({
|
|
@@ -168,16 +168,13 @@ const destroyFn = (editorView, editorAnalyticsAPI) => {
|
|
|
168
168
|
tableNode
|
|
169
169
|
} = getTablePluginState(editorView.state);
|
|
170
170
|
if (tableRef && tableNode) {
|
|
171
|
-
const {
|
|
172
|
-
isTableScalingEnabled = false
|
|
173
|
-
} = getTablePluginState(editorView.state);
|
|
174
171
|
let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
if (isTableScalingEnabledWithLockButton) {
|
|
172
|
+
const isTableScalingWithFixedColumnWidthsOptionEnabled = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled;
|
|
173
|
+
if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
|
|
178
174
|
isTableScalingEnabledOnCurrentTable = tableNode.attrs.displayMode !== 'fixed';
|
|
179
175
|
}
|
|
180
|
-
|
|
176
|
+
const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
177
|
+
insertColgroupFromNode(tableRef, tableNode, isTableScalingEnabledOnCurrentTable, undefined, shouldUseIncreasedScalingPercent);
|
|
181
178
|
}
|
|
182
179
|
}
|
|
183
180
|
editorView.focus();
|
|
@@ -185,7 +182,7 @@ const destroyFn = (editorView, editorAnalyticsAPI) => {
|
|
|
185
182
|
}
|
|
186
183
|
}));
|
|
187
184
|
};
|
|
188
|
-
export const createPlugin = (dispatch, editorAnalyticsAPI) => {
|
|
185
|
+
export const createPlugin = (dispatch, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false) => {
|
|
189
186
|
return new SafePlugin({
|
|
190
187
|
state: createPluginState(dispatch, state => ({
|
|
191
188
|
decorationSet: DecorationSet.empty,
|
|
@@ -254,7 +251,7 @@ export const createPlugin = (dispatch, editorAnalyticsAPI) => {
|
|
|
254
251
|
},
|
|
255
252
|
view: editorView => {
|
|
256
253
|
return {
|
|
257
|
-
destroy: destroyFn(editorView, editorAnalyticsAPI)
|
|
254
|
+
destroy: destroyFn(editorView, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled)
|
|
258
255
|
};
|
|
259
256
|
},
|
|
260
257
|
props: {
|
|
@@ -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;
|