@atlaskit/editor-plugin-table 5.3.13 → 5.3.14
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/plugins/table/event-handlers.js +6 -3
- package/dist/cjs/plugins/table/index.js +4 -3
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +11 -0
- package/dist/cjs/plugins/table/types.js +9 -2
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +5 -3
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +57 -9
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +9 -7
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +13 -4
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +44 -5
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +6 -4
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +35 -13
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +2 -0
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/ui-styles.js +27 -24
- package/dist/cjs/plugins/table/utils/dom.js +12 -4
- package/dist/cjs/plugins/table/utils/index.js +12 -0
- package/dist/es2019/plugins/table/event-handlers.js +5 -4
- package/dist/es2019/plugins/table/index.js +4 -3
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +12 -0
- package/dist/es2019/plugins/table/types.js +9 -2
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +5 -3
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +58 -7
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +9 -7
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +10 -4
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +46 -6
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +7 -5
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +35 -14
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +2 -0
- package/dist/es2019/plugins/table/ui/common-styles.js +51 -3
- package/dist/es2019/plugins/table/ui/ui-styles.js +23 -1
- package/dist/es2019/plugins/table/utils/dom.js +5 -1
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/event-handlers.js +7 -4
- package/dist/esm/plugins/table/index.js +4 -3
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +11 -0
- package/dist/esm/plugins/table/types.js +9 -2
- package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +5 -3
- package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +56 -8
- package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +9 -7
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +10 -4
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +45 -6
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +7 -5
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +36 -14
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +2 -0
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/ui/ui-styles.js +26 -23
- package/dist/esm/plugins/table/utils/dom.js +11 -3
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/types.d.ts +9 -2
- package/dist/types/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +5 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +1 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/index.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +2 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types/plugins/table/utils/dom.d.ts +4 -1
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +9 -2
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +5 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +4 -1
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +2 -1
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +40 -194
- package/src/__tests__/unit/ui/RowDragControls.tsx +9 -11
- package/src/plugins/table/event-handlers.ts +15 -3
- package/src/plugins/table/index.tsx +3 -2
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +2 -9
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -3
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +9 -0
- package/src/plugins/table/types.ts +12 -2
- package/src/plugins/table/ui/FloatingDragMenu/index.tsx +10 -3
- package/src/plugins/table/ui/FloatingInsertButton/InsertButton.tsx +82 -8
- package/src/plugins/table/ui/FloatingInsertButton/getPopupOptions.ts +28 -5
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +19 -7
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +47 -3
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +11 -4
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +49 -18
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +2 -0
- package/src/plugins/table/ui/common-styles.ts +57 -2
- package/src/plugins/table/ui/ui-styles.ts +27 -1
- package/src/plugins/table/utils/dom.ts +11 -4
- package/src/plugins/table/utils/index.ts +2 -0
- package/tsconfig.app.json +3 -0
|
@@ -7,7 +7,7 @@ import { B300, N0, N20A, N300, N40A, R500 } from '@atlaskit/theme/colors';
|
|
|
7
7
|
import { fontSize } from '@atlaskit/theme/constants';
|
|
8
8
|
import { TableCssClassName as ClassName } from '../types';
|
|
9
9
|
import { columnControlsDecorationHeight, resizeHandlerAreaWidth, resizeLineWidth, rowControlsZIndex, stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableBorderColor, tableBorderDeleteColor, tableBorderRadiusSize, tableBorderSelectedColor, tableCellBackgroundColor, tableCellDeleteColor, tableCellSelectedColor, tableControlsSpacing, tableHeaderCellBackgroundColor, tableInsertColumnButtonSize, tableOverflowShadowWidth, tablePadding, tableScrollbarOffset, tableTextColor, tableToolbarDeleteColor, tableToolbarSelectedColor, tableToolbarSize } from './consts';
|
|
10
|
-
import { columnControlsDecoration, columnControlsLineMarker, DeleteButton, floatingColumnControls, HeaderButton, HeaderButtonDanger, HeaderButtonHover, hoveredCell, hoveredDeleteButton, hoveredWarningCell, insertColumnButtonWrapper, insertLine, InsertMarker, insertRowButtonWrapper, OverflowShadow, resizeHandle, rowControlsWrapperDotStyle } from './ui-styles';
|
|
10
|
+
import { columnControlsDecoration, columnControlsLineMarker, DeleteButton, dragInsertButtonWrapper, floatingColumnControls, HeaderButton, HeaderButtonDanger, HeaderButtonHover, hoveredCell, hoveredDeleteButton, hoveredWarningCell, insertColumnButtonWrapper, insertLine, InsertMarker, insertRowButtonWrapper, OverflowShadow, resizeHandle, rowControlsWrapperDotStyle } from './ui-styles';
|
|
11
11
|
const cornerControlHeight = tableToolbarSize + 1;
|
|
12
12
|
|
|
13
13
|
/*
|
|
@@ -270,6 +270,8 @@ export const tableStyles = props => {
|
|
|
270
270
|
${insertRowButtonWrapper(props)}
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
+
${dragInsertButtonWrapper(props)}
|
|
274
|
+
|
|
273
275
|
/* Delete button */
|
|
274
276
|
${DeleteButton(props)}
|
|
275
277
|
/* Ends Delete button */
|
|
@@ -602,12 +604,58 @@ export const tableStyles = props => {
|
|
|
602
604
|
`)}
|
|
603
605
|
}
|
|
604
606
|
|
|
605
|
-
.${ClassName.
|
|
607
|
+
.${ClassName.DRAG_ROW_CONTROLS} {
|
|
606
608
|
display: grid;
|
|
607
609
|
align-items: center;
|
|
608
610
|
position: absolute;
|
|
609
611
|
left: -4px;
|
|
610
612
|
z-index: ${akEditorUnitZIndex};
|
|
613
|
+
|
|
614
|
+
.${ClassName.DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER} {
|
|
615
|
+
align-self: end;
|
|
616
|
+
position: absolute;
|
|
617
|
+
height: 100%;
|
|
618
|
+
width: 24px;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
.${ClassName.DRAG_ROW_FLOATING_INSERT_DOT} {
|
|
622
|
+
position: absolute;
|
|
623
|
+
bottom: -3px;
|
|
624
|
+
left: 6px;
|
|
625
|
+
background-color: ${"var(--ds-background-accent-gray-subtler, #C1C7D0)"};
|
|
626
|
+
height: 4px;
|
|
627
|
+
width: 4px;
|
|
628
|
+
border-radius: 50%;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
.${ClassName.DRAG_COLUMN_CONTROLS} {
|
|
633
|
+
.${ClassName.COLUMN_CONTROLS_INNER} {
|
|
634
|
+
height: 24px;
|
|
635
|
+
position: absolute;
|
|
636
|
+
top: ${"var(--ds-space-negative-150, -12px)"};
|
|
637
|
+
z-index: ${akEditorUnitZIndex};
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
.${ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER} {
|
|
641
|
+
position: absolute;
|
|
642
|
+
height: 24px;
|
|
643
|
+
width: 100%;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
.${ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT} {
|
|
647
|
+
background-color: ${"var(--ds-background-accent-gray-subtler, #C1C7D0)"};
|
|
648
|
+
height: 4px;
|
|
649
|
+
width: 4px;
|
|
650
|
+
border-radius: 50%;
|
|
651
|
+
position: absolute;
|
|
652
|
+
right: -2px;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
.${ClassName.CONTROLS_FLOATING_BUTTON_ROW}
|
|
657
|
+
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON_INNER} {
|
|
658
|
+
bottom: -1px;
|
|
611
659
|
}
|
|
612
660
|
|
|
613
661
|
.${ClassName.DRAG_HANDLE_BUTTON_CONTAINER} {
|
|
@@ -621,10 +669,10 @@ export const tableStyles = props => {
|
|
|
621
669
|
display: flex;
|
|
622
670
|
justify-content: center;
|
|
623
671
|
align-items: center;
|
|
672
|
+
outline: none !important;
|
|
624
673
|
|
|
625
674
|
svg {
|
|
626
675
|
rect {
|
|
627
|
-
//
|
|
628
676
|
fill: ${"var(--ds-background-accent-gray-subtlest, #F1F2F4)"};
|
|
629
677
|
}
|
|
630
678
|
g {
|
|
@@ -129,6 +129,28 @@ const InsertButtonHover = () => css`
|
|
|
129
129
|
cursor: pointer;
|
|
130
130
|
}
|
|
131
131
|
`;
|
|
132
|
+
export const dragInsertButtonWrapper = props => css`
|
|
133
|
+
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON_INNER} {
|
|
134
|
+
position: absolute;
|
|
135
|
+
z-index: ${akEditorUnitZIndex + 10};
|
|
136
|
+
bottom: -5px;
|
|
137
|
+
left: 3px;
|
|
138
|
+
}
|
|
139
|
+
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON} {
|
|
140
|
+
${Button(`
|
|
141
|
+
background: ${"var(--ds-surface-overlay, white)"};
|
|
142
|
+
color: ${`var(--ds-icon, ${N300})`};
|
|
143
|
+
border: 1px solid ${"var(--ds-background-accent-gray-subtler, #C1C7D0)"};
|
|
144
|
+
border-radius: 50%;
|
|
145
|
+
`)}
|
|
146
|
+
}
|
|
147
|
+
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON}:hover {
|
|
148
|
+
background: ${`var(--ds-background-brand-bold, ${B300})`};
|
|
149
|
+
border: 1px solid ${`var(--ds-background-brand-bold, ${B300})`};
|
|
150
|
+
color: ${"var(--ds-icon-inverse, white)"};
|
|
151
|
+
cursor: pointer;
|
|
152
|
+
}
|
|
153
|
+
`;
|
|
132
154
|
export const insertColumnButtonWrapper = props => css`
|
|
133
155
|
${InsertButton()}
|
|
134
156
|
${InsertButtonHover()}
|
|
@@ -299,7 +321,7 @@ export const floatingColumnControls = props => {
|
|
|
299
321
|
}
|
|
300
322
|
}
|
|
301
323
|
|
|
302
|
-
.${ClassName.
|
|
324
|
+
.${ClassName.DRAG_COLUMN_CONTROLS} {
|
|
303
325
|
box-sizing: border-box;
|
|
304
326
|
|
|
305
327
|
.${ClassName.COLUMN_CONTROLS_INNER} {
|
|
@@ -10,11 +10,15 @@ export const isInsertRowButton = node => containsClassName(node, ClassName.CONTR
|
|
|
10
10
|
export const getColumnOrRowIndex = target => [parseInt(target.getAttribute('data-start-index') || '-1', 10), parseInt(target.getAttribute('data-end-index') || '-1', 10)];
|
|
11
11
|
export const isColumnControlsDecorations = node => containsClassName(node, ClassName.COLUMN_CONTROLS_DECORATIONS);
|
|
12
12
|
export const isRowControlsButton = node => containsClassName(node, ClassName.ROW_CONTROLS_BUTTON) || containsClassName(node, ClassName.NUMBERED_COLUMN_BUTTON);
|
|
13
|
-
export const isRowDragControlsButton = node => containsClassName(node, ClassName.ROW_CONTROLS_WITH_DRAG) || closestElement(node, `.${ClassName.ROW_CONTROLS_WITH_DRAG}`);
|
|
14
13
|
export const isResizeHandleDecoration = node => containsClassName(node, ClassName.RESIZE_HANDLE_DECORATION);
|
|
15
14
|
export const isTableControlsButton = node => containsClassName(node, ClassName.CONTROLS_BUTTON) || containsClassName(node, ClassName.ROW_CONTROLS_BUTTON_WRAP);
|
|
16
15
|
export const isTableContainerOrWrapper = node => containsClassName(node, ClassName.TABLE_CONTAINER) || containsClassName(node, ClassName.TABLE_NODE_WRAPPER);
|
|
17
16
|
|
|
17
|
+
/** drag-and-drop classes */
|
|
18
|
+
export const isRowDragControlsButton = node => containsClassName(node, ClassName.DRAG_ROW_CONTROLS) || closestElement(node, `.${ClassName.DRAG_ROW_CONTROLS}`);
|
|
19
|
+
export const isDragRowFloatingInsertDot = node => containsClassName(node, ClassName.DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER);
|
|
20
|
+
export const isDragColumnFloatingInsertDot = node => containsClassName(node, ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER);
|
|
21
|
+
|
|
18
22
|
/*
|
|
19
23
|
* This function returns which side of a given element the mouse cursor is,
|
|
20
24
|
* using as a base the half of the width by default, for example:
|
|
@@ -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, isRowDragControlsButton, isRowControlsButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler } from './dom';
|
|
5
|
+
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowDragControlsButton, isRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler } from './dom';
|
|
6
6
|
export { getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames } from './column-controls';
|
|
7
7
|
export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow } from './row-controls';
|
|
8
8
|
export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
|
|
@@ -10,7 +10,7 @@ import { getPluginState } from './pm-plugins/plugin-factory';
|
|
|
10
10
|
import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
|
|
11
11
|
import { deleteColumns, deleteRows } from './transforms';
|
|
12
12
|
import { RESIZE_HANDLE_AREA_DECORATION_GAP } from './types';
|
|
13
|
-
import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from './utils';
|
|
13
|
+
import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from './utils';
|
|
14
14
|
import { getAllowAddColumnCustomStep } from './utils/get-allow-add-column-custom-step';
|
|
15
15
|
var isFocusingCalendar = function isFocusingCalendar(event) {
|
|
16
16
|
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
|
|
@@ -21,12 +21,15 @@ var isFocusingModal = function isFocusingModal(event) {
|
|
|
21
21
|
var isFocusingFloatingToolbar = function isFocusingFloatingToolbar(event) {
|
|
22
22
|
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="toolbar"]');
|
|
23
23
|
};
|
|
24
|
+
var isFocusingDragHandles = function isFocusingDragHandles(event) {
|
|
25
|
+
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('button') && event.relatedTarget.getAttribute('draggable') === 'true';
|
|
26
|
+
};
|
|
24
27
|
export var handleBlur = function handleBlur(view, event) {
|
|
25
28
|
var state = view.state,
|
|
26
29
|
dispatch = view.dispatch;
|
|
27
30
|
// IE version check for ED-4665
|
|
28
31
|
// Calendar focus check for ED-10466
|
|
29
|
-
if (browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event)) {
|
|
32
|
+
if (browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event)) {
|
|
30
33
|
setEditorFocus(false)(state, dispatch);
|
|
31
34
|
}
|
|
32
35
|
event.preventDefault();
|
|
@@ -183,7 +186,7 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
183
186
|
return false;
|
|
184
187
|
}
|
|
185
188
|
var element = event.target;
|
|
186
|
-
if (isColumnControlsDecorations(element)) {
|
|
189
|
+
if (isColumnControlsDecorations(element) || isDragColumnFloatingInsertDot(element)) {
|
|
187
190
|
var state = view.state,
|
|
188
191
|
dispatch = view.dispatch;
|
|
189
192
|
var _getPluginState3 = getPluginState(state),
|
|
@@ -197,7 +200,7 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
197
200
|
return showInsertColumnButton(positionColumn)(state, dispatch);
|
|
198
201
|
}
|
|
199
202
|
}
|
|
200
|
-
if (isRowControlsButton(element)) {
|
|
203
|
+
if (isRowControlsButton(element) || isDragRowFloatingInsertDot(element)) {
|
|
201
204
|
var _state3 = view.state,
|
|
202
205
|
_dispatch4 = view.dispatch;
|
|
203
206
|
var _getPluginState4 = getPluginState(_state3),
|
|
@@ -268,8 +268,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
268
268
|
insertRowButtonIndex = _ref14.insertRowButtonIndex,
|
|
269
269
|
isHeaderColumnEnabled = _ref14.isHeaderColumnEnabled,
|
|
270
270
|
isHeaderRowEnabled = _ref14.isHeaderRowEnabled,
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
isDragAndDropEnabled = _ref14.isDragAndDropEnabled,
|
|
272
|
+
tableWrapperTarget = _ref14.tableWrapperTarget;
|
|
273
273
|
var allowControls = pluginConfig.allowControls;
|
|
274
274
|
var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
275
275
|
var LayoutContent = options && !options.tableResizingEnabled && isLayoutSupported(state) && options.breakoutEnabled ? /*#__PURE__*/React.createElement(LayoutButton, {
|
|
@@ -302,6 +302,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
302
302
|
insertRowButtonIndex: insertRowButtonIndex,
|
|
303
303
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
304
304
|
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
305
|
+
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
305
306
|
editorView: editorView,
|
|
306
307
|
mountPoint: popupsMountPoint,
|
|
307
308
|
boundariesElement: popupsBoundariesElement,
|
|
@@ -330,7 +331,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
330
331
|
direction: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
331
332
|
index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
332
333
|
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing
|
|
333
|
-
}), allowControls && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
334
|
+
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
334
335
|
editorView: editorView,
|
|
335
336
|
selection: editorView.state.selection,
|
|
336
337
|
tableRef: tableRef,
|
|
@@ -11,7 +11,7 @@ export var getDecorations = function getDecorations(state) {
|
|
|
11
11
|
return pluginKey.getState(state);
|
|
12
12
|
};
|
|
13
13
|
export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr, decorationSet, oldState, newState) {
|
|
14
|
-
var _tableWidthPluginKey$, _tableWidthPluginKey$2
|
|
14
|
+
var _tableWidthPluginKey$, _tableWidthPluginKey$2;
|
|
15
15
|
var isResizing = (_tableWidthPluginKey$ = tableWidthPluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
|
|
16
16
|
var wasResizing = (_tableWidthPluginKey$2 = tableWidthPluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
|
|
17
17
|
var changedResizing = isResizing !== wasResizing;
|
|
@@ -19,7 +19,7 @@ export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr
|
|
|
19
19
|
// Remove column controls when resizing and don't add column decoration controls when DnD enabled
|
|
20
20
|
if (isResizing || getBooleanFF('platform.editor.table.drag-and-drop')) {
|
|
21
21
|
return DecorationSet.empty;
|
|
22
|
-
} else if (tr.docChanged || tr.selection instanceof CellSelection || changedResizing
|
|
22
|
+
} else if (tr.docChanged || tr.selection instanceof CellSelection || changedResizing) {
|
|
23
23
|
return buildColumnControlsDecorations({
|
|
24
24
|
decorationSet: decorationSet,
|
|
25
25
|
tr: tr
|
|
@@ -42,16 +42,12 @@ export var createPlugin = function createPlugin() {
|
|
|
42
42
|
return DecorationSet.empty;
|
|
43
43
|
},
|
|
44
44
|
apply: function apply(tr, decorationSet, oldState, newState) {
|
|
45
|
-
var _tablePluginKey$getSt, _tablePluginKey$getSt2;
|
|
46
45
|
var pluginState = decorationSet;
|
|
47
46
|
var meta = tr.getMeta(tablePluginKey);
|
|
48
|
-
var previousHover = (_tablePluginKey$getSt = tablePluginKey.getState(oldState)) === null || _tablePluginKey$getSt === void 0 ? void 0 : _tablePluginKey$getSt.hoveredCell;
|
|
49
|
-
var newHover = (_tablePluginKey$getSt2 = tablePluginKey.getState(newState)) === null || _tablePluginKey$getSt2 === void 0 ? void 0 : _tablePluginKey$getSt2.hoveredCell;
|
|
50
|
-
var changedCellHover = (previousHover === null || previousHover === void 0 ? void 0 : previousHover.colIndex) !== (newHover === null || newHover === void 0 ? void 0 : newHover.colIndex) || (previousHover === null || previousHover === void 0 ? void 0 : previousHover.rowIndex) !== (newHover === null || newHover === void 0 ? void 0 : newHover.rowIndex);
|
|
51
47
|
if (meta && meta.data && meta.data.decorationSet) {
|
|
52
48
|
pluginState = meta.data.decorationSet;
|
|
53
49
|
}
|
|
54
|
-
if (tr.docChanged || tr.selectionSet || tr.getMeta(tableWidthPluginKey)
|
|
50
|
+
if (tr.docChanged || tr.selectionSet || tr.getMeta(tableWidthPluginKey)) {
|
|
55
51
|
pluginState = pluginState.map(tr.mapping, tr.doc);
|
|
56
52
|
return handleDocOrSelectionChanged(tr, pluginState, oldState, newState);
|
|
57
53
|
}
|
|
@@ -4,7 +4,6 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
4
4
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { TableDecorations } from '../../../types';
|
|
6
6
|
import { createColumnControlsDecoration, createColumnSelectedDecoration, findColumnControlSelectedDecoration, findControlsHoverDecoration, updateDecorations } from '../../../utils/decoration';
|
|
7
|
-
import { pluginKey as tablePluginKey } from '../../plugin-key';
|
|
8
7
|
import { composeDecorations } from './compose-decorations';
|
|
9
8
|
var isColumnSelected = function isColumnSelected(tr) {
|
|
10
9
|
return tr.selection instanceof CellSelection && tr.selection.isColSelection();
|
|
@@ -27,10 +26,9 @@ var maybeUpdateColumnControlsDecoration = function maybeUpdateColumnControlsDeco
|
|
|
27
26
|
var decorationSet = _ref3.decorationSet,
|
|
28
27
|
tr = _ref3.tr;
|
|
29
28
|
var table = findTable(tr.selection);
|
|
30
|
-
var meta = tr.getMeta(tablePluginKey);
|
|
31
29
|
|
|
32
30
|
// avoid re-drawing state if dnd decorations don't need to be updated
|
|
33
|
-
if (!table
|
|
31
|
+
if (!table) {
|
|
34
32
|
return decorationSet;
|
|
35
33
|
}
|
|
36
34
|
return updateDecorations(tr.doc, decorationSet, createColumnControlsDecoration(tr.selection), TableDecorations.COLUMN_CONTROLS_DECORATIONS);
|
|
@@ -2,6 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { getCellsInRow } from '@atlaskit/editor-tables/utils';
|
|
5
|
+
import { autoScroller } from '@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll';
|
|
5
6
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
6
7
|
import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils/merged-cells';
|
|
7
8
|
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
@@ -80,7 +81,16 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
|
|
|
80
81
|
// watch for changes
|
|
81
82
|
return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
|
|
82
83
|
},
|
|
84
|
+
onDragStart: function onDragStart(_ref3) {
|
|
85
|
+
var location = _ref3.location;
|
|
86
|
+
autoScroller.start({
|
|
87
|
+
input: location.current.input
|
|
88
|
+
});
|
|
89
|
+
},
|
|
83
90
|
onDrag: function onDrag(event) {
|
|
91
|
+
autoScroller.updateInput({
|
|
92
|
+
input: event.location.current.input
|
|
93
|
+
});
|
|
84
94
|
var data = getDraggableDataFromEvent(event);
|
|
85
95
|
// If no data can be found then it's most like we do not want to perform any drag actions
|
|
86
96
|
if (!data) {
|
|
@@ -96,6 +106,7 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
|
|
|
96
106
|
setDropTarget(dropTargetType, targetAdjustedIndex)(editorView.state, editorView.dispatch);
|
|
97
107
|
},
|
|
98
108
|
onDrop: function onDrop(event) {
|
|
109
|
+
autoScroller.stop();
|
|
99
110
|
var data = getDraggableDataFromEvent(event);
|
|
100
111
|
|
|
101
112
|
// If no data can be found then it's most like we do not want to perform any drop action
|
|
@@ -68,6 +68,9 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
|
|
|
68
68
|
CONTROLS_INSERT_LINE: "".concat(tablePrefixSelector, "-controls__insert-line"),
|
|
69
69
|
CONTROLS_BUTTON_OVERLAY: "".concat(tablePrefixSelector, "-controls__button-overlay"),
|
|
70
70
|
LAYOUT_BUTTON: "".concat(tablePrefixSelector, "-layout-button"),
|
|
71
|
+
DRAG_CONTROLS_INSERT_BUTTON: "".concat(tablePrefixSelector, "-controls__drag-insert-button"),
|
|
72
|
+
DRAG_CONTROLS_INSERT_BUTTON_INNER: "".concat(tablePrefixSelector, "-controls__drag-insert-button-inner"),
|
|
73
|
+
DRAG_CONTROLS_INSERT_BUTTON_WRAP: "".concat(tablePrefixSelector, "-controls__drag-insert-button-wrap"),
|
|
71
74
|
CONTROLS_INSERT_MARKER: "".concat(tablePrefixSelector, "-controls__insert-marker"),
|
|
72
75
|
CONTROLS_INSERT_COLUMN: "".concat(tablePrefixSelector, "-controls__insert-column"),
|
|
73
76
|
CONTROLS_INSERT_ROW: "".concat(tablePrefixSelector, "-controls__insert-row"),
|
|
@@ -80,8 +83,12 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
|
|
|
80
83
|
CORNER_CONTROLS_INSERT_COLUMN_MARKER: "".concat(tablePrefixSelector, "-corner-controls__insert-column-marker"),
|
|
81
84
|
CONTROLS_CORNER_BUTTON: "".concat(tablePrefixSelector, "-corner-button"),
|
|
82
85
|
/** Controls with drag handle */
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
DRAG_ROW_CONTROLS: "".concat(tablePrefixSelector, "-drag-row-controls"),
|
|
87
|
+
DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER: "".concat(tablePrefixSelector, "-drag-row-floating-insert-dot-wrapper"),
|
|
88
|
+
DRAG_ROW_FLOATING_INSERT_DOT: "".concat(tablePrefixSelector, "-drag-row-floating-insert-dot"),
|
|
89
|
+
DRAG_COLUMN_CONTROLS: "".concat(tablePrefixSelector, "-drag-column-controls"),
|
|
90
|
+
DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER: "".concat(tablePrefixSelector, "-drag-columns-floating-insert-dot-wrapper"),
|
|
91
|
+
DRAG_COLUMN_FLOATING_INSERT_DOT: "".concat(tablePrefixSelector, "-drag-columns-floating-insert-dot"),
|
|
85
92
|
DRAG_HANDLE_BUTTON_CONTAINER: "".concat(tablePrefixSelector, "-drag-handle-button-container"),
|
|
86
93
|
/** Other classes */
|
|
87
94
|
NUMBERED_COLUMN: "".concat(tablePrefixSelector, "-numbered-column"),
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
3
3
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
5
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
6
|
import { dragMenuDropdownWidth } from '../consts';
|
|
6
7
|
import { DragMenu } from './DragMenu';
|
|
7
8
|
var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
@@ -23,10 +24,11 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
23
24
|
if (!targetCellRef) {
|
|
24
25
|
return null;
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
+
var tableMap = tableNode ? TableMap.get(tableNode) : undefined;
|
|
28
|
+
var offset = direction === 'row' ? [7, 0] : index === ((tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) || 1) - 1 ? [14, 0] : [-14, 0];
|
|
27
29
|
// TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
|
|
28
30
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
29
|
-
alignX:
|
|
31
|
+
alignX: direction === 'row' ? 'left' : 'center',
|
|
30
32
|
alignY: "top",
|
|
31
33
|
target: targetCellRef,
|
|
32
34
|
mountTo: mountPoint,
|
|
@@ -38,7 +40,7 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
38
40
|
,
|
|
39
41
|
zIndex: akEditorFloatingOverlapPanelZIndex,
|
|
40
42
|
forcePlacement: true,
|
|
41
|
-
offset:
|
|
43
|
+
offset: offset,
|
|
42
44
|
stick: true
|
|
43
45
|
}, /*#__PURE__*/React.createElement(DragMenu, {
|
|
44
46
|
editorView: editorView,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
2
|
+
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { injectIntl } from 'react-intl-next';
|
|
3
5
|
import { addColumnAfter, addRowAfter, ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
@@ -23,7 +25,7 @@ var getToolbarSize = function getToolbarSize(tableRef) {
|
|
|
23
25
|
}
|
|
24
26
|
return tableToolbarSize;
|
|
25
27
|
};
|
|
26
|
-
var getInsertLineWidth = function getInsertLineWidth(tableRef) {
|
|
28
|
+
var getInsertLineWidth = function getInsertLineWidth(tableRef, isDragAndDropEnabled) {
|
|
27
29
|
// The line gets width 100% from the table,
|
|
28
30
|
// but since we have an overflow on the left,
|
|
29
31
|
// we should add an offset to make up for it.
|
|
@@ -34,22 +36,68 @@ var getInsertLineWidth = function getInsertLineWidth(tableRef) {
|
|
|
34
36
|
var _ref = parentElement,
|
|
35
37
|
scrollLeft = _ref.scrollLeft;
|
|
36
38
|
var diff = offsetWidth - parentOffsetWidth;
|
|
37
|
-
var toolbarSize = getToolbarSize(tableRef);
|
|
39
|
+
var toolbarSize = isDragAndDropEnabled ? 0 : getToolbarSize(tableRef);
|
|
38
40
|
return Math.min(offsetWidth + toolbarSize, parentOffsetWidth + toolbarSize - Math.max(scrollLeft - diff, 0)) + LINE_OFFSET;
|
|
39
41
|
};
|
|
40
42
|
var tooltipMessageByType = function tooltipMessageByType(type) {
|
|
41
43
|
return type === 'row' ? tableMessages.insertRow : tableMessages.insertColumn;
|
|
42
44
|
};
|
|
43
|
-
var
|
|
45
|
+
export var InsertButtonForDragAndDrop = function InsertButtonForDragAndDrop(_ref2) {
|
|
44
46
|
var onMouseDown = _ref2.onMouseDown,
|
|
45
47
|
tableRef = _ref2.tableRef,
|
|
46
|
-
|
|
48
|
+
type = _ref2.type,
|
|
47
49
|
formatMessage = _ref2.intl.formatMessage,
|
|
48
50
|
hasStickyHeaders = _ref2.hasStickyHeaders;
|
|
49
51
|
var content = /*#__PURE__*/React.createElement(Tooltip, {
|
|
50
52
|
content: /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
51
|
-
description: formatMessage(tooltipMessageByType(
|
|
52
|
-
keymap:
|
|
53
|
+
description: formatMessage(tooltipMessageByType(type)),
|
|
54
|
+
keymap: type === 'row' ? addRowAfter : addColumnAfter
|
|
55
|
+
}),
|
|
56
|
+
position: "top"
|
|
57
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
className: ClassName.DRAG_CONTROLS_INSERT_BUTTON_INNER
|
|
59
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
60
|
+
type: "button",
|
|
61
|
+
className: ClassName.DRAG_CONTROLS_INSERT_BUTTON,
|
|
62
|
+
onMouseDown: onMouseDown
|
|
63
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
64
|
+
width: "10",
|
|
65
|
+
height: "10",
|
|
66
|
+
viewBox: "0 0 10 10",
|
|
67
|
+
fill: "none",
|
|
68
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
69
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
70
|
+
fillRule: "evenodd",
|
|
71
|
+
clipRule: "evenodd",
|
|
72
|
+
d: "M5.41667 4.58333V2.91667C5.41667 2.80616 5.37277 2.70018 5.29463 2.62204C5.21649 2.5439 5.11051 2.5 5 2.5C4.88949 2.5 4.78351 2.5439 4.70537 2.62204C4.62723 2.70018 4.58333 2.80616 4.58333 2.91667V4.58333H2.91667C2.80616 4.58333 2.70018 4.62723 2.62204 4.70537C2.5439 4.78351 2.5 4.88949 2.5 5C2.5 5.11051 2.5439 5.21649 2.62204 5.29463C2.70018 5.37277 2.80616 5.41667 2.91667 5.41667H4.58333V7.08333C4.58333 7.19384 4.62723 7.29982 4.70537 7.37796C4.78351 7.4561 4.88949 7.5 5 7.5C5.11051 7.5 5.21649 7.4561 5.29463 7.37796C5.37277 7.29982 5.41667 7.19384 5.41667 7.08333V5.41667H7.08333C7.19384 5.41667 7.29982 5.37277 7.37796 5.29463C7.4561 5.21649 7.5 5.11051 7.5 5C7.5 4.88949 7.4561 4.78351 7.37796 4.70537C7.29982 4.62723 7.19384 4.58333 7.08333 4.58333H5.41667Z",
|
|
73
|
+
fill: "currentColor"
|
|
74
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: ClassName.CONTROLS_INSERT_LINE,
|
|
76
|
+
style: type === 'row' ? {
|
|
77
|
+
width: getInsertLineWidth(tableRef, true),
|
|
78
|
+
left: '14px'
|
|
79
|
+
} : {
|
|
80
|
+
height: getInsertLineHeight(tableRef, hasStickyHeaders) - 11
|
|
81
|
+
}
|
|
82
|
+
})));
|
|
83
|
+
var floatingButtonClassName = type === 'column' ? ClassName.CONTROLS_FLOATING_BUTTON_COLUMN : ClassName.CONTROLS_FLOATING_BUTTON_ROW;
|
|
84
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
className: floatingButtonClassName
|
|
86
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
className: "".concat(ClassName.CONTROLS_INSERT_BUTTON_WRAP, " ").concat(ClassName.CONTROLS_INSERT_ROW)
|
|
88
|
+
}, content));
|
|
89
|
+
};
|
|
90
|
+
export var DragAndDropInsertButton = injectIntl(InsertButtonForDragAndDrop);
|
|
91
|
+
var InsertButton = function InsertButton(_ref3) {
|
|
92
|
+
var onMouseDown = _ref3.onMouseDown,
|
|
93
|
+
tableRef = _ref3.tableRef,
|
|
94
|
+
type = _ref3.type,
|
|
95
|
+
formatMessage = _ref3.intl.formatMessage,
|
|
96
|
+
hasStickyHeaders = _ref3.hasStickyHeaders;
|
|
97
|
+
var content = /*#__PURE__*/React.createElement(Tooltip, {
|
|
98
|
+
content: /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
99
|
+
description: formatMessage(tooltipMessageByType(type)),
|
|
100
|
+
keymap: type === 'row' ? addRowAfter : addColumnAfter
|
|
53
101
|
}),
|
|
54
102
|
position: "top"
|
|
55
103
|
}, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -66,13 +114,13 @@ var InsertButton = function InsertButton(_ref2) {
|
|
|
66
114
|
fillRule: "evenodd"
|
|
67
115
|
})))), /*#__PURE__*/React.createElement("div", {
|
|
68
116
|
className: ClassName.CONTROLS_INSERT_LINE,
|
|
69
|
-
style:
|
|
117
|
+
style: type === 'row' ? {
|
|
70
118
|
width: getInsertLineWidth(tableRef)
|
|
71
119
|
} : {
|
|
72
120
|
height: getInsertLineHeight(tableRef, hasStickyHeaders)
|
|
73
121
|
}
|
|
74
122
|
})));
|
|
75
|
-
var floatingButtonClassName =
|
|
123
|
+
var floatingButtonClassName = type === 'column' ? ClassName.CONTROLS_FLOATING_BUTTON_COLUMN : ClassName.CONTROLS_FLOATING_BUTTON_ROW;
|
|
76
124
|
return /*#__PURE__*/React.createElement("div", {
|
|
77
125
|
className: floatingButtonClassName
|
|
78
126
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -6,9 +6,11 @@ import { tableInsertColumnButtonOffset, tableInsertColumnButtonSize, tableToolba
|
|
|
6
6
|
var HORIZONTAL_ALIGN_COLUMN_BUTTON = -(tableInsertColumnButtonSize / 2);
|
|
7
7
|
var HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON = HORIZONTAL_ALIGN_COLUMN_BUTTON + akEditorTableNumberColumnWidth;
|
|
8
8
|
var VERTICAL_ALIGN_COLUMN_BUTTON = tableToolbarSize + tableInsertColumnButtonOffset;
|
|
9
|
+
var VERTICAL_ALIGN_COLUMN_BUTTON_DRAG = tableInsertColumnButtonOffset;
|
|
9
10
|
var HORIZONTAL_ALIGN_ROW_BUTTON = -(tableToolbarSize + tableInsertColumnButtonOffset + tableInsertColumnButtonSize);
|
|
11
|
+
var HORIZONTAL_ALIGN_ROW_BUTTON_DRAG = -18;
|
|
10
12
|
var VERTICAL_ALIGN_ROW_BUTTON = tableInsertColumnButtonSize / 2;
|
|
11
|
-
function getRowOptions(index) {
|
|
13
|
+
function getRowOptions(index, isDragAndDropEnabled) {
|
|
12
14
|
var defaultOptions = {
|
|
13
15
|
alignX: 'left',
|
|
14
16
|
alignY: 'bottom',
|
|
@@ -25,16 +27,16 @@ function getRowOptions(index) {
|
|
|
25
27
|
onPositionCalculated: function onPositionCalculated(position) {
|
|
26
28
|
return _objectSpread(_objectSpread({}, position), {}, {
|
|
27
29
|
// Left position should be always the offset (To place in the correct position even if the table has overflow).
|
|
28
|
-
left: HORIZONTAL_ALIGN_ROW_BUTTON
|
|
30
|
+
left: isDragAndDropEnabled ? HORIZONTAL_ALIGN_ROW_BUTTON_DRAG : HORIZONTAL_ALIGN_ROW_BUTTON
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
|
-
function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
35
|
+
function getColumnOptions(index, tableContainer, hasNumberedColumns, isDragAndDropEnabled) {
|
|
34
36
|
var options = {
|
|
35
37
|
alignX: 'end',
|
|
36
38
|
alignY: 'top',
|
|
37
|
-
offset: [HORIZONTAL_ALIGN_COLUMN_BUTTON, VERTICAL_ALIGN_COLUMN_BUTTON],
|
|
39
|
+
offset: [HORIZONTAL_ALIGN_COLUMN_BUTTON, isDragAndDropEnabled ? VERTICAL_ALIGN_COLUMN_BUTTON_DRAG : VERTICAL_ALIGN_COLUMN_BUTTON],
|
|
38
40
|
// :: (position: PopupPosition) -> PopupPosition
|
|
39
41
|
// Limit the InsertButton position to the table container
|
|
40
42
|
// if the left position starts before it
|
|
@@ -70,12 +72,12 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
|
70
72
|
}
|
|
71
73
|
return options;
|
|
72
74
|
}
|
|
73
|
-
function getPopupOptions(direction, index, hasNumberedColumns, tableContainer) {
|
|
75
|
+
function getPopupOptions(direction, index, hasNumberedColumns, isDragAndDropEnabled, tableContainer) {
|
|
74
76
|
switch (direction) {
|
|
75
77
|
case 'column':
|
|
76
|
-
return getColumnOptions(index, tableContainer, hasNumberedColumns);
|
|
78
|
+
return getColumnOptions(index, tableContainer, hasNumberedColumns, isDragAndDropEnabled);
|
|
77
79
|
case 'row':
|
|
78
|
-
return getRowOptions(index);
|
|
80
|
+
return getRowOptions(index, isDragAndDropEnabled);
|
|
79
81
|
default:
|
|
80
82
|
return {};
|
|
81
83
|
}
|
|
@@ -22,7 +22,7 @@ import { insertColumnWithAnalytics, insertRowWithAnalytics } from '../../command
|
|
|
22
22
|
import { TableCssClassName as ClassName } from '../../types';
|
|
23
23
|
import { checkIfNumberColumnEnabled } from '../../utils';
|
|
24
24
|
import getPopupOptions from './getPopupOptions';
|
|
25
|
-
import InsertButton from './InsertButton';
|
|
25
|
+
import InsertButton, { DragAndDropInsertButton } from './InsertButton';
|
|
26
26
|
export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
27
27
|
_inherits(FloatingInsertButton, _React$Component);
|
|
28
28
|
var _super = _createSuper(FloatingInsertButton);
|
|
@@ -47,6 +47,7 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
47
47
|
boundariesElement = _this$props.boundariesElement,
|
|
48
48
|
isHeaderColumnEnabled = _this$props.isHeaderColumnEnabled,
|
|
49
49
|
isHeaderRowEnabled = _this$props.isHeaderRowEnabled,
|
|
50
|
+
isDragAndDropEnabled = _this$props.isDragAndDropEnabled,
|
|
50
51
|
dispatchAnalyticsEvent = _this$props.dispatchAnalyticsEvent;
|
|
51
52
|
var type = typeof insertColumnButtonIndex !== 'undefined' ? 'column' : typeof insertRowButtonIndex !== 'undefined' ? 'row' : null;
|
|
52
53
|
if (!tableNode || !tableRef || !type) {
|
|
@@ -121,10 +122,15 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
121
122
|
scrollableElement: tableWrapper,
|
|
122
123
|
forcePlacement: true,
|
|
123
124
|
allowOutOfBounds: true
|
|
124
|
-
}, getPopupOptions(type, index, hasNumberedColumns, tableContainerWrapper), {
|
|
125
|
+
}, getPopupOptions(type, index, hasNumberedColumns, !!isDragAndDropEnabled, tableContainerWrapper), {
|
|
125
126
|
zIndex: zIndex
|
|
126
|
-
}), /*#__PURE__*/React.createElement(
|
|
127
|
-
|
|
127
|
+
}), isDragAndDropEnabled ? /*#__PURE__*/React.createElement(DragAndDropInsertButton, {
|
|
128
|
+
type: type,
|
|
129
|
+
tableRef: tableRef,
|
|
130
|
+
onMouseDown: type === 'column' ? this.insertColumn : this.insertRow,
|
|
131
|
+
hasStickyHeaders: this.props.hasStickyHeaders || false
|
|
132
|
+
}) : /*#__PURE__*/React.createElement(InsertButton, {
|
|
133
|
+
type: type,
|
|
128
134
|
tableRef: tableRef,
|
|
129
135
|
onMouseDown: type === 'column' ? this.insertColumn : this.insertRow,
|
|
130
136
|
hasStickyHeaders: this.props.hasStickyHeaders || false
|