@atlaskit/editor-plugin-table 7.6.14 → 7.7.0
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 +6 -0
- package/dist/cjs/commands/misc.js +0 -2
- package/dist/cjs/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/cjs/nodeviews/TableComponent.js +3 -18
- package/dist/cjs/nodeviews/TableContainer.js +2 -18
- package/dist/cjs/nodeviews/table.js +0 -2
- package/dist/cjs/plugin.js +3 -20
- package/dist/cjs/pm-plugins/main.js +1 -2
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +7 -21
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +32 -57
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +1 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +16 -28
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +2 -12
- package/dist/cjs/reducer.js +0 -2
- package/dist/cjs/transforms/column-width.js +3 -5
- package/dist/cjs/types.js +0 -1
- package/dist/cjs/ui/ColumnResizeWidget/index.js +5 -1
- package/dist/cjs/ui/common-styles.js +5 -12
- package/dist/cjs/ui/ui-styles.js +7 -12
- package/dist/cjs/utils/index.js +0 -6
- package/dist/cjs/utils/nodes.js +5 -18
- package/dist/es2019/commands/misc.js +0 -2
- package/dist/es2019/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/es2019/nodeviews/TableComponent.js +3 -18
- package/dist/es2019/nodeviews/TableContainer.js +1 -16
- package/dist/es2019/nodeviews/table.js +0 -2
- package/dist/es2019/plugin.js +5 -24
- package/dist/es2019/pm-plugins/main.js +1 -2
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +8 -22
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +30 -53
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +1 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +14 -24
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +2 -12
- package/dist/es2019/reducer.js +0 -5
- package/dist/es2019/transforms/column-width.js +3 -5
- package/dist/es2019/types.js +0 -1
- package/dist/es2019/ui/ColumnResizeWidget/index.js +5 -1
- package/dist/es2019/ui/common-styles.js +15 -46
- package/dist/es2019/ui/ui-styles.js +34 -41
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/utils/nodes.js +0 -15
- package/dist/esm/commands/misc.js +0 -2
- package/dist/esm/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/esm/nodeviews/TableComponent.js +3 -18
- package/dist/esm/nodeviews/TableContainer.js +2 -18
- package/dist/esm/nodeviews/table.js +0 -2
- package/dist/esm/plugin.js +5 -22
- package/dist/esm/pm-plugins/main.js +1 -2
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +8 -22
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +32 -57
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +1 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +16 -28
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +2 -12
- package/dist/esm/reducer.js +0 -2
- package/dist/esm/transforms/column-width.js +3 -5
- package/dist/esm/types.js +0 -1
- package/dist/esm/ui/ColumnResizeWidget/index.js +5 -1
- package/dist/esm/ui/common-styles.js +6 -13
- package/dist/esm/ui/ui-styles.js +7 -12
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/nodes.js +0 -13
- package/dist/types/nodeviews/TableContainer.d.ts +1 -2
- package/dist/types/nodeviews/types.d.ts +0 -1
- package/dist/types/plugin.d.ts +0 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -1
- package/dist/types/types.d.ts +0 -9
- package/dist/types/ui/FloatingContextualButton/index.d.ts +0 -2
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/nodes.d.ts +0 -1
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +1 -2
- package/dist/types-ts4.5/nodeviews/types.d.ts +0 -1
- package/dist/types-ts4.5/plugin.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -1
- package/dist/types-ts4.5/types.d.ts +0 -9
- package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +0 -2
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/utils/nodes.d.ts +0 -1
- package/package.json +2 -5
- package/src/commands/misc.ts +0 -2
- package/src/nodeviews/OverflowShadowsObserver.ts +1 -6
- package/src/nodeviews/TableComponent.tsx +2 -25
- package/src/nodeviews/TableContainer.tsx +2 -26
- package/src/nodeviews/table.tsx +0 -2
- package/src/nodeviews/types.ts +0 -1
- package/src/plugin.tsx +4 -43
- package/src/pm-plugins/main.ts +0 -2
- package/src/pm-plugins/table-resizing/event-handlers.ts +8 -37
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +40 -61
- package/src/pm-plugins/table-resizing/utils/misc.ts +4 -6
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -29
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +2 -13
- package/src/reducer.ts +0 -3
- package/src/transforms/column-width.ts +2 -10
- package/src/types.ts +0 -8
- package/src/ui/ColumnResizeWidget/index.tsx +10 -1
- package/src/ui/FloatingContextualButton/index.tsx +0 -2
- package/src/ui/common-styles.ts +15 -53
- package/src/ui/ui-styles.ts +34 -47
- package/src/utils/index.ts +0 -1
- package/src/utils/nodes.ts +0 -23
- package/dist/cjs/ui/LayoutButton/index.js +0 -206
- package/dist/es2019/ui/LayoutButton/index.js +0 -168
- package/dist/esm/ui/LayoutButton/index.js +0 -196
- package/dist/types/ui/LayoutButton/index.d.ts +0 -21
- package/dist/types-ts4.5/ui/LayoutButton/index.d.ts +0 -21
- package/src/ui/LayoutButton/index.tsx +0 -217
|
@@ -3,7 +3,6 @@ import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
|
3
3
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
|
|
8
7
|
import { getTableScalingPercent } from './misc';
|
|
9
8
|
|
|
@@ -21,70 +20,50 @@ export const getColWidthFix = (colwidth: number, tableColumnCount: number) =>
|
|
|
21
20
|
export const generateColgroup = (table: PmNode, tableRef?: HTMLElement) => {
|
|
22
21
|
const cols: Col[] = [];
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const scalePercent = getTableScalingPercent(table, tableRef);
|
|
33
|
-
cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
|
|
34
|
-
const fixedColWidth = getColWidthFix(width, map.width);
|
|
35
|
-
const scaledWidth = fixedColWidth * scalePercent;
|
|
36
|
-
const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
|
|
37
|
-
cols.push([
|
|
38
|
-
'col',
|
|
39
|
-
{
|
|
40
|
-
style: `width: ${finalWidth}px;`,
|
|
41
|
-
},
|
|
42
|
-
]);
|
|
43
|
-
});
|
|
44
|
-
} else {
|
|
45
|
-
cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
|
|
46
|
-
cols.push([
|
|
47
|
-
'col',
|
|
48
|
-
{
|
|
49
|
-
style: `width: ${getColWidthFix(
|
|
50
|
-
width
|
|
51
|
-
? Math.max(width, tableCellMinWidth)
|
|
52
|
-
: tableCellMinWidth,
|
|
53
|
-
map.width,
|
|
54
|
-
)}px;`,
|
|
55
|
-
},
|
|
56
|
-
]);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
// When we have merged cells on the first row (firstChild),
|
|
61
|
-
// We want to ensure we're creating the appropriate amount of
|
|
62
|
-
// cols the table still has.
|
|
63
|
-
cols.push(
|
|
64
|
-
...Array.from({ length: colspan }, (_) => [
|
|
65
|
-
'col',
|
|
66
|
-
{ style: `width: ${tableCellMinWidth}px;` },
|
|
67
|
-
]),
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
} else {
|
|
72
|
-
table.content.firstChild!.content.forEach((cell) => {
|
|
73
|
-
const colspan = cell.attrs.colspan || 1;
|
|
74
|
-
if (Array.isArray(cell.attrs.colwidth)) {
|
|
75
|
-
// We slice here to guard against our colwidth array having more entries
|
|
76
|
-
// Than the we actually span. We'll patch the document at a later point.
|
|
23
|
+
const map = TableMap.get(table);
|
|
24
|
+
table.content.firstChild!.content.forEach((cell) => {
|
|
25
|
+
const colspan = cell.attrs.colspan || 1;
|
|
26
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
27
|
+
// We slice here to guard against our colwidth array having more entries
|
|
28
|
+
// Than the we actually span. We'll patch the document at a later point.
|
|
29
|
+
if (tableRef) {
|
|
30
|
+
const scalePercent = getTableScalingPercent(table, tableRef);
|
|
77
31
|
cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
|
|
78
|
-
|
|
32
|
+
const fixedColWidth = getColWidthFix(width, map.width);
|
|
33
|
+
const scaledWidth = fixedColWidth * scalePercent;
|
|
34
|
+
const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
|
|
35
|
+
cols.push([
|
|
36
|
+
'col',
|
|
37
|
+
{
|
|
38
|
+
style: `width: ${finalWidth}px;`,
|
|
39
|
+
},
|
|
40
|
+
]);
|
|
79
41
|
});
|
|
80
42
|
} else {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
43
|
+
cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
|
|
44
|
+
cols.push([
|
|
45
|
+
'col',
|
|
46
|
+
{
|
|
47
|
+
style: `width: ${getColWidthFix(
|
|
48
|
+
width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth,
|
|
49
|
+
map.width,
|
|
50
|
+
)}px;`,
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
53
|
+
});
|
|
85
54
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
55
|
+
} else {
|
|
56
|
+
// When we have merged cells on the first row (firstChild),
|
|
57
|
+
// We want to ensure we're creating the appropriate amount of
|
|
58
|
+
// cols the table still has.
|
|
59
|
+
cols.push(
|
|
60
|
+
...Array.from({ length: colspan }, (_) => [
|
|
61
|
+
'col',
|
|
62
|
+
{ style: `width: ${tableCellMinWidth}px;` },
|
|
63
|
+
]),
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
88
67
|
|
|
89
68
|
return cols;
|
|
90
69
|
};
|
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
akEditorGutterPadding,
|
|
27
27
|
akEditorTableNumberColumnWidth,
|
|
28
28
|
} from '@atlaskit/editor-shared-styles';
|
|
29
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
30
29
|
|
|
31
30
|
import type { TableOptions } from '../../../nodeviews/types';
|
|
32
31
|
|
|
@@ -127,11 +126,10 @@ export const getTableMaxWidth = ({
|
|
|
127
126
|
const containerWidth = getEditorContainerWidth();
|
|
128
127
|
const parentWidth = getParentNodeWidth(tableStart, state, containerWidth);
|
|
129
128
|
|
|
130
|
-
let maxWidth =
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
: parentWidth || getLayoutSize(layout, containerWidth.width, {});
|
|
129
|
+
let maxWidth =
|
|
130
|
+
parentWidth ||
|
|
131
|
+
table.attrs.width ||
|
|
132
|
+
getLayoutSize(layout, containerWidth.width, {});
|
|
135
133
|
|
|
136
134
|
if (table.attrs.isNumberColumnEnabled) {
|
|
137
135
|
maxWidth -= akEditorTableNumberColumnWidth;
|
|
@@ -9,7 +9,6 @@ import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
|
|
|
9
9
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
10
10
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
11
11
|
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
12
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
13
12
|
|
|
14
13
|
import { getSelectedTableInfo } from '../../../utils';
|
|
15
14
|
|
|
@@ -115,39 +114,29 @@ export const updateColgroup = (
|
|
|
115
114
|
): void => {
|
|
116
115
|
const cols = tableRef.querySelectorAll('col');
|
|
117
116
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
});
|
|
133
|
-
} else {
|
|
134
|
-
state.cols
|
|
135
|
-
.filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
|
|
136
|
-
.forEach((column, i) => {
|
|
137
|
-
if (cols[i]) {
|
|
138
|
-
cols[i].style.width = `${getColWidthFix(
|
|
139
|
-
column.width,
|
|
140
|
-
columnsCount,
|
|
141
|
-
)}px`;
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
}
|
|
117
|
+
const columnsCount = cols.length;
|
|
118
|
+
if (isTableScalingEnabled && tableNode) {
|
|
119
|
+
const scalePercent = getTableScalingPercent(tableNode, tableRef);
|
|
120
|
+
state.cols
|
|
121
|
+
.filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
|
|
122
|
+
.forEach((column, i) => {
|
|
123
|
+
const fixedColWidth = getColWidthFix(column.width, columnsCount);
|
|
124
|
+
const scaledWidth = fixedColWidth * scalePercent;
|
|
125
|
+
const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
|
|
126
|
+
// we aren't handling the remaining pixels here when the 48px min width is reached
|
|
127
|
+
if (cols[i]) {
|
|
128
|
+
cols[i].style.width = `${finalWidth}px`;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
145
131
|
} else {
|
|
146
132
|
state.cols
|
|
147
133
|
.filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
|
|
148
134
|
.forEach((column, i) => {
|
|
149
135
|
if (cols[i]) {
|
|
150
|
-
cols[i].style.width = `${
|
|
136
|
+
cols[i].style.width = `${getColWidthFix(
|
|
137
|
+
column.width,
|
|
138
|
+
columnsCount,
|
|
139
|
+
)}px`;
|
|
151
140
|
}
|
|
152
141
|
});
|
|
153
142
|
}
|
|
@@ -28,7 +28,6 @@ export interface ScaleOptions {
|
|
|
28
28
|
previousContainerWidth?: number;
|
|
29
29
|
parentWidth?: number;
|
|
30
30
|
layoutChanged?: boolean;
|
|
31
|
-
isBreakoutEnabled?: boolean;
|
|
32
31
|
isFullWidthModeEnabled?: boolean;
|
|
33
32
|
isTableResizingEnabled?: boolean;
|
|
34
33
|
}
|
|
@@ -41,34 +40,24 @@ export const scale = (
|
|
|
41
40
|
domAtPos: DomAtPos,
|
|
42
41
|
isTableScalingEnabled = false,
|
|
43
42
|
): ResizeState | undefined => {
|
|
44
|
-
/**
|
|
45
|
-
* isBreakoutEnabled === true -> default center aligned
|
|
46
|
-
* isBreakoutEnabled === false -> full width mode
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
43
|
const {
|
|
50
44
|
node,
|
|
51
45
|
containerWidth,
|
|
52
46
|
previousContainerWidth,
|
|
53
47
|
prevNode,
|
|
54
48
|
start,
|
|
55
|
-
isBreakoutEnabled,
|
|
56
49
|
layoutChanged,
|
|
57
50
|
isTableResizingEnabled,
|
|
58
51
|
} = options;
|
|
59
52
|
|
|
60
53
|
const maxSize = isTableResizingEnabled
|
|
61
54
|
? getTableContainerWidth(node)
|
|
62
|
-
: getLayoutSize(node.attrs.layout, containerWidth, {
|
|
63
|
-
isBreakoutEnabled,
|
|
64
|
-
});
|
|
55
|
+
: getLayoutSize(node.attrs.layout, containerWidth, {});
|
|
65
56
|
|
|
66
57
|
const prevTableWidth = getTableWidth(prevNode);
|
|
67
58
|
const previousMaxSize = isTableResizingEnabled
|
|
68
59
|
? getTableContainerWidth(node)
|
|
69
|
-
: getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {
|
|
70
|
-
isBreakoutEnabled,
|
|
71
|
-
});
|
|
60
|
+
: getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {});
|
|
72
61
|
|
|
73
62
|
let newWidth = maxSize;
|
|
74
63
|
|
package/src/reducer.ts
CHANGED
|
@@ -27,9 +27,6 @@ export default (
|
|
|
27
27
|
case 'SET_TARGET_CELL_POSITION':
|
|
28
28
|
return { ...pluginState, ...action.data, isContextualMenuOpen: false };
|
|
29
29
|
|
|
30
|
-
case 'SET_TABLE_LAYOUT':
|
|
31
|
-
return { ...pluginState, ...action.data };
|
|
32
|
-
|
|
33
30
|
case 'TOGGLE_CONTEXTUAL_MENU':
|
|
34
31
|
return {
|
|
35
32
|
...pluginState,
|
|
@@ -6,7 +6,6 @@ import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
|
6
6
|
import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
9
|
|
|
11
10
|
import type { ResizeState } from '../pm-plugins/table-resizing/utils';
|
|
12
11
|
import {
|
|
@@ -17,7 +16,6 @@ import {
|
|
|
17
16
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
18
17
|
import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
19
18
|
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
20
|
-
import { insertColumnButtonOffset } from '../ui/common-styles';
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
21
|
* Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
|
|
@@ -141,10 +139,7 @@ export const rescaleColumns =
|
|
|
141
139
|
if (shouldScale) {
|
|
142
140
|
previousTableInfo = {
|
|
143
141
|
width: getTableElementWidth(table.node),
|
|
144
|
-
possibleMaxWidth:
|
|
145
|
-
? getTableContainerElementWidth(table.node)
|
|
146
|
-
: getTableContainerElementWidth(table.node) -
|
|
147
|
-
insertColumnButtonOffset,
|
|
142
|
+
possibleMaxWidth: getTableContainerElementWidth(table.node),
|
|
148
143
|
isResized,
|
|
149
144
|
};
|
|
150
145
|
} else {
|
|
@@ -152,10 +147,7 @@ export const rescaleColumns =
|
|
|
152
147
|
// when table is resized the tableRef client width will be 1px larger than colGroup, which is used in calculations
|
|
153
148
|
width: isResized ? tableRef.clientWidth - 1 : tableRef.clientWidth,
|
|
154
149
|
/** the is the width the table can reach before overflowing */
|
|
155
|
-
possibleMaxWidth:
|
|
156
|
-
? tableRef?.parentElement?.clientWidth || 0
|
|
157
|
-
: (tableRef?.parentElement?.clientWidth || 0) -
|
|
158
|
-
insertColumnButtonOffset,
|
|
150
|
+
possibleMaxWidth: tableRef?.parentElement?.clientWidth || 0,
|
|
159
151
|
isResized,
|
|
160
152
|
};
|
|
161
153
|
}
|
package/src/types.ts
CHANGED
|
@@ -157,7 +157,6 @@ export interface TablePluginState {
|
|
|
157
157
|
insertColumnButtonIndex?: number;
|
|
158
158
|
insertRowButtonIndex?: number;
|
|
159
159
|
isFullWidthModeEnabled?: boolean;
|
|
160
|
-
layout?: TableLayout;
|
|
161
160
|
ordering?: TableColumnOrdering;
|
|
162
161
|
isResizeHandleWidgetAdded?: boolean;
|
|
163
162
|
resizeHandleRowIndex?: number;
|
|
@@ -171,7 +170,6 @@ export interface TablePluginState {
|
|
|
171
170
|
|
|
172
171
|
getIntl: () => IntlShape;
|
|
173
172
|
|
|
174
|
-
isBreakoutEnabled?: boolean;
|
|
175
173
|
wasFullWidthModeEnabled?: boolean;
|
|
176
174
|
isTableResizingEnabled?: boolean;
|
|
177
175
|
isDragAndDropEnabled?: boolean;
|
|
@@ -190,7 +188,6 @@ export type TablePluginAction =
|
|
|
190
188
|
tableRef?: HTMLTableElement;
|
|
191
189
|
tableNode?: PmNode;
|
|
192
190
|
tableWrapperTarget?: HTMLElement;
|
|
193
|
-
layout: TableLayout;
|
|
194
191
|
isHeaderRowEnabled: boolean;
|
|
195
192
|
isHeaderColumnEnabled: boolean;
|
|
196
193
|
};
|
|
@@ -289,10 +286,6 @@ export type TablePluginAction =
|
|
|
289
286
|
type: 'SELECT_COLUMN';
|
|
290
287
|
data: { targetCellPosition: number; decorationSet: DecorationSet };
|
|
291
288
|
}
|
|
292
|
-
| {
|
|
293
|
-
type: 'SET_TABLE_LAYOUT';
|
|
294
|
-
data: { layout: TableLayout };
|
|
295
|
-
}
|
|
296
289
|
| { type: 'SHOW_INSERT_ROW_BUTTON'; data: { insertRowButtonIndex: number } }
|
|
297
290
|
| {
|
|
298
291
|
type: 'SHOW_INSERT_COLUMN_BUTTON';
|
|
@@ -361,7 +354,6 @@ export const TableCssClassName = {
|
|
|
361
354
|
CONTROLS_INSERT_BUTTON_WRAP: `${tablePrefixSelector}-controls__insert-button-wrap`,
|
|
362
355
|
CONTROLS_INSERT_LINE: `${tablePrefixSelector}-controls__insert-line`,
|
|
363
356
|
CONTROLS_BUTTON_OVERLAY: `${tablePrefixSelector}-controls__button-overlay`,
|
|
364
|
-
LAYOUT_BUTTON: `${tablePrefixSelector}-layout-button`,
|
|
365
357
|
|
|
366
358
|
DRAG_CONTROLS_INSERT_BUTTON: `${tablePrefixSelector}-controls__drag-insert-button`,
|
|
367
359
|
DRAG_CONTROLS_INSERT_BUTTON_INNER: `${tablePrefixSelector}-controls__drag-insert-button-inner`,
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
3
|
import { useIntl } from 'react-intl-next';
|
|
4
4
|
|
|
5
|
+
import {
|
|
6
|
+
startColumnResizing,
|
|
7
|
+
ToolTipContent,
|
|
8
|
+
} from '@atlaskit/editor-common/keymaps';
|
|
5
9
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
10
|
import Tooltip from '@atlaskit/tooltip';
|
|
7
11
|
|
|
@@ -32,7 +36,12 @@ export const ColumnResizeWidget = ({
|
|
|
32
36
|
|
|
33
37
|
return (
|
|
34
38
|
<Tooltip
|
|
35
|
-
content={
|
|
39
|
+
content={
|
|
40
|
+
<ToolTipContent
|
|
41
|
+
description={formatMessage(messages.adjustColumns)}
|
|
42
|
+
keymap={startColumnResizing}
|
|
43
|
+
/>
|
|
44
|
+
}
|
|
36
45
|
hideTooltipOnClick
|
|
37
46
|
hideTooltipOnMouseDown
|
|
38
47
|
position="mouse"
|
|
@@ -5,7 +5,6 @@ import { jsx } from '@emotion/react';
|
|
|
5
5
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
6
6
|
import { injectIntl } from 'react-intl-next';
|
|
7
7
|
|
|
8
|
-
import type { TableLayout } from '@atlaskit/adf-schema';
|
|
9
8
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
10
9
|
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
11
10
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
@@ -37,7 +36,6 @@ export interface Props {
|
|
|
37
36
|
mountPoint?: HTMLElement;
|
|
38
37
|
boundariesElement?: HTMLElement;
|
|
39
38
|
scrollableElement?: HTMLElement;
|
|
40
|
-
layout?: TableLayout;
|
|
41
39
|
isNumberColumnEnabled?: boolean;
|
|
42
40
|
stickyHeader?: RowStickyState;
|
|
43
41
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
package/src/ui/common-styles.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from '@atlaskit/editor-shared-styles';
|
|
24
24
|
import { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
|
|
25
25
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
26
|
-
import {
|
|
26
|
+
import { N0, N40A, R500 } from '@atlaskit/theme/colors';
|
|
27
27
|
import { fontSize } from '@atlaskit/theme/constants';
|
|
28
28
|
import { token } from '@atlaskit/tokens';
|
|
29
29
|
|
|
@@ -259,36 +259,6 @@ const tableStickyHeaderFirefoxFixStyle = () => {
|
|
|
259
259
|
}
|
|
260
260
|
};
|
|
261
261
|
|
|
262
|
-
const tableWrapperStyles = () => {
|
|
263
|
-
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
264
|
-
return css`
|
|
265
|
-
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
266
|
-
padding-bottom: 0px;
|
|
267
|
-
/* fixes gap cursor height */
|
|
268
|
-
overflow: auto;
|
|
269
|
-
overflow-y: hidden;
|
|
270
|
-
position: relative;
|
|
271
|
-
|
|
272
|
-
> table[data-number-column='true'] {
|
|
273
|
-
width: calc(100% - 1px);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
`;
|
|
277
|
-
} else {
|
|
278
|
-
return css`
|
|
279
|
-
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
280
|
-
padding-right: ${insertColumnButtonOffset}px;
|
|
281
|
-
margin-right: -${insertColumnButtonOffset}px;
|
|
282
|
-
padding-bottom: 0px;
|
|
283
|
-
/* fixes gap cursor height */
|
|
284
|
-
overflow: auto;
|
|
285
|
-
overflow-y: hidden;
|
|
286
|
-
position: relative;
|
|
287
|
-
}
|
|
288
|
-
`;
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
|
|
292
262
|
// re-exporting these styles to use in Gemini test when table node view is rendered outside of PM
|
|
293
263
|
export const baseTableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
294
264
|
${tableSharedStyle()};
|
|
@@ -608,9 +578,7 @@ export const baseTableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
608
578
|
|
|
609
579
|
.${ClassName.TABLE_CONTAINER}[data-number-column='true'] {
|
|
610
580
|
.${ClassName.CORNER_CONTROLS}, .${ClassName.CONTROLS_CORNER_BUTTON} {
|
|
611
|
-
width: ${
|
|
612
|
-
? akEditorTableToolbarSize + akEditorTableNumberColumnWidth + 1
|
|
613
|
-
: akEditorTableToolbarSize + akEditorTableNumberColumnWidth}px;
|
|
581
|
+
width: ${akEditorTableToolbarSize + akEditorTableNumberColumnWidth + 1}px;
|
|
614
582
|
}
|
|
615
583
|
.${ClassName.ROW_CONTROLS} .${ClassName.CONTROLS_BUTTON} {
|
|
616
584
|
border-right-width: 0;
|
|
@@ -861,9 +829,7 @@ export const baseTableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
861
829
|
.${ClassName.NUMBERED_COLUMN} {
|
|
862
830
|
position: relative;
|
|
863
831
|
float: right;
|
|
864
|
-
margin-left: ${
|
|
865
|
-
? akEditorTableToolbarSize
|
|
866
|
-
: akEditorTableToolbarSize - 1}px;
|
|
832
|
+
margin-left: ${akEditorTableToolbarSize}px;
|
|
867
833
|
top: ${props.featureFlags?.tableDragAndDrop
|
|
868
834
|
? 0
|
|
869
835
|
: akEditorTableToolbarSize}px;
|
|
@@ -914,9 +880,7 @@ export const baseTableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
914
880
|
display: block;
|
|
915
881
|
}
|
|
916
882
|
.${ClassName.NUMBERED_COLUMN} {
|
|
917
|
-
padding-left:
|
|
918
|
-
? 0
|
|
919
|
-
: 1}px;
|
|
883
|
+
padding-left: 0px;
|
|
920
884
|
|
|
921
885
|
.${ClassName.NUMBERED_COLUMN_BUTTON} {
|
|
922
886
|
border-left: 0 none;
|
|
@@ -1082,23 +1046,21 @@ export const baseTableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
1082
1046
|
z-index: ${akEditorTableCellOnStickyHeaderZIndex - 4};
|
|
1083
1047
|
}
|
|
1084
1048
|
|
|
1085
|
-
|
|
1049
|
+
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
1050
|
+
padding-bottom: 0px;
|
|
1051
|
+
/* fixes gap cursor height */
|
|
1052
|
+
overflow: auto;
|
|
1053
|
+
overflow-y: hidden;
|
|
1054
|
+
position: relative;
|
|
1055
|
+
|
|
1056
|
+
> table[data-number-column='true'] {
|
|
1057
|
+
width: calc(100% - 1px);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1086
1060
|
`;
|
|
1087
1061
|
|
|
1088
1062
|
// TODO: https://product-fabric.atlassian.net/browse/DSP-4139
|
|
1089
1063
|
export const tableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
1090
|
-
.${ClassName.LAYOUT_BUTTON} button {
|
|
1091
|
-
background: ${token('color.background.neutral', N20A)};
|
|
1092
|
-
color: ${token('color.icon', N300)};
|
|
1093
|
-
cursor: none;
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
.${ClassName.LAYOUT_BUTTON}:not(.${ClassName.IS_RESIZING}) button:hover {
|
|
1097
|
-
background: ${token('color.background.neutral.hovered', B300)};
|
|
1098
|
-
color: ${token('color.icon', 'white')} !important;
|
|
1099
|
-
cursor: pointer;
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
1064
|
.ProseMirror {
|
|
1103
1065
|
${baseTableStyles(props)}
|
|
1104
1066
|
}
|
package/src/ui/ui-styles.ts
CHANGED
|
@@ -374,9 +374,7 @@ export const OverflowShadow = (
|
|
|
374
374
|
${token('elevation.shadow.overflow.perimeter', 'transparent')} 0px,
|
|
375
375
|
transparent 1px
|
|
376
376
|
);
|
|
377
|
-
left: ${
|
|
378
|
-
? `calc(100% - ${tableOverflowShadowWidthWide}px)`
|
|
379
|
-
: `calc(100% - ${tableOverflowShadowWidthWide - 10}px)`};
|
|
377
|
+
left: calc(100% - ${tableOverflowShadowWidthWide}px);
|
|
380
378
|
}
|
|
381
379
|
.${ClassName.WITH_CONTROLS} {
|
|
382
380
|
${overflowShadowWidhoutDnD(isDragAndDropEnabled)}
|
|
@@ -439,26 +437,24 @@ const columnHeaderButtonSelected = () =>
|
|
|
439
437
|
});
|
|
440
438
|
|
|
441
439
|
const getFloatingDotOverrides = () => {
|
|
442
|
-
return
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
`
|
|
461
|
-
: '';
|
|
440
|
+
return css`
|
|
441
|
+
tr
|
|
442
|
+
th:last-child
|
|
443
|
+
.${ClassName.COLUMN_CONTROLS_DECORATIONS}::before,
|
|
444
|
+
tr
|
|
445
|
+
td:last-child
|
|
446
|
+
.${ClassName.COLUMN_CONTROLS_DECORATIONS}::before {
|
|
447
|
+
content: '';
|
|
448
|
+
background-color: ${tableBorderColor};
|
|
449
|
+
position: absolute;
|
|
450
|
+
height: ${lineMarkerSize}px;
|
|
451
|
+
width: ${lineMarkerSize}px;
|
|
452
|
+
border-radius: 50%;
|
|
453
|
+
pointer-events: none;
|
|
454
|
+
top: ${token('space.025', '2px')};
|
|
455
|
+
right: 0px;
|
|
456
|
+
}
|
|
457
|
+
`;
|
|
462
458
|
};
|
|
463
459
|
|
|
464
460
|
export const floatingColumnControls = () => {
|
|
@@ -755,29 +751,6 @@ export const hoveredWarningCell = css`
|
|
|
755
751
|
}
|
|
756
752
|
`;
|
|
757
753
|
|
|
758
|
-
// move the resize handle zone completely inside the table cell to avoid overflow
|
|
759
|
-
const getLastColumnResizerOverrides = () => {
|
|
760
|
-
return getBooleanFF('platform.editor.custom-table-width')
|
|
761
|
-
? css`
|
|
762
|
-
tr
|
|
763
|
-
th:last-child
|
|
764
|
-
.${ClassName.RESIZE_HANDLE_DECORATION},
|
|
765
|
-
tr
|
|
766
|
-
td:last-child
|
|
767
|
-
.${ClassName.RESIZE_HANDLE_DECORATION} {
|
|
768
|
-
background-color: transparent;
|
|
769
|
-
position: absolute;
|
|
770
|
-
width: ${resizeHandlerAreaWidth / 2}px;
|
|
771
|
-
height: 100%;
|
|
772
|
-
top: 0;
|
|
773
|
-
right: 0;
|
|
774
|
-
cursor: col-resize;
|
|
775
|
-
z-index: ${resizeHandlerZIndex};
|
|
776
|
-
}
|
|
777
|
-
`
|
|
778
|
-
: '';
|
|
779
|
-
};
|
|
780
|
-
|
|
781
754
|
// Explicit pixel values required here to ensure correct positioning and sizes of column resize handle
|
|
782
755
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
783
756
|
const resizeHandleOverrides = (isDragAndDropEnabled: boolean | undefined) => {
|
|
@@ -868,7 +841,21 @@ export const resizeHandle = (isDragAndDropEnabled: boolean | undefined) => css`
|
|
|
868
841
|
z-index: ${resizeHandlerZIndex};
|
|
869
842
|
}
|
|
870
843
|
|
|
871
|
-
|
|
844
|
+
tr
|
|
845
|
+
th:last-child
|
|
846
|
+
.${ClassName.RESIZE_HANDLE_DECORATION},
|
|
847
|
+
tr
|
|
848
|
+
td:last-child
|
|
849
|
+
.${ClassName.RESIZE_HANDLE_DECORATION} {
|
|
850
|
+
background-color: transparent;
|
|
851
|
+
position: absolute;
|
|
852
|
+
width: ${resizeHandlerAreaWidth / 2}px;
|
|
853
|
+
height: 100%;
|
|
854
|
+
top: 0;
|
|
855
|
+
right: 0;
|
|
856
|
+
cursor: col-resize;
|
|
857
|
+
z-index: ${resizeHandlerZIndex};
|
|
858
|
+
}
|
|
872
859
|
|
|
873
860
|
${resizeHandleOverrides(isDragAndDropEnabled)}
|
|
874
861
|
|
package/src/utils/index.ts
CHANGED
package/src/utils/nodes.ts
CHANGED
|
@@ -4,12 +4,9 @@ import type {
|
|
|
4
4
|
EditorState,
|
|
5
5
|
Selection,
|
|
6
6
|
} from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
8
7
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
8
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
10
9
|
|
|
11
|
-
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
12
|
-
|
|
13
10
|
export const isIsolating = (node: PmNode): boolean => {
|
|
14
11
|
return !!node.type.spec.isolating;
|
|
15
12
|
};
|
|
@@ -63,26 +60,6 @@ export const checkIfNumberColumnEnabled = (selection: Selection): boolean =>
|
|
|
63
60
|
false,
|
|
64
61
|
);
|
|
65
62
|
|
|
66
|
-
export const isLayoutSupported = (state: EditorState): boolean => {
|
|
67
|
-
const { permittedLayouts } = pluginKey.getState(state)?.pluginConfig || {};
|
|
68
|
-
const { bodiedExtension, layoutSection, expand, extensionFrame } =
|
|
69
|
-
state.schema.nodes;
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
!hasParentNodeOfType([
|
|
73
|
-
expand,
|
|
74
|
-
layoutSection,
|
|
75
|
-
bodiedExtension,
|
|
76
|
-
extensionFrame,
|
|
77
|
-
])(state.selection) &&
|
|
78
|
-
!!permittedLayouts &&
|
|
79
|
-
(permittedLayouts === 'all' ||
|
|
80
|
-
(permittedLayouts.indexOf('default') > -1 &&
|
|
81
|
-
permittedLayouts.indexOf('wide') > -1 &&
|
|
82
|
-
permittedLayouts.indexOf('full-width') > -1))
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
63
|
export const getTableWidth = (node: PmNode) => {
|
|
87
64
|
return getTableWidths(node).reduce((acc, current) => acc + current, 0);
|
|
88
65
|
};
|