@atlaskit/editor-plugin-table 3.2.1 → 4.0.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 +10 -0
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +18 -17
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +18 -17
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +18 -17
- package/package.json +2 -2
- package/src/plugins/table/nodeviews/TableResizer.tsx +23 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`151b0d45db4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/151b0d45db4) - Changed Resizer API. Removed handleComponent, innerPadding & handleMarginTop. Also renamed HandleHeightSizeType to HandleSize. The resizer should be opionated and control the handle component itself. innerPadding & handleMarginTop can also be controlled via the handleStyles override property.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 3.2.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -38,15 +38,16 @@ var messages = (0, _reactIntlNext.defineMessages)({
|
|
|
38
38
|
var handles = {
|
|
39
39
|
right: true
|
|
40
40
|
};
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (!tableHeight) {
|
|
47
|
-
return handleHeightSize;
|
|
41
|
+
var handleStyles = {
|
|
42
|
+
right: {
|
|
43
|
+
// eslint-disable-next-line
|
|
44
|
+
right: '-14px',
|
|
45
|
+
marginTop: "var(--ds-space-150, 12px)"
|
|
48
46
|
}
|
|
49
|
-
|
|
47
|
+
};
|
|
48
|
+
var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
|
|
49
|
+
var _tableRef$clientHeigh;
|
|
50
|
+
var tableHeight = (_tableRef$clientHeigh = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight) !== null && _tableRef$clientHeigh !== void 0 ? _tableRef$clientHeigh : 0;
|
|
50
51
|
/*
|
|
51
52
|
- One row table height (minimum possible table height) ~ 45px
|
|
52
53
|
- Two row table height ~ 90px
|
|
@@ -55,12 +56,13 @@ var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
|
|
|
55
56
|
- > 46 because the height of the table can be a float number like 45.44.
|
|
56
57
|
- < 96 is the height of large resize handle.
|
|
57
58
|
*/
|
|
58
|
-
if (tableHeight
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
59
|
+
if (tableHeight >= 96) {
|
|
60
|
+
return 'large';
|
|
61
|
+
}
|
|
62
|
+
if (tableHeight > 46) {
|
|
63
|
+
return 'medium';
|
|
62
64
|
}
|
|
63
|
-
return
|
|
65
|
+
return 'small';
|
|
64
66
|
};
|
|
65
67
|
var getResizerMinWidth = function getResizerMinWidth(node) {
|
|
66
68
|
var currentColumnCount = (0, _utils2.getColgroupChildrenLength)(node);
|
|
@@ -107,7 +109,7 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
107
109
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
108
110
|
formatMessage = _useIntl.formatMessage;
|
|
109
111
|
var resizerMinWidth = getResizerMinWidth(node);
|
|
110
|
-
var
|
|
112
|
+
var handleSize = getResizerHandleHeight(tableRef);
|
|
111
113
|
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
112
114
|
isInDanger = _getPluginState.isInDanger;
|
|
113
115
|
var _useMeasureFramerate = (0, _analytics2.useMeasureFramerate)(),
|
|
@@ -244,8 +246,8 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
244
246
|
enable: handles,
|
|
245
247
|
width: width,
|
|
246
248
|
handleAlignmentMethod: "sticky",
|
|
247
|
-
|
|
248
|
-
|
|
249
|
+
handleSize: handleSize,
|
|
250
|
+
handleStyles: handleStyles,
|
|
249
251
|
handleResizeStart: handleResizeStart,
|
|
250
252
|
handleResize: scheduleResize,
|
|
251
253
|
handleResizeStop: handleResizeStop,
|
|
@@ -255,7 +257,6 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
255
257
|
snapGap: _consts.TABLE_SNAP_GAP,
|
|
256
258
|
snap: guidelineSnaps,
|
|
257
259
|
handlePositioning: "adjacent",
|
|
258
|
-
innerPadding: tableHandlePosition,
|
|
259
260
|
isHandleVisible: isTableSelected,
|
|
260
261
|
appearance: isInDanger && isTableSelected ? 'danger' : undefined,
|
|
261
262
|
handleHighlight: "shadow",
|
|
@@ -24,15 +24,16 @@ const messages = defineMessages({
|
|
|
24
24
|
const handles = {
|
|
25
25
|
right: true
|
|
26
26
|
};
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (!tableHeight) {
|
|
33
|
-
return handleHeightSize;
|
|
27
|
+
const handleStyles = {
|
|
28
|
+
right: {
|
|
29
|
+
// eslint-disable-next-line
|
|
30
|
+
right: '-14px',
|
|
31
|
+
marginTop: "var(--ds-space-150, 12px)"
|
|
34
32
|
}
|
|
35
|
-
|
|
33
|
+
};
|
|
34
|
+
const getResizerHandleHeight = tableRef => {
|
|
35
|
+
var _tableRef$clientHeigh;
|
|
36
|
+
const tableHeight = (_tableRef$clientHeigh = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight) !== null && _tableRef$clientHeigh !== void 0 ? _tableRef$clientHeigh : 0;
|
|
36
37
|
/*
|
|
37
38
|
- One row table height (minimum possible table height) ~ 45px
|
|
38
39
|
- Two row table height ~ 90px
|
|
@@ -41,12 +42,13 @@ const getResizerHandleHeight = tableRef => {
|
|
|
41
42
|
- > 46 because the height of the table can be a float number like 45.44.
|
|
42
43
|
- < 96 is the height of large resize handle.
|
|
43
44
|
*/
|
|
44
|
-
if (tableHeight
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
45
|
+
if (tableHeight >= 96) {
|
|
46
|
+
return 'large';
|
|
47
|
+
}
|
|
48
|
+
if (tableHeight > 46) {
|
|
49
|
+
return 'medium';
|
|
48
50
|
}
|
|
49
|
-
return
|
|
51
|
+
return 'small';
|
|
50
52
|
};
|
|
51
53
|
const getResizerMinWidth = node => {
|
|
52
54
|
const currentColumnCount = getColgroupChildrenLength(node);
|
|
@@ -92,7 +94,7 @@ export const TableResizer = ({
|
|
|
92
94
|
formatMessage
|
|
93
95
|
} = useIntl();
|
|
94
96
|
const resizerMinWidth = getResizerMinWidth(node);
|
|
95
|
-
const
|
|
97
|
+
const handleSize = getResizerHandleHeight(tableRef);
|
|
96
98
|
const {
|
|
97
99
|
isInDanger
|
|
98
100
|
} = getPluginState(editorView.state);
|
|
@@ -239,8 +241,8 @@ export const TableResizer = ({
|
|
|
239
241
|
enable: handles,
|
|
240
242
|
width: width,
|
|
241
243
|
handleAlignmentMethod: "sticky",
|
|
242
|
-
|
|
243
|
-
|
|
244
|
+
handleSize: handleSize,
|
|
245
|
+
handleStyles: handleStyles,
|
|
244
246
|
handleResizeStart: handleResizeStart,
|
|
245
247
|
handleResize: scheduleResize,
|
|
246
248
|
handleResizeStop: handleResizeStop,
|
|
@@ -250,7 +252,6 @@ export const TableResizer = ({
|
|
|
250
252
|
snapGap: TABLE_SNAP_GAP,
|
|
251
253
|
snap: guidelineSnaps,
|
|
252
254
|
handlePositioning: "adjacent",
|
|
253
|
-
innerPadding: tableHandlePosition,
|
|
254
255
|
isHandleVisible: isTableSelected,
|
|
255
256
|
appearance: isInDanger && isTableSelected ? 'danger' : undefined,
|
|
256
257
|
handleHighlight: "shadow",
|
|
@@ -28,15 +28,16 @@ var messages = defineMessages({
|
|
|
28
28
|
var handles = {
|
|
29
29
|
right: true
|
|
30
30
|
};
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (!tableHeight) {
|
|
37
|
-
return handleHeightSize;
|
|
31
|
+
var handleStyles = {
|
|
32
|
+
right: {
|
|
33
|
+
// eslint-disable-next-line
|
|
34
|
+
right: '-14px',
|
|
35
|
+
marginTop: "var(--ds-space-150, 12px)"
|
|
38
36
|
}
|
|
39
|
-
|
|
37
|
+
};
|
|
38
|
+
var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
|
|
39
|
+
var _tableRef$clientHeigh;
|
|
40
|
+
var tableHeight = (_tableRef$clientHeigh = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight) !== null && _tableRef$clientHeigh !== void 0 ? _tableRef$clientHeigh : 0;
|
|
40
41
|
/*
|
|
41
42
|
- One row table height (minimum possible table height) ~ 45px
|
|
42
43
|
- Two row table height ~ 90px
|
|
@@ -45,12 +46,13 @@ var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
|
|
|
45
46
|
- > 46 because the height of the table can be a float number like 45.44.
|
|
46
47
|
- < 96 is the height of large resize handle.
|
|
47
48
|
*/
|
|
48
|
-
if (tableHeight
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
49
|
+
if (tableHeight >= 96) {
|
|
50
|
+
return 'large';
|
|
51
|
+
}
|
|
52
|
+
if (tableHeight > 46) {
|
|
53
|
+
return 'medium';
|
|
52
54
|
}
|
|
53
|
-
return
|
|
55
|
+
return 'small';
|
|
54
56
|
};
|
|
55
57
|
var getResizerMinWidth = function getResizerMinWidth(node) {
|
|
56
58
|
var currentColumnCount = getColgroupChildrenLength(node);
|
|
@@ -97,7 +99,7 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
97
99
|
var _useIntl = useIntl(),
|
|
98
100
|
formatMessage = _useIntl.formatMessage;
|
|
99
101
|
var resizerMinWidth = getResizerMinWidth(node);
|
|
100
|
-
var
|
|
102
|
+
var handleSize = getResizerHandleHeight(tableRef);
|
|
101
103
|
var _getPluginState = getPluginState(editorView.state),
|
|
102
104
|
isInDanger = _getPluginState.isInDanger;
|
|
103
105
|
var _useMeasureFramerate = useMeasureFramerate(),
|
|
@@ -234,8 +236,8 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
234
236
|
enable: handles,
|
|
235
237
|
width: width,
|
|
236
238
|
handleAlignmentMethod: "sticky",
|
|
237
|
-
|
|
238
|
-
|
|
239
|
+
handleSize: handleSize,
|
|
240
|
+
handleStyles: handleStyles,
|
|
239
241
|
handleResizeStart: handleResizeStart,
|
|
240
242
|
handleResize: scheduleResize,
|
|
241
243
|
handleResizeStop: handleResizeStop,
|
|
@@ -245,7 +247,6 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
245
247
|
snapGap: TABLE_SNAP_GAP,
|
|
246
248
|
snap: guidelineSnaps,
|
|
247
249
|
handlePositioning: "adjacent",
|
|
248
|
-
innerPadding: tableHandlePosition,
|
|
249
250
|
isHandleVisible: isTableSelected,
|
|
250
251
|
appearance: isInDanger && isTableSelected ? 'danger' : undefined,
|
|
251
252
|
handleHighlight: "shadow",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/adf-schema": "^29.1.0",
|
|
31
|
-
"@atlaskit/editor-common": "^
|
|
31
|
+
"@atlaskit/editor-common": "^76.0.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.1",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^0.2.0",
|
|
34
34
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
@@ -14,16 +14,14 @@ import type { TableEventPayload } from '@atlaskit/editor-common/analytics';
|
|
|
14
14
|
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
15
15
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
16
16
|
import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
17
|
-
import type {
|
|
18
|
-
HandleHeightSizeType,
|
|
19
|
-
HandleResize,
|
|
20
|
-
} from '@atlaskit/editor-common/resizer';
|
|
17
|
+
import type { HandleResize, HandleSize } from '@atlaskit/editor-common/resizer';
|
|
21
18
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
22
19
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
23
20
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
24
21
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
25
22
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
26
23
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
24
|
+
import { token } from '@atlaskit/tokens';
|
|
27
25
|
|
|
28
26
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
29
27
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
@@ -77,17 +75,18 @@ const messages = defineMessages({
|
|
|
77
75
|
});
|
|
78
76
|
|
|
79
77
|
const handles = { right: true };
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (!tableHeight) {
|
|
88
|
-
return handleHeightSize;
|
|
89
|
-
}
|
|
78
|
+
const handleStyles = {
|
|
79
|
+
right: {
|
|
80
|
+
// eslint-disable-next-line
|
|
81
|
+
right: '-14px',
|
|
82
|
+
marginTop: token('space.150', '12px'),
|
|
83
|
+
},
|
|
84
|
+
};
|
|
90
85
|
|
|
86
|
+
const getResizerHandleHeight = (
|
|
87
|
+
tableRef: HTMLTableElement | undefined,
|
|
88
|
+
): HandleSize | undefined => {
|
|
89
|
+
const tableHeight = tableRef?.clientHeight ?? 0;
|
|
91
90
|
/*
|
|
92
91
|
- One row table height (minimum possible table height) ~ 45px
|
|
93
92
|
- Two row table height ~ 90px
|
|
@@ -97,13 +96,15 @@ const getResizerHandleHeight = (tableRef: HTMLTableElement | undefined) => {
|
|
|
97
96
|
- > 46 because the height of the table can be a float number like 45.44.
|
|
98
97
|
- < 96 is the height of large resize handle.
|
|
99
98
|
*/
|
|
100
|
-
if (tableHeight
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
99
|
+
if (tableHeight >= 96) {
|
|
100
|
+
return 'large';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (tableHeight > 46) {
|
|
104
|
+
return 'medium';
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
return
|
|
107
|
+
return 'small';
|
|
107
108
|
};
|
|
108
109
|
|
|
109
110
|
const getResizerMinWidth = (node: PMNode) => {
|
|
@@ -160,7 +161,7 @@ export const TableResizer = ({
|
|
|
160
161
|
const { formatMessage } = useIntl();
|
|
161
162
|
|
|
162
163
|
const resizerMinWidth = getResizerMinWidth(node);
|
|
163
|
-
const
|
|
164
|
+
const handleSize = getResizerHandleHeight(tableRef);
|
|
164
165
|
const { isInDanger } = getPluginState(editorView.state);
|
|
165
166
|
|
|
166
167
|
const { startMeasure, endMeasure, countFrames } = useMeasureFramerate();
|
|
@@ -389,8 +390,8 @@ export const TableResizer = ({
|
|
|
389
390
|
enable={handles}
|
|
390
391
|
width={width}
|
|
391
392
|
handleAlignmentMethod="sticky"
|
|
392
|
-
|
|
393
|
-
|
|
393
|
+
handleSize={handleSize}
|
|
394
|
+
handleStyles={handleStyles}
|
|
394
395
|
handleResizeStart={handleResizeStart}
|
|
395
396
|
handleResize={scheduleResize}
|
|
396
397
|
handleResizeStop={handleResizeStop}
|
|
@@ -400,7 +401,6 @@ export const TableResizer = ({
|
|
|
400
401
|
snapGap={TABLE_SNAP_GAP}
|
|
401
402
|
snap={guidelineSnaps}
|
|
402
403
|
handlePositioning="adjacent"
|
|
403
|
-
innerPadding={tableHandlePosition}
|
|
404
404
|
isHandleVisible={isTableSelected}
|
|
405
405
|
appearance={isInDanger && isTableSelected ? 'danger' : undefined}
|
|
406
406
|
handleHighlight="shadow"
|