@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
|
@@ -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';
|
|
@@ -13,3 +13,4 @@ export declare const handleMouseMove: (view: EditorView, event: Event, elementCo
|
|
|
13
13
|
export declare function handleTripleClick(view: EditorView, pos: number): boolean;
|
|
14
14
|
export declare const handleCut: (oldTr: Transaction, oldState: EditorState, newState: EditorState, editorAnalyticsAPI?: EditorAnalyticsAPI, editorView?: EditorView) => Transaction;
|
|
15
15
|
export declare const whenTableInFocus: (eventHandler: (view: EditorView, mouseEvent: Event, elementContentRects?: ElementContentRects) => boolean, elementContentRects?: ElementContentRects) => (view: EditorView, mouseEvent: Event) => boolean;
|
|
16
|
+
export declare const withCellTracking: (eventHandler: (view: EditorView, mouseEvent: Event, elementContentRects?: ElementContentRects) => boolean, elementContentRects?: ElementContentRects) => (view: EditorView, mouseEvent: Event) => boolean;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
1
|
+
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
2
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
3
3
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { PluginInjectionAPI } from '../types';
|
|
7
7
|
export type TableOptions = {
|
|
8
8
|
isBreakoutEnabled?: boolean;
|
|
9
9
|
isFullWidthModeEnabled?: boolean;
|
|
10
10
|
wasFullWidthModeEnabled?: boolean;
|
|
11
11
|
isTableResizingEnabled?: boolean;
|
|
12
|
+
isDragAndDropEnabled?: boolean;
|
|
12
13
|
};
|
|
13
14
|
export interface Props {
|
|
14
15
|
node: PmNode;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { EditorState,
|
|
2
|
+
import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
5
|
export declare const pluginKey: PluginKey<any>;
|
|
5
6
|
export declare const getDecorations: (state: EditorState) => DecorationSet;
|
|
@@ -2,3 +2,15 @@ export declare const defaultTableSelection: {
|
|
|
2
2
|
hoveredColumns: never[];
|
|
3
3
|
hoveredRows: never[];
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Creating a separate object for hoveredCell so it doesn't get defaulted when `handleDocOrSelectionChanged` runs.
|
|
7
|
+
*
|
|
8
|
+
* It is safe to persist this value as it gets removed when the mouse cursor leaves the table, so no need to remove it
|
|
9
|
+
* when doc changes.
|
|
10
|
+
*/
|
|
11
|
+
export declare const defaultHoveredCell: {
|
|
12
|
+
hoveredCell: {
|
|
13
|
+
rowIndex: undefined;
|
|
14
|
+
colIndex: undefined;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -5,4 +5,4 @@ import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider'
|
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
7
7
|
import type { PluginConfig, PluginInjectionAPI } from '../types';
|
|
8
|
-
export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, getIntl: () => IntlShape, breakoutEnabled?: boolean,
|
|
8
|
+
export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, getIntl: () => IntlShape, breakoutEnabled?: boolean, tableResizingEnabled?: boolean, fullWidthModeEnabled?: boolean, previousFullWidthModeEnabled?: boolean, dragAndDropEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI) => SafePlugin<import("../types").TablePluginState>;
|
|
@@ -44,10 +44,15 @@ export interface PluginConfig {
|
|
|
44
44
|
}
|
|
45
45
|
export type { ColumnResizingPluginState } from '@atlaskit/editor-common/types';
|
|
46
46
|
export type CellColumnPositioning = Pick<Rect, 'right' | 'left'>;
|
|
47
|
+
export type CellHoverCoordinates = {
|
|
48
|
+
colIndex?: number;
|
|
49
|
+
rowIndex?: number;
|
|
50
|
+
};
|
|
47
51
|
export interface TablePluginState {
|
|
48
52
|
editorHasFocus?: boolean;
|
|
49
53
|
hoveredColumns: number[];
|
|
50
54
|
hoveredRows: number[];
|
|
55
|
+
hoveredCell: CellHoverCoordinates;
|
|
51
56
|
pluginConfig: PluginConfig;
|
|
52
57
|
isHeaderColumnEnabled: boolean;
|
|
53
58
|
isHeaderRowEnabled: boolean;
|
|
@@ -108,7 +113,7 @@ export type TablePluginAction = {
|
|
|
108
113
|
isInDanger?: boolean;
|
|
109
114
|
};
|
|
110
115
|
} | {
|
|
111
|
-
type: '
|
|
116
|
+
type: 'HOVER_MERGED_CELLS';
|
|
112
117
|
data: {
|
|
113
118
|
decorationSet: DecorationSet;
|
|
114
119
|
};
|
|
@@ -163,6 +168,9 @@ export type TablePluginAction = {
|
|
|
163
168
|
data: {
|
|
164
169
|
decorationSet: DecorationSet;
|
|
165
170
|
};
|
|
171
|
+
} | {
|
|
172
|
+
type: 'HOVER_CELL';
|
|
173
|
+
data: CellHoverCoordinates;
|
|
166
174
|
} | {
|
|
167
175
|
type: 'SET_TARGET_CELL_POSITION';
|
|
168
176
|
data: {
|
|
@@ -220,6 +228,7 @@ export type ColumnResizingPluginAction = {
|
|
|
220
228
|
};
|
|
221
229
|
};
|
|
222
230
|
export declare enum TableDecorations {
|
|
231
|
+
/** Classic controls */
|
|
223
232
|
ALL_CONTROLS_HOVER = "CONTROLS_HOVER",
|
|
224
233
|
ROW_CONTROLS_HOVER = "ROW_CONTROLS_HOVER",
|
|
225
234
|
COLUMN_CONTROLS_HOVER = "COLUMN_CONTROLS_HOVER",
|
|
@@ -236,6 +245,7 @@ export declare enum TableDecorations {
|
|
|
236
245
|
LAST_CELL_ELEMENT = "LAST_CELL_ELEMENT"
|
|
237
246
|
}
|
|
238
247
|
export declare const TableCssClassName: {
|
|
248
|
+
/** Classic controls */
|
|
239
249
|
COLUMN_CONTROLS: string;
|
|
240
250
|
COLUMN_CONTROLS_DECORATIONS: string;
|
|
241
251
|
COLUMN_SELECTED: string;
|
|
@@ -266,8 +276,13 @@ export declare const TableCssClassName: {
|
|
|
266
276
|
CORNER_CONTROLS_INSERT_ROW_MARKER: string;
|
|
267
277
|
CORNER_CONTROLS_INSERT_COLUMN_MARKER: string;
|
|
268
278
|
CONTROLS_CORNER_BUTTON: string;
|
|
279
|
+
/** Controls with drag handle */
|
|
280
|
+
COLUMN_CONTROLS_DECORATIONS_WITH_DRAG: string;
|
|
281
|
+
ROW_CONTROLS_WITH_DRAG: string;
|
|
282
|
+
/** Other classes */
|
|
269
283
|
NUMBERED_COLUMN: string;
|
|
270
284
|
NUMBERED_COLUMN_BUTTON: string;
|
|
285
|
+
NUMBERED_COLUMN_BUTTON_DISABLED: string;
|
|
271
286
|
HOVERED_COLUMN: string;
|
|
272
287
|
HOVERED_ROW: string;
|
|
273
288
|
HOVERED_TABLE: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MouseEventHandler } from 'react';
|
|
2
|
+
type DragHandleProps = {
|
|
3
|
+
tableLocalId: string;
|
|
4
|
+
indexes: number[];
|
|
5
|
+
direction?: 'column' | 'row';
|
|
6
|
+
onClick?: MouseEventHandler;
|
|
7
|
+
onMouseOver?: MouseEventHandler;
|
|
8
|
+
onMouseOut?: MouseEventHandler;
|
|
9
|
+
};
|
|
10
|
+
export declare const DragHandle: ({ tableLocalId, direction, indexes, onClick, onMouseOver, onMouseOut, }: DragHandleProps) => JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
export interface Props {
|
|
4
4
|
editorView: EditorView;
|
|
5
5
|
tableRef: HTMLTableElement;
|
|
@@ -11,11 +11,14 @@ export interface Props {
|
|
|
11
11
|
isInDanger?: boolean;
|
|
12
12
|
isResizing?: boolean;
|
|
13
13
|
stickyTop?: number;
|
|
14
|
+
isDragAndDropEnabled?: boolean;
|
|
14
15
|
}
|
|
15
16
|
export default class NumberColumn extends Component<Props, any> {
|
|
16
17
|
render(): JSX.Element;
|
|
17
18
|
private hoverRows;
|
|
18
19
|
private selectRow;
|
|
19
20
|
private clearHoverSelection;
|
|
21
|
+
private updateDragHandleLocation;
|
|
22
|
+
private getCellStyles;
|
|
20
23
|
private getClassNames;
|
|
21
24
|
}
|
package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
export interface Props {
|
|
5
|
+
editorView: EditorView;
|
|
6
|
+
tableRef: HTMLTableElement;
|
|
7
|
+
selectRow: (row: number, expand: boolean) => void;
|
|
8
|
+
hoverRows: (rows: number[], danger?: boolean) => void;
|
|
9
|
+
hoveredRows?: number[];
|
|
10
|
+
isInDanger?: boolean;
|
|
11
|
+
isResizing?: boolean;
|
|
12
|
+
insertRowButtonIndex?: number;
|
|
13
|
+
stickyTop?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const RowControls: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
16
|
+
WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { CellHoverCoordinates } from '../../../types';
|
|
5
|
+
type DragControlsProps = {
|
|
6
|
+
editorView: EditorView;
|
|
7
|
+
tableRef: HTMLTableElement;
|
|
8
|
+
tableActive?: boolean;
|
|
9
|
+
hoveredCell?: CellHoverCoordinates;
|
|
10
|
+
hoverRows?: (rows: number[], danger?: boolean) => void;
|
|
11
|
+
selectRow?: (row: number, expand: boolean) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const DragControls: React.FC<import("react-intl-next").WithIntlProps<DragControlsProps & WrappedComponentProps<"intl">>> & {
|
|
14
|
+
WrappedComponent: React.ComponentType<DragControlsProps & WrappedComponentProps<"intl">>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
export interface Props {
|
|
5
|
-
editorView: EditorView;
|
|
6
|
-
tableRef: HTMLTableElement;
|
|
7
|
-
selectRow: (row: number, expand: boolean) => void;
|
|
8
|
-
hoverRows: (rows: number[], danger?: boolean) => void;
|
|
9
|
-
hoveredRows?: number[];
|
|
10
|
-
isInDanger?: boolean;
|
|
11
|
-
isResizing?: boolean;
|
|
12
|
-
insertRowButtonIndex?: number;
|
|
13
|
-
stickyTop?: number;
|
|
14
|
-
}
|
|
15
|
-
export declare const RowControls: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
16
|
-
WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
|
|
17
|
-
};
|
|
1
|
+
export { RowControls } from './ClassicControls';
|
|
2
|
+
export { DragControls } from './DragControls';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
2
|
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
3
|
-
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
3
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
5
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
6
|
+
import type { CellHoverCoordinates } from '../../types';
|
|
7
7
|
export interface Props {
|
|
8
8
|
editorView: EditorView;
|
|
9
|
-
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
10
9
|
selection?: Selection;
|
|
11
10
|
tableRef?: HTMLTableElement;
|
|
12
11
|
tableActive?: boolean;
|
|
@@ -15,9 +14,11 @@ export interface Props {
|
|
|
15
14
|
isHeaderRowEnabled?: boolean;
|
|
16
15
|
isHeaderColumnEnabled?: boolean;
|
|
17
16
|
isNumberColumnEnabled?: boolean;
|
|
17
|
+
isDragAndDropEnabled?: boolean;
|
|
18
18
|
hasHeaderRow?: boolean;
|
|
19
19
|
headerRowHeight?: number;
|
|
20
20
|
hoveredRows?: number[];
|
|
21
|
+
hoveredCell?: CellHoverCoordinates;
|
|
21
22
|
ordering?: TableColumnOrdering;
|
|
22
23
|
stickyHeader?: RowStickyState;
|
|
23
24
|
}
|
|
@@ -33,6 +33,7 @@ export declare const lineMarkerSize = 4;
|
|
|
33
33
|
export declare const columnControlsDecorationHeight = 25;
|
|
34
34
|
export declare const columnControlsZIndex: number;
|
|
35
35
|
export declare const columnControlsSelectedZIndex: number;
|
|
36
|
+
export declare const rowControlsZIndex: number;
|
|
36
37
|
export declare const columnResizeHandleZIndex: number;
|
|
37
38
|
export declare const insertLineWidth = 3;
|
|
38
39
|
export declare const resizeHandlerAreaWidth: number;
|
|
@@ -3,14 +3,14 @@ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import type { ReadonlyTransaction, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import type { Cell, CellColumnPositioning } from '../types';
|
|
6
|
+
import type { Cell, CellColumnPositioning, CellHoverCoordinates } from '../types';
|
|
7
7
|
import { TableDecorations } from '../types';
|
|
8
8
|
export declare const findColumnControlSelectedDecoration: (decorationSet: DecorationSet) => Decoration[];
|
|
9
9
|
export declare const findControlsHoverDecoration: (decorationSet: DecorationSet) => Decoration[];
|
|
10
10
|
export declare const createCellHoverDecoration: (cells: Cell[]) => Decoration[];
|
|
11
11
|
export declare const createControlsHoverDecoration: (cells: Cell[], type: 'row' | 'column' | 'table', tr: Transaction | ReadonlyTransaction, danger?: boolean, selected?: boolean) => Decoration[];
|
|
12
12
|
export declare const createColumnSelectedDecoration: (tr: Transaction | ReadonlyTransaction) => Decoration[];
|
|
13
|
-
export declare const createColumnControlsDecoration: (selection: Selection) => Decoration[];
|
|
13
|
+
export declare const createColumnControlsDecoration: (selection: Selection, hoverLocation?: CellHoverCoordinates) => Decoration[];
|
|
14
14
|
export declare const updateDecorations: (node: PmNode, decorationSet: DecorationSet, decorations: Decoration[], key: TableDecorations) => DecorationSet;
|
|
15
15
|
export declare const createResizeHandleDecoration: (tr: Transaction | ReadonlyTransaction, rowIndexTarget: number, columnEndIndexTarget: Omit<CellColumnPositioning, 'left'>, includeTooltip: boolean | undefined, getIntl: () => IntlShape) => [
|
|
16
16
|
Decoration[],
|
|
@@ -7,7 +7,9 @@ export declare const getColumnOrRowIndex: (target: HTMLElement) => [
|
|
|
7
7
|
number
|
|
8
8
|
];
|
|
9
9
|
export declare const isColumnControlsDecorations: (node: HTMLElement | null) => boolean;
|
|
10
|
+
export declare const isColumnDragControlsDecorations: (node: HTMLElement | null) => true | HTMLElement | null;
|
|
10
11
|
export declare const isRowControlsButton: (node: HTMLElement | null) => boolean;
|
|
12
|
+
export declare const isRowDragControlsButton: (node: HTMLElement | null) => true | HTMLElement | null;
|
|
11
13
|
export declare const isResizeHandleDecoration: (node: HTMLElement | null) => boolean;
|
|
12
14
|
export declare const isTableControlsButton: (node: HTMLElement | null) => boolean;
|
|
13
15
|
export declare const isTableContainerOrWrapper: (node: HTMLElement | null) => boolean;
|
|
@@ -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 type { RowParams } from './row-controls';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.3",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/adf-schema": "^32.0.0",
|
|
31
31
|
"@atlaskit/custom-steps": "^0.0.2",
|
|
32
|
-
"@atlaskit/editor-common": "^76.
|
|
32
|
+
"@atlaskit/editor-common": "^76.12.0",
|
|
33
33
|
"@atlaskit/editor-palette": "1.5.1",
|
|
34
34
|
"@atlaskit/editor-plugin-analytics": "^0.2.0",
|
|
35
35
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
@@ -40,8 +40,10 @@
|
|
|
40
40
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
41
41
|
"@atlaskit/pragmatic-drag-and-drop": "^0.23.0",
|
|
42
42
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^0.11.8",
|
|
43
|
+
"@atlaskit/pragmatic-drag-and-drop-react-accessibility": "^0.4.0",
|
|
44
|
+
"@atlaskit/primitives": "^1.6.7",
|
|
43
45
|
"@atlaskit/theme": "^12.6.0",
|
|
44
|
-
"@atlaskit/tokens": "^1.
|
|
46
|
+
"@atlaskit/tokens": "^1.28.0",
|
|
45
47
|
"@atlaskit/tooltip": "^17.8.0",
|
|
46
48
|
"@babel/runtime": "^7.0.0",
|
|
47
49
|
"@emotion/react": "^11.7.1",
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
tdEmpty,
|
|
26
26
|
tr,
|
|
27
27
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
28
|
+
import { ffTest } from '@atlassian/feature-flags-test-utils';
|
|
28
29
|
|
|
29
30
|
import tablePlugin from '../../plugins/table-plugin';
|
|
30
31
|
import {
|
|
@@ -36,7 +37,9 @@ import {
|
|
|
36
37
|
handleMouseMove,
|
|
37
38
|
handleMouseOut,
|
|
38
39
|
handleMouseOver,
|
|
40
|
+
withCellTracking,
|
|
39
41
|
} from '../../plugins/table/event-handlers';
|
|
42
|
+
import { getPluginState } from '../../plugins/table/pm-plugins/plugin-factory';
|
|
40
43
|
import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
41
44
|
import { TableCssClassName as ClassName } from '../../plugins/table/types';
|
|
42
45
|
|
|
@@ -60,7 +63,7 @@ describe('table plugin: decorations', () => {
|
|
|
60
63
|
beforeEach(() => {
|
|
61
64
|
jest.resetAllMocks();
|
|
62
65
|
});
|
|
63
|
-
it('should return true & prevent default behaviour for table wrappers: pm-table-
|
|
66
|
+
it('should return true & prevent default behaviour for table wrappers: pm-table-container', () => {
|
|
64
67
|
const { editorView } = editor(
|
|
65
68
|
doc(table()(tr(td({})(p())), tr(td({})(p())), tr(td({})(p())))),
|
|
66
69
|
);
|
|
@@ -232,3 +235,73 @@ describe('table event handlers', () => {
|
|
|
232
235
|
});
|
|
233
236
|
});
|
|
234
237
|
});
|
|
238
|
+
|
|
239
|
+
describe('withCellTracking', () => {
|
|
240
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
241
|
+
const editor = (doc: DocBuilder, isDragAndDropEnabled = false) =>
|
|
242
|
+
createEditor({
|
|
243
|
+
doc,
|
|
244
|
+
attachTo: document.body,
|
|
245
|
+
preset: new Preset<LightEditorPlugin>()
|
|
246
|
+
.add([featureFlagsPlugin, {}])
|
|
247
|
+
.add([analyticsPlugin, {}])
|
|
248
|
+
.add(contentInsertionPlugin)
|
|
249
|
+
.add(decorationsPlugin)
|
|
250
|
+
.add(widthPlugin)
|
|
251
|
+
.add(guidelinePlugin)
|
|
252
|
+
.add(gridPlugin)
|
|
253
|
+
.add(selectionPlugin)
|
|
254
|
+
.add([
|
|
255
|
+
tablePlugin,
|
|
256
|
+
{
|
|
257
|
+
dragAndDropEnabled: isDragAndDropEnabled,
|
|
258
|
+
tableOptions: { advanced: true },
|
|
259
|
+
},
|
|
260
|
+
]),
|
|
261
|
+
pluginKey,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
describe('should fire event handler passed in', () => {
|
|
265
|
+
ffTest(
|
|
266
|
+
'platform.editor.table.drag-and-drop',
|
|
267
|
+
() => {
|
|
268
|
+
const { editorView } = editor(
|
|
269
|
+
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
270
|
+
true,
|
|
271
|
+
);
|
|
272
|
+
const eventHandlerSpy = jest.fn();
|
|
273
|
+
withCellTracking(eventHandlerSpy)(editorView, {} as any);
|
|
274
|
+
|
|
275
|
+
expect(eventHandlerSpy).toHaveBeenCalled();
|
|
276
|
+
},
|
|
277
|
+
() => {
|
|
278
|
+
const { editorView } = editor(
|
|
279
|
+
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
280
|
+
);
|
|
281
|
+
const eventHandlerSpy = jest.fn();
|
|
282
|
+
withCellTracking(eventHandlerSpy)(editorView, {} as any);
|
|
283
|
+
|
|
284
|
+
expect(eventHandlerSpy).toHaveBeenCalled();
|
|
285
|
+
},
|
|
286
|
+
);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
describe('should correctly set table cell coordinates based on mouse location', () => {
|
|
290
|
+
ffTest('platform.editor.table.drag-and-drop', () => {
|
|
291
|
+
const { editorView, refs } = editor(
|
|
292
|
+
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
293
|
+
true,
|
|
294
|
+
);
|
|
295
|
+
const firstCell = editorView.domAtPos(refs['<>']);
|
|
296
|
+
|
|
297
|
+
const event = {
|
|
298
|
+
target: firstCell.node,
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
withCellTracking(jest.fn())(editorView, event as any);
|
|
302
|
+
|
|
303
|
+
const pluginState = getPluginState(editorView.state);
|
|
304
|
+
expect(pluginState.hoveredCell).toEqual({ colIndex: 0, rowIndex: 0 });
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
});
|
|
@@ -9,27 +9,47 @@ import {
|
|
|
9
9
|
tdEmpty,
|
|
10
10
|
tr,
|
|
11
11
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
12
|
+
import { ffTest } from '@atlassian/feature-flags-test-utils';
|
|
12
13
|
|
|
13
14
|
import { buildColumnControlsDecorations } from '../../../../plugins/table/pm-plugins/decorations/utils';
|
|
14
15
|
import { TableDecorations } from '../../../../plugins/table/types';
|
|
15
16
|
|
|
16
17
|
describe('tables: column controls decorations', () => {
|
|
17
|
-
describe(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
describe(`should return a decorationSet with 2 ${TableDecorations.COLUMN_CONTROLS_DECORATIONS} type`, () => {
|
|
19
|
+
ffTest(
|
|
20
|
+
'platform.editor.table.drag-and-drop',
|
|
21
|
+
() => {
|
|
22
|
+
const decorationKey = TableDecorations.COLUMN_CONTROLS_DECORATIONS;
|
|
23
|
+
const state = createEditorState(doc(table()(tr(tdCursor, tdEmpty))));
|
|
24
|
+
const nextDecorationSet = buildColumnControlsDecorations({
|
|
25
|
+
decorationSet: DecorationSet.empty,
|
|
26
|
+
tr: state.tr,
|
|
27
|
+
});
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const decorations = nextDecorationSet.find(
|
|
30
|
+
undefined,
|
|
31
|
+
undefined,
|
|
32
|
+
(spec: any) => spec.key.indexOf(decorationKey) > -1,
|
|
33
|
+
);
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
expect(decorations).toHaveLength(2);
|
|
36
|
+
},
|
|
37
|
+
() => {
|
|
38
|
+
const decorationKey = TableDecorations.COLUMN_CONTROLS_DECORATIONS;
|
|
39
|
+
const state = createEditorState(doc(table()(tr(tdCursor, tdEmpty))));
|
|
40
|
+
const nextDecorationSet = buildColumnControlsDecorations({
|
|
41
|
+
decorationSet: DecorationSet.empty,
|
|
42
|
+
tr: state.tr,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const decorations = nextDecorationSet.find(
|
|
46
|
+
undefined,
|
|
47
|
+
undefined,
|
|
48
|
+
(spec: any) => spec.key.indexOf(decorationKey) > -1,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
expect(decorations).toHaveLength(2);
|
|
52
|
+
},
|
|
53
|
+
);
|
|
34
54
|
});
|
|
35
55
|
});
|