@atlaskit/editor-plugin-table 5.3.15 → 5.3.17
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 +14 -0
- package/dist/cjs/plugins/table/event-handlers.js +4 -3
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/cjs/plugins/table/types.js +5 -3
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +5 -0
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -11
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +114 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.js +60 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +11 -112
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/types.js +5 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +1 -7
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +7 -2
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/messages.js +5 -0
- package/dist/cjs/plugins/table/ui/ui-styles.js +28 -25
- package/dist/cjs/plugins/table/utils/dom.js +16 -7
- package/dist/cjs/plugins/table/utils/index.js +12 -6
- package/dist/es2019/plugins/table/event-handlers.js +5 -4
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +2 -1
- package/dist/es2019/plugins/table/types.js +5 -3
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +5 -0
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -11
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +93 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.js +61 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -99
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/types.js +1 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +1 -7
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +8 -3
- package/dist/es2019/plugins/table/ui/common-styles.js +8 -6
- package/dist/es2019/plugins/table/ui/messages.js +5 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +44 -3
- package/dist/es2019/plugins/table/utils/dom.js +13 -6
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/event-handlers.js +5 -4
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +2 -1
- package/dist/esm/plugins/table/types.js +5 -3
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +5 -0
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -11
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +104 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.js +50 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -110
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/types.js +1 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +1 -7
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +8 -3
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/ui/messages.js +5 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +27 -24
- package/dist/esm/plugins/table/utils/dom.js +15 -6
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/types.d.ts +5 -3
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.d.ts +6 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +6 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +2 -16
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/types.d.ts +11 -0
- package/dist/types/plugins/table/ui/messages.d.ts +5 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types/plugins/table/utils/dom.d.ts +3 -2
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +5 -3
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +2 -16
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/types.d.ts +11 -0
- package/dist/types-ts4.5/plugins/table/ui/messages.d.ts +5 -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 +3 -2
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +4 -4
- package/src/plugins/table/event-handlers.ts +7 -2
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +7 -1
- package/src/plugins/table/types.ts +7 -4
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +8 -0
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +5 -7
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +2 -2
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +1 -1
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +107 -0
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +66 -0
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +2 -125
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/types.ts +12 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +3 -3
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +22 -14
- package/src/plugins/table/ui/common-styles.ts +8 -5
- package/src/plugins/table/ui/messages.ts +6 -0
- package/src/plugins/table/ui/ui-styles.ts +45 -3
- package/src/plugins/table/utils/dom.ts +16 -4
- package/src/plugins/table/utils/index.ts +2 -1
|
@@ -17,7 +17,12 @@ import {
|
|
|
17
17
|
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
18
18
|
|
|
19
19
|
import { DragAndDropActionType } from './actions';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
clearDropTarget,
|
|
22
|
+
moveSource,
|
|
23
|
+
setDropTarget,
|
|
24
|
+
toggleDragMenu,
|
|
25
|
+
} from './commands';
|
|
21
26
|
import { DropTargetType } from './consts';
|
|
22
27
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
23
28
|
import { pluginKey } from './plugin-key';
|
|
@@ -99,6 +104,7 @@ export const createPlugin = (
|
|
|
99
104
|
},
|
|
100
105
|
onDragStart: ({ location }) => {
|
|
101
106
|
autoScroller.start({ input: location.current.input });
|
|
107
|
+
toggleDragMenu(false)(editorView.state, editorView.dispatch);
|
|
102
108
|
},
|
|
103
109
|
onDrag(event) {
|
|
104
110
|
autoScroller.updateInput({
|
|
@@ -273,10 +273,6 @@ export const TableCssClassName = {
|
|
|
273
273
|
COLUMN_CONTROLS_DECORATIONS: `${tablePrefixSelector}-column-controls-decoration`,
|
|
274
274
|
COLUMN_SELECTED: `${tablePrefixSelector}-column__selected`,
|
|
275
275
|
|
|
276
|
-
COLUMN_CONTROLS_WRAPPER: `${tablePrefixSelector}-col-controls-wrapper`,
|
|
277
|
-
COLUMN_DROP_TARGET_CONTROLS: `${tablePrefixSelector}-col-drop-target-controls`,
|
|
278
|
-
COLUMN_CONTROLS_INNER: `${tablePrefixSelector}-col-controls__inner`,
|
|
279
|
-
|
|
280
276
|
ROW_CONTROLS_WRAPPER: `${tablePrefixSelector}-row-controls-wrapper`,
|
|
281
277
|
ROW_CONTROLS: `${tablePrefixSelector}-row-controls`,
|
|
282
278
|
ROW_CONTROLS_INNER: `${tablePrefixSelector}-row-controls__inner`,
|
|
@@ -320,8 +316,15 @@ export const TableCssClassName = {
|
|
|
320
316
|
DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER: `${tablePrefixSelector}-drag-columns-floating-insert-dot-wrapper`,
|
|
321
317
|
DRAG_COLUMN_FLOATING_INSERT_DOT: `${tablePrefixSelector}-drag-columns-floating-insert-dot`,
|
|
322
318
|
|
|
319
|
+
DRAG_COLUMN_CONTROLS_WRAPPER: `${tablePrefixSelector}-col-controls-wrapper`,
|
|
320
|
+
DRAG_COLUMN_DROP_TARGET_CONTROLS: `${tablePrefixSelector}-col-drop-target-controls`,
|
|
321
|
+
DRAG_COLUMN_CONTROLS_INNER: `${tablePrefixSelector}-col-controls__inner`,
|
|
322
|
+
|
|
323
323
|
DRAG_HANDLE_BUTTON_CONTAINER: `${tablePrefixSelector}-drag-handle-button-container`,
|
|
324
324
|
|
|
325
|
+
DRAG_CORNER_BUTTON: `${tablePrefixSelector}-drag-corner-button`,
|
|
326
|
+
DRAG_CORNER_BUTTON_INNER: `${tablePrefixSelector}-drag-corner-button-inner`,
|
|
327
|
+
|
|
325
328
|
/** Other classes */
|
|
326
329
|
NUMBERED_COLUMN: `${tablePrefixSelector}-numbered-column`,
|
|
327
330
|
NUMBERED_COLUMN_BUTTON: `${tablePrefixSelector}-numbered-column__button`,
|
|
@@ -81,6 +81,14 @@ export class FloatingInsertButton extends React.Component<
|
|
|
81
81
|
dispatchAnalyticsEvent,
|
|
82
82
|
} = this.props;
|
|
83
83
|
|
|
84
|
+
// TODO: temporarily disable insert button for first column and row https://atlassian.slack.com/archives/C05U8HRQM50/p1698363744682219?thread_ts=1698209039.104909&cid=C05U8HRQM50
|
|
85
|
+
if (
|
|
86
|
+
isDragAndDropEnabled &&
|
|
87
|
+
(insertColumnButtonIndex === 0 || insertRowButtonIndex === 0)
|
|
88
|
+
) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
84
92
|
const type =
|
|
85
93
|
typeof insertColumnButtonIndex !== 'undefined'
|
|
86
94
|
? 'column'
|
|
@@ -5,7 +5,6 @@ import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
7
7
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
8
|
-
import { token } from '@atlaskit/tokens';
|
|
9
8
|
|
|
10
9
|
import {
|
|
11
10
|
clearHoverSelection,
|
|
@@ -108,7 +107,7 @@ export const ColumnControls = ({
|
|
|
108
107
|
return (
|
|
109
108
|
<div className={ClassName.DRAG_COLUMN_CONTROLS}>
|
|
110
109
|
<div
|
|
111
|
-
className={ClassName.
|
|
110
|
+
className={ClassName.DRAG_COLUMN_CONTROLS_INNER}
|
|
112
111
|
data-testid="table-floating-column-controls"
|
|
113
112
|
style={{
|
|
114
113
|
gridTemplateColumns: widths,
|
|
@@ -127,7 +126,8 @@ export const ColumnControls = ({
|
|
|
127
126
|
contentEditable={false}
|
|
128
127
|
key={index}
|
|
129
128
|
>
|
|
130
|
-
{
|
|
129
|
+
{/* TODO: Disabling first column insert button https://atlassian.slack.com/archives/C05U8HRQM50/p1698363744682219?thread_ts=1698209039.104909&cid=C05U8HRQM50 */}
|
|
130
|
+
{/* {!hasHeaderColumn && index === 0 && (
|
|
131
131
|
<div
|
|
132
132
|
style={{
|
|
133
133
|
left: '0px',
|
|
@@ -135,7 +135,7 @@ export const ColumnControls = ({
|
|
|
135
135
|
}}
|
|
136
136
|
className={ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT}
|
|
137
137
|
/>
|
|
138
|
-
)}
|
|
138
|
+
)} */}
|
|
139
139
|
<div
|
|
140
140
|
className={ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT}
|
|
141
141
|
style={columnParams.length - 1 === index ? { right: '0' } : {}}
|
|
@@ -149,12 +149,10 @@ export const ColumnControls = ({
|
|
|
149
149
|
<div
|
|
150
150
|
style={{
|
|
151
151
|
gridColumn: gridColumnPosition,
|
|
152
|
-
zIndex: 99,
|
|
153
152
|
display: 'flex',
|
|
154
|
-
width: '100%',
|
|
155
153
|
justifyContent: 'center',
|
|
156
154
|
alignItems: 'center',
|
|
157
|
-
|
|
155
|
+
zIndex: 99,
|
|
158
156
|
}}
|
|
159
157
|
data-column-control-index={hoveredCell.colIndex}
|
|
160
158
|
data-testid="table-floating-column-control"
|
|
@@ -35,11 +35,11 @@ export const ColumnDropTargets: React.FC<Props> = ({
|
|
|
35
35
|
|
|
36
36
|
return (
|
|
37
37
|
<div
|
|
38
|
-
className={ClassName.
|
|
38
|
+
className={ClassName.DRAG_COLUMN_DROP_TARGET_CONTROLS}
|
|
39
39
|
contentEditable={false}
|
|
40
40
|
>
|
|
41
41
|
<div
|
|
42
|
-
className={ClassName.
|
|
42
|
+
className={ClassName.DRAG_COLUMN_CONTROLS_INNER}
|
|
43
43
|
data-testid="table-floating-column-controls-drop-targets"
|
|
44
44
|
>
|
|
45
45
|
{colWidths?.map((width, index) => {
|
|
@@ -129,7 +129,7 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
|
|
|
129
129
|
|
|
130
130
|
return ReactDOM.createPortal(
|
|
131
131
|
<div
|
|
132
|
-
className={ClassName.
|
|
132
|
+
className={ClassName.DRAG_COLUMN_CONTROLS_WRAPPER}
|
|
133
133
|
data-testid="table-floating-column-controls-wrapper"
|
|
134
134
|
>
|
|
135
135
|
<ColumnControls
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
5
|
+
import { injectIntl } from 'react-intl-next';
|
|
6
|
+
|
|
7
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
8
|
+
import {
|
|
9
|
+
findTable,
|
|
10
|
+
isTableSelected,
|
|
11
|
+
selectTable,
|
|
12
|
+
} from '@atlaskit/editor-tables/utils';
|
|
13
|
+
|
|
14
|
+
import { clearHoverSelection, hoverTable } from '../../../commands';
|
|
15
|
+
import { TableCssClassName as ClassName } from '../../../types';
|
|
16
|
+
import messages from '../../messages';
|
|
17
|
+
|
|
18
|
+
import type { CornerControlProps } from './types';
|
|
19
|
+
|
|
20
|
+
class CornerControlComponent extends Component<
|
|
21
|
+
CornerControlProps & WrappedComponentProps,
|
|
22
|
+
any
|
|
23
|
+
> {
|
|
24
|
+
render() {
|
|
25
|
+
const {
|
|
26
|
+
isInDanger,
|
|
27
|
+
tableRef,
|
|
28
|
+
isHeaderColumnEnabled,
|
|
29
|
+
isHeaderRowEnabled,
|
|
30
|
+
intl: { formatMessage },
|
|
31
|
+
} = this.props;
|
|
32
|
+
if (!tableRef) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const isActive = this.isActive();
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
className={classnames(ClassName.CORNER_CONTROLS, {
|
|
40
|
+
active: isActive,
|
|
41
|
+
sticky: this.props.stickyTop !== undefined,
|
|
42
|
+
})}
|
|
43
|
+
style={{
|
|
44
|
+
top:
|
|
45
|
+
this.props.stickyTop !== undefined
|
|
46
|
+
? `${this.props.stickyTop}px`
|
|
47
|
+
: undefined,
|
|
48
|
+
}}
|
|
49
|
+
contentEditable={false}
|
|
50
|
+
>
|
|
51
|
+
<button
|
|
52
|
+
aria-label={formatMessage(messages.cornerControl)}
|
|
53
|
+
type="button"
|
|
54
|
+
className={classnames(ClassName.CONTROLS_CORNER_BUTTON, {
|
|
55
|
+
danger: isActive && isInDanger,
|
|
56
|
+
})}
|
|
57
|
+
onClick={this.selectTable}
|
|
58
|
+
onMouseOver={this.hoverTable}
|
|
59
|
+
onMouseOut={this.clearHoverSelection}
|
|
60
|
+
/>
|
|
61
|
+
|
|
62
|
+
{!isHeaderRowEnabled && (
|
|
63
|
+
<div className={ClassName.CORNER_CONTROLS_INSERT_ROW_MARKER}>
|
|
64
|
+
<div className={ClassName.CONTROLS_INSERT_MARKER} />
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
{!isHeaderColumnEnabled && (
|
|
68
|
+
<div className={ClassName.CORNER_CONTROLS_INSERT_COLUMN_MARKER}>
|
|
69
|
+
<div className={ClassName.CONTROLS_INSERT_MARKER} />
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private isActive = () => {
|
|
77
|
+
const { editorView, hoveredRows, isResizing } = this.props;
|
|
78
|
+
const { selection } = editorView.state;
|
|
79
|
+
const table = findTable(selection);
|
|
80
|
+
if (!table) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return (
|
|
84
|
+
isTableSelected(selection) ||
|
|
85
|
+
(hoveredRows &&
|
|
86
|
+
hoveredRows.length === TableMap.get(table.node).height &&
|
|
87
|
+
!isResizing)
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
private clearHoverSelection = () => {
|
|
92
|
+
const { state, dispatch } = this.props.editorView;
|
|
93
|
+
clearHoverSelection()(state, dispatch);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
private selectTable = () => {
|
|
97
|
+
const { state, dispatch } = this.props.editorView;
|
|
98
|
+
dispatch(selectTable(state.tr).setMeta('addToHistory', false));
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
private hoverTable = () => {
|
|
102
|
+
const { state, dispatch } = this.props.editorView;
|
|
103
|
+
hoverTable()(state, dispatch);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const CornerControls = injectIntl(CornerControlComponent);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
5
|
+
import { injectIntl } from 'react-intl-next';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
findTable,
|
|
9
|
+
isTableSelected,
|
|
10
|
+
selectTable,
|
|
11
|
+
} from '@atlaskit/editor-tables/utils';
|
|
12
|
+
|
|
13
|
+
import { clearHoverSelection, hoverTable } from '../../../commands';
|
|
14
|
+
import { TableCssClassName as ClassName } from '../../../types';
|
|
15
|
+
import messages from '../../messages';
|
|
16
|
+
|
|
17
|
+
import type { CornerControlProps } from './types';
|
|
18
|
+
|
|
19
|
+
const DragCornerControlsComponent = ({
|
|
20
|
+
editorView,
|
|
21
|
+
isInDanger,
|
|
22
|
+
intl: { formatMessage },
|
|
23
|
+
}: CornerControlProps & WrappedComponentProps) => {
|
|
24
|
+
const handleOnClick = () => {
|
|
25
|
+
const { state, dispatch } = editorView;
|
|
26
|
+
dispatch(selectTable(state.tr).setMeta('addToHistory', false));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const handleMouseOver = () => {
|
|
30
|
+
const { state, dispatch } = editorView;
|
|
31
|
+
hoverTable()(state, dispatch);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const handleMouseOut = () => {
|
|
35
|
+
const { state, dispatch } = editorView;
|
|
36
|
+
clearHoverSelection()(state, dispatch);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const isActive = useMemo(() => {
|
|
40
|
+
const { selection } = editorView.state;
|
|
41
|
+
const table = findTable(selection);
|
|
42
|
+
if (!table) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return isTableSelected(selection);
|
|
46
|
+
}, [editorView.state]);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<button
|
|
50
|
+
className={classnames(ClassName.DRAG_CORNER_BUTTON, {
|
|
51
|
+
active: isActive,
|
|
52
|
+
danger: isActive && isInDanger,
|
|
53
|
+
})}
|
|
54
|
+
aria-label={formatMessage(messages.cornerControl)}
|
|
55
|
+
type="button"
|
|
56
|
+
onClick={handleOnClick}
|
|
57
|
+
onMouseOver={handleMouseOver}
|
|
58
|
+
onMouseOut={handleMouseOut}
|
|
59
|
+
contentEditable={false}
|
|
60
|
+
>
|
|
61
|
+
<div className={ClassName.DRAG_CORNER_BUTTON_INNER} />
|
|
62
|
+
</button>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const DragCornerControls = injectIntl(DragCornerControlsComponent);
|
|
@@ -1,125 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import classnames from 'classnames';
|
|
4
|
-
import type { WrappedComponentProps } from 'react-intl-next';
|
|
5
|
-
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
6
|
-
|
|
7
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
-
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
|
-
import {
|
|
10
|
-
findTable,
|
|
11
|
-
isTableSelected,
|
|
12
|
-
selectTable,
|
|
13
|
-
} from '@atlaskit/editor-tables/utils';
|
|
14
|
-
|
|
15
|
-
import { clearHoverSelection, hoverTable } from '../../../commands';
|
|
16
|
-
import { TableCssClassName as ClassName } from '../../../types';
|
|
17
|
-
|
|
18
|
-
const messages = defineMessages({
|
|
19
|
-
cornerControl: {
|
|
20
|
-
id: 'fabric.editor.cornerControl',
|
|
21
|
-
defaultMessage: 'Highlight table',
|
|
22
|
-
description:
|
|
23
|
-
'A button on the upper left corner of the table that shows up when the table is in focus. Clicking on it will select the entire table.',
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export interface Props {
|
|
28
|
-
editorView: EditorView;
|
|
29
|
-
tableRef?: HTMLTableElement;
|
|
30
|
-
isInDanger?: boolean;
|
|
31
|
-
isResizing?: boolean;
|
|
32
|
-
hoveredRows?: number[];
|
|
33
|
-
isHeaderColumnEnabled?: boolean;
|
|
34
|
-
isHeaderRowEnabled?: boolean;
|
|
35
|
-
stickyTop?: number;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
class CornerControlComponent extends Component<
|
|
39
|
-
Props & WrappedComponentProps,
|
|
40
|
-
any
|
|
41
|
-
> {
|
|
42
|
-
render() {
|
|
43
|
-
const {
|
|
44
|
-
isInDanger,
|
|
45
|
-
tableRef,
|
|
46
|
-
isHeaderColumnEnabled,
|
|
47
|
-
isHeaderRowEnabled,
|
|
48
|
-
intl: { formatMessage },
|
|
49
|
-
} = this.props;
|
|
50
|
-
if (!tableRef) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const isActive = this.isActive();
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<div
|
|
57
|
-
className={classnames(ClassName.CORNER_CONTROLS, {
|
|
58
|
-
active: isActive,
|
|
59
|
-
sticky: this.props.stickyTop !== undefined,
|
|
60
|
-
})}
|
|
61
|
-
style={{
|
|
62
|
-
top:
|
|
63
|
-
this.props.stickyTop !== undefined
|
|
64
|
-
? `${this.props.stickyTop}px`
|
|
65
|
-
: undefined,
|
|
66
|
-
}}
|
|
67
|
-
contentEditable={false}
|
|
68
|
-
>
|
|
69
|
-
<button
|
|
70
|
-
aria-label={formatMessage(messages.cornerControl)}
|
|
71
|
-
type="button"
|
|
72
|
-
className={classnames(ClassName.CONTROLS_CORNER_BUTTON, {
|
|
73
|
-
danger: isActive && isInDanger,
|
|
74
|
-
})}
|
|
75
|
-
onClick={this.selectTable}
|
|
76
|
-
onMouseOver={this.hoverTable}
|
|
77
|
-
onMouseOut={this.clearHoverSelection}
|
|
78
|
-
/>
|
|
79
|
-
|
|
80
|
-
{!isHeaderRowEnabled && (
|
|
81
|
-
<div className={ClassName.CORNER_CONTROLS_INSERT_ROW_MARKER}>
|
|
82
|
-
<div className={ClassName.CONTROLS_INSERT_MARKER} />
|
|
83
|
-
</div>
|
|
84
|
-
)}
|
|
85
|
-
{!isHeaderColumnEnabled && (
|
|
86
|
-
<div className={ClassName.CORNER_CONTROLS_INSERT_COLUMN_MARKER}>
|
|
87
|
-
<div className={ClassName.CONTROLS_INSERT_MARKER} />
|
|
88
|
-
</div>
|
|
89
|
-
)}
|
|
90
|
-
</div>
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
private isActive = () => {
|
|
95
|
-
const { editorView, hoveredRows, isResizing } = this.props;
|
|
96
|
-
const { selection } = editorView.state;
|
|
97
|
-
const table = findTable(selection);
|
|
98
|
-
if (!table) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
return (
|
|
102
|
-
isTableSelected(selection) ||
|
|
103
|
-
(hoveredRows &&
|
|
104
|
-
hoveredRows.length === TableMap.get(table.node).height &&
|
|
105
|
-
!isResizing)
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
private clearHoverSelection = () => {
|
|
110
|
-
const { state, dispatch } = this.props.editorView;
|
|
111
|
-
clearHoverSelection()(state, dispatch);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
private selectTable = () => {
|
|
115
|
-
const { state, dispatch } = this.props.editorView;
|
|
116
|
-
dispatch(selectTable(state.tr).setMeta('addToHistory', false));
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
private hoverTable = () => {
|
|
120
|
-
const { state, dispatch } = this.props.editorView;
|
|
121
|
-
hoverTable()(state, dispatch);
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export const CornerControls = injectIntl(CornerControlComponent);
|
|
1
|
+
export { CornerControls } from './ClassicCornerControls';
|
|
2
|
+
export { DragCornerControls } from './DragCornerControls';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
|
|
3
|
+
export type CornerControlProps = {
|
|
4
|
+
editorView: EditorView;
|
|
5
|
+
tableRef?: HTMLTableElement;
|
|
6
|
+
isInDanger?: boolean;
|
|
7
|
+
isResizing?: boolean;
|
|
8
|
+
hoveredRows?: number[];
|
|
9
|
+
isHeaderColumnEnabled?: boolean;
|
|
10
|
+
isHeaderRowEnabled?: boolean;
|
|
11
|
+
stickyTop?: number;
|
|
12
|
+
};
|
|
@@ -9,7 +9,6 @@ import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
|
9
9
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
11
11
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
12
|
-
import { token } from '@atlaskit/tokens';
|
|
13
12
|
|
|
14
13
|
import { clearHoverSelection } from '../../../commands';
|
|
15
14
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
@@ -141,7 +140,8 @@ const DragControlsComponent = ({
|
|
|
141
140
|
contentEditable={false}
|
|
142
141
|
key={index}
|
|
143
142
|
>
|
|
144
|
-
{
|
|
143
|
+
{/* TODO: Disabling first column insert button https://atlassian.slack.com/archives/C05U8HRQM50/p1698363744682219?thread_ts=1698209039.104909&cid=C05U8HRQM50 */}
|
|
144
|
+
{/* {!hasHeaderRow && index === 0 && (
|
|
145
145
|
<div
|
|
146
146
|
style={{
|
|
147
147
|
top: '0px',
|
|
@@ -149,7 +149,7 @@ const DragControlsComponent = ({
|
|
|
149
149
|
}}
|
|
150
150
|
className={ClassName.DRAG_ROW_FLOATING_INSERT_DOT}
|
|
151
151
|
/>
|
|
152
|
-
)}
|
|
152
|
+
)} */}
|
|
153
153
|
<div className={ClassName.DRAG_ROW_FLOATING_INSERT_DOT} />
|
|
154
154
|
</div>
|
|
155
155
|
))}
|
|
@@ -12,7 +12,7 @@ import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
|
12
12
|
import type { CellHoverMeta } from '../../types';
|
|
13
13
|
import { isSelectionUpdated } from '../../utils';
|
|
14
14
|
|
|
15
|
-
import { CornerControls } from './CornerControls';
|
|
15
|
+
import { CornerControls, DragCornerControls } from './CornerControls';
|
|
16
16
|
import NumberColumn from './NumberColumn';
|
|
17
17
|
import { DragControls, RowControls } from './RowControls';
|
|
18
18
|
|
|
@@ -159,19 +159,27 @@ export default class TableFloatingControls extends Component<Props, State> {
|
|
|
159
159
|
{tableActive && (
|
|
160
160
|
<>
|
|
161
161
|
{isDragAndDropEnabled ? (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
<>
|
|
163
|
+
<DragCornerControls
|
|
164
|
+
editorView={editorView}
|
|
165
|
+
tableRef={tableRef}
|
|
166
|
+
isInDanger={isInDanger}
|
|
167
|
+
isResizing={isResizing}
|
|
168
|
+
/>
|
|
169
|
+
<DragControls
|
|
170
|
+
tableRef={tableRef}
|
|
171
|
+
tableNode={tableNode}
|
|
172
|
+
hoveredCell={hoveredCell}
|
|
173
|
+
editorView={editorView}
|
|
174
|
+
tableActive={tableActive}
|
|
175
|
+
isInDanger={isInDanger}
|
|
176
|
+
isResizing={isResizing}
|
|
177
|
+
hasHeaderRow={hasHeaderRow}
|
|
178
|
+
hoverRows={this.hoverRows}
|
|
179
|
+
selectRow={this.selectRow}
|
|
180
|
+
updateCellHoverLocation={this.updateCellHoverLocation}
|
|
181
|
+
/>
|
|
182
|
+
</>
|
|
175
183
|
) : (
|
|
176
184
|
<>
|
|
177
185
|
<CornerControls
|
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
columnControlsDecoration,
|
|
57
57
|
columnControlsLineMarker,
|
|
58
58
|
DeleteButton,
|
|
59
|
+
dragCornerControlButton,
|
|
59
60
|
dragInsertButtonWrapper,
|
|
60
61
|
floatingColumnControls,
|
|
61
62
|
HeaderButton,
|
|
@@ -360,6 +361,8 @@ export const tableStyles = (
|
|
|
360
361
|
|
|
361
362
|
${dragInsertButtonWrapper(props)}
|
|
362
363
|
|
|
364
|
+
${dragCornerControlButton(props)}
|
|
365
|
+
|
|
363
366
|
/* Delete button */
|
|
364
367
|
${DeleteButton(props)}
|
|
365
368
|
/* Ends Delete button */
|
|
@@ -543,7 +546,7 @@ export const tableStyles = (
|
|
|
543
546
|
}
|
|
544
547
|
}
|
|
545
548
|
|
|
546
|
-
.${ClassName.
|
|
549
|
+
.${ClassName.DRAG_COLUMN_CONTROLS_WRAPPER} {
|
|
547
550
|
padding: 0 ${tablePadding}px;
|
|
548
551
|
}
|
|
549
552
|
|
|
@@ -732,11 +735,11 @@ export const tableStyles = (
|
|
|
732
735
|
}
|
|
733
736
|
|
|
734
737
|
.${ClassName.DRAG_COLUMN_CONTROLS} {
|
|
735
|
-
.${ClassName.
|
|
738
|
+
.${ClassName.DRAG_COLUMN_CONTROLS_INNER} {
|
|
736
739
|
height: 24px;
|
|
737
740
|
position: absolute;
|
|
738
741
|
top: ${token('space.negative.150', '-12px')};
|
|
739
|
-
z-index: ${akEditorUnitZIndex};
|
|
742
|
+
z-index: ${akEditorUnitZIndex * 13};
|
|
740
743
|
}
|
|
741
744
|
|
|
742
745
|
.${ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER} {
|
|
@@ -1031,9 +1034,9 @@ export const tableStyles = (
|
|
|
1031
1034
|
z-index: ${akEditorUnitZIndex};
|
|
1032
1035
|
}
|
|
1033
1036
|
|
|
1034
|
-
.${ClassName.
|
|
1037
|
+
.${ClassName.DRAG_COLUMN_CONTROLS_WRAPPER} {
|
|
1035
1038
|
position: absolute;
|
|
1036
|
-
top: ${tableMarginTop
|
|
1039
|
+
top: ${tableMarginTop}px;
|
|
1037
1040
|
}
|
|
1038
1041
|
|
|
1039
1042
|
${tableWrapperStyles()}
|
|
@@ -65,4 +65,10 @@ export default defineMessages({
|
|
|
65
65
|
defaultMessage: 'Adjust column',
|
|
66
66
|
description: 'Tooltip displayed on table column resize handle',
|
|
67
67
|
},
|
|
68
|
+
cornerControl: {
|
|
69
|
+
id: 'fabric.editor.cornerControl',
|
|
70
|
+
defaultMessage: 'Highlight table',
|
|
71
|
+
description:
|
|
72
|
+
'A button on the upper left corner of the table that shows up when the table is in focus. Clicking on it will select the entire table.',
|
|
73
|
+
},
|
|
68
74
|
});
|
|
@@ -187,6 +187,7 @@ export const dragInsertButtonWrapper = (props: ThemeProps) => css`
|
|
|
187
187
|
bottom: -5px;
|
|
188
188
|
left: 3px;
|
|
189
189
|
}
|
|
190
|
+
|
|
190
191
|
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON} {
|
|
191
192
|
${Button(`
|
|
192
193
|
background: ${token('elevation.surface.overlay', 'white')};
|
|
@@ -198,6 +199,7 @@ export const dragInsertButtonWrapper = (props: ThemeProps) => css`
|
|
|
198
199
|
border-radius: 50%;
|
|
199
200
|
`)}
|
|
200
201
|
}
|
|
202
|
+
|
|
201
203
|
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON}:hover {
|
|
202
204
|
background: ${token('color.background.brand.bold', B300)};
|
|
203
205
|
border: 1px solid ${token('color.background.brand.bold', B300)};
|
|
@@ -206,6 +208,46 @@ export const dragInsertButtonWrapper = (props: ThemeProps) => css`
|
|
|
206
208
|
}
|
|
207
209
|
`;
|
|
208
210
|
|
|
211
|
+
export const dragCornerControlButton = (props: ThemeProps) => css`
|
|
212
|
+
.${ClassName.DRAG_CORNER_BUTTON} {
|
|
213
|
+
width: 12px;
|
|
214
|
+
height: 12px;
|
|
215
|
+
display: flex;
|
|
216
|
+
justify-content: center;
|
|
217
|
+
align-items: center;
|
|
218
|
+
position: absolute;
|
|
219
|
+
top: ${token('space.negative.075', '-6px')};
|
|
220
|
+
left: ${token('space.075', '6px')};
|
|
221
|
+
background-color: ${token('elevation.surface', '#FFF')};
|
|
222
|
+
border-radius: 50%;
|
|
223
|
+
border: none;
|
|
224
|
+
padding: 0;
|
|
225
|
+
outline: none;
|
|
226
|
+
z-index: ${akEditorUnitZIndex * 99};
|
|
227
|
+
|
|
228
|
+
&.active .${ClassName.DRAG_CORNER_BUTTON_INNER} {
|
|
229
|
+
background-color: ${token('color.border.selected', '#0C66E4')};
|
|
230
|
+
border-color: ${token('color.border.selected', '#0C66E4')};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
&:hover {
|
|
234
|
+
cursor: pointer;
|
|
235
|
+
|
|
236
|
+
.${ClassName.DRAG_CORNER_BUTTON_INNER} {
|
|
237
|
+
border-color: ${token('color.border.selected', '#0C66E4')};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.${ClassName.DRAG_CORNER_BUTTON_INNER} {
|
|
243
|
+
border: 1px solid
|
|
244
|
+
${token('color.background.accent.gray.subtler', '#DCDFE4')};
|
|
245
|
+
border-radius: 50%;
|
|
246
|
+
width: 6px;
|
|
247
|
+
height: 6px;
|
|
248
|
+
}
|
|
249
|
+
`;
|
|
250
|
+
|
|
209
251
|
export const insertColumnButtonWrapper = (props: ThemeProps) => css`
|
|
210
252
|
${InsertButton()}
|
|
211
253
|
${InsertButtonHover()}
|
|
@@ -403,12 +445,12 @@ const getFloatingDotOverrides = (props: ThemeProps) => {
|
|
|
403
445
|
|
|
404
446
|
export const floatingColumnControls = (props: ThemeProps) => {
|
|
405
447
|
return css`
|
|
406
|
-
.${ClassName.
|
|
448
|
+
.${ClassName.DRAG_COLUMN_DROP_TARGET_CONTROLS} {
|
|
407
449
|
box-sizing: border-box;
|
|
408
450
|
position: absolute;
|
|
409
451
|
top: 0;
|
|
410
452
|
|
|
411
|
-
.${ClassName.
|
|
453
|
+
.${ClassName.DRAG_COLUMN_CONTROLS_INNER} {
|
|
412
454
|
display: flex;
|
|
413
455
|
flex-direction: row;
|
|
414
456
|
}
|
|
@@ -417,7 +459,7 @@ export const floatingColumnControls = (props: ThemeProps) => {
|
|
|
417
459
|
.${ClassName.DRAG_COLUMN_CONTROLS} {
|
|
418
460
|
box-sizing: border-box;
|
|
419
461
|
|
|
420
|
-
.${ClassName.
|
|
462
|
+
.${ClassName.DRAG_COLUMN_CONTROLS_INNER} {
|
|
421
463
|
display: grid;
|
|
422
464
|
justify-items: center;
|
|
423
465
|
}
|