@atlaskit/editor-plugin-table 5.7.2 → 5.7.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 +9 -0
- package/dist/cjs/nodeviews/TableComponent.js +4 -1
- package/dist/cjs/plugin.js +2 -1
- package/dist/cjs/pm-plugins/main.js +5 -16
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +0 -4
- package/dist/cjs/types.js +0 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +5 -2
- package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +3 -3
- package/dist/cjs/ui/FloatingInsertButton/index.js +1 -1
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +39 -8
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +17 -8
- package/dist/cjs/ui/common-styles.js +1 -1
- package/dist/cjs/utils/decoration.js +48 -34
- package/dist/cjs/utils/dom.js +1 -19
- package/dist/cjs/utils/index.js +0 -6
- package/dist/es2019/nodeviews/TableComponent.js +5 -2
- package/dist/es2019/plugin.js +2 -1
- package/dist/es2019/pm-plugins/main.js +1 -12
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +1 -5
- package/dist/es2019/types.js +0 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +6 -3
- package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +3 -3
- package/dist/es2019/ui/FloatingInsertButton/index.js +2 -2
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +34 -4
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +18 -9
- package/dist/es2019/ui/common-styles.js +6 -1
- package/dist/es2019/utils/decoration.js +47 -33
- package/dist/es2019/utils/dom.js +0 -18
- package/dist/es2019/utils/index.js +1 -1
- package/dist/esm/nodeviews/TableComponent.js +5 -2
- package/dist/esm/plugin.js +2 -1
- package/dist/esm/pm-plugins/main.js +1 -12
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +1 -5
- package/dist/esm/types.js +0 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +6 -3
- package/dist/esm/ui/FloatingInsertButton/InsertButton.js +3 -3
- package/dist/esm/ui/FloatingInsertButton/index.js +2 -2
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +35 -4
- package/dist/esm/ui/TableFloatingColumnControls/index.js +18 -9
- package/dist/esm/ui/common-styles.js +2 -2
- package/dist/esm/utils/decoration.js +48 -34
- package/dist/esm/utils/dom.js +0 -18
- package/dist/esm/utils/index.js +1 -1
- package/dist/types/types.d.ts +0 -1
- package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +3 -1
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -0
- package/dist/types/utils/dom.d.ts +0 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +0 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +3 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -0
- package/dist/types-ts4.5/utils/dom.d.ts +0 -1
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/package.json +6 -6
- package/src/nodeviews/TableComponent.tsx +7 -2
- package/src/plugin.tsx +1 -0
- package/src/pm-plugins/main.ts +0 -18
- package/src/pm-plugins/table-resizing/event-handlers.ts +1 -8
- package/src/types.ts +0 -2
- package/src/ui/FloatingDragMenu/index.tsx +14 -2
- package/src/ui/FloatingInsertButton/InsertButton.tsx +6 -2
- package/src/ui/FloatingInsertButton/index.tsx +4 -2
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +48 -3
- package/src/ui/TableFloatingColumnControls/index.tsx +23 -11
- package/src/ui/common-styles.ts +6 -0
- package/src/utils/decoration.ts +41 -28
- package/src/utils/dom.ts +0 -23
- package/src/utils/index.ts +0 -1
|
@@ -2,7 +2,7 @@ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, is
|
|
|
2
2
|
export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine, } from './decoration';
|
|
3
3
|
export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow, } from './nodes';
|
|
4
4
|
export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, } from './paste';
|
|
5
|
-
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement,
|
|
5
|
+
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint, } from './dom';
|
|
6
6
|
export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, getColumnIndexMappedToColumnIndexInFirstRow, } from './column-controls';
|
|
7
7
|
export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow, } from './row-controls';
|
|
8
8
|
export type { RowParams } from './row-controls';
|
|
@@ -322,7 +322,6 @@ export declare const TableCssClassName: {
|
|
|
322
322
|
RESIZING_PLUGIN: string;
|
|
323
323
|
RESIZE_CURSOR: string;
|
|
324
324
|
IS_RESIZING: string;
|
|
325
|
-
RESIZE_HANDLE: string;
|
|
326
325
|
RESIZE_HANDLE_DECORATION: string;
|
|
327
326
|
CONTEXTUAL_SUBMENU: string;
|
|
328
327
|
CONTEXTUAL_MENU_BUTTON_WRAP: string;
|
|
@@ -3,6 +3,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
6
7
|
import type { TableDirection } from '../../types';
|
|
7
8
|
export interface Props {
|
|
8
9
|
editorView: EditorView;
|
|
@@ -18,9 +19,10 @@ export interface Props {
|
|
|
18
19
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
19
20
|
canDrag?: boolean;
|
|
20
21
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
22
|
+
stickyHeaders?: RowStickyState;
|
|
21
23
|
}
|
|
22
24
|
declare const FloatingDragMenu: {
|
|
23
|
-
({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, editorAnalyticsAPI, }: Props): JSX.Element | null;
|
|
25
|
+
({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, editorAnalyticsAPI, stickyHeaders, }: Props): JSX.Element | null;
|
|
24
26
|
displayName: string;
|
|
25
27
|
};
|
|
26
28
|
export default FloatingDragMenu;
|
|
@@ -15,6 +15,8 @@ export interface ColumnControlsProps {
|
|
|
15
15
|
hasHeaderColumn?: boolean;
|
|
16
16
|
isTableHovered?: boolean;
|
|
17
17
|
canDrag?: boolean;
|
|
18
|
+
tableContainerWidth?: number;
|
|
19
|
+
isNumberColumnEnabled?: boolean;
|
|
18
20
|
}
|
|
19
|
-
export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, canDrag, }: ColumnControlsProps) => JSX.Element;
|
|
21
|
+
export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, canDrag, tableContainerWidth, isNumberColumnEnabled, }: ColumnControlsProps) => JSX.Element;
|
|
20
22
|
export default ColumnControls;
|
|
@@ -23,6 +23,8 @@ export interface Props {
|
|
|
23
23
|
stickyHeader?: RowStickyState;
|
|
24
24
|
isTableHovered?: boolean;
|
|
25
25
|
canDrag?: boolean;
|
|
26
|
+
tableContainerWidth?: number;
|
|
27
|
+
isNumberColumnEnabled?: boolean;
|
|
26
28
|
}
|
|
27
29
|
export declare const TableFloatingColumnControls: React.FC<Props>;
|
|
28
30
|
export default TableFloatingColumnControls;
|
|
@@ -18,7 +18,6 @@ export declare const isDragColumnFloatingInsertDot: (node: HTMLElement | null) =
|
|
|
18
18
|
export declare const isDragCornerButton: (node: HTMLElement | null) => boolean;
|
|
19
19
|
export declare const getMousePositionHorizontalRelativeByElement: (mouseEvent: MouseEvent, elementContentRects?: ElementContentRects, gapInPixels?: number, isDragAndDropEnabled?: boolean) => 'left' | 'right' | null;
|
|
20
20
|
export declare const getMousePositionVerticalRelativeByElement: (mouseEvent: MouseEvent) => 'top' | 'bottom' | null;
|
|
21
|
-
export declare const updateResizeHandles: (tableRef?: HTMLElement) => void;
|
|
22
21
|
export declare const hasResizeHandler: ({ columnEndIndexTarget, target, }: {
|
|
23
22
|
columnEndIndexTarget: number;
|
|
24
23
|
target: HTMLElement;
|
|
@@ -2,7 +2,7 @@ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, is
|
|
|
2
2
|
export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine, } from './decoration';
|
|
3
3
|
export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow, } from './nodes';
|
|
4
4
|
export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, } from './paste';
|
|
5
|
-
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement,
|
|
5
|
+
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint, } from './dom';
|
|
6
6
|
export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, getColumnIndexMappedToColumnIndexInFirstRow, } from './column-controls';
|
|
7
7
|
export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow, } from './row-controls';
|
|
8
8
|
export type { RowParams } from './row-controls';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "5.7.
|
|
3
|
+
"version": "5.7.3",
|
|
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
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^35.2.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.0.10",
|
|
33
|
-
"@atlaskit/editor-common": "^76.
|
|
33
|
+
"@atlaskit/editor-common": "^76.30.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.5.2",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
36
36
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
@@ -119,9 +119,6 @@
|
|
|
119
119
|
"platform.editor.resizing-table-height-improvement": {
|
|
120
120
|
"type": "boolean"
|
|
121
121
|
},
|
|
122
|
-
"platform.editor.table-remove-update-resize-handles_djvab": {
|
|
123
|
-
"type": "boolean"
|
|
124
|
-
},
|
|
125
122
|
"platform.editor.table.increase-shadow-visibility_lh89r": {
|
|
126
123
|
"type": "boolean"
|
|
127
124
|
},
|
|
@@ -148,6 +145,9 @@
|
|
|
148
145
|
},
|
|
149
146
|
"platform.editor.menu.group-items": {
|
|
150
147
|
"type": "boolean"
|
|
148
|
+
},
|
|
149
|
+
"platform.editor.table.in-danger-hover-merged-cells-fix": {
|
|
150
|
+
"type": "boolean"
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
}
|
|
153
|
+
}
|
|
@@ -13,7 +13,10 @@ import {
|
|
|
13
13
|
} from '@atlaskit/editor-common/analytics';
|
|
14
14
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
15
15
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
getParentNodeWidth,
|
|
18
|
+
getTableContainerWidth,
|
|
19
|
+
} from '@atlaskit/editor-common/node-width';
|
|
17
20
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
18
21
|
import type {
|
|
19
22
|
EditorContainerWidth,
|
|
@@ -510,7 +513,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
510
513
|
stickyHeader={this.state.stickyHeader}
|
|
511
514
|
/>
|
|
512
515
|
);
|
|
513
|
-
|
|
516
|
+
const tableContainerWidth = getTableContainerWidth(node);
|
|
514
517
|
const colControls = isDragAndDropEnabled ? (
|
|
515
518
|
<TableFloatingColumnControls
|
|
516
519
|
editorView={view}
|
|
@@ -530,6 +533,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
530
533
|
stickyHeader={this.state.stickyHeader}
|
|
531
534
|
canDrag={canDrag}
|
|
532
535
|
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
536
|
+
tableContainerWidth={tableContainerWidth}
|
|
537
|
+
isNumberColumnEnabled={node.attrs.isNumberColumnEnabled}
|
|
533
538
|
/>
|
|
534
539
|
) : null;
|
|
535
540
|
|
package/src/plugin.tsx
CHANGED
|
@@ -515,6 +515,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
515
515
|
canDrag={dragAndDropState?.canDrag}
|
|
516
516
|
getEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
517
517
|
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
518
|
+
stickyHeaders={stickyHeader}
|
|
518
519
|
/>
|
|
519
520
|
)}
|
|
520
521
|
{allowControls && !isDragAndDropEnabled && !isResizing && (
|
package/src/pm-plugins/main.ts
CHANGED
|
@@ -37,8 +37,6 @@ import {
|
|
|
37
37
|
findParentNodeOfType,
|
|
38
38
|
} from '@atlaskit/editor-prosemirror/utils';
|
|
39
39
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
40
|
-
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
41
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
42
40
|
|
|
43
41
|
import {
|
|
44
42
|
addBoldInEmptyHeaderCells,
|
|
@@ -83,7 +81,6 @@ import {
|
|
|
83
81
|
transformSliceToCorrectEmptyTableCells,
|
|
84
82
|
transformSliceToFixHardBreakProblemOnCopyFromCell,
|
|
85
83
|
transformSliceToRemoveOpenTable,
|
|
86
|
-
updateResizeHandles,
|
|
87
84
|
} from '../utils';
|
|
88
85
|
import { isHeaderRowRequired } from '../utils/paste';
|
|
89
86
|
|
|
@@ -209,7 +206,6 @@ export const createPlugin = (
|
|
|
209
206
|
const { selection } = state;
|
|
210
207
|
const pluginState = getPluginState(state);
|
|
211
208
|
let tableRef: HTMLTableElement | undefined;
|
|
212
|
-
let tableNode;
|
|
213
209
|
if (pluginState.editorHasFocus) {
|
|
214
210
|
const parent = findParentDomRefOfType(
|
|
215
211
|
state.schema.nodes.table,
|
|
@@ -221,26 +217,12 @@ export const createPlugin = (
|
|
|
221
217
|
'table',
|
|
222
218
|
) || undefined;
|
|
223
219
|
}
|
|
224
|
-
|
|
225
|
-
tableNode = findTable(state.selection);
|
|
226
220
|
}
|
|
227
221
|
|
|
228
222
|
if (pluginState.tableRef !== tableRef) {
|
|
229
223
|
setTableRef(tableRef)(state, dispatch);
|
|
230
224
|
}
|
|
231
225
|
|
|
232
|
-
// Removes updateResizeHandles
|
|
233
|
-
if (
|
|
234
|
-
getBooleanFF(
|
|
235
|
-
'platform.editor.table-remove-update-resize-handles_djvab',
|
|
236
|
-
)
|
|
237
|
-
) {
|
|
238
|
-
} else {
|
|
239
|
-
if (pluginState.tableNode !== tableNode) {
|
|
240
|
-
updateResizeHandles(tableRef);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
226
|
if (pluginState.editorHasFocus && pluginState.tableRef) {
|
|
245
227
|
const { $cursor } = state.selection as TextSelection;
|
|
246
228
|
if ($cursor) {
|
|
@@ -20,7 +20,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
|
20
20
|
|
|
21
21
|
import { updateResizeHandleDecorations } from '../../commands/misc';
|
|
22
22
|
import { updateColumnWidths } from '../../transforms';
|
|
23
|
-
import { getSelectedColumnIndexes
|
|
23
|
+
import { getSelectedColumnIndexes } from '../../utils';
|
|
24
24
|
import { META_KEYS } from '../table-analytics';
|
|
25
25
|
|
|
26
26
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
@@ -228,13 +228,6 @@ export const handleMouseDown = (
|
|
|
228
228
|
resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom);
|
|
229
229
|
|
|
230
230
|
updateControls()(state);
|
|
231
|
-
// Remove updateResizeHandles
|
|
232
|
-
if (
|
|
233
|
-
getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')
|
|
234
|
-
) {
|
|
235
|
-
} else {
|
|
236
|
-
updateResizeHandles(dom);
|
|
237
|
-
}
|
|
238
231
|
}
|
|
239
232
|
|
|
240
233
|
window.addEventListener('mouseup', finish);
|
package/src/types.ts
CHANGED
|
@@ -359,8 +359,6 @@ export const TableCssClassName = {
|
|
|
359
359
|
RESIZE_CURSOR: `${tablePrefixSelector}-resize-cursor`,
|
|
360
360
|
IS_RESIZING: `${tablePrefixSelector}-is-resizing`,
|
|
361
361
|
|
|
362
|
-
// Resize handle is going to be removed together with updateResizeHandles - table's utility function
|
|
363
|
-
RESIZE_HANDLE: `${tablePrefixSelector}-resize-handle`,
|
|
364
362
|
RESIZE_HANDLE_DECORATION: `${tablePrefixSelector}-resize-decoration`,
|
|
365
363
|
|
|
366
364
|
CONTEXTUAL_SUBMENU: `${tablePrefixSelector}-contextual-submenu`,
|
|
@@ -5,9 +5,13 @@ import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
|
5
5
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
6
6
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
7
7
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
akEditorFloatingDialogZIndex,
|
|
10
|
+
akEditorFloatingOverlapPanelZIndex,
|
|
11
|
+
} from '@atlaskit/editor-shared-styles';
|
|
9
12
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
10
13
|
|
|
14
|
+
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
11
15
|
import type { TableDirection } from '../../types';
|
|
12
16
|
import { dragMenuDropdownWidth } from '../consts';
|
|
13
17
|
|
|
@@ -27,6 +31,7 @@ export interface Props {
|
|
|
27
31
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
28
32
|
canDrag?: boolean;
|
|
29
33
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
34
|
+
stickyHeaders?: RowStickyState;
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
const FloatingDragMenu = ({
|
|
@@ -42,6 +47,7 @@ const FloatingDragMenu = ({
|
|
|
42
47
|
getEditorContainerWidth,
|
|
43
48
|
canDrag,
|
|
44
49
|
editorAnalyticsAPI,
|
|
50
|
+
stickyHeaders,
|
|
45
51
|
}: Props) => {
|
|
46
52
|
if (
|
|
47
53
|
!isOpen ||
|
|
@@ -50,6 +56,7 @@ const FloatingDragMenu = ({
|
|
|
50
56
|
) {
|
|
51
57
|
return null;
|
|
52
58
|
}
|
|
59
|
+
const inStickyMode = stickyHeaders?.sticky;
|
|
53
60
|
|
|
54
61
|
const targetHandleRef =
|
|
55
62
|
direction === 'row'
|
|
@@ -77,7 +84,12 @@ const FloatingDragMenu = ({
|
|
|
77
84
|
fitWidth={dragMenuDropdownWidth}
|
|
78
85
|
// z-index value below is to ensure that this menu is above other floating menu
|
|
79
86
|
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
80
|
-
|
|
87
|
+
// In sticky mode, we want to show the menu above the sticky header
|
|
88
|
+
zIndex={
|
|
89
|
+
inStickyMode
|
|
90
|
+
? akEditorFloatingDialogZIndex
|
|
91
|
+
: akEditorFloatingOverlapPanelZIndex
|
|
92
|
+
}
|
|
81
93
|
forcePlacement={true}
|
|
82
94
|
offset={offset}
|
|
83
95
|
stick={true}
|
|
@@ -32,6 +32,7 @@ export interface ButtonProps {
|
|
|
32
32
|
const getInsertLineHeight = (
|
|
33
33
|
tableRef: HTMLElement,
|
|
34
34
|
hasStickyHeaders: boolean,
|
|
35
|
+
isDragAndDropEnabled?: boolean,
|
|
35
36
|
) => {
|
|
36
37
|
// The line gets height 100% from the table,
|
|
37
38
|
// but since we have an overflow on the left,
|
|
@@ -39,7 +40,9 @@ const getInsertLineHeight = (
|
|
|
39
40
|
const LINE_OFFSET = 3;
|
|
40
41
|
|
|
41
42
|
const ADDITIONAL_HEIGHT = hasStickyHeaders
|
|
42
|
-
? tableRef.getBoundingClientRect().top -
|
|
43
|
+
? tableRef.getBoundingClientRect().top -
|
|
44
|
+
tableMarginTop * (isDragAndDropEnabled ? 3 : 4) -
|
|
45
|
+
LINE_OFFSET
|
|
43
46
|
: tableToolbarSize + LINE_OFFSET;
|
|
44
47
|
return tableRef.offsetHeight + ADDITIONAL_HEIGHT;
|
|
45
48
|
};
|
|
@@ -140,7 +143,8 @@ export const InsertButtonForDragAndDrop = ({
|
|
|
140
143
|
left: token('space.150', '12px'),
|
|
141
144
|
}
|
|
142
145
|
: {
|
|
143
|
-
height:
|
|
146
|
+
height:
|
|
147
|
+
getInsertLineHeight(tableRef, hasStickyHeaders, true) - 8,
|
|
144
148
|
top: '-3px',
|
|
145
149
|
}
|
|
146
150
|
}
|
|
@@ -21,7 +21,7 @@ import { closestElement } from '@atlaskit/editor-common/utils';
|
|
|
21
21
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
22
22
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
23
23
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
24
|
-
import {
|
|
24
|
+
import { akEditorTableInsertButtonOnStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
|
|
25
25
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
26
26
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
27
27
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
@@ -192,7 +192,9 @@ export class FloatingInsertButton extends React.Component<
|
|
|
192
192
|
// Only when inserting a column, otherwise set to undefined
|
|
193
193
|
// Need to set z-index in the Popup, set z-index in the <InsertButton /> will not work
|
|
194
194
|
const zIndex: number | undefined =
|
|
195
|
-
type === 'column'
|
|
195
|
+
type === 'column'
|
|
196
|
+
? akEditorTableInsertButtonOnStickyHeaderZIndex
|
|
197
|
+
: undefined;
|
|
196
198
|
|
|
197
199
|
return (
|
|
198
200
|
<Popup
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
2
|
import type { MouseEvent } from 'react';
|
|
3
|
-
import React, { useCallback, useMemo } from 'react';
|
|
3
|
+
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
4
4
|
|
|
5
5
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
6
|
+
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
6
7
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
8
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
+
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
8
10
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
9
11
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
10
12
|
|
|
@@ -35,6 +37,8 @@ export interface ColumnControlsProps {
|
|
|
35
37
|
hasHeaderColumn?: boolean;
|
|
36
38
|
isTableHovered?: boolean;
|
|
37
39
|
canDrag?: boolean;
|
|
40
|
+
tableContainerWidth?: number;
|
|
41
|
+
isNumberColumnEnabled?: boolean;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
const getSelectedColumns = (selection: Selection) => {
|
|
@@ -62,10 +66,18 @@ export const ColumnControls = ({
|
|
|
62
66
|
hasHeaderColumn,
|
|
63
67
|
isTableHovered,
|
|
64
68
|
canDrag,
|
|
69
|
+
tableContainerWidth,
|
|
70
|
+
isNumberColumnEnabled,
|
|
65
71
|
}: ColumnControlsProps) => {
|
|
72
|
+
const columnControlsRef = useRef<HTMLDivElement>(null);
|
|
66
73
|
const widths =
|
|
67
|
-
colWidths
|
|
68
|
-
|
|
74
|
+
colWidths
|
|
75
|
+
?.map((width) =>
|
|
76
|
+
// when there is sticky header, a `margin-right: -1px` applied to `tr.sticky th` so it causes colWidths to be 1px wider
|
|
77
|
+
// we need to reduce the width by 1px to avoid misalignment of column controls.
|
|
78
|
+
width ? (stickyTop ? `${width - 2}px` : `${width - 1}px`) : '0px',
|
|
79
|
+
)
|
|
80
|
+
.join(' ') ?? '0px';
|
|
69
81
|
// TODO: reusing getRowsParams here because it's generic enough to work for columns -> rename
|
|
70
82
|
const columnParams = getRowsParams(colWidths ?? []);
|
|
71
83
|
const colIndex = hoveredCell?.colIndex;
|
|
@@ -153,6 +165,32 @@ export const ColumnControls = ({
|
|
|
153
165
|
const colIndexes = useMemo(() => {
|
|
154
166
|
return [colIndex!];
|
|
155
167
|
}, [colIndex]);
|
|
168
|
+
const tableWrapper = closestElement(
|
|
169
|
+
tableRef,
|
|
170
|
+
`.${ClassName.TABLE_NODE_WRAPPER}`,
|
|
171
|
+
);
|
|
172
|
+
const handleScroll = useCallback(
|
|
173
|
+
(event?: Event) => {
|
|
174
|
+
if (stickyTop) {
|
|
175
|
+
if (columnControlsRef && columnControlsRef.current) {
|
|
176
|
+
columnControlsRef.current.scrollLeft = tableWrapper?.scrollLeft ?? 0;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
[stickyTop, tableWrapper],
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
handleScroll();
|
|
185
|
+
}, [handleScroll]);
|
|
186
|
+
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
tableWrapper?.addEventListener('scroll', handleScroll);
|
|
189
|
+
|
|
190
|
+
return () => {
|
|
191
|
+
tableWrapper?.removeEventListener('scroll', handleScroll);
|
|
192
|
+
};
|
|
193
|
+
}, [tableWrapper, handleScroll]);
|
|
156
194
|
|
|
157
195
|
const generateHandleByType = (type: HandleTypes): JSX.Element | null => {
|
|
158
196
|
if (!hoveredCell || !colWidths?.length) {
|
|
@@ -260,17 +298,24 @@ export const ColumnControls = ({
|
|
|
260
298
|
: sortedHandles.reverse();
|
|
261
299
|
};
|
|
262
300
|
|
|
301
|
+
const containerWidth =
|
|
302
|
+
isNumberColumnEnabled && tableContainerWidth
|
|
303
|
+
? tableContainerWidth - akEditorTableNumberColumnWidth
|
|
304
|
+
: tableContainerWidth;
|
|
263
305
|
return (
|
|
264
306
|
<div
|
|
265
307
|
className={ClassName.DRAG_COLUMN_CONTROLS}
|
|
266
308
|
onMouseMove={handleMouseMove}
|
|
267
309
|
>
|
|
268
310
|
<div
|
|
311
|
+
ref={columnControlsRef}
|
|
269
312
|
className={ClassName.DRAG_COLUMN_CONTROLS_INNER}
|
|
270
313
|
data-testid="table-floating-column-controls"
|
|
271
314
|
style={{
|
|
272
315
|
gridTemplateColumns: widths,
|
|
273
316
|
marginTop,
|
|
317
|
+
width: stickyTop ? containerWidth : undefined,
|
|
318
|
+
overflowX: stickyTop ? 'hidden' : 'visible',
|
|
274
319
|
}}
|
|
275
320
|
>
|
|
276
321
|
{!isResizing &&
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
4
4
|
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
@@ -36,6 +36,8 @@ export interface Props {
|
|
|
36
36
|
stickyHeader?: RowStickyState;
|
|
37
37
|
isTableHovered?: boolean;
|
|
38
38
|
canDrag?: boolean;
|
|
39
|
+
tableContainerWidth?: number;
|
|
40
|
+
isNumberColumnEnabled?: boolean;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export const TableFloatingColumnControls: React.FC<Props> = ({
|
|
@@ -51,15 +53,22 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
|
|
|
51
53
|
isInDanger,
|
|
52
54
|
isTableHovered,
|
|
53
55
|
canDrag,
|
|
56
|
+
tableContainerWidth,
|
|
57
|
+
isNumberColumnEnabled,
|
|
54
58
|
}) => {
|
|
55
59
|
const [tableRect, setTableRect] = useState<{ width: number; height: number }>(
|
|
56
60
|
{ width: 0, height: 0 },
|
|
57
61
|
);
|
|
58
|
-
|
|
59
62
|
const [hasDropTargets, setHasDropTargets] = useState(false);
|
|
63
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
64
|
+
|
|
60
65
|
const node = getNode();
|
|
61
66
|
const currentNodeLocalId = node?.attrs.localId;
|
|
62
67
|
const hasHeaderColumn = containsHeaderColumn(node);
|
|
68
|
+
const stickyTop =
|
|
69
|
+
stickyHeader && stickyHeader.sticky && hasHeaderRow
|
|
70
|
+
? stickyHeader.top
|
|
71
|
+
: undefined;
|
|
63
72
|
|
|
64
73
|
useEffect(() => {
|
|
65
74
|
if (tableRef && window?.ResizeObserver) {
|
|
@@ -118,19 +127,20 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
|
|
|
118
127
|
|
|
119
128
|
const colWidths = getColumnsWidths(editorView);
|
|
120
129
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
?
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
if (stickyTop) {
|
|
131
|
+
const headerRowHeight =
|
|
132
|
+
hasHeaderRow && stickyTop !== undefined ? rowHeights?.[0] ?? 0 : 0;
|
|
133
|
+
containerRef?.current?.style.setProperty(
|
|
134
|
+
'top',
|
|
135
|
+
`${stickyTop! - headerRowHeight + 33}px`, // 33px is padding and margin applied on tr.sticky
|
|
136
|
+
);
|
|
137
|
+
} else {
|
|
138
|
+
containerRef?.current?.style.removeProperty('top');
|
|
130
139
|
}
|
|
131
140
|
|
|
132
141
|
return (
|
|
133
142
|
<div
|
|
143
|
+
ref={containerRef}
|
|
134
144
|
className={ClassName.DRAG_COLUMN_CONTROLS_WRAPPER}
|
|
135
145
|
data-testid="table-floating-column-controls-wrapper"
|
|
136
146
|
>
|
|
@@ -148,6 +158,8 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
|
|
|
148
158
|
colWidths={colWidths}
|
|
149
159
|
hasHeaderColumn={hasHeaderColumn}
|
|
150
160
|
canDrag={canDrag}
|
|
161
|
+
tableContainerWidth={tableContainerWidth}
|
|
162
|
+
isNumberColumnEnabled={isNumberColumnEnabled}
|
|
151
163
|
/>
|
|
152
164
|
{hasDropTargets && (
|
|
153
165
|
<ColumnDropTargets
|
package/src/ui/common-styles.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
8
8
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import {
|
|
10
|
+
akEditorFloatingDialogZIndex,
|
|
10
11
|
akEditorSelectedNodeClassName,
|
|
11
12
|
akEditorSmallZIndex,
|
|
12
13
|
akEditorStickyHeaderZIndex,
|
|
@@ -1049,6 +1050,11 @@ export const tableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
1049
1050
|
top: ${tableMarginTop}px;
|
|
1050
1051
|
}
|
|
1051
1052
|
|
|
1053
|
+
.${ClassName.TABLE_STICKY} .${ClassName.DRAG_COLUMN_CONTROLS_WRAPPER} {
|
|
1054
|
+
position: fixed;
|
|
1055
|
+
z-index: ${akEditorFloatingDialogZIndex};
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1052
1058
|
${tableWrapperStyles()}
|
|
1053
1059
|
}
|
|
1054
1060
|
|
package/src/utils/decoration.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
getCellsInRow,
|
|
23
23
|
getSelectionRect,
|
|
24
24
|
} from '@atlaskit/editor-tables/utils';
|
|
25
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
25
26
|
|
|
26
27
|
import type { Cell, CellColumnPositioning } from '../types';
|
|
27
28
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
@@ -101,34 +102,46 @@ export const createControlsHoverDecoration = (
|
|
|
101
102
|
// So If the table cells are in danger we want to create a "rectangle" selection
|
|
102
103
|
// to match the "clicked" selection
|
|
103
104
|
|
|
104
|
-
if (danger) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
105
|
+
if (getBooleanFF('platform.editor.table.in-danger-hover-merged-cells-fix')) {
|
|
106
|
+
if (danger && type !== 'table') {
|
|
107
|
+
const { selection } = tr;
|
|
108
|
+
const table = findTable(selection);
|
|
109
|
+
const rect = getSelectionRect(selection);
|
|
110
|
+
|
|
111
|
+
if (table && rect) {
|
|
112
|
+
updatedCells = map.cellsInRect(rect).map((x) => x + table.start);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
if (danger) {
|
|
117
|
+
// Find the bounding rectangle of all the given cells, also considering
|
|
118
|
+
// merged cells.
|
|
119
|
+
const { recLeft, recTop, recRight, recBottom } = cells.reduce(
|
|
120
|
+
(acc, cell) => {
|
|
121
|
+
const { left, right, bottom, top } = map.findCell(
|
|
122
|
+
cell.pos - table.start,
|
|
123
|
+
);
|
|
124
|
+
// Finding the bounding rect requires finding the min left and top positions,
|
|
125
|
+
// and the max right and bottom positions of the cells
|
|
126
|
+
return {
|
|
127
|
+
recLeft: Math.min(acc.recLeft, left),
|
|
128
|
+
recTop: Math.min(acc.recTop, top),
|
|
129
|
+
recRight: Math.max(acc.recRight, right),
|
|
130
|
+
recBottom: Math.max(acc.recBottom, bottom),
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
// +-Infinity as initialisation vars which will always be overwritten
|
|
134
|
+
// by smaller/larger values respectively
|
|
135
|
+
{
|
|
136
|
+
recLeft: Infinity,
|
|
137
|
+
recTop: Infinity,
|
|
138
|
+
recRight: -Infinity,
|
|
139
|
+
recBottom: -Infinity,
|
|
140
|
+
},
|
|
141
|
+
);
|
|
142
|
+
const rect = new Rect(recLeft, recTop, recRight, recBottom);
|
|
143
|
+
updatedCells = map.cellsInRect(rect).map((x) => x + table.start);
|
|
144
|
+
}
|
|
132
145
|
}
|
|
133
146
|
|
|
134
147
|
return updatedCells.map((pos) => {
|