@atlaskit/editor-plugin-table 5.4.6 → 5.4.8
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/insert.js +12 -2
- package/dist/cjs/plugins/table/commands/misc.js +63 -13
- package/dist/cjs/plugins/table/index.js +46 -35
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +14 -20
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/table.js +3 -1
- package/dist/cjs/plugins/table/pm-plugins/analytics/actions.js +14 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/commands.js +45 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/plugin-factory.js +13 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/plugin-key.js +8 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/plugin.js +74 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/reducer.js +26 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/types.js +13 -0
- package/dist/cjs/plugins/table/pm-plugins/analytics/utils/moved-event.js +38 -0
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +9 -3
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
- package/dist/cjs/plugins/table/pm-plugins/main.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/table-analytics.js +1 -1
- package/dist/cjs/plugins/table/types.js +2 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +4 -1
- package/dist/cjs/plugins/table/ui/common-styles.js +6 -9
- package/dist/cjs/plugins/table/ui/ui-styles.js +12 -16
- package/dist/cjs/plugins/table/utils/decoration.js +20 -25
- package/dist/es2019/plugins/table/commands/insert.js +12 -3
- package/dist/es2019/plugins/table/commands/misc.js +54 -4
- package/dist/es2019/plugins/table/index.js +14 -4
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +15 -21
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/table.js +3 -1
- package/dist/es2019/plugins/table/pm-plugins/analytics/actions.js +8 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/commands.js +33 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/plugin-factory.js +8 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/plugin-key.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/plugin.js +72 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/reducer.js +21 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/types.js +7 -0
- package/dist/es2019/plugins/table/pm-plugins/analytics/utils/moved-event.js +30 -0
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +9 -3
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
- package/dist/es2019/plugins/table/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/table-analytics.js +1 -1
- package/dist/es2019/plugins/table/types.js +2 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +20 -20
- package/dist/es2019/plugins/table/ui/ui-styles.js +18 -21
- package/dist/es2019/plugins/table/utils/decoration.js +20 -25
- package/dist/esm/plugins/table/commands/insert.js +12 -3
- package/dist/esm/plugins/table/commands/misc.js +61 -13
- package/dist/esm/plugins/table/index.js +43 -32
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +15 -21
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +1 -1
- package/dist/esm/plugins/table/nodeviews/table.js +3 -1
- package/dist/esm/plugins/table/pm-plugins/analytics/actions.js +8 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/commands.js +39 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/plugin-factory.js +8 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/plugin-key.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/plugin.js +68 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/reducer.js +19 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/types.js +7 -0
- package/dist/esm/plugins/table/pm-plugins/analytics/utils/moved-event.js +31 -0
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +9 -3
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
- package/dist/esm/plugins/table/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/table-analytics.js +1 -1
- package/dist/esm/plugins/table/types.js +2 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +4 -1
- package/dist/esm/plugins/table/ui/common-styles.js +6 -9
- package/dist/esm/plugins/table/ui/ui-styles.js +12 -16
- package/dist/esm/plugins/table/utils/decoration.js +20 -25
- package/dist/types/plugins/table/commands/misc.d.ts +5 -1
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +2 -0
- package/dist/types/plugins/table/nodeviews/table.d.ts +2 -1
- package/dist/types/plugins/table/nodeviews/types.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/analytics/actions.d.ts +17 -0
- package/dist/types/plugins/table/pm-plugins/analytics/commands.d.ts +5 -0
- package/dist/types/plugins/table/pm-plugins/analytics/plugin-factory.d.ts +1 -0
- package/dist/types/plugins/table/pm-plugins/analytics/plugin-key.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/analytics/plugin.d.ts +4 -0
- package/dist/types/plugins/table/pm-plugins/analytics/reducer.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/analytics/types.d.ts +11 -0
- package/dist/types/plugins/table/pm-plugins/analytics/utils/moved-event.d.ts +6 -0
- package/dist/types/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -2
- package/dist/types/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/decorations/utils/types.d.ts +10 -4
- package/dist/types/plugins/table/types.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +5 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/actions.d.ts +17 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/commands.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/plugin-factory.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/plugin.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/reducer.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/types.d.ts +11 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/analytics/utils/moved-event.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/types.d.ts +10 -4
- package/dist/types-ts4.5/plugins/table/types.d.ts +2 -1
- package/package.json +4 -1
- package/src/__tests__/unit/event-handlers.ts +37 -38
- package/src/__tests__/unit/index-with-fake-timers.ts +1 -0
- package/src/__tests__/unit/nodeviews/table.ts +1 -0
- package/src/__tests__/unit/pm-plugins/analytics.ts +327 -0
- package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +46 -36
- package/src/plugins/table/commands/insert.ts +23 -2
- package/src/plugins/table/commands/misc.ts +93 -8
- package/src/plugins/table/index.tsx +13 -6
- package/src/plugins/table/nodeviews/TableComponent.tsx +35 -44
- package/src/plugins/table/nodeviews/TableResizer.tsx +1 -2
- package/src/plugins/table/nodeviews/table.tsx +4 -0
- package/src/plugins/table/nodeviews/types.ts +2 -0
- package/src/plugins/table/pm-plugins/analytics/actions.ts +23 -0
- package/src/plugins/table/pm-plugins/analytics/commands.ts +53 -0
- package/src/plugins/table/pm-plugins/analytics/plugin-factory.ts +7 -0
- package/src/plugins/table/pm-plugins/analytics/plugin-key.ts +7 -0
- package/src/plugins/table/pm-plugins/analytics/plugin.ts +98 -0
- package/src/plugins/table/pm-plugins/analytics/reducer.ts +27 -0
- package/src/plugins/table/pm-plugins/analytics/types.ts +20 -0
- package/src/plugins/table/pm-plugins/analytics/utils/moved-event.ts +51 -0
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +7 -2
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +20 -11
- package/src/plugins/table/pm-plugins/decorations/utils/compose-decorations.ts +2 -4
- package/src/plugins/table/pm-plugins/decorations/utils/types.ts +14 -7
- package/src/plugins/table/pm-plugins/main.ts +1 -0
- package/src/plugins/table/pm-plugins/table-analytics.ts +1 -1
- package/src/plugins/table/types.ts +2 -1
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +73 -67
- package/src/plugins/table/ui/common-styles.ts +20 -23
- package/src/plugins/table/ui/ui-styles.ts +18 -21
- package/src/plugins/table/utils/decoration.ts +27 -32
- package/tsconfig.dev.json +3 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
4
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
4
5
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
@@ -29,5 +30,5 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
29
30
|
}): boolean;
|
|
30
31
|
destroy(): void;
|
|
31
32
|
}
|
|
32
|
-
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
|
|
33
|
+
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
|
|
33
34
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
3
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
3
4
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
@@ -22,6 +23,7 @@ export interface Props {
|
|
|
22
23
|
options?: TableOptions;
|
|
23
24
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
24
25
|
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
26
|
+
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
25
27
|
hasIntlContext: boolean;
|
|
26
28
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
27
29
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RowOrColumnMovedState } from './types';
|
|
2
|
+
export declare enum AnalyticPluginTypes {
|
|
3
|
+
UpdateOverflowTriggerNameAction = 0,
|
|
4
|
+
UpdateRowOrColumnMovedAction = 1,
|
|
5
|
+
RemoveRowOrColumnMovedAction = 2,
|
|
6
|
+
RemoveOverFlowTriggerNameAction = 3,
|
|
7
|
+
UpdateRowOrColumnMovedAndOverflowTrigger = 4
|
|
8
|
+
}
|
|
9
|
+
export type UpdateRowOrColumnMovedAction = {
|
|
10
|
+
type: AnalyticPluginTypes.UpdateRowOrColumnMovedAction;
|
|
11
|
+
data: RowOrColumnMovedState;
|
|
12
|
+
};
|
|
13
|
+
export type RemoveRowOrColumnMovedAction = {
|
|
14
|
+
type: AnalyticPluginTypes.RemoveRowOrColumnMovedAction;
|
|
15
|
+
data: undefined;
|
|
16
|
+
};
|
|
17
|
+
export type AnalyticPluginAction = UpdateRowOrColumnMovedAction | RemoveRowOrColumnMovedAction;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { ActionType, RowOrColumnMovedState } from './types';
|
|
3
|
+
export declare const updateRowOrColumnMoved: (nextState: Omit<RowOrColumnMovedState, 'currentActions'>, nextAction: ActionType) => import("@atlaskit/editor-common/types").Command;
|
|
4
|
+
export declare const resetRowOrColumnMovedTransform: () => (tr: Transaction) => Transaction;
|
|
5
|
+
export declare const updateRowOrColumnMovedTransform: (nextState: Omit<RowOrColumnMovedState, 'currentActions'>, nextAction: ActionType) => (state: EditorState, tr: Transaction) => Transaction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: import("./types").AnalyticPluginState | ((state: import("prosemirror-state").EditorState) => import("./types").AnalyticPluginState)) => import("prosemirror-state").SafeStateField<import("./types").AnalyticPluginState>, createCommand: <A = import("./actions").AnalyticPluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => import("./types").AnalyticPluginState;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
export declare const createPlugin: (dispatch: Dispatch, dispatchAnalyticsEvent: DispatchAnalyticsEvent) => SafePlugin<import("./types").AnalyticPluginState>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ActionType = 'none' | 'addRowOrColumn' | 'copyOrCut' | 'pasted';
|
|
2
|
+
export type RowOrColumnMovedState = {
|
|
3
|
+
type?: 'row' | 'column';
|
|
4
|
+
/** used to confirm if same number of cells was copied and pasted */
|
|
5
|
+
numberOfCells?: number;
|
|
6
|
+
currentActions: Array<ActionType>;
|
|
7
|
+
};
|
|
8
|
+
export type AnalyticPluginState = {
|
|
9
|
+
rowOrColumnMoved: RowOrColumnMovedState;
|
|
10
|
+
};
|
|
11
|
+
export declare const defaultState: AnalyticPluginState;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ActionType, RowOrColumnMovedState } from '../types';
|
|
2
|
+
export declare const getMovedPayload: (nextState: Omit<RowOrColumnMovedState, 'currentActions'>, nextAction: ActionType, prevState: RowOrColumnMovedState) => RowOrColumnMovedState | {
|
|
3
|
+
currentActions: string[];
|
|
4
|
+
numberOfCells: number | undefined;
|
|
5
|
+
type: "row" | "column" | undefined;
|
|
6
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import type { BuildDecorationTransformerParams, DecorationTransformer } from './types';
|
|
2
3
|
export declare const maybeUpdateColumnControlsSelectedDecoration: DecorationTransformer;
|
|
3
|
-
export declare const buildColumnControlsDecorations:
|
|
4
|
+
export declare const buildColumnControlsDecorations: ({ decorationSet, tr, options, }: BuildDecorationTransformerParams) => DecorationSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DecorationTransformer } from './types';
|
|
1
|
+
import type { DecorationTransformer } from './types';
|
|
2
2
|
export declare const composeDecorations: (transformers: Array<DecorationTransformer>) => DecorationTransformer;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
export type DecorationTransformer = (
|
|
1
|
+
import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
export type DecorationTransformer = (params: DecorationTransformerParams) => DecorationSet;
|
|
4
|
+
export type DecorationTransformerParams = {
|
|
4
5
|
decorationSet: DecorationSet;
|
|
5
6
|
tr: Transaction | ReadonlyTransaction;
|
|
6
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export type BuildDecorationTransformerParams = DecorationTransformerParams & {
|
|
9
|
+
options: {
|
|
10
|
+
isDragAndDropEnabled: boolean;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -282,7 +282,8 @@ export declare const TableCssClassName: {
|
|
|
282
282
|
CORNER_CONTROLS_INSERT_ROW_MARKER: string;
|
|
283
283
|
CORNER_CONTROLS_INSERT_COLUMN_MARKER: string;
|
|
284
284
|
CONTROLS_CORNER_BUTTON: string;
|
|
285
|
-
/**
|
|
285
|
+
/** drag and drop controls */
|
|
286
|
+
DRAG_ROW_CONTROLS_WRAPPER: string;
|
|
286
287
|
DRAG_ROW_CONTROLS: string;
|
|
287
288
|
DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER: string;
|
|
288
289
|
DRAG_ROW_FLOATING_INSERT_DOT: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
export declare const setEditorFocus: (editorHasFocus: boolean) => Command;
|
|
@@ -10,6 +10,10 @@ export declare const triggerUnlessTableHeader: (command: Command) => Command;
|
|
|
10
10
|
export declare const transformSliceRemoveCellBackgroundColor: (slice: Slice, schema: Schema) => Slice;
|
|
11
11
|
export declare const transformSliceToAddTableHeaders: (slice: Slice, schema: Schema) => Slice;
|
|
12
12
|
export declare const transformSliceToRemoveColumnsWidths: (slice: Slice, schema: Schema) => Slice;
|
|
13
|
+
export declare const countCellsInSlice: (slice: Slice, schema: Schema, type?: 'row' | 'column') => number;
|
|
14
|
+
export declare const getTableSelectionType: (selection: Selection) => "row" | "column" | undefined;
|
|
15
|
+
export declare const getTableElementMoveTypeBySlice: (slice: Slice, state: EditorState) => "row" | "column" | undefined;
|
|
16
|
+
export declare const isInsideFirstCellOfRowOrColumn: (selection: Selection, type?: 'row' | 'column') => boolean | undefined;
|
|
13
17
|
export declare const deleteTable: Command;
|
|
14
18
|
export declare const deleteTableIfSelected: Command;
|
|
15
19
|
export declare const convertFirstRowToHeader: (schema: Schema) => (tr: Transaction) => Transaction;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
3
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
4
5
|
import type { EditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
5
6
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -26,6 +27,7 @@ export interface ComponentProps {
|
|
|
26
27
|
ordering: TableColumnOrdering;
|
|
27
28
|
isResizing?: boolean;
|
|
28
29
|
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
30
|
+
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
29
31
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
30
32
|
}
|
|
31
33
|
interface TableState {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
4
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
4
5
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
@@ -29,5 +30,5 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
29
30
|
}): boolean;
|
|
30
31
|
destroy(): void;
|
|
31
32
|
}
|
|
32
|
-
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
|
|
33
|
+
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
|
|
33
34
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
3
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
3
4
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
@@ -22,6 +23,7 @@ export interface Props {
|
|
|
22
23
|
options?: TableOptions;
|
|
23
24
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
24
25
|
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
26
|
+
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
25
27
|
hasIntlContext: boolean;
|
|
26
28
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
27
29
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RowOrColumnMovedState } from './types';
|
|
2
|
+
export declare enum AnalyticPluginTypes {
|
|
3
|
+
UpdateOverflowTriggerNameAction = 0,
|
|
4
|
+
UpdateRowOrColumnMovedAction = 1,
|
|
5
|
+
RemoveRowOrColumnMovedAction = 2,
|
|
6
|
+
RemoveOverFlowTriggerNameAction = 3,
|
|
7
|
+
UpdateRowOrColumnMovedAndOverflowTrigger = 4
|
|
8
|
+
}
|
|
9
|
+
export type UpdateRowOrColumnMovedAction = {
|
|
10
|
+
type: AnalyticPluginTypes.UpdateRowOrColumnMovedAction;
|
|
11
|
+
data: RowOrColumnMovedState;
|
|
12
|
+
};
|
|
13
|
+
export type RemoveRowOrColumnMovedAction = {
|
|
14
|
+
type: AnalyticPluginTypes.RemoveRowOrColumnMovedAction;
|
|
15
|
+
data: undefined;
|
|
16
|
+
};
|
|
17
|
+
export type AnalyticPluginAction = UpdateRowOrColumnMovedAction | RemoveRowOrColumnMovedAction;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { ActionType, RowOrColumnMovedState } from './types';
|
|
3
|
+
export declare const updateRowOrColumnMoved: (nextState: Omit<RowOrColumnMovedState, 'currentActions'>, nextAction: ActionType) => import("@atlaskit/editor-common/types").Command;
|
|
4
|
+
export declare const resetRowOrColumnMovedTransform: () => (tr: Transaction) => Transaction;
|
|
5
|
+
export declare const updateRowOrColumnMovedTransform: (nextState: Omit<RowOrColumnMovedState, 'currentActions'>, nextAction: ActionType) => (state: EditorState, tr: Transaction) => Transaction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: import("./types").AnalyticPluginState | ((state: import("prosemirror-state").EditorState) => import("./types").AnalyticPluginState)) => import("prosemirror-state").SafeStateField<import("./types").AnalyticPluginState>, createCommand: <A = import("./actions").AnalyticPluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => import("./types").AnalyticPluginState;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
export declare const createPlugin: (dispatch: Dispatch, dispatchAnalyticsEvent: DispatchAnalyticsEvent) => SafePlugin<import("./types").AnalyticPluginState>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ActionType = 'none' | 'addRowOrColumn' | 'copyOrCut' | 'pasted';
|
|
2
|
+
export type RowOrColumnMovedState = {
|
|
3
|
+
type?: 'row' | 'column';
|
|
4
|
+
/** used to confirm if same number of cells was copied and pasted */
|
|
5
|
+
numberOfCells?: number;
|
|
6
|
+
currentActions: Array<ActionType>;
|
|
7
|
+
};
|
|
8
|
+
export type AnalyticPluginState = {
|
|
9
|
+
rowOrColumnMoved: RowOrColumnMovedState;
|
|
10
|
+
};
|
|
11
|
+
export declare const defaultState: AnalyticPluginState;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ActionType, RowOrColumnMovedState } from '../types';
|
|
2
|
+
export declare const getMovedPayload: (nextState: Omit<RowOrColumnMovedState, 'currentActions'>, nextAction: ActionType, prevState: RowOrColumnMovedState) => RowOrColumnMovedState | {
|
|
3
|
+
currentActions: string[];
|
|
4
|
+
numberOfCells: number | undefined;
|
|
5
|
+
type: "row" | "column" | undefined;
|
|
6
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import type { BuildDecorationTransformerParams, DecorationTransformer } from './types';
|
|
2
3
|
export declare const maybeUpdateColumnControlsSelectedDecoration: DecorationTransformer;
|
|
3
|
-
export declare const buildColumnControlsDecorations:
|
|
4
|
+
export declare const buildColumnControlsDecorations: ({ decorationSet, tr, options, }: BuildDecorationTransformerParams) => DecorationSet;
|
package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DecorationTransformer } from './types';
|
|
1
|
+
import type { DecorationTransformer } from './types';
|
|
2
2
|
export declare const composeDecorations: (transformers: Array<DecorationTransformer>) => DecorationTransformer;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
export type DecorationTransformer = (
|
|
1
|
+
import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
export type DecorationTransformer = (params: DecorationTransformerParams) => DecorationSet;
|
|
4
|
+
export type DecorationTransformerParams = {
|
|
4
5
|
decorationSet: DecorationSet;
|
|
5
6
|
tr: Transaction | ReadonlyTransaction;
|
|
6
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export type BuildDecorationTransformerParams = DecorationTransformerParams & {
|
|
9
|
+
options: {
|
|
10
|
+
isDragAndDropEnabled: boolean;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -282,7 +282,8 @@ export declare const TableCssClassName: {
|
|
|
282
282
|
CORNER_CONTROLS_INSERT_ROW_MARKER: string;
|
|
283
283
|
CORNER_CONTROLS_INSERT_COLUMN_MARKER: string;
|
|
284
284
|
CONTROLS_CORNER_BUTTON: string;
|
|
285
|
-
/**
|
|
285
|
+
/** drag and drop controls */
|
|
286
|
+
DRAG_ROW_CONTROLS_WRAPPER: string;
|
|
286
287
|
DRAG_ROW_CONTROLS: string;
|
|
287
288
|
DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER: string;
|
|
288
289
|
DRAG_ROW_FLOATING_INSERT_DOT: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.8",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -141,6 +141,9 @@
|
|
|
141
141
|
},
|
|
142
142
|
"platform.editor.table.alternative-sticky-header-logic": {
|
|
143
143
|
"type": "boolean"
|
|
144
|
+
},
|
|
145
|
+
"platform.editor.table.analytics-plugin-moved-event": {
|
|
146
|
+
"type": "boolean"
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
}
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
tdEmpty,
|
|
27
27
|
tr,
|
|
28
28
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
29
|
-
import {
|
|
29
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
30
30
|
|
|
31
31
|
import tablePlugin from '../../plugins/table-plugin';
|
|
32
32
|
import {
|
|
@@ -44,6 +44,15 @@ import { getPluginState } from '../../plugins/table/pm-plugins/plugin-factory';
|
|
|
44
44
|
import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
45
45
|
import { TableCssClassName as ClassName } from '../../plugins/table/types';
|
|
46
46
|
|
|
47
|
+
// Mock Feature flags instead of using ffTest because we don't use the feature flag directly
|
|
48
|
+
jest.mock('@atlaskit/platform-feature-flags', () => ({
|
|
49
|
+
getBooleanFF: jest.fn().mockImplementation(() => false),
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
(getBooleanFF as jest.Mock).mockReset();
|
|
54
|
+
});
|
|
55
|
+
|
|
47
56
|
describe('table plugin: decorations', () => {
|
|
48
57
|
const createEditor = createProsemirrorEditorFactory();
|
|
49
58
|
const editor = (doc: DocBuilder) =>
|
|
@@ -263,49 +272,39 @@ describe('withCellTracking', () => {
|
|
|
263
272
|
});
|
|
264
273
|
|
|
265
274
|
describe('should fire event handler passed in', () => {
|
|
266
|
-
|
|
267
|
-
'platform.editor.table.drag-and-drop',
|
|
268
|
-
() => {
|
|
269
|
-
const { editorView } = editor(
|
|
270
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
271
|
-
true,
|
|
272
|
-
);
|
|
273
|
-
const eventHandlerSpy = jest.fn();
|
|
274
|
-
withCellTracking(eventHandlerSpy)(editorView, {} as any);
|
|
275
|
-
|
|
276
|
-
expect(eventHandlerSpy).toHaveBeenCalled();
|
|
277
|
-
},
|
|
278
|
-
() => {
|
|
279
|
-
const { editorView } = editor(
|
|
280
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
281
|
-
);
|
|
282
|
-
const eventHandlerSpy = jest.fn();
|
|
283
|
-
withCellTracking(eventHandlerSpy)(editorView, {} as any);
|
|
284
|
-
|
|
285
|
-
expect(eventHandlerSpy).toHaveBeenCalled();
|
|
286
|
-
},
|
|
275
|
+
(getBooleanFF as jest.Mock).mockImplementation(
|
|
276
|
+
(name) => name === 'platform.editor.table.drag-and-drop',
|
|
287
277
|
);
|
|
278
|
+
const { editorView } = editor(
|
|
279
|
+
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
280
|
+
true,
|
|
281
|
+
);
|
|
282
|
+
const eventHandlerSpy = jest.fn();
|
|
283
|
+
withCellTracking(eventHandlerSpy)(editorView, {} as any);
|
|
284
|
+
|
|
285
|
+
expect(eventHandlerSpy).toHaveBeenCalled();
|
|
288
286
|
});
|
|
289
287
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
)
|
|
296
|
-
|
|
288
|
+
it('should correctly set table cell coordinates based on mouse location', () => {
|
|
289
|
+
(getBooleanFF as jest.Mock).mockImplementation(
|
|
290
|
+
(name) => name === 'platform.editor.table.drag-and-drop',
|
|
291
|
+
);
|
|
292
|
+
const { editorView, refs } = editor(
|
|
293
|
+
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
294
|
+
true,
|
|
295
|
+
);
|
|
296
|
+
const firstCell = editorView.domAtPos(refs['<>']);
|
|
297
297
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
298
|
+
const event = {
|
|
299
|
+
target: firstCell.node,
|
|
300
|
+
};
|
|
301
301
|
|
|
302
|
-
|
|
302
|
+
withCellTracking(jest.fn())(editorView, event as any);
|
|
303
303
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
});
|
|
304
|
+
const pluginState = getPluginState(editorView.state);
|
|
305
|
+
expect(pluginState.hoveredCell).toEqual({
|
|
306
|
+
colIndex: undefined,
|
|
307
|
+
rowIndex: undefined,
|
|
309
308
|
});
|
|
310
309
|
});
|
|
311
310
|
});
|
|
@@ -86,6 +86,7 @@ describe.skip('TableView', () => {
|
|
|
86
86
|
getEditorContainerWidth,
|
|
87
87
|
getEditorFeatureFlags: fakeGetEditorFeatureFlags,
|
|
88
88
|
hasIntlContext: true,
|
|
89
|
+
dispatchAnalyticsEvent: jest.fn(),
|
|
89
90
|
}).init();
|
|
90
91
|
|
|
91
92
|
// we expect to have a contentDOM after instanciating the NodeView so that
|
|
@@ -84,6 +84,7 @@ describe('table -> nodeviews -> table.tsx', () => {
|
|
|
84
84
|
getEditorContainerWidth: () => ({ width: 500 }),
|
|
85
85
|
getEditorFeatureFlags: () => ({}),
|
|
86
86
|
hasIntlContext: true,
|
|
87
|
+
dispatchAnalyticsEvent: jest.fn(),
|
|
87
88
|
}).init();
|
|
88
89
|
|
|
89
90
|
renderSpy = jest.spyOn(tableNodeView, 'render');
|