@atlaskit/editor-plugin-table 7.6.2 → 7.6.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 +6 -0
- package/dist/cjs/nodeviews/TableComponent.js +25 -11
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +87 -0
- package/dist/cjs/nodeviews/TableContainer.js +8 -4
- package/dist/cjs/nodeviews/TableResizer.js +4 -5
- package/dist/cjs/nodeviews/table.js +21 -1
- package/dist/cjs/plugin.js +24 -2
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -2
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +5 -2
- package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +48 -1
- package/dist/cjs/ui/TableFloatingControls/CornerControls/index.js +6 -0
- package/dist/cjs/ui/TableFloatingControls/FloatingControlsWithSelection.js +47 -0
- package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -2
- package/dist/cjs/ui/TableFloatingControls/index.js +25 -3
- package/dist/cjs/ui/common-styles.js +11 -6
- package/dist/es2019/nodeviews/TableComponent.js +27 -12
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +83 -0
- package/dist/es2019/nodeviews/TableContainer.js +8 -4
- package/dist/es2019/nodeviews/TableResizer.js +2 -4
- package/dist/es2019/nodeviews/table.js +21 -1
- package/dist/es2019/plugin.js +25 -3
- package/dist/es2019/types.js +3 -0
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +7 -2
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -2
- package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +55 -0
- package/dist/es2019/ui/TableFloatingControls/CornerControls/index.js +1 -1
- package/dist/es2019/ui/TableFloatingControls/FloatingControlsWithSelection.js +42 -0
- package/dist/es2019/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -2
- package/dist/es2019/ui/TableFloatingControls/index.js +26 -4
- package/dist/es2019/ui/common-styles.js +589 -588
- package/dist/esm/nodeviews/TableComponent.js +25 -11
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +80 -0
- package/dist/esm/nodeviews/TableContainer.js +8 -4
- package/dist/esm/nodeviews/TableResizer.js +4 -5
- package/dist/esm/nodeviews/table.js +21 -1
- package/dist/esm/plugin.js +25 -3
- package/dist/esm/types.js +3 -0
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +6 -2
- package/dist/esm/ui/TableFloatingColumnControls/index.js +5 -2
- package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +47 -0
- package/dist/esm/ui/TableFloatingControls/CornerControls/index.js +1 -1
- package/dist/esm/ui/TableFloatingControls/FloatingControlsWithSelection.js +40 -0
- package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -2
- package/dist/esm/ui/TableFloatingControls/index.js +26 -4
- package/dist/esm/ui/common-styles.js +10 -5
- package/dist/types/nodeviews/TableComponent.d.ts +7 -2
- package/dist/types/nodeviews/TableComponentWithSharedState.d.ts +27 -0
- package/dist/types/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/plugin.d.ts +11 -7
- package/dist/types/types.d.ts +8 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +113 -1
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +3 -2
- package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +223 -0
- package/dist/types/ui/TableFloatingControls/CornerControls/index.d.ts +1 -1
- package/dist/types/ui/TableFloatingControls/FloatingControlsWithSelection.d.ts +20 -0
- package/dist/types/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +2 -0
- package/dist/types/ui/TableFloatingControls/index.d.ts +113 -1
- package/dist/types/ui/common-styles.d.ts +3 -0
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +7 -2
- package/dist/types-ts4.5/nodeviews/TableComponentWithSharedState.d.ts +27 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +11 -7
- package/dist/types-ts4.5/types.d.ts +8 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +144 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +285 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/FloatingControlsWithSelection.d.ts +20 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +144 -1
- package/dist/types-ts4.5/ui/common-styles.d.ts +3 -0
- package/package.json +6 -3
- package/src/nodeviews/TableComponent.tsx +36 -7
- package/src/nodeviews/TableComponentWithSharedState.tsx +125 -0
- package/src/nodeviews/TableContainer.tsx +6 -0
- package/src/nodeviews/TableResizer.tsx +2 -1
- package/src/nodeviews/table.tsx +22 -1
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +46 -6
- package/src/types.ts +27 -2
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +10 -2
- package/src/ui/TableFloatingColumnControls/index.tsx +13 -1
- package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +58 -0
- package/src/ui/TableFloatingControls/CornerControls/index.tsx +4 -1
- package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +68 -0
- package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +4 -1
- package/src/ui/TableFloatingControls/index.tsx +42 -8
- package/src/ui/common-styles.ts +611 -610
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { injectIntl } from 'react-intl-next';
|
|
4
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
5
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
6
|
import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
|
|
6
7
|
import { clearHoverSelection } from '../../../commands';
|
|
@@ -54,4 +55,58 @@ const DragCornerControlsComponent = ({
|
|
|
54
55
|
className: ClassName.DRAG_CORNER_BUTTON_INNER
|
|
55
56
|
}));
|
|
56
57
|
};
|
|
58
|
+
const DragCornerControlsComponentWithSelection = ({
|
|
59
|
+
editorView,
|
|
60
|
+
isInDanger,
|
|
61
|
+
isResizing,
|
|
62
|
+
intl: {
|
|
63
|
+
formatMessage
|
|
64
|
+
},
|
|
65
|
+
api
|
|
66
|
+
}) => {
|
|
67
|
+
const {
|
|
68
|
+
selectionState
|
|
69
|
+
} = useSharedPluginState(api, ['selection']);
|
|
70
|
+
const handleOnClick = () => {
|
|
71
|
+
const {
|
|
72
|
+
state,
|
|
73
|
+
dispatch
|
|
74
|
+
} = editorView;
|
|
75
|
+
dispatch(selectTable(state.tr).setMeta('addToHistory', false));
|
|
76
|
+
};
|
|
77
|
+
const handleMouseOut = () => {
|
|
78
|
+
const {
|
|
79
|
+
state,
|
|
80
|
+
dispatch
|
|
81
|
+
} = editorView;
|
|
82
|
+
clearHoverSelection()(state, dispatch);
|
|
83
|
+
};
|
|
84
|
+
const isActive = useMemo(() => {
|
|
85
|
+
if (!(selectionState !== null && selectionState !== void 0 && selectionState.selection)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const table = findTable(selectionState.selection);
|
|
89
|
+
if (!table) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return isTableSelected(selectionState.selection);
|
|
93
|
+
}, [selectionState]);
|
|
94
|
+
if (isResizing) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
98
|
+
className: classnames(ClassName.DRAG_CORNER_BUTTON, {
|
|
99
|
+
active: isActive,
|
|
100
|
+
danger: isActive && isInDanger
|
|
101
|
+
}),
|
|
102
|
+
"aria-label": formatMessage(messages.cornerControl),
|
|
103
|
+
type: "button",
|
|
104
|
+
onClick: handleOnClick,
|
|
105
|
+
onMouseOut: handleMouseOut,
|
|
106
|
+
contentEditable: false
|
|
107
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
108
|
+
className: ClassName.DRAG_CORNER_BUTTON_INNER
|
|
109
|
+
}));
|
|
110
|
+
};
|
|
111
|
+
export const DragCornerControlsWithSelection = injectIntl(DragCornerControlsComponentWithSelection);
|
|
57
112
|
export const DragCornerControls = injectIntl(DragCornerControlsComponent);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { CornerControls } from './ClassicCornerControls';
|
|
2
|
-
export { DragCornerControls } from './DragCornerControls';
|
|
2
|
+
export { DragCornerControls, DragCornerControlsWithSelection } from './DragCornerControls';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { CornerControls } from './CornerControls';
|
|
4
|
+
import { RowControls } from './RowControls';
|
|
5
|
+
export const FloatingControlsWithSelection = ({
|
|
6
|
+
editorView,
|
|
7
|
+
tableRef,
|
|
8
|
+
isInDanger,
|
|
9
|
+
isResizing,
|
|
10
|
+
isHeaderRowEnabled,
|
|
11
|
+
isHeaderColumnEnabled,
|
|
12
|
+
hoveredRows,
|
|
13
|
+
stickyTop,
|
|
14
|
+
hoverRows,
|
|
15
|
+
selectRow,
|
|
16
|
+
tableActive,
|
|
17
|
+
api
|
|
18
|
+
}) => {
|
|
19
|
+
const {
|
|
20
|
+
selectionState
|
|
21
|
+
} = useSharedPluginState(api, ['selection']);
|
|
22
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CornerControls, {
|
|
23
|
+
editorView: editorView,
|
|
24
|
+
tableRef: tableRef,
|
|
25
|
+
isInDanger: isInDanger,
|
|
26
|
+
isResizing: isResizing,
|
|
27
|
+
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
28
|
+
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
29
|
+
hoveredRows: hoveredRows,
|
|
30
|
+
stickyTop: tableActive ? stickyTop : undefined
|
|
31
|
+
}), /*#__PURE__*/React.createElement(RowControls, {
|
|
32
|
+
selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection,
|
|
33
|
+
editorView: editorView,
|
|
34
|
+
tableRef: tableRef,
|
|
35
|
+
hoverRows: hoverRows,
|
|
36
|
+
hoveredRows: hoveredRows,
|
|
37
|
+
isInDanger: isInDanger,
|
|
38
|
+
isResizing: isResizing,
|
|
39
|
+
selectRow: selectRow,
|
|
40
|
+
stickyTop: tableActive ? stickyTop : undefined
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
@@ -26,7 +26,8 @@ class RowControlsComponent extends Component {
|
|
|
26
26
|
isResizing,
|
|
27
27
|
intl: {
|
|
28
28
|
formatMessage
|
|
29
|
-
}
|
|
29
|
+
},
|
|
30
|
+
selection: selectionState
|
|
30
31
|
} = this.props;
|
|
31
32
|
if (!tableRef) {
|
|
32
33
|
return null;
|
|
@@ -54,7 +55,7 @@ class RowControlsComponent extends Component {
|
|
|
54
55
|
}
|
|
55
56
|
const thisRowSticky = this.props.stickyTop !== undefined && index === 0 && hasHeaderRow;
|
|
56
57
|
return /*#__PURE__*/React.createElement("div", {
|
|
57
|
-
className: `${ClassName.ROW_CONTROLS_BUTTON_WRAP} ${getRowClassNames(startIndex, selection, hoveredRows, isInDanger, isResizing)} ${thisRowSticky ? 'sticky' : ''}`,
|
|
58
|
+
className: `${ClassName.ROW_CONTROLS_BUTTON_WRAP} ${getRowClassNames(startIndex, selectionState || selection, hoveredRows, isInDanger, isResizing)} ${thisRowSticky ? 'sticky' : ''}`,
|
|
58
59
|
key: startIndex,
|
|
59
60
|
style: {
|
|
60
61
|
height: height,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { hoverCell, hoverRows, selectRow, selectRows } from '../../commands';
|
|
4
5
|
import { TableCssClassName as ClassName } from '../../types';
|
|
5
|
-
import { CornerControls, DragCornerControls } from './CornerControls';
|
|
6
|
+
import { CornerControls, DragCornerControls, DragCornerControlsWithSelection } from './CornerControls';
|
|
7
|
+
import { FloatingControlsWithSelection } from './FloatingControlsWithSelection';
|
|
6
8
|
import NumberColumn from './NumberColumn';
|
|
7
9
|
import { DragControls, RowControls } from './RowControls';
|
|
8
10
|
export const TableFloatingControls = ({
|
|
@@ -21,7 +23,8 @@ export const TableFloatingControls = ({
|
|
|
21
23
|
isDragAndDropEnabled,
|
|
22
24
|
hoveredCell,
|
|
23
25
|
isTableHovered,
|
|
24
|
-
tableWrapperWidth
|
|
26
|
+
tableWrapperWidth,
|
|
27
|
+
api
|
|
25
28
|
}) => {
|
|
26
29
|
const _selectRow = useCallback((row, expand) => {
|
|
27
30
|
const {
|
|
@@ -89,7 +92,13 @@ export const TableFloatingControls = ({
|
|
|
89
92
|
updateCellHoverLocation: updateCellHoverLocation,
|
|
90
93
|
stickyTop: stickyTop,
|
|
91
94
|
isDragAndDropEnabled: isDragAndDropEnabled
|
|
92
|
-
}) : null, tableActive && /*#__PURE__*/React.createElement(React.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
95
|
+
}) : null, tableActive && /*#__PURE__*/React.createElement(React.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/React.createElement(React.Fragment, null, getBooleanFF('platform.editor.table.use-shared-state-hook') ? /*#__PURE__*/React.createElement(DragCornerControlsWithSelection, {
|
|
96
|
+
editorView: editorView,
|
|
97
|
+
tableRef: tableRef,
|
|
98
|
+
isInDanger: isInDanger,
|
|
99
|
+
isResizing: isResizing,
|
|
100
|
+
api: api
|
|
101
|
+
}) : /*#__PURE__*/React.createElement(DragCornerControls, {
|
|
93
102
|
editorView: editorView,
|
|
94
103
|
tableRef: tableRef,
|
|
95
104
|
isInDanger: isInDanger,
|
|
@@ -108,7 +117,20 @@ export const TableFloatingControls = ({
|
|
|
108
117
|
selectRow: _selectRow,
|
|
109
118
|
selectRows: _selectRows,
|
|
110
119
|
updateCellHoverLocation: updateCellHoverLocation
|
|
111
|
-
})) :
|
|
120
|
+
})) : getBooleanFF('platform.editor.table.use-shared-state-hook') ? /*#__PURE__*/React.createElement(FloatingControlsWithSelection, {
|
|
121
|
+
editorView: editorView,
|
|
122
|
+
tableRef: tableRef,
|
|
123
|
+
isInDanger: isInDanger,
|
|
124
|
+
isResizing: isResizing,
|
|
125
|
+
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
126
|
+
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
127
|
+
hoveredRows: hoveredRows,
|
|
128
|
+
stickyTop: tableActive ? stickyTop : undefined,
|
|
129
|
+
tableActive: tableActive,
|
|
130
|
+
hoverRows: _hoverRows,
|
|
131
|
+
selectRow: _selectRow,
|
|
132
|
+
api: api
|
|
133
|
+
}) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CornerControls, {
|
|
112
134
|
editorView: editorView,
|
|
113
135
|
tableRef: tableRef,
|
|
114
136
|
isInDanger: isInDanger,
|