@atlaskit/editor-plugin-table 24.2.1 → 24.2.3
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 +21 -0
- package/dist/cjs/pm-plugins/utils/column-controls.js +119 -2
- package/dist/cjs/pm-plugins/utils/dom.js +20 -1
- package/dist/cjs/pm-plugins/utils/row-controls.js +43 -1
- package/dist/cjs/pm-plugins/utils/selection.js +61 -1
- package/dist/cjs/ui/DragHandle/index.js +10 -2
- package/dist/cjs/ui/FloatingInsertButton/getPopupOptions.js +19 -5
- package/dist/cjs/ui/FloatingInsertButton/index.js +37 -3
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +25 -15
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +28 -12
- package/dist/cjs/ui/common-styles.js +6 -1
- package/dist/cjs/ui/event-handlers.js +47 -7
- package/dist/cjs/ui/rounded-table-styles.js +1 -1
- package/dist/es2019/pm-plugins/utils/column-controls.js +114 -2
- package/dist/es2019/pm-plugins/utils/dom.js +19 -0
- package/dist/es2019/pm-plugins/utils/row-controls.js +42 -0
- package/dist/es2019/pm-plugins/utils/selection.js +60 -0
- package/dist/es2019/ui/DragHandle/index.js +10 -2
- package/dist/es2019/ui/FloatingInsertButton/getPopupOptions.js +24 -5
- package/dist/es2019/ui/FloatingInsertButton/index.js +35 -3
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +26 -16
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +2 -2
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +29 -12
- package/dist/es2019/ui/common-styles.js +28 -2
- package/dist/es2019/ui/event-handlers.js +47 -7
- package/dist/es2019/ui/rounded-table-styles.js +1 -1
- package/dist/esm/pm-plugins/utils/column-controls.js +118 -1
- package/dist/esm/pm-plugins/utils/dom.js +19 -0
- package/dist/esm/pm-plugins/utils/row-controls.js +42 -0
- package/dist/esm/pm-plugins/utils/selection.js +60 -0
- package/dist/esm/ui/DragHandle/index.js +10 -2
- package/dist/esm/ui/FloatingInsertButton/getPopupOptions.js +19 -5
- package/dist/esm/ui/FloatingInsertButton/index.js +37 -3
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +27 -17
- package/dist/esm/ui/TableFloatingColumnControls/index.js +2 -2
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +30 -14
- package/dist/esm/ui/common-styles.js +7 -2
- package/dist/esm/ui/event-handlers.js +49 -9
- package/dist/esm/ui/rounded-table-styles.js +1 -1
- package/dist/types/pm-plugins/utils/column-controls.d.ts +35 -1
- package/dist/types/pm-plugins/utils/dom.d.ts +10 -0
- package/dist/types/pm-plugins/utils/row-controls.d.ts +16 -0
- package/dist/types/pm-plugins/utils/selection.d.ts +13 -0
- package/dist/types/ui/DragHandle/index.d.ts +1 -1
- package/dist/types/ui/FloatingInsertButton/getPopupOptions.d.ts +1 -1
- package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -0
- package/package.json +3 -3
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { css } from '@emotion/react';
|
|
8
8
|
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
9
|
-
import { ANCHOR_VARIABLE_NAME, tableMarginTop, tableSharedStyle, TableSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
9
|
+
import { ANCHOR_VARIABLE_NAME, DRAG_HANDLE_WIDTH, tableMarginTop, tableSharedStyle, TableSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
10
10
|
import { SORTABLE_COLUMN_ICON_CLASSNAME } from '@atlaskit/editor-common/table';
|
|
11
11
|
import { akEditorSelectedNodeClassName, akEditorSmallZIndex, akEditorStickyHeaderZIndex, akEditorTableCellOnStickyHeaderZIndex, akEditorTableNumberColumnWidth, akEditorTableToolbarSize, akEditorUnitZIndex, getSelectionStyles, MAX_BROWSER_SCROLLBAR_HEIGHT, SelectionStyle, relativeSizeToBaseFontSize, relativeFontSizeToBase16, akEditorSelectedBorderColor } from '@atlaskit/editor-shared-styles';
|
|
12
12
|
import { akEditorTableContainerBg } from '@atlaskit/editor-shared-styles/consts';
|
|
@@ -425,6 +425,31 @@ const baseTableStylesWithoutSharedStyle = props => css`
|
|
|
425
425
|
width: ${insertColumnButtonOffset + 1}px;
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
+
/* use :before element to hide table row insert dots when legacy table sticky header is activated */
|
|
429
|
+
${expValEquals('platform_editor_table_col_insert', 'isEnabled', true) ?
|
|
430
|
+
// Mask geometry mirrors the drag-handle wrapper geometry from
|
|
431
|
+
// editor-plugin-block-controls/src/ui/drag-handle.tsx
|
|
432
|
+
// (`buttonWrapperStyles`):
|
|
433
|
+
// height = paddingTop (=calc(space.400 - 1px)) + paddingBottom (=space.200) + DRAG_HANDLE_HEIGHT
|
|
434
|
+
// width = DRAG_HANDLE_WIDTH + paddingRight('space.150')
|
|
435
|
+
`.${ClassName.TABLE_CONTAINER}.${ClassName.TABLE_STICKY}:has(tr.sticky)::before {
|
|
436
|
+
content: ' ';
|
|
437
|
+
position: sticky;
|
|
438
|
+
pointer-events: none;
|
|
439
|
+
top: 0;
|
|
440
|
+
float: left;
|
|
441
|
+
transform: translateX(calc(-1 * (${DRAG_HANDLE_WIDTH}px + ${"var(--ds-space-150, 12px)"})));
|
|
442
|
+
margin-bottom: calc(-1 * (${"var(--ds-space-400, 32px)"} - 1px + ${"var(--ds-space-200, 16px)"} + ${"var(--ds-space-300, 24px)"}));
|
|
443
|
+
height: calc(${"var(--ds-space-400, 32px)"} - 1px + ${"var(--ds-space-200, 16px)"} + ${"var(--ds-space-300, 24px)"});
|
|
444
|
+
width: calc(${DRAG_HANDLE_WIDTH}px + ${"var(--ds-space-150, 12px)"});
|
|
445
|
+
background: linear-gradient(
|
|
446
|
+
to bottom,
|
|
447
|
+
${expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? `var(${akEditorTableContainerBg}, ${"var(--ds-surface, #FFFFFF)"})` : "var(--ds-surface, #FFFFFF)"} 90%,
|
|
448
|
+
transparent
|
|
449
|
+
);
|
|
450
|
+
z-index: ${rowControlsZIndex + 5};
|
|
451
|
+
}` : ``}
|
|
452
|
+
|
|
428
453
|
/* To fix jumpiness caused in Chrome Browsers for sticky headers */
|
|
429
454
|
.${ClassName.TABLE_STICKY} .sticky + tr {
|
|
430
455
|
min-height: 0px;
|
|
@@ -456,12 +481,13 @@ const baseTableStylesWithoutSharedStyle = props => css`
|
|
|
456
481
|
tr.${ClassName.NATIVE_STICKY} {
|
|
457
482
|
position: sticky;
|
|
458
483
|
top: ${tableMarginTop}px;
|
|
459
|
-
z-index: calc(${akEditorTableCellOnStickyHeaderZIndex} - 5);
|
|
484
|
+
z-index: ${expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true) ? akEditorSmallZIndex : `calc(${akEditorTableCellOnStickyHeaderZIndex} - 5)`};
|
|
460
485
|
box-shadow:
|
|
461
486
|
inset -1px 1px ${tableBorderColor},
|
|
462
487
|
inset 1px -1px ${tableBorderColor};
|
|
463
488
|
|
|
464
489
|
&.${ClassName.NATIVE_STICKY_ACTIVE} {
|
|
490
|
+
${expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true) ? `z-index: ${nativeStickyHeaderZIndex};` : ''}
|
|
465
491
|
box-shadow:
|
|
466
492
|
inset -1px 1px ${tableBorderColor},
|
|
467
493
|
inset 1px -1px ${tableBorderColor},
|
|
@@ -16,9 +16,10 @@ import { getPluginState as getResizePluginState } from '../pm-plugins/table-resi
|
|
|
16
16
|
import { deleteColumns } from '../pm-plugins/transforms/delete-columns';
|
|
17
17
|
import { deleteRows } from '../pm-plugins/transforms/delete-rows';
|
|
18
18
|
import { getSelectedCellInfo } from '../pm-plugins/utils/analytics';
|
|
19
|
-
import { convertHTMLCellIndexToColumnIndex, getColumnIndexMappedToColumnIndexInFirstRow } from '../pm-plugins/utils/column-controls';
|
|
20
|
-
import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isDragColumnFloatingInsertDot, isDragCornerButton, isDragRowFloatingInsertDot, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from '../pm-plugins/utils/dom';
|
|
19
|
+
import { convertHTMLCellIndexToColumnIndex, getColumnIndexByMousePosition, getColumnIndexMappedToColumnIndexInFirstRow } from '../pm-plugins/utils/column-controls';
|
|
20
|
+
import { getColumnOrRowIndex, getIndexAttributeSourceElement, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isDragColumnFloatingInsertDot, isDragCornerButton, isDragRowFloatingInsertDot, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from '../pm-plugins/utils/dom';
|
|
21
21
|
import { getAllowAddColumnCustomStep } from '../pm-plugins/utils/get-allow-add-column-custom-step';
|
|
22
|
+
import { getRowIndexByMousePosition } from '../pm-plugins/utils/row-controls';
|
|
22
23
|
import { TableCssClassName as ClassName, RESIZE_HANDLE_AREA_DECORATION_GAP } from '../types';
|
|
23
24
|
import { TABLE_MENU_SELECTOR } from './TableMenu/shared/consts';
|
|
24
25
|
const isFocusingCalendar = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
|
|
@@ -292,6 +293,19 @@ const handleMouseMoveDebounce = nodeViewPortalProviderAPI => rafSchedule((view,
|
|
|
292
293
|
return false;
|
|
293
294
|
}
|
|
294
295
|
const element = event.target;
|
|
296
|
+
const isTableMenuUpdatesEnabled = expValEquals('platform_editor_table_menu_updates', 'isEnabled', true);
|
|
297
|
+
|
|
298
|
+
// Spanned cells need mouse-position-based hover indexes; normal cells already report them.
|
|
299
|
+
if (isTableMenuUpdatesEnabled) {
|
|
300
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
301
|
+
const tableCell = isElementInTableCell(element);
|
|
302
|
+
if (tableCell && (tableCell.rowSpan > 1 || tableCell.colSpan > 1)) {
|
|
303
|
+
const dragDropState = getDragDropPluginState(view.state);
|
|
304
|
+
if (dragDropState && !dragDropState.isDragging) {
|
|
305
|
+
trackCellLocation(view, event);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
295
309
|
if (isColumnControlsDecorations(element) || isDragColumnFloatingInsertDot(element)) {
|
|
296
310
|
const {
|
|
297
311
|
state,
|
|
@@ -300,7 +314,8 @@ const handleMouseMoveDebounce = nodeViewPortalProviderAPI => rafSchedule((view,
|
|
|
300
314
|
const {
|
|
301
315
|
insertColumnButtonIndex
|
|
302
316
|
} = getPluginState(state);
|
|
303
|
-
const
|
|
317
|
+
const indexSourceElement = isTableMenuUpdatesEnabled ? getIndexAttributeSourceElement(element) : element;
|
|
318
|
+
const [startIndex, endIndex] = getColumnOrRowIndex(indexSourceElement);
|
|
304
319
|
const positionColumn = getMousePositionHorizontalRelativeByElement(event, offsetX, undefined) === 'right' ? endIndex : startIndex;
|
|
305
320
|
if (positionColumn !== insertColumnButtonIndex) {
|
|
306
321
|
return showInsertColumnButton(positionColumn)(state, dispatch);
|
|
@@ -314,7 +329,8 @@ const handleMouseMoveDebounce = nodeViewPortalProviderAPI => rafSchedule((view,
|
|
|
314
329
|
const {
|
|
315
330
|
insertRowButtonIndex
|
|
316
331
|
} = getPluginState(state);
|
|
317
|
-
const
|
|
332
|
+
const indexSourceElement = isTableMenuUpdatesEnabled ? getIndexAttributeSourceElement(element) : element;
|
|
333
|
+
const [startIndex, endIndex] = getColumnOrRowIndex(indexSourceElement);
|
|
318
334
|
const positionRow = getMousePositionVerticalRelativeByElement(event) === 'bottom' ? endIndex : startIndex;
|
|
319
335
|
if (positionRow !== insertRowButtonIndex) {
|
|
320
336
|
return showInsertRowButton(positionRow)(state, dispatch);
|
|
@@ -462,7 +478,8 @@ export const whenTableInFocus = (eventHandler, pluginInjectionApi) => (view, mou
|
|
|
462
478
|
return eventHandler(view, mouseEvent);
|
|
463
479
|
};
|
|
464
480
|
const trackCellLocation = (view, mouseEvent) => {
|
|
465
|
-
var _tableElement$dataset;
|
|
481
|
+
var _tableElement$dataset, _getRowIndexByMousePo;
|
|
482
|
+
const isTableMenuUpdatesEnabled = expValEquals('platform_editor_table_menu_updates', 'isEnabled', true);
|
|
466
483
|
const target = mouseEvent.target;
|
|
467
484
|
// Ignored via go/ees005
|
|
468
485
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -488,13 +505,36 @@ const trackCellLocation = (view, mouseEvent) => {
|
|
|
488
505
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
489
506
|
const rowElement = closestElement(target, 'tr');
|
|
490
507
|
const htmlRowIndex = rowElement && rowElement.rowIndex;
|
|
508
|
+
const rowIndex = maybeTableCell.rowSpan > 1 && mouseEvent instanceof MouseEvent && isTableMenuUpdatesEnabled ? (_getRowIndexByMousePo = getRowIndexByMousePosition(tableRef, mouseEvent, {
|
|
509
|
+
startIndex: htmlRowIndex,
|
|
510
|
+
endIndex: htmlRowIndex + maybeTableCell.rowSpan
|
|
511
|
+
})) !== null && _getRowIndexByMousePo !== void 0 ? _getRowIndexByMousePo : htmlRowIndex : htmlRowIndex;
|
|
491
512
|
const tableMap = tableNode && TableMap.get(tableNode);
|
|
492
513
|
let colIndex = htmlColIndex;
|
|
493
514
|
if (tableMap) {
|
|
494
515
|
const convertedColIndex = convertHTMLCellIndexToColumnIndex(htmlColIndex, htmlRowIndex, tableMap);
|
|
495
|
-
|
|
516
|
+
if (isTableMenuUpdatesEnabled) {
|
|
517
|
+
// New behaviour: the column controls grid renders one track per visual column
|
|
518
|
+
// (`getColumnsWidthsWithMergedCells`), so the hover index must be the visual column
|
|
519
|
+
// index — not the first-row-cell index. Mapping to the first-row cell would collapse
|
|
520
|
+
// every column under a merged first-row cell to the same index, leaving the drag handle
|
|
521
|
+
// stuck when hovering cells in other rows. For a colspanned cell, refine the converted
|
|
522
|
+
// (left-most) visual column to the exact visual column under the pointer.
|
|
523
|
+
colIndex = convertedColIndex;
|
|
524
|
+
if (maybeTableCell.colSpan > 1 && mouseEvent instanceof MouseEvent) {
|
|
525
|
+
var _getColumnIndexByMous;
|
|
526
|
+
colIndex = (_getColumnIndexByMous = getColumnIndexByMousePosition(maybeTableCell, mouseEvent, {
|
|
527
|
+
startIndex: convertedColIndex,
|
|
528
|
+
endIndex: convertedColIndex + maybeTableCell.colSpan
|
|
529
|
+
})) !== null && _getColumnIndexByMous !== void 0 ? _getColumnIndexByMous : convertedColIndex;
|
|
530
|
+
}
|
|
531
|
+
} else {
|
|
532
|
+
// Old behaviour: the legacy grid renders one track per first-row cell, so snap to the
|
|
533
|
+
// first-row column index (a merged first-row cell collapses to a single column track).
|
|
534
|
+
colIndex = getColumnIndexMappedToColumnIndexInFirstRow(convertedColIndex, htmlRowIndex, tableMap);
|
|
535
|
+
}
|
|
496
536
|
}
|
|
497
|
-
hoverCell(
|
|
537
|
+
hoverCell(rowIndex, colIndex)(view.state, view.dispatch);
|
|
498
538
|
};
|
|
499
539
|
export const withCellTracking = eventHandler => (view, mouseEvent) => {
|
|
500
540
|
if (getDragDropPluginState(view.state) && !getDragDropPluginState(view.state).isDragging) {
|
|
@@ -374,7 +374,7 @@ const roundedTableStickyHeaderCornerMaskStyles = () => css`
|
|
|
374
374
|
sticky / fallback layout. The masks belong to the wrapper of the table
|
|
375
375
|
that owns the sticky row, never to an ancestor wrapper.
|
|
376
376
|
*/
|
|
377
|
-
.${ClassName.TABLE_NODE_WRAPPER}:has(> table > tbody > tr.${ClassName.
|
|
377
|
+
.${ClassName.TABLE_NODE_WRAPPER}:has(> table > tbody > tr.${ClassName.NATIVE_STICKY_ACTIVE})
|
|
378
378
|
> .${ClassName.TABLE_CORNER_MASK},
|
|
379
379
|
.${ClassName.TABLE_NODE_WRAPPER}:has(> table.${ClassName.TABLE_STICKY} > tbody > tr.sticky)
|
|
380
380
|
> .${ClassName.TABLE_CORNER_MASK} {
|
|
@@ -33,6 +33,73 @@ export var getColumnsWidths = function getColumnsWidths(view) {
|
|
|
33
33
|
}
|
|
34
34
|
return widths;
|
|
35
35
|
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Splits a merged cell's rendered width by `colwidth` ratios, falling back to an even split when
|
|
39
|
+
* usable ratios are unavailable.
|
|
40
|
+
*/
|
|
41
|
+
export var getProportionalColumnWidths = function getProportionalColumnWidths(totalWidth, columnCount, ratios) {
|
|
42
|
+
var evenSplit = function evenSplit() {
|
|
43
|
+
return new Array(columnCount).fill(totalWidth / columnCount);
|
|
44
|
+
};
|
|
45
|
+
if (!ratios || ratios.length !== columnCount) {
|
|
46
|
+
return evenSplit();
|
|
47
|
+
}
|
|
48
|
+
var total = ratios.reduce(function (sum, ratio) {
|
|
49
|
+
return sum + (ratio > 0 ? ratio : 0);
|
|
50
|
+
}, 0);
|
|
51
|
+
if (total <= 0) {
|
|
52
|
+
return evenSplit();
|
|
53
|
+
}
|
|
54
|
+
return ratios.map(function (ratio) {
|
|
55
|
+
return totalWidth * ((ratio > 0 ? ratio : 0) / total);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Like `getColumnsWidths`, but fills every visual column under a first-row `colspan` so column
|
|
61
|
+
* controls can render one grid track per column.
|
|
62
|
+
*/
|
|
63
|
+
export var getColumnsWidthsWithMergedCells = function getColumnsWidthsWithMergedCells(view) {
|
|
64
|
+
var selection = view.state.selection;
|
|
65
|
+
var table = findTable(selection);
|
|
66
|
+
if (!table) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
var map = TableMap.get(table.node);
|
|
70
|
+
var domAtPos = view.domAtPos.bind(view);
|
|
71
|
+
var widths = Array.from({
|
|
72
|
+
length: map.width
|
|
73
|
+
});
|
|
74
|
+
for (var i = 0; i < map.width; i++) {
|
|
75
|
+
var _node$attrs$colspan;
|
|
76
|
+
if (map.isCellMergedTopLeft(0, i)) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Ignored via go/ees005
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
82
|
+
var node = table.node.nodeAt(map.map[i]);
|
|
83
|
+
var pos = map.map[i] + table.start;
|
|
84
|
+
// Ignored via go/ees005
|
|
85
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
86
|
+
var cellRef = findDomRefAtPos(pos, domAtPos);
|
|
87
|
+
var rect = cellRef.getBoundingClientRect();
|
|
88
|
+
var measuredWidth = (rect ? rect.width : cellRef.offsetWidth) + 1;
|
|
89
|
+
var colspan = (_node$attrs$colspan = node.attrs.colspan) !== null && _node$attrs$colspan !== void 0 ? _node$attrs$colspan : 1;
|
|
90
|
+
if (colspan <= 1) {
|
|
91
|
+
widths[i] = measuredWidth;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
var colwidth = Array.isArray(node.attrs.colwidth) ? node.attrs.colwidth : undefined;
|
|
95
|
+
var perColumnWidths = getProportionalColumnWidths(measuredWidth, colspan, colwidth);
|
|
96
|
+
for (var span = 0; span < colspan && i + span < map.width; span++) {
|
|
97
|
+
widths[i + span] = perColumnWidths[span];
|
|
98
|
+
}
|
|
99
|
+
i += colspan - 1;
|
|
100
|
+
}
|
|
101
|
+
return widths;
|
|
102
|
+
};
|
|
36
103
|
export var getColumnDeleteButtonParams = function getColumnDeleteButtonParams(columnsWidths, selection) {
|
|
37
104
|
var rect = getSelectionRect(selection);
|
|
38
105
|
if (!rect) {
|
|
@@ -115,6 +182,9 @@ var getRelativeDomCellWidths = function getRelativeDomCellWidths(_ref) {
|
|
|
115
182
|
});
|
|
116
183
|
};
|
|
117
184
|
export var colWidthsForRow = function colWidthsForRow(tr) {
|
|
185
|
+
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
186
|
+
_ref2$useColwidthRati = _ref2.useColwidthRatios,
|
|
187
|
+
useColwidthRatios = _ref2$useColwidthRati === void 0 ? false : _ref2$useColwidthRati;
|
|
118
188
|
// get the colspans
|
|
119
189
|
var rowColSpans = maphElem(tr, function (cell) {
|
|
120
190
|
return Number(cell.getAttribute('colspan') || 1 /* default to span of 1 */);
|
|
@@ -142,7 +212,7 @@ export var colWidthsForRow = function colWidthsForRow(tr) {
|
|
|
142
212
|
// reverse engineer cell widths from table widths
|
|
143
213
|
var domBasedCellWidths = [];
|
|
144
214
|
cellInfos.map(function (cell) {
|
|
145
|
-
domBasedCellWidths.push.apply(domBasedCellWidths, _toConsumableArray(getRelativeDomCellWidths(cell)));
|
|
215
|
+
domBasedCellWidths.push.apply(domBasedCellWidths, _toConsumableArray(useColwidthRatios ? getRelativeDomCellWidths(cell) : new Array(cell.colspan).fill(cell.width / cell.colspan)));
|
|
146
216
|
});
|
|
147
217
|
if (cellInfos.reduce(function (acc, cell) {
|
|
148
218
|
return acc + cell.width;
|
|
@@ -166,6 +236,53 @@ export var colWidthsForRow = function colWidthsForRow(tr) {
|
|
|
166
236
|
return "".concat(pct, "%");
|
|
167
237
|
}).join(' ');
|
|
168
238
|
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Returns the visual column index that the mouse pointer is over within a column-spanned
|
|
242
|
+
* cell, by walking the per-column boundaries of the spanned cell and finding the column whose
|
|
243
|
+
* horizontal range contains `mouseEvent.clientX`.
|
|
244
|
+
*
|
|
245
|
+
* `<td>.cellIndex` for a cell with `colspan > 1` only resolves to the first column the cell
|
|
246
|
+
* occupies, so hovering anywhere inside a colspanned first-row cell pins the column drag handle
|
|
247
|
+
* to that first column. This resolver disambiguates which visual column the pointer is actually
|
|
248
|
+
* over so the handle/menu can target a single column.
|
|
249
|
+
*
|
|
250
|
+
* The search is restricted to columns in `[startIndex, endIndex)` (the cell's own span). The
|
|
251
|
+
* spanned cell's bounding rect is read once and split into per-column boundaries using the cell's
|
|
252
|
+
* `data-colwidth` ratios (falling back to an even split for unresized columns) — this keeps the
|
|
253
|
+
* work bounded by the colspan size and avoids measuring the whole table.
|
|
254
|
+
*
|
|
255
|
+
* Returns `undefined` when the mouse is outside the spanned range (so callers can fall back to
|
|
256
|
+
* the converted HTML column index).
|
|
257
|
+
*/
|
|
258
|
+
export var getColumnIndexByMousePosition = function getColumnIndexByMousePosition(cellElement, mouseEvent, columnIndexRange) {
|
|
259
|
+
var _cellElement$dataset$;
|
|
260
|
+
var startIndex = columnIndexRange.startIndex,
|
|
261
|
+
endIndex = columnIndexRange.endIndex;
|
|
262
|
+
var columnCount = endIndex - startIndex;
|
|
263
|
+
if (columnCount <= 0) {
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
var cellRect = cellElement.getBoundingClientRect();
|
|
267
|
+
if (mouseEvent.clientX < cellRect.left || mouseEvent.clientX >= cellRect.right) {
|
|
268
|
+
return undefined;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Read DOM ratios here to avoid resolving the ProseMirror node on this mouse-move path.
|
|
272
|
+
var ratios = (_cellElement$dataset$ = cellElement.dataset.colwidth) === null || _cellElement$dataset$ === void 0 ? void 0 : _cellElement$dataset$.split(',').map(Number).filter(function (value) {
|
|
273
|
+
return !Number.isNaN(value);
|
|
274
|
+
});
|
|
275
|
+
var perColumnWidths = getProportionalColumnWidths(cellRect.width, columnCount, ratios);
|
|
276
|
+
var offsetFromLeft = mouseEvent.clientX - cellRect.left;
|
|
277
|
+
var cumulativeWidth = 0;
|
|
278
|
+
for (var column = 0; column < columnCount; column++) {
|
|
279
|
+
cumulativeWidth += perColumnWidths[column];
|
|
280
|
+
if (offsetFromLeft < cumulativeWidth) {
|
|
281
|
+
return startIndex + column;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return endIndex - 1;
|
|
285
|
+
};
|
|
169
286
|
export var convertHTMLCellIndexToColumnIndex = function convertHTMLCellIndexToColumnIndex(htmlColIndex, htmlRowIndex, tableMap) {
|
|
170
287
|
// Same numbers (positions) in tableMap.map array mean that there are merged cells.
|
|
171
288
|
// Cells can be merged across columns. So we need to check if the cell on the left and current cell have the same value.
|
|
@@ -12,6 +12,25 @@ export var isInsertRowButton = function isInsertRowButton(node) {
|
|
|
12
12
|
export var getColumnOrRowIndex = function getColumnOrRowIndex(target) {
|
|
13
13
|
return [parseInt(target.getAttribute('data-start-index') || '-1', 10), parseInt(target.getAttribute('data-end-index') || '-1', 10)];
|
|
14
14
|
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Returns the element that carries the `data-start-index` / `data-end-index` attributes for a
|
|
18
|
+
* column/row control.
|
|
19
|
+
*
|
|
20
|
+
* The floating insert dot is a child of a wrapper that holds the index attributes, so when the
|
|
21
|
+
* pointer is directly over the dot the attributes are not on the event target. This walks up to
|
|
22
|
+
* the nearest ancestor that has `data-start-index`, falling back to the original element so the
|
|
23
|
+
* behaviour is unchanged when the target already carries the attributes.
|
|
24
|
+
*/
|
|
25
|
+
export var getIndexAttributeSourceElement = function getIndexAttributeSourceElement(target) {
|
|
26
|
+
if (target.hasAttribute('data-start-index')) {
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
// Ignored via go/ees005
|
|
30
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
31
|
+
var closestWithIndex = target.closest('[data-start-index]');
|
|
32
|
+
return closestWithIndex !== null && closestWithIndex !== void 0 ? closestWithIndex : target;
|
|
33
|
+
};
|
|
15
34
|
export var isColumnControlsDecorations = function isColumnControlsDecorations(node) {
|
|
16
35
|
return containsClassName(node, ClassName.COLUMN_CONTROLS_DECORATIONS);
|
|
17
36
|
};
|
|
@@ -78,6 +78,48 @@ export var getRowsParams = function getRowsParams(rowsHeights) {
|
|
|
78
78
|
}
|
|
79
79
|
return rows;
|
|
80
80
|
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Returns the visual row index that the mouse pointer is over, by walking the row heights
|
|
84
|
+
* inside `tbody` and finding the row whose vertical range contains `mouseEvent.clientY`.
|
|
85
|
+
*
|
|
86
|
+
* When `rowIndexRange` is provided, the search is restricted to rows in that range (the
|
|
87
|
+
* `endIndex` is exclusive). This is the hot path used on `mousemove` when hovering over a
|
|
88
|
+
* row-spanned cell — restricting the range to `[startIndex, endIndex)` keeps the number
|
|
89
|
+
* of forced layout reads bounded by the row-span size, not the table size.
|
|
90
|
+
*
|
|
91
|
+
* Returns `undefined` when the mouse is above the search range or below it (so callers can
|
|
92
|
+
* fall back to the HTML row index).
|
|
93
|
+
*/
|
|
94
|
+
export var getRowIndexByMousePosition = function getRowIndexByMousePosition(tableRef, mouseEvent, rowIndexRange) {
|
|
95
|
+
var _rowIndexRange$startI, _rowIndexRange$endInd;
|
|
96
|
+
var tableBody = tableRef.querySelector('tbody');
|
|
97
|
+
if (!tableBody) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
var rows = tableBody.children;
|
|
101
|
+
var startIndex = (_rowIndexRange$startI = rowIndexRange === null || rowIndexRange === void 0 ? void 0 : rowIndexRange.startIndex) !== null && _rowIndexRange$startI !== void 0 ? _rowIndexRange$startI : 0;
|
|
102
|
+
var endIndex = Math.min((_rowIndexRange$endInd = rowIndexRange === null || rowIndexRange === void 0 ? void 0 : rowIndexRange.endIndex) !== null && _rowIndexRange$endInd !== void 0 ? _rowIndexRange$endInd : rows.length, rows.length);
|
|
103
|
+
if (startIndex >= endIndex) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
var firstRowRect = rows[startIndex].getBoundingClientRect();
|
|
107
|
+
if (mouseEvent.clientY < firstRowRect.top) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
var rowBottom = firstRowRect.bottom;
|
|
111
|
+
if (mouseEvent.clientY < rowBottom) {
|
|
112
|
+
return startIndex;
|
|
113
|
+
}
|
|
114
|
+
for (var rowIndex = startIndex + 1; rowIndex < endIndex; rowIndex++) {
|
|
115
|
+
var rowRect = rows[rowIndex].getBoundingClientRect();
|
|
116
|
+
rowBottom = rowRect.bottom;
|
|
117
|
+
if (mouseEvent.clientY < rowBottom) {
|
|
118
|
+
return rowIndex;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return undefined;
|
|
122
|
+
};
|
|
81
123
|
export var getRowClassNames = function getRowClassNames(index, selection) {
|
|
82
124
|
var hoveredRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
83
125
|
var isInDanger = arguments.length > 3 ? arguments[3] : undefined;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
2
|
+
import { findTableClosestToPos, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
1
3
|
export var getSelectedColumnIndexes = function getSelectedColumnIndexes(selectionRect) {
|
|
2
4
|
var columnIndexes = [];
|
|
3
5
|
for (var i = selectionRect.left; i < selectionRect.right; i++) {
|
|
@@ -11,4 +13,62 @@ export var getSelectedRowIndexes = function getSelectedRowIndexes(selectionRect)
|
|
|
11
13
|
rowIndexes.push(i);
|
|
12
14
|
}
|
|
13
15
|
return rowIndexes;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Treats a column as fully selected when its first-row area is covered by a horizontal merge and
|
|
20
|
+
* the explicit `CellSelection` starts below that merged cell. `CellSelection.isColSelection()`
|
|
21
|
+
* returns `false` in this case because the selection does not include the merged first-row cell.
|
|
22
|
+
*/
|
|
23
|
+
export var isColumnSelectionWithMergedFirstRow = function isColumnSelectionWithMergedFirstRow(selection) {
|
|
24
|
+
var rect = getSelectionRect(selection);
|
|
25
|
+
if (!rect) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
var table = findTableClosestToPos(selection.$anchorCell);
|
|
29
|
+
if (!table) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
var map = TableMap.get(table.node);
|
|
33
|
+
if (rect.bottom !== map.height || rect.top === 0) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
for (var col = rect.left; col < rect.right; col++) {
|
|
37
|
+
var topCellRect = map.findCell(map.map[col]);
|
|
38
|
+
var isHorizontallyMerged = topCellRect.right - topCellRect.left > 1;
|
|
39
|
+
var bridgesGapAboveSelection = topCellRect.bottom >= rect.top;
|
|
40
|
+
if (!isHorizontallyMerged || !bridgesGapAboveSelection) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Treats a row as fully selected when its first-column area is covered by a vertical merge and the
|
|
49
|
+
* explicit `CellSelection` starts to the right of that merged cell. `CellSelection.isRowSelection()`
|
|
50
|
+
* returns `false` in this case because the selection does not include the merged first-column cell.
|
|
51
|
+
*/
|
|
52
|
+
export var isRowSelectionWithMergedFirstColumn = function isRowSelectionWithMergedFirstColumn(selection) {
|
|
53
|
+
var rect = getSelectionRect(selection);
|
|
54
|
+
if (!rect) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
var table = findTableClosestToPos(selection.$anchorCell);
|
|
58
|
+
if (!table) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
var map = TableMap.get(table.node);
|
|
62
|
+
if (rect.right !== map.width || rect.left === 0) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
for (var row = rect.top; row < rect.bottom; row++) {
|
|
66
|
+
var leftCellRect = map.findCell(map.map[row * map.width]);
|
|
67
|
+
var isVerticallyMerged = leftCellRect.bottom - leftCellRect.top > 1;
|
|
68
|
+
var bridgesGapLeftOfSelection = leftCellRect.right >= rect.left;
|
|
69
|
+
if (!isVerticallyMerged || !bridgesGapLeftOfSelection) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
14
74
|
};
|
|
@@ -215,12 +215,20 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
215
215
|
// return focus to editor so copying table selections whilst still works, i cannot call e.preventDefault in a mousemove event as this stops dragstart events from firing
|
|
216
216
|
// -> this is bad for a11y but is the current standard new copy/paste keyboard shortcuts should be introduced instead
|
|
217
217
|
editorView.focus();
|
|
218
|
-
|
|
218
|
+
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
219
|
+
toggleDragMenu && toggleDragMenu('mouse', e, indexes[0]);
|
|
220
|
+
} else {
|
|
221
|
+
toggleDragMenu && toggleDragMenu('mouse', e);
|
|
222
|
+
}
|
|
219
223
|
},
|
|
220
224
|
onClick: onClick,
|
|
221
225
|
onKeyDown: function onKeyDown(e) {
|
|
222
226
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
223
|
-
|
|
227
|
+
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
228
|
+
toggleDragMenu && toggleDragMenu('keyboard', undefined, indexes[0]);
|
|
229
|
+
} else {
|
|
230
|
+
toggleDragMenu && toggleDragMenu('keyboard');
|
|
231
|
+
}
|
|
224
232
|
}
|
|
225
233
|
}
|
|
226
234
|
}, appearance !== 'placeholder' ?
|
|
@@ -31,6 +31,7 @@ function getRowOptions(index) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
34
|
+
var verticalOffsetCorrection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
34
35
|
var options = {
|
|
35
36
|
alignX: 'end',
|
|
36
37
|
alignY: 'top',
|
|
@@ -41,20 +42,32 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
|
41
42
|
// we should always set the InsertButton on the start,
|
|
42
43
|
// considering the offset from the first column
|
|
43
44
|
onPositionCalculated: function onPositionCalculated(position) {
|
|
45
|
+
// Move the popup upward whether the offset parent provides `top` or `bottom`.
|
|
46
|
+
var verticalCorrection;
|
|
47
|
+
if (verticalOffsetCorrection) {
|
|
48
|
+
if (position.top !== undefined) {
|
|
49
|
+
verticalCorrection = {
|
|
50
|
+
top: position.top - verticalOffsetCorrection
|
|
51
|
+
};
|
|
52
|
+
} else if (position.bottom !== undefined) {
|
|
53
|
+
verticalCorrection = {
|
|
54
|
+
bottom: position.bottom + verticalOffsetCorrection
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
44
58
|
var left = position.left;
|
|
45
59
|
if (!left) {
|
|
46
|
-
|
|
47
|
-
return position;
|
|
60
|
+
return _objectSpread(_objectSpread({}, position), verticalCorrection);
|
|
48
61
|
}
|
|
49
62
|
if (index === 0) {
|
|
50
|
-
return _objectSpread(_objectSpread({}, position), {}, {
|
|
63
|
+
return _objectSpread(_objectSpread(_objectSpread({}, position), verticalCorrection), {}, {
|
|
51
64
|
left: hasNumberedColumns ? HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON : HORIZONTAL_ALIGN_COLUMN_BUTTON
|
|
52
65
|
});
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
// Check if current position is greater than the available container width
|
|
56
69
|
var rect = tableContainer ? tableContainer.getBoundingClientRect() : null;
|
|
57
|
-
return _objectSpread(_objectSpread({}, position), {}, {
|
|
70
|
+
return _objectSpread(_objectSpread(_objectSpread({}, position), verticalCorrection), {}, {
|
|
58
71
|
left: rect && left > rect.width ? rect.width : left
|
|
59
72
|
});
|
|
60
73
|
}
|
|
@@ -71,9 +84,10 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
|
71
84
|
return options;
|
|
72
85
|
}
|
|
73
86
|
function getPopupOptions(direction, index, hasNumberedColumns, tableContainer) {
|
|
87
|
+
var verticalOffsetCorrection = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
74
88
|
switch (direction) {
|
|
75
89
|
case 'column':
|
|
76
|
-
return getColumnOptions(index, tableContainer, hasNumberedColumns);
|
|
90
|
+
return getColumnOptions(index, tableContainer, hasNumberedColumns, verticalOffsetCorrection);
|
|
77
91
|
case 'row':
|
|
78
92
|
return getRowOptions(index);
|
|
79
93
|
default:
|
|
@@ -20,6 +20,7 @@ import { findTable } from '@atlaskit/editor-tables/utils';
|
|
|
20
20
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
21
21
|
import { insertColumnWithAnalytics, insertRowWithAnalytics } from '../../pm-plugins/commands/commands-with-analytics';
|
|
22
22
|
import { checkIfNumberColumnEnabled } from '../../pm-plugins/utils/nodes';
|
|
23
|
+
import { isColumnSelectionWithMergedFirstRow, isRowSelectionWithMergedFirstColumn } from '../../pm-plugins/utils/selection';
|
|
23
24
|
import { TableCssClassName as ClassName } from '../../types';
|
|
24
25
|
import getPopupOptions from './getPopupOptions';
|
|
25
26
|
import { DragAndDropInsertButton } from './InsertButton';
|
|
@@ -73,8 +74,14 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
73
74
|
return null;
|
|
74
75
|
}
|
|
75
76
|
var tr = editorView.state.tr;
|
|
76
|
-
if (
|
|
77
|
-
|
|
77
|
+
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
78
|
+
if (tr.selection instanceof CellSelection && (tr.selection.isColSelection() || tr.selection.isRowSelection() || isColumnSelectionWithMergedFirstRow(tr.selection) || isRowSelectionWithMergedFirstColumn(tr.selection))) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
if (tr.selection instanceof CellSelection && (tr.selection.isColSelection() || tr.selection.isRowSelection())) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
78
85
|
}
|
|
79
86
|
var tablePos = findTable(tr.selection);
|
|
80
87
|
if (!tablePos) {
|
|
@@ -128,6 +135,15 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
128
135
|
var index = type === 'column' ? insertColumnButtonIndex : insertRowButtonIndex;
|
|
129
136
|
var hasNumberedColumns = checkIfNumberColumnEnabled(editorView.state.selection);
|
|
130
137
|
|
|
138
|
+
// If row 0 has a colspan, anchor to a lower row for the real column boundary (X),
|
|
139
|
+
// then move back up to the table top (Y):
|
|
140
|
+
// row 0: [ colspan=2 ]
|
|
141
|
+
// row 1: [ col 1 ][ col 2 ] ← anchor here for X
|
|
142
|
+
// ↑ button should render at row 0/table top
|
|
143
|
+
var verticalOffsetCorrection = 0;
|
|
144
|
+
if (type === 'column' && expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
145
|
+
verticalOffsetCorrection = Math.max(0, targetCellRef.getBoundingClientRect().top - tableRef.getBoundingClientRect().top);
|
|
146
|
+
}
|
|
131
147
|
// Fixed the 'add column button' not visible issue when sticky header is enabled
|
|
132
148
|
// By setting the Popup z-index higher than the sticky header z-index ( common-styles.ts tr.sticky)
|
|
133
149
|
// Only when inserting a column, otherwise set to undefined
|
|
@@ -145,7 +161,7 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
145
161
|
allowOutOfBounds: true
|
|
146
162
|
// Ignored via go/ees005
|
|
147
163
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
148
|
-
}, getPopupOptions(type, index, hasNumberedColumns, tableContainerWrapper), {
|
|
164
|
+
}, getPopupOptions(type, index, hasNumberedColumns, tableContainerWrapper, verticalOffsetCorrection), {
|
|
149
165
|
zIndex: zIndex
|
|
150
166
|
}), /*#__PURE__*/React.createElement(DragAndDropInsertButton, {
|
|
151
167
|
type: type,
|
|
@@ -155,6 +171,20 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
155
171
|
isChromelessEditor: isChromelessEditor
|
|
156
172
|
}));
|
|
157
173
|
}
|
|
174
|
+
|
|
175
|
+
// Finds a row where `columnIndex` has real left/right cell boundaries.
|
|
176
|
+
}, {
|
|
177
|
+
key: "findRowWithUnmergedColumn",
|
|
178
|
+
value: function findRowWithUnmergedColumn(tableMap, columnIndex) {
|
|
179
|
+
for (var row = 0; row < tableMap.height; row++) {
|
|
180
|
+
var pos = tableMap.map[row * tableMap.width + columnIndex];
|
|
181
|
+
var rect = tableMap.findCell(pos);
|
|
182
|
+
if (rect.left === columnIndex && rect.right === columnIndex + 1) {
|
|
183
|
+
return row;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
158
188
|
}, {
|
|
159
189
|
key: "getCellPosition",
|
|
160
190
|
value: function getCellPosition(type, tableNode) {
|
|
@@ -172,6 +202,10 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
172
202
|
if (columnIndex > tableMap.width - 1) {
|
|
173
203
|
return null;
|
|
174
204
|
}
|
|
205
|
+
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
206
|
+
var rowWithRealColumn = this.findRowWithUnmergedColumn(tableMap, columnIndex);
|
|
207
|
+
return rowWithRealColumn === null ? null : tableMap.positionAt(rowWithRealColumn, columnIndex, tableNode);
|
|
208
|
+
}
|
|
175
209
|
return tableMap.positionAt(0, columnIndex, tableNode);
|
|
176
210
|
} else {
|
|
177
211
|
// This condition is to make typescript happy.
|