@atlaskit/editor-plugin-table 7.6.2 → 7.6.4
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 +13 -0
- package/dist/cjs/commands/misc.js +3 -2
- package/dist/cjs/nodeviews/TableComponent.js +25 -11
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +87 -0
- package/dist/cjs/nodeviews/TableContainer.js +37 -21
- package/dist/cjs/nodeviews/TableResizer.js +40 -29
- package/dist/cjs/nodeviews/table.js +21 -1
- package/dist/cjs/plugin.js +25 -2
- package/dist/cjs/toolbar.js +5 -4
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -3
- package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +21 -28
- 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/cjs/utils/guidelines.js +1 -1
- package/dist/es2019/commands/misc.js +6 -2
- package/dist/es2019/nodeviews/TableComponent.js +27 -12
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +83 -0
- package/dist/es2019/nodeviews/TableContainer.js +24 -6
- package/dist/es2019/nodeviews/TableResizer.js +27 -19
- package/dist/es2019/nodeviews/table.js +21 -1
- package/dist/es2019/plugin.js +26 -3
- package/dist/es2019/toolbar.js +5 -4
- package/dist/es2019/types.js +3 -0
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -3
- package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +20 -27
- 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/es2019/utils/guidelines.js +1 -1
- package/dist/esm/commands/misc.js +3 -2
- package/dist/esm/nodeviews/TableComponent.js +25 -11
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +80 -0
- package/dist/esm/nodeviews/TableContainer.js +37 -21
- package/dist/esm/nodeviews/TableResizer.js +41 -30
- package/dist/esm/nodeviews/table.js +21 -1
- package/dist/esm/plugin.js +26 -3
- package/dist/esm/toolbar.js +5 -4
- package/dist/esm/types.js +3 -0
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -3
- package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +21 -28
- 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/esm/utils/guidelines.js +1 -1
- package/dist/types/commands/misc.d.ts +2 -1
- 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 +4 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/plugin.d.ts +11 -7
- package/dist/types/types.d.ts +13 -4
- 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/commands/misc.d.ts +2 -1
- 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 +4 -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 +13 -4
- 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 -6
- package/src/commands/misc.ts +6 -3
- package/src/nodeviews/TableComponent.tsx +36 -7
- package/src/nodeviews/TableComponentWithSharedState.tsx +125 -0
- package/src/nodeviews/TableContainer.tsx +24 -3
- package/src/nodeviews/TableResizer.tsx +36 -21
- package/src/nodeviews/table.tsx +22 -1
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +47 -6
- package/src/toolbar.tsx +20 -19
- package/src/types.ts +33 -4
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +66 -112
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -12
- package/src/ui/FloatingDragMenu/DropdownMenu.tsx +19 -28
- 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
- package/src/utils/guidelines.ts +5 -4
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
|
|
7
|
+
import type { TablePlugin } from '../../plugin';
|
|
8
|
+
|
|
9
|
+
import { CornerControls } from './CornerControls';
|
|
10
|
+
import { RowControls } from './RowControls';
|
|
11
|
+
|
|
12
|
+
type FloatingControlsWithSelectionProps = {
|
|
13
|
+
editorView: EditorView;
|
|
14
|
+
tableRef: HTMLTableElement;
|
|
15
|
+
isInDanger?: boolean;
|
|
16
|
+
isResizing?: boolean;
|
|
17
|
+
isHeaderRowEnabled?: boolean;
|
|
18
|
+
isHeaderColumnEnabled?: boolean;
|
|
19
|
+
hoveredRows?: number[];
|
|
20
|
+
stickyTop?: number;
|
|
21
|
+
hoverRows: (rows: number[]) => void;
|
|
22
|
+
selectRow: (row: number, expand: boolean) => void;
|
|
23
|
+
tableActive: boolean;
|
|
24
|
+
api?: ExtractInjectionAPI<TablePlugin>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const FloatingControlsWithSelection = ({
|
|
28
|
+
editorView,
|
|
29
|
+
tableRef,
|
|
30
|
+
isInDanger,
|
|
31
|
+
isResizing,
|
|
32
|
+
isHeaderRowEnabled,
|
|
33
|
+
isHeaderColumnEnabled,
|
|
34
|
+
hoveredRows,
|
|
35
|
+
stickyTop,
|
|
36
|
+
hoverRows,
|
|
37
|
+
selectRow,
|
|
38
|
+
tableActive,
|
|
39
|
+
api,
|
|
40
|
+
}: FloatingControlsWithSelectionProps) => {
|
|
41
|
+
const { selectionState } = useSharedPluginState(api, ['selection']);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<CornerControls
|
|
46
|
+
editorView={editorView}
|
|
47
|
+
tableRef={tableRef}
|
|
48
|
+
isInDanger={isInDanger}
|
|
49
|
+
isResizing={isResizing}
|
|
50
|
+
isHeaderRowEnabled={isHeaderRowEnabled}
|
|
51
|
+
isHeaderColumnEnabled={isHeaderColumnEnabled}
|
|
52
|
+
hoveredRows={hoveredRows}
|
|
53
|
+
stickyTop={tableActive ? stickyTop : undefined}
|
|
54
|
+
/>
|
|
55
|
+
<RowControls
|
|
56
|
+
selection={selectionState?.selection}
|
|
57
|
+
editorView={editorView}
|
|
58
|
+
tableRef={tableRef}
|
|
59
|
+
hoverRows={hoverRows}
|
|
60
|
+
hoveredRows={hoveredRows}
|
|
61
|
+
isInDanger={isInDanger}
|
|
62
|
+
isResizing={isResizing}
|
|
63
|
+
selectRow={selectRow}
|
|
64
|
+
stickyTop={tableActive ? stickyTop : undefined}
|
|
65
|
+
/>
|
|
66
|
+
</>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
@@ -4,6 +4,7 @@ import type { WrappedComponentProps } from 'react-intl-next';
|
|
|
4
4
|
import { injectIntl } from 'react-intl-next';
|
|
5
5
|
|
|
6
6
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
|
+
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
8
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
9
|
|
|
9
10
|
import { clearHoverSelection } from '../../../commands';
|
|
@@ -22,6 +23,7 @@ export interface Props {
|
|
|
22
23
|
isResizing?: boolean;
|
|
23
24
|
insertRowButtonIndex?: number;
|
|
24
25
|
stickyTop?: number;
|
|
26
|
+
selection?: Selection;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
class RowControlsComponent extends Component<Props & WrappedComponentProps> {
|
|
@@ -33,6 +35,7 @@ class RowControlsComponent extends Component<Props & WrappedComponentProps> {
|
|
|
33
35
|
isInDanger,
|
|
34
36
|
isResizing,
|
|
35
37
|
intl: { formatMessage },
|
|
38
|
+
selection: selectionState,
|
|
36
39
|
} = this.props;
|
|
37
40
|
if (!tableRef) {
|
|
38
41
|
return null;
|
|
@@ -72,7 +75,7 @@ class RowControlsComponent extends Component<Props & WrappedComponentProps> {
|
|
|
72
75
|
ClassName.ROW_CONTROLS_BUTTON_WRAP
|
|
73
76
|
} ${getRowClassNames(
|
|
74
77
|
startIndex,
|
|
75
|
-
selection,
|
|
78
|
+
selectionState || selection,
|
|
76
79
|
hoveredRows,
|
|
77
80
|
isInDanger,
|
|
78
81
|
isResizing,
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
4
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
5
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
5
6
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
7
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
8
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
10
|
|
|
9
11
|
import { hoverCell, hoverRows, selectRow, selectRows } from '../../commands';
|
|
12
|
+
import type { TablePlugin } from '../../plugin';
|
|
10
13
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
11
14
|
import { TableCssClassName as ClassName } from '../../types';
|
|
12
15
|
import type { CellHoverMeta } from '../../types';
|
|
13
16
|
|
|
14
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
CornerControls,
|
|
19
|
+
DragCornerControls,
|
|
20
|
+
DragCornerControlsWithSelection,
|
|
21
|
+
} from './CornerControls';
|
|
22
|
+
import { FloatingControlsWithSelection } from './FloatingControlsWithSelection';
|
|
15
23
|
import NumberColumn from './NumberColumn';
|
|
16
24
|
import { DragControls, RowControls } from './RowControls';
|
|
17
25
|
|
|
@@ -55,7 +63,8 @@ export const TableFloatingControls = ({
|
|
|
55
63
|
hoveredCell,
|
|
56
64
|
isTableHovered,
|
|
57
65
|
tableWrapperWidth,
|
|
58
|
-
|
|
66
|
+
api,
|
|
67
|
+
}: TableFloatingControlsProps & { api?: ExtractInjectionAPI<TablePlugin> }) => {
|
|
59
68
|
const _selectRow = useCallback(
|
|
60
69
|
(row: number, expand: boolean) => {
|
|
61
70
|
const { state, dispatch } = editorView;
|
|
@@ -141,12 +150,22 @@ export const TableFloatingControls = ({
|
|
|
141
150
|
<>
|
|
142
151
|
{isDragAndDropEnabled ? (
|
|
143
152
|
<>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
153
|
+
{getBooleanFF('platform.editor.table.use-shared-state-hook') ? (
|
|
154
|
+
<DragCornerControlsWithSelection
|
|
155
|
+
editorView={editorView}
|
|
156
|
+
tableRef={tableRef}
|
|
157
|
+
isInDanger={isInDanger}
|
|
158
|
+
isResizing={isResizing}
|
|
159
|
+
api={api}
|
|
160
|
+
/>
|
|
161
|
+
) : (
|
|
162
|
+
<DragCornerControls
|
|
163
|
+
editorView={editorView}
|
|
164
|
+
tableRef={tableRef}
|
|
165
|
+
isInDanger={isInDanger}
|
|
166
|
+
isResizing={isResizing}
|
|
167
|
+
/>
|
|
168
|
+
)}
|
|
150
169
|
<DragControls
|
|
151
170
|
tableRef={tableRef}
|
|
152
171
|
tableNode={tableNode}
|
|
@@ -163,6 +182,21 @@ export const TableFloatingControls = ({
|
|
|
163
182
|
updateCellHoverLocation={updateCellHoverLocation}
|
|
164
183
|
/>
|
|
165
184
|
</>
|
|
185
|
+
) : getBooleanFF('platform.editor.table.use-shared-state-hook') ? (
|
|
186
|
+
<FloatingControlsWithSelection
|
|
187
|
+
editorView={editorView}
|
|
188
|
+
tableRef={tableRef}
|
|
189
|
+
isInDanger={isInDanger}
|
|
190
|
+
isResizing={isResizing}
|
|
191
|
+
isHeaderRowEnabled={isHeaderRowEnabled}
|
|
192
|
+
isHeaderColumnEnabled={isHeaderColumnEnabled}
|
|
193
|
+
hoveredRows={hoveredRows}
|
|
194
|
+
stickyTop={tableActive ? stickyTop : undefined}
|
|
195
|
+
tableActive={tableActive}
|
|
196
|
+
hoverRows={_hoverRows}
|
|
197
|
+
selectRow={_selectRow}
|
|
198
|
+
api={api}
|
|
199
|
+
/>
|
|
166
200
|
) : (
|
|
167
201
|
<>
|
|
168
202
|
<CornerControls
|