@atlaskit/editor-plugin-table 7.5.5 → 7.5.7
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/selection.js +23 -1
- package/dist/cjs/event-handlers.js +25 -9
- package/dist/cjs/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/cjs/nodeviews/TableCell.js +5 -30
- package/dist/cjs/nodeviews/TableComponent.js +96 -41
- package/dist/cjs/nodeviews/TableContainer.js +19 -17
- package/dist/cjs/nodeviews/TableResizer.js +1 -1
- package/dist/cjs/plugin.js +2 -3
- package/dist/cjs/pm-plugins/main.js +3 -18
- package/dist/cjs/pm-plugins/sticky-headers/types.js +1 -5
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +3 -7
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +11 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +22 -23
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +2 -2
- package/dist/cjs/pm-plugins/table-selection-keymap.js +3 -0
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +8 -48
- package/dist/cjs/ui/TableFloatingControls/index.js +113 -223
- package/dist/cjs/utils/column-controls.js +5 -5
- package/dist/cjs/utils/dom.js +13 -15
- package/dist/es2019/commands/selection.js +22 -0
- package/dist/es2019/event-handlers.js +25 -9
- package/dist/es2019/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/es2019/nodeviews/TableCell.js +1 -24
- package/dist/es2019/nodeviews/TableComponent.js +69 -31
- package/dist/es2019/nodeviews/TableContainer.js +16 -18
- package/dist/es2019/nodeviews/TableResizer.js +1 -1
- package/dist/es2019/plugin.js +2 -3
- package/dist/es2019/pm-plugins/main.js +3 -18
- package/dist/es2019/pm-plugins/sticky-headers/types.js +0 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +3 -7
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +10 -0
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +21 -22
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +2 -2
- package/dist/es2019/pm-plugins/table-selection-keymap.js +5 -2
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -27
- package/dist/es2019/ui/TableFloatingControls/index.js +119 -193
- package/dist/es2019/utils/column-controls.js +6 -6
- package/dist/es2019/utils/dom.js +13 -15
- package/dist/esm/commands/selection.js +22 -0
- package/dist/esm/event-handlers.js +25 -9
- package/dist/esm/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/esm/nodeviews/TableCell.js +5 -30
- package/dist/esm/nodeviews/TableComponent.js +96 -41
- package/dist/esm/nodeviews/TableContainer.js +20 -18
- package/dist/esm/nodeviews/TableResizer.js +1 -1
- package/dist/esm/plugin.js +2 -3
- package/dist/esm/pm-plugins/main.js +3 -18
- package/dist/esm/pm-plugins/sticky-headers/types.js +0 -1
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +3 -7
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +10 -0
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +23 -24
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +2 -2
- package/dist/esm/pm-plugins/table-selection-keymap.js +5 -2
- package/dist/esm/ui/TableFloatingColumnControls/index.js +8 -48
- package/dist/esm/ui/TableFloatingControls/index.js +113 -224
- package/dist/esm/utils/column-controls.js +6 -6
- package/dist/esm/utils/dom.js +13 -15
- package/dist/types/commands/selection.d.ts +1 -0
- package/dist/types/event-handlers.d.ts +3 -4
- package/dist/types/nodeviews/OverflowShadowsObserver.d.ts +3 -1
- package/dist/types/nodeviews/TableCell.d.ts +1 -5
- package/dist/types/nodeviews/TableComponent.d.ts +4 -0
- package/dist/types/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -0
- package/dist/types/types.d.ts +0 -3
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -1
- package/dist/types/ui/TableFloatingControls/index.d.ts +5 -22
- package/dist/types/utils/dom.d.ts +10 -2
- package/dist/types-ts4.5/commands/selection.d.ts +1 -0
- package/dist/types-ts4.5/event-handlers.d.ts +3 -4
- package/dist/types-ts4.5/nodeviews/OverflowShadowsObserver.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/TableCell.d.ts +1 -5
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +4 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +0 -3
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +5 -22
- package/dist/types-ts4.5/utils/dom.d.ts +10 -2
- package/package.json +8 -6
- package/src/commands/selection.ts +33 -0
- package/src/event-handlers.ts +105 -103
- package/src/nodeviews/OverflowShadowsObserver.ts +32 -21
- package/src/nodeviews/TableCell.ts +0 -26
- package/src/nodeviews/TableComponent.tsx +81 -34
- package/src/nodeviews/TableContainer.tsx +19 -25
- package/src/nodeviews/TableResizer.tsx +1 -4
- package/src/plugin.tsx +5 -4
- package/src/pm-plugins/main.ts +3 -22
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +3 -6
- package/src/pm-plugins/table-resizing/utils/misc.ts +13 -0
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +22 -28
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +3 -10
- package/src/pm-plugins/table-selection-keymap.ts +10 -0
- package/src/types.ts +0 -4
- package/src/ui/TableFloatingColumnControls/index.tsx +5 -29
- package/src/ui/TableFloatingControls/index.tsx +155 -241
- package/src/utils/column-controls.ts +5 -6
- package/src/utils/dom.ts +12 -19
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
3
3
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
7
7
|
import type { CellHoverMeta } from '../../types';
|
|
8
|
-
export interface
|
|
8
|
+
export interface TableFloatingControlsProps {
|
|
9
9
|
editorView: EditorView;
|
|
10
10
|
selection?: Selection;
|
|
11
11
|
tableRef?: HTMLTableElement;
|
|
@@ -25,24 +25,7 @@ export interface Props {
|
|
|
25
25
|
ordering?: TableColumnOrdering;
|
|
26
26
|
stickyHeader?: RowStickyState;
|
|
27
27
|
insertRowButtonIndex?: number;
|
|
28
|
+
tableWrapperWidth?: number;
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
tableWrapperHeight: number;
|
|
32
|
-
}
|
|
33
|
-
export default class TableFloatingControls extends Component<Props, State> {
|
|
34
|
-
static displayName: string;
|
|
35
|
-
private resizeObserver?;
|
|
36
|
-
constructor(props: Props);
|
|
37
|
-
componentDidMount(): void;
|
|
38
|
-
componentDidUpdate(): void;
|
|
39
|
-
private tryInitResizeObserver;
|
|
40
|
-
shouldComponentUpdate(nextProps: Props, nextState: State): boolean;
|
|
41
|
-
componentWillUnmount(): void;
|
|
42
|
-
render(): JSX.Element | null;
|
|
43
|
-
private selectRow;
|
|
44
|
-
private selectRows;
|
|
45
|
-
private hoverRows;
|
|
46
|
-
private updateCellHoverLocation;
|
|
47
|
-
}
|
|
48
|
-
export {};
|
|
30
|
+
export declare const TableFloatingControls: ({ editorView, tableRef, tableNode, isInDanger, isResizing, isNumberColumnEnabled, isHeaderRowEnabled, isHeaderColumnEnabled, tableActive, hasHeaderRow, hoveredRows, stickyHeader, isDragAndDropEnabled, hoveredCell, isTableHovered, tableWrapperWidth, }: TableFloatingControlsProps) => JSX.Element | null;
|
|
31
|
+
export default TableFloatingControls;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ElementContentRects } from '../types';
|
|
2
1
|
export declare const isCell: (node: HTMLElement | null) => boolean;
|
|
3
2
|
export declare const isCornerButton: (node: HTMLElement | null) => boolean;
|
|
4
3
|
export declare const isInsertRowButton: (node: HTMLElement | null) => boolean | HTMLElement | null;
|
|
@@ -13,7 +12,16 @@ export declare const isDragRowControlsButton: (node: HTMLElement | null) => true
|
|
|
13
12
|
export declare const isDragRowFloatingInsertDot: (node: HTMLElement | null) => boolean;
|
|
14
13
|
export declare const isDragColumnFloatingInsertDot: (node: HTMLElement | null) => boolean;
|
|
15
14
|
export declare const isDragCornerButton: (node: HTMLElement | null) => boolean;
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* This can be used with mouse events to determine the left/right side of the target the pointer is closest too.
|
|
17
|
+
*
|
|
18
|
+
* WARNING: This metod reads properties which can trigger a reflow; use this wisely.
|
|
19
|
+
*
|
|
20
|
+
* @param mouseEvent
|
|
21
|
+
* @param gapInPixels
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
export declare const getMousePositionHorizontalRelativeByElement: (mouseEvent: MouseEvent, offsetX: number, gapInPixels?: number) => 'left' | 'right' | null;
|
|
17
25
|
export declare const getMousePositionVerticalRelativeByElement: (mouseEvent: MouseEvent) => 'top' | 'bottom' | null;
|
|
18
26
|
export declare const hasResizeHandler: ({ columnEndIndexTarget, target, }: {
|
|
19
27
|
columnEndIndexTarget: number;
|
|
@@ -9,3 +9,4 @@ export declare const arrowRightFromTable: (editorSelectionAPI: ExtractInjectionA
|
|
|
9
9
|
export declare const selectColumns: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => (triggeredByKeyboard?: boolean) => Command;
|
|
10
10
|
export declare const selectRows: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => (triggeredByKeyboard?: boolean) => Command;
|
|
11
11
|
export declare const shiftArrowUpFromTable: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => () => Command;
|
|
12
|
+
export declare const modASelectTable: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => () => Command;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
import type { ElementContentRects } from './types';
|
|
5
4
|
export declare const handleBlur: (view: EditorView, event: Event) => boolean;
|
|
6
5
|
export declare const handleFocus: (view: EditorView, event: Event) => boolean;
|
|
7
6
|
export declare const handleClick: (view: EditorView, event: Event) => boolean;
|
|
@@ -11,9 +10,9 @@ export declare const handleMouseDown: (_: EditorView, event: Event) => boolean;
|
|
|
11
10
|
export declare const handleMouseOut: (view: EditorView, mouseEvent: Event) => boolean;
|
|
12
11
|
export declare const handleMouseEnter: (view: EditorView, mouseEvent: Event) => boolean;
|
|
13
12
|
export declare const handleMouseLeave: (view: EditorView, event: Event) => boolean;
|
|
14
|
-
export declare const handleMouseMove: (view: EditorView, event: Event
|
|
13
|
+
export declare const handleMouseMove: (view: EditorView, event: Event) => boolean;
|
|
15
14
|
export declare function handleTripleClick(view: EditorView, pos: number): boolean;
|
|
16
15
|
export declare const handleCut: (oldTr: Transaction, oldState: EditorState, newState: EditorState, editorAnalyticsAPI?: EditorAnalyticsAPI, editorView?: EditorView, isTableScalingEnabled?: boolean) => Transaction;
|
|
17
16
|
export declare const isTableInFocus: (view: EditorView) => boolean;
|
|
18
|
-
export declare const whenTableInFocus: (eventHandler: (view: EditorView, mouseEvent: Event
|
|
19
|
-
export declare const withCellTracking: (eventHandler: (view: EditorView, mouseEvent: Event
|
|
17
|
+
export declare const whenTableInFocus: (eventHandler: (view: EditorView, mouseEvent: Event) => boolean) => (view: EditorView, mouseEvent: Event) => boolean;
|
|
18
|
+
export declare const withCellTracking: (eventHandler: (view: EditorView, mouseEvent: Event) => boolean) => (view: EditorView, mouseEvent: Event) => boolean;
|
|
@@ -19,6 +19,8 @@ export declare class OverflowShadowsObserver {
|
|
|
19
19
|
* e.g. bounds on an IntersectionObserverEntry, otherwise proceed with
|
|
20
20
|
* reading it from sticky cell
|
|
21
21
|
*/
|
|
22
|
-
updateStickyShadows: (stickyRowHeight?: number) => void
|
|
22
|
+
updateStickyShadows: ((stickyRowHeight?: number) => void) & {
|
|
23
|
+
cancel(): void;
|
|
24
|
+
};
|
|
23
25
|
dispose(): void;
|
|
24
26
|
}
|
|
@@ -3,11 +3,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import TableNodeView from './TableNodeViewBase';
|
|
5
5
|
export default class TableCell extends TableNodeView<HTMLElement> implements NodeView {
|
|
6
|
-
|
|
7
|
-
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined, eventDispatcher: EventDispatcher, observer?: ResizeObserver | undefined);
|
|
8
|
-
private isStickyHeaderEnabled;
|
|
9
|
-
private isDragAndDropEnabled;
|
|
6
|
+
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined, eventDispatcher: EventDispatcher);
|
|
10
7
|
update(node: PMNode): boolean;
|
|
11
|
-
destroy(): void;
|
|
12
8
|
private updateNodeView;
|
|
13
9
|
}
|
|
@@ -37,6 +37,8 @@ interface TableState {
|
|
|
37
37
|
stickyHeader?: RowStickyState;
|
|
38
38
|
[ShadowEvent.SHOW_BEFORE_SHADOW]: boolean;
|
|
39
39
|
[ShadowEvent.SHOW_AFTER_SHADOW]: boolean;
|
|
40
|
+
tableWrapperWidth?: number;
|
|
41
|
+
tableWrapperHeight?: number;
|
|
40
42
|
}
|
|
41
43
|
declare class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
42
44
|
static displayName: string;
|
|
@@ -50,6 +52,7 @@ declare class TableComponent extends React.Component<ComponentProps, TableState>
|
|
|
50
52
|
private stickyScrollbar?;
|
|
51
53
|
private isInitialOverflowSent;
|
|
52
54
|
private initialOverflowCaptureTimerId?;
|
|
55
|
+
private resizeObserver?;
|
|
53
56
|
private dragAndDropCleanupFn?;
|
|
54
57
|
constructor(props: ComponentProps);
|
|
55
58
|
componentDidMount(): void;
|
|
@@ -58,6 +61,7 @@ declare class TableComponent extends React.Component<ComponentProps, TableState>
|
|
|
58
61
|
componentDidUpdate(_: any, prevState: TableState): void;
|
|
59
62
|
private updateShadowState;
|
|
60
63
|
private createShadowSentinels;
|
|
64
|
+
private observeTable;
|
|
61
65
|
onStickyState: (state: StickyPluginState) => void;
|
|
62
66
|
prevTableState: any;
|
|
63
67
|
render(): JSX.Element;
|
|
@@ -25,8 +25,9 @@ type ResizableTableContainerProps = {
|
|
|
25
25
|
isResizing?: boolean;
|
|
26
26
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
27
27
|
isTableScalingEnabled?: boolean;
|
|
28
|
+
tableWrapperHeight?: number;
|
|
28
29
|
};
|
|
29
|
-
export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, isTableScalingEnabled, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
|
|
30
|
+
export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, isTableScalingEnabled, tableWrapperHeight, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
|
|
30
31
|
type TableContainerProps = {
|
|
31
32
|
node: PMNode;
|
|
32
33
|
className: string;
|
|
@@ -40,6 +41,7 @@ type TableContainerProps = {
|
|
|
40
41
|
isResizing?: boolean;
|
|
41
42
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
42
43
|
isTableScalingEnabled?: boolean;
|
|
44
|
+
tableWrapperHeight?: number;
|
|
43
45
|
};
|
|
44
|
-
export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isTableResizingEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, isResizing, pluginInjectionApi, isTableScalingEnabled, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
|
|
46
|
+
export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isTableResizingEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, tableWrapperHeight, isResizing, pluginInjectionApi, isTableScalingEnabled, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
|
|
45
47
|
export {};
|
|
@@ -24,4 +24,5 @@ export declare const getTableMaxWidth: ({ table, tableStart, state, layout, getE
|
|
|
24
24
|
*/
|
|
25
25
|
export declare const getTableElementWidth: (table: PMNode) => number;
|
|
26
26
|
export declare const getTableContainerElementWidth: (table: PMNode) => number;
|
|
27
|
+
export declare const getTableScalingPercent: (table: PMNode, tableRef: HTMLElement) => number;
|
|
27
28
|
export {};
|
|
@@ -412,9 +412,6 @@ export interface ToolbarMenuState {
|
|
|
412
412
|
export interface ToolbarMenuContext {
|
|
413
413
|
formatMessage: IntlShape['formatMessage'];
|
|
414
414
|
}
|
|
415
|
-
export type ElementContentRects = {
|
|
416
|
-
[key: string]: ResizeObserverEntry['contentRect'];
|
|
417
|
-
};
|
|
418
415
|
export declare enum ShadowEvent {
|
|
419
416
|
SHOW_BEFORE_SHADOW = "showBeforeShadow",
|
|
420
417
|
SHOW_AFTER_SHADOW = "showAfterShadow"
|
|
@@ -25,6 +25,7 @@ export interface Props {
|
|
|
25
25
|
tableContainerWidth?: number;
|
|
26
26
|
isNumberColumnEnabled?: boolean;
|
|
27
27
|
getScrollOffset?: () => number;
|
|
28
|
+
tableWrapperHeight?: number;
|
|
28
29
|
}
|
|
29
|
-
export declare const TableFloatingColumnControls: ({ editorView, tableRef, getNode, tableActive, hasHeaderRow, hoveredCell, isResizing, stickyHeader, selection, isInDanger, isTableHovered, tableContainerWidth, isNumberColumnEnabled, getScrollOffset, }: Props) => JSX.Element | null;
|
|
30
|
+
export declare const TableFloatingColumnControls: ({ editorView, tableRef, getNode, tableActive, hasHeaderRow, hoveredCell, isResizing, stickyHeader, selection, isInDanger, isTableHovered, tableContainerWidth, isNumberColumnEnabled, getScrollOffset, tableWrapperHeight, }: Props) => JSX.Element | null;
|
|
30
31
|
export default TableFloatingColumnControls;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
3
3
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
7
7
|
import type { CellHoverMeta } from '../../types';
|
|
8
|
-
export interface
|
|
8
|
+
export interface TableFloatingControlsProps {
|
|
9
9
|
editorView: EditorView;
|
|
10
10
|
selection?: Selection;
|
|
11
11
|
tableRef?: HTMLTableElement;
|
|
@@ -25,24 +25,7 @@ export interface Props {
|
|
|
25
25
|
ordering?: TableColumnOrdering;
|
|
26
26
|
stickyHeader?: RowStickyState;
|
|
27
27
|
insertRowButtonIndex?: number;
|
|
28
|
+
tableWrapperWidth?: number;
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
tableWrapperHeight: number;
|
|
32
|
-
}
|
|
33
|
-
export default class TableFloatingControls extends Component<Props, State> {
|
|
34
|
-
static displayName: string;
|
|
35
|
-
private resizeObserver?;
|
|
36
|
-
constructor(props: Props);
|
|
37
|
-
componentDidMount(): void;
|
|
38
|
-
componentDidUpdate(): void;
|
|
39
|
-
private tryInitResizeObserver;
|
|
40
|
-
shouldComponentUpdate(nextProps: Props, nextState: State): boolean;
|
|
41
|
-
componentWillUnmount(): void;
|
|
42
|
-
render(): JSX.Element | null;
|
|
43
|
-
private selectRow;
|
|
44
|
-
private selectRows;
|
|
45
|
-
private hoverRows;
|
|
46
|
-
private updateCellHoverLocation;
|
|
47
|
-
}
|
|
48
|
-
export {};
|
|
30
|
+
export declare const TableFloatingControls: ({ editorView, tableRef, tableNode, isInDanger, isResizing, isNumberColumnEnabled, isHeaderRowEnabled, isHeaderColumnEnabled, tableActive, hasHeaderRow, hoveredRows, stickyHeader, isDragAndDropEnabled, hoveredCell, isTableHovered, tableWrapperWidth, }: TableFloatingControlsProps) => JSX.Element | null;
|
|
31
|
+
export default TableFloatingControls;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ElementContentRects } from '../types';
|
|
2
1
|
export declare const isCell: (node: HTMLElement | null) => boolean;
|
|
3
2
|
export declare const isCornerButton: (node: HTMLElement | null) => boolean;
|
|
4
3
|
export declare const isInsertRowButton: (node: HTMLElement | null) => boolean | HTMLElement | null;
|
|
@@ -16,7 +15,16 @@ export declare const isDragRowControlsButton: (node: HTMLElement | null) => true
|
|
|
16
15
|
export declare const isDragRowFloatingInsertDot: (node: HTMLElement | null) => boolean;
|
|
17
16
|
export declare const isDragColumnFloatingInsertDot: (node: HTMLElement | null) => boolean;
|
|
18
17
|
export declare const isDragCornerButton: (node: HTMLElement | null) => boolean;
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* This can be used with mouse events to determine the left/right side of the target the pointer is closest too.
|
|
20
|
+
*
|
|
21
|
+
* WARNING: This metod reads properties which can trigger a reflow; use this wisely.
|
|
22
|
+
*
|
|
23
|
+
* @param mouseEvent
|
|
24
|
+
* @param gapInPixels
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export declare const getMousePositionHorizontalRelativeByElement: (mouseEvent: MouseEvent, offsetX: number, gapInPixels?: number) => 'left' | 'right' | null;
|
|
20
28
|
export declare const getMousePositionVerticalRelativeByElement: (mouseEvent: MouseEvent) => 'top' | 'bottom' | null;
|
|
21
29
|
export declare const hasResizeHandler: ({ columnEndIndexTarget, target, }: {
|
|
22
30
|
columnEndIndexTarget: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.7",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^35.5.2",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.0.14",
|
|
33
|
-
"@atlaskit/editor-common": "^78.
|
|
33
|
+
"@atlaskit/editor-common": "^78.12.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.5.2",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-content-insertion": "^1.0.0",
|
|
@@ -46,18 +46,17 @@
|
|
|
46
46
|
"@atlaskit/pragmatic-drag-and-drop": "^1.0.0",
|
|
47
47
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.0.0",
|
|
48
48
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
|
|
49
|
-
"@atlaskit/primitives": "^4.
|
|
49
|
+
"@atlaskit/primitives": "^4.1.0",
|
|
50
50
|
"@atlaskit/theme": "^12.6.0",
|
|
51
51
|
"@atlaskit/toggle": "^13.0.0",
|
|
52
|
-
"@atlaskit/tokens": "^1.
|
|
52
|
+
"@atlaskit/tokens": "^1.41.0",
|
|
53
53
|
"@atlaskit/tooltip": "^18.1.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
55
55
|
"@emotion/react": "^11.7.1",
|
|
56
56
|
"classnames": "^2.2.5",
|
|
57
57
|
"lodash": "^4.17.21",
|
|
58
58
|
"memoize-one": "^6.0.0",
|
|
59
|
-
"raf-schd": "^4.0.3"
|
|
60
|
-
"uuid": "^3.1.0"
|
|
59
|
+
"raf-schd": "^4.0.3"
|
|
61
60
|
},
|
|
62
61
|
"peerDependencies": {
|
|
63
62
|
"react": "^16.8.0",
|
|
@@ -143,6 +142,9 @@
|
|
|
143
142
|
},
|
|
144
143
|
"platform.editor.transform-slice-for-nested-expand": {
|
|
145
144
|
"type": "boolean"
|
|
145
|
+
},
|
|
146
|
+
"platform.editor.table.cmd-a-select-table": {
|
|
147
|
+
"type": "boolean"
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
150
|
}
|
|
@@ -589,3 +589,36 @@ export const shiftArrowUpFromTable =
|
|
|
589
589
|
|
|
590
590
|
return false;
|
|
591
591
|
};
|
|
592
|
+
|
|
593
|
+
export const modASelectTable =
|
|
594
|
+
(
|
|
595
|
+
editorSelectionAPI:
|
|
596
|
+
| ExtractInjectionAPI<typeof tablePlugin>['selection']
|
|
597
|
+
| undefined,
|
|
598
|
+
) =>
|
|
599
|
+
(): Command =>
|
|
600
|
+
(state, dispatch) => {
|
|
601
|
+
const { selection } = state;
|
|
602
|
+
const table = findTable(selection);
|
|
603
|
+
|
|
604
|
+
if (!table) {
|
|
605
|
+
return false;
|
|
606
|
+
}
|
|
607
|
+
const { $from, $to } = selection;
|
|
608
|
+
|
|
609
|
+
const tableSelected = isTableSelected(selection);
|
|
610
|
+
|
|
611
|
+
if (
|
|
612
|
+
!tableSelected &&
|
|
613
|
+
$from.pos > table.start + 1 &&
|
|
614
|
+
$to.pos < table.start + table.node.nodeSize
|
|
615
|
+
) {
|
|
616
|
+
return selectFullTable(editorSelectionAPI)({
|
|
617
|
+
node: table.node,
|
|
618
|
+
startPos: table.start,
|
|
619
|
+
dir: TableSelectionDirection.BottomToTop,
|
|
620
|
+
})(state, dispatch);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
return false;
|
|
624
|
+
};
|
package/src/event-handlers.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import rafSchedule from 'raf-schd';
|
|
2
|
+
|
|
1
3
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
4
|
import {
|
|
3
5
|
ACTION_SUBJECT,
|
|
@@ -47,7 +49,6 @@ import { getPluginState as getDragDropPluginState } from './pm-plugins/drag-and-
|
|
|
47
49
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
48
50
|
import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
|
|
49
51
|
import { deleteColumns, deleteRows } from './transforms';
|
|
50
|
-
import type { ElementContentRects } from './types';
|
|
51
52
|
import {
|
|
52
53
|
TableCssClassName as ClassName,
|
|
53
54
|
RESIZE_HANDLE_AREA_DECORATION_GAP,
|
|
@@ -406,104 +407,119 @@ export const handleMouseLeave = (view: EditorView, event: Event): boolean => {
|
|
|
406
407
|
return false;
|
|
407
408
|
};
|
|
408
409
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
)
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
const element = event.target;
|
|
418
|
-
|
|
419
|
-
if (
|
|
420
|
-
isColumnControlsDecorations(element) ||
|
|
421
|
-
isDragColumnFloatingInsertDot(element)
|
|
422
|
-
) {
|
|
423
|
-
const { state, dispatch } = view;
|
|
424
|
-
const { insertColumnButtonIndex, isDragAndDropEnabled } =
|
|
425
|
-
getPluginState(state);
|
|
426
|
-
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
427
|
-
|
|
428
|
-
const positionColumn =
|
|
429
|
-
getMousePositionHorizontalRelativeByElement(
|
|
430
|
-
event as MouseEvent,
|
|
431
|
-
elementContentRects,
|
|
432
|
-
undefined,
|
|
433
|
-
isDragAndDropEnabled,
|
|
434
|
-
) === 'right'
|
|
435
|
-
? endIndex
|
|
436
|
-
: startIndex;
|
|
410
|
+
// IMPORTANT: The mouse move handler has been setup with RAF schedule to avoid Reflows which will occur as some methods
|
|
411
|
+
// need to access the mouse event offset position and also the target clientWidth vallue.
|
|
412
|
+
const handleMouseMoveDebounce = rafSchedule(
|
|
413
|
+
(view: EditorView, event: MouseEvent, offsetX: number) => {
|
|
414
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
const element = event.target;
|
|
437
418
|
|
|
438
|
-
if (
|
|
439
|
-
|
|
419
|
+
if (
|
|
420
|
+
isColumnControlsDecorations(element) ||
|
|
421
|
+
isDragColumnFloatingInsertDot(element)
|
|
422
|
+
) {
|
|
423
|
+
const { state, dispatch } = view;
|
|
424
|
+
const { insertColumnButtonIndex } = getPluginState(state);
|
|
425
|
+
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
426
|
+
|
|
427
|
+
const positionColumn =
|
|
428
|
+
getMousePositionHorizontalRelativeByElement(
|
|
429
|
+
event,
|
|
430
|
+
offsetX,
|
|
431
|
+
undefined,
|
|
432
|
+
) === 'right'
|
|
433
|
+
? endIndex
|
|
434
|
+
: startIndex;
|
|
435
|
+
|
|
436
|
+
if (positionColumn !== insertColumnButtonIndex) {
|
|
437
|
+
return showInsertColumnButton(positionColumn)(state, dispatch);
|
|
438
|
+
}
|
|
440
439
|
}
|
|
441
|
-
}
|
|
442
440
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
441
|
+
if (isRowControlsButton(element) || isDragRowFloatingInsertDot(element)) {
|
|
442
|
+
const { state, dispatch } = view;
|
|
443
|
+
const { insertRowButtonIndex } = getPluginState(state);
|
|
444
|
+
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
447
445
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
: startIndex;
|
|
446
|
+
const positionRow =
|
|
447
|
+
getMousePositionVerticalRelativeByElement(event) === 'bottom'
|
|
448
|
+
? endIndex
|
|
449
|
+
: startIndex;
|
|
453
450
|
|
|
454
|
-
|
|
455
|
-
|
|
451
|
+
if (positionRow !== insertRowButtonIndex) {
|
|
452
|
+
return showInsertRowButton(positionRow)(state, dispatch);
|
|
453
|
+
}
|
|
456
454
|
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
if (!isResizeHandleDecoration(element) && isCell(element)) {
|
|
460
|
-
const positionColumn = getMousePositionHorizontalRelativeByElement(
|
|
461
|
-
event as MouseEvent,
|
|
462
|
-
elementContentRects,
|
|
463
|
-
RESIZE_HANDLE_AREA_DECORATION_GAP,
|
|
464
|
-
);
|
|
465
455
|
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
const isKeyboardResize = getBooleanFF(
|
|
472
|
-
'platform.editor.a11y-column-resizing_emcvz',
|
|
473
|
-
)
|
|
474
|
-
? getPluginState(state).isKeyboardResize
|
|
475
|
-
: false;
|
|
476
|
-
const tableCell = closestElement(
|
|
477
|
-
element,
|
|
478
|
-
'td, th',
|
|
479
|
-
) as HTMLTableCellElement;
|
|
480
|
-
const cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
481
|
-
const rect = findCellRectClosestToPos(
|
|
482
|
-
state.doc.resolve(cellStartPosition),
|
|
456
|
+
if (!isResizeHandleDecoration(element) && isCell(element)) {
|
|
457
|
+
const positionColumn = getMousePositionHorizontalRelativeByElement(
|
|
458
|
+
event,
|
|
459
|
+
offsetX,
|
|
460
|
+
RESIZE_HANDLE_AREA_DECORATION_GAP,
|
|
483
461
|
);
|
|
484
462
|
|
|
485
|
-
if (
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
)
|
|
463
|
+
if (positionColumn !== null) {
|
|
464
|
+
const { state, dispatch } = view;
|
|
465
|
+
const { resizeHandleColumnIndex, resizeHandleRowIndex } =
|
|
466
|
+
getPluginState(state);
|
|
467
|
+
|
|
468
|
+
const isKeyboardResize = getBooleanFF(
|
|
469
|
+
'platform.editor.a11y-column-resizing_emcvz',
|
|
470
|
+
)
|
|
471
|
+
? getPluginState(state).isKeyboardResize
|
|
472
|
+
: false;
|
|
473
|
+
const tableCell = closestElement(
|
|
474
|
+
element,
|
|
475
|
+
'td, th',
|
|
476
|
+
) as HTMLTableCellElement;
|
|
477
|
+
const cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
478
|
+
const rect = findCellRectClosestToPos(
|
|
479
|
+
state.doc.resolve(cellStartPosition),
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
if (rect) {
|
|
483
|
+
const columnEndIndexTarget =
|
|
484
|
+
positionColumn === 'left' ? rect.left : rect.right;
|
|
485
|
+
|
|
486
|
+
const rowIndexTarget = rect.top;
|
|
487
|
+
|
|
488
|
+
if (
|
|
489
|
+
(columnEndIndexTarget !== resizeHandleColumnIndex ||
|
|
490
|
+
rowIndexTarget !== resizeHandleRowIndex ||
|
|
491
|
+
!hasResizeHandler({ target: element, columnEndIndexTarget })) &&
|
|
492
|
+
!isKeyboardResize // if initiated by keyboard don't need to react on hover for other resize sliders
|
|
493
|
+
) {
|
|
494
|
+
return addResizeHandleDecorations(
|
|
495
|
+
rowIndexTarget,
|
|
496
|
+
columnEndIndexTarget,
|
|
497
|
+
true,
|
|
498
|
+
)(state, dispatch);
|
|
499
|
+
}
|
|
502
500
|
}
|
|
503
501
|
}
|
|
504
502
|
}
|
|
503
|
+
|
|
504
|
+
return false;
|
|
505
|
+
},
|
|
506
|
+
);
|
|
507
|
+
|
|
508
|
+
export const handleMouseMove = (view: EditorView, event: Event) => {
|
|
509
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
510
|
+
return false;
|
|
505
511
|
}
|
|
506
512
|
|
|
513
|
+
// NOTE: When accessing offsetX in gecko from a deferred callback, it will return 0. However it will be non-zero if accessed
|
|
514
|
+
// within the scope of it's initial mouse move handler. Also Chrome does return the correct value, however it could trigger
|
|
515
|
+
// a reflow. So for now this will just grab the offsetX value immediately for gecko and chrome will calculate later
|
|
516
|
+
// in the deferred callback handler.
|
|
517
|
+
// Bug Tracking: https://bugzilla.mozilla.org/show_bug.cgi?id=1882903
|
|
518
|
+
handleMouseMoveDebounce(
|
|
519
|
+
view,
|
|
520
|
+
event as MouseEvent,
|
|
521
|
+
browser.gecko ? (event as MouseEvent).offsetX : NaN,
|
|
522
|
+
);
|
|
507
523
|
return false;
|
|
508
524
|
};
|
|
509
525
|
|
|
@@ -614,20 +630,13 @@ export const isTableInFocus = (view: EditorView) => {
|
|
|
614
630
|
};
|
|
615
631
|
|
|
616
632
|
export const whenTableInFocus =
|
|
617
|
-
(
|
|
618
|
-
eventHandler: (
|
|
619
|
-
view: EditorView,
|
|
620
|
-
mouseEvent: Event,
|
|
621
|
-
elementContentRects?: ElementContentRects,
|
|
622
|
-
) => boolean,
|
|
623
|
-
elementContentRects?: ElementContentRects,
|
|
624
|
-
) =>
|
|
633
|
+
(eventHandler: (view: EditorView, mouseEvent: Event) => boolean) =>
|
|
625
634
|
(view: EditorView, mouseEvent: Event): boolean => {
|
|
626
635
|
if (!isTableInFocus(view)) {
|
|
627
636
|
return false;
|
|
628
637
|
}
|
|
629
638
|
|
|
630
|
-
return eventHandler(view, mouseEvent
|
|
639
|
+
return eventHandler(view, mouseEvent);
|
|
631
640
|
};
|
|
632
641
|
|
|
633
642
|
const trackCellLocation = (view: EditorView, mouseEvent: Event) => {
|
|
@@ -681,14 +690,7 @@ const trackCellLocation = (view: EditorView, mouseEvent: Event) => {
|
|
|
681
690
|
};
|
|
682
691
|
|
|
683
692
|
export const withCellTracking =
|
|
684
|
-
(
|
|
685
|
-
eventHandler: (
|
|
686
|
-
view: EditorView,
|
|
687
|
-
mouseEvent: Event,
|
|
688
|
-
elementContentRects?: ElementContentRects,
|
|
689
|
-
) => boolean,
|
|
690
|
-
elementContentRects?: ElementContentRects,
|
|
691
|
-
) =>
|
|
693
|
+
(eventHandler: (view: EditorView, mouseEvent: Event) => boolean) =>
|
|
692
694
|
(view: EditorView, mouseEvent: Event): boolean => {
|
|
693
695
|
if (
|
|
694
696
|
getPluginState(view.state).isDragAndDropEnabled &&
|
|
@@ -696,5 +698,5 @@ export const withCellTracking =
|
|
|
696
698
|
) {
|
|
697
699
|
trackCellLocation(view, mouseEvent);
|
|
698
700
|
}
|
|
699
|
-
return eventHandler(view, mouseEvent
|
|
701
|
+
return eventHandler(view, mouseEvent);
|
|
700
702
|
};
|