@atlaskit/editor-plugin-table 7.16.14 → 7.16.16
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 +16 -0
- package/dist/cjs/commands/column-resize.js +6 -3
- package/dist/cjs/commands/delete.js +2 -1
- package/dist/cjs/commands/insert.js +8 -5
- package/dist/cjs/commands-with-analytics.js +6 -4
- package/dist/cjs/event-handlers.js +2 -1
- package/dist/cjs/nodeviews/TableComponent.js +21 -10
- package/dist/cjs/nodeviews/TableContainer.js +7 -3
- package/dist/cjs/nodeviews/TableResizer.js +3 -2
- package/dist/cjs/plugin.js +4 -3
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +4 -2
- package/dist/cjs/pm-plugins/keymap.js +5 -4
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -7
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +6 -5
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +2 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +6 -0
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +6 -4
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +5 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +13 -8
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +17 -9
- package/dist/cjs/toolbar.js +7 -4
- package/dist/cjs/transforms/column-width.js +3 -1
- package/dist/cjs/transforms/delete-columns.js +2 -1
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +4 -2
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +4 -1
- package/dist/cjs/ui/FloatingInsertButton/index.js +3 -1
- package/dist/cjs/ui/TableFloatingControls/index.js +2 -2
- package/dist/cjs/utils/drag-menu.js +2 -1
- package/dist/es2019/commands/column-resize.js +6 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +8 -8
- package/dist/es2019/commands-with-analytics.js +6 -6
- package/dist/es2019/event-handlers.js +2 -2
- package/dist/es2019/nodeviews/TableComponent.js +21 -10
- package/dist/es2019/nodeviews/TableContainer.js +7 -3
- package/dist/es2019/nodeviews/TableResizer.js +3 -2
- package/dist/es2019/plugin.js +4 -3
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +4 -2
- package/dist/es2019/pm-plugins/keymap.js +5 -5
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +12 -7
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +6 -6
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +1 -0
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +7 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +5 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -8
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +17 -12
- package/dist/es2019/toolbar.js +7 -7
- package/dist/es2019/transforms/column-width.js +3 -2
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +4 -2
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +4 -1
- package/dist/es2019/ui/FloatingInsertButton/index.js +3 -1
- package/dist/es2019/ui/TableFloatingControls/index.js +2 -2
- package/dist/es2019/utils/drag-menu.js +2 -2
- package/dist/esm/commands/column-resize.js +6 -3
- package/dist/esm/commands/delete.js +2 -1
- package/dist/esm/commands/insert.js +8 -5
- package/dist/esm/commands-with-analytics.js +6 -4
- package/dist/esm/event-handlers.js +2 -1
- package/dist/esm/nodeviews/TableComponent.js +21 -10
- package/dist/esm/nodeviews/TableContainer.js +7 -3
- package/dist/esm/nodeviews/TableResizer.js +3 -2
- package/dist/esm/plugin.js +4 -3
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +4 -2
- package/dist/esm/pm-plugins/keymap.js +5 -4
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -7
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +6 -5
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +1 -0
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +7 -5
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +5 -3
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -8
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +17 -9
- package/dist/esm/toolbar.js +7 -4
- package/dist/esm/transforms/column-width.js +3 -1
- package/dist/esm/transforms/delete-columns.js +2 -1
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +4 -2
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +4 -1
- package/dist/esm/ui/FloatingInsertButton/index.js +3 -1
- package/dist/esm/ui/TableFloatingControls/index.js +2 -2
- package/dist/esm/utils/drag-menu.js +2 -1
- package/dist/types/commands/delete.d.ts +1 -1
- package/dist/types/commands/insert.d.ts +4 -4
- package/dist/types/commands-with-analytics.d.ts +3 -3
- package/dist/types/event-handlers.d.ts +1 -1
- package/dist/types/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +3 -2
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
- package/dist/types/toolbar.d.ts +2 -2
- package/dist/types/transforms/column-width.d.ts +1 -1
- package/dist/types/transforms/delete-columns.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/delete.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +4 -4
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -3
- package/dist/types-ts4.5/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +3 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
- package/dist/types-ts4.5/toolbar.d.ts +2 -2
- package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
- package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +8 -2
- package/src/commands/column-resize.ts +9 -3
- package/src/commands/delete.ts +2 -1
- package/src/commands/insert.ts +31 -12
- package/src/commands-with-analytics.ts +24 -8
- package/src/event-handlers.ts +2 -0
- package/src/nodeviews/TableComponent.tsx +41 -12
- package/src/nodeviews/TableContainer.tsx +6 -0
- package/src/nodeviews/TableResizer.tsx +4 -0
- package/src/plugin.tsx +9 -0
- package/src/pm-plugins/drag-and-drop/plugin.ts +13 -4
- package/src/pm-plugins/keymap.ts +17 -4
- package/src/pm-plugins/main.ts +2 -0
- package/src/pm-plugins/table-resizing/event-handlers.ts +21 -10
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +14 -4
- package/src/pm-plugins/table-resizing/utils/consts.ts +1 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +1 -0
- package/src/pm-plugins/table-resizing/utils/misc.ts +24 -5
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +11 -4
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +17 -6
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +32 -9
- package/src/toolbar.tsx +15 -9
- package/src/transforms/column-width.ts +2 -1
- package/src/transforms/delete-columns.ts +11 -2
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +12 -5
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -0
- package/src/ui/FloatingDragMenu/index.tsx +7 -0
- package/src/ui/FloatingInsertButton/index.tsx +7 -0
- package/src/ui/TableFloatingControls/index.tsx +18 -16
- package/src/utils/drag-menu.ts +2 -0
package/src/commands/delete.ts
CHANGED
|
@@ -5,13 +5,14 @@ import { deleteColumns } from '../transforms/delete-columns';
|
|
|
5
5
|
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
6
6
|
|
|
7
7
|
export const deleteColumnsCommand =
|
|
8
|
-
(rect: Rect, isTableScalingEnabled = false): Command =>
|
|
8
|
+
(rect: Rect, isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false): Command =>
|
|
9
9
|
(state, dispatch, view) => {
|
|
10
10
|
const tr = deleteColumns(
|
|
11
11
|
rect,
|
|
12
12
|
getAllowAddColumnCustomStep(state),
|
|
13
13
|
view,
|
|
14
14
|
isTableScalingEnabled,
|
|
15
|
+
shouldUseIncreasedScalingPercent,
|
|
15
16
|
)(state.tr);
|
|
16
17
|
if (dispatch) {
|
|
17
18
|
dispatch(tr);
|
package/src/commands/insert.ts
CHANGED
|
@@ -38,7 +38,11 @@ function addColumnAtCustomStep(column: number) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export function addColumnAt(
|
|
41
|
+
export function addColumnAt(
|
|
42
|
+
isTableScalingEnabled = false,
|
|
43
|
+
isCellBackgroundDuplicated?: boolean,
|
|
44
|
+
shouldUseIncreasedScalingPercent?: boolean,
|
|
45
|
+
) {
|
|
42
46
|
return (
|
|
43
47
|
column: number,
|
|
44
48
|
allowAddColumnCustomStep: boolean = false,
|
|
@@ -54,7 +58,10 @@ export function addColumnAt(isTableScalingEnabled = false, isCellBackgroundDupli
|
|
|
54
58
|
const table = findTable(updatedTr.selection);
|
|
55
59
|
if (table) {
|
|
56
60
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
57
|
-
updatedTr = rescaleColumns(isTableScalingEnabled
|
|
61
|
+
updatedTr = rescaleColumns(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(
|
|
62
|
+
table,
|
|
63
|
+
view,
|
|
64
|
+
)(updatedTr);
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
if (view) {
|
|
@@ -76,7 +83,7 @@ export function addColumnAt(isTableScalingEnabled = false, isCellBackgroundDupli
|
|
|
76
83
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
77
84
|
// Command to add a column before the column with the selection.
|
|
78
85
|
export const addColumnBefore =
|
|
79
|
-
(isTableScalingEnabled = false): Command =>
|
|
86
|
+
(isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false): Command =>
|
|
80
87
|
(state, dispatch, view) => {
|
|
81
88
|
const table = findTable(state.selection);
|
|
82
89
|
if (!table) {
|
|
@@ -85,9 +92,11 @@ export const addColumnBefore =
|
|
|
85
92
|
if (dispatch) {
|
|
86
93
|
let rect = selectedRect(state);
|
|
87
94
|
dispatch(
|
|
88
|
-
addColumnAt(isTableScalingEnabled
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
addColumnAt(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(
|
|
96
|
+
rect.left,
|
|
97
|
+
getAllowAddColumnCustomStep(state),
|
|
98
|
+
view,
|
|
99
|
+
)(state.tr),
|
|
91
100
|
);
|
|
92
101
|
}
|
|
93
102
|
return true;
|
|
@@ -96,7 +105,7 @@ export const addColumnBefore =
|
|
|
96
105
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
97
106
|
// Command to add a column after the column with the selection.
|
|
98
107
|
export const addColumnAfter =
|
|
99
|
-
(isTableScalingEnabled?: boolean): Command =>
|
|
108
|
+
(isTableScalingEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean): Command =>
|
|
100
109
|
(state, dispatch, view) => {
|
|
101
110
|
const table = findTable(state.selection);
|
|
102
111
|
if (!table) {
|
|
@@ -105,19 +114,29 @@ export const addColumnAfter =
|
|
|
105
114
|
if (dispatch) {
|
|
106
115
|
let rect = selectedRect(state);
|
|
107
116
|
dispatch(
|
|
108
|
-
addColumnAt(isTableScalingEnabled
|
|
109
|
-
|
|
110
|
-
|
|
117
|
+
addColumnAt(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(
|
|
118
|
+
rect.right,
|
|
119
|
+
getAllowAddColumnCustomStep(state),
|
|
120
|
+
view,
|
|
121
|
+
)(state.tr),
|
|
111
122
|
);
|
|
112
123
|
}
|
|
113
124
|
return true;
|
|
114
125
|
};
|
|
115
126
|
|
|
116
127
|
export const insertColumn =
|
|
117
|
-
(
|
|
128
|
+
(
|
|
129
|
+
isTableScalingEnabled = false,
|
|
130
|
+
isCellBackgroundDuplicated?: boolean,
|
|
131
|
+
shouldUseIncreasedScalingPercent?: boolean,
|
|
132
|
+
) =>
|
|
118
133
|
(column: number): Command =>
|
|
119
134
|
(state, dispatch, view) => {
|
|
120
|
-
let tr = addColumnAt(
|
|
135
|
+
let tr = addColumnAt(
|
|
136
|
+
isTableScalingEnabled,
|
|
137
|
+
isCellBackgroundDuplicated,
|
|
138
|
+
shouldUseIncreasedScalingPercent,
|
|
139
|
+
)(
|
|
121
140
|
column,
|
|
122
141
|
getAllowAddColumnCustomStep(state),
|
|
123
142
|
view,
|
|
@@ -276,6 +276,7 @@ export const insertColumnWithAnalytics =
|
|
|
276
276
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
277
277
|
isTableScalingEnabled = false,
|
|
278
278
|
isCellbackgroundDuplicated = false,
|
|
279
|
+
shouldUseIncreasedScalingPercent = false,
|
|
279
280
|
) =>
|
|
280
281
|
(
|
|
281
282
|
inputMethod:
|
|
@@ -301,7 +302,11 @@ export const insertColumnWithAnalytics =
|
|
|
301
302
|
eventType: EVENT_TYPE.TRACK,
|
|
302
303
|
};
|
|
303
304
|
})(editorAnalyticsAPI)(
|
|
304
|
-
insertColumn(
|
|
305
|
+
insertColumn(
|
|
306
|
+
isTableScalingEnabled,
|
|
307
|
+
isCellbackgroundDuplicated,
|
|
308
|
+
shouldUseIncreasedScalingPercent,
|
|
309
|
+
)(position),
|
|
305
310
|
);
|
|
306
311
|
|
|
307
312
|
export const deleteRowsWithAnalytics =
|
|
@@ -340,7 +345,11 @@ export const deleteRowsWithAnalytics =
|
|
|
340
345
|
});
|
|
341
346
|
|
|
342
347
|
export const deleteColumnsWithAnalytics =
|
|
343
|
-
(
|
|
348
|
+
(
|
|
349
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
350
|
+
isTableScalingEnabled = false,
|
|
351
|
+
shouldUseIncreasedScalingPercent = false,
|
|
352
|
+
) =>
|
|
344
353
|
(
|
|
345
354
|
inputMethod:
|
|
346
355
|
| INPUT_METHOD.CONTEXT_MENU
|
|
@@ -366,10 +375,16 @@ export const deleteColumnsWithAnalytics =
|
|
|
366
375
|
},
|
|
367
376
|
eventType: EVENT_TYPE.TRACK,
|
|
368
377
|
};
|
|
369
|
-
})(editorAnalyticsAPI)(
|
|
378
|
+
})(editorAnalyticsAPI)(
|
|
379
|
+
deleteColumnsCommand(rect, isTableScalingEnabled, shouldUseIncreasedScalingPercent),
|
|
380
|
+
);
|
|
370
381
|
|
|
371
382
|
export const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut =
|
|
372
|
-
(
|
|
383
|
+
(
|
|
384
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
385
|
+
isTableScalingEnabled?: boolean,
|
|
386
|
+
shouldUseIncreasedScalingPercent?: boolean,
|
|
387
|
+
): Command =>
|
|
373
388
|
(state, dispatch) => {
|
|
374
389
|
const { selection } = state;
|
|
375
390
|
const isCellSelection = selection instanceof CellSelection;
|
|
@@ -393,10 +408,11 @@ export const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut =
|
|
|
393
408
|
isHeaderRowRequired,
|
|
394
409
|
)(state, dispatch);
|
|
395
410
|
} else if (selectionType === 'column') {
|
|
396
|
-
return deleteColumnsWithAnalytics(
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
411
|
+
return deleteColumnsWithAnalytics(
|
|
412
|
+
editorAnalyticsAPI,
|
|
413
|
+
isTableScalingEnabled,
|
|
414
|
+
shouldUseIncreasedScalingPercent,
|
|
415
|
+
)(INPUT_METHOD.SHORTCUT, rect)(state, dispatch);
|
|
400
416
|
} else {
|
|
401
417
|
return false;
|
|
402
418
|
}
|
package/src/event-handlers.ts
CHANGED
|
@@ -477,6 +477,7 @@ export const handleCut = (
|
|
|
477
477
|
editorAnalyticsAPI?: EditorAnalyticsAPI,
|
|
478
478
|
editorView?: EditorView,
|
|
479
479
|
isTableScalingEnabled = false,
|
|
480
|
+
shouldUseIncreasedScalingPercent = false,
|
|
480
481
|
): Transaction => {
|
|
481
482
|
const oldSelection = oldState.tr.selection;
|
|
482
483
|
let { tr } = newState;
|
|
@@ -524,6 +525,7 @@ export const handleCut = (
|
|
|
524
525
|
getAllowAddColumnCustomStep(oldState),
|
|
525
526
|
editorView,
|
|
526
527
|
isTableScalingEnabled,
|
|
528
|
+
shouldUseIncreasedScalingPercent,
|
|
527
529
|
)(tr);
|
|
528
530
|
}
|
|
529
531
|
}
|
|
@@ -383,6 +383,15 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
383
383
|
isNumberColumnChanged ||
|
|
384
384
|
isNumberOfColumnsChanged;
|
|
385
385
|
|
|
386
|
+
const isTableScalingEnabledWithLockButton =
|
|
387
|
+
this.props.options?.isTableScalingEnabled &&
|
|
388
|
+
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
|
|
389
|
+
|
|
390
|
+
const shouldUseIncreasedScalingPercent =
|
|
391
|
+
(isTableScalingEnabledWithLockButton &&
|
|
392
|
+
getBooleanFF('platform.editor.table.use-increased-scaling-percent')) ||
|
|
393
|
+
false;
|
|
394
|
+
|
|
386
395
|
if (force || (!isResizing && shouldUpdateColgroup)) {
|
|
387
396
|
const resizeState = getResizeState({
|
|
388
397
|
minWidth: COLUMN_MIN_WIDTH,
|
|
@@ -392,6 +401,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
392
401
|
start,
|
|
393
402
|
domAtPos: view.domAtPos.bind(view),
|
|
394
403
|
isTableScalingEnabled: true,
|
|
404
|
+
shouldUseIncreasedScalingPercent,
|
|
395
405
|
});
|
|
396
406
|
|
|
397
407
|
let shouldScaleOnColgroupUpdate = false;
|
|
@@ -402,17 +412,19 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
402
412
|
shouldScaleOnColgroupUpdate = true;
|
|
403
413
|
}
|
|
404
414
|
|
|
405
|
-
if (
|
|
406
|
-
this.props.options?.isTableScalingEnabled &&
|
|
407
|
-
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
|
|
408
|
-
tableNode.attrs.displayMode !== 'fixed'
|
|
409
|
-
) {
|
|
415
|
+
if (isTableScalingEnabledWithLockButton && tableNode.attrs.displayMode !== 'fixed') {
|
|
410
416
|
shouldScaleOnColgroupUpdate = true;
|
|
411
417
|
}
|
|
412
418
|
|
|
413
419
|
// Request animation frame required for Firefox
|
|
414
420
|
requestAnimationFrame(() => {
|
|
415
|
-
updateColgroup(
|
|
421
|
+
updateColgroup(
|
|
422
|
+
resizeState,
|
|
423
|
+
this.table!,
|
|
424
|
+
tableNode,
|
|
425
|
+
shouldScaleOnColgroupUpdate,
|
|
426
|
+
shouldUseIncreasedScalingPercent,
|
|
427
|
+
);
|
|
416
428
|
});
|
|
417
429
|
}
|
|
418
430
|
}
|
|
@@ -452,11 +464,14 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
452
464
|
shouldHandleColgroupUpdates = true;
|
|
453
465
|
}
|
|
454
466
|
|
|
455
|
-
|
|
467
|
+
const isTableScalingEnabledWithLockButton =
|
|
456
468
|
isTableScalingEnabled &&
|
|
457
|
-
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
|
|
458
|
-
|
|
459
|
-
|
|
469
|
+
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
|
|
470
|
+
const shouldUseIncreasedScalingPercent =
|
|
471
|
+
isTableScalingEnabledWithLockButton &&
|
|
472
|
+
getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
473
|
+
|
|
474
|
+
if (isTableScalingEnabledWithLockButton && getNode().attrs.displayMode !== 'fixed') {
|
|
460
475
|
shouldScale = true;
|
|
461
476
|
shouldHandleColgroupUpdates = true;
|
|
462
477
|
}
|
|
@@ -523,7 +538,13 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
523
538
|
const depth = view.state.doc.resolve(start).depth;
|
|
524
539
|
shouldScale = depth === 0 && shouldScale;
|
|
525
540
|
|
|
526
|
-
insertColgroupFromNode(
|
|
541
|
+
insertColgroupFromNode(
|
|
542
|
+
this.table,
|
|
543
|
+
currentTable,
|
|
544
|
+
shouldScale,
|
|
545
|
+
undefined,
|
|
546
|
+
shouldUseIncreasedScalingPercent,
|
|
547
|
+
);
|
|
527
548
|
}
|
|
528
549
|
|
|
529
550
|
updateControls()(view.state);
|
|
@@ -724,6 +745,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
724
745
|
|
|
725
746
|
const { stickyScrollbar } = getEditorFeatureFlags();
|
|
726
747
|
|
|
748
|
+
const shouldUseIncreasedScalingPercent =
|
|
749
|
+
isTableScalingEnabled &&
|
|
750
|
+
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
|
|
751
|
+
getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
752
|
+
|
|
727
753
|
return (
|
|
728
754
|
<TableContainer
|
|
729
755
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -746,6 +772,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
746
772
|
isTableScalingEnabled={isTableScalingEnabled}
|
|
747
773
|
isWholeTableInDanger={isWholeTableInDanger}
|
|
748
774
|
isTableAlignmentEnabled={isTableAlignmentEnabled}
|
|
775
|
+
shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
|
|
749
776
|
>
|
|
750
777
|
<div
|
|
751
778
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -961,6 +988,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
961
988
|
this.layoutSize = layoutSize;
|
|
962
989
|
};
|
|
963
990
|
|
|
991
|
+
// Function gets called when table is nested.
|
|
964
992
|
private scaleTable = (scaleOptions: { parentWidth?: number }) => {
|
|
965
993
|
const { view, getNode, getPos, containerWidth, options } = this.props;
|
|
966
994
|
const node = getNode();
|
|
@@ -987,7 +1015,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
987
1015
|
...options,
|
|
988
1016
|
},
|
|
989
1017
|
domAtPos,
|
|
990
|
-
false,
|
|
1018
|
+
false, // isTableScalingEnabled doesn't change the behavior of nested tables
|
|
1019
|
+
false, // shouldUseIncreasedScalingPercent set to false for nested tables
|
|
991
1020
|
)(state.tr);
|
|
992
1021
|
|
|
993
1022
|
dispatch(tr);
|
|
@@ -162,6 +162,7 @@ type ResizableTableContainerProps = {
|
|
|
162
162
|
|
|
163
163
|
isTableScalingEnabled?: boolean;
|
|
164
164
|
isTableAlignmentEnabled?: boolean;
|
|
165
|
+
shouldUseIncreasedScalingPercent?: boolean;
|
|
165
166
|
};
|
|
166
167
|
|
|
167
168
|
export const ResizableTableContainer = React.memo(
|
|
@@ -180,6 +181,7 @@ export const ResizableTableContainer = React.memo(
|
|
|
180
181
|
isWholeTableInDanger,
|
|
181
182
|
isTableScalingEnabled,
|
|
182
183
|
isTableAlignmentEnabled,
|
|
184
|
+
shouldUseIncreasedScalingPercent,
|
|
183
185
|
}: PropsWithChildren<ResizableTableContainerProps>) => {
|
|
184
186
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
185
187
|
const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
|
|
@@ -308,6 +310,7 @@ export const ResizableTableContainer = React.memo(
|
|
|
308
310
|
isFullWidthModeEnabled,
|
|
309
311
|
isTableScalingEnabled,
|
|
310
312
|
isWholeTableInDanger,
|
|
313
|
+
shouldUseIncreasedScalingPercent,
|
|
311
314
|
pluginInjectionApi,
|
|
312
315
|
onResizeStart,
|
|
313
316
|
onResizeStop,
|
|
@@ -373,6 +376,7 @@ type TableContainerProps = {
|
|
|
373
376
|
isTableResizingEnabled: boolean | undefined;
|
|
374
377
|
isTableScalingEnabled?: boolean;
|
|
375
378
|
isTableAlignmentEnabled?: boolean;
|
|
379
|
+
shouldUseIncreasedScalingPercent?: boolean;
|
|
376
380
|
};
|
|
377
381
|
|
|
378
382
|
export const TableContainer = ({
|
|
@@ -391,6 +395,7 @@ export const TableContainer = ({
|
|
|
391
395
|
isTableResizingEnabled,
|
|
392
396
|
isTableScalingEnabled,
|
|
393
397
|
isTableAlignmentEnabled,
|
|
398
|
+
shouldUseIncreasedScalingPercent,
|
|
394
399
|
}: PropsWithChildren<TableContainerProps>) => {
|
|
395
400
|
if (isTableResizingEnabled && !isNested) {
|
|
396
401
|
return (
|
|
@@ -409,6 +414,7 @@ export const TableContainer = ({
|
|
|
409
414
|
isTableScalingEnabled={isTableScalingEnabled}
|
|
410
415
|
isWholeTableInDanger={isWholeTableInDanger}
|
|
411
416
|
isTableAlignmentEnabled={isTableAlignmentEnabled}
|
|
417
|
+
shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
|
|
412
418
|
>
|
|
413
419
|
{children}
|
|
414
420
|
</ResizableTableContainer>
|
|
@@ -76,6 +76,7 @@ interface TableResizerProps {
|
|
|
76
76
|
isTableAlignmentEnabled?: boolean;
|
|
77
77
|
isWholeTableInDanger?: boolean;
|
|
78
78
|
isFullWidthModeEnabled?: boolean;
|
|
79
|
+
shouldUseIncreasedScalingPercent?: boolean;
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
export interface TableResizerImprovementProps extends TableResizerProps {
|
|
@@ -189,6 +190,7 @@ export const TableResizer = ({
|
|
|
189
190
|
isTableScalingEnabled,
|
|
190
191
|
isTableAlignmentEnabled,
|
|
191
192
|
isWholeTableInDanger,
|
|
193
|
+
shouldUseIncreasedScalingPercent,
|
|
192
194
|
pluginInjectionApi,
|
|
193
195
|
isFullWidthModeEnabled,
|
|
194
196
|
}: PropsWithChildren<TableResizerImprovementProps>) => {
|
|
@@ -517,6 +519,7 @@ export const TableResizer = ({
|
|
|
517
519
|
},
|
|
518
520
|
editorView.domAtPos.bind(editorView),
|
|
519
521
|
isTableScalingEnabled,
|
|
522
|
+
shouldUseIncreasedScalingPercent || false,
|
|
520
523
|
)(tr);
|
|
521
524
|
|
|
522
525
|
const scaledNode = tr.doc.nodeAt(pos)!;
|
|
@@ -571,6 +574,7 @@ export const TableResizer = ({
|
|
|
571
574
|
endMeasure,
|
|
572
575
|
onResizeStop,
|
|
573
576
|
isTableScalingEnabled,
|
|
577
|
+
shouldUseIncreasedScalingPercent,
|
|
574
578
|
widthToWidest,
|
|
575
579
|
formatMessage,
|
|
576
580
|
pluginInjectionApi,
|
package/src/plugin.tsx
CHANGED
|
@@ -153,6 +153,11 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
153
153
|
};
|
|
154
154
|
const editorAnalyticsAPI = api?.analytics?.actions;
|
|
155
155
|
|
|
156
|
+
const shouldUseIncreasedScalingPercent =
|
|
157
|
+
options?.isTableScalingEnabled &&
|
|
158
|
+
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
|
|
159
|
+
getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
160
|
+
|
|
156
161
|
return {
|
|
157
162
|
name: 'table',
|
|
158
163
|
|
|
@@ -278,6 +283,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
278
283
|
api,
|
|
279
284
|
isTableScalingEnabled,
|
|
280
285
|
isTableAlignmentEnabled,
|
|
286
|
+
shouldUseIncreasedScalingPercent,
|
|
281
287
|
);
|
|
282
288
|
},
|
|
283
289
|
},
|
|
@@ -313,6 +319,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
313
319
|
isTableAlignmentEnabled = false,
|
|
314
320
|
fullWidthEnabled = false,
|
|
315
321
|
} = options || ({} as TablePluginOptions);
|
|
322
|
+
|
|
316
323
|
return keymapPlugin(
|
|
317
324
|
defaultGetEditorContainerWidth,
|
|
318
325
|
editorAnalyticsAPI,
|
|
@@ -322,6 +329,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
322
329
|
fullWidthEnabled,
|
|
323
330
|
api,
|
|
324
331
|
getIntl,
|
|
332
|
+
shouldUseIncreasedScalingPercent,
|
|
325
333
|
);
|
|
326
334
|
},
|
|
327
335
|
},
|
|
@@ -652,6 +660,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
652
660
|
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
653
661
|
() => editorViewRef.current,
|
|
654
662
|
options,
|
|
663
|
+
shouldUseIncreasedScalingPercent,
|
|
655
664
|
)(pluginConfig(options?.tableOptions)),
|
|
656
665
|
},
|
|
657
666
|
};
|
|
@@ -214,14 +214,23 @@ const destroyFn = (editorView: EditorView, editorAnalyticsAPI: any) => {
|
|
|
214
214
|
const { isTableScalingEnabled = false } = getTablePluginState(editorView.state);
|
|
215
215
|
|
|
216
216
|
let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
217
|
-
|
|
217
|
+
const isTableScalingEnabledWithLockButton =
|
|
218
218
|
isTableScalingEnabled &&
|
|
219
|
-
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
|
|
220
|
-
|
|
219
|
+
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
|
|
220
|
+
const shouldUseIncreasedScalingPercent =
|
|
221
|
+
isTableScalingEnabledWithLockButton &&
|
|
222
|
+
getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
223
|
+
|
|
224
|
+
if (isTableScalingEnabledWithLockButton) {
|
|
221
225
|
isTableScalingEnabledOnCurrentTable = tableNode.attrs.displayMode !== 'fixed';
|
|
222
226
|
}
|
|
223
227
|
|
|
224
|
-
insertColgroupFromNode(
|
|
228
|
+
insertColgroupFromNode(
|
|
229
|
+
tableRef,
|
|
230
|
+
tableNode,
|
|
231
|
+
isTableScalingEnabledOnCurrentTable,
|
|
232
|
+
shouldUseIncreasedScalingPercent,
|
|
233
|
+
);
|
|
225
234
|
}
|
|
226
235
|
}
|
|
227
236
|
|
package/src/pm-plugins/keymap.ts
CHANGED
|
@@ -61,6 +61,7 @@ export function keymapPlugin(
|
|
|
61
61
|
isFullWidthEnabled?: boolean,
|
|
62
62
|
pluginInjectionApi?: PluginInjectionAPIWithA11y,
|
|
63
63
|
getIntl?: () => IntlShape,
|
|
64
|
+
shouldUseIncreasedScalingPercent?: boolean,
|
|
64
65
|
): SafePlugin {
|
|
65
66
|
const list = {};
|
|
66
67
|
|
|
@@ -111,11 +112,15 @@ export function keymapPlugin(
|
|
|
111
112
|
|
|
112
113
|
bindKeymapWithCommand(
|
|
113
114
|
addColumnBefore.common!,
|
|
114
|
-
addColumnBeforeCommand(isTableScalingEnabled),
|
|
115
|
+
addColumnBeforeCommand(isTableScalingEnabled, shouldUseIncreasedScalingPercent),
|
|
115
116
|
list,
|
|
116
117
|
);
|
|
117
118
|
|
|
118
|
-
bindKeymapWithCommand(
|
|
119
|
+
bindKeymapWithCommand(
|
|
120
|
+
addColumnAfter.common!,
|
|
121
|
+
addColumnAfterCommand(isTableScalingEnabled, shouldUseIncreasedScalingPercent),
|
|
122
|
+
list,
|
|
123
|
+
);
|
|
119
124
|
|
|
120
125
|
if (dragAndDropEnabled) {
|
|
121
126
|
// Move row/column shortcuts
|
|
@@ -153,13 +158,21 @@ export function keymapPlugin(
|
|
|
153
158
|
// Delete row/column shortcuts
|
|
154
159
|
bindKeymapWithCommand(
|
|
155
160
|
deleteColumn.common!,
|
|
156
|
-
deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(
|
|
161
|
+
deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(
|
|
162
|
+
editorAnalyticsAPI,
|
|
163
|
+
isTableScalingEnabled,
|
|
164
|
+
shouldUseIncreasedScalingPercent,
|
|
165
|
+
),
|
|
157
166
|
list,
|
|
158
167
|
);
|
|
159
168
|
|
|
160
169
|
bindKeymapWithCommand(
|
|
161
170
|
deleteRow.common!,
|
|
162
|
-
deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(
|
|
171
|
+
deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(
|
|
172
|
+
editorAnalyticsAPI,
|
|
173
|
+
isTableScalingEnabled,
|
|
174
|
+
shouldUseIncreasedScalingPercent,
|
|
175
|
+
),
|
|
163
176
|
list,
|
|
164
177
|
);
|
|
165
178
|
}
|
package/src/pm-plugins/main.ts
CHANGED
|
@@ -93,6 +93,7 @@ export const createPlugin = (
|
|
|
93
93
|
pluginInjectionApi?: PluginInjectionAPI,
|
|
94
94
|
isTableScalingEnabled?: boolean,
|
|
95
95
|
isTableAlignmentEnabled?: boolean,
|
|
96
|
+
shouldUseIncreasedScalingPercent?: boolean,
|
|
96
97
|
) => {
|
|
97
98
|
const state = createPluginState(dispatch, {
|
|
98
99
|
pluginConfig,
|
|
@@ -165,6 +166,7 @@ export const createPlugin = (
|
|
|
165
166
|
editorAnalyticsAPI,
|
|
166
167
|
editorViewRef || undefined,
|
|
167
168
|
isTableScalingEnabled,
|
|
169
|
+
shouldUseIncreasedScalingPercent,
|
|
168
170
|
);
|
|
169
171
|
return fixTables(updatedTr) || updatedTr;
|
|
170
172
|
}
|
|
@@ -84,10 +84,10 @@ export const handleMouseDown = (
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
let shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
|
|
90
|
-
) {
|
|
87
|
+
|
|
88
|
+
const isTableScalingEnabledWithLockButton =
|
|
89
|
+
isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
|
|
90
|
+
if (isTableScalingEnabledWithLockButton) {
|
|
91
91
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -99,6 +99,9 @@ export const handleMouseDown = (
|
|
|
99
99
|
start,
|
|
100
100
|
domAtPos,
|
|
101
101
|
isTableScalingEnabled: shouldScale,
|
|
102
|
+
shouldUseIncreasedScalingPercent:
|
|
103
|
+
isTableScalingEnabledWithLockButton &&
|
|
104
|
+
getBooleanFF('platform.editor.table.use-increased-scaling-percent'),
|
|
102
105
|
});
|
|
103
106
|
|
|
104
107
|
if (
|
|
@@ -180,10 +183,10 @@ export const handleMouseDown = (
|
|
|
180
183
|
selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
181
184
|
|
|
182
185
|
let shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
183
|
-
|
|
186
|
+
const isTableScalingEnabledWithLockButton =
|
|
184
187
|
isTableScalingEnabled &&
|
|
185
|
-
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
|
|
186
|
-
) {
|
|
188
|
+
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
|
|
189
|
+
if (isTableScalingEnabledWithLockButton) {
|
|
187
190
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
188
191
|
}
|
|
189
192
|
|
|
@@ -210,6 +213,8 @@ export const handleMouseDown = (
|
|
|
210
213
|
originalTable,
|
|
211
214
|
resizingSelectedColumns ? selectedColumns : undefined,
|
|
212
215
|
shouldScale,
|
|
216
|
+
isTableScalingEnabledWithLockButton &&
|
|
217
|
+
getBooleanFF('platform.editor.table.use-increased-scaling-percent'),
|
|
213
218
|
);
|
|
214
219
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
215
220
|
}
|
|
@@ -284,10 +289,13 @@ export const handleMouseDown = (
|
|
|
284
289
|
const colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter!.attrs.colspan - 1;
|
|
285
290
|
|
|
286
291
|
let shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
287
|
-
|
|
292
|
+
const isTableScalingEnabledWithLockButton =
|
|
288
293
|
isTableScalingEnabled &&
|
|
289
|
-
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
|
|
290
|
-
|
|
294
|
+
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
|
|
295
|
+
const shouldUseIncreasedScalingPercent =
|
|
296
|
+
isTableScalingEnabledWithLockButton &&
|
|
297
|
+
getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
298
|
+
if (isTableScalingEnabledWithLockButton) {
|
|
291
299
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
292
300
|
}
|
|
293
301
|
|
|
@@ -300,6 +308,8 @@ export const handleMouseDown = (
|
|
|
300
308
|
table,
|
|
301
309
|
undefined,
|
|
302
310
|
shouldScale,
|
|
311
|
+
undefined,
|
|
312
|
+
shouldUseIncreasedScalingPercent,
|
|
303
313
|
);
|
|
304
314
|
} else {
|
|
305
315
|
resizeColumn(
|
|
@@ -310,6 +320,7 @@ export const handleMouseDown = (
|
|
|
310
320
|
table,
|
|
311
321
|
undefined,
|
|
312
322
|
shouldScale,
|
|
323
|
+
shouldUseIncreasedScalingPercent,
|
|
313
324
|
);
|
|
314
325
|
}
|
|
315
326
|
|
|
@@ -17,9 +17,12 @@ type Col = Array<string | { [name: string]: string }>;
|
|
|
17
17
|
export const getColWidthFix = (colwidth: number, tableColumnCount: number) =>
|
|
18
18
|
colwidth - 1 / tableColumnCount;
|
|
19
19
|
|
|
20
|
-
export const generateColgroup = (
|
|
20
|
+
export const generateColgroup = (
|
|
21
|
+
table: PmNode,
|
|
22
|
+
tableRef?: HTMLElement,
|
|
23
|
+
shouldUseIncreasedScalingPercent?: boolean,
|
|
24
|
+
) => {
|
|
21
25
|
const cols: Col[] = [];
|
|
22
|
-
|
|
23
26
|
const map = TableMap.get(table);
|
|
24
27
|
table.content.firstChild!.content.forEach((cell) => {
|
|
25
28
|
const colspan = cell.attrs.colspan || 1;
|
|
@@ -27,7 +30,11 @@ export const generateColgroup = (table: PmNode, tableRef?: HTMLElement) => {
|
|
|
27
30
|
// We slice here to guard against our colwidth array having more entries
|
|
28
31
|
// Than the we actually span. We'll patch the document at a later point.
|
|
29
32
|
if (tableRef) {
|
|
30
|
-
const scalePercent = getTableScalingPercent(
|
|
33
|
+
const scalePercent = getTableScalingPercent(
|
|
34
|
+
table,
|
|
35
|
+
tableRef,
|
|
36
|
+
shouldUseIncreasedScalingPercent,
|
|
37
|
+
);
|
|
31
38
|
cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
|
|
32
39
|
const fixedColWidth = getColWidthFix(width, map.width);
|
|
33
40
|
const scaledWidth = fixedColWidth * scalePercent;
|
|
@@ -73,6 +80,7 @@ export const insertColgroupFromNode = (
|
|
|
73
80
|
table: PmNode,
|
|
74
81
|
isTableScalingEnabled = false,
|
|
75
82
|
shouldRemove = true,
|
|
83
|
+
shouldUseIncreasedScalingPercent = false,
|
|
76
84
|
): HTMLCollection => {
|
|
77
85
|
let colgroup = tableRef?.querySelector('colgroup') as HTMLElement;
|
|
78
86
|
if (colgroup && shouldRemove) {
|
|
@@ -82,6 +90,7 @@ export const insertColgroupFromNode = (
|
|
|
82
90
|
colgroup = renderColgroupFromNode(
|
|
83
91
|
table,
|
|
84
92
|
isTableScalingEnabled ? tableRef ?? undefined : undefined,
|
|
93
|
+
shouldUseIncreasedScalingPercent,
|
|
85
94
|
);
|
|
86
95
|
if (shouldRemove) {
|
|
87
96
|
tableRef?.insertBefore(colgroup, tableRef?.firstChild);
|
|
@@ -117,11 +126,12 @@ export const isMinCellWidthTable = (table: PmNode) => {
|
|
|
117
126
|
function renderColgroupFromNode(
|
|
118
127
|
table: PmNode,
|
|
119
128
|
maybeTableRef: HTMLElement | undefined,
|
|
129
|
+
shouldUseIncreasedScalingPercent: boolean,
|
|
120
130
|
): HTMLElement {
|
|
121
131
|
const rendered = DOMSerializer.renderSpec(document, [
|
|
122
132
|
'colgroup',
|
|
123
133
|
{},
|
|
124
|
-
...generateColgroup(table, maybeTableRef),
|
|
134
|
+
...generateColgroup(table, maybeTableRef, shouldUseIncreasedScalingPercent),
|
|
125
135
|
]);
|
|
126
136
|
|
|
127
137
|
return rendered.dom as HTMLElement;
|
|
@@ -2,5 +2,6 @@ export const COLUMN_MIN_WIDTH = 48;
|
|
|
2
2
|
export const TABLE_DEFAULT_WIDTH = 760;
|
|
3
3
|
export const TABLE_MAX_WIDTH = 1800;
|
|
4
4
|
export const MAX_SCALING_PERCENT = 0.3;
|
|
5
|
+
export const MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION = 0.4;
|
|
5
6
|
// Used to calculate the width of a table using the Editor width
|
|
6
7
|
export const TABLE_EDITOR_MARGIN = 76;
|