@atlaskit/editor-plugin-table 10.5.6 → 10.5.8
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 +15 -0
- package/dist/cjs/pm-plugins/utils/paste.js +19 -11
- package/dist/cjs/ui/toolbar.js +11 -3
- package/dist/es2019/pm-plugins/utils/paste.js +19 -11
- package/dist/es2019/ui/toolbar.js +10 -2
- package/dist/esm/pm-plugins/utils/paste.js +19 -11
- package/dist/esm/ui/toolbar.js +11 -3
- package/package.json +10 -4
- package/src/pm-plugins/utils/paste.ts +30 -15
- package/src/ui/common-styles.ts +5 -3
- package/src/ui/toolbar.tsx +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 10.5.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#134468](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/134468)
|
|
8
|
+
[`e312ec529d05a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e312ec529d05a) -
|
|
9
|
+
[ux] Apply hover decoration when hovering on copy/delete button on overflow menu
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 10.5.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 10.5.6
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -12,6 +12,7 @@ var _nesting = require("@atlaskit/editor-common/nesting");
|
|
|
12
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
13
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
14
14
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
15
|
+
var _editorTables = require("@atlaskit/editor-tables");
|
|
15
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
17
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
17
18
|
var _pluginFactory = require("../plugin-factory");
|
|
@@ -81,16 +82,19 @@ var transformSliceToRemoveNestedTables = exports.transformSliceToRemoveNestedTab
|
|
|
81
82
|
tableHeader = _schema$nodes2.tableHeader;
|
|
82
83
|
var openEnd = slice.openEnd;
|
|
83
84
|
var newFragment = (0, _utils.flatmap)(slice.content, function (node, i, fragment) {
|
|
85
|
+
var _slice$content$firstC;
|
|
84
86
|
// if pasted content is a node that supports nesting a table
|
|
85
87
|
// such as layoutSection or expand allow 1 level by default
|
|
86
88
|
var allowedTableNesting = 1;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
var isPasteFullTableInsideEmptyCellEnabled = (0, _platformFeatureFlags.fg)('platform_editor_paste_full_table_inside_empty_cell');
|
|
92
|
-
var isCellPaste = isPasteInTable && slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === table && (!isPasteFullTableInsideEmptyCellEnabled || slice.openStart !== 0 && slice.openEnd !== 0);
|
|
89
|
+
var isCellSelection = selection instanceof _editorTables.CellSelection;
|
|
90
|
+
var isPasteInTable = (0, _utils2.hasParentNodeOfType)([table, tableCell, tableHeader])(selection);
|
|
91
|
+
var isPasteInNestedTable = (0, _nesting.getParentOfTypeCount)(schema.nodes.table)(selection.$from) > 1;
|
|
92
|
+
var isPasteFullTableInsideEmptyCellEnabled = (0, _platformFeatureFlags.fg)('platform_editor_paste_full_table_inside_empty_cell');
|
|
93
93
|
|
|
94
|
+
// Pasted content only contains a table and no other content
|
|
95
|
+
var isCellPaste = isPasteInTable && slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === table && (!isPasteFullTableInsideEmptyCellEnabled || slice.openStart !== 0 && slice.openEnd !== 0);
|
|
96
|
+
if (isNestingAllowed) {
|
|
97
|
+
var _slice$content$lastCh;
|
|
94
98
|
// if nesting is allowed we bump up the default nesting allowance to 2 to support
|
|
95
99
|
// two levels of nesting in nodes that support table nesting already such as layoutSection and expands
|
|
96
100
|
allowedTableNesting = 2;
|
|
@@ -112,7 +116,7 @@ var transformSliceToRemoveNestedTables = exports.transformSliceToRemoveNestedTab
|
|
|
112
116
|
|
|
113
117
|
// paste of table cells into a table cell - content is spread across multiple cells
|
|
114
118
|
// by editor-tables so needs to be treated a little differently
|
|
115
|
-
if (isCellPaste) {
|
|
119
|
+
if (isCellPaste || isCellSelection && (0, _platformFeatureFlags.fg)('platform_editor_nested_tables_cellselection_paste')) {
|
|
116
120
|
allowedTableNesting = 1;
|
|
117
121
|
if (isPasteInNestedTable) {
|
|
118
122
|
allowedTableNesting = 0;
|
|
@@ -138,10 +142,14 @@ var transformSliceToRemoveNestedTables = exports.transformSliceToRemoveNestedTab
|
|
|
138
142
|
allowedTableNesting = 0;
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
if (isCellSelection && !isCellPaste && (0, _platformFeatureFlags.fg)('platform_editor_nested_tables_cellselection_paste')) {
|
|
146
|
+
// if pasting into a cell selection, we need to flatten the parent table as well
|
|
147
|
+
return _unwrapNestedTables(_model.Fragment.fromArray([node]), schema, allowedTableNesting);
|
|
148
|
+
} else {
|
|
149
|
+
// after we've worked out what the allowed nesting depth is, unwrap nested tables
|
|
150
|
+
var newChildren = _unwrapNestedTables(node.content, schema, allowedTableNesting);
|
|
151
|
+
return node.copy(_model.Fragment.fromArray(newChildren));
|
|
152
|
+
}
|
|
145
153
|
});
|
|
146
154
|
return new _model.Slice(newFragment, slice.openStart, openEnd);
|
|
147
155
|
};
|
package/dist/cjs/ui/toolbar.js
CHANGED
|
@@ -454,6 +454,14 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
454
454
|
}]
|
|
455
455
|
};
|
|
456
456
|
var isNestedTable = (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes') && (0, _nesting.isSelectionTableNestedInTable)(state);
|
|
457
|
+
var hoverTableProps = function hoverTableProps(isInDanger, isSelected) {
|
|
458
|
+
return (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_1') ? {
|
|
459
|
+
onMouseEnter: (0, _commands.hoverTable)(isInDanger, isSelected),
|
|
460
|
+
onMouseLeave: (0, _commands.clearHoverSelection)(),
|
|
461
|
+
onFocus: (0, _commands.hoverTable)(isInDanger, isSelected),
|
|
462
|
+
onBlur: (0, _commands.clearHoverSelection)()
|
|
463
|
+
} : undefined;
|
|
464
|
+
};
|
|
457
465
|
return {
|
|
458
466
|
title: 'Table floating controls',
|
|
459
467
|
getDomRef: getDomRef,
|
|
@@ -498,7 +506,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
498
506
|
}
|
|
499
507
|
});
|
|
500
508
|
}
|
|
501
|
-
}, {
|
|
509
|
+
}, _objectSpread({
|
|
502
510
|
title: intl.formatMessage(_messages.default.copyToClipboard),
|
|
503
511
|
onClick: function onClick() {
|
|
504
512
|
var _api$core, _api$floatingToolbar;
|
|
@@ -509,13 +517,13 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
509
517
|
icon: (0, _react.jsx)(_copy.default, {
|
|
510
518
|
label: intl.formatMessage(_messages.default.copyToClipboard)
|
|
511
519
|
})
|
|
512
|
-
}, {
|
|
520
|
+
}, hoverTableProps(false, true)), _objectSpread({
|
|
513
521
|
title: intl.formatMessage(_messages.default.delete),
|
|
514
522
|
onClick: (0, _commandsWithAnalytics.deleteTableWithAnalytics)(editorAnalyticsAPI),
|
|
515
523
|
icon: (0, _react.jsx)(_deleteEditorRemove.default, {
|
|
516
524
|
label: intl.formatMessage(_messages.default.delete)
|
|
517
525
|
})
|
|
518
|
-
}]
|
|
526
|
+
}, hoverTableProps(true))]
|
|
519
527
|
}])),
|
|
520
528
|
scrollable: true
|
|
521
529
|
};
|
|
@@ -2,6 +2,7 @@ import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
|
2
2
|
import { flatmap, mapChildren, mapSlice } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { Slice, Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { flatten, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
import { CellSelection } from '@atlaskit/editor-tables';
|
|
5
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
8
|
import { getPluginState } from '../plugin-factory';
|
|
@@ -71,16 +72,19 @@ export const transformSliceToRemoveNestedTables = (slice, schema, selection) =>
|
|
|
71
72
|
} = schema.nodes;
|
|
72
73
|
let openEnd = slice.openEnd;
|
|
73
74
|
const newFragment = flatmap(slice.content, (node, i, fragment) => {
|
|
75
|
+
var _slice$content$firstC;
|
|
74
76
|
// if pasted content is a node that supports nesting a table
|
|
75
77
|
// such as layoutSection or expand allow 1 level by default
|
|
76
78
|
let allowedTableNesting = 1;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const isPasteFullTableInsideEmptyCellEnabled = fg('platform_editor_paste_full_table_inside_empty_cell');
|
|
82
|
-
const isCellPaste = isPasteInTable && slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === table && (!isPasteFullTableInsideEmptyCellEnabled || slice.openStart !== 0 && slice.openEnd !== 0);
|
|
79
|
+
const isCellSelection = selection instanceof CellSelection;
|
|
80
|
+
const isPasteInTable = hasParentNodeOfType([table, tableCell, tableHeader])(selection);
|
|
81
|
+
const isPasteInNestedTable = getParentOfTypeCount(schema.nodes.table)(selection.$from) > 1;
|
|
82
|
+
const isPasteFullTableInsideEmptyCellEnabled = fg('platform_editor_paste_full_table_inside_empty_cell');
|
|
83
83
|
|
|
84
|
+
// Pasted content only contains a table and no other content
|
|
85
|
+
const isCellPaste = isPasteInTable && slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === table && (!isPasteFullTableInsideEmptyCellEnabled || slice.openStart !== 0 && slice.openEnd !== 0);
|
|
86
|
+
if (isNestingAllowed) {
|
|
87
|
+
var _slice$content$lastCh;
|
|
84
88
|
// if nesting is allowed we bump up the default nesting allowance to 2 to support
|
|
85
89
|
// two levels of nesting in nodes that support table nesting already such as layoutSection and expands
|
|
86
90
|
allowedTableNesting = 2;
|
|
@@ -102,7 +106,7 @@ export const transformSliceToRemoveNestedTables = (slice, schema, selection) =>
|
|
|
102
106
|
|
|
103
107
|
// paste of table cells into a table cell - content is spread across multiple cells
|
|
104
108
|
// by editor-tables so needs to be treated a little differently
|
|
105
|
-
if (isCellPaste) {
|
|
109
|
+
if (isCellPaste || isCellSelection && fg('platform_editor_nested_tables_cellselection_paste')) {
|
|
106
110
|
allowedTableNesting = 1;
|
|
107
111
|
if (isPasteInNestedTable) {
|
|
108
112
|
allowedTableNesting = 0;
|
|
@@ -128,10 +132,14 @@ export const transformSliceToRemoveNestedTables = (slice, schema, selection) =>
|
|
|
128
132
|
allowedTableNesting = 0;
|
|
129
133
|
}
|
|
130
134
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
if (isCellSelection && !isCellPaste && fg('platform_editor_nested_tables_cellselection_paste')) {
|
|
136
|
+
// if pasting into a cell selection, we need to flatten the parent table as well
|
|
137
|
+
return unwrapNestedTables(Fragment.fromArray([node]), schema, allowedTableNesting);
|
|
138
|
+
} else {
|
|
139
|
+
// after we've worked out what the allowed nesting depth is, unwrap nested tables
|
|
140
|
+
const newChildren = unwrapNestedTables(node.content, schema, allowedTableNesting);
|
|
141
|
+
return node.copy(Fragment.fromArray(newChildren));
|
|
142
|
+
}
|
|
135
143
|
});
|
|
136
144
|
return new Slice(newFragment, slice.openStart, openEnd);
|
|
137
145
|
};
|
|
@@ -426,6 +426,12 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
|
|
|
426
426
|
}]
|
|
427
427
|
};
|
|
428
428
|
const isNestedTable = fg('platform_editor_use_nested_table_pm_nodes') && isSelectionTableNestedInTable(state);
|
|
429
|
+
const hoverTableProps = (isInDanger, isSelected) => fg('platform_editor_controls_patch_1') ? {
|
|
430
|
+
onMouseEnter: hoverTable(isInDanger, isSelected),
|
|
431
|
+
onMouseLeave: clearHoverSelection(),
|
|
432
|
+
onFocus: hoverTable(isInDanger, isSelected),
|
|
433
|
+
onBlur: clearHoverSelection()
|
|
434
|
+
} : undefined;
|
|
429
435
|
return {
|
|
430
436
|
title: 'Table floating controls',
|
|
431
437
|
getDomRef,
|
|
@@ -480,13 +486,15 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
|
|
|
480
486
|
},
|
|
481
487
|
icon: jsx(CopyIcon, {
|
|
482
488
|
label: intl.formatMessage(commonMessages.copyToClipboard)
|
|
483
|
-
})
|
|
489
|
+
}),
|
|
490
|
+
...hoverTableProps(false, true)
|
|
484
491
|
}, {
|
|
485
492
|
title: intl.formatMessage(commonMessages.delete),
|
|
486
493
|
onClick: deleteTableWithAnalytics(editorAnalyticsAPI),
|
|
487
494
|
icon: jsx(DeleteIcon, {
|
|
488
495
|
label: intl.formatMessage(commonMessages.delete)
|
|
489
|
-
})
|
|
496
|
+
}),
|
|
497
|
+
...hoverTableProps(true)
|
|
490
498
|
}]
|
|
491
499
|
}])],
|
|
492
500
|
scrollable: true
|
|
@@ -6,6 +6,7 @@ import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
|
6
6
|
import { flatmap, mapChildren, mapSlice } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { Slice, Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
8
8
|
import { flatten, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
9
|
+
import { CellSelection } from '@atlaskit/editor-tables';
|
|
9
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
12
|
import { getPluginState } from '../plugin-factory';
|
|
@@ -74,16 +75,19 @@ export var transformSliceToRemoveNestedTables = function transformSliceToRemoveN
|
|
|
74
75
|
tableHeader = _schema$nodes2.tableHeader;
|
|
75
76
|
var openEnd = slice.openEnd;
|
|
76
77
|
var newFragment = flatmap(slice.content, function (node, i, fragment) {
|
|
78
|
+
var _slice$content$firstC;
|
|
77
79
|
// if pasted content is a node that supports nesting a table
|
|
78
80
|
// such as layoutSection or expand allow 1 level by default
|
|
79
81
|
var allowedTableNesting = 1;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var isPasteFullTableInsideEmptyCellEnabled = fg('platform_editor_paste_full_table_inside_empty_cell');
|
|
85
|
-
var isCellPaste = isPasteInTable && slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === table && (!isPasteFullTableInsideEmptyCellEnabled || slice.openStart !== 0 && slice.openEnd !== 0);
|
|
82
|
+
var isCellSelection = selection instanceof CellSelection;
|
|
83
|
+
var isPasteInTable = hasParentNodeOfType([table, tableCell, tableHeader])(selection);
|
|
84
|
+
var isPasteInNestedTable = getParentOfTypeCount(schema.nodes.table)(selection.$from) > 1;
|
|
85
|
+
var isPasteFullTableInsideEmptyCellEnabled = fg('platform_editor_paste_full_table_inside_empty_cell');
|
|
86
86
|
|
|
87
|
+
// Pasted content only contains a table and no other content
|
|
88
|
+
var isCellPaste = isPasteInTable && slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === table && (!isPasteFullTableInsideEmptyCellEnabled || slice.openStart !== 0 && slice.openEnd !== 0);
|
|
89
|
+
if (isNestingAllowed) {
|
|
90
|
+
var _slice$content$lastCh;
|
|
87
91
|
// if nesting is allowed we bump up the default nesting allowance to 2 to support
|
|
88
92
|
// two levels of nesting in nodes that support table nesting already such as layoutSection and expands
|
|
89
93
|
allowedTableNesting = 2;
|
|
@@ -105,7 +109,7 @@ export var transformSliceToRemoveNestedTables = function transformSliceToRemoveN
|
|
|
105
109
|
|
|
106
110
|
// paste of table cells into a table cell - content is spread across multiple cells
|
|
107
111
|
// by editor-tables so needs to be treated a little differently
|
|
108
|
-
if (isCellPaste) {
|
|
112
|
+
if (isCellPaste || isCellSelection && fg('platform_editor_nested_tables_cellselection_paste')) {
|
|
109
113
|
allowedTableNesting = 1;
|
|
110
114
|
if (isPasteInNestedTable) {
|
|
111
115
|
allowedTableNesting = 0;
|
|
@@ -131,10 +135,14 @@ export var transformSliceToRemoveNestedTables = function transformSliceToRemoveN
|
|
|
131
135
|
allowedTableNesting = 0;
|
|
132
136
|
}
|
|
133
137
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
if (isCellSelection && !isCellPaste && fg('platform_editor_nested_tables_cellselection_paste')) {
|
|
139
|
+
// if pasting into a cell selection, we need to flatten the parent table as well
|
|
140
|
+
return _unwrapNestedTables(Fragment.fromArray([node]), schema, allowedTableNesting);
|
|
141
|
+
} else {
|
|
142
|
+
// after we've worked out what the allowed nesting depth is, unwrap nested tables
|
|
143
|
+
var newChildren = _unwrapNestedTables(node.content, schema, allowedTableNesting);
|
|
144
|
+
return node.copy(Fragment.fromArray(newChildren));
|
|
145
|
+
}
|
|
138
146
|
});
|
|
139
147
|
return new Slice(newFragment, slice.openStart, openEnd);
|
|
140
148
|
};
|
package/dist/esm/ui/toolbar.js
CHANGED
|
@@ -446,6 +446,14 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
446
446
|
}]
|
|
447
447
|
};
|
|
448
448
|
var isNestedTable = fg('platform_editor_use_nested_table_pm_nodes') && isSelectionTableNestedInTable(state);
|
|
449
|
+
var hoverTableProps = function hoverTableProps(isInDanger, isSelected) {
|
|
450
|
+
return fg('platform_editor_controls_patch_1') ? {
|
|
451
|
+
onMouseEnter: hoverTable(isInDanger, isSelected),
|
|
452
|
+
onMouseLeave: clearHoverSelection(),
|
|
453
|
+
onFocus: hoverTable(isInDanger, isSelected),
|
|
454
|
+
onBlur: clearHoverSelection()
|
|
455
|
+
} : undefined;
|
|
456
|
+
};
|
|
449
457
|
return {
|
|
450
458
|
title: 'Table floating controls',
|
|
451
459
|
getDomRef: getDomRef,
|
|
@@ -490,7 +498,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
490
498
|
}
|
|
491
499
|
});
|
|
492
500
|
}
|
|
493
|
-
}, {
|
|
501
|
+
}, _objectSpread({
|
|
494
502
|
title: intl.formatMessage(commonMessages.copyToClipboard),
|
|
495
503
|
onClick: function onClick() {
|
|
496
504
|
var _api$core, _api$floatingToolbar;
|
|
@@ -501,13 +509,13 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
501
509
|
icon: jsx(CopyIcon, {
|
|
502
510
|
label: intl.formatMessage(commonMessages.copyToClipboard)
|
|
503
511
|
})
|
|
504
|
-
}, {
|
|
512
|
+
}, hoverTableProps(false, true)), _objectSpread({
|
|
505
513
|
title: intl.formatMessage(commonMessages.delete),
|
|
506
514
|
onClick: deleteTableWithAnalytics(editorAnalyticsAPI),
|
|
507
515
|
icon: jsx(DeleteIcon, {
|
|
508
516
|
label: intl.formatMessage(commonMessages.delete)
|
|
509
517
|
})
|
|
510
|
-
}]
|
|
518
|
+
}, hoverTableProps(true))]
|
|
511
519
|
}])),
|
|
512
520
|
scrollable: true
|
|
513
521
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "10.5.
|
|
3
|
+
"version": "10.5.8",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
33
33
|
"@atlaskit/button": "^22.0.0",
|
|
34
34
|
"@atlaskit/custom-steps": "^0.11.0",
|
|
35
|
-
"@atlaskit/editor-common": "^102.
|
|
35
|
+
"@atlaskit/editor-common": "^102.15.0",
|
|
36
36
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-batch-attribute-updates": "^2.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-content-insertion": "^2.1.0",
|
|
41
41
|
"@atlaskit/editor-plugin-editor-viewmode": "^3.0.0",
|
|
42
|
-
"@atlaskit/editor-plugin-extension": "5.
|
|
42
|
+
"@atlaskit/editor-plugin-extension": "5.1.1",
|
|
43
43
|
"@atlaskit/editor-plugin-guideline": "^2.0.0",
|
|
44
44
|
"@atlaskit/editor-plugin-selection": "^2.1.0",
|
|
45
45
|
"@atlaskit/editor-plugin-width": "^3.0.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
|
|
55
55
|
"@atlaskit/primitives": "^14.2.0",
|
|
56
56
|
"@atlaskit/theme": "^18.0.0",
|
|
57
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
57
|
+
"@atlaskit/tmp-editor-statsig": "^4.6.0",
|
|
58
58
|
"@atlaskit/toggle": "^15.0.0",
|
|
59
59
|
"@atlaskit/tokens": "^4.5.0",
|
|
60
60
|
"@atlaskit/tooltip": "^20.0.0",
|
|
@@ -191,6 +191,12 @@
|
|
|
191
191
|
},
|
|
192
192
|
"platform_editor_numbered_column_misalignment": {
|
|
193
193
|
"type": "boolean"
|
|
194
|
+
},
|
|
195
|
+
"platform_editor_nested_tables_cellselection_paste": {
|
|
196
|
+
"type": "boolean"
|
|
197
|
+
},
|
|
198
|
+
"platform_editor_controls_patch_1": {
|
|
199
|
+
"type": "boolean"
|
|
194
200
|
}
|
|
195
201
|
}
|
|
196
202
|
}
|
|
@@ -4,6 +4,7 @@ import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
import { Slice, Fragment, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { flatten, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
import { CellSelection } from '@atlaskit/editor-tables';
|
|
7
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
10
|
|
|
@@ -100,19 +101,21 @@ export const transformSliceToRemoveNestedTables = (
|
|
|
100
101
|
// if pasted content is a node that supports nesting a table
|
|
101
102
|
// such as layoutSection or expand allow 1 level by default
|
|
102
103
|
let allowedTableNesting = 1;
|
|
104
|
+
const isCellSelection = selection instanceof CellSelection;
|
|
105
|
+
const isPasteInTable = hasParentNodeOfType([table, tableCell, tableHeader])(selection);
|
|
106
|
+
const isPasteInNestedTable = getParentOfTypeCount(schema.nodes.table)(selection.$from) > 1;
|
|
107
|
+
const isPasteFullTableInsideEmptyCellEnabled = fg(
|
|
108
|
+
'platform_editor_paste_full_table_inside_empty_cell',
|
|
109
|
+
);
|
|
103
110
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
);
|
|
110
|
-
const isCellPaste =
|
|
111
|
-
isPasteInTable &&
|
|
112
|
-
slice.content.childCount === 1 &&
|
|
113
|
-
slice.content.firstChild?.type === table &&
|
|
114
|
-
(!isPasteFullTableInsideEmptyCellEnabled || (slice.openStart !== 0 && slice.openEnd !== 0));
|
|
111
|
+
// Pasted content only contains a table and no other content
|
|
112
|
+
const isCellPaste =
|
|
113
|
+
isPasteInTable &&
|
|
114
|
+
slice.content.childCount === 1 &&
|
|
115
|
+
slice.content.firstChild?.type === table &&
|
|
116
|
+
(!isPasteFullTableInsideEmptyCellEnabled || (slice.openStart !== 0 && slice.openEnd !== 0));
|
|
115
117
|
|
|
118
|
+
if (isNestingAllowed) {
|
|
116
119
|
// if nesting is allowed we bump up the default nesting allowance to 2 to support
|
|
117
120
|
// two levels of nesting in nodes that support table nesting already such as layoutSection and expands
|
|
118
121
|
allowedTableNesting = 2;
|
|
@@ -134,7 +137,10 @@ export const transformSliceToRemoveNestedTables = (
|
|
|
134
137
|
|
|
135
138
|
// paste of table cells into a table cell - content is spread across multiple cells
|
|
136
139
|
// by editor-tables so needs to be treated a little differently
|
|
137
|
-
if (
|
|
140
|
+
if (
|
|
141
|
+
isCellPaste ||
|
|
142
|
+
(isCellSelection && fg('platform_editor_nested_tables_cellselection_paste'))
|
|
143
|
+
) {
|
|
138
144
|
allowedTableNesting = 1;
|
|
139
145
|
if (isPasteInNestedTable) {
|
|
140
146
|
allowedTableNesting = 0;
|
|
@@ -164,9 +170,18 @@ export const transformSliceToRemoveNestedTables = (
|
|
|
164
170
|
}
|
|
165
171
|
}
|
|
166
172
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
173
|
+
if (
|
|
174
|
+
isCellSelection &&
|
|
175
|
+
!isCellPaste &&
|
|
176
|
+
fg('platform_editor_nested_tables_cellselection_paste')
|
|
177
|
+
) {
|
|
178
|
+
// if pasting into a cell selection, we need to flatten the parent table as well
|
|
179
|
+
return unwrapNestedTables(Fragment.fromArray([node]), schema, allowedTableNesting);
|
|
180
|
+
} else {
|
|
181
|
+
// after we've worked out what the allowed nesting depth is, unwrap nested tables
|
|
182
|
+
const newChildren = unwrapNestedTables(node.content, schema, allowedTableNesting);
|
|
183
|
+
return node.copy(Fragment.fromArray(newChildren));
|
|
184
|
+
}
|
|
170
185
|
});
|
|
171
186
|
|
|
172
187
|
return new Slice(newFragment, slice.openStart, openEnd);
|
package/src/ui/common-styles.ts
CHANGED
|
@@ -1146,14 +1146,16 @@ export const baseTableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
1146
1146
|
.${ClassName.ROW_CONTROLS_WRAPPER} {
|
|
1147
1147
|
position: absolute;
|
|
1148
1148
|
/* this is to fix the misalignment of the numbered column in live page view mode */
|
|
1149
|
-
${props.featureFlags?.tableDragAndDrop && fg('platform_editor_numbered_column_misalignment')
|
|
1149
|
+
${props.featureFlags?.tableDragAndDrop && fg('platform_editor_numbered_column_misalignment')
|
|
1150
|
+
? `
|
|
1150
1151
|
margin-top: ${tableMarginTop}px;
|
|
1151
1152
|
left: -${tableToolbarSize + 1}px;
|
|
1152
|
-
`
|
|
1153
|
+
`
|
|
1154
|
+
: `
|
|
1153
1155
|
/* top of corner control is table margin top - corner control height + 1 pixel of table border. */
|
|
1154
1156
|
top: ${tableMarginTop - cornerControlHeight + 1}px;
|
|
1155
1157
|
left: -${tableToolbarSize}px;
|
|
1156
|
-
`
|
|
1158
|
+
`}
|
|
1157
1159
|
}
|
|
1158
1160
|
|
|
1159
1161
|
.${ClassName.DRAG_ROW_CONTROLS_WRAPPER}.${ClassName.TABLE_LEFT_SHADOW},
|
package/src/ui/toolbar.tsx
CHANGED
|
@@ -634,6 +634,16 @@ export const getToolbarConfig =
|
|
|
634
634
|
const isNestedTable =
|
|
635
635
|
fg('platform_editor_use_nested_table_pm_nodes') && isSelectionTableNestedInTable(state);
|
|
636
636
|
|
|
637
|
+
const hoverTableProps = (isInDanger?: boolean, isSelected?: boolean) =>
|
|
638
|
+
fg('platform_editor_controls_patch_1')
|
|
639
|
+
? {
|
|
640
|
+
onMouseEnter: hoverTable(isInDanger, isSelected),
|
|
641
|
+
onMouseLeave: clearHoverSelection(),
|
|
642
|
+
onFocus: hoverTable(isInDanger, isSelected),
|
|
643
|
+
onBlur: clearHoverSelection(),
|
|
644
|
+
}
|
|
645
|
+
: undefined;
|
|
646
|
+
|
|
637
647
|
return {
|
|
638
648
|
title: 'Table floating controls',
|
|
639
649
|
getDomRef,
|
|
@@ -710,11 +720,13 @@ export const getToolbarConfig =
|
|
|
710
720
|
return true;
|
|
711
721
|
},
|
|
712
722
|
icon: <CopyIcon label={intl.formatMessage(commonMessages.copyToClipboard)} />,
|
|
723
|
+
...hoverTableProps(false, true),
|
|
713
724
|
},
|
|
714
725
|
{
|
|
715
726
|
title: intl.formatMessage(commonMessages.delete),
|
|
716
727
|
onClick: deleteTableWithAnalytics(editorAnalyticsAPI),
|
|
717
728
|
icon: <DeleteIcon label={intl.formatMessage(commonMessages.delete)} />,
|
|
729
|
+
...hoverTableProps(true),
|
|
718
730
|
},
|
|
719
731
|
],
|
|
720
732
|
},
|