@atlaskit/editor-plugin-table 7.16.2 → 7.16.3

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,14 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.16.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#102385](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102385)
8
+ [`501e08d95a31`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/501e08d95a31) -
9
+ [ux] Resize ratio depends on table alignment option. Fixed resize ratio for the cases when table
10
+ alignment is not 'center'.
11
+
3
12
  ## 7.16.2
4
13
 
5
14
  ### Patch Changes
@@ -163,6 +163,7 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
163
163
  displayGuideline: displayGuideline,
164
164
  attachAnalyticsEvent: attachAnalyticsEvent,
165
165
  displayGapCursor: displayGapCursor,
166
+ isTableAlignmentEnabled: isTableAlignmentEnabled,
166
167
  isTableScalingEnabled: isTableScalingEnabled,
167
168
  isWholeTableInDanger: isWholeTableInDanger,
168
169
  pluginInjectionApi: pluginInjectionApi,
@@ -25,6 +25,7 @@ var _tableAnalytics = require("../pm-plugins/table-analytics");
25
25
  var _utils3 = require("../pm-plugins/table-resizing/utils");
26
26
  var _tableWidth = require("../pm-plugins/table-width");
27
27
  var _consts = require("../ui/consts");
28
+ var _alignment = require("../utils/alignment");
28
29
  var _analytics2 = require("../utils/analytics");
29
30
  var _guidelines = require("../utils/guidelines");
30
31
  var _snapping = require("../utils/snapping");
@@ -98,6 +99,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
98
99
  attachAnalyticsEvent = _ref.attachAnalyticsEvent,
99
100
  displayGapCursor = _ref.displayGapCursor,
100
101
  isTableScalingEnabled = _ref.isTableScalingEnabled,
102
+ isTableAlignmentEnabled = _ref.isTableAlignmentEnabled,
101
103
  isWholeTableInDanger = _ref.isWholeTableInDanger,
102
104
  pluginInjectionApi = _ref.pluginInjectionApi;
103
105
  var currentGap = (0, _react.useRef)(0);
@@ -365,6 +367,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
365
367
  (_updateTooltip$curren = updateTooltip.current) === null || _updateTooltip$curren === void 0 || _updateTooltip$curren.call(updateTooltip);
366
368
  }
367
369
  }, [width]);
370
+ var resizeRatio = !isTableAlignmentEnabled || isTableAlignmentEnabled && (0, _alignment.normaliseAlignment)(node.attrs.layout) === 'center' ? 2 : 1;
368
371
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_resizer.ResizerNext, {
369
372
  ref: resizerRef,
370
373
  enable: handles,
@@ -375,7 +378,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
375
378
  handleResizeStart: handleResizeStart,
376
379
  handleResize: scheduleResize,
377
380
  handleResizeStop: handleResizeStop,
378
- resizeRatio: 2,
381
+ resizeRatio: resizeRatio,
379
382
  minWidth: resizerMinWidth,
380
383
  maxWidth: maxWidth,
381
384
  snapGap: _consts.TABLE_SNAP_GAP,
@@ -154,6 +154,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
154
154
  displayGuideline,
155
155
  attachAnalyticsEvent,
156
156
  displayGapCursor,
157
+ isTableAlignmentEnabled,
157
158
  isTableScalingEnabled,
158
159
  isWholeTableInDanger,
159
160
  pluginInjectionApi,
@@ -15,6 +15,7 @@ import { META_KEYS } from '../pm-plugins/table-analytics';
15
15
  import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
16
16
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
17
17
  import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
18
+ import { normaliseAlignment } from '../utils/alignment';
18
19
  import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
19
20
  import { defaultGuidelines, defaultGuidelinesForPreserveTable } from '../utils/guidelines';
20
21
  import { defaultSnappingWidths, defaultTablePreserveSnappingWidths, findClosestSnap } from '../utils/snapping';
@@ -83,6 +84,7 @@ export const TableResizer = ({
83
84
  attachAnalyticsEvent,
84
85
  displayGapCursor,
85
86
  isTableScalingEnabled,
87
+ isTableAlignmentEnabled,
86
88
  isWholeTableInDanger,
87
89
  pluginInjectionApi
88
90
  }) => {
@@ -363,6 +365,7 @@ export const TableResizer = ({
363
365
  (_updateTooltip$curren = updateTooltip.current) === null || _updateTooltip$curren === void 0 ? void 0 : _updateTooltip$curren.call(updateTooltip);
364
366
  }
365
367
  }, [width]);
368
+ const resizeRatio = !isTableAlignmentEnabled || isTableAlignmentEnabled && normaliseAlignment(node.attrs.layout) === 'center' ? 2 : 1;
366
369
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ResizerNext, {
367
370
  ref: resizerRef,
368
371
  enable: handles,
@@ -373,7 +376,7 @@ export const TableResizer = ({
373
376
  handleResizeStart: handleResizeStart,
374
377
  handleResize: scheduleResize,
375
378
  handleResizeStop: handleResizeStop,
376
- resizeRatio: 2,
379
+ resizeRatio: resizeRatio,
377
380
  minWidth: resizerMinWidth,
378
381
  maxWidth: maxWidth,
379
382
  snapGap: TABLE_SNAP_GAP,
@@ -153,6 +153,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
153
153
  displayGuideline: displayGuideline,
154
154
  attachAnalyticsEvent: attachAnalyticsEvent,
155
155
  displayGapCursor: displayGapCursor,
156
+ isTableAlignmentEnabled: isTableAlignmentEnabled,
156
157
  isTableScalingEnabled: isTableScalingEnabled,
157
158
  isWholeTableInDanger: isWholeTableInDanger,
158
159
  pluginInjectionApi: pluginInjectionApi,
@@ -19,6 +19,7 @@ import { META_KEYS } from '../pm-plugins/table-analytics';
19
19
  import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
20
20
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
21
21
  import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
22
+ import { normaliseAlignment } from '../utils/alignment';
22
23
  import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
23
24
  import { defaultGuidelines, defaultGuidelinesForPreserveTable } from '../utils/guidelines';
24
25
  import { defaultSnappingWidths, defaultTablePreserveSnappingWidths, findClosestSnap } from '../utils/snapping';
@@ -88,6 +89,7 @@ export var TableResizer = function TableResizer(_ref) {
88
89
  attachAnalyticsEvent = _ref.attachAnalyticsEvent,
89
90
  displayGapCursor = _ref.displayGapCursor,
90
91
  isTableScalingEnabled = _ref.isTableScalingEnabled,
92
+ isTableAlignmentEnabled = _ref.isTableAlignmentEnabled,
91
93
  isWholeTableInDanger = _ref.isWholeTableInDanger,
92
94
  pluginInjectionApi = _ref.pluginInjectionApi;
93
95
  var currentGap = useRef(0);
@@ -355,6 +357,7 @@ export var TableResizer = function TableResizer(_ref) {
355
357
  (_updateTooltip$curren = updateTooltip.current) === null || _updateTooltip$curren === void 0 || _updateTooltip$curren.call(updateTooltip);
356
358
  }
357
359
  }, [width]);
360
+ var resizeRatio = !isTableAlignmentEnabled || isTableAlignmentEnabled && normaliseAlignment(node.attrs.layout) === 'center' ? 2 : 1;
358
361
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ResizerNext, {
359
362
  ref: resizerRef,
360
363
  enable: handles,
@@ -365,7 +368,7 @@ export var TableResizer = function TableResizer(_ref) {
365
368
  handleResizeStart: handleResizeStart,
366
369
  handleResize: scheduleResize,
367
370
  handleResizeStop: handleResizeStop,
368
- resizeRatio: 2,
371
+ resizeRatio: resizeRatio,
369
372
  minWidth: resizerMinWidth,
370
373
  maxWidth: maxWidth,
371
374
  snapGap: TABLE_SNAP_GAP,
@@ -19,11 +19,12 @@ interface TableResizerProps {
19
19
  displayGapCursor: (toggle: boolean) => boolean;
20
20
  pluginInjectionApi?: PluginInjectionAPI;
21
21
  isTableScalingEnabled?: boolean;
22
+ isTableAlignmentEnabled?: boolean;
22
23
  isWholeTableInDanger?: boolean;
23
24
  }
24
25
  export interface TableResizerImprovementProps extends TableResizerProps {
25
26
  onResizeStop?: () => void;
26
27
  onResizeStart?: () => void;
27
28
  }
28
- export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isWholeTableInDanger, pluginInjectionApi, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
29
+ export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isTableAlignmentEnabled, isWholeTableInDanger, pluginInjectionApi, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
29
30
  export {};
@@ -19,11 +19,12 @@ interface TableResizerProps {
19
19
  displayGapCursor: (toggle: boolean) => boolean;
20
20
  pluginInjectionApi?: PluginInjectionAPI;
21
21
  isTableScalingEnabled?: boolean;
22
+ isTableAlignmentEnabled?: boolean;
22
23
  isWholeTableInDanger?: boolean;
23
24
  }
24
25
  export interface TableResizerImprovementProps extends TableResizerProps {
25
26
  onResizeStop?: () => void;
26
27
  onResizeStart?: () => void;
27
28
  }
28
- export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isWholeTableInDanger, pluginInjectionApi, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
29
+ export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isTableAlignmentEnabled, isWholeTableInDanger, pluginInjectionApi, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
29
30
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.16.2",
3
+ "version": "7.16.3",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -254,6 +254,7 @@ export const ResizableTableContainer = React.memo(
254
254
  displayGuideline,
255
255
  attachAnalyticsEvent,
256
256
  displayGapCursor,
257
+ isTableAlignmentEnabled,
257
258
  isTableScalingEnabled,
258
259
  isWholeTableInDanger,
259
260
  pluginInjectionApi,
@@ -48,6 +48,7 @@ import {
48
48
  TABLE_HIGHLIGHT_TOLERANCE,
49
49
  TABLE_SNAP_GAP,
50
50
  } from '../ui/consts';
51
+ import { normaliseAlignment } from '../utils/alignment';
51
52
  import {
52
53
  generateResizedPayload,
53
54
  generateResizeFrameRatePayloads,
@@ -79,6 +80,7 @@ interface TableResizerProps {
79
80
  displayGapCursor: (toggle: boolean) => boolean;
80
81
  pluginInjectionApi?: PluginInjectionAPI;
81
82
  isTableScalingEnabled?: boolean;
83
+ isTableAlignmentEnabled?: boolean;
82
84
  isWholeTableInDanger?: boolean;
83
85
  }
84
86
 
@@ -169,6 +171,7 @@ export const TableResizer = ({
169
171
  attachAnalyticsEvent,
170
172
  displayGapCursor,
171
173
  isTableScalingEnabled,
174
+ isTableAlignmentEnabled,
172
175
  isWholeTableInDanger,
173
176
  pluginInjectionApi,
174
177
  }: PropsWithChildren<TableResizerImprovementProps>) => {
@@ -594,6 +597,13 @@ export const TableResizer = ({
594
597
  }
595
598
  }, [width]);
596
599
 
600
+ const resizeRatio =
601
+ !isTableAlignmentEnabled ||
602
+ (isTableAlignmentEnabled &&
603
+ normaliseAlignment(node.attrs.layout) === 'center')
604
+ ? 2
605
+ : 1;
606
+
597
607
  return (
598
608
  <>
599
609
  <ResizerNext
@@ -606,7 +616,7 @@ export const TableResizer = ({
606
616
  handleResizeStart={handleResizeStart}
607
617
  handleResize={scheduleResize}
608
618
  handleResizeStop={handleResizeStop}
609
- resizeRatio={2}
619
+ resizeRatio={resizeRatio}
610
620
  minWidth={resizerMinWidth}
611
621
  maxWidth={maxWidth}
612
622
  snapGap={TABLE_SNAP_GAP}