@atlaskit/editor-plugin-table 5.3.1 → 5.3.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 +12 -0
- package/dist/cjs/plugins/table/commands/hover.js +17 -8
- package/dist/cjs/plugins/table/commands/index.js +6 -0
- package/dist/cjs/plugins/table/commands/misc.js +1 -7
- package/dist/cjs/plugins/table/event-handlers.js +29 -2
- package/dist/cjs/plugins/table/index.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +5 -3
- package/dist/cjs/plugins/table/nodeviews/table.js +4 -2
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +7 -3
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
- package/dist/cjs/plugins/table/pm-plugins/default-table-selection.js +14 -1
- package/dist/cjs/plugins/table/pm-plugins/main.js +5 -5
- package/dist/cjs/plugins/table/reducer.js +2 -1
- package/dist/cjs/plugins/table/types.js +6 -0
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +50 -0
- package/dist/cjs/plugins/table/ui/DragPreview/index.js +39 -0
- package/dist/cjs/plugins/table/ui/Icons/DragInMotionIcon.js +55 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +53 -14
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +114 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +53 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +11 -106
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +16 -6
- package/dist/cjs/plugins/table/ui/common-styles.js +9 -6
- package/dist/cjs/plugins/table/ui/consts.js +2 -1
- package/dist/cjs/plugins/table/ui/ui-styles.js +18 -9
- package/dist/cjs/plugins/table/utils/decoration.js +44 -18
- package/dist/cjs/plugins/table/utils/dom.js +7 -1
- package/dist/cjs/plugins/table/utils/index.js +12 -0
- package/dist/es2019/plugins/table/commands/hover.js +12 -8
- package/dist/es2019/plugins/table/commands/index.js +1 -1
- package/dist/es2019/plugins/table/commands/misc.js +1 -7
- package/dist/es2019/plugins/table/event-handlers.js +28 -2
- package/dist/es2019/plugins/table/index.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +5 -3
- package/dist/es2019/plugins/table/nodeviews/table.js +4 -2
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +8 -6
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
- package/dist/es2019/plugins/table/pm-plugins/default-table-selection.js +13 -0
- package/dist/es2019/plugins/table/pm-plugins/main.js +6 -5
- package/dist/es2019/plugins/table/reducer.js +2 -1
- package/dist/es2019/plugins/table/types.js +6 -0
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +41 -0
- package/dist/es2019/plugins/table/ui/DragPreview/index.js +33 -0
- package/dist/es2019/plugins/table/ui/Icons/DragInMotionIcon.js +47 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +54 -10
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +86 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +43 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +2 -88
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +17 -7
- package/dist/es2019/plugins/table/ui/common-styles.js +47 -12
- package/dist/es2019/plugins/table/ui/consts.js +1 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +57 -14
- package/dist/es2019/plugins/table/utils/decoration.js +44 -18
- package/dist/es2019/plugins/table/utils/dom.js +2 -0
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/commands/hover.js +16 -8
- package/dist/esm/plugins/table/commands/index.js +1 -1
- package/dist/esm/plugins/table/commands/misc.js +1 -7
- package/dist/esm/plugins/table/event-handlers.js +29 -2
- package/dist/esm/plugins/table/index.js +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +5 -3
- package/dist/esm/plugins/table/nodeviews/table.js +4 -2
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +8 -6
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
- package/dist/esm/plugins/table/pm-plugins/default-table-selection.js +13 -0
- package/dist/esm/plugins/table/pm-plugins/main.js +7 -7
- package/dist/esm/plugins/table/reducer.js +2 -1
- package/dist/esm/plugins/table/types.js +6 -0
- package/dist/esm/plugins/table/ui/DragHandle/index.js +41 -0
- package/dist/esm/plugins/table/ui/DragPreview/index.js +32 -0
- package/dist/esm/plugins/table/ui/Icons/DragInMotionIcon.js +48 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +54 -15
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +104 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +46 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +2 -104
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +17 -7
- package/dist/esm/plugins/table/ui/common-styles.js +10 -7
- package/dist/esm/plugins/table/ui/consts.js +1 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +18 -9
- package/dist/esm/plugins/table/utils/decoration.js +44 -18
- package/dist/esm/plugins/table/utils/dom.js +6 -0
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/commands/hover.d.ts +2 -1
- package/dist/types/plugins/table/commands/index.d.ts +1 -1
- package/dist/types/plugins/table/event-handlers.d.ts +1 -0
- package/dist/types/plugins/table/nodeviews/types.d.ts +4 -3
- package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +2 -1
- package/dist/types/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/default-table-selection.d.ts +12 -0
- package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/table/types.d.ts +16 -1
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +11 -0
- package/dist/types/plugins/table/ui/DragPreview/index.d.ts +6 -0
- package/dist/types/plugins/table/ui/Icons/DragInMotionIcon.d.ts +6 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +4 -1
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +17 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +16 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +2 -17
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -2
- package/dist/types/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types/plugins/table/utils/decoration.d.ts +2 -2
- package/dist/types/plugins/table/utils/dom.d.ts +2 -0
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +4 -3
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/default-table-selection.d.ts +12 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +16 -1
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +11 -0
- package/dist/types-ts4.5/plugins/table/ui/DragPreview/index.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/ui/Icons/DragInMotionIcon.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +4 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +17 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +2 -17
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -2
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +5 -3
- package/src/__tests__/unit/event-handlers.ts +74 -1
- package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +35 -15
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +146 -42
- package/src/__tests__/unit/ui/NumberColumn.tsx +148 -0
- package/src/__tests__/unit/ui/RowControls.tsx +4 -4
- package/src/__tests__/unit/ui/RowDragControls.tsx +118 -0
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +9 -5
- package/src/plugins/table/commands/hover.ts +16 -7
- package/src/plugins/table/commands/index.ts +1 -0
- package/src/plugins/table/commands/misc.ts +0 -5
- package/src/plugins/table/event-handlers.ts +49 -2
- package/src/plugins/table/index.tsx +1 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +3 -2
- package/src/plugins/table/nodeviews/table.tsx +2 -0
- package/src/plugins/table/nodeviews/types.ts +4 -3
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +13 -4
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +10 -5
- package/src/plugins/table/pm-plugins/default-table-selection.ts +10 -0
- package/src/plugins/table/pm-plugins/main.ts +9 -4
- package/src/plugins/table/reducer.ts +2 -1
- package/src/plugins/table/types.ts +14 -2
- package/src/plugins/table/ui/DragHandle/index.tsx +57 -0
- package/src/plugins/table/ui/DragPreview/index.tsx +45 -0
- package/src/plugins/table/ui/Icons/DragInMotionIcon.tsx +60 -0
- package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +68 -30
- package/src/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.tsx +129 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +75 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/index.tsx +2 -135
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +43 -24
- package/src/plugins/table/ui/common-styles.ts +52 -11
- package/src/plugins/table/ui/consts.ts +1 -0
- package/src/plugins/table/ui/ui-styles.ts +58 -14
- package/src/plugins/table/utils/decoration.ts +75 -27
- package/src/plugins/table/utils/dom.ts +8 -0
- package/src/plugins/table/utils/index.ts +2 -0
- package/tsconfig.app.json +6 -0
|
@@ -300,6 +300,17 @@ export const floatingColumnControls = props => {
|
|
|
300
300
|
`;
|
|
301
301
|
};
|
|
302
302
|
export const columnControlsDecoration = props => {
|
|
303
|
+
if (getBooleanFF('platform.editor.table.drag-and-drop')) {
|
|
304
|
+
return css`
|
|
305
|
+
.${ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG} {
|
|
306
|
+
position: absolute;
|
|
307
|
+
// kinda a hacky way to center an element with absolute positioning inside a relative element
|
|
308
|
+
top: 25%;
|
|
309
|
+
left: 50%;
|
|
310
|
+
transform: translate(-50%, -100%);
|
|
311
|
+
}
|
|
312
|
+
`;
|
|
313
|
+
}
|
|
303
314
|
if (getBooleanFF('platform.editor.table.column-controls-styles-updated')) {
|
|
304
315
|
return css`
|
|
305
316
|
.${ClassName.COLUMN_CONTROLS_DECORATIONS} {
|
|
@@ -564,21 +575,35 @@ const getLastColumnResizerOverrides = () => {
|
|
|
564
575
|
}
|
|
565
576
|
` : '';
|
|
566
577
|
};
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
578
|
+
const resizeHandleOverrides = props => {
|
|
579
|
+
if (getBooleanFF('platform.editor.table.drag-and-drop')) {
|
|
580
|
+
return css`
|
|
581
|
+
th.${ClassName.WITH_RESIZE_LINE}::before,
|
|
582
|
+
td.${ClassName.WITH_RESIZE_LINE}::before {
|
|
583
|
+
content: ' ';
|
|
584
|
+
position: absolute;
|
|
585
|
+
left: ${"var(--ds-space-negative-025, -2px)"};
|
|
586
|
+
top: -1px;
|
|
587
|
+
width: ${resizeLineWidth}px;
|
|
588
|
+
height: calc(100% + 2px);
|
|
589
|
+
background-color: ${tableBorderSelectedColor(props)};
|
|
590
|
+
z-index: ${columnControlsZIndex * 2};
|
|
591
|
+
}
|
|
581
592
|
|
|
593
|
+
th.${ClassName.WITH_RESIZE_LINE_LAST_COLUMN}::before,
|
|
594
|
+
td.${ClassName.WITH_RESIZE_LINE_LAST_COLUMN}::before {
|
|
595
|
+
content: ' ';
|
|
596
|
+
position: absolute;
|
|
597
|
+
right: -1px;
|
|
598
|
+
top: -1px;
|
|
599
|
+
width: ${resizeLineWidth}px;
|
|
600
|
+
height: calc(100% + 2px);
|
|
601
|
+
background-color: ${tableBorderSelectedColor(props)};
|
|
602
|
+
z-index: ${columnControlsZIndex * 2};
|
|
603
|
+
}
|
|
604
|
+
`;
|
|
605
|
+
}
|
|
606
|
+
return css`
|
|
582
607
|
td.${ClassName.WITH_RESIZE_LINE}::before {
|
|
583
608
|
content: ' ';
|
|
584
609
|
position: absolute;
|
|
@@ -622,6 +647,24 @@ export const resizeHandle = props => css`
|
|
|
622
647
|
z-index: ${columnControlsZIndex * 2};
|
|
623
648
|
top: -${tableToolbarSize + tableCellBorderWidth}px;
|
|
624
649
|
}
|
|
650
|
+
`;
|
|
651
|
+
};
|
|
652
|
+
export const resizeHandle = props => css`
|
|
653
|
+
.${ClassName.TABLE_CONTAINER} {
|
|
654
|
+
.${ClassName.RESIZE_HANDLE_DECORATION} {
|
|
655
|
+
background-color: transparent;
|
|
656
|
+
position: absolute;
|
|
657
|
+
width: ${resizeHandlerAreaWidth}px;
|
|
658
|
+
height: 100%;
|
|
659
|
+
top: 0;
|
|
660
|
+
right: -${resizeHandlerAreaWidth / 2}px;
|
|
661
|
+
cursor: col-resize;
|
|
662
|
+
z-index: ${resizeHandlerZIndex};
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
${getLastColumnResizerOverrides()}
|
|
666
|
+
|
|
667
|
+
${resizeHandleOverrides(props)}
|
|
625
668
|
|
|
626
669
|
table
|
|
627
670
|
tr:first-of-type
|
|
@@ -8,8 +8,10 @@ import { nonNullable } from '@atlaskit/editor-common/utils';
|
|
|
8
8
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
|
|
10
10
|
import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
11
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
12
13
|
import { ColumnResizeWidget } from '../ui/ColumnResizeWidget';
|
|
14
|
+
import { DragHandle } from '../ui/DragHandle';
|
|
13
15
|
const filterDecorationByKey = (key, decorationSet) => decorationSet.find(undefined, undefined, spec => spec.key.indexOf(key) > -1);
|
|
14
16
|
export const findColumnControlSelectedDecoration = decorationSet => filterDecorationByKey(TableDecorations.COLUMN_SELECTED, decorationSet);
|
|
15
17
|
export const findControlsHoverDecoration = decorationSet => filterDecorationByKey(TableDecorations.ALL_CONTROLS_HOVER, decorationSet);
|
|
@@ -128,30 +130,54 @@ export const createColumnSelectedDecoration = tr => {
|
|
|
128
130
|
});
|
|
129
131
|
});
|
|
130
132
|
};
|
|
131
|
-
export const createColumnControlsDecoration = selection => {
|
|
133
|
+
export const createColumnControlsDecoration = (selection, hoverLocation) => {
|
|
134
|
+
// todo: issue here where table may not be selected yet
|
|
132
135
|
const cells = getCellsInRow(0)(selection) || [];
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const startIndex = index;
|
|
139
|
-
const endIndex = startIndex + colspan;
|
|
140
|
-
|
|
141
|
-
// The next cell start index will commence from the current cell end index.
|
|
142
|
-
index = endIndex;
|
|
143
|
-
return Decoration.widget(cell.pos + 1, () => {
|
|
136
|
+
const table = findTable(selection);
|
|
137
|
+
if (getBooleanFF('platform.editor.table.drag-and-drop') && hoverLocation && !Number.isNaN(hoverLocation === null || hoverLocation === void 0 ? void 0 : hoverLocation.colIndex) && table) {
|
|
138
|
+
const colIndex = hoverLocation.colIndex;
|
|
139
|
+
const cell = cells[colIndex];
|
|
140
|
+
return [Decoration.widget(cell.pos + 1, () => {
|
|
144
141
|
const element = document.createElement('div');
|
|
145
|
-
element.classList.add(ClassName.
|
|
146
|
-
|
|
147
|
-
|
|
142
|
+
element.classList.add(ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG);
|
|
143
|
+
ReactDOM.render( /*#__PURE__*/createElement(DragHandle, {
|
|
144
|
+
tableLocalId: table.node.attrs.localId,
|
|
145
|
+
direction: 'column',
|
|
146
|
+
indexes: [colIndex]
|
|
147
|
+
}), element);
|
|
148
148
|
return element;
|
|
149
149
|
}, {
|
|
150
|
-
key: `${TableDecorations.COLUMN_CONTROLS_DECORATIONS}_${
|
|
150
|
+
key: `${TableDecorations.COLUMN_CONTROLS_DECORATIONS}_${colIndex}`,
|
|
151
151
|
// this decoration should be the first one, even before gap cursor.
|
|
152
|
-
side: -100
|
|
152
|
+
side: -100,
|
|
153
|
+
destroy: node => {
|
|
154
|
+
ReactDOM.unmountComponentAtNode(node);
|
|
155
|
+
}
|
|
156
|
+
})];
|
|
157
|
+
} else {
|
|
158
|
+
let index = 0;
|
|
159
|
+
return cells.map(cell => {
|
|
160
|
+
const colspan = cell.node.attrs.colspan || 1;
|
|
161
|
+
// It's important these values are scoped locally as the widget callback could be executed anytime in the future
|
|
162
|
+
// and we want to avoid value leak
|
|
163
|
+
const startIndex = index;
|
|
164
|
+
const endIndex = startIndex + colspan;
|
|
165
|
+
|
|
166
|
+
// The next cell start index will commence from the current cell end index.
|
|
167
|
+
index = endIndex;
|
|
168
|
+
return Decoration.widget(cell.pos + 1, () => {
|
|
169
|
+
const element = document.createElement('div');
|
|
170
|
+
element.classList.add(ClassName.COLUMN_CONTROLS_DECORATIONS);
|
|
171
|
+
element.dataset.startIndex = `${startIndex}`;
|
|
172
|
+
element.dataset.endIndex = `${endIndex}`;
|
|
173
|
+
return element;
|
|
174
|
+
}, {
|
|
175
|
+
key: `${TableDecorations.COLUMN_CONTROLS_DECORATIONS}_${endIndex}`,
|
|
176
|
+
// this decoration should be the first one, even before gap cursor.
|
|
177
|
+
side: -100
|
|
178
|
+
});
|
|
153
179
|
});
|
|
154
|
-
}
|
|
180
|
+
}
|
|
155
181
|
};
|
|
156
182
|
export const updateDecorations = (node, decorationSet, decorations, key) => {
|
|
157
183
|
const filteredDecorations = filterDecorationByKey(key, decorationSet);
|
|
@@ -9,7 +9,9 @@ export const isCornerButton = node => containsClassName(node, ClassName.CONTROLS
|
|
|
9
9
|
export const isInsertRowButton = node => containsClassName(node, ClassName.CONTROLS_INSERT_ROW) || closestElement(node, `.${ClassName.CONTROLS_INSERT_ROW}`) || containsClassName(node, ClassName.CONTROLS_BUTTON_OVERLAY) && closestElement(node, `.${ClassName.ROW_CONTROLS}`);
|
|
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
|
+
export const isColumnDragControlsDecorations = node => containsClassName(node, ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG) || closestElement(node, `.${ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG}`);
|
|
12
13
|
export const isRowControlsButton = node => containsClassName(node, ClassName.ROW_CONTROLS_BUTTON) || containsClassName(node, ClassName.NUMBERED_COLUMN_BUTTON);
|
|
14
|
+
export const isRowDragControlsButton = node => containsClassName(node, ClassName.ROW_CONTROLS_WITH_DRAG) || closestElement(node, `.${ClassName.ROW_CONTROLS_WITH_DRAG}`);
|
|
13
15
|
export const isResizeHandleDecoration = node => containsClassName(node, ClassName.RESIZE_HANDLE_DECORATION);
|
|
14
16
|
export const isTableControlsButton = node => containsClassName(node, ClassName.CONTROLS_BUTTON) || containsClassName(node, ClassName.ROW_CONTROLS_BUTTON_WRAP);
|
|
15
17
|
export const isTableContainerOrWrapper = node => containsClassName(node, ClassName.TABLE_CONTAINER) || containsClassName(node, ClassName.TABLE_NODE_WRAPPER);
|
|
@@ -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, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler } from './dom';
|
|
5
|
+
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isColumnDragControlsDecorations, isRowDragControlsButton, isRowControlsButton, 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';
|
|
@@ -4,15 +4,9 @@ import { findTable, getCellsInColumn, getCellsInRow } from '@atlaskit/editor-tab
|
|
|
4
4
|
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
5
5
|
import { TableDecorations } from '../types';
|
|
6
6
|
import { createCellHoverDecoration, createColumnLineResize, createControlsHoverDecoration, getMergedCellsPositions, updatePluginStateDecorations } from '../utils';
|
|
7
|
-
// #endregion
|
|
8
|
-
|
|
9
|
-
// #region Utils
|
|
10
7
|
var makeArray = function makeArray(n) {
|
|
11
8
|
return Array.from(Array(n).keys());
|
|
12
9
|
};
|
|
13
|
-
// #endregion
|
|
14
|
-
|
|
15
|
-
// #region Commands
|
|
16
10
|
export var hoverMergedCells = function hoverMergedCells() {
|
|
17
11
|
return createCommand(function (state) {
|
|
18
12
|
var mergedCellsPositions = getMergedCellsPositions(state.tr);
|
|
@@ -32,7 +26,7 @@ export var hoverMergedCells = function hoverMergedCells() {
|
|
|
32
26
|
});
|
|
33
27
|
var decorations = createCellHoverDecoration(mergedCells);
|
|
34
28
|
return {
|
|
35
|
-
type: '
|
|
29
|
+
type: 'HOVER_MERGED_CELLS',
|
|
36
30
|
data: {
|
|
37
31
|
decorationSet: updatePluginStateDecorations(state, decorations, TableDecorations.CELL_CONTROLS_HOVER)
|
|
38
32
|
}
|
|
@@ -137,4 +131,18 @@ export var hideResizeHandleLine = function hideResizeHandleLine() {
|
|
|
137
131
|
};
|
|
138
132
|
});
|
|
139
133
|
};
|
|
140
|
-
|
|
134
|
+
export var hoverCell = function hoverCell(rowIndex, colIndex) {
|
|
135
|
+
return createCommand(function () {
|
|
136
|
+
return {
|
|
137
|
+
type: 'HOVER_CELL',
|
|
138
|
+
data: {
|
|
139
|
+
hoveredCell: {
|
|
140
|
+
rowIndex: rowIndex,
|
|
141
|
+
colIndex: colIndex
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}, function (tr) {
|
|
146
|
+
return tr.setMeta('addToHistory', false);
|
|
147
|
+
});
|
|
148
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { hoverColumns, hoverRows, hoverTable, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine } from './hover';
|
|
1
|
+
export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine } from './hover';
|
|
2
2
|
export { insertColumn, insertRow, createTable } from './insert';
|
|
3
3
|
export { getNextLayout, toggleContextualMenu, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './toggle';
|
|
4
4
|
export { clearMultipleCells } from './clear';
|
|
@@ -16,11 +16,6 @@ import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
|
16
16
|
import { createColumnControlsDecoration, createColumnSelectedDecoration } from '../utils/decoration';
|
|
17
17
|
import { checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isIsolating } from '../utils/nodes';
|
|
18
18
|
import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations';
|
|
19
|
-
// #endregion
|
|
20
|
-
|
|
21
|
-
// #endregion
|
|
22
|
-
|
|
23
|
-
// #region Commands
|
|
24
19
|
export var setEditorFocus = function setEditorFocus(editorHasFocus) {
|
|
25
20
|
return createCommand({
|
|
26
21
|
type: 'SET_EDITOR_FOCUS',
|
|
@@ -439,5 +434,4 @@ export var addBoldInEmptyHeaderCells = function addBoldInEmptyHeaderCells(tableC
|
|
|
439
434
|
}
|
|
440
435
|
return false;
|
|
441
436
|
};
|
|
442
|
-
};
|
|
443
|
-
// #endregion
|
|
437
|
+
};
|
|
@@ -5,7 +5,7 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
5
5
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
6
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
7
|
import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
|
|
8
|
-
import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverColumns, selectColumn, setEditorFocus, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
|
|
8
|
+
import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
|
|
9
9
|
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';
|
|
@@ -164,11 +164,15 @@ export var handleMouseLeave = function handleMouseLeave(view, event) {
|
|
|
164
164
|
dispatch = view.dispatch;
|
|
165
165
|
var _getPluginState2 = getPluginState(state),
|
|
166
166
|
insertColumnButtonIndex = _getPluginState2.insertColumnButtonIndex,
|
|
167
|
-
insertRowButtonIndex = _getPluginState2.insertRowButtonIndex
|
|
167
|
+
insertRowButtonIndex = _getPluginState2.insertRowButtonIndex,
|
|
168
|
+
isDragAndDropEnabled = _getPluginState2.isDragAndDropEnabled;
|
|
168
169
|
var target = event.target;
|
|
169
170
|
if (isTableControlsButton(target)) {
|
|
170
171
|
return true;
|
|
171
172
|
}
|
|
173
|
+
if (isDragAndDropEnabled) {
|
|
174
|
+
hoverCell(undefined, undefined)(state, dispatch);
|
|
175
|
+
}
|
|
172
176
|
if ((typeof insertColumnButtonIndex !== 'undefined' || typeof insertRowButtonIndex !== 'undefined') && hideInsertColumnOrRowButton()(state, dispatch)) {
|
|
173
177
|
return true;
|
|
174
178
|
}
|
|
@@ -309,4 +313,27 @@ export var whenTableInFocus = function whenTableInFocus(eventHandler, elementCon
|
|
|
309
313
|
}
|
|
310
314
|
return eventHandler(view, mouseEvent, elementContentRects);
|
|
311
315
|
};
|
|
316
|
+
};
|
|
317
|
+
var trackCellLocation = function trackCellLocation(view, mouseEvent) {
|
|
318
|
+
var target = mouseEvent.target;
|
|
319
|
+
var maybeTableCell = isElementInTableCell(target);
|
|
320
|
+
if (!maybeTableCell) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
var colIndex = maybeTableCell.cellIndex;
|
|
324
|
+
var rowElement = closestElement(target, 'tr');
|
|
325
|
+
var rowIndex = rowElement && rowElement.rowIndex;
|
|
326
|
+
var _getPluginState8 = getPluginState(view.state),
|
|
327
|
+
hoveredCell = _getPluginState8.hoveredCell;
|
|
328
|
+
if (hoveredCell.colIndex !== colIndex || hoveredCell.rowIndex !== rowIndex) {
|
|
329
|
+
hoverCell(rowIndex, colIndex)(view.state, view.dispatch);
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
export var withCellTracking = function withCellTracking(eventHandler, elementContentRects) {
|
|
333
|
+
return function (view, mouseEvent) {
|
|
334
|
+
if (getPluginState(view.state).isDragAndDropEnabled) {
|
|
335
|
+
trackCellLocation(view, mouseEvent);
|
|
336
|
+
}
|
|
337
|
+
return eventHandler(view, mouseEvent, elementContentRects);
|
|
338
|
+
};
|
|
312
339
|
};
|
|
@@ -107,7 +107,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
107
107
|
tableOptions = _ref3.tableOptions,
|
|
108
108
|
getEditorFeatureFlags = _ref3.getEditorFeatureFlags,
|
|
109
109
|
dragAndDropEnabled = _ref3.dragAndDropEnabled;
|
|
110
|
-
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled,
|
|
110
|
+
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api);
|
|
111
111
|
}
|
|
112
112
|
}, {
|
|
113
113
|
name: 'tablePMColResizing',
|
|
@@ -462,7 +462,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
462
462
|
// doesn't work well with WithPluginState
|
|
463
463
|
var _getPluginState2 = getPluginState(view.state),
|
|
464
464
|
isInDanger = _getPluginState2.isInDanger,
|
|
465
|
-
hoveredRows = _getPluginState2.hoveredRows
|
|
465
|
+
hoveredRows = _getPluginState2.hoveredRows,
|
|
466
|
+
hoveredCell = _getPluginState2.hoveredCell;
|
|
466
467
|
var tableRef = this.table || undefined;
|
|
467
468
|
var headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
|
|
468
469
|
var hasHeaderRow = containsHeaderRow(node);
|
|
@@ -473,10 +474,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
473
474
|
tableRef: tableRef,
|
|
474
475
|
tableActive: tableActive,
|
|
475
476
|
hoveredRows: hoveredRows,
|
|
477
|
+
hoveredCell: hoveredCell,
|
|
476
478
|
isInDanger: isInDanger,
|
|
477
479
|
isResizing: isResizing,
|
|
478
480
|
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
479
481
|
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
482
|
+
isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
|
|
480
483
|
ordering: ordering,
|
|
481
484
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
482
485
|
hasHeaderRow: hasHeaderRow
|
|
@@ -484,8 +487,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
484
487
|
,
|
|
485
488
|
selection: view.state.selection,
|
|
486
489
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
487
|
-
stickyHeader: this.state.stickyHeader
|
|
488
|
-
getEditorFeatureFlags: this.props.getEditorFeatureFlags
|
|
490
|
+
stickyHeader: this.state.stickyHeader
|
|
489
491
|
}));
|
|
490
492
|
var colControls = /*#__PURE__*/React.createElement("div", {
|
|
491
493
|
className: ClassName.COLUMN_CONTROLS_WRAPPER
|
|
@@ -249,7 +249,8 @@ export var createTableView = function createTableView(node, view, getPos, portal
|
|
|
249
249
|
isBreakoutEnabled = _getPluginState2.isBreakoutEnabled,
|
|
250
250
|
isFullWidthModeEnabled = _getPluginState2.isFullWidthModeEnabled,
|
|
251
251
|
wasFullWidthModeEnabled = _getPluginState2.wasFullWidthModeEnabled,
|
|
252
|
-
isTableResizingEnabled = _getPluginState2.isTableResizingEnabled
|
|
252
|
+
isTableResizingEnabled = _getPluginState2.isTableResizingEnabled,
|
|
253
|
+
isDragAndDropEnabled = _getPluginState2.isDragAndDropEnabled;
|
|
253
254
|
var _getPluginConfig = getPluginConfig(pluginConfig),
|
|
254
255
|
allowColumnResizing = _getPluginConfig.allowColumnResizing;
|
|
255
256
|
var hasIntlContext = true;
|
|
@@ -264,7 +265,8 @@ export var createTableView = function createTableView(node, view, getPos, portal
|
|
|
264
265
|
isBreakoutEnabled: isBreakoutEnabled,
|
|
265
266
|
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
266
267
|
wasFullWidthModeEnabled: wasFullWidthModeEnabled,
|
|
267
|
-
isTableResizingEnabled: isTableResizingEnabled
|
|
268
|
+
isTableResizingEnabled: isTableResizingEnabled,
|
|
269
|
+
isDragAndDropEnabled: isDragAndDropEnabled
|
|
268
270
|
},
|
|
269
271
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
270
272
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey
|
|
3
|
-
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
4
|
-
} from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
7
5
|
import { pluginKey as tablePluginKey } from '../plugin-key';
|
|
@@ -12,7 +10,7 @@ export var getDecorations = function getDecorations(state) {
|
|
|
12
10
|
return pluginKey.getState(state);
|
|
13
11
|
};
|
|
14
12
|
export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr, decorationSet, oldState, newState) {
|
|
15
|
-
var _tableWidthPluginKey$, _tableWidthPluginKey$2;
|
|
13
|
+
var _tableWidthPluginKey$, _tableWidthPluginKey$2, _tr$getMeta;
|
|
16
14
|
var isResizing = (_tableWidthPluginKey$ = tableWidthPluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
|
|
17
15
|
var wasResizing = (_tableWidthPluginKey$2 = tableWidthPluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
|
|
18
16
|
var changedResizing = isResizing !== wasResizing;
|
|
@@ -20,7 +18,7 @@ export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr
|
|
|
20
18
|
// Remove column controls when resizing
|
|
21
19
|
if (isResizing) {
|
|
22
20
|
return DecorationSet.empty;
|
|
23
|
-
} else if (tr.docChanged || tr.selection instanceof CellSelection || changedResizing) {
|
|
21
|
+
} else if (tr.docChanged || tr.selection instanceof CellSelection || changedResizing || ((_tr$getMeta = tr.getMeta(tablePluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.type) === 'HOVER_CELL') {
|
|
24
22
|
return buildColumnControlsDecorations({
|
|
25
23
|
decorationSet: decorationSet,
|
|
26
24
|
tr: tr
|
|
@@ -43,12 +41,16 @@ export var createPlugin = function createPlugin() {
|
|
|
43
41
|
return DecorationSet.empty;
|
|
44
42
|
},
|
|
45
43
|
apply: function apply(tr, decorationSet, oldState, newState) {
|
|
44
|
+
var _tablePluginKey$getSt, _tablePluginKey$getSt2;
|
|
46
45
|
var pluginState = decorationSet;
|
|
47
46
|
var meta = tr.getMeta(tablePluginKey);
|
|
47
|
+
var previousHover = (_tablePluginKey$getSt = tablePluginKey.getState(oldState)) === null || _tablePluginKey$getSt === void 0 ? void 0 : _tablePluginKey$getSt.hoveredCell;
|
|
48
|
+
var newHover = (_tablePluginKey$getSt2 = tablePluginKey.getState(newState)) === null || _tablePluginKey$getSt2 === void 0 ? void 0 : _tablePluginKey$getSt2.hoveredCell;
|
|
49
|
+
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);
|
|
48
50
|
if (meta && meta.data && meta.data.decorationSet) {
|
|
49
51
|
pluginState = meta.data.decorationSet;
|
|
50
52
|
}
|
|
51
|
-
if (tr.docChanged || tr.selectionSet || tr.getMeta(tableWidthPluginKey)) {
|
|
53
|
+
if (tr.docChanged || tr.selectionSet || tr.getMeta(tableWidthPluginKey) || changedCellHover) {
|
|
52
54
|
pluginState = pluginState.map(tr.mapping, tr.doc);
|
|
53
55
|
return handleDocOrSelectionChanged(tr, pluginState, oldState, newState);
|
|
54
56
|
}
|
|
@@ -4,6 +4,7 @@ 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';
|
|
7
8
|
import { composeDecorations } from './compose-decorations';
|
|
8
9
|
var isColumnSelected = function isColumnSelected(tr) {
|
|
9
10
|
return tr.selection instanceof CellSelection && tr.selection.isColSelection();
|
|
@@ -23,13 +24,17 @@ var maybeUpdateColumnSelectedDecoration = function maybeUpdateColumnSelectedDeco
|
|
|
23
24
|
return updateDecorations(tr.doc, decorationSet, createColumnSelectedDecoration(tr), TableDecorations.COLUMN_SELECTED);
|
|
24
25
|
};
|
|
25
26
|
var maybeUpdateColumnControlsDecoration = function maybeUpdateColumnControlsDecoration(_ref3) {
|
|
27
|
+
var _meta$data;
|
|
26
28
|
var decorationSet = _ref3.decorationSet,
|
|
27
29
|
tr = _ref3.tr;
|
|
28
30
|
var table = findTable(tr.selection);
|
|
29
|
-
|
|
31
|
+
var meta = tr.getMeta(tablePluginKey);
|
|
32
|
+
|
|
33
|
+
// avoid re-drawing state if dnd decorations don't need to be updated
|
|
34
|
+
if (!table && (meta === null || meta === void 0 ? void 0 : meta.type) !== 'HOVER_CELL') {
|
|
30
35
|
return decorationSet;
|
|
31
36
|
}
|
|
32
|
-
return updateDecorations(tr.doc, decorationSet, createColumnControlsDecoration(tr.selection), TableDecorations.COLUMN_CONTROLS_DECORATIONS);
|
|
37
|
+
return updateDecorations(tr.doc, decorationSet, createColumnControlsDecoration(tr.selection, meta === null || meta === void 0 || (_meta$data = meta.data) === null || _meta$data === void 0 ? void 0 : _meta$data.hoveredCell), TableDecorations.COLUMN_CONTROLS_DECORATIONS);
|
|
33
38
|
};
|
|
34
39
|
|
|
35
40
|
// @see: https://product-fabric.atlassian.net/browse/ED-7304
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
export var defaultTableSelection = {
|
|
2
2
|
hoveredColumns: [],
|
|
3
3
|
hoveredRows: []
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creating a separate object for hoveredCell so it doesn't get defaulted when `handleDocOrSelectionChanged` runs.
|
|
8
|
+
*
|
|
9
|
+
* It is safe to persist this value as it gets removed when the mouse cursor leaves the table, so no need to remove it
|
|
10
|
+
* when doc changes.
|
|
11
|
+
*/
|
|
12
|
+
export var defaultHoveredCell = {
|
|
13
|
+
hoveredCell: {
|
|
14
|
+
rowIndex: undefined,
|
|
15
|
+
colIndex: undefined
|
|
16
|
+
}
|
|
4
17
|
};
|
|
@@ -11,7 +11,7 @@ import { findTable } from '@atlaskit/editor-tables/utils';
|
|
|
11
11
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
12
|
import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
|
|
13
13
|
import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
14
|
-
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus } from '../event-handlers';
|
|
14
|
+
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
|
|
15
15
|
import { createTableView } from '../nodeviews/table';
|
|
16
16
|
import TableCell from '../nodeviews/TableCell';
|
|
17
17
|
import TableRow from '../nodeviews/TableRow';
|
|
@@ -20,12 +20,12 @@ import { fixTables, replaceSelectedTable } from '../transforms';
|
|
|
20
20
|
import { TableCssClassName as ClassName } from '../types';
|
|
21
21
|
import { findControlsHoverDecoration, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, transformSliceToRemoveOpenTable, updateResizeHandles } from '../utils';
|
|
22
22
|
import { isHeaderRowRequired } from '../utils/paste';
|
|
23
|
-
import { defaultTableSelection } from './default-table-selection';
|
|
23
|
+
import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
|
|
24
24
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
25
25
|
import { pluginKey } from './plugin-key';
|
|
26
|
-
export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled,
|
|
26
|
+
export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
27
27
|
var _window;
|
|
28
|
-
var state = createPluginState(dispatch, _objectSpread(_objectSpread({
|
|
28
|
+
var state = createPluginState(dispatch, _objectSpread(_objectSpread(_objectSpread({
|
|
29
29
|
pluginConfig: pluginConfig,
|
|
30
30
|
insertColumnButtonIndex: undefined,
|
|
31
31
|
insertRowButtonIndex: undefined,
|
|
@@ -36,7 +36,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
36
36
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
37
37
|
isHeaderColumnEnabled: false,
|
|
38
38
|
isDragAndDropEnabled: dragAndDropEnabled
|
|
39
|
-
}, defaultTableSelection), {}, {
|
|
39
|
+
}, defaultHoveredCell), defaultTableSelection), {}, {
|
|
40
40
|
getIntl: getIntl
|
|
41
41
|
}));
|
|
42
42
|
var elementContentRects = {};
|
|
@@ -240,8 +240,8 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
240
240
|
handleDOMEvents: {
|
|
241
241
|
focus: handleFocus,
|
|
242
242
|
blur: handleBlur,
|
|
243
|
-
mousedown: handleMouseDown,
|
|
244
|
-
mouseover: whenTableInFocus(handleMouseOver),
|
|
243
|
+
mousedown: withCellTracking(handleMouseDown),
|
|
244
|
+
mouseover: whenTableInFocus(withCellTracking(handleMouseOver)),
|
|
245
245
|
mouseleave: whenTableInFocus(handleMouseLeave),
|
|
246
246
|
mouseout: whenTableInFocus(handleMouseOut),
|
|
247
247
|
mousemove: whenTableInFocus(handleMouseMove, elementContentRects),
|
|
@@ -90,7 +90,8 @@ export default (function (pluginState, action) {
|
|
|
90
90
|
case 'HOVER_ROWS':
|
|
91
91
|
case 'HOVER_COLUMNS':
|
|
92
92
|
case 'HOVER_TABLE':
|
|
93
|
-
case '
|
|
93
|
+
case 'HOVER_MERGED_CELLS':
|
|
94
|
+
case 'HOVER_CELL':
|
|
94
95
|
case 'SHOW_RESIZE_HANDLE_LINE':
|
|
95
96
|
case 'SET_EDITOR_FOCUS':
|
|
96
97
|
return _objectSpread(_objectSpread({}, pluginState), action.data);
|
|
@@ -48,6 +48,7 @@ export var TableDecorations = /*#__PURE__*/function (TableDecorations) {
|
|
|
48
48
|
return TableDecorations;
|
|
49
49
|
}({});
|
|
50
50
|
export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssClassName), {}, {
|
|
51
|
+
/** Classic controls */
|
|
51
52
|
COLUMN_CONTROLS: "".concat(tablePrefixSelector, "-column-controls"),
|
|
52
53
|
COLUMN_CONTROLS_DECORATIONS: "".concat(tablePrefixSelector, "-column-controls-decoration"),
|
|
53
54
|
COLUMN_SELECTED: "".concat(tablePrefixSelector, "-column__selected"),
|
|
@@ -78,8 +79,13 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
|
|
|
78
79
|
CORNER_CONTROLS_INSERT_ROW_MARKER: "".concat(tablePrefixSelector, "-corner-controls__insert-row-marker"),
|
|
79
80
|
CORNER_CONTROLS_INSERT_COLUMN_MARKER: "".concat(tablePrefixSelector, "-corner-controls__insert-column-marker"),
|
|
80
81
|
CONTROLS_CORNER_BUTTON: "".concat(tablePrefixSelector, "-corner-button"),
|
|
82
|
+
/** Controls with drag handle */
|
|
83
|
+
COLUMN_CONTROLS_DECORATIONS_WITH_DRAG: "".concat(tablePrefixSelector, "-column-controls-decoration-with-drag"),
|
|
84
|
+
ROW_CONTROLS_WITH_DRAG: "".concat(tablePrefixSelector, "-row-controls-with-drag"),
|
|
85
|
+
/** Other classes */
|
|
81
86
|
NUMBERED_COLUMN: "".concat(tablePrefixSelector, "-numbered-column"),
|
|
82
87
|
NUMBERED_COLUMN_BUTTON: "".concat(tablePrefixSelector, "-numbered-column__button"),
|
|
88
|
+
NUMBERED_COLUMN_BUTTON_DISABLED: "".concat(tablePrefixSelector, "-numbered-column__button-disabled"),
|
|
83
89
|
HOVERED_COLUMN: "".concat(tablePrefixSelector, "-hovered-column"),
|
|
84
90
|
HOVERED_ROW: "".concat(tablePrefixSelector, "-hovered-row"),
|
|
85
91
|
HOVERED_TABLE: "".concat(tablePrefixSelector, "-hovered-table"),
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { DragHandleButton } from '@atlaskit/pragmatic-drag-and-drop-react-accessibility/drag-handle-button';
|
|
3
|
+
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
4
|
+
// TODO: use for now, in future replace with custom @atlaskit/icon/glyph/drag-handler
|
|
5
|
+
// width is too large (24px), should be 16px
|
|
6
|
+
export var DragHandle = function DragHandle(_ref) {
|
|
7
|
+
var tableLocalId = _ref.tableLocalId,
|
|
8
|
+
_ref$direction = _ref.direction,
|
|
9
|
+
direction = _ref$direction === void 0 ? 'row' : _ref$direction,
|
|
10
|
+
indexes = _ref.indexes,
|
|
11
|
+
onClick = _ref.onClick,
|
|
12
|
+
onMouseOver = _ref.onMouseOver,
|
|
13
|
+
onMouseOut = _ref.onMouseOut;
|
|
14
|
+
var dragHandleDivRef = useRef(null);
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
var dragHandleDivRefCurrent = dragHandleDivRef.current;
|
|
17
|
+
if (dragHandleDivRefCurrent) {
|
|
18
|
+
return draggable({
|
|
19
|
+
element: dragHandleDivRefCurrent,
|
|
20
|
+
getInitialData: function getInitialData() {
|
|
21
|
+
return {
|
|
22
|
+
localId: tableLocalId,
|
|
23
|
+
type: "table-".concat(direction),
|
|
24
|
+
indexes: indexes
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}, [tableLocalId, direction, indexes]);
|
|
30
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
ref: dragHandleDivRef,
|
|
32
|
+
style: {
|
|
33
|
+
backgroundColor: "var(--ds-surface, white)",
|
|
34
|
+
borderRadius: '4px',
|
|
35
|
+
border: "2px solid ".concat("var(--ds-surface, white)"),
|
|
36
|
+
transform: direction === 'column' ? 'rotate(90deg)' : 'none'
|
|
37
|
+
}
|
|
38
|
+
}, /*#__PURE__*/React.createElement(DragHandleButton, {
|
|
39
|
+
label: "blah"
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
3
|
+
import { DragInMotionIcon } from '../Icons/DragInMotionIcon';
|
|
4
|
+
var boxStyles = xcss({
|
|
5
|
+
borderColor: 'color.border.focused',
|
|
6
|
+
borderStyle: 'solid',
|
|
7
|
+
borderRadius: 'border.radius.100',
|
|
8
|
+
borderWidth: 'border.width.outline',
|
|
9
|
+
backgroundColor: 'color.blanket.selected'
|
|
10
|
+
});
|
|
11
|
+
export var DragPreview = function DragPreview(_ref) {
|
|
12
|
+
var direction = _ref.direction,
|
|
13
|
+
width = _ref.width,
|
|
14
|
+
height = _ref.height;
|
|
15
|
+
var marginLeft = direction === 'row' ? -14 : width / 2 - 14;
|
|
16
|
+
var marginTop = direction === 'row' ? height / 2 - 14 : -10;
|
|
17
|
+
var transform = direction === 'row' ? 'rotate(90deg)' : 'none';
|
|
18
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
19
|
+
xcss: boxStyles,
|
|
20
|
+
style: {
|
|
21
|
+
width: "".concat(width, "px"),
|
|
22
|
+
height: "".concat(height, "px")
|
|
23
|
+
}
|
|
24
|
+
}, /*#__PURE__*/React.createElement(DragInMotionIcon, {
|
|
25
|
+
style: {
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
marginLeft: "".concat(marginLeft, "px"),
|
|
28
|
+
marginTop: "".concat(marginTop, "px"),
|
|
29
|
+
transform: transform
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
};
|