@atlaskit/editor-plugin-table 9.0.0 → 9.0.1
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 +10 -0
- package/dist/cjs/nodeviews/TableRow.js +24 -14
- package/dist/cjs/ui/TableFullWidthLabel/index.js +1 -0
- package/dist/cjs/ui/event-handlers.js +18 -7
- package/dist/es2019/nodeviews/TableRow.js +24 -14
- package/dist/es2019/ui/TableFullWidthLabel/index.js +1 -0
- package/dist/es2019/ui/event-handlers.js +12 -1
- package/dist/esm/nodeviews/TableRow.js +24 -14
- package/dist/esm/ui/TableFullWidthLabel/index.js +1 -0
- package/dist/esm/ui/event-handlers.js +12 -1
- package/package.json +4 -4
- package/src/nodeviews/TableComponent.tsx +1 -1
- package/src/nodeviews/TableRow.ts +34 -14
- package/src/pm-plugins/commands/hover.ts +2 -2
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +1 -1
- package/src/pm-plugins/drag-and-drop/commands.ts +5 -1
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +1 -1
- package/src/pm-plugins/transforms/column-width.ts +1 -1
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +1 -1
- package/src/ui/TableFloatingColumnControls/index.tsx +1 -1
- package/src/ui/TableFullWidthLabel/index.tsx +1 -0
- package/src/ui/event-handlers.ts +19 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 9.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#98104](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98104)
|
|
8
|
+
[`7c7c2dc094742`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7c7c2dc094742) -
|
|
9
|
+
[ux] [ED-25529] This change adds padding to nested tables when active, to allow space for the row
|
|
10
|
+
and column controls. It also prevents the Insert Row/ Insert Column buttons from being hidden too
|
|
11
|
+
early.
|
|
12
|
+
|
|
3
13
|
## 9.0.0
|
|
4
14
|
|
|
5
15
|
### Major Changes
|
|
@@ -413,6 +413,7 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
413
413
|
}, {
|
|
414
414
|
key: "onTablePluginState",
|
|
415
415
|
value: function onTablePluginState(state) {
|
|
416
|
+
var _parentContainer$pare, _parentContainer$pare2;
|
|
416
417
|
var tableRef = state.tableRef;
|
|
417
418
|
var tree = (0, _dom2.getTree)(this.dom);
|
|
418
419
|
if (!tree) {
|
|
@@ -437,22 +438,31 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
437
438
|
var wrapper = tree.wrapper;
|
|
438
439
|
var tableContainer = wrapper.parentElement;
|
|
439
440
|
var tableContentWrapper = tableContainer === null || tableContainer === void 0 ? void 0 : tableContainer.parentElement;
|
|
440
|
-
var
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
441
|
+
var parentContainer = tableContentWrapper && tableContentWrapper.parentElement;
|
|
442
|
+
var isTableInsideLayout = parentContainer && parentContainer.getAttribute('data-layout-content');
|
|
443
|
+
var isNestedTable = parentContainer && (parentContainer.className === 'pm-table-header-content-wrap' || parentContainer.className === 'pm-table-cell-content-wrap');
|
|
444
|
+
var isNestedDataTable = parentContainer && parentContainer.getAttribute('data-mark-type') === 'fragment' && (((_parentContainer$pare = parentContainer.parentElement) === null || _parentContainer$pare === void 0 ? void 0 : _parentContainer$pare.className) === 'pm-table-header-content-wrap' || ((_parentContainer$pare2 = parentContainer.parentElement) === null || _parentContainer$pare2 === void 0 ? void 0 : _parentContainer$pare2.className) === 'pm-table-cell-content-wrap');
|
|
445
|
+
var isTableInsideTable = isNestedTable || isNestedDataTable;
|
|
446
|
+
if (tableContentWrapper) {
|
|
447
|
+
if (isCurrentTableSelected) {
|
|
448
|
+
this.colControlsOffset = _consts.tableControlsSpacing;
|
|
449
|
+
|
|
444
450
|
// move table a little out of the way
|
|
445
451
|
// to provide spacing for table controls
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
452
|
+
if (isTableInsideLayout) {
|
|
453
|
+
tableContentWrapper.style.paddingLeft = '11px';
|
|
454
|
+
} else if (isTableInsideTable) {
|
|
455
|
+
tableContentWrapper.style.paddingLeft = '15px';
|
|
456
|
+
tableContentWrapper.style.paddingRight = '4px';
|
|
457
|
+
}
|
|
458
|
+
} else {
|
|
459
|
+
this.colControlsOffset = 0;
|
|
460
|
+
if (isTableInsideLayout) {
|
|
461
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
462
|
+
} else if (isTableInsideTable) {
|
|
463
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
464
|
+
tableContentWrapper.style.removeProperty('padding-right');
|
|
465
|
+
}
|
|
456
466
|
}
|
|
457
467
|
}
|
|
458
468
|
|
|
@@ -15,6 +15,7 @@ var tableFullWidthLabelWrapperStyles = (0, _primitives.xcss)({
|
|
|
15
15
|
backgroundColor: 'elevation.surface.overlay',
|
|
16
16
|
borderRadius: 'border.radius',
|
|
17
17
|
boxShadow: 'elevation.shadow.overlay',
|
|
18
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
18
19
|
lineHeight: 1,
|
|
19
20
|
boxSizing: 'border-box',
|
|
20
21
|
alignItems: 'center'
|
|
@@ -10,11 +10,13 @@ exports.withCellTracking = exports.whenTableInFocus = exports.isTableInFocus = v
|
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
12
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
+
var _nesting = require("@atlaskit/editor-common/nesting");
|
|
13
14
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
14
15
|
var _state5 = require("@atlaskit/editor-prosemirror/state");
|
|
16
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
15
17
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
16
18
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
17
|
-
var
|
|
19
|
+
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
18
20
|
var _commands = require("../pm-plugins/commands");
|
|
19
21
|
var _pluginFactory = require("../pm-plugins/drag-and-drop/plugin-factory");
|
|
20
22
|
var _pluginFactory2 = require("../pm-plugins/plugin-factory");
|
|
@@ -66,7 +68,7 @@ var handleClick = exports.handleClick = function handleClick(view, event) {
|
|
|
66
68
|
var element = event.target;
|
|
67
69
|
// Ignored via go/ees005
|
|
68
70
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
69
|
-
var table = (0,
|
|
71
|
+
var table = (0, _utils3.findTable)(view.state.selection);
|
|
70
72
|
|
|
71
73
|
// Ignored via go/ees005
|
|
72
74
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -149,7 +151,16 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, m
|
|
|
149
151
|
_dispatch2 = view.dispatch;
|
|
150
152
|
return (0, _commands.hoverColumns)([_startIndex], false)(_state, _dispatch2);
|
|
151
153
|
}
|
|
152
|
-
|
|
154
|
+
var isNestedTable = (0, _nesting.getParentOfTypeCount)(state.schema.nodes.table)(state.selection.$from) > 1;
|
|
155
|
+
if (isNestedTable) {
|
|
156
|
+
// if the table is nested inside a table, we only call hideInsertColumnOrRowButton if the table nearest to the mouse target is NOT the parent table
|
|
157
|
+
var nearestTable = (0, _utils.closestElement)(target, 'table');
|
|
158
|
+
var nestedTable = (0, _utils2.findParentNodeOfTypeClosestToPos)(state.doc.resolve(state.selection.from), [state.schema.nodes.table]);
|
|
159
|
+
var parentTable = (0, _utils2.findParentNodeOfTypeClosestToPos)(state.doc.resolve((nestedTable === null || nestedTable === void 0 ? void 0 : nestedTable.pos) || 0), [state.schema.nodes.table]);
|
|
160
|
+
if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId)) {
|
|
161
|
+
return (0, _commands.hideInsertColumnOrRowButton)()(state, dispatch);
|
|
162
|
+
}
|
|
163
|
+
} else if (((0, _dom.isCell)(target) || (0, _dom.isCornerButton)(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
|
|
153
164
|
return (0, _commands.hideInsertColumnOrRowButton)()(state, dispatch);
|
|
154
165
|
}
|
|
155
166
|
if ((0, _dom.isResizeHandleDecoration)(target)) {
|
|
@@ -319,7 +330,7 @@ var handleMouseMoveDebounce = function handleMouseMoveDebounce(nodeViewPortalPro
|
|
|
319
330
|
var isKeyboardResize = (0, _pluginFactory2.getPluginState)(_state4).isKeyboardResize;
|
|
320
331
|
var tableCell = (0, _utils.closestElement)(element, 'td, th');
|
|
321
332
|
var cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
322
|
-
var rect = (0,
|
|
333
|
+
var rect = (0, _utils3.findCellRectClosestToPos)(_state4.doc.resolve(cellStartPosition));
|
|
323
334
|
if (rect) {
|
|
324
335
|
var columnEndIndexTarget = _positionColumn === 'left' ? rect.left : rect.right;
|
|
325
336
|
var rowIndexTarget = rect.top;
|
|
@@ -354,7 +365,7 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(nodeVie
|
|
|
354
365
|
function handleTripleClick(view, pos) {
|
|
355
366
|
var state = view.state,
|
|
356
367
|
dispatch = view.dispatch;
|
|
357
|
-
var $cellPos = (0,
|
|
368
|
+
var $cellPos = (0, _utils3.cellAround)(state.doc.resolve(pos));
|
|
358
369
|
if (!$cellPos) {
|
|
359
370
|
return false;
|
|
360
371
|
}
|
|
@@ -381,7 +392,7 @@ var handleCut = exports.handleCut = function handleCut(oldTr, oldState, newState
|
|
|
381
392
|
var cellSelection = new _cellSelection.CellSelection($anchorCell, $headCell);
|
|
382
393
|
tr.setSelection(cellSelection);
|
|
383
394
|
if (tr.selection instanceof _cellSelection.CellSelection) {
|
|
384
|
-
var rect = (0,
|
|
395
|
+
var rect = (0, _utils3.getSelectionRect)(cellSelection);
|
|
385
396
|
if (rect) {
|
|
386
397
|
var _getSelectedCellInfo = (0, _analytics2.getSelectedCellInfo)(tr.selection),
|
|
387
398
|
verticalCells = _getSelectedCellInfo.verticalCells,
|
|
@@ -409,7 +420,7 @@ var handleCut = exports.handleCut = function handleCut(oldTr, oldState, newState
|
|
|
409
420
|
if (tr.selection instanceof _cellSelection.CellSelection) {
|
|
410
421
|
var isTableSelected = tr.selection.isRowSelection() && tr.selection.isColSelection();
|
|
411
422
|
if (isTableSelected) {
|
|
412
|
-
tr = (0,
|
|
423
|
+
tr = (0, _utils3.removeTable)(tr);
|
|
413
424
|
} else if (tr.selection.isRowSelection()) {
|
|
414
425
|
var _getPluginState9 = (0, _pluginFactory2.getPluginState)(newState),
|
|
415
426
|
isHeaderRowRequired = _getPluginState9.pluginConfig.isHeaderRowRequired;
|
|
@@ -379,6 +379,7 @@ export default class TableRow extends TableNodeView {
|
|
|
379
379
|
/* receive external events */
|
|
380
380
|
|
|
381
381
|
onTablePluginState(state) {
|
|
382
|
+
var _parentContainer$pare, _parentContainer$pare2;
|
|
382
383
|
const tableRef = state.tableRef;
|
|
383
384
|
const tree = getTree(this.dom);
|
|
384
385
|
if (!tree) {
|
|
@@ -405,22 +406,31 @@ export default class TableRow extends TableNodeView {
|
|
|
405
406
|
} = tree;
|
|
406
407
|
const tableContainer = wrapper.parentElement;
|
|
407
408
|
const tableContentWrapper = tableContainer === null || tableContainer === void 0 ? void 0 : tableContainer.parentElement;
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
409
|
+
const parentContainer = tableContentWrapper && tableContentWrapper.parentElement;
|
|
410
|
+
const isTableInsideLayout = parentContainer && parentContainer.getAttribute('data-layout-content');
|
|
411
|
+
const isNestedTable = parentContainer && (parentContainer.className === 'pm-table-header-content-wrap' || parentContainer.className === 'pm-table-cell-content-wrap');
|
|
412
|
+
const isNestedDataTable = parentContainer && parentContainer.getAttribute('data-mark-type') === 'fragment' && (((_parentContainer$pare = parentContainer.parentElement) === null || _parentContainer$pare === void 0 ? void 0 : _parentContainer$pare.className) === 'pm-table-header-content-wrap' || ((_parentContainer$pare2 = parentContainer.parentElement) === null || _parentContainer$pare2 === void 0 ? void 0 : _parentContainer$pare2.className) === 'pm-table-cell-content-wrap');
|
|
413
|
+
const isTableInsideTable = isNestedTable || isNestedDataTable;
|
|
414
|
+
if (tableContentWrapper) {
|
|
415
|
+
if (isCurrentTableSelected) {
|
|
416
|
+
this.colControlsOffset = tableControlsSpacing;
|
|
417
|
+
|
|
412
418
|
// move table a little out of the way
|
|
413
419
|
// to provide spacing for table controls
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
420
|
+
if (isTableInsideLayout) {
|
|
421
|
+
tableContentWrapper.style.paddingLeft = '11px';
|
|
422
|
+
} else if (isTableInsideTable) {
|
|
423
|
+
tableContentWrapper.style.paddingLeft = '15px';
|
|
424
|
+
tableContentWrapper.style.paddingRight = '4px';
|
|
425
|
+
}
|
|
426
|
+
} else {
|
|
427
|
+
this.colControlsOffset = 0;
|
|
428
|
+
if (isTableInsideLayout) {
|
|
429
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
430
|
+
} else if (isTableInsideTable) {
|
|
431
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
432
|
+
tableContentWrapper.style.removeProperty('padding-right');
|
|
433
|
+
}
|
|
424
434
|
}
|
|
425
435
|
}
|
|
426
436
|
|
|
@@ -8,6 +8,7 @@ const tableFullWidthLabelWrapperStyles = xcss({
|
|
|
8
8
|
backgroundColor: 'elevation.surface.overlay',
|
|
9
9
|
borderRadius: 'border.radius',
|
|
10
10
|
boxShadow: 'elevation.shadow.overlay',
|
|
11
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
11
12
|
lineHeight: 1,
|
|
12
13
|
boxSizing: 'border-box',
|
|
13
14
|
alignItems: 'center'
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import rafSchedule from 'raf-schd';
|
|
2
2
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
3
4
|
import { browser, closestElement, isElementInTableCell, isLastItemMediaGroup, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
4
5
|
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
7
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
6
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
9
|
import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
|
|
@@ -140,7 +142,16 @@ export const handleMouseOver = (view, mouseEvent) => {
|
|
|
140
142
|
} = view;
|
|
141
143
|
return hoverColumns([startIndex], false)(state, dispatch);
|
|
142
144
|
}
|
|
143
|
-
|
|
145
|
+
const isNestedTable = getParentOfTypeCount(state.schema.nodes.table)(state.selection.$from) > 1;
|
|
146
|
+
if (isNestedTable) {
|
|
147
|
+
// if the table is nested inside a table, we only call hideInsertColumnOrRowButton if the table nearest to the mouse target is NOT the parent table
|
|
148
|
+
const nearestTable = closestElement(target, 'table');
|
|
149
|
+
const nestedTable = findParentNodeOfTypeClosestToPos(state.doc.resolve(state.selection.from), [state.schema.nodes.table]);
|
|
150
|
+
const parentTable = findParentNodeOfTypeClosestToPos(state.doc.resolve((nestedTable === null || nestedTable === void 0 ? void 0 : nestedTable.pos) || 0), [state.schema.nodes.table]);
|
|
151
|
+
if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId)) {
|
|
152
|
+
return hideInsertColumnOrRowButton()(state, dispatch);
|
|
153
|
+
}
|
|
154
|
+
} else if ((isCell(target) || isCornerButton(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
|
|
144
155
|
return hideInsertColumnOrRowButton()(state, dispatch);
|
|
145
156
|
}
|
|
146
157
|
if (isResizeHandleDecoration(target)) {
|
|
@@ -406,6 +406,7 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
406
406
|
}, {
|
|
407
407
|
key: "onTablePluginState",
|
|
408
408
|
value: function onTablePluginState(state) {
|
|
409
|
+
var _parentContainer$pare, _parentContainer$pare2;
|
|
409
410
|
var tableRef = state.tableRef;
|
|
410
411
|
var tree = getTree(this.dom);
|
|
411
412
|
if (!tree) {
|
|
@@ -430,22 +431,31 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
430
431
|
var wrapper = tree.wrapper;
|
|
431
432
|
var tableContainer = wrapper.parentElement;
|
|
432
433
|
var tableContentWrapper = tableContainer === null || tableContainer === void 0 ? void 0 : tableContainer.parentElement;
|
|
433
|
-
var
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
434
|
+
var parentContainer = tableContentWrapper && tableContentWrapper.parentElement;
|
|
435
|
+
var isTableInsideLayout = parentContainer && parentContainer.getAttribute('data-layout-content');
|
|
436
|
+
var isNestedTable = parentContainer && (parentContainer.className === 'pm-table-header-content-wrap' || parentContainer.className === 'pm-table-cell-content-wrap');
|
|
437
|
+
var isNestedDataTable = parentContainer && parentContainer.getAttribute('data-mark-type') === 'fragment' && (((_parentContainer$pare = parentContainer.parentElement) === null || _parentContainer$pare === void 0 ? void 0 : _parentContainer$pare.className) === 'pm-table-header-content-wrap' || ((_parentContainer$pare2 = parentContainer.parentElement) === null || _parentContainer$pare2 === void 0 ? void 0 : _parentContainer$pare2.className) === 'pm-table-cell-content-wrap');
|
|
438
|
+
var isTableInsideTable = isNestedTable || isNestedDataTable;
|
|
439
|
+
if (tableContentWrapper) {
|
|
440
|
+
if (isCurrentTableSelected) {
|
|
441
|
+
this.colControlsOffset = tableControlsSpacing;
|
|
442
|
+
|
|
437
443
|
// move table a little out of the way
|
|
438
444
|
// to provide spacing for table controls
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
445
|
+
if (isTableInsideLayout) {
|
|
446
|
+
tableContentWrapper.style.paddingLeft = '11px';
|
|
447
|
+
} else if (isTableInsideTable) {
|
|
448
|
+
tableContentWrapper.style.paddingLeft = '15px';
|
|
449
|
+
tableContentWrapper.style.paddingRight = '4px';
|
|
450
|
+
}
|
|
451
|
+
} else {
|
|
452
|
+
this.colControlsOffset = 0;
|
|
453
|
+
if (isTableInsideLayout) {
|
|
454
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
455
|
+
} else if (isTableInsideTable) {
|
|
456
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
457
|
+
tableContentWrapper.style.removeProperty('padding-right');
|
|
458
|
+
}
|
|
449
459
|
}
|
|
450
460
|
}
|
|
451
461
|
|
|
@@ -8,6 +8,7 @@ var tableFullWidthLabelWrapperStyles = xcss({
|
|
|
8
8
|
backgroundColor: 'elevation.surface.overlay',
|
|
9
9
|
borderRadius: 'border.radius',
|
|
10
10
|
boxShadow: 'elevation.shadow.overlay',
|
|
11
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
11
12
|
lineHeight: 1,
|
|
12
13
|
boxSizing: 'border-box',
|
|
13
14
|
alignItems: 'center'
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import rafSchedule from 'raf-schd';
|
|
3
3
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
4
5
|
import { browser, closestElement, isElementInTableCell, isLastItemMediaGroup, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
5
6
|
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
6
8
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
7
9
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
8
10
|
import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
|
|
@@ -140,7 +142,16 @@ export var handleMouseOver = function handleMouseOver(view, mouseEvent) {
|
|
|
140
142
|
_dispatch2 = view.dispatch;
|
|
141
143
|
return hoverColumns([_startIndex], false)(_state, _dispatch2);
|
|
142
144
|
}
|
|
143
|
-
|
|
145
|
+
var isNestedTable = getParentOfTypeCount(state.schema.nodes.table)(state.selection.$from) > 1;
|
|
146
|
+
if (isNestedTable) {
|
|
147
|
+
// if the table is nested inside a table, we only call hideInsertColumnOrRowButton if the table nearest to the mouse target is NOT the parent table
|
|
148
|
+
var nearestTable = closestElement(target, 'table');
|
|
149
|
+
var nestedTable = findParentNodeOfTypeClosestToPos(state.doc.resolve(state.selection.from), [state.schema.nodes.table]);
|
|
150
|
+
var parentTable = findParentNodeOfTypeClosestToPos(state.doc.resolve((nestedTable === null || nestedTable === void 0 ? void 0 : nestedTable.pos) || 0), [state.schema.nodes.table]);
|
|
151
|
+
if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId)) {
|
|
152
|
+
return hideInsertColumnOrRowButton()(state, dispatch);
|
|
153
|
+
}
|
|
154
|
+
} else if ((isCell(target) || isCornerButton(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
|
|
144
155
|
return hideInsertColumnOrRowButton()(state, dispatch);
|
|
145
156
|
}
|
|
146
157
|
if (isResizeHandleDecoration(target)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.1",
|
|
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
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
31
31
|
"@atlaskit/button": "^20.3.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.9.0",
|
|
33
|
-
"@atlaskit/editor-common": "^98.
|
|
33
|
+
"@atlaskit/editor-common": "^98.2.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.6.3",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
44
44
|
"@atlaskit/editor-shared-styles": "^3.2.0",
|
|
45
45
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
46
|
-
"@atlaskit/icon": "^23.
|
|
46
|
+
"@atlaskit/icon": "^23.2.0",
|
|
47
47
|
"@atlaskit/menu": "^2.13.0",
|
|
48
48
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
49
49
|
"@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
|
|
52
52
|
"@atlaskit/primitives": "^13.3.0",
|
|
53
53
|
"@atlaskit/theme": "^14.0.0",
|
|
54
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
54
|
+
"@atlaskit/tmp-editor-statsig": "^2.32.0",
|
|
55
55
|
"@atlaskit/toggle": "^14.0.0",
|
|
56
56
|
"@atlaskit/tokens": "^2.5.0",
|
|
57
57
|
"@atlaskit/tooltip": "^19.0.0",
|
|
@@ -908,7 +908,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
908
908
|
const topShadowPadding = isDragAndDropEnabled ? 0 : shadowPadding;
|
|
909
909
|
const topOffset = fg('platform_editor_breakout_use_css')
|
|
910
910
|
? 0
|
|
911
|
-
:
|
|
911
|
+
: this.state.stickyHeader?.top ?? 0;
|
|
912
912
|
|
|
913
913
|
const topStickyShadowPosition =
|
|
914
914
|
this.state.stickyHeader && topOffset + this.state.stickyHeader.padding + topShadowPadding + 2;
|
|
@@ -493,24 +493,44 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
|
|
|
493
493
|
const tableContainer = wrapper.parentElement;
|
|
494
494
|
const tableContentWrapper = tableContainer?.parentElement;
|
|
495
495
|
|
|
496
|
-
const
|
|
496
|
+
const parentContainer = tableContentWrapper && tableContentWrapper.parentElement;
|
|
497
497
|
|
|
498
|
-
|
|
499
|
-
|
|
498
|
+
const isTableInsideLayout =
|
|
499
|
+
parentContainer && parentContainer.getAttribute('data-layout-content');
|
|
500
|
+
|
|
501
|
+
const isNestedTable =
|
|
502
|
+
parentContainer &&
|
|
503
|
+
(parentContainer.className === 'pm-table-header-content-wrap' ||
|
|
504
|
+
parentContainer.className === 'pm-table-cell-content-wrap');
|
|
505
|
+
|
|
506
|
+
const isNestedDataTable =
|
|
507
|
+
parentContainer &&
|
|
508
|
+
parentContainer.getAttribute('data-mark-type') === 'fragment' &&
|
|
509
|
+
(parentContainer.parentElement?.className === 'pm-table-header-content-wrap' ||
|
|
510
|
+
parentContainer.parentElement?.className === 'pm-table-cell-content-wrap');
|
|
511
|
+
|
|
512
|
+
const isTableInsideTable = isNestedTable || isNestedDataTable;
|
|
513
|
+
|
|
514
|
+
if (tableContentWrapper) {
|
|
515
|
+
if (isCurrentTableSelected) {
|
|
516
|
+
this.colControlsOffset = tableControlsSpacing;
|
|
500
517
|
|
|
501
|
-
if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
|
|
502
518
|
// move table a little out of the way
|
|
503
519
|
// to provide spacing for table controls
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
520
|
+
if (isTableInsideLayout) {
|
|
521
|
+
tableContentWrapper.style.paddingLeft = '11px';
|
|
522
|
+
} else if (isTableInsideTable) {
|
|
523
|
+
tableContentWrapper.style.paddingLeft = '15px';
|
|
524
|
+
tableContentWrapper.style.paddingRight = '4px';
|
|
525
|
+
}
|
|
526
|
+
} else {
|
|
527
|
+
this.colControlsOffset = 0;
|
|
528
|
+
if (isTableInsideLayout) {
|
|
529
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
530
|
+
} else if (isTableInsideTable) {
|
|
531
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
532
|
+
tableContentWrapper.style.removeProperty('padding-right');
|
|
533
|
+
}
|
|
514
534
|
}
|
|
515
535
|
}
|
|
516
536
|
|
|
@@ -221,8 +221,8 @@ export const hoverCell = (rowIndex?: number, colIndex?: number) =>
|
|
|
221
221
|
// If no arguments have been passed then the intention it to reset the hover cell data
|
|
222
222
|
const clear = rowIndex === undefined && colIndex === undefined;
|
|
223
223
|
|
|
224
|
-
const nextRowIndex = clear ? undefined :
|
|
225
|
-
const nextColIndex = clear ? undefined :
|
|
224
|
+
const nextRowIndex = clear ? undefined : rowIndex ?? prevHoveredCell.rowIndex;
|
|
225
|
+
const nextColIndex = clear ? undefined : colIndex ?? prevHoveredCell.colIndex;
|
|
226
226
|
|
|
227
227
|
if (nextRowIndex === prevHoveredCell.rowIndex && nextColIndex === prevHoveredCell.colIndex) {
|
|
228
228
|
return false;
|
|
@@ -16,7 +16,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
16
16
|
import { findCellRectClosestToPos, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
17
17
|
|
|
18
18
|
import type { DraggableData, DraggableType } from '../../types';
|
|
19
|
-
import { getSelectedTableInfo
|
|
19
|
+
import { getSelectedTableInfo, withEditorAnalyticsAPI } from '../utils/analytics';
|
|
20
20
|
import { canMove, getTargetIndex } from '../utils/drag-menu';
|
|
21
21
|
import { getSelectedColumnIndexes, getSelectedRowIndexes } from '../utils/selection';
|
|
22
22
|
|
|
@@ -5,7 +5,11 @@ import { cloneColumn, cloneRow, moveColumn, moveRow } from '@atlaskit/editor-tab
|
|
|
5
5
|
|
|
6
6
|
import type { DraggableType, TableDirection } from '../../types';
|
|
7
7
|
import { TableDecorations } from '../../types';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
createColumnInsertLine,
|
|
10
|
+
createRowInsertLine,
|
|
11
|
+
updateDecorations,
|
|
12
|
+
} from '../utils/decoration';
|
|
9
13
|
|
|
10
14
|
import { DragAndDropActionType } from './actions';
|
|
11
15
|
import { DropTargetType } from './consts';
|
|
@@ -105,7 +105,7 @@ export const insertColgroupFromNode = (
|
|
|
105
105
|
|
|
106
106
|
colgroup = renderColgroupFromNode(
|
|
107
107
|
table,
|
|
108
|
-
isTableScalingEnabled ?
|
|
108
|
+
isTableScalingEnabled ? tableRef ?? undefined : undefined,
|
|
109
109
|
shouldUseIncreasedScalingPercent,
|
|
110
110
|
isCommentEditor,
|
|
111
111
|
);
|
|
@@ -9,7 +9,7 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
|
|
11
11
|
import type { PluginInjectionAPI } from '../../types';
|
|
12
|
-
import { isMinCellWidthTable
|
|
12
|
+
import { isMinCellWidthTable, hasTableBeenResized } from '../table-resizing/utils/colgroup';
|
|
13
13
|
import { getTableContainerElementWidth, getTableElementWidth } from '../table-resizing/utils/misc';
|
|
14
14
|
import { getResizeState } from '../table-resizing/utils/resize-state';
|
|
15
15
|
import { scaleTableTo } from '../table-resizing/utils/scale-table';
|
|
@@ -98,7 +98,7 @@ export const ColumnControls = ({
|
|
|
98
98
|
const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
99
99
|
|
|
100
100
|
const rowControlStickyTop = fg('platform_editor_breakout_use_css') ? 45 : rowHeights?.[0];
|
|
101
|
-
const marginTop = hasHeaderRow && stickyTop !== undefined ?
|
|
101
|
+
const marginTop = hasHeaderRow && stickyTop !== undefined ? rowControlStickyTop ?? 0 : 0;
|
|
102
102
|
|
|
103
103
|
const handleClick = useCallback(
|
|
104
104
|
(event: MouseEvent) => {
|
|
@@ -102,7 +102,7 @@ const TableFloatingColumnControls = ({
|
|
|
102
102
|
|
|
103
103
|
if (stickyTop) {
|
|
104
104
|
const columnControlTopOffsetFromParent = '-12px';
|
|
105
|
-
const headerRowHeight = hasHeaderRow && stickyTop !== undefined ?
|
|
105
|
+
const headerRowHeight = hasHeaderRow && stickyTop !== undefined ? rowHeights?.[0] ?? 0 : 0;
|
|
106
106
|
containerRef?.current?.style.setProperty(
|
|
107
107
|
'top',
|
|
108
108
|
fg('platform_editor_breakout_use_css')
|
|
@@ -12,6 +12,7 @@ const tableFullWidthLabelWrapperStyles = xcss({
|
|
|
12
12
|
backgroundColor: 'elevation.surface.overlay',
|
|
13
13
|
borderRadius: 'border.radius',
|
|
14
14
|
boxShadow: 'elevation.shadow.overlay',
|
|
15
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
15
16
|
lineHeight: 1,
|
|
16
17
|
boxSizing: 'border-box',
|
|
17
18
|
alignItems: 'center',
|
package/src/ui/event-handlers.ts
CHANGED
|
@@ -2,6 +2,7 @@ import rafSchedule from 'raf-schd';
|
|
|
2
2
|
|
|
3
3
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
5
6
|
import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
6
7
|
import {
|
|
7
8
|
browser,
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
14
15
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
15
16
|
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
17
|
+
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
16
18
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
17
19
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
18
20
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
@@ -224,7 +226,23 @@ export const handleMouseOver = (view: EditorView, mouseEvent: Event): boolean =>
|
|
|
224
226
|
return hoverColumns([startIndex], false)(state, dispatch);
|
|
225
227
|
}
|
|
226
228
|
|
|
227
|
-
|
|
229
|
+
const isNestedTable = getParentOfTypeCount(state.schema.nodes.table)(state.selection.$from) > 1;
|
|
230
|
+
|
|
231
|
+
if (isNestedTable) {
|
|
232
|
+
// if the table is nested inside a table, we only call hideInsertColumnOrRowButton if the table nearest to the mouse target is NOT the parent table
|
|
233
|
+
const nearestTable = closestElement(target, 'table');
|
|
234
|
+
const nestedTable = findParentNodeOfTypeClosestToPos(state.doc.resolve(state.selection.from), [
|
|
235
|
+
state.schema.nodes.table,
|
|
236
|
+
]);
|
|
237
|
+
|
|
238
|
+
const parentTable = findParentNodeOfTypeClosestToPos(state.doc.resolve(nestedTable?.pos || 0), [
|
|
239
|
+
state.schema.nodes.table,
|
|
240
|
+
]);
|
|
241
|
+
|
|
242
|
+
if (nearestTable?.dataset.tableLocalId !== parentTable?.node.attrs.localId) {
|
|
243
|
+
return hideInsertColumnOrRowButton()(state, dispatch);
|
|
244
|
+
}
|
|
245
|
+
} else if (
|
|
228
246
|
(isCell(target) || isCornerButton(target)) &&
|
|
229
247
|
(typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')
|
|
230
248
|
) {
|