@atlaskit/editor-plugin-table 7.2.2 → 7.3.0
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 +14 -0
- package/dist/cjs/commands/column-resize.js +115 -45
- package/dist/cjs/commands/go-to-next-cell.js +7 -11
- package/dist/cjs/commands/misc.js +3 -2
- package/dist/cjs/commands/selection.js +3 -3
- package/dist/cjs/event-handlers.js +38 -25
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -19
- package/dist/cjs/pm-plugins/keymap.js +1 -0
- package/dist/cjs/pm-plugins/main.js +43 -9
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +37 -7
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +20 -6
- package/dist/cjs/reducer.js +5 -2
- package/dist/cjs/utils/drag-menu.js +37 -23
- package/dist/cjs/utils/merged-cells.js +66 -1
- package/dist/es2019/commands/column-resize.js +100 -35
- package/dist/es2019/commands/go-to-next-cell.js +7 -9
- package/dist/es2019/commands/misc.js +3 -2
- package/dist/es2019/commands/selection.js +5 -5
- package/dist/es2019/event-handlers.js +17 -3
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +4 -20
- package/dist/es2019/pm-plugins/keymap.js +3 -2
- package/dist/es2019/pm-plugins/main.js +41 -5
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +37 -4
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +16 -1
- package/dist/es2019/reducer.js +5 -2
- package/dist/es2019/utils/drag-menu.js +38 -14
- package/dist/es2019/utils/merged-cells.js +73 -0
- package/dist/esm/commands/column-resize.js +105 -35
- package/dist/esm/commands/go-to-next-cell.js +7 -11
- package/dist/esm/commands/misc.js +3 -2
- package/dist/esm/commands/selection.js +5 -5
- package/dist/esm/event-handlers.js +38 -25
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +4 -20
- package/dist/esm/pm-plugins/keymap.js +3 -2
- package/dist/esm/pm-plugins/main.js +38 -4
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +34 -4
- package/dist/esm/pm-plugins/table-resizing/plugin.js +15 -1
- package/dist/esm/reducer.js +5 -2
- package/dist/esm/utils/drag-menu.js +36 -22
- package/dist/esm/utils/merged-cells.js +65 -0
- package/dist/types/commands/column-resize.d.ts +2 -0
- package/dist/types/commands/misc.d.ts +1 -1
- package/dist/types/types.d.ts +16 -0
- package/dist/types/utils/drag-menu.d.ts +4 -1
- package/dist/types/utils/merged-cells.d.ts +2 -0
- package/dist/types-ts4.5/commands/column-resize.d.ts +2 -0
- package/dist/types-ts4.5/commands/misc.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +16 -0
- package/dist/types-ts4.5/utils/drag-menu.d.ts +4 -1
- package/dist/types-ts4.5/utils/merged-cells.d.ts +2 -0
- package/package.json +10 -17
- package/src/commands/column-resize.ts +155 -40
- package/src/commands/go-to-next-cell.ts +6 -15
- package/src/commands/misc.ts +2 -0
- package/src/commands/selection.ts +5 -5
- package/src/event-handlers.ts +21 -4
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +11 -32
- package/src/pm-plugins/keymap.ts +3 -0
- package/src/pm-plugins/main.ts +47 -2
- package/src/pm-plugins/table-resizing/event-handlers.ts +33 -5
- package/src/pm-plugins/table-resizing/plugin.ts +18 -1
- package/src/reducer.ts +5 -2
- package/src/types.ts +16 -0
- package/src/utils/drag-menu.ts +94 -20
- package/src/utils/merged-cells.ts +78 -0
- package/tsconfig.dev.json +0 -69
- package/tsconfig.json +2 -877
- package/examples/99-testing.tsx +0 -140
- package/examples/config.jsonc +0 -14
- package/src/__tests__/unit/analytics.ts +0 -888
- package/src/__tests__/unit/collab.ts +0 -93
- package/src/__tests__/unit/commands/go-to-next-cell.ts +0 -173
- package/src/__tests__/unit/commands/insert.ts +0 -137
- package/src/__tests__/unit/commands/misc.ts +0 -185
- package/src/__tests__/unit/commands/sort.ts +0 -128
- package/src/__tests__/unit/commands.ts +0 -745
- package/src/__tests__/unit/copy-button.ts +0 -22
- package/src/__tests__/unit/copy-paste.ts +0 -677
- package/src/__tests__/unit/event-handlers/index.ts +0 -125
- package/src/__tests__/unit/event-handlers.ts +0 -296
- package/src/__tests__/unit/fix-tables.ts +0 -164
- package/src/__tests__/unit/get-toolbar-config.ts +0 -127
- package/src/__tests__/unit/handlers.ts +0 -98
- package/src/__tests__/unit/hover-selection.ts +0 -230
- package/src/__tests__/unit/index-with-fake-timers.ts +0 -111
- package/src/__tests__/unit/index.ts +0 -912
- package/src/__tests__/unit/layout.ts +0 -146
- package/src/__tests__/unit/nodeviews/OverflowShadowsObserver.ts +0 -162
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +0 -280
- package/src/__tests__/unit/nodeviews/TableContainer.tsx +0 -525
- package/src/__tests__/unit/nodeviews/cell.ts +0 -132
- package/src/__tests__/unit/nodeviews/table.ts +0 -129
- package/src/__tests__/unit/pm-plugins/analytics.ts +0 -327
- package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +0 -94
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +0 -176
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +0 -211
- package/src/__tests__/unit/pm-plugins/main.ts +0 -214
- package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +0 -101
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +0 -562
- package/src/__tests__/unit/pm-plugins/table-local-id.ts +0 -507
- package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +0 -269
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +0 -192
- package/src/__tests__/unit/pm-plugins/table-resizing/utils/resize-state.ts +0 -33
- package/src/__tests__/unit/pm-plugins/table-width.ts +0 -292
- package/src/__tests__/unit/sort-column.ts +0 -399
- package/src/__tests__/unit/toolbar.ts +0 -512
- package/src/__tests__/unit/transforms/delete-columns.ts +0 -597
- package/src/__tests__/unit/transforms/delete-rows.ts +0 -620
- package/src/__tests__/unit/transforms/merging.ts +0 -392
- package/src/__tests__/unit/ui/ContextualMenu.tsx +0 -71
- package/src/__tests__/unit/ui/CornerControls.tsx +0 -99
- package/src/__tests__/unit/ui/DeleteButton.tsx +0 -38
- package/src/__tests__/unit/ui/FixedButton.tsx +0 -217
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +0 -123
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +0 -68
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +0 -178
- package/src/__tests__/unit/ui/FloatingDragMenu.tsx +0 -511
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +0 -322
- package/src/__tests__/unit/ui/NumberColumn.tsx +0 -146
- package/src/__tests__/unit/ui/RowControls.tsx +0 -294
- package/src/__tests__/unit/ui/RowDragControls.tsx +0 -129
- package/src/__tests__/unit/ui/TableFloatingColumnControls.tsx +0 -189
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +0 -118
- package/src/__tests__/unit/undo-redo.ts +0 -220
- package/src/__tests__/unit/utils/analytics.ts +0 -98
- package/src/__tests__/unit/utils/collapse.ts +0 -57
- package/src/__tests__/unit/utils/column-controls.ts +0 -205
- package/src/__tests__/unit/utils/dom.ts +0 -180
- package/src/__tests__/unit/utils/merged-cells.ts +0 -156
- package/src/__tests__/unit/utils/nodes.ts +0 -79
- package/src/__tests__/unit/utils/row-controls.ts +0 -195
- package/src/__tests__/unit/utils/table.ts +0 -96
- package/src/__tests__/unit/utils.ts +0 -670
- package/src/__tests__/visual-regression/__fixtures__/sticky-header-with-horizontal-scroll.json +0 -5228
- package/src/__tests__/visual-regression/__fixtures__/table-with-100-numbered-list-items.json +0 -20272
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-should-remove-the-table-column-on-click-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/copy-button-ts-floating-toolbar-copy-button-table-target-node-displays-blue-border-when-copy-button-is-hovered-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-2-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-3-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-2-snap.png +0 -3
- package/src/__tests__/visual-regression/cell-options-menu.ts +0 -101
- package/src/__tests__/visual-regression/copy-button.ts +0 -181
- package/src/__tests__/visual-regression/index.ts +0 -62
- package/src/__tests__/visual-regression/sticky-header.ts +0 -61
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^35.5.1",
|
|
32
|
-
"@atlaskit/custom-steps": "^0.0.
|
|
33
|
-
"@atlaskit/editor-common": "^77.
|
|
32
|
+
"@atlaskit/custom-steps": "^0.0.13",
|
|
33
|
+
"@atlaskit/editor-common": "^77.3.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.5.2",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
36
36
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-guideline": "^0.5.0",
|
|
38
38
|
"@atlaskit/editor-plugin-selection": "^0.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-width": "^0.2.0",
|
|
40
|
-
"@atlaskit/editor-prosemirror": "
|
|
40
|
+
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
41
41
|
"@atlaskit/editor-shared-styles": "^2.9.0",
|
|
42
42
|
"@atlaskit/editor-tables": "^2.5.0",
|
|
43
43
|
"@atlaskit/icon": "^22.0.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/primitives": "^2.0.0",
|
|
49
49
|
"@atlaskit/theme": "^12.6.0",
|
|
50
50
|
"@atlaskit/toggle": "^13.0.0",
|
|
51
|
-
"@atlaskit/tokens": "^1.
|
|
51
|
+
"@atlaskit/tokens": "^1.36.0",
|
|
52
52
|
"@atlaskit/tooltip": "^18.1.0",
|
|
53
53
|
"@babel/runtime": "^7.0.0",
|
|
54
54
|
"@emotion/react": "^11.7.1",
|
|
@@ -64,19 +64,7 @@
|
|
|
64
64
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@atlaskit/analytics-next": "^9.2.0",
|
|
68
|
-
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|
|
69
|
-
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
70
|
-
"@atlaskit/editor-plugin-grid": "^0.3.0",
|
|
71
|
-
"@atlaskit/editor-plugin-hyperlink": "^0.8.0",
|
|
72
|
-
"@atlaskit/editor-test-helpers": "^18.16.0",
|
|
73
|
-
"@atlaskit/visual-regression": "*",
|
|
74
67
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
75
|
-
"@atlassian/feature-flags-test-utils": "^0.2.0",
|
|
76
|
-
"@testing-library/dom": "^8.17.1",
|
|
77
|
-
"@testing-library/react": "^12.1.5",
|
|
78
|
-
"@testing-library/react-hooks": "^8.0.1",
|
|
79
|
-
"raf-stub": "^2.0.1",
|
|
80
68
|
"typescript": "~4.9.5"
|
|
81
69
|
},
|
|
82
70
|
"af:exports": {
|
|
@@ -107,6 +95,11 @@
|
|
|
107
95
|
]
|
|
108
96
|
}
|
|
109
97
|
},
|
|
98
|
+
"stricter": {
|
|
99
|
+
"no-unused-dependencies": {
|
|
100
|
+
"checkDevDependencies": true
|
|
101
|
+
}
|
|
102
|
+
},
|
|
110
103
|
"platform-feature-flags": {
|
|
111
104
|
"platform.editor.custom-table-width": {
|
|
112
105
|
"type": "boolean"
|
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
Command,
|
|
4
4
|
GetEditorContainerWidth,
|
|
5
5
|
} from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import { TableMap } from '@atlaskit/editor-tables';
|
|
7
8
|
import type { CellAttributes, Direction } from '@atlaskit/editor-tables/types';
|
|
8
9
|
import {
|
|
@@ -15,10 +16,17 @@ import {
|
|
|
15
16
|
} from '@atlaskit/editor-tables/utils';
|
|
16
17
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
17
18
|
|
|
19
|
+
import { getDecorations } from '../pm-plugins/decorations/plugin';
|
|
20
|
+
import {
|
|
21
|
+
buildColumnResizingDecorations,
|
|
22
|
+
clearColumnResizingDecorations,
|
|
23
|
+
} from '../pm-plugins/decorations/utils';
|
|
24
|
+
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
18
25
|
import {
|
|
19
26
|
getPluginState as getTableResizingPluginState,
|
|
20
27
|
createCommand as tableResizingPluginCreateCommand,
|
|
21
28
|
} from '../pm-plugins/table-resizing/plugin-factory';
|
|
29
|
+
import { pluginKey as tableResizingPK } from '../pm-plugins/table-resizing/plugin-key';
|
|
22
30
|
import {
|
|
23
31
|
currentColWidth,
|
|
24
32
|
getResizeState,
|
|
@@ -27,9 +35,23 @@ import {
|
|
|
27
35
|
updateControls,
|
|
28
36
|
} from '../pm-plugins/table-resizing/utils';
|
|
29
37
|
import { updateColumnWidths } from '../transforms';
|
|
30
|
-
import {
|
|
38
|
+
import { TableDecorations } from '../types';
|
|
39
|
+
import type { TablePluginAction } from '../types';
|
|
40
|
+
import {
|
|
41
|
+
createColumnLineResize,
|
|
42
|
+
getSelectedColumnIndexes,
|
|
43
|
+
updateDecorations,
|
|
44
|
+
} from '../utils';
|
|
31
45
|
|
|
32
|
-
|
|
46
|
+
const getTablePluginCommand = (
|
|
47
|
+
actionPayload: TablePluginAction,
|
|
48
|
+
originalTr?: Transaction,
|
|
49
|
+
): Command => {
|
|
50
|
+
return createCommand(
|
|
51
|
+
() => actionPayload,
|
|
52
|
+
(tr) => (originalTr || tr).setMeta('addToHistory', false),
|
|
53
|
+
);
|
|
54
|
+
};
|
|
33
55
|
|
|
34
56
|
const updateResizeHandleAndStatePosition =
|
|
35
57
|
(
|
|
@@ -38,19 +60,64 @@ const updateResizeHandleAndStatePosition =
|
|
|
38
60
|
nextResizeHandlePos: number,
|
|
39
61
|
): Command =>
|
|
40
62
|
(state, dispatch) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
})(state, dispatch);
|
|
63
|
+
let customTr = state.tr;
|
|
64
|
+
const {
|
|
65
|
+
pluginConfig: { allowColumnResizing },
|
|
66
|
+
getIntl,
|
|
67
|
+
} = getPluginState(state);
|
|
47
68
|
|
|
48
|
-
|
|
69
|
+
const fakeDispatch = (tr: Transaction) => {
|
|
70
|
+
customTr = tr;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (!allowColumnResizing) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const decorationsWithWidget = buildColumnResizingDecorations(
|
|
78
|
+
rowIndex,
|
|
79
|
+
columnIndex,
|
|
80
|
+
true,
|
|
81
|
+
getIntl,
|
|
82
|
+
)({
|
|
83
|
+
tr: customTr,
|
|
84
|
+
decorationSet: getDecorations(state),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const decorationsWithWidgetAndHandle = updateDecorations(
|
|
88
|
+
customTr.doc,
|
|
89
|
+
decorationsWithWidget,
|
|
90
|
+
createColumnLineResize(state.selection, {
|
|
91
|
+
right: columnIndex,
|
|
92
|
+
}),
|
|
93
|
+
TableDecorations.COLUMN_RESIZING_HANDLE_LINE,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
getTablePluginCommand(
|
|
97
|
+
{
|
|
98
|
+
type: 'START_KEYBOARD_COLUMN_RESIZE',
|
|
99
|
+
data: {
|
|
100
|
+
resizeHandleRowIndex: rowIndex,
|
|
101
|
+
resizeHandleColumnIndex: columnIndex,
|
|
102
|
+
resizeHandleIncludeTooltip: true,
|
|
103
|
+
isKeyboardResize: true,
|
|
104
|
+
decorationSet: decorationsWithWidgetAndHandle,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
customTr,
|
|
108
|
+
)(state, fakeDispatch);
|
|
109
|
+
|
|
110
|
+
customTr.setMeta(tableResizingPK, {
|
|
49
111
|
type: 'SET_RESIZE_HANDLE_POSITION',
|
|
50
112
|
data: {
|
|
51
113
|
resizeHandlePos: nextResizeHandlePos,
|
|
52
114
|
},
|
|
53
|
-
})
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
if (dispatch) {
|
|
118
|
+
dispatch(customTr);
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
54
121
|
return false;
|
|
55
122
|
};
|
|
56
123
|
|
|
@@ -69,39 +136,24 @@ export const initiateKeyboardColumnResizing: Command = (
|
|
|
69
136
|
const cell = findCellClosestToPos(selection.$from);
|
|
70
137
|
|
|
71
138
|
if (selectionRect && cell && view) {
|
|
72
|
-
|
|
73
|
-
const width = currentColWidth(view, cell.pos, cellAttrs as CellAttributes);
|
|
74
|
-
|
|
75
|
-
updateResizeHandleAndStatePosition(
|
|
139
|
+
return updateResizeHandleAndStatePosition(
|
|
76
140
|
selectionRect.top,
|
|
77
141
|
selectionRect.right,
|
|
78
142
|
cell.pos,
|
|
79
143
|
)(state, dispatch);
|
|
80
|
-
|
|
81
|
-
tableResizingPluginCreateCommand({
|
|
82
|
-
type: 'SET_DRAGGING',
|
|
83
|
-
data: {
|
|
84
|
-
dragging: {
|
|
85
|
-
startX: 0,
|
|
86
|
-
startWidth: width,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
})(state, dispatch);
|
|
90
|
-
return true;
|
|
91
144
|
}
|
|
92
145
|
return false;
|
|
93
146
|
};
|
|
94
147
|
|
|
95
148
|
export const activateNextResizeArea =
|
|
96
149
|
(direction: Direction): Command =>
|
|
97
|
-
(state, dispatch) => {
|
|
150
|
+
(state, dispatch, view) => {
|
|
98
151
|
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
99
152
|
return false;
|
|
100
153
|
}
|
|
101
|
-
const { resizeHandlePos
|
|
102
|
-
getTableResizingPluginState(state) || {};
|
|
154
|
+
const { resizeHandlePos } = getTableResizingPluginState(state) || {};
|
|
103
155
|
// If No resizing has initiated, skip to regular handler
|
|
104
|
-
if (!resizeHandlePos
|
|
156
|
+
if (!resizeHandlePos) {
|
|
105
157
|
return false;
|
|
106
158
|
}
|
|
107
159
|
|
|
@@ -135,11 +187,11 @@ export const activateNextResizeArea =
|
|
|
135
187
|
// we are somewhere in between the side columns of the table
|
|
136
188
|
const offset = $nextCell.pos - $nextCell.start(-1);
|
|
137
189
|
const rectForNextCell = tableMap.findCell(offset);
|
|
138
|
-
updateResizeHandleAndStatePosition(
|
|
190
|
+
return updateResizeHandleAndStatePosition(
|
|
139
191
|
rectForNextCell.top,
|
|
140
192
|
rectForNextCell.right,
|
|
141
193
|
$nextCell.pos,
|
|
142
|
-
)(state, dispatch);
|
|
194
|
+
)(state, dispatch, view);
|
|
143
195
|
} else {
|
|
144
196
|
// current position is in the one of the side columns of the table(left or right)
|
|
145
197
|
if (currentCellRect.left === 0) {
|
|
@@ -151,25 +203,25 @@ export const activateNextResizeArea =
|
|
|
151
203
|
) + closestTable.start;
|
|
152
204
|
const $lastCell = state.doc.resolve(lastCellInCurrentRow);
|
|
153
205
|
|
|
154
|
-
updateResizeHandleAndStatePosition(
|
|
206
|
+
return updateResizeHandleAndStatePosition(
|
|
155
207
|
currentCellRect.top,
|
|
156
208
|
tableMap.width,
|
|
157
209
|
$lastCell.pos,
|
|
158
|
-
)(state, dispatch);
|
|
210
|
+
)(state, dispatch, view);
|
|
159
211
|
} else if (tableMap.width === currentCellRect.right) {
|
|
160
212
|
const firsCellInCurrentRow =
|
|
161
213
|
tableMap.positionAt(currentCellRect.top, 0, tableNode) +
|
|
162
214
|
closestTable.start;
|
|
163
215
|
const $nextCell = state.doc.resolve(firsCellInCurrentRow);
|
|
164
216
|
|
|
165
|
-
updateResizeHandleAndStatePosition(
|
|
217
|
+
return updateResizeHandleAndStatePosition(
|
|
166
218
|
currentCellRect.top,
|
|
167
219
|
1,
|
|
168
220
|
$nextCell.pos,
|
|
169
221
|
)(state, dispatch);
|
|
170
222
|
}
|
|
171
223
|
}
|
|
172
|
-
return
|
|
224
|
+
return false;
|
|
173
225
|
};
|
|
174
226
|
|
|
175
227
|
export const changeColumnWidthByStep =
|
|
@@ -178,11 +230,16 @@ export const changeColumnWidthByStep =
|
|
|
178
230
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
179
231
|
): Command =>
|
|
180
232
|
(state, dispatch, view) => {
|
|
233
|
+
let customTr = state.tr;
|
|
234
|
+
const fakeDispatch = (tr: Transaction) => {
|
|
235
|
+
customTr = tr;
|
|
236
|
+
};
|
|
181
237
|
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
182
238
|
return false;
|
|
183
239
|
}
|
|
184
|
-
const { resizeHandlePos
|
|
185
|
-
|
|
240
|
+
const { resizeHandlePos } = getTableResizingPluginState(state);
|
|
241
|
+
const cell = findCellClosestToPos(state.selection.$from);
|
|
242
|
+
if (!view || !resizeHandlePos || !cell) {
|
|
186
243
|
return false;
|
|
187
244
|
}
|
|
188
245
|
|
|
@@ -205,6 +262,18 @@ export const changeColumnWidthByStep =
|
|
|
205
262
|
dom = dom.closest('table') as HTMLTableElement;
|
|
206
263
|
}
|
|
207
264
|
|
|
265
|
+
const cellAttrs = cell?.node.attrs;
|
|
266
|
+
const width = currentColWidth(view, cell?.pos, cellAttrs as CellAttributes);
|
|
267
|
+
tableResizingPluginCreateCommand({
|
|
268
|
+
type: 'SET_DRAGGING',
|
|
269
|
+
data: {
|
|
270
|
+
dragging: {
|
|
271
|
+
startX: 0,
|
|
272
|
+
startWidth: width,
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
})(state, fakeDispatch);
|
|
276
|
+
|
|
208
277
|
const maxSize = getTableMaxWidth({
|
|
209
278
|
table: originalTable,
|
|
210
279
|
tableStart: tableStartPosition,
|
|
@@ -240,15 +309,61 @@ export const changeColumnWidthByStep =
|
|
|
240
309
|
resizingSelectedColumns ? selectedColumns : undefined,
|
|
241
310
|
);
|
|
242
311
|
|
|
243
|
-
|
|
312
|
+
customTr = updateColumnWidths(
|
|
244
313
|
newResizeState,
|
|
245
314
|
originalTable,
|
|
246
315
|
tableStartPosition,
|
|
247
|
-
)(
|
|
316
|
+
)(customTr);
|
|
248
317
|
|
|
249
318
|
if (dispatch) {
|
|
250
|
-
dispatch(
|
|
319
|
+
dispatch(customTr);
|
|
251
320
|
}
|
|
252
321
|
|
|
253
322
|
return true;
|
|
254
323
|
};
|
|
324
|
+
|
|
325
|
+
export const stopKeyboardColumnResizing =
|
|
326
|
+
(originalTr?: Transaction): Command =>
|
|
327
|
+
(state, dispatch) => {
|
|
328
|
+
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
let customTr = originalTr || state.tr;
|
|
332
|
+
const fakeDispatch = (tr: Transaction) => {
|
|
333
|
+
customTr = tr;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
const decorationWithoutWidget = clearColumnResizingDecorations()({
|
|
337
|
+
tr: customTr,
|
|
338
|
+
decorationSet: getDecorations(state),
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const decorationWithoutWidgetAndHandle = updateDecorations(
|
|
342
|
+
customTr.doc,
|
|
343
|
+
decorationWithoutWidget,
|
|
344
|
+
[],
|
|
345
|
+
TableDecorations.COLUMN_RESIZING_HANDLE_LINE,
|
|
346
|
+
);
|
|
347
|
+
getTablePluginCommand(
|
|
348
|
+
{
|
|
349
|
+
type: 'STOP_KEYBOARD_COLUMN_RESIZE',
|
|
350
|
+
data: {
|
|
351
|
+
decorationSet: decorationWithoutWidgetAndHandle,
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
customTr,
|
|
355
|
+
)(state, fakeDispatch);
|
|
356
|
+
|
|
357
|
+
tableResizingPluginCreateCommand(
|
|
358
|
+
{
|
|
359
|
+
type: 'STOP_RESIZING',
|
|
360
|
+
},
|
|
361
|
+
() => customTr.setMeta('scrollIntoView', false),
|
|
362
|
+
)(state, fakeDispatch);
|
|
363
|
+
|
|
364
|
+
if (dispatch) {
|
|
365
|
+
dispatch(customTr);
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
return false;
|
|
369
|
+
};
|
|
@@ -13,12 +13,9 @@ import {
|
|
|
13
13
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
14
14
|
|
|
15
15
|
import { insertRowWithAnalytics } from '../commands-with-analytics';
|
|
16
|
-
import {
|
|
17
|
-
getPluginState as getResizePluginState,
|
|
18
|
-
createCommand as tableResizingPluginCreateCommand,
|
|
19
|
-
} from '../pm-plugins/table-resizing/plugin-factory';
|
|
16
|
+
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
20
17
|
|
|
21
|
-
import {
|
|
18
|
+
import { stopKeyboardColumnResizing } from './column-resize';
|
|
22
19
|
|
|
23
20
|
const TAB_FORWARD_DIRECTION = 1;
|
|
24
21
|
const TAB_BACKWARD_DIRECTION = -1;
|
|
@@ -26,23 +23,17 @@ const TAB_BACKWARD_DIRECTION = -1;
|
|
|
26
23
|
export const goToNextCell =
|
|
27
24
|
(editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
|
|
28
25
|
(direction: Direction): Command =>
|
|
29
|
-
(state, dispatch) => {
|
|
26
|
+
(state, dispatch, view) => {
|
|
30
27
|
const table = findTable(state.selection);
|
|
31
28
|
if (!table) {
|
|
32
29
|
return false;
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
36
|
-
const isColumnResizing =
|
|
33
|
+
const isColumnResizing = getPluginState(state)?.isKeyboardResize;
|
|
37
34
|
if (isColumnResizing) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
type: 'STOP_RESIZING',
|
|
41
|
-
},
|
|
42
|
-
(originalTr) =>
|
|
43
|
-
(state.tr || originalTr).setMeta('scrollIntoView', false),
|
|
44
|
-
)(state, dispatch);
|
|
45
|
-
hideResizeHandleLine()(state, dispatch);
|
|
35
|
+
stopKeyboardColumnResizing()(state, dispatch, view);
|
|
36
|
+
return true;
|
|
46
37
|
}
|
|
47
38
|
}
|
|
48
39
|
|
package/src/commands/misc.ts
CHANGED
|
@@ -616,6 +616,7 @@ export const addResizeHandleDecorations = (
|
|
|
616
616
|
rowIndex: number,
|
|
617
617
|
columnIndex: number,
|
|
618
618
|
includeTooltip: boolean,
|
|
619
|
+
isKeyboardResize?: boolean,
|
|
619
620
|
) =>
|
|
620
621
|
createCommand(
|
|
621
622
|
(state) => {
|
|
@@ -644,6 +645,7 @@ export const addResizeHandleDecorations = (
|
|
|
644
645
|
resizeHandleRowIndex: rowIndex,
|
|
645
646
|
resizeHandleColumnIndex: columnIndex,
|
|
646
647
|
resizeHandleIncludeTooltip: includeTooltip,
|
|
648
|
+
isKeyboardResize: isKeyboardResize || false,
|
|
647
649
|
},
|
|
648
650
|
};
|
|
649
651
|
},
|
|
@@ -28,7 +28,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
|
28
28
|
|
|
29
29
|
import { selectColumn, selectRow } from '../commands/misc';
|
|
30
30
|
import type tablePlugin from '../plugin';
|
|
31
|
-
import { getPluginState
|
|
31
|
+
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
32
32
|
import { getClosestSelectionRect } from '../toolbar';
|
|
33
33
|
|
|
34
34
|
export enum TableSelectionDirection {
|
|
@@ -294,8 +294,8 @@ const arrowLeftFromText =
|
|
|
294
294
|
let isColumnResizing = false;
|
|
295
295
|
|
|
296
296
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
297
|
-
const columResizePluginState =
|
|
298
|
-
isColumnResizing = Boolean(columResizePluginState?.
|
|
297
|
+
const columResizePluginState = getPluginState(state) || {};
|
|
298
|
+
isColumnResizing = Boolean(columResizePluginState?.isKeyboardResize);
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
if (
|
|
@@ -343,8 +343,8 @@ const arrowRightFromText =
|
|
|
343
343
|
let isColumnResizing = false;
|
|
344
344
|
|
|
345
345
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
346
|
-
const columResizePluginState =
|
|
347
|
-
isColumnResizing = Boolean(columResizePluginState?.
|
|
346
|
+
const columResizePluginState = getPluginState(state) || {};
|
|
347
|
+
isColumnResizing = Boolean(columResizePluginState?.isKeyboardResize);
|
|
348
348
|
}
|
|
349
349
|
if (
|
|
350
350
|
isSelectionAtEndOfTable($to, selection) &&
|
package/src/event-handlers.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
getSelectionRect,
|
|
28
28
|
removeTable,
|
|
29
29
|
} from '@atlaskit/editor-tables/utils';
|
|
30
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
30
31
|
|
|
31
32
|
import {
|
|
32
33
|
addResizeHandleDecorations,
|
|
@@ -295,7 +296,16 @@ export const handleMouseOut = (
|
|
|
295
296
|
!isResizeHandleDecoration(relatedTarget)
|
|
296
297
|
) {
|
|
297
298
|
const { state, dispatch } = view;
|
|
298
|
-
|
|
299
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
300
|
+
const { isKeyboardResize } = getPluginState(state);
|
|
301
|
+
if (isKeyboardResize) {
|
|
302
|
+
// no need to hide decoration if column resizing started by keyboard
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
return hideResizeHandleLine()(state, dispatch);
|
|
306
|
+
} else {
|
|
307
|
+
return hideResizeHandleLine()(state, dispatch);
|
|
308
|
+
}
|
|
299
309
|
}
|
|
300
310
|
|
|
301
311
|
return false;
|
|
@@ -421,6 +431,12 @@ export const handleMouseMove = (
|
|
|
421
431
|
const { state, dispatch } = view;
|
|
422
432
|
const { resizeHandleColumnIndex, resizeHandleRowIndex } =
|
|
423
433
|
getPluginState(state);
|
|
434
|
+
|
|
435
|
+
const isKeyboardResize = getBooleanFF(
|
|
436
|
+
'platform.editor.a11y-column-resizing_emcvz',
|
|
437
|
+
)
|
|
438
|
+
? getPluginState(state).isKeyboardResize
|
|
439
|
+
: false;
|
|
424
440
|
const tableCell = closestElement(
|
|
425
441
|
element,
|
|
426
442
|
'td, th',
|
|
@@ -437,9 +453,10 @@ export const handleMouseMove = (
|
|
|
437
453
|
const rowIndexTarget = rect.top;
|
|
438
454
|
|
|
439
455
|
if (
|
|
440
|
-
columnEndIndexTarget !== resizeHandleColumnIndex ||
|
|
441
|
-
|
|
442
|
-
|
|
456
|
+
(columnEndIndexTarget !== resizeHandleColumnIndex ||
|
|
457
|
+
rowIndexTarget !== resizeHandleRowIndex ||
|
|
458
|
+
!hasResizeHandler({ target: element, columnEndIndexTarget })) &&
|
|
459
|
+
!isKeyboardResize // if initiated by keyboard don't need to react on hover for other resize sliders
|
|
443
460
|
) {
|
|
444
461
|
return addResizeHandleDecorations(
|
|
445
462
|
rowIndexTarget,
|
|
@@ -22,10 +22,9 @@ import {
|
|
|
22
22
|
getSelectedColumnIndexes,
|
|
23
23
|
getSelectedRowIndexes,
|
|
24
24
|
getSelectedTableInfo,
|
|
25
|
-
hasMergedCellsInColumn,
|
|
26
|
-
hasMergedCellsInRow,
|
|
27
25
|
} from '../../utils';
|
|
28
26
|
import { withEditorAnalyticsAPI } from '../../utils/analytics';
|
|
27
|
+
import { canMove, getTargetIndex } from '../../utils/drag-menu';
|
|
29
28
|
|
|
30
29
|
import { clearDropTarget, moveSource } from './commands';
|
|
31
30
|
|
|
@@ -132,44 +131,24 @@ export const moveSourceWithAnalyticsViaShortcut =
|
|
|
132
131
|
const selectedIndexes = isRow
|
|
133
132
|
? getSelectedRowIndexes(selectionRect)
|
|
134
133
|
: getSelectedColumnIndexes(selectionRect);
|
|
135
|
-
|
|
136
134
|
if (selectedIndexes.length === 0) {
|
|
137
135
|
return false;
|
|
138
136
|
}
|
|
139
137
|
|
|
140
|
-
// const sourceIndex = selectedIndexes[0];
|
|
141
|
-
// we can move only by one row/column
|
|
142
|
-
// 'direction' can only be 1 (for right or down) or -1 (for left or up)
|
|
143
|
-
const targetIndex =
|
|
144
|
-
Math[direction < 0 ? 'min' : 'max'](...selectedIndexes) + direction;
|
|
145
|
-
|
|
146
|
-
// We can move only if targetIndex is a positive number and is not higher than the total number of rows/columns.
|
|
147
138
|
const { totalRowCount, totalColumnCount } = getSelectedTableInfo(selection);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
?
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// We can move only if there are no merged cells in the source or target row/column
|
|
160
|
-
const hasMergedCellsInSource = isRow
|
|
161
|
-
? hasMergedCellsInRow(selectedIndexes)(selection)
|
|
162
|
-
: hasMergedCellsInColumn(selectedIndexes)(selection);
|
|
163
|
-
if (hasMergedCellsInSource) {
|
|
139
|
+
if (
|
|
140
|
+
!canMove(
|
|
141
|
+
sourceType,
|
|
142
|
+
direction,
|
|
143
|
+
isRow ? totalRowCount : totalColumnCount,
|
|
144
|
+
selection,
|
|
145
|
+
selectionRect,
|
|
146
|
+
)
|
|
147
|
+
) {
|
|
164
148
|
return false;
|
|
165
149
|
}
|
|
166
150
|
|
|
167
|
-
const
|
|
168
|
-
? hasMergedCellsInRow(targetIndex)(selection)
|
|
169
|
-
: hasMergedCellsInColumn(targetIndex)(selection);
|
|
170
|
-
if (hasMergedCellsInTarget) {
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
151
|
+
const targetIndex = getTargetIndex(selectedIndexes, direction);
|
|
173
152
|
|
|
174
153
|
return moveSourceWithAnalytics(editorAnalyticsAPI)(
|
|
175
154
|
INPUT_METHOD.SHORTCUT,
|
package/src/pm-plugins/keymap.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
decreaseMediaSize,
|
|
17
17
|
deleteColumn,
|
|
18
18
|
deleteRow,
|
|
19
|
+
escape,
|
|
19
20
|
increaseMediaSize,
|
|
20
21
|
moveColumnLeft,
|
|
21
22
|
moveColumnRight,
|
|
@@ -45,6 +46,7 @@ import {
|
|
|
45
46
|
activateNextResizeArea,
|
|
46
47
|
changeColumnWidthByStep,
|
|
47
48
|
initiateKeyboardColumnResizing,
|
|
49
|
+
stopKeyboardColumnResizing,
|
|
48
50
|
} from '../commands/column-resize';
|
|
49
51
|
import {
|
|
50
52
|
addColumnAfter as addColumnAfterCommand,
|
|
@@ -190,6 +192,7 @@ export function keymapPlugin(
|
|
|
190
192
|
changeColumnWidthByStep(10, getEditorContainerWidth),
|
|
191
193
|
list,
|
|
192
194
|
);
|
|
195
|
+
bindKeymapWithCommand(escape.common!, stopKeyboardColumnResizing(), list);
|
|
193
196
|
}
|
|
194
197
|
|
|
195
198
|
return keymap(list) as SafePlugin;
|