@atlaskit/editor-plugin-table 12.2.6 → 12.2.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 +8 -0
- package/package.json +4 -4
- package/afm-cc/tsconfig.json +0 -123
- package/afm-dev-agents/tsconfig.json +0 -123
- package/afm-jira/tsconfig.json +0 -123
- package/afm-passionfruit/tsconfig.json +0 -123
- package/afm-post-office/tsconfig.json +0 -123
- package/afm-rovo-extension/tsconfig.json +0 -123
- package/afm-townsquare/tsconfig.json +0 -123
- package/afm-volt/tsconfig.json +0 -114
- package/build/tsconfig.json +0 -23
- package/docs/0-intro.tsx +0 -57
- package/src/index.ts +0 -21
- package/src/nodeviews/ExternalDropTargets.tsx +0 -91
- package/src/nodeviews/OverflowShadowsObserver.ts +0 -156
- package/src/nodeviews/TableCell.ts +0 -134
- package/src/nodeviews/TableComponent.tsx +0 -1590
- package/src/nodeviews/TableComponentWithSharedState.tsx +0 -278
- package/src/nodeviews/TableContainer.tsx +0 -926
- package/src/nodeviews/TableNodeViewBase.ts +0 -29
- package/src/nodeviews/TableResizer.tsx +0 -884
- package/src/nodeviews/TableRow.ts +0 -830
- package/src/nodeviews/TableStickyScrollbar.ts +0 -211
- package/src/nodeviews/__mocks__/OverflowShadowsObserver.ts +0 -15
- package/src/nodeviews/__mocks__/OverridableMock.ts +0 -26
- package/src/nodeviews/table-container-styles.ts +0 -9
- package/src/nodeviews/table-node-views.ts +0 -76
- package/src/nodeviews/table.tsx +0 -530
- package/src/nodeviews/toDOM.ts +0 -244
- package/src/nodeviews/types.ts +0 -36
- package/src/nodeviews/update-overflow-shadows.ts +0 -11
- package/src/pm-plugins/analytics/actions.ts +0 -21
- package/src/pm-plugins/analytics/commands.ts +0 -47
- package/src/pm-plugins/analytics/plugin-factory.ts +0 -9
- package/src/pm-plugins/analytics/plugin-key.ts +0 -5
- package/src/pm-plugins/analytics/plugin.ts +0 -80
- package/src/pm-plugins/analytics/reducer.ts +0 -27
- package/src/pm-plugins/analytics/types.ts +0 -20
- package/src/pm-plugins/analytics/utils/moved-event.ts +0 -51
- package/src/pm-plugins/commands/clear.ts +0 -43
- package/src/pm-plugins/commands/collapse.ts +0 -17
- package/src/pm-plugins/commands/column-resize.ts +0 -478
- package/src/pm-plugins/commands/commands-with-analytics.ts +0 -715
- package/src/pm-plugins/commands/delete.ts +0 -42
- package/src/pm-plugins/commands/display-mode.ts +0 -18
- package/src/pm-plugins/commands/go-to-next-cell.ts +0 -198
- package/src/pm-plugins/commands/hover.ts +0 -242
- package/src/pm-plugins/commands/index.ts +0 -51
- package/src/pm-plugins/commands/insert.ts +0 -438
- package/src/pm-plugins/commands/misc.ts +0 -811
- package/src/pm-plugins/commands/referentiality.ts +0 -15
- package/src/pm-plugins/commands/selection.ts +0 -537
- package/src/pm-plugins/commands/sort.ts +0 -102
- package/src/pm-plugins/commands/split-cell.ts +0 -28
- package/src/pm-plugins/commands/toggle.ts +0 -109
- package/src/pm-plugins/create-plugin-config.ts +0 -17
- package/src/pm-plugins/decorations/plugin.ts +0 -107
- package/src/pm-plugins/decorations/utils/column-controls.ts +0 -91
- package/src/pm-plugins/decorations/utils/column-resizing.ts +0 -71
- package/src/pm-plugins/decorations/utils/compose-decorations.ts +0 -9
- package/src/pm-plugins/decorations/utils/types.ts +0 -16
- package/src/pm-plugins/default-table-selection.ts +0 -14
- package/src/pm-plugins/drag-and-drop/actions.ts +0 -48
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +0 -222
- package/src/pm-plugins/drag-and-drop/commands.ts +0 -194
- package/src/pm-plugins/drag-and-drop/consts.ts +0 -7
- package/src/pm-plugins/drag-and-drop/plugin-factory.ts +0 -33
- package/src/pm-plugins/drag-and-drop/plugin-key.ts +0 -5
- package/src/pm-plugins/drag-and-drop/plugin.ts +0 -398
- package/src/pm-plugins/drag-and-drop/reducer.ts +0 -38
- package/src/pm-plugins/drag-and-drop/types.ts +0 -18
- package/src/pm-plugins/drag-and-drop/utils/autoscrollers.ts +0 -49
- package/src/pm-plugins/drag-and-drop/utils/getDragBehaviour.ts +0 -9
- package/src/pm-plugins/drag-and-drop/utils/monitor.ts +0 -73
- package/src/pm-plugins/handlers.ts +0 -161
- package/src/pm-plugins/keymap.ts +0 -436
- package/src/pm-plugins/main.ts +0 -433
- package/src/pm-plugins/plugin-factory.ts +0 -42
- package/src/pm-plugins/plugin-key.ts +0 -8
- package/src/pm-plugins/reducer.ts +0 -145
- package/src/pm-plugins/safari-delete-composition-text-issue-workaround.ts +0 -102
- package/src/pm-plugins/sticky-headers/commands.ts +0 -8
- package/src/pm-plugins/sticky-headers/plugin-key.ts +0 -5
- package/src/pm-plugins/sticky-headers/plugin-state.ts +0 -52
- package/src/pm-plugins/sticky-headers/plugin.ts +0 -12
- package/src/pm-plugins/sticky-headers/types.ts +0 -20
- package/src/pm-plugins/sticky-headers/util.ts +0 -18
- package/src/pm-plugins/table-analytics.ts +0 -100
- package/src/pm-plugins/table-local-id.ts +0 -213
- package/src/pm-plugins/table-resizing/commands.ts +0 -116
- package/src/pm-plugins/table-resizing/event-handlers.ts +0 -352
- package/src/pm-plugins/table-resizing/plugin-factory.ts +0 -29
- package/src/pm-plugins/table-resizing/plugin-key.ts +0 -5
- package/src/pm-plugins/table-resizing/plugin.ts +0 -94
- package/src/pm-plugins/table-resizing/reducer.ts +0 -37
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +0 -306
- package/src/pm-plugins/table-resizing/utils/column-state.ts +0 -120
- package/src/pm-plugins/table-resizing/utils/consts.ts +0 -11
- package/src/pm-plugins/table-resizing/utils/content-width.ts +0 -118
- package/src/pm-plugins/table-resizing/utils/dom.ts +0 -132
- package/src/pm-plugins/table-resizing/utils/misc.ts +0 -282
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +0 -34
- package/src/pm-plugins/table-resizing/utils/resize-logic.ts +0 -289
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +0 -417
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +0 -290
- package/src/pm-plugins/table-resizing/utils/types.ts +0 -25
- package/src/pm-plugins/table-resizing/utils/unit-to-number.ts +0 -1
- package/src/pm-plugins/table-selection-keymap.ts +0 -64
- package/src/pm-plugins/table-size-selector.ts +0 -39
- package/src/pm-plugins/table-width-in-comment-fix.ts +0 -113
- package/src/pm-plugins/table-width.ts +0 -153
- package/src/pm-plugins/transforms/column-width.ts +0 -249
- package/src/pm-plugins/transforms/delete-columns.ts +0 -281
- package/src/pm-plugins/transforms/delete-rows.ts +0 -154
- package/src/pm-plugins/transforms/fix-tables.ts +0 -249
- package/src/pm-plugins/transforms/merge.ts +0 -301
- package/src/pm-plugins/transforms/replace-table.ts +0 -38
- package/src/pm-plugins/transforms/split.ts +0 -90
- package/src/pm-plugins/utils/alignment.ts +0 -33
- package/src/pm-plugins/utils/analytics.ts +0 -238
- package/src/pm-plugins/utils/collapse.ts +0 -93
- package/src/pm-plugins/utils/column-controls.ts +0 -250
- package/src/pm-plugins/utils/create.ts +0 -64
- package/src/pm-plugins/utils/decoration.ts +0 -672
- package/src/pm-plugins/utils/dom.ts +0 -251
- package/src/pm-plugins/utils/drag-menu.tsx +0 -491
- package/src/pm-plugins/utils/get-allow-add-column-custom-step.ts +0 -10
- package/src/pm-plugins/utils/guidelines.ts +0 -30
- package/src/pm-plugins/utils/merged-cells.ts +0 -239
- package/src/pm-plugins/utils/nodes.ts +0 -162
- package/src/pm-plugins/utils/paste.ts +0 -386
- package/src/pm-plugins/utils/row-controls.ts +0 -211
- package/src/pm-plugins/utils/selection.ts +0 -17
- package/src/pm-plugins/utils/snapping.ts +0 -136
- package/src/pm-plugins/utils/table.ts +0 -60
- package/src/pm-plugins/utils/update-plugin-state-decorations.ts +0 -13
- package/src/pm-plugins/view-mode-sort/consts.ts +0 -3
- package/src/pm-plugins/view-mode-sort/index.ts +0 -291
- package/src/pm-plugins/view-mode-sort/plugin-key.ts +0 -7
- package/src/pm-plugins/view-mode-sort/types.ts +0 -23
- package/src/pm-plugins/view-mode-sort/utils.ts +0 -136
- package/src/tablePlugin.tsx +0 -971
- package/src/tablePluginType.ts +0 -102
- package/src/types/index.ts +0 -592
- package/src/ui/ColumnResizeWidget/index.tsx +0 -61
- package/src/ui/ContentComponent.tsx +0 -311
- package/src/ui/DragHandle/HandleIconComponent.tsx +0 -21
- package/src/ui/DragHandle/index.tsx +0 -391
- package/src/ui/DragPreview/index.tsx +0 -51
- package/src/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.tsx +0 -59
- package/src/ui/FloatingContextualButton/FixedButton.tsx +0 -203
- package/src/ui/FloatingContextualButton/index.tsx +0 -168
- package/src/ui/FloatingContextualButton/styles.ts +0 -69
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +0 -931
- package/src/ui/FloatingContextualMenu/index.tsx +0 -141
- package/src/ui/FloatingContextualMenu/styles.ts +0 -77
- package/src/ui/FloatingDeleteButton/DeleteButton.tsx +0 -54
- package/src/ui/FloatingDeleteButton/getPopUpOptions.ts +0 -65
- package/src/ui/FloatingDeleteButton/index.tsx +0 -383
- package/src/ui/FloatingDeleteButton/types.ts +0 -3
- package/src/ui/FloatingDragMenu/DragMenu.tsx +0 -668
- package/src/ui/FloatingDragMenu/DropdownMenu.tsx +0 -221
- package/src/ui/FloatingDragMenu/index.tsx +0 -136
- package/src/ui/FloatingDragMenu/styles.ts +0 -83
- package/src/ui/FloatingInsertButton/InsertButton.tsx +0 -263
- package/src/ui/FloatingInsertButton/getPopupOptions.ts +0 -131
- package/src/ui/FloatingInsertButton/index.tsx +0 -314
- package/src/ui/FloatingToolbarLabel/FloatingToolbarLabel.tsx +0 -31
- package/src/ui/SizeSelector/index.tsx +0 -74
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +0 -397
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +0 -105
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +0 -63
- package/src/ui/TableFloatingColumnControls/index.tsx +0 -151
- package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +0 -106
- package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +0 -143
- package/src/ui/TableFloatingControls/CornerControls/types.ts +0 -12
- package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +0 -88
- package/src/ui/TableFloatingControls/NumberColumn/index.tsx +0 -175
- package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +0 -131
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -429
- package/src/ui/TableFloatingControls/RowDropTarget/index.tsx +0 -96
- package/src/ui/TableFloatingControls/index.tsx +0 -275
- package/src/ui/TableFullWidthLabel/index.tsx +0 -38
- package/src/ui/common-styles.ts +0 -1218
- package/src/ui/consts.ts +0 -109
- package/src/ui/event-handlers.ts +0 -662
- package/src/ui/global-styles.tsx +0 -55
- package/src/ui/hooks/useInternalTablePluginStateSelector.ts +0 -38
- package/src/ui/icons/AddColLeftIcon.tsx +0 -37
- package/src/ui/icons/AddColRightIcon.tsx +0 -37
- package/src/ui/icons/AddRowAboveIcon.tsx +0 -22
- package/src/ui/icons/AddRowBelowIcon.tsx +0 -39
- package/src/ui/icons/DragHandleDisabledIcon.tsx +0 -25
- package/src/ui/icons/DragHandleIcon.tsx +0 -16
- package/src/ui/icons/DragInMotionIcon.tsx +0 -54
- package/src/ui/icons/MergeCellsIcon.tsx +0 -26
- package/src/ui/icons/MinimisedHandle.tsx +0 -15
- package/src/ui/icons/SortingIconWrapper.tsx +0 -43
- package/src/ui/icons/SplitCellIcon.tsx +0 -34
- package/src/ui/toolbar.tsx +0 -1153
- package/src/ui/ui-styles.ts +0 -960
- package/tsconfig.app.json +0 -135
- package/tsconfig.dev.json +0 -54
- package/tsconfig.json +0 -18
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
//#region Imports
|
|
2
|
-
|
|
3
|
-
import type { TableLayout } from '@atlaskit/adf-schema';
|
|
4
|
-
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import type { Command } from '@atlaskit/editor-common/types';
|
|
6
|
-
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import { findTable, toggleHeader } from '@atlaskit/editor-tables/utils';
|
|
8
|
-
|
|
9
|
-
import { createCommand } from '../plugin-factory';
|
|
10
|
-
import { META_KEYS } from '../table-analytics';
|
|
11
|
-
//#endregion
|
|
12
|
-
|
|
13
|
-
// #region Utils
|
|
14
|
-
/**
|
|
15
|
-
* Table layout toggle logic
|
|
16
|
-
* default -> wide -> full-width -> default
|
|
17
|
-
*/
|
|
18
|
-
export const getNextLayout = (currentLayout: TableLayout) => {
|
|
19
|
-
switch (currentLayout) {
|
|
20
|
-
case 'default':
|
|
21
|
-
return 'wide';
|
|
22
|
-
case 'wide':
|
|
23
|
-
return 'full-width';
|
|
24
|
-
case 'full-width':
|
|
25
|
-
return 'default';
|
|
26
|
-
default:
|
|
27
|
-
return 'default';
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
// #endregion
|
|
31
|
-
|
|
32
|
-
// #region Actions
|
|
33
|
-
export const toggleHeaderRow: Command = (state, dispatch): boolean =>
|
|
34
|
-
toggleHeader('row')(state, (tr) =>
|
|
35
|
-
createCommand({ type: 'TOGGLE_HEADER_ROW' }, () => tr.setMeta('scrollIntoView', false))(
|
|
36
|
-
state,
|
|
37
|
-
dispatch,
|
|
38
|
-
),
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
export const toggleHeaderColumn: Command = (state, dispatch): boolean =>
|
|
42
|
-
toggleHeader('column')(state, (tr) =>
|
|
43
|
-
createCommand({ type: 'TOGGLE_HEADER_COLUMN' }, () => tr.setMeta('scrollIntoView', false))(
|
|
44
|
-
state,
|
|
45
|
-
dispatch,
|
|
46
|
-
),
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
export const toggleNumberColumn: Command = (state, dispatch) => {
|
|
50
|
-
const { tr } = state;
|
|
51
|
-
// Ignored via go/ees005
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
53
|
-
const { node, pos } = findTable(state.selection)!;
|
|
54
|
-
const isNumberedColumnEnabled = node.attrs.isNumberColumnEnabled;
|
|
55
|
-
|
|
56
|
-
tr.setNodeMarkup(pos, state.schema.nodes.table, {
|
|
57
|
-
...node.attrs,
|
|
58
|
-
isNumberColumnEnabled: !isNumberedColumnEnabled,
|
|
59
|
-
});
|
|
60
|
-
tr.setMeta('scrollIntoView', false);
|
|
61
|
-
|
|
62
|
-
const tableOverflowChangeTriggerName = isNumberedColumnEnabled
|
|
63
|
-
? TABLE_OVERFLOW_CHANGE_TRIGGER.DISABLED_NUMBERED_COLUMN
|
|
64
|
-
: TABLE_OVERFLOW_CHANGE_TRIGGER.ENABLED_NUMBERED_COLUMN;
|
|
65
|
-
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
66
|
-
name: tableOverflowChangeTriggerName,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
if (dispatch) {
|
|
70
|
-
dispatch(tr);
|
|
71
|
-
}
|
|
72
|
-
return true;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const toggleTableLayout: Command = (state, dispatch): boolean => {
|
|
76
|
-
const table = findTable(state.selection);
|
|
77
|
-
if (!table) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
const layout = getNextLayout(table.node.attrs.layout);
|
|
81
|
-
|
|
82
|
-
return createCommand(
|
|
83
|
-
{
|
|
84
|
-
type: 'SET_TABLE_LAYOUT',
|
|
85
|
-
data: {
|
|
86
|
-
layout,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
(tr: Transaction) => {
|
|
90
|
-
tr.setNodeMarkup(table.pos, state.schema.nodes.table, {
|
|
91
|
-
...table.node.attrs,
|
|
92
|
-
layout,
|
|
93
|
-
});
|
|
94
|
-
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
95
|
-
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED,
|
|
96
|
-
});
|
|
97
|
-
return tr.setMeta('scrollIntoView', false);
|
|
98
|
-
},
|
|
99
|
-
)(state, dispatch);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
export const toggleContextualMenu = () =>
|
|
103
|
-
createCommand(
|
|
104
|
-
{
|
|
105
|
-
type: 'TOGGLE_CONTEXTUAL_MENU',
|
|
106
|
-
},
|
|
107
|
-
(tr) => tr.setMeta('addToHistory', false),
|
|
108
|
-
);
|
|
109
|
-
// #endregion
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { PermittedLayoutsDescriptor, PluginConfig } from '../types';
|
|
2
|
-
|
|
3
|
-
export const pluginConfig = (config: PluginConfig = {}) => {
|
|
4
|
-
return config.advanced
|
|
5
|
-
? {
|
|
6
|
-
allowBackgroundColor: true,
|
|
7
|
-
allowColumnResizing: true,
|
|
8
|
-
allowHeaderColumn: true,
|
|
9
|
-
allowHeaderRow: true,
|
|
10
|
-
allowMergeCells: true,
|
|
11
|
-
allowNumberColumn: true,
|
|
12
|
-
permittedLayouts: 'all' as PermittedLayoutsDescriptor,
|
|
13
|
-
allowControls: true,
|
|
14
|
-
...config,
|
|
15
|
-
}
|
|
16
|
-
: config;
|
|
17
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { insideTable } from '@atlaskit/editor-common/core-utils';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import type {
|
|
4
|
-
EditorState,
|
|
5
|
-
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
6
|
-
ReadonlyTransaction,
|
|
7
|
-
Transaction,
|
|
8
|
-
} from '@atlaskit/editor-prosemirror/state';
|
|
9
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
10
|
-
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
11
|
-
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
12
|
-
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
13
|
-
|
|
14
|
-
import { pluginKey as tablePluginKey } from '../plugin-key';
|
|
15
|
-
import { pluginKey as tableWidthPluginKey } from '../table-width';
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
buildColumnControlsDecorations,
|
|
19
|
-
maybeUpdateColumnControlsSelectedDecoration,
|
|
20
|
-
} from './utils/column-controls';
|
|
21
|
-
|
|
22
|
-
export const pluginKey = new PluginKey('tableDecorationsPlugin');
|
|
23
|
-
|
|
24
|
-
export const getDecorations = (state: EditorState): DecorationSet => pluginKey.getState(state);
|
|
25
|
-
|
|
26
|
-
export const handleDocOrSelectionChanged = (
|
|
27
|
-
tr: Transaction | ReadonlyTransaction,
|
|
28
|
-
decorationSet: DecorationSet,
|
|
29
|
-
oldState: EditorState,
|
|
30
|
-
newState: EditorState,
|
|
31
|
-
): DecorationSet => {
|
|
32
|
-
const isResizing = tableWidthPluginKey.getState(newState)?.resizing;
|
|
33
|
-
const wasResizing = tableWidthPluginKey.getState(oldState)?.resizing;
|
|
34
|
-
const {
|
|
35
|
-
isDragAndDropEnabled = false,
|
|
36
|
-
isInDanger,
|
|
37
|
-
isTableHovered,
|
|
38
|
-
} = tablePluginKey.getState(newState) || {};
|
|
39
|
-
|
|
40
|
-
const changedResizing = isResizing !== wasResizing;
|
|
41
|
-
|
|
42
|
-
// Remove column controls when resizing and don't add column decoration controls when DnD enabled
|
|
43
|
-
if (isResizing) {
|
|
44
|
-
return DecorationSet.empty;
|
|
45
|
-
} else if (tr.docChanged || tr.selection instanceof CellSelection || changedResizing) {
|
|
46
|
-
return buildColumnControlsDecorations({
|
|
47
|
-
decorationSet,
|
|
48
|
-
tr,
|
|
49
|
-
options: {
|
|
50
|
-
isDragAndDropEnabled,
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
} else if (tr.selectionSet) {
|
|
54
|
-
const isTransactionFromMouseClick = !tr.docChanged && tr.selectionSet && tr.getMeta('pointer');
|
|
55
|
-
if (isTransactionFromMouseClick || oldState.selection instanceof CellSelection) {
|
|
56
|
-
return maybeUpdateColumnControlsSelectedDecoration({
|
|
57
|
-
decorationSet,
|
|
58
|
-
tr,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
// We're exiting a table with an existing decorations so we should clean it up
|
|
62
|
-
if (
|
|
63
|
-
(isInDanger || isTableHovered) &&
|
|
64
|
-
(!insideTable(newState) ||
|
|
65
|
-
findTable(newState.selection)?.node !== findTable(oldState.selection)?.node)
|
|
66
|
-
) {
|
|
67
|
-
return buildColumnControlsDecorations({
|
|
68
|
-
decorationSet,
|
|
69
|
-
tr,
|
|
70
|
-
options: {
|
|
71
|
-
isDragAndDropEnabled,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return decorationSet;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export const createPlugin = () => {
|
|
81
|
-
return new SafePlugin({
|
|
82
|
-
state: {
|
|
83
|
-
init: () => DecorationSet.empty,
|
|
84
|
-
|
|
85
|
-
apply: (tr, decorationSet, oldState, newState) => {
|
|
86
|
-
let pluginState = decorationSet;
|
|
87
|
-
// main table plugin --->
|
|
88
|
-
const meta = tr.getMeta(tablePluginKey);
|
|
89
|
-
|
|
90
|
-
if (meta && meta.data && meta.data.decorationSet) {
|
|
91
|
-
pluginState = meta.data.decorationSet;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (tr.docChanged || tr.selectionSet || tr.getMeta(tableWidthPluginKey)) {
|
|
95
|
-
pluginState = pluginState.map(tr.mapping, tr.doc);
|
|
96
|
-
return handleDocOrSelectionChanged(tr, pluginState, oldState, newState);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return pluginState;
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
key: pluginKey,
|
|
103
|
-
props: {
|
|
104
|
-
decorations: (state) => getDecorations(state),
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
2
|
-
import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
|
-
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
6
|
-
|
|
7
|
-
import { TableDecorations } from '../../../types';
|
|
8
|
-
import {
|
|
9
|
-
createColumnControlsDecoration,
|
|
10
|
-
createColumnSelectedDecoration,
|
|
11
|
-
findColumnControlSelectedDecoration,
|
|
12
|
-
findControlsHoverDecoration,
|
|
13
|
-
updateDecorations,
|
|
14
|
-
} from '../../utils/decoration';
|
|
15
|
-
|
|
16
|
-
import { composeDecorations } from './compose-decorations';
|
|
17
|
-
import type { BuildDecorationTransformerParams, DecorationTransformer } from './types';
|
|
18
|
-
|
|
19
|
-
const isColumnSelected = (tr: Transaction | ReadonlyTransaction): boolean =>
|
|
20
|
-
tr.selection instanceof CellSelection && tr.selection.isColSelection();
|
|
21
|
-
|
|
22
|
-
// @see: https://product-fabric.atlassian.net/browse/ED-3796
|
|
23
|
-
const removeControlsHoverDecoration: DecorationTransformer = ({ decorationSet }) =>
|
|
24
|
-
decorationSet.remove(findControlsHoverDecoration(decorationSet));
|
|
25
|
-
|
|
26
|
-
const maybeUpdateColumnSelectedDecoration: DecorationTransformer = ({ decorationSet, tr }) => {
|
|
27
|
-
if (!isColumnSelected(tr)) {
|
|
28
|
-
return decorationSet;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return updateDecorations(
|
|
32
|
-
tr.doc,
|
|
33
|
-
decorationSet,
|
|
34
|
-
createColumnSelectedDecoration(tr),
|
|
35
|
-
TableDecorations.COLUMN_SELECTED,
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const maybeUpdateColumnControlsDecoration: DecorationTransformer = ({ decorationSet, tr }) => {
|
|
40
|
-
const table = findTable(tr.selection);
|
|
41
|
-
|
|
42
|
-
if (!table) {
|
|
43
|
-
return decorationSet;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return updateDecorations(
|
|
47
|
-
tr.doc,
|
|
48
|
-
decorationSet,
|
|
49
|
-
createColumnControlsDecoration(tr.selection),
|
|
50
|
-
TableDecorations.COLUMN_CONTROLS_DECORATIONS,
|
|
51
|
-
);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// @see: https://product-fabric.atlassian.net/browse/ED-7304
|
|
55
|
-
const removeColumnControlsSelectedDecoration: DecorationTransformer = ({ decorationSet }) =>
|
|
56
|
-
decorationSet.remove(findColumnControlSelectedDecoration(decorationSet));
|
|
57
|
-
|
|
58
|
-
const hasColumnSelectedDecorations = (decorationSet: DecorationSet): boolean =>
|
|
59
|
-
!!findColumnControlSelectedDecoration(decorationSet).length;
|
|
60
|
-
|
|
61
|
-
export const maybeUpdateColumnControlsSelectedDecoration: DecorationTransformer = ({
|
|
62
|
-
decorationSet,
|
|
63
|
-
tr,
|
|
64
|
-
}) => {
|
|
65
|
-
if (!hasColumnSelectedDecorations(decorationSet)) {
|
|
66
|
-
return decorationSet;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return removeColumnControlsSelectedDecoration({ decorationSet, tr });
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const buildColumnControlsDecorations = ({
|
|
73
|
-
decorationSet,
|
|
74
|
-
tr,
|
|
75
|
-
options,
|
|
76
|
-
}: BuildDecorationTransformerParams): DecorationSet => {
|
|
77
|
-
if (options.isDragAndDropEnabled) {
|
|
78
|
-
return composeDecorations([
|
|
79
|
-
removeColumnControlsSelectedDecoration,
|
|
80
|
-
removeControlsHoverDecoration,
|
|
81
|
-
maybeUpdateColumnSelectedDecoration,
|
|
82
|
-
])({ decorationSet, tr });
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return composeDecorations([
|
|
86
|
-
removeColumnControlsSelectedDecoration,
|
|
87
|
-
removeControlsHoverDecoration,
|
|
88
|
-
maybeUpdateColumnSelectedDecoration,
|
|
89
|
-
maybeUpdateColumnControlsDecoration,
|
|
90
|
-
])({ decorationSet, tr });
|
|
91
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { IntlShape } from 'react-intl-next';
|
|
2
|
-
|
|
3
|
-
import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
4
|
-
import type { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
|
|
6
|
-
import { TableDecorations } from '../../../types';
|
|
7
|
-
import { createResizeHandleDecoration, updateDecorations } from '../../utils/decoration';
|
|
8
|
-
|
|
9
|
-
import { composeDecorations } from './compose-decorations';
|
|
10
|
-
import type { DecorationTransformer } from './types';
|
|
11
|
-
|
|
12
|
-
const emptyDecorations = [[], []];
|
|
13
|
-
|
|
14
|
-
const updateColumnResizeHandle =
|
|
15
|
-
(columnResizesDecorations: Decoration[]): DecorationTransformer =>
|
|
16
|
-
({ decorationSet, tr }) =>
|
|
17
|
-
updateDecorations(
|
|
18
|
-
tr.doc,
|
|
19
|
-
decorationSet,
|
|
20
|
-
columnResizesDecorations,
|
|
21
|
-
TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET,
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
const updateLastCellElement =
|
|
25
|
-
(lastCellElementsDecorations: Decoration[]): DecorationTransformer =>
|
|
26
|
-
({ decorationSet, tr }) =>
|
|
27
|
-
updateDecorations(
|
|
28
|
-
tr.doc,
|
|
29
|
-
decorationSet,
|
|
30
|
-
lastCellElementsDecorations,
|
|
31
|
-
TableDecorations.LAST_CELL_ELEMENT,
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
export const buildColumnResizingDecorations =
|
|
35
|
-
(
|
|
36
|
-
rowEndIndex: number,
|
|
37
|
-
columnEndIndex: number,
|
|
38
|
-
includeTooltip: boolean,
|
|
39
|
-
getIntl: () => IntlShape,
|
|
40
|
-
nodeViewPortalProviderAPI: PortalProviderAPI,
|
|
41
|
-
): DecorationTransformer =>
|
|
42
|
-
({ tr, decorationSet }): DecorationSet => {
|
|
43
|
-
const [columnResizesDecorations, lastCellElementsDecorations] =
|
|
44
|
-
columnEndIndex < 0
|
|
45
|
-
? emptyDecorations
|
|
46
|
-
: createResizeHandleDecoration(
|
|
47
|
-
tr,
|
|
48
|
-
rowEndIndex,
|
|
49
|
-
{
|
|
50
|
-
right: columnEndIndex,
|
|
51
|
-
},
|
|
52
|
-
includeTooltip,
|
|
53
|
-
getIntl,
|
|
54
|
-
nodeViewPortalProviderAPI,
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
return composeDecorations([
|
|
58
|
-
updateColumnResizeHandle(columnResizesDecorations),
|
|
59
|
-
updateLastCellElement(lastCellElementsDecorations),
|
|
60
|
-
])({ decorationSet, tr });
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const clearColumnResizingDecorations =
|
|
64
|
-
(): DecorationTransformer =>
|
|
65
|
-
({ tr, decorationSet }): DecorationSet => {
|
|
66
|
-
const [columnResizesDecorations, lastCellElementsDecorations] = emptyDecorations;
|
|
67
|
-
return composeDecorations([
|
|
68
|
-
updateColumnResizeHandle(columnResizesDecorations),
|
|
69
|
-
updateLastCellElement(lastCellElementsDecorations),
|
|
70
|
-
])({ decorationSet, tr });
|
|
71
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { DecorationTransformer } from './types';
|
|
2
|
-
|
|
3
|
-
export const composeDecorations =
|
|
4
|
-
(transformers: Array<DecorationTransformer>): DecorationTransformer =>
|
|
5
|
-
({ decorationSet, tr }) =>
|
|
6
|
-
transformers.reduce(
|
|
7
|
-
(decorationSet, transform) => transform({ decorationSet, tr }),
|
|
8
|
-
decorationSet,
|
|
9
|
-
);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
2
|
-
import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
|
|
5
|
-
export type DecorationTransformer = (params: DecorationTransformerParams) => DecorationSet;
|
|
6
|
-
|
|
7
|
-
type DecorationTransformerParams = {
|
|
8
|
-
decorationSet: DecorationSet;
|
|
9
|
-
tr: Transaction | ReadonlyTransaction;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type BuildDecorationTransformerParams = DecorationTransformerParams & {
|
|
13
|
-
options: {
|
|
14
|
-
isDragAndDropEnabled: boolean;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const defaultTableSelection = {
|
|
2
|
-
hoveredColumns: [],
|
|
3
|
-
hoveredRows: [],
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Creating a separate object for hoveredCell so it doesn't get defaulted when `handleDocOrSelectionChanged` runs.
|
|
8
|
-
*
|
|
9
|
-
* It is safe to persist this value as it gets removed when the mouse cursor leaves the table, so no need to remove it
|
|
10
|
-
* when doc changes.
|
|
11
|
-
*/
|
|
12
|
-
export const defaultHoveredCell = {
|
|
13
|
-
hoveredCell: { rowIndex: undefined, colIndex: undefined },
|
|
14
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
|
|
3
|
-
import type { TableDirection } from '../../types';
|
|
4
|
-
|
|
5
|
-
import type { DropTargetType } from './consts';
|
|
6
|
-
|
|
7
|
-
interface DragAndDropAction<T, D> {
|
|
8
|
-
type: T;
|
|
9
|
-
data: D;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const DragAndDropActionType = {
|
|
13
|
-
SET_DROP_TARGET: 'SET_DROP_TARGET',
|
|
14
|
-
CLEAR_DROP_TARGET: 'CLEAR_DROP_TARGET',
|
|
15
|
-
TOGGLE_DRAG_MENU: 'TOGGLE_DRAG_MENU',
|
|
16
|
-
} as const;
|
|
17
|
-
|
|
18
|
-
type DragAndDropSetDropTargetAction = DragAndDropAction<
|
|
19
|
-
typeof DragAndDropActionType.SET_DROP_TARGET,
|
|
20
|
-
{
|
|
21
|
-
type: DropTargetType;
|
|
22
|
-
index: number;
|
|
23
|
-
decorationSet: DecorationSet;
|
|
24
|
-
}
|
|
25
|
-
>;
|
|
26
|
-
|
|
27
|
-
type DragAndDropClearDropTargetAction = DragAndDropAction<
|
|
28
|
-
typeof DragAndDropActionType.CLEAR_DROP_TARGET,
|
|
29
|
-
{
|
|
30
|
-
decorationSet: DecorationSet;
|
|
31
|
-
}
|
|
32
|
-
>;
|
|
33
|
-
|
|
34
|
-
type DragAndDropToggleDragMenuAction = DragAndDropAction<
|
|
35
|
-
typeof DragAndDropActionType.TOGGLE_DRAG_MENU,
|
|
36
|
-
{
|
|
37
|
-
isDragMenuOpen: boolean;
|
|
38
|
-
direction: TableDirection;
|
|
39
|
-
index: number;
|
|
40
|
-
isKeyboardModeActive: boolean;
|
|
41
|
-
}
|
|
42
|
-
>;
|
|
43
|
-
|
|
44
|
-
// NOTE: This should be a Union of all possible actions
|
|
45
|
-
export type DragAndDropPluginAction =
|
|
46
|
-
| DragAndDropSetDropTargetAction
|
|
47
|
-
| DragAndDropClearDropTargetAction
|
|
48
|
-
| DragAndDropToggleDragMenuAction;
|