@atlaskit/editor-plugin-table 3.2.1 → 4.0.1

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#40684](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40684) [`9aa958ee692`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9aa958ee692) - [ux] Makes sticky scrollbar visible in Safari and Firefox by setting height.
8
+
9
+ ## 4.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - [`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.
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 3.2.1
4
20
 
5
21
  ### Patch Changes
@@ -559,7 +559,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
559
559
  }
560
560
  }, /*#__PURE__*/_react.default.createElement("div", {
561
561
  style: {
562
- width: tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth
562
+ width: tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth,
563
+ height: '100%'
563
564
  }
564
565
  })), /*#__PURE__*/_react.default.createElement("div", {
565
566
  style: shadowStyle(showAfterShadow),
@@ -38,15 +38,16 @@ var messages = (0, _reactIntlNext.defineMessages)({
38
38
  var handles = {
39
39
  right: true
40
40
  };
41
- var tableHandleMarginTop = 12;
42
- var tableHandlePosition = 14;
43
- var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
44
- var tableHeight = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight;
45
- var handleHeightSize = 'small';
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 > 46 && tableHeight < 96) {
59
- handleHeightSize = 'medium';
60
- } else if (tableHeight >= 96) {
61
- handleHeightSize = 'large';
59
+ if (tableHeight >= 96) {
60
+ return 'large';
61
+ }
62
+ if (tableHeight > 46) {
63
+ return 'medium';
62
64
  }
63
- return handleHeightSize;
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 handleHeightSize = getResizerHandleHeight(tableRef);
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
- handleHeightSize: handleHeightSize,
248
- handleMarginTop: tableHandleMarginTop,
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",
@@ -560,7 +560,8 @@ class TableComponent extends React.Component {
560
560
  }
561
561
  }, /*#__PURE__*/React.createElement("div", {
562
562
  style: {
563
- width: tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth
563
+ width: tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth,
564
+ height: '100%'
564
565
  }
565
566
  })), /*#__PURE__*/React.createElement("div", {
566
567
  style: shadowStyle(showAfterShadow),
@@ -24,15 +24,16 @@ const messages = defineMessages({
24
24
  const handles = {
25
25
  right: true
26
26
  };
27
- const tableHandleMarginTop = 12;
28
- const tableHandlePosition = 14;
29
- const getResizerHandleHeight = tableRef => {
30
- const tableHeight = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight;
31
- let handleHeightSize = 'small';
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 > 46 && tableHeight < 96) {
45
- handleHeightSize = 'medium';
46
- } else if (tableHeight >= 96) {
47
- handleHeightSize = 'large';
45
+ if (tableHeight >= 96) {
46
+ return 'large';
47
+ }
48
+ if (tableHeight > 46) {
49
+ return 'medium';
48
50
  }
49
- return handleHeightSize;
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 handleHeightSize = getResizerHandleHeight(tableRef);
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
- handleHeightSize: handleHeightSize,
243
- handleMarginTop: tableHandleMarginTop,
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",
@@ -552,7 +552,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
552
552
  }
553
553
  }, /*#__PURE__*/React.createElement("div", {
554
554
  style: {
555
- width: tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth
555
+ width: tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth,
556
+ height: '100%'
556
557
  }
557
558
  })), /*#__PURE__*/React.createElement("div", {
558
559
  style: shadowStyle(showAfterShadow),
@@ -28,15 +28,16 @@ var messages = defineMessages({
28
28
  var handles = {
29
29
  right: true
30
30
  };
31
- var tableHandleMarginTop = 12;
32
- var tableHandlePosition = 14;
33
- var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
34
- var tableHeight = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight;
35
- var handleHeightSize = 'small';
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 > 46 && tableHeight < 96) {
49
- handleHeightSize = 'medium';
50
- } else if (tableHeight >= 96) {
51
- handleHeightSize = 'large';
49
+ if (tableHeight >= 96) {
50
+ return 'large';
51
+ }
52
+ if (tableHeight > 46) {
53
+ return 'medium';
52
54
  }
53
- return handleHeightSize;
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 handleHeightSize = getResizerHandleHeight(tableRef);
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
- handleHeightSize: handleHeightSize,
238
- handleMarginTop: tableHandleMarginTop,
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.2.1",
3
+ "version": "4.0.1",
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": "^75.8.0",
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",
@@ -524,7 +524,12 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
524
524
  display: 'none',
525
525
  }}
526
526
  >
527
- <div style={{ width: tableRef?.clientWidth }}></div>
527
+ <div
528
+ style={{
529
+ width: tableRef?.clientWidth,
530
+ height: '100%',
531
+ }}
532
+ ></div>
528
533
  </div>
529
534
  )}
530
535
  <div
@@ -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 tableHandleMarginTop = 12;
81
- const tableHandlePosition = 14;
82
-
83
- const getResizerHandleHeight = (tableRef: HTMLTableElement | undefined) => {
84
- const tableHeight = tableRef?.clientHeight;
85
- let handleHeightSize: HandleHeightSizeType | undefined = 'small';
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 > 46 && tableHeight < 96) {
101
- handleHeightSize = 'medium';
102
- } else if (tableHeight >= 96) {
103
- handleHeightSize = 'large';
99
+ if (tableHeight >= 96) {
100
+ return 'large';
101
+ }
102
+
103
+ if (tableHeight > 46) {
104
+ return 'medium';
104
105
  }
105
106
 
106
- return handleHeightSize;
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 handleHeightSize = getResizerHandleHeight(tableRef);
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
- handleHeightSize={handleHeightSize}
393
- handleMarginTop={tableHandleMarginTop}
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"