@atlaskit/editor-plugin-table 5.4.9 → 5.4.10
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
|
+
## 5.4.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#58174](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58174) [`b409282ab2b8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b409282ab2b8) - Check pasted slice is a table element before trying to access table map
|
|
8
|
+
|
|
3
9
|
## 5.4.9
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -181,17 +181,21 @@ var getTableSelectionType = exports.getTableSelectionType = function getTableSel
|
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
183
|
var getTableElementMoveTypeBySlice = exports.getTableElementMoveTypeBySlice = function getTableElementMoveTypeBySlice(slice, state) {
|
|
184
|
-
|
|
184
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
185
|
+
tableRow = _state$schema$nodes.tableRow,
|
|
186
|
+
table = _state$schema$nodes.table;
|
|
187
|
+
|
|
188
|
+
// check if copied slice is a table or table row
|
|
189
|
+
if (!slice.content.firstChild || slice.content.firstChild.type !== table && slice.content.firstChild.type !== tableRow) {
|
|
185
190
|
return;
|
|
186
191
|
}
|
|
187
|
-
var schema = state.schema;
|
|
188
192
|
|
|
189
193
|
// if the slice only contains one table row, assume it's a row
|
|
190
|
-
if (slice.content.childCount === 1 && slice.content.firstChild.type ===
|
|
194
|
+
if (slice.content.childCount === 1 && slice.content.firstChild.type === tableRow) {
|
|
191
195
|
return 'row';
|
|
192
196
|
}
|
|
193
|
-
var
|
|
194
|
-
var map = _tableMap.TableMap.get(
|
|
197
|
+
var currentTable = (0, _utils2.findTable)(state.tr.selection);
|
|
198
|
+
var map = _tableMap.TableMap.get(currentTable.node);
|
|
195
199
|
var slicedMap = _tableMap.TableMap.get(slice.content.firstChild);
|
|
196
200
|
return map.width === slicedMap.width ? 'row' : map.height === slicedMap.height ? 'column' : undefined;
|
|
197
201
|
};
|
|
@@ -183,19 +183,26 @@ export const getTableSelectionType = selection => {
|
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
export const getTableElementMoveTypeBySlice = (slice, state) => {
|
|
186
|
-
if (!slice.content.firstChild) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
186
|
const {
|
|
190
|
-
schema
|
|
187
|
+
schema: {
|
|
188
|
+
nodes: {
|
|
189
|
+
tableRow,
|
|
190
|
+
table
|
|
191
|
+
}
|
|
192
|
+
}
|
|
191
193
|
} = state;
|
|
192
194
|
|
|
195
|
+
// check if copied slice is a table or table row
|
|
196
|
+
if (!slice.content.firstChild || slice.content.firstChild.type !== table && slice.content.firstChild.type !== tableRow) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
193
200
|
// if the slice only contains one table row, assume it's a row
|
|
194
|
-
if (slice.content.childCount === 1 && slice.content.firstChild.type ===
|
|
201
|
+
if (slice.content.childCount === 1 && slice.content.firstChild.type === tableRow) {
|
|
195
202
|
return 'row';
|
|
196
203
|
}
|
|
197
|
-
const
|
|
198
|
-
const map = TableMap.get(
|
|
204
|
+
const currentTable = findTable(state.tr.selection);
|
|
205
|
+
const map = TableMap.get(currentTable.node);
|
|
199
206
|
const slicedMap = TableMap.get(slice.content.firstChild);
|
|
200
207
|
return map.width === slicedMap.width ? 'row' : map.height === slicedMap.height ? 'column' : undefined;
|
|
201
208
|
};
|
|
@@ -174,17 +174,21 @@ export var getTableSelectionType = function getTableSelectionType(selection) {
|
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
176
|
export var getTableElementMoveTypeBySlice = function getTableElementMoveTypeBySlice(slice, state) {
|
|
177
|
-
|
|
177
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
178
|
+
tableRow = _state$schema$nodes.tableRow,
|
|
179
|
+
table = _state$schema$nodes.table;
|
|
180
|
+
|
|
181
|
+
// check if copied slice is a table or table row
|
|
182
|
+
if (!slice.content.firstChild || slice.content.firstChild.type !== table && slice.content.firstChild.type !== tableRow) {
|
|
178
183
|
return;
|
|
179
184
|
}
|
|
180
|
-
var schema = state.schema;
|
|
181
185
|
|
|
182
186
|
// if the slice only contains one table row, assume it's a row
|
|
183
|
-
if (slice.content.childCount === 1 && slice.content.firstChild.type ===
|
|
187
|
+
if (slice.content.childCount === 1 && slice.content.firstChild.type === tableRow) {
|
|
184
188
|
return 'row';
|
|
185
189
|
}
|
|
186
|
-
var
|
|
187
|
-
var map = TableMap.get(
|
|
190
|
+
var currentTable = findTable(state.tr.selection);
|
|
191
|
+
var map = TableMap.get(currentTable.node);
|
|
188
192
|
var slicedMap = TableMap.get(slice.content.firstChild);
|
|
189
193
|
return map.width === slicedMap.width ? 'row' : map.height === slicedMap.height ? 'column' : undefined;
|
|
190
194
|
};
|
package/package.json
CHANGED
|
@@ -276,22 +276,31 @@ export const getTableElementMoveTypeBySlice = (
|
|
|
276
276
|
slice: Slice,
|
|
277
277
|
state: EditorState,
|
|
278
278
|
) => {
|
|
279
|
-
|
|
279
|
+
const {
|
|
280
|
+
schema: {
|
|
281
|
+
nodes: { tableRow, table },
|
|
282
|
+
},
|
|
283
|
+
} = state;
|
|
284
|
+
|
|
285
|
+
// check if copied slice is a table or table row
|
|
286
|
+
if (
|
|
287
|
+
!slice.content.firstChild ||
|
|
288
|
+
(slice.content.firstChild.type !== table &&
|
|
289
|
+
slice.content.firstChild.type !== tableRow)
|
|
290
|
+
) {
|
|
280
291
|
return;
|
|
281
292
|
}
|
|
282
293
|
|
|
283
|
-
const { schema } = state;
|
|
284
|
-
|
|
285
294
|
// if the slice only contains one table row, assume it's a row
|
|
286
295
|
if (
|
|
287
296
|
slice.content.childCount === 1 &&
|
|
288
|
-
slice.content.firstChild.type ===
|
|
297
|
+
slice.content.firstChild.type === tableRow
|
|
289
298
|
) {
|
|
290
299
|
return 'row';
|
|
291
300
|
}
|
|
292
301
|
|
|
293
|
-
const
|
|
294
|
-
const map = TableMap.get(
|
|
302
|
+
const currentTable = findTable(state.tr.selection)!;
|
|
303
|
+
const map = TableMap.get(currentTable.node);
|
|
295
304
|
const slicedMap = TableMap.get(slice.content.firstChild);
|
|
296
305
|
|
|
297
306
|
return map.width === slicedMap.width
|