@atlaskit/editor-plugin-table 7.5.4 → 7.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/commands/column-resize.js +3 -3
- package/dist/cjs/commands/delete.js +2 -2
- package/dist/cjs/commands/insert.js +15 -15
- package/dist/cjs/commands-with-analytics.js +7 -7
- package/dist/cjs/event-handlers.js +27 -11
- package/dist/cjs/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/cjs/nodeviews/TableCell.js +5 -30
- package/dist/cjs/nodeviews/TableComponent.js +120 -83
- package/dist/cjs/nodeviews/TableContainer.js +23 -21
- package/dist/cjs/nodeviews/TableResizer.js +13 -13
- package/dist/cjs/nodeviews/table.js +9 -9
- package/dist/cjs/plugin.js +60 -59
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/cjs/pm-plugins/keymap.js +6 -8
- package/dist/cjs/pm-plugins/main.js +7 -24
- package/dist/cjs/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +11 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/cjs/pm-plugins/table-width.js +6 -2
- package/dist/cjs/toolbar.js +21 -21
- package/dist/cjs/transforms/column-width.js +4 -4
- package/dist/cjs/transforms/delete-columns.js +2 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +6 -6
- package/dist/cjs/ui/FloatingInsertButton/index.js +6 -7
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +8 -48
- package/dist/cjs/ui/TableFloatingControls/index.js +113 -223
- package/dist/cjs/utils/column-controls.js +5 -5
- package/dist/cjs/utils/create.js +2 -5
- package/dist/cjs/utils/dom.js +13 -15
- package/dist/cjs/utils/drag-menu.js +4 -4
- package/dist/es2019/commands/column-resize.js +3 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +12 -12
- package/dist/es2019/commands-with-analytics.js +6 -6
- package/dist/es2019/event-handlers.js +27 -11
- package/dist/es2019/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/es2019/nodeviews/TableCell.js +1 -24
- package/dist/es2019/nodeviews/TableComponent.js +88 -63
- package/dist/es2019/nodeviews/TableContainer.js +20 -22
- package/dist/es2019/nodeviews/TableResizer.js +13 -13
- package/dist/es2019/nodeviews/table.js +9 -9
- package/dist/es2019/plugin.js +19 -20
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +6 -6
- package/dist/es2019/pm-plugins/keymap.js +5 -8
- package/dist/es2019/pm-plugins/main.js +6 -23
- package/dist/es2019/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +5 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +3 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -13
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/es2019/pm-plugins/table-width.js +6 -2
- package/dist/es2019/toolbar.js +15 -15
- package/dist/es2019/transforms/column-width.js +5 -5
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +9 -12
- package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +5 -5
- package/dist/es2019/ui/FloatingInsertButton/index.js +5 -6
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -27
- package/dist/es2019/ui/TableFloatingControls/index.js +119 -193
- package/dist/es2019/utils/column-controls.js +6 -6
- package/dist/es2019/utils/create.js +2 -5
- package/dist/es2019/utils/dom.js +13 -15
- package/dist/es2019/utils/drag-menu.js +4 -4
- package/dist/esm/commands/column-resize.js +3 -3
- package/dist/esm/commands/delete.js +2 -2
- package/dist/esm/commands/insert.js +15 -15
- package/dist/esm/commands-with-analytics.js +7 -7
- package/dist/esm/event-handlers.js +27 -11
- package/dist/esm/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/esm/nodeviews/TableCell.js +5 -30
- package/dist/esm/nodeviews/TableComponent.js +119 -82
- package/dist/esm/nodeviews/TableContainer.js +24 -22
- package/dist/esm/nodeviews/TableResizer.js +13 -13
- package/dist/esm/nodeviews/table.js +9 -9
- package/dist/esm/plugin.js +60 -59
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/esm/pm-plugins/keymap.js +6 -8
- package/dist/esm/pm-plugins/main.js +7 -24
- package/dist/esm/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +4 -3
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -14
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/esm/pm-plugins/table-width.js +6 -2
- package/dist/esm/toolbar.js +21 -21
- package/dist/esm/transforms/column-width.js +5 -5
- package/dist/esm/transforms/delete-columns.js +2 -2
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/esm/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +6 -6
- package/dist/esm/ui/FloatingInsertButton/index.js +6 -7
- package/dist/esm/ui/TableFloatingColumnControls/index.js +8 -48
- package/dist/esm/ui/TableFloatingControls/index.js +113 -224
- package/dist/esm/utils/column-controls.js +6 -6
- package/dist/esm/utils/create.js +2 -5
- package/dist/esm/utils/dom.js +13 -15
- package/dist/esm/utils/drag-menu.js +4 -4
- package/dist/types/commands/column-resize.d.ts +1 -1
- package/dist/types/commands/delete.d.ts +1 -1
- package/dist/types/commands/insert.d.ts +7 -7
- package/dist/types/commands-with-analytics.d.ts +3 -3
- package/dist/types/event-handlers.d.ts +4 -5
- package/dist/types/nodeviews/OverflowShadowsObserver.d.ts +3 -1
- package/dist/types/nodeviews/TableCell.d.ts +1 -5
- package/dist/types/nodeviews/TableComponent.d.ts +6 -3
- package/dist/types/nodeviews/TableContainer.d.ts +6 -4
- package/dist/types/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types/pm-plugins/table-width.d.ts +1 -2
- package/dist/types/toolbar.d.ts +2 -2
- package/dist/types/transforms/column-width.d.ts +1 -1
- package/dist/types/transforms/delete-columns.d.ts +1 -1
- package/dist/types/types.d.ts +1 -3
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -1
- package/dist/types/ui/TableFloatingControls/index.d.ts +5 -22
- package/dist/types/utils/create.d.ts +1 -2
- package/dist/types/utils/dom.d.ts +10 -2
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
- package/dist/types-ts4.5/commands/delete.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +7 -7
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -3
- package/dist/types-ts4.5/event-handlers.d.ts +4 -5
- package/dist/types-ts4.5/nodeviews/OverflowShadowsObserver.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/TableCell.d.ts +1 -5
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +6 -3
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +6 -4
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -2
- package/dist/types-ts4.5/toolbar.d.ts +2 -2
- package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
- package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +1 -3
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +5 -22
- package/dist/types-ts4.5/utils/create.d.ts +1 -2
- package/dist/types-ts4.5/utils/dom.d.ts +10 -2
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +3 -4
- package/src/commands/column-resize.ts +4 -3
- package/src/commands/delete.ts +2 -2
- package/src/commands/insert.ts +15 -27
- package/src/commands-with-analytics.ts +6 -9
- package/src/event-handlers.ts +107 -105
- package/src/nodeviews/OverflowShadowsObserver.ts +32 -21
- package/src/nodeviews/TableCell.ts +0 -26
- package/src/nodeviews/TableComponent.tsx +107 -78
- package/src/nodeviews/TableContainer.tsx +26 -32
- package/src/nodeviews/TableResizer.tsx +15 -18
- package/src/nodeviews/table.tsx +6 -5
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +17 -32
- package/src/pm-plugins/drag-and-drop/plugin.ts +10 -15
- package/src/pm-plugins/keymap.ts +6 -13
- package/src/pm-plugins/main.ts +6 -25
- package/src/pm-plugins/sticky-headers/plugin.ts +2 -11
- package/src/pm-plugins/table-resizing/event-handlers.ts +6 -4
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +1 -1
- package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +5 -2
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -13
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +14 -14
- package/src/pm-plugins/table-width.ts +4 -6
- package/src/toolbar.tsx +16 -19
- package/src/transforms/column-width.ts +7 -6
- package/src/transforms/delete-columns.ts +2 -2
- package/src/types.ts +1 -4
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -16
- package/src/ui/FloatingContextualMenu/index.tsx +0 -2
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -3
- package/src/ui/FloatingDragMenu/index.tsx +4 -8
- package/src/ui/FloatingInsertButton/index.tsx +11 -22
- package/src/ui/TableFloatingColumnControls/index.tsx +5 -29
- package/src/ui/TableFloatingControls/index.tsx +155 -241
- package/src/utils/column-controls.ts +5 -6
- package/src/utils/create.ts +2 -5
- package/src/utils/dom.ts +12 -19
- package/src/utils/drag-menu.ts +7 -12
package/src/commands/insert.ts
CHANGED
|
@@ -11,12 +11,7 @@ import {
|
|
|
11
11
|
EVENT_TYPE,
|
|
12
12
|
TABLE_OVERFLOW_CHANGE_TRIGGER,
|
|
13
13
|
} from '@atlaskit/editor-common/analytics';
|
|
14
|
-
import type {
|
|
15
|
-
Command,
|
|
16
|
-
EditorCommand,
|
|
17
|
-
GetEditorContainerWidth,
|
|
18
|
-
GetEditorFeatureFlags,
|
|
19
|
-
} from '@atlaskit/editor-common/types';
|
|
14
|
+
import type { Command, EditorCommand } from '@atlaskit/editor-common/types';
|
|
20
15
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
21
16
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
22
17
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -50,10 +45,7 @@ function addColumnAtCustomStep(column: number) {
|
|
|
50
45
|
};
|
|
51
46
|
}
|
|
52
47
|
|
|
53
|
-
export function addColumnAt(
|
|
54
|
-
getEditorContainerWidth: GetEditorContainerWidth,
|
|
55
|
-
tablePreserveWidth = false,
|
|
56
|
-
) {
|
|
48
|
+
export function addColumnAt(isTableScalingEnabled = false) {
|
|
57
49
|
return (
|
|
58
50
|
column: number,
|
|
59
51
|
allowAddColumnCustomStep: boolean = false,
|
|
@@ -69,7 +61,9 @@ export function addColumnAt(
|
|
|
69
61
|
const table = findTable(updatedTr.selection);
|
|
70
62
|
if (table) {
|
|
71
63
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
72
|
-
updatedTr = rescaleColumns(
|
|
64
|
+
updatedTr = rescaleColumns(isTableScalingEnabled)(table, view)(
|
|
65
|
+
updatedTr,
|
|
66
|
+
);
|
|
73
67
|
}
|
|
74
68
|
|
|
75
69
|
if (
|
|
@@ -94,10 +88,7 @@ export function addColumnAt(
|
|
|
94
88
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
95
89
|
// Command to add a column before the column with the selection.
|
|
96
90
|
export const addColumnBefore =
|
|
97
|
-
(
|
|
98
|
-
getEditorContainerWidth: GetEditorContainerWidth,
|
|
99
|
-
tablePreserveWidth = false,
|
|
100
|
-
): Command =>
|
|
91
|
+
(isTableScalingEnabled = false): Command =>
|
|
101
92
|
(state, dispatch, view) => {
|
|
102
93
|
const table = findTable(state.selection);
|
|
103
94
|
if (!table) {
|
|
@@ -106,7 +97,7 @@ export const addColumnBefore =
|
|
|
106
97
|
if (dispatch) {
|
|
107
98
|
let rect = selectedRect(state);
|
|
108
99
|
dispatch(
|
|
109
|
-
addColumnAt(
|
|
100
|
+
addColumnAt(isTableScalingEnabled)(
|
|
110
101
|
rect.left,
|
|
111
102
|
getAllowAddColumnCustomStep(state),
|
|
112
103
|
view,
|
|
@@ -119,7 +110,7 @@ export const addColumnBefore =
|
|
|
119
110
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
120
111
|
// Command to add a column after the column with the selection.
|
|
121
112
|
export const addColumnAfter =
|
|
122
|
-
(
|
|
113
|
+
(isTableScalingEnabled?: boolean): Command =>
|
|
123
114
|
(state, dispatch, view) => {
|
|
124
115
|
const table = findTable(state.selection);
|
|
125
116
|
if (!table) {
|
|
@@ -128,7 +119,7 @@ export const addColumnAfter =
|
|
|
128
119
|
if (dispatch) {
|
|
129
120
|
let rect = selectedRect(state);
|
|
130
121
|
dispatch(
|
|
131
|
-
addColumnAt(
|
|
122
|
+
addColumnAt(isTableScalingEnabled)(
|
|
132
123
|
rect.right,
|
|
133
124
|
getAllowAddColumnCustomStep(state),
|
|
134
125
|
view,
|
|
@@ -139,13 +130,10 @@ export const addColumnAfter =
|
|
|
139
130
|
};
|
|
140
131
|
|
|
141
132
|
export const insertColumn =
|
|
142
|
-
(
|
|
143
|
-
getEditorContainerWidth: GetEditorContainerWidth,
|
|
144
|
-
tablePreserveWidth = false,
|
|
145
|
-
) =>
|
|
133
|
+
(isTableScalingEnabled = false) =>
|
|
146
134
|
(column: number): Command =>
|
|
147
135
|
(state, dispatch, view) => {
|
|
148
|
-
let tr = addColumnAt(
|
|
136
|
+
let tr = addColumnAt(isTableScalingEnabled)(
|
|
149
137
|
column,
|
|
150
138
|
getAllowAddColumnCustomStep(state),
|
|
151
139
|
view,
|
|
@@ -213,13 +201,13 @@ export const insertRow =
|
|
|
213
201
|
|
|
214
202
|
export const createTable =
|
|
215
203
|
(
|
|
204
|
+
isTableScalingEnabled?: boolean,
|
|
216
205
|
isFullWidthModeEnabled?: boolean,
|
|
217
|
-
getEditorFeatureFlags?: GetEditorFeatureFlags,
|
|
218
206
|
): Command =>
|
|
219
207
|
(state, dispatch) => {
|
|
220
208
|
const table = createTableWithWidth(
|
|
209
|
+
isTableScalingEnabled,
|
|
221
210
|
isFullWidthModeEnabled,
|
|
222
|
-
getEditorFeatureFlags,
|
|
223
211
|
)(state.schema);
|
|
224
212
|
|
|
225
213
|
if (dispatch) {
|
|
@@ -231,7 +219,7 @@ export const createTable =
|
|
|
231
219
|
export const insertTableWithSize =
|
|
232
220
|
(
|
|
233
221
|
isFullWidthModeEnabled?: boolean,
|
|
234
|
-
|
|
222
|
+
isTableScalingEnabled?: boolean,
|
|
235
223
|
editorAnalyticsAPI?: EditorAnalyticsAPI,
|
|
236
224
|
) =>
|
|
237
225
|
(
|
|
@@ -241,8 +229,8 @@ export const insertTableWithSize =
|
|
|
241
229
|
): EditorCommand => {
|
|
242
230
|
return ({ tr }) => {
|
|
243
231
|
const tableNode = createTableWithWidth(
|
|
232
|
+
isTableScalingEnabled,
|
|
244
233
|
isFullWidthModeEnabled,
|
|
245
|
-
getEditorFeatureFlags,
|
|
246
234
|
{
|
|
247
235
|
rowsCount: rowsCount,
|
|
248
236
|
colsCount: colsCount,
|
|
@@ -257,7 +257,7 @@ export const changeColumnWidthByStepWithAnalytics =
|
|
|
257
257
|
(
|
|
258
258
|
stepSize: number,
|
|
259
259
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
260
|
-
|
|
260
|
+
isTableScalingEnabled: boolean,
|
|
261
261
|
inputMethod: INPUT_METHOD.SHORTCUT,
|
|
262
262
|
) =>
|
|
263
263
|
withEditorAnalyticsAPI((state) => {
|
|
@@ -286,15 +286,14 @@ export const changeColumnWidthByStepWithAnalytics =
|
|
|
286
286
|
changeColumnWidthByStep(
|
|
287
287
|
stepSize,
|
|
288
288
|
getEditorContainerWidth,
|
|
289
|
-
|
|
289
|
+
isTableScalingEnabled,
|
|
290
290
|
),
|
|
291
291
|
);
|
|
292
292
|
|
|
293
293
|
export const insertColumnWithAnalytics =
|
|
294
294
|
(
|
|
295
|
-
getEditorContainerWidth: GetEditorContainerWidth,
|
|
296
295
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
297
|
-
|
|
296
|
+
isTableScalingEnabled = false,
|
|
298
297
|
) =>
|
|
299
298
|
(
|
|
300
299
|
inputMethod:
|
|
@@ -321,9 +320,7 @@ export const insertColumnWithAnalytics =
|
|
|
321
320
|
},
|
|
322
321
|
eventType: EVENT_TYPE.TRACK,
|
|
323
322
|
};
|
|
324
|
-
})(editorAnalyticsAPI)(
|
|
325
|
-
insertColumn(getEditorContainerWidth, tablePreserveWidth)(position),
|
|
326
|
-
);
|
|
323
|
+
})(editorAnalyticsAPI)(insertColumn(isTableScalingEnabled)(position));
|
|
327
324
|
|
|
328
325
|
export const deleteRowsWithAnalytics =
|
|
329
326
|
(editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
|
|
@@ -364,7 +361,7 @@ export const deleteRowsWithAnalytics =
|
|
|
364
361
|
export const deleteColumnsWithAnalytics =
|
|
365
362
|
(
|
|
366
363
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
367
|
-
|
|
364
|
+
isTableScalingEnabled = false,
|
|
368
365
|
) =>
|
|
369
366
|
(
|
|
370
367
|
inputMethod:
|
|
@@ -392,7 +389,7 @@ export const deleteColumnsWithAnalytics =
|
|
|
392
389
|
},
|
|
393
390
|
eventType: EVENT_TYPE.TRACK,
|
|
394
391
|
};
|
|
395
|
-
})(editorAnalyticsAPI)(deleteColumnsCommand(rect,
|
|
392
|
+
})(editorAnalyticsAPI)(deleteColumnsCommand(rect, isTableScalingEnabled));
|
|
396
393
|
|
|
397
394
|
export const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut =
|
|
398
395
|
(editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null): Command =>
|
package/src/event-handlers.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import rafSchedule from 'raf-schd';
|
|
2
|
+
|
|
1
3
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
4
|
import {
|
|
3
5
|
ACTION_SUBJECT,
|
|
@@ -47,7 +49,6 @@ import { getPluginState as getDragDropPluginState } from './pm-plugins/drag-and-
|
|
|
47
49
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
48
50
|
import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
|
|
49
51
|
import { deleteColumns, deleteRows } from './transforms';
|
|
50
|
-
import type { ElementContentRects } from './types';
|
|
51
52
|
import {
|
|
52
53
|
TableCssClassName as ClassName,
|
|
53
54
|
RESIZE_HANDLE_AREA_DECORATION_GAP,
|
|
@@ -406,104 +407,119 @@ export const handleMouseLeave = (view: EditorView, event: Event): boolean => {
|
|
|
406
407
|
return false;
|
|
407
408
|
};
|
|
408
409
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
)
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
const element = event.target;
|
|
418
|
-
|
|
419
|
-
if (
|
|
420
|
-
isColumnControlsDecorations(element) ||
|
|
421
|
-
isDragColumnFloatingInsertDot(element)
|
|
422
|
-
) {
|
|
423
|
-
const { state, dispatch } = view;
|
|
424
|
-
const { insertColumnButtonIndex, isDragAndDropEnabled } =
|
|
425
|
-
getPluginState(state);
|
|
426
|
-
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
427
|
-
|
|
428
|
-
const positionColumn =
|
|
429
|
-
getMousePositionHorizontalRelativeByElement(
|
|
430
|
-
event as MouseEvent,
|
|
431
|
-
elementContentRects,
|
|
432
|
-
undefined,
|
|
433
|
-
isDragAndDropEnabled,
|
|
434
|
-
) === 'right'
|
|
435
|
-
? endIndex
|
|
436
|
-
: startIndex;
|
|
410
|
+
// IMPORTANT: The mouse move handler has been setup with RAF schedule to avoid Reflows which will occur as some methods
|
|
411
|
+
// need to access the mouse event offset position and also the target clientWidth vallue.
|
|
412
|
+
const handleMouseMoveDebounce = rafSchedule(
|
|
413
|
+
(view: EditorView, event: MouseEvent, offsetX: number) => {
|
|
414
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
const element = event.target;
|
|
437
418
|
|
|
438
|
-
if (
|
|
439
|
-
|
|
419
|
+
if (
|
|
420
|
+
isColumnControlsDecorations(element) ||
|
|
421
|
+
isDragColumnFloatingInsertDot(element)
|
|
422
|
+
) {
|
|
423
|
+
const { state, dispatch } = view;
|
|
424
|
+
const { insertColumnButtonIndex } = getPluginState(state);
|
|
425
|
+
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
426
|
+
|
|
427
|
+
const positionColumn =
|
|
428
|
+
getMousePositionHorizontalRelativeByElement(
|
|
429
|
+
event,
|
|
430
|
+
offsetX,
|
|
431
|
+
undefined,
|
|
432
|
+
) === 'right'
|
|
433
|
+
? endIndex
|
|
434
|
+
: startIndex;
|
|
435
|
+
|
|
436
|
+
if (positionColumn !== insertColumnButtonIndex) {
|
|
437
|
+
return showInsertColumnButton(positionColumn)(state, dispatch);
|
|
438
|
+
}
|
|
440
439
|
}
|
|
441
|
-
}
|
|
442
440
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
441
|
+
if (isRowControlsButton(element) || isDragRowFloatingInsertDot(element)) {
|
|
442
|
+
const { state, dispatch } = view;
|
|
443
|
+
const { insertRowButtonIndex } = getPluginState(state);
|
|
444
|
+
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
447
445
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
: startIndex;
|
|
446
|
+
const positionRow =
|
|
447
|
+
getMousePositionVerticalRelativeByElement(event) === 'bottom'
|
|
448
|
+
? endIndex
|
|
449
|
+
: startIndex;
|
|
453
450
|
|
|
454
|
-
|
|
455
|
-
|
|
451
|
+
if (positionRow !== insertRowButtonIndex) {
|
|
452
|
+
return showInsertRowButton(positionRow)(state, dispatch);
|
|
453
|
+
}
|
|
456
454
|
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
if (!isResizeHandleDecoration(element) && isCell(element)) {
|
|
460
|
-
const positionColumn = getMousePositionHorizontalRelativeByElement(
|
|
461
|
-
event as MouseEvent,
|
|
462
|
-
elementContentRects,
|
|
463
|
-
RESIZE_HANDLE_AREA_DECORATION_GAP,
|
|
464
|
-
);
|
|
465
455
|
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
const isKeyboardResize = getBooleanFF(
|
|
472
|
-
'platform.editor.a11y-column-resizing_emcvz',
|
|
473
|
-
)
|
|
474
|
-
? getPluginState(state).isKeyboardResize
|
|
475
|
-
: false;
|
|
476
|
-
const tableCell = closestElement(
|
|
477
|
-
element,
|
|
478
|
-
'td, th',
|
|
479
|
-
) as HTMLTableCellElement;
|
|
480
|
-
const cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
481
|
-
const rect = findCellRectClosestToPos(
|
|
482
|
-
state.doc.resolve(cellStartPosition),
|
|
456
|
+
if (!isResizeHandleDecoration(element) && isCell(element)) {
|
|
457
|
+
const positionColumn = getMousePositionHorizontalRelativeByElement(
|
|
458
|
+
event,
|
|
459
|
+
offsetX,
|
|
460
|
+
RESIZE_HANDLE_AREA_DECORATION_GAP,
|
|
483
461
|
);
|
|
484
462
|
|
|
485
|
-
if (
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
)
|
|
463
|
+
if (positionColumn !== null) {
|
|
464
|
+
const { state, dispatch } = view;
|
|
465
|
+
const { resizeHandleColumnIndex, resizeHandleRowIndex } =
|
|
466
|
+
getPluginState(state);
|
|
467
|
+
|
|
468
|
+
const isKeyboardResize = getBooleanFF(
|
|
469
|
+
'platform.editor.a11y-column-resizing_emcvz',
|
|
470
|
+
)
|
|
471
|
+
? getPluginState(state).isKeyboardResize
|
|
472
|
+
: false;
|
|
473
|
+
const tableCell = closestElement(
|
|
474
|
+
element,
|
|
475
|
+
'td, th',
|
|
476
|
+
) as HTMLTableCellElement;
|
|
477
|
+
const cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
478
|
+
const rect = findCellRectClosestToPos(
|
|
479
|
+
state.doc.resolve(cellStartPosition),
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
if (rect) {
|
|
483
|
+
const columnEndIndexTarget =
|
|
484
|
+
positionColumn === 'left' ? rect.left : rect.right;
|
|
485
|
+
|
|
486
|
+
const rowIndexTarget = rect.top;
|
|
487
|
+
|
|
488
|
+
if (
|
|
489
|
+
(columnEndIndexTarget !== resizeHandleColumnIndex ||
|
|
490
|
+
rowIndexTarget !== resizeHandleRowIndex ||
|
|
491
|
+
!hasResizeHandler({ target: element, columnEndIndexTarget })) &&
|
|
492
|
+
!isKeyboardResize // if initiated by keyboard don't need to react on hover for other resize sliders
|
|
493
|
+
) {
|
|
494
|
+
return addResizeHandleDecorations(
|
|
495
|
+
rowIndexTarget,
|
|
496
|
+
columnEndIndexTarget,
|
|
497
|
+
true,
|
|
498
|
+
)(state, dispatch);
|
|
499
|
+
}
|
|
502
500
|
}
|
|
503
501
|
}
|
|
504
502
|
}
|
|
503
|
+
|
|
504
|
+
return false;
|
|
505
|
+
},
|
|
506
|
+
);
|
|
507
|
+
|
|
508
|
+
export const handleMouseMove = (view: EditorView, event: Event) => {
|
|
509
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
510
|
+
return false;
|
|
505
511
|
}
|
|
506
512
|
|
|
513
|
+
// NOTE: When accessing offsetX in gecko from a deferred callback, it will return 0. However it will be non-zero if accessed
|
|
514
|
+
// within the scope of it's initial mouse move handler. Also Chrome does return the correct value, however it could trigger
|
|
515
|
+
// a reflow. So for now this will just grab the offsetX value immediately for gecko and chrome will calculate later
|
|
516
|
+
// in the deferred callback handler.
|
|
517
|
+
// Bug Tracking: https://bugzilla.mozilla.org/show_bug.cgi?id=1882903
|
|
518
|
+
handleMouseMoveDebounce(
|
|
519
|
+
view,
|
|
520
|
+
event as MouseEvent,
|
|
521
|
+
browser.gecko ? (event as MouseEvent).offsetX : NaN,
|
|
522
|
+
);
|
|
507
523
|
return false;
|
|
508
524
|
};
|
|
509
525
|
|
|
@@ -538,7 +554,7 @@ export const handleCut = (
|
|
|
538
554
|
newState: EditorState,
|
|
539
555
|
editorAnalyticsAPI?: EditorAnalyticsAPI,
|
|
540
556
|
editorView?: EditorView,
|
|
541
|
-
|
|
557
|
+
isTableScalingEnabled = false,
|
|
542
558
|
): Transaction => {
|
|
543
559
|
const oldSelection = oldState.tr.selection;
|
|
544
560
|
let { tr } = newState;
|
|
@@ -595,7 +611,7 @@ export const handleCut = (
|
|
|
595
611
|
rect,
|
|
596
612
|
getAllowAddColumnCustomStep(oldState),
|
|
597
613
|
editorView,
|
|
598
|
-
|
|
614
|
+
isTableScalingEnabled,
|
|
599
615
|
)(tr);
|
|
600
616
|
}
|
|
601
617
|
}
|
|
@@ -614,20 +630,13 @@ export const isTableInFocus = (view: EditorView) => {
|
|
|
614
630
|
};
|
|
615
631
|
|
|
616
632
|
export const whenTableInFocus =
|
|
617
|
-
(
|
|
618
|
-
eventHandler: (
|
|
619
|
-
view: EditorView,
|
|
620
|
-
mouseEvent: Event,
|
|
621
|
-
elementContentRects?: ElementContentRects,
|
|
622
|
-
) => boolean,
|
|
623
|
-
elementContentRects?: ElementContentRects,
|
|
624
|
-
) =>
|
|
633
|
+
(eventHandler: (view: EditorView, mouseEvent: Event) => boolean) =>
|
|
625
634
|
(view: EditorView, mouseEvent: Event): boolean => {
|
|
626
635
|
if (!isTableInFocus(view)) {
|
|
627
636
|
return false;
|
|
628
637
|
}
|
|
629
638
|
|
|
630
|
-
return eventHandler(view, mouseEvent
|
|
639
|
+
return eventHandler(view, mouseEvent);
|
|
631
640
|
};
|
|
632
641
|
|
|
633
642
|
const trackCellLocation = (view: EditorView, mouseEvent: Event) => {
|
|
@@ -681,14 +690,7 @@ const trackCellLocation = (view: EditorView, mouseEvent: Event) => {
|
|
|
681
690
|
};
|
|
682
691
|
|
|
683
692
|
export const withCellTracking =
|
|
684
|
-
(
|
|
685
|
-
eventHandler: (
|
|
686
|
-
view: EditorView,
|
|
687
|
-
mouseEvent: Event,
|
|
688
|
-
elementContentRects?: ElementContentRects,
|
|
689
|
-
) => boolean,
|
|
690
|
-
elementContentRects?: ElementContentRects,
|
|
691
|
-
) =>
|
|
693
|
+
(eventHandler: (view: EditorView, mouseEvent: Event) => boolean) =>
|
|
692
694
|
(view: EditorView, mouseEvent: Event): boolean => {
|
|
693
695
|
if (
|
|
694
696
|
getPluginState(view.state).isDragAndDropEnabled &&
|
|
@@ -696,5 +698,5 @@ export const withCellTracking =
|
|
|
696
698
|
) {
|
|
697
699
|
trackCellLocation(view, mouseEvent);
|
|
698
700
|
}
|
|
699
|
-
return eventHandler(view, mouseEvent
|
|
701
|
+
return eventHandler(view, mouseEvent);
|
|
700
702
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import rafSchedule from 'raf-schd';
|
|
2
|
+
|
|
1
3
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
2
4
|
|
|
3
5
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
@@ -82,11 +84,8 @@ export class OverflowShadowsObserver {
|
|
|
82
84
|
if (!stickyCell) {
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
this.stickyRowHeight = newStickyRowHeight;
|
|
88
|
-
this.updateStickyShadows(this.stickyRowHeight);
|
|
89
|
-
}
|
|
87
|
+
|
|
88
|
+
this.updateStickyShadows();
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
private getStickyCell() {
|
|
@@ -96,8 +95,14 @@ export class OverflowShadowsObserver {
|
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
observeShadowSentinels = (isSticky?: boolean) => {
|
|
98
|
+
if (this.isSticky === isSticky) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
99
102
|
this.isSticky = !!isSticky;
|
|
100
103
|
|
|
104
|
+
// reset height
|
|
105
|
+
this.stickyRowHeight = 0;
|
|
101
106
|
// update sticky shadows
|
|
102
107
|
this.updateStickyShadowsHeightIfChanged();
|
|
103
108
|
|
|
@@ -126,7 +131,7 @@ export class OverflowShadowsObserver {
|
|
|
126
131
|
* e.g. bounds on an IntersectionObserverEntry, otherwise proceed with
|
|
127
132
|
* reading it from sticky cell
|
|
128
133
|
*/
|
|
129
|
-
updateStickyShadows = (stickyRowHeight?: number) => {
|
|
134
|
+
updateStickyShadows = rafSchedule((stickyRowHeight?: number) => {
|
|
130
135
|
if (!this.isSticky) {
|
|
131
136
|
return;
|
|
132
137
|
}
|
|
@@ -134,21 +139,27 @@ export class OverflowShadowsObserver {
|
|
|
134
139
|
if (!stickyCell || !this.wrapper?.parentElement) {
|
|
135
140
|
return;
|
|
136
141
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
142
|
+
|
|
143
|
+
// Reflow Warning! - stickyCell.clientHeight
|
|
144
|
+
const newStickyRowHeight = stickyRowHeight || stickyCell.clientHeight + 1;
|
|
145
|
+
|
|
146
|
+
if (newStickyRowHeight !== this.stickyRowHeight) {
|
|
147
|
+
this.stickyRowHeight = newStickyRowHeight;
|
|
148
|
+
const heightStyleOrCompute = `${newStickyRowHeight}px`;
|
|
149
|
+
// Use getElementsByClassName here for a live node list to capture
|
|
150
|
+
// sticky shadows
|
|
151
|
+
const liveRightShadows =
|
|
152
|
+
this.wrapper?.parentElement?.getElementsByClassName(
|
|
153
|
+
`${ClassName.TABLE_RIGHT_SHADOW}`,
|
|
154
|
+
);
|
|
155
|
+
const liveLeftShadows =
|
|
156
|
+
this.wrapper?.parentElement?.getElementsByClassName(
|
|
157
|
+
`${ClassName.TABLE_LEFT_SHADOW}`,
|
|
158
|
+
);
|
|
159
|
+
updateShadowListForStickyStyles(heightStyleOrCompute, liveLeftShadows);
|
|
160
|
+
updateShadowListForStickyStyles(heightStyleOrCompute, liveRightShadows);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
152
163
|
|
|
153
164
|
dispose() {
|
|
154
165
|
if (this.tableIntersectionObserver) {
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import uuid from 'uuid';
|
|
2
|
-
|
|
3
1
|
import type { CellDomAttrs } from '@atlaskit/adf-schema';
|
|
4
2
|
import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
|
|
5
3
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
6
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
7
5
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
8
6
|
|
|
9
|
-
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
10
|
-
|
|
11
7
|
import TableNodeView from './TableNodeViewBase';
|
|
12
8
|
|
|
13
9
|
const DEFAULT_COL_SPAN = 1;
|
|
@@ -22,26 +18,10 @@ export default class TableCell
|
|
|
22
18
|
view: EditorView,
|
|
23
19
|
getPos: () => number | undefined,
|
|
24
20
|
eventDispatcher: EventDispatcher,
|
|
25
|
-
private readonly observer?: ResizeObserver,
|
|
26
21
|
) {
|
|
27
22
|
super(node, view, getPos, eventDispatcher);
|
|
28
|
-
|
|
29
|
-
const { pluginConfig, isDragAndDropEnabled } = getPluginState(view.state);
|
|
30
|
-
|
|
31
|
-
this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
|
|
32
|
-
this.isDragAndDropEnabled = !!isDragAndDropEnabled;
|
|
33
|
-
|
|
34
|
-
if (observer) {
|
|
35
|
-
this.contentDOM.id = uuid();
|
|
36
|
-
observer.observe(this.contentDOM);
|
|
37
|
-
}
|
|
38
23
|
}
|
|
39
24
|
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
private isStickyHeaderEnabled: boolean;
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
private isDragAndDropEnabled: boolean;
|
|
44
|
-
|
|
45
25
|
update(node: PMNode) {
|
|
46
26
|
const didUpdate = this.updateNodeView(node);
|
|
47
27
|
if (didUpdate) {
|
|
@@ -50,12 +30,6 @@ export default class TableCell
|
|
|
50
30
|
return didUpdate;
|
|
51
31
|
}
|
|
52
32
|
|
|
53
|
-
destroy() {
|
|
54
|
-
if (this.observer) {
|
|
55
|
-
this.observer.unobserve(this.contentDOM);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
33
|
private updateNodeView(node: PMNode) {
|
|
60
34
|
if (this.node.type !== node.type) {
|
|
61
35
|
return false;
|