@atlaskit/editor-plugin-table 7.4.3 → 7.4.5

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,18 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.4.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#77616](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/77616) [`fbf65d3a22d9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fbf65d3a22d9) - clean up work for merged cell.
8
+ - Updated dependencies
9
+
10
+ ## 7.4.4
11
+
12
+ ### Patch Changes
13
+
14
+ - [#75436](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75436) [`bfcf32bb4fa3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bfcf32bb4fa3) - [ux] ED-21941 Disable resize/layout options for table, media and extension when added to MBE. Table rendering fixed for Confluence editor
15
+
3
16
  ## 7.4.3
4
17
 
5
18
  ### Patch Changes
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.hasMergedCellsWithRowNextToRowIndex = exports.hasMergedCellsWithColumnNextToColumnIndex = exports.hasMergedCellsInSelection = exports.hasMergedCellsInRow = exports.hasMergedCellsInColumn = exports.hasMergedCellsInBetween = exports.getTableMapByRowOrColumn = exports.findDuplicatePosition = exports.checkEdgeHasMergedCells = void 0;
7
+ exports.hasMergedCellsWithRowNextToRowIndex = exports.hasMergedCellsWithColumnNextToColumnIndex = exports.hasMergedCellsInSelection = exports.hasMergedCellsInRow = exports.hasMergedCellsInColumn = exports.hasMergedCellsInBetween = exports.findDuplicatePosition = exports.checkEdgeHasMergedCells = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _editorTables = require("@atlaskit/editor-tables");
10
10
  var hasMergedCells = function hasMergedCells(indexes, normalizeRect) {
@@ -217,29 +217,6 @@ var hasMergedCellsInSelection = exports.hasMergedCellsInSelection = function has
217
217
  };
218
218
  };
219
219
 
220
- /**
221
- * handle table map by preprocess table's map row or column.
222
- *
223
- * @param map TableMap
224
- * @returns object including mapByRow and mapByColumn
225
- */
226
- var getTableMapByRowOrColumn = exports.getTableMapByRowOrColumn = function getTableMapByRowOrColumn(map) {
227
- var mapByRow = Array(map.height);
228
- var mapByColumn = Array(map.width);
229
- var mapCopy = (0, _toConsumableArray2.default)(map.map);
230
- for (var i = 0; i < mapCopy.length; i++) {
231
- var _mapByColumn$columnIn, _mapByRow$rowIndex;
232
- var columnIndex = i % map.width;
233
- mapByColumn[columnIndex] = [].concat((0, _toConsumableArray2.default)((_mapByColumn$columnIn = mapByColumn[columnIndex]) !== null && _mapByColumn$columnIn !== void 0 ? _mapByColumn$columnIn : []), [mapCopy[i]]);
234
- var rowIndex = Math.trunc(i / map.width);
235
- mapByRow[rowIndex] = [].concat((0, _toConsumableArray2.default)((_mapByRow$rowIndex = mapByRow[rowIndex]) !== null && _mapByRow$rowIndex !== void 0 ? _mapByRow$rowIndex : []), [mapCopy[i]]);
236
- }
237
- return {
238
- mapByRow: mapByRow,
239
- mapByColumn: mapByColumn
240
- };
241
- };
242
-
243
220
  /**
244
221
  * this check the selection has merged cells with previous/next col or row.
245
222
  *
@@ -249,9 +226,8 @@ var getTableMapByRowOrColumn = exports.getTableMapByRowOrColumn = function getTa
249
226
  * @returns boolean
250
227
  */
251
228
  var checkEdgeHasMergedCells = exports.checkEdgeHasMergedCells = function checkEdgeHasMergedCells(indexes, tableMap, direction) {
252
- var _getTableMapByRowOrCo = getTableMapByRowOrColumn(tableMap),
253
- mapByRow = _getTableMapByRowOrCo.mapByRow,
254
- mapByColumn = _getTableMapByRowOrCo.mapByColumn;
229
+ var mapByRow = tableMap.mapByRow,
230
+ mapByColumn = tableMap.mapByColumn;
255
231
  var map = 'row' === direction ? mapByRow : mapByColumn;
256
232
  var lengthLimiter = direction === 'row' ? tableMap.width : tableMap.height;
257
233
  var minIndex = Math.min.apply(Math, (0, _toConsumableArray2.default)(indexes));
@@ -63,8 +63,9 @@ var isLayoutSupported = exports.isLayoutSupported = function isLayoutSupported(s
63
63
  var _state$schema$nodes = state.schema.nodes,
64
64
  bodiedExtension = _state$schema$nodes.bodiedExtension,
65
65
  layoutSection = _state$schema$nodes.layoutSection,
66
- expand = _state$schema$nodes.expand;
67
- return !(0, _utils2.hasParentNodeOfType)([expand, layoutSection, bodiedExtension])(state.selection) && !!permittedLayouts && (permittedLayouts === 'all' || permittedLayouts.indexOf('default') > -1 && permittedLayouts.indexOf('wide') > -1 && permittedLayouts.indexOf('full-width') > -1);
66
+ expand = _state$schema$nodes.expand,
67
+ extensionFrame = _state$schema$nodes.extensionFrame;
68
+ return !(0, _utils2.hasParentNodeOfType)([expand, layoutSection, bodiedExtension, extensionFrame])(state.selection) && !!permittedLayouts && (permittedLayouts === 'all' || permittedLayouts.indexOf('default') > -1 && permittedLayouts.indexOf('wide') > -1 && permittedLayouts.indexOf('full-width') > -1);
68
69
  };
69
70
  var getTableWidth = exports.getTableWidth = function getTableWidth(node) {
70
71
  return getTableWidths(node).reduce(function (acc, current) {
@@ -111,7 +112,7 @@ var isTableNested = exports.isTableNested = function isTableNested(state) {
111
112
  var tablePos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
112
113
  var parent = state.doc.resolve(tablePos).parent;
113
114
  var nodeTypes = state.schema.nodes;
114
- return parent.type === nodeTypes.layoutColumn || parent.type === nodeTypes.expand || parent.type === nodeTypes.bodiedExtension;
115
+ return parent.type === nodeTypes.layoutColumn || parent.type === nodeTypes.expand || parent.type === nodeTypes.bodiedExtension || parent.type === nodeTypes.extensionFrame;
115
116
  };
116
117
  var anyChildCellMergedAcrossRow = exports.anyChildCellMergedAcrossRow = function anyChildCellMergedAcrossRow(node) {
117
118
  return (0, _utils.mapChildren)(node, function (child) {
@@ -193,29 +193,6 @@ export const hasMergedCellsInSelection = (indexes, type) => selection => {
193
193
  return checkEdgeHasMergedCells(indexes, map, type);
194
194
  };
195
195
 
196
- /**
197
- * handle table map by preprocess table's map row or column.
198
- *
199
- * @param map TableMap
200
- * @returns object including mapByRow and mapByColumn
201
- */
202
- export const getTableMapByRowOrColumn = map => {
203
- let mapByRow = Array(map.height);
204
- let mapByColumn = Array(map.width);
205
- const mapCopy = [...map.map];
206
- for (let i = 0; i < mapCopy.length; i++) {
207
- var _mapByColumn$columnIn, _mapByRow$rowIndex;
208
- const columnIndex = i % map.width;
209
- mapByColumn[columnIndex] = [...((_mapByColumn$columnIn = mapByColumn[columnIndex]) !== null && _mapByColumn$columnIn !== void 0 ? _mapByColumn$columnIn : []), mapCopy[i]];
210
- const rowIndex = Math.trunc(i / map.width);
211
- mapByRow[rowIndex] = [...((_mapByRow$rowIndex = mapByRow[rowIndex]) !== null && _mapByRow$rowIndex !== void 0 ? _mapByRow$rowIndex : []), mapCopy[i]];
212
- }
213
- return {
214
- mapByRow,
215
- mapByColumn
216
- };
217
- };
218
-
219
196
  /**
220
197
  * this check the selection has merged cells with previous/next col or row.
221
198
  *
@@ -228,7 +205,7 @@ export const checkEdgeHasMergedCells = (indexes, tableMap, direction) => {
228
205
  const {
229
206
  mapByRow,
230
207
  mapByColumn
231
- } = getTableMapByRowOrColumn(tableMap);
208
+ } = tableMap;
232
209
  const map = 'row' === direction ? mapByRow : mapByColumn;
233
210
  const lengthLimiter = direction === 'row' ? tableMap.width : tableMap.height;
234
211
  let minIndex = Math.min(...indexes);
@@ -48,9 +48,10 @@ export const isLayoutSupported = state => {
48
48
  const {
49
49
  bodiedExtension,
50
50
  layoutSection,
51
- expand
51
+ expand,
52
+ extensionFrame
52
53
  } = state.schema.nodes;
53
- return !hasParentNodeOfType([expand, layoutSection, bodiedExtension])(state.selection) && !!permittedLayouts && (permittedLayouts === 'all' || permittedLayouts.indexOf('default') > -1 && permittedLayouts.indexOf('wide') > -1 && permittedLayouts.indexOf('full-width') > -1);
54
+ return !hasParentNodeOfType([expand, layoutSection, bodiedExtension, extensionFrame])(state.selection) && !!permittedLayouts && (permittedLayouts === 'all' || permittedLayouts.indexOf('default') > -1 && permittedLayouts.indexOf('wide') > -1 && permittedLayouts.indexOf('full-width') > -1);
54
55
  };
55
56
  export const getTableWidth = node => {
56
57
  return getTableWidths(node).reduce((acc, current) => acc + current, 0);
@@ -94,7 +95,7 @@ function getTableWidths(node) {
94
95
  export const isTableNested = (state, tablePos = 0) => {
95
96
  const parent = state.doc.resolve(tablePos).parent;
96
97
  const nodeTypes = state.schema.nodes;
97
- return parent.type === nodeTypes.layoutColumn || parent.type === nodeTypes.expand || parent.type === nodeTypes.bodiedExtension;
98
+ return parent.type === nodeTypes.layoutColumn || parent.type === nodeTypes.expand || parent.type === nodeTypes.bodiedExtension || parent.type === nodeTypes.extensionFrame;
98
99
  };
99
100
  export const anyChildCellMergedAcrossRow = node => mapChildren(node, child => child.attrs.rowspan || 0).some(rowspan => rowspan > 1);
100
101
 
@@ -210,29 +210,6 @@ export var hasMergedCellsInSelection = function hasMergedCellsInSelection(indexe
210
210
  };
211
211
  };
212
212
 
213
- /**
214
- * handle table map by preprocess table's map row or column.
215
- *
216
- * @param map TableMap
217
- * @returns object including mapByRow and mapByColumn
218
- */
219
- export var getTableMapByRowOrColumn = function getTableMapByRowOrColumn(map) {
220
- var mapByRow = Array(map.height);
221
- var mapByColumn = Array(map.width);
222
- var mapCopy = _toConsumableArray(map.map);
223
- for (var i = 0; i < mapCopy.length; i++) {
224
- var _mapByColumn$columnIn, _mapByRow$rowIndex;
225
- var columnIndex = i % map.width;
226
- mapByColumn[columnIndex] = [].concat(_toConsumableArray((_mapByColumn$columnIn = mapByColumn[columnIndex]) !== null && _mapByColumn$columnIn !== void 0 ? _mapByColumn$columnIn : []), [mapCopy[i]]);
227
- var rowIndex = Math.trunc(i / map.width);
228
- mapByRow[rowIndex] = [].concat(_toConsumableArray((_mapByRow$rowIndex = mapByRow[rowIndex]) !== null && _mapByRow$rowIndex !== void 0 ? _mapByRow$rowIndex : []), [mapCopy[i]]);
229
- }
230
- return {
231
- mapByRow: mapByRow,
232
- mapByColumn: mapByColumn
233
- };
234
- };
235
-
236
213
  /**
237
214
  * this check the selection has merged cells with previous/next col or row.
238
215
  *
@@ -242,9 +219,8 @@ export var getTableMapByRowOrColumn = function getTableMapByRowOrColumn(map) {
242
219
  * @returns boolean
243
220
  */
244
221
  export var checkEdgeHasMergedCells = function checkEdgeHasMergedCells(indexes, tableMap, direction) {
245
- var _getTableMapByRowOrCo = getTableMapByRowOrColumn(tableMap),
246
- mapByRow = _getTableMapByRowOrCo.mapByRow,
247
- mapByColumn = _getTableMapByRowOrCo.mapByColumn;
222
+ var mapByRow = tableMap.mapByRow,
223
+ mapByColumn = tableMap.mapByColumn;
248
224
  var map = 'row' === direction ? mapByRow : mapByColumn;
249
225
  var lengthLimiter = direction === 'row' ? tableMap.width : tableMap.height;
250
226
  var minIndex = Math.min.apply(Math, _toConsumableArray(indexes));
@@ -56,8 +56,9 @@ export var isLayoutSupported = function isLayoutSupported(state) {
56
56
  var _state$schema$nodes = state.schema.nodes,
57
57
  bodiedExtension = _state$schema$nodes.bodiedExtension,
58
58
  layoutSection = _state$schema$nodes.layoutSection,
59
- expand = _state$schema$nodes.expand;
60
- return !hasParentNodeOfType([expand, layoutSection, bodiedExtension])(state.selection) && !!permittedLayouts && (permittedLayouts === 'all' || permittedLayouts.indexOf('default') > -1 && permittedLayouts.indexOf('wide') > -1 && permittedLayouts.indexOf('full-width') > -1);
59
+ expand = _state$schema$nodes.expand,
60
+ extensionFrame = _state$schema$nodes.extensionFrame;
61
+ return !hasParentNodeOfType([expand, layoutSection, bodiedExtension, extensionFrame])(state.selection) && !!permittedLayouts && (permittedLayouts === 'all' || permittedLayouts.indexOf('default') > -1 && permittedLayouts.indexOf('wide') > -1 && permittedLayouts.indexOf('full-width') > -1);
61
62
  };
62
63
  export var getTableWidth = function getTableWidth(node) {
63
64
  return getTableWidths(node).reduce(function (acc, current) {
@@ -104,7 +105,7 @@ export var isTableNested = function isTableNested(state) {
104
105
  var tablePos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
105
106
  var parent = state.doc.resolve(tablePos).parent;
106
107
  var nodeTypes = state.schema.nodes;
107
- return parent.type === nodeTypes.layoutColumn || parent.type === nodeTypes.expand || parent.type === nodeTypes.bodiedExtension;
108
+ return parent.type === nodeTypes.layoutColumn || parent.type === nodeTypes.expand || parent.type === nodeTypes.bodiedExtension || parent.type === nodeTypes.extensionFrame;
108
109
  };
109
110
  export var anyChildCellMergedAcrossRow = function anyChildCellMergedAcrossRow(node) {
110
111
  return mapChildren(node, function (child) {
@@ -7,16 +7,6 @@ export declare const hasMergedCellsInBetween: (indexes: number[], type: MergeTyp
7
7
  export declare const hasMergedCellsWithColumnNextToColumnIndex: (colIndex: number, selection: Selection) => boolean;
8
8
  export declare const hasMergedCellsWithRowNextToRowIndex: (rowIndex: number, selection: Selection) => boolean;
9
9
  export declare const hasMergedCellsInSelection: (indexes: number[], type: MergeType) => (selection: Selection) => boolean;
10
- /**
11
- * handle table map by preprocess table's map row or column.
12
- *
13
- * @param map TableMap
14
- * @returns object including mapByRow and mapByColumn
15
- */
16
- export declare const getTableMapByRowOrColumn: (map: TableMap) => {
17
- mapByRow: any[];
18
- mapByColumn: any[];
19
- };
20
10
  /**
21
11
  * this check the selection has merged cells with previous/next col or row.
22
12
  *
@@ -7,16 +7,6 @@ export declare const hasMergedCellsInBetween: (indexes: number[], type: MergeTyp
7
7
  export declare const hasMergedCellsWithColumnNextToColumnIndex: (colIndex: number, selection: Selection) => boolean;
8
8
  export declare const hasMergedCellsWithRowNextToRowIndex: (rowIndex: number, selection: Selection) => boolean;
9
9
  export declare const hasMergedCellsInSelection: (indexes: number[], type: MergeType) => (selection: Selection) => boolean;
10
- /**
11
- * handle table map by preprocess table's map row or column.
12
- *
13
- * @param map TableMap
14
- * @returns object including mapByRow and mapByColumn
15
- */
16
- export declare const getTableMapByRowOrColumn: (map: TableMap) => {
17
- mapByRow: any[];
18
- mapByColumn: any[];
19
- };
20
10
  /**
21
11
  * this check the selection has merged cells with previous/next col or row.
22
12
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.4.3",
3
+ "version": "7.4.5",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^35.5.1",
32
32
  "@atlaskit/custom-steps": "^0.0.13",
33
- "@atlaskit/editor-common": "^78.8.0",
33
+ "@atlaskit/editor-common": "^78.9.0",
34
34
  "@atlaskit/editor-palette": "1.5.2",
35
35
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
36
36
  "@atlaskit/editor-plugin-content-insertion": "^1.0.0",
@@ -46,7 +46,7 @@
46
46
  "@atlaskit/pragmatic-drag-and-drop": "^1.0.0",
47
47
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.0.0",
48
48
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
49
- "@atlaskit/primitives": "^3.1.0",
49
+ "@atlaskit/primitives": "^3.2.0",
50
50
  "@atlaskit/theme": "^12.6.0",
51
51
  "@atlaskit/toggle": "^13.0.0",
52
52
  "@atlaskit/tokens": "^1.38.0",
@@ -243,31 +243,6 @@ export const hasMergedCellsInSelection =
243
243
  return checkEdgeHasMergedCells(indexes, map, type);
244
244
  };
245
245
 
246
- /**
247
- * handle table map by preprocess table's map row or column.
248
- *
249
- * @param map TableMap
250
- * @returns object including mapByRow and mapByColumn
251
- */
252
- export const getTableMapByRowOrColumn = (map: TableMap) => {
253
- let mapByRow = Array(map.height);
254
- let mapByColumn = Array(map.width);
255
-
256
- const mapCopy = [...map.map];
257
-
258
- for (let i = 0; i < mapCopy.length; i++) {
259
- const columnIndex = i % map.width;
260
- mapByColumn[columnIndex] = [
261
- ...(mapByColumn[columnIndex] ?? []),
262
- mapCopy[i],
263
- ];
264
- const rowIndex = Math.trunc(i / map.width);
265
- mapByRow[rowIndex] = [...(mapByRow[rowIndex] ?? []), mapCopy[i]];
266
- }
267
-
268
- return { mapByRow, mapByColumn };
269
- };
270
-
271
246
  /**
272
247
  * this check the selection has merged cells with previous/next col or row.
273
248
  *
@@ -281,7 +256,7 @@ export const checkEdgeHasMergedCells = (
281
256
  tableMap: TableMap,
282
257
  direction: 'row' | 'column',
283
258
  ): boolean => {
284
- const { mapByRow, mapByColumn } = getTableMapByRowOrColumn(tableMap);
259
+ const { mapByRow, mapByColumn } = tableMap;
285
260
  const map = 'row' === direction ? mapByRow : mapByColumn;
286
261
  const lengthLimiter = direction === 'row' ? tableMap.width : tableMap.height;
287
262
 
@@ -65,12 +65,16 @@ export const checkIfNumberColumnEnabled = (selection: Selection): boolean =>
65
65
 
66
66
  export const isLayoutSupported = (state: EditorState): boolean => {
67
67
  const { permittedLayouts } = pluginKey.getState(state)?.pluginConfig || {};
68
- const { bodiedExtension, layoutSection, expand } = state.schema.nodes;
68
+ const { bodiedExtension, layoutSection, expand, extensionFrame } =
69
+ state.schema.nodes;
69
70
 
70
71
  return (
71
- !hasParentNodeOfType([expand, layoutSection, bodiedExtension])(
72
- state.selection,
73
- ) &&
72
+ !hasParentNodeOfType([
73
+ expand,
74
+ layoutSection,
75
+ bodiedExtension,
76
+ extensionFrame,
77
+ ])(state.selection) &&
74
78
  !!permittedLayouts &&
75
79
  (permittedLayouts === 'all' ||
76
80
  (permittedLayouts.indexOf('default') > -1 &&
@@ -150,7 +154,8 @@ export const isTableNested = (state: EditorState, tablePos = 0): boolean => {
150
154
  return (
151
155
  parent.type === nodeTypes.layoutColumn ||
152
156
  parent.type === nodeTypes.expand ||
153
- parent.type === nodeTypes.bodiedExtension
157
+ parent.type === nodeTypes.bodiedExtension ||
158
+ parent.type === nodeTypes.extensionFrame
154
159
  );
155
160
  };
156
161