@atlaskit/editor-plugin-table 7.1.1 → 7.1.2

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,11 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#70109](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70109) [`ecf39362df41`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ecf39362df41) - The drag preview size will now match the same size of the selection row/col region when a drag is started.
8
+
3
9
  ## 7.1.1
4
10
 
5
11
  ### Patch Changes
@@ -136,7 +136,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
136
136
  };
137
137
  }, [tableWrapper, handleScroll]);
138
138
  var generateHandleByType = function generateHandleByType(type) {
139
- var _rowHeights$reduce, _colWidths;
139
+ var _rowHeights$reduce, _colWidths$reduce;
140
140
  if (!hoveredCell || !(colWidths !== null && colWidths !== void 0 && colWidths.length)) {
141
141
  return null;
142
142
  }
@@ -157,6 +157,9 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
157
157
 
158
158
  // this indexes are used to calculate the drag and drop source
159
159
  var indexes = isColumnsSelected ? isHover ? colIndexes : selectedColIndexes : colIndexes;
160
+ var previewWidth = (_colWidths$reduce = colWidths === null || colWidths === void 0 ? void 0 : colWidths.reduce(function (sum, v, i) {
161
+ return sum + (v !== null && v !== void 0 ? v : _styles.tableCellMinWidth) * (indexes.includes(i) ? 1 : 0);
162
+ }, 0)) !== null && _colWidths$reduce !== void 0 ? _colWidths$reduce : _styles.tableCellMinWidth;
160
163
  return /*#__PURE__*/_react.default.createElement("div", {
161
164
  key: type,
162
165
  style: {
@@ -178,7 +181,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
178
181
  tableLocalId: localId || '',
179
182
  indexes: indexes,
180
183
  forceDefaultHandle: isHover ? false : isColumnsSelected,
181
- previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : _styles.tableCellMinWidth,
184
+ previewWidth: previewWidth,
182
185
  previewHeight: previewHeight,
183
186
  appearance: isSelecting ? currentSelectionAppearance : hoveredAppearance,
184
187
  onClick: handleClick,
@@ -143,6 +143,9 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
143
143
  var currentSelectionAppearance = isRowsSelected ? isInDanger ? 'danger' : 'selected' : hoveredAppearance;
144
144
  var isSelecting = isRowsSelected && !isHover;
145
145
  var indexes = isRowsSelected ? isHover ? rowIndexes : selectedRowIndexes : rowIndexes;
146
+ var previewHeight = rowHeights.reduce(function (sum, v, i) {
147
+ return sum + v * (indexes.includes(i) ? 1 : 0);
148
+ }, 0);
146
149
  return /*#__PURE__*/_react.default.createElement("div", {
147
150
  key: type,
148
151
  style: {
@@ -163,7 +166,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
163
166
  indexes: indexes,
164
167
  forceDefaultHandle: isHover ? false : isRowsSelected,
165
168
  previewWidth: tableWidth,
166
- previewHeight: rowHeights[rowIndex],
169
+ previewHeight: previewHeight,
167
170
  appearance: isSelecting ? currentSelectionAppearance : hoveredAppearance,
168
171
  onClick: handleClick,
169
172
  onMouseOver: handleMouseOver,
@@ -135,7 +135,7 @@ export const ColumnControls = ({
135
135
  };
136
136
  }, [tableWrapper, handleScroll]);
137
137
  const generateHandleByType = type => {
138
- var _rowHeights$reduce, _colWidths;
138
+ var _rowHeights$reduce, _colWidths$reduce;
139
139
  if (!hoveredCell || !(colWidths !== null && colWidths !== void 0 && colWidths.length)) {
140
140
  return null;
141
141
  }
@@ -154,6 +154,7 @@ export const ColumnControls = ({
154
154
 
155
155
  // this indexes are used to calculate the drag and drop source
156
156
  const indexes = isColumnsSelected ? isHover ? colIndexes : selectedColIndexes : colIndexes;
157
+ const previewWidth = (_colWidths$reduce = colWidths === null || colWidths === void 0 ? void 0 : colWidths.reduce((sum, v, i) => sum + (v !== null && v !== void 0 ? v : tableCellMinWidth) * (indexes.includes(i) ? 1 : 0), 0)) !== null && _colWidths$reduce !== void 0 ? _colWidths$reduce : tableCellMinWidth;
157
158
  return /*#__PURE__*/React.createElement("div", {
158
159
  key: type,
159
160
  style: {
@@ -175,7 +176,7 @@ export const ColumnControls = ({
175
176
  tableLocalId: localId || '',
176
177
  indexes: indexes,
177
178
  forceDefaultHandle: isHover ? false : isColumnsSelected,
178
- previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : tableCellMinWidth,
179
+ previewWidth: previewWidth,
179
180
  previewHeight: previewHeight,
180
181
  appearance: isSelecting ? currentSelectionAppearance : hoveredAppearance,
181
182
  onClick: handleClick,
@@ -133,6 +133,7 @@ const DragControlsComponent = ({
133
133
  const currentSelectionAppearance = isRowsSelected ? isInDanger ? 'danger' : 'selected' : hoveredAppearance;
134
134
  const isSelecting = isRowsSelected && !isHover;
135
135
  const indexes = isRowsSelected ? isHover ? rowIndexes : selectedRowIndexes : rowIndexes;
136
+ const previewHeight = rowHeights.reduce((sum, v, i) => sum + v * (indexes.includes(i) ? 1 : 0), 0);
136
137
  return /*#__PURE__*/React.createElement("div", {
137
138
  key: type,
138
139
  style: {
@@ -153,7 +154,7 @@ const DragControlsComponent = ({
153
154
  indexes: indexes,
154
155
  forceDefaultHandle: isHover ? false : isRowsSelected,
155
156
  previewWidth: tableWidth,
156
- previewHeight: rowHeights[rowIndex],
157
+ previewHeight: previewHeight,
157
158
  appearance: isSelecting ? currentSelectionAppearance : hoveredAppearance,
158
159
  onClick: handleClick,
159
160
  onMouseOver: handleMouseOver,
@@ -127,7 +127,7 @@ export var ColumnControls = function ColumnControls(_ref) {
127
127
  };
128
128
  }, [tableWrapper, handleScroll]);
129
129
  var generateHandleByType = function generateHandleByType(type) {
130
- var _rowHeights$reduce, _colWidths;
130
+ var _rowHeights$reduce, _colWidths$reduce;
131
131
  if (!hoveredCell || !(colWidths !== null && colWidths !== void 0 && colWidths.length)) {
132
132
  return null;
133
133
  }
@@ -148,6 +148,9 @@ export var ColumnControls = function ColumnControls(_ref) {
148
148
 
149
149
  // this indexes are used to calculate the drag and drop source
150
150
  var indexes = isColumnsSelected ? isHover ? colIndexes : selectedColIndexes : colIndexes;
151
+ var previewWidth = (_colWidths$reduce = colWidths === null || colWidths === void 0 ? void 0 : colWidths.reduce(function (sum, v, i) {
152
+ return sum + (v !== null && v !== void 0 ? v : tableCellMinWidth) * (indexes.includes(i) ? 1 : 0);
153
+ }, 0)) !== null && _colWidths$reduce !== void 0 ? _colWidths$reduce : tableCellMinWidth;
151
154
  return /*#__PURE__*/React.createElement("div", {
152
155
  key: type,
153
156
  style: {
@@ -169,7 +172,7 @@ export var ColumnControls = function ColumnControls(_ref) {
169
172
  tableLocalId: localId || '',
170
173
  indexes: indexes,
171
174
  forceDefaultHandle: isHover ? false : isColumnsSelected,
172
- previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : tableCellMinWidth,
175
+ previewWidth: previewWidth,
173
176
  previewHeight: previewHeight,
174
177
  appearance: isSelecting ? currentSelectionAppearance : hoveredAppearance,
175
178
  onClick: handleClick,
@@ -133,6 +133,9 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
133
133
  var currentSelectionAppearance = isRowsSelected ? isInDanger ? 'danger' : 'selected' : hoveredAppearance;
134
134
  var isSelecting = isRowsSelected && !isHover;
135
135
  var indexes = isRowsSelected ? isHover ? rowIndexes : selectedRowIndexes : rowIndexes;
136
+ var previewHeight = rowHeights.reduce(function (sum, v, i) {
137
+ return sum + v * (indexes.includes(i) ? 1 : 0);
138
+ }, 0);
136
139
  return /*#__PURE__*/React.createElement("div", {
137
140
  key: type,
138
141
  style: {
@@ -153,7 +156,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
153
156
  indexes: indexes,
154
157
  forceDefaultHandle: isHover ? false : isRowsSelected,
155
158
  previewWidth: tableWidth,
156
- previewHeight: rowHeights[rowIndex],
159
+ previewHeight: previewHeight,
157
160
  appearance: isSelecting ? currentSelectionAppearance : hoveredAppearance,
158
161
  onClick: handleClick,
159
162
  onMouseOver: handleMouseOver,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.1.1",
3
+ "version": "7.1.2",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -7,11 +7,11 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
7
7
  import type { Command, DocBuilder } from '@atlaskit/editor-common/types';
8
8
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
9
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
10
- import { selectTableClosestToPos } from '@atlaskit/editor-tables/src/utils/select-nodes';
11
10
  import {
12
11
  findTable,
13
12
  findTableClosestToPos,
14
13
  selectTable,
14
+ selectTableClosestToPos,
15
15
  } from '@atlaskit/editor-tables/utils';
16
16
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
17
17
  import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
@@ -247,6 +247,13 @@ export const ColumnControls = ({
247
247
  : selectedColIndexes
248
248
  : colIndexes;
249
249
 
250
+ const previewWidth =
251
+ colWidths?.reduce<number>(
252
+ (sum, v, i) =>
253
+ sum + (v ?? tableCellMinWidth) * (indexes.includes(i) ? 1 : 0),
254
+ 0,
255
+ ) ?? tableCellMinWidth;
256
+
250
257
  return (
251
258
  <div
252
259
  key={type}
@@ -272,7 +279,7 @@ export const ColumnControls = ({
272
279
  tableLocalId={localId || ''}
273
280
  indexes={indexes}
274
281
  forceDefaultHandle={isHover ? false : isColumnsSelected}
275
- previewWidth={colWidths?.[colIndex!] ?? tableCellMinWidth}
282
+ previewWidth={previewWidth}
276
283
  previewHeight={previewHeight}
277
284
  appearance={
278
285
  isSelecting ? currentSelectionAppearance : hoveredAppearance
@@ -235,6 +235,11 @@ const DragControlsComponent = ({
235
235
  : selectedRowIndexes
236
236
  : rowIndexes;
237
237
 
238
+ const previewHeight = rowHeights.reduce(
239
+ (sum, v, i) => sum + v * (indexes.includes(i) ? 1 : 0),
240
+ 0,
241
+ );
242
+
238
243
  return (
239
244
  <div
240
245
  key={type}
@@ -259,7 +264,7 @@ const DragControlsComponent = ({
259
264
  indexes={indexes}
260
265
  forceDefaultHandle={isHover ? false : isRowsSelected}
261
266
  previewWidth={tableWidth}
262
- previewHeight={rowHeights[rowIndex!]}
267
+ previewHeight={previewHeight}
263
268
  appearance={
264
269
  isSelecting ? currentSelectionAppearance : hoveredAppearance
265
270
  }