@atlaskit/editor-plugin-table 9.3.3 → 9.3.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 +17 -0
- package/dist/cjs/nodeviews/toDOM.js +2 -1
- package/dist/cjs/pm-plugins/utils/paste.js +60 -11
- package/dist/es2019/nodeviews/toDOM.js +2 -1
- package/dist/es2019/pm-plugins/utils/paste.js +57 -8
- package/dist/esm/nodeviews/toDOM.js +2 -1
- package/dist/esm/pm-plugins/utils/paste.js +60 -11
- package/dist/types/nodeviews/ExternalDropTargets.d.ts +2 -2
- package/dist/types/nodeviews/TableComponentWithSharedState.d.ts +2 -2
- package/dist/types/nodeviews/TableContainer.d.ts +2 -2
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/nodeviews/table.d.ts +2 -2
- package/dist/types/ui/DragHandle/HandleIconComponent.d.ts +2 -2
- package/dist/types/ui/DragPreview/index.d.ts +2 -2
- package/dist/types/ui/FloatingDeleteButton/index.d.ts +2 -2
- package/dist/types/ui/FloatingDragMenu/DropdownMenu.d.ts +2 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -2
- package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -1
- package/dist/types/ui/FloatingToolbarLabel/FloatingToolbarLabel.d.ts +1 -1
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingControls/FloatingControlsWithSelection.d.ts +2 -2
- package/dist/types/ui/TableFloatingControls/NumberColumn/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +3 -3
- package/dist/types/ui/TableFloatingControls/RowDropTarget/index.d.ts +1 -1
- package/dist/types/ui/TableFloatingControls/index.d.ts +2 -2
- package/dist/types/ui/TableFullWidthLabel/index.d.ts +2 -2
- package/dist/types/ui/icons/AddColLeftIcon.d.ts +2 -2
- package/dist/types/ui/icons/AddColRightIcon.d.ts +2 -2
- package/dist/types/ui/icons/AddRowAboveIcon.d.ts +2 -2
- package/dist/types/ui/icons/AddRowBelowIcon.d.ts +2 -2
- package/dist/types/ui/icons/DragHandleDisabledIcon.d.ts +1 -1
- package/dist/types/ui/icons/DragHandleIcon.d.ts +2 -2
- package/dist/types/ui/icons/DragInMotionIcon.d.ts +1 -1
- package/dist/types/ui/icons/MergeCellsIcon.d.ts +2 -2
- package/dist/types/ui/icons/MinimisedHandle.d.ts +2 -2
- package/dist/types/ui/icons/SortingIconWrapper.d.ts +1 -1
- package/dist/types/ui/icons/SplitCellIcon.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/ExternalDropTargets.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/TableComponentWithSharedState.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/table.d.ts +2 -2
- package/dist/types-ts4.5/ui/DragHandle/HandleIconComponent.d.ts +2 -2
- package/dist/types-ts4.5/ui/DragPreview/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDeleteButton/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/DropdownMenu.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingToolbarLabel/FloatingToolbarLabel.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingControls/FloatingControlsWithSelection.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingControls/NumberColumn/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +3 -3
- package/dist/types-ts4.5/ui/TableFloatingControls/RowDropTarget/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFullWidthLabel/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/icons/AddColLeftIcon.d.ts +2 -2
- package/dist/types-ts4.5/ui/icons/AddColRightIcon.d.ts +2 -2
- package/dist/types-ts4.5/ui/icons/AddRowAboveIcon.d.ts +2 -2
- package/dist/types-ts4.5/ui/icons/AddRowBelowIcon.d.ts +2 -2
- package/dist/types-ts4.5/ui/icons/DragHandleDisabledIcon.d.ts +1 -1
- package/dist/types-ts4.5/ui/icons/DragHandleIcon.d.ts +2 -2
- package/dist/types-ts4.5/ui/icons/DragInMotionIcon.d.ts +1 -1
- package/dist/types-ts4.5/ui/icons/MergeCellsIcon.d.ts +2 -2
- package/dist/types-ts4.5/ui/icons/MinimisedHandle.d.ts +2 -2
- package/dist/types-ts4.5/ui/icons/SortingIconWrapper.d.ts +1 -1
- package/dist/types-ts4.5/ui/icons/SplitCellIcon.d.ts +2 -2
- package/package.json +11 -5
- package/src/nodeviews/toDOM.ts +4 -1
- package/src/pm-plugins/utils/paste.ts +71 -4
|
@@ -211,11 +211,75 @@ export const transformSliceToFixHardBreakProblemOnCopyFromCell = (
|
|
|
211
211
|
return slice;
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
+
const isNodeSingleCellTable = (node: PMNode, schema: Schema): boolean => {
|
|
215
|
+
return (
|
|
216
|
+
node.childCount === 1 &&
|
|
217
|
+
node.firstChild?.type === schema.nodes.tableRow &&
|
|
218
|
+
node.firstChild.childCount === 1 &&
|
|
219
|
+
(node.firstChild.firstChild?.type === schema.nodes.tableCell ||
|
|
220
|
+
node.firstChild.firstChild?.type === schema.nodes.tableHeader)
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const isFragmentSingleCellTable = (fragment: Fragment, schema: Schema): boolean => {
|
|
225
|
+
return (
|
|
226
|
+
fragment.childCount === 1 &&
|
|
227
|
+
fragment.firstChild !== null &&
|
|
228
|
+
isNodeSingleCellTable(fragment.firstChild, schema)
|
|
229
|
+
);
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
const containsTextBlockChildren = (fragment: Fragment, schema: Schema): boolean => {
|
|
233
|
+
let containsTextBlock = false;
|
|
234
|
+
|
|
235
|
+
fragment.forEach((node) => {
|
|
236
|
+
if (node.isTextblock) {
|
|
237
|
+
containsTextBlock = true;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
return containsTextBlock;
|
|
242
|
+
};
|
|
243
|
+
|
|
214
244
|
export const transformSliceToRemoveOpenTable = (slice: Slice, schema: Schema): Slice => {
|
|
215
|
-
|
|
216
|
-
|
|
245
|
+
if (fg('platform_editor_nested_tables_paste_wrap_fix')) {
|
|
246
|
+
// Case 1: A slice of a textblock selection inside a nested table
|
|
247
|
+
// Prosemirror wraps nested textblock selections in their respective tables
|
|
248
|
+
// We are using `safeInsert` to paste nested tables, so we do not want to preserve this wrapping
|
|
249
|
+
|
|
250
|
+
// slice starts and ends inside a nested table at the same depth
|
|
251
|
+
if (slice.openStart >= 7 && slice.openEnd >= 7 && slice.openStart === slice.openEnd) {
|
|
252
|
+
let cleaned = slice;
|
|
253
|
+
let descendedDepth = 0;
|
|
254
|
+
const tableDepthDecrement = 2;
|
|
255
|
+
|
|
256
|
+
// if the slice is a single cell table and contains cells with single cell tables, descend into it until we find textblock children
|
|
257
|
+
if (isFragmentSingleCellTable(slice.content, schema)) {
|
|
258
|
+
slice.content.firstChild?.descendants((node, _pos, parent) => {
|
|
259
|
+
if (isNodeSingleCellTable(node, schema)) {
|
|
260
|
+
descendedDepth += tableDepthDecrement;
|
|
261
|
+
} else if (node.type === schema.nodes.table) {
|
|
262
|
+
return false;
|
|
263
|
+
} else if (containsTextBlockChildren(node.content, schema)) {
|
|
264
|
+
descendedDepth += tableDepthDecrement;
|
|
265
|
+
// create a new slice with the content of the textblock children and the depth of the nested tables subtracted
|
|
266
|
+
cleaned = new Slice(
|
|
267
|
+
node.content,
|
|
268
|
+
slice.openStart - descendedDepth - tableDepthDecrement,
|
|
269
|
+
slice.openEnd - descendedDepth - tableDepthDecrement,
|
|
270
|
+
);
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (!cleaned.eq(slice)) {
|
|
277
|
+
return cleaned;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
217
281
|
|
|
218
|
-
// Case
|
|
282
|
+
// Case 2: A slice entirely within a single CELL
|
|
219
283
|
if (
|
|
220
284
|
// starts and ends inside of a cell
|
|
221
285
|
slice.openStart >= 4 &&
|
|
@@ -226,6 +290,9 @@ export const transformSliceToRemoveOpenTable = (slice: Slice, schema: Schema): S
|
|
|
226
290
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
227
291
|
slice.content.firstChild!.type === schema.nodes.table
|
|
228
292
|
) {
|
|
293
|
+
// we're removing the table, tableRow and tableCell reducing the open depth by 3
|
|
294
|
+
const depthDecrement = 3;
|
|
295
|
+
|
|
229
296
|
// prosemirror-view has a bug that it duplicates table entry when selecting multiple paragraphs in a table cell.
|
|
230
297
|
// https://github.com/ProseMirror/prosemirror/issues/1270
|
|
231
298
|
// The structure becomes
|
|
@@ -250,7 +317,7 @@ export const transformSliceToRemoveOpenTable = (slice: Slice, schema: Schema): S
|
|
|
250
317
|
);
|
|
251
318
|
}
|
|
252
319
|
|
|
253
|
-
// Case
|
|
320
|
+
// Case 3: A slice starting within a CELL and ending outside the table
|
|
254
321
|
if (
|
|
255
322
|
// starts inside of a cell but ends outside of the starting table
|
|
256
323
|
slice.openStart >= 4 &&
|