@atlaskit/editor-plugin-table 5.6.3 → 5.6.5

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 5.6.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#58893](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58893) [`ed82b25d516b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ed82b25d516b) - [ux] [ECA11Y-110] Selecting table columns and rows via shortcuts
8
+
9
+ ## 5.6.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [#61812](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/61812) [`1d1776f9f6bf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1d1776f9f6bf) - Fix issue where inserting column via drag menu introduces a scroll
14
+
3
15
  ## 5.6.3
4
16
 
5
17
  ### Patch Changes
@@ -3,12 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.shiftArrowUpFromTable = exports.arrowRightFromTable = exports.arrowLeftFromTable = exports.TableSelectionDirection = void 0;
6
+ exports.shiftArrowUpFromTable = exports.selectRows = exports.selectColumns = exports.arrowRightFromTable = exports.arrowLeftFromTable = exports.TableSelectionDirection = void 0;
7
7
  var _selection = require("@atlaskit/editor-common/selection");
8
8
  var _state = require("@atlaskit/editor-prosemirror/state");
9
9
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
10
10
  var _tableMap = require("@atlaskit/editor-tables/table-map");
11
11
  var _utils = require("@atlaskit/editor-tables/utils");
12
+ var _misc = require("../commands/misc");
12
13
  var _toolbar = require("../toolbar");
13
14
  var TableSelectionDirection = exports.TableSelectionDirection = /*#__PURE__*/function (TableSelectionDirection) {
14
15
  TableSelectionDirection["TopToBottom"] = "TopToBottom";
@@ -83,6 +84,46 @@ var arrowRightFromCellSelection = function arrowRightFromCellSelection(editorSel
83
84
  };
84
85
  };
85
86
  };
87
+ var selectColumns = exports.selectColumns = function selectColumns(editorSelectionAPI) {
88
+ return function () {
89
+ return function (state, dispatch) {
90
+ var selection = state.selection;
91
+ var table = (0, _utils.findTable)(selection);
92
+ var rect = (0, _utils.selectedRect)(state);
93
+ if (table && (0, _utils.isRowSelected)(rect.top)(selection)) {
94
+ return selectFullTable(editorSelectionAPI)({
95
+ node: table.node,
96
+ startPos: table.start,
97
+ dir: TableSelectionDirection.BottomToTop
98
+ })(state, dispatch);
99
+ }
100
+ if (table && rect) {
101
+ return (0, _misc.selectColumn)(rect.left)(state, dispatch);
102
+ }
103
+ return false;
104
+ };
105
+ };
106
+ };
107
+ var selectRows = exports.selectRows = function selectRows(editorSelectionAPI) {
108
+ return function () {
109
+ return function (state, dispatch) {
110
+ var selection = state.selection;
111
+ var table = (0, _utils.findTable)(selection);
112
+ var rect = (0, _utils.selectedRect)(state);
113
+ if (table && (0, _utils.isColumnSelected)(rect.left)(selection)) {
114
+ return selectFullTable(editorSelectionAPI)({
115
+ node: table.node,
116
+ startPos: table.start,
117
+ dir: TableSelectionDirection.BottomToTop
118
+ })(state, dispatch);
119
+ }
120
+ if (table && rect) {
121
+ return (0, _misc.selectRow)(rect.top)(state, dispatch);
122
+ }
123
+ return false;
124
+ };
125
+ };
126
+ };
86
127
  var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(editorSelectionAPI) {
87
128
  return function (selection) {
88
129
  return function (state, dispatch) {
@@ -13,6 +13,10 @@ function tableSelectionKeymapPlugin(editorSelectionAPI) {
13
13
  var list = {};
14
14
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.moveRight.common, (0, _selection.arrowRightFromTable)(editorSelectionAPI)(), list);
15
15
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.moveLeft.common, (0, _selection.arrowLeftFromTable)(editorSelectionAPI)(), list);
16
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y.table-selection_9uv33')) {
17
+ (0, _keymaps.bindKeymapArrayWithCommand)(_keymaps.selectColumn, (0, _selection.selectColumns)(editorSelectionAPI)(), list);
18
+ (0, _keymaps.bindKeymapArrayWithCommand)(_keymaps.selectRow, (0, _selection.selectRows)(editorSelectionAPI)(), list);
19
+ }
16
20
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.shift-arrowup-fix')) {
17
21
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.shiftArrowUp.common, (0, _selection.shiftArrowUpFromTable)(editorSelectionAPI)(), list);
18
22
  }
@@ -118,7 +118,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
118
118
  if (direction === 'row') {
119
119
  (0, _commands.insertRow)(index + offset, true)(state, dispatch);
120
120
  } else {
121
- (0, _commands.insertColumn)(getEditorContainerWidth)(index + offset)(state, dispatch);
121
+ (0, _commands.insertColumn)(getEditorContainerWidth)(index + offset)(state, dispatch, editorView);
122
122
  }
123
123
  return true;
124
124
  },
@@ -2,7 +2,8 @@ import { GapCursorSelection, isSelectionAtEndOfNode, isSelectionAtStartOfNode, R
2
2
  import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
4
  import { TableMap } from '@atlaskit/editor-tables/table-map';
5
- import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
5
+ import { findTable, isColumnSelected, isRowSelected, isTableSelected, selectedRect } from '@atlaskit/editor-tables/utils';
6
+ import { selectColumn, selectRow } from '../commands/misc';
6
7
  import { getClosestSelectionRect } from '../toolbar';
7
8
  export let TableSelectionDirection = /*#__PURE__*/function (TableSelectionDirection) {
8
9
  TableSelectionDirection["TopToBottom"] = "TopToBottom";
@@ -66,6 +67,42 @@ const arrowRightFromCellSelection = editorSelectionAPI => selection => (state, d
66
67
  }
67
68
  return false;
68
69
  };
70
+ export const selectColumns = editorSelectionAPI => () => (state, dispatch) => {
71
+ const {
72
+ selection
73
+ } = state;
74
+ const table = findTable(selection);
75
+ const rect = selectedRect(state);
76
+ if (table && isRowSelected(rect.top)(selection)) {
77
+ return selectFullTable(editorSelectionAPI)({
78
+ node: table.node,
79
+ startPos: table.start,
80
+ dir: TableSelectionDirection.BottomToTop
81
+ })(state, dispatch);
82
+ }
83
+ if (table && rect) {
84
+ return selectColumn(rect.left)(state, dispatch);
85
+ }
86
+ return false;
87
+ };
88
+ export const selectRows = editorSelectionAPI => () => (state, dispatch) => {
89
+ const {
90
+ selection
91
+ } = state;
92
+ const table = findTable(selection);
93
+ const rect = selectedRect(state);
94
+ if (table && isColumnSelected(rect.left)(selection)) {
95
+ return selectFullTable(editorSelectionAPI)({
96
+ node: table.node,
97
+ startPos: table.start,
98
+ dir: TableSelectionDirection.BottomToTop
99
+ })(state, dispatch);
100
+ }
101
+ if (table && rect) {
102
+ return selectRow(rect.top)(state, dispatch);
103
+ }
104
+ return false;
105
+ };
69
106
  const arrowLeftFromGapCursor = editorSelectionAPI => selection => (state, dispatch) => {
70
107
  const {
71
108
  doc
@@ -1,11 +1,15 @@
1
- import { bindKeymapWithCommand, moveLeft, moveRight, shiftArrowUp } from '@atlaskit/editor-common/keymaps';
1
+ import { bindKeymapArrayWithCommand, bindKeymapWithCommand, moveLeft, moveRight, selectColumn, selectRow, shiftArrowUp } from '@atlaskit/editor-common/keymaps';
2
2
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
3
3
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
- import { arrowLeftFromTable, arrowRightFromTable, shiftArrowUpFromTable } from '../commands/selection';
4
+ import { arrowLeftFromTable, arrowRightFromTable, selectColumns, selectRows, shiftArrowUpFromTable } from '../commands/selection';
5
5
  export function tableSelectionKeymapPlugin(editorSelectionAPI) {
6
6
  const list = {};
7
7
  bindKeymapWithCommand(moveRight.common, arrowRightFromTable(editorSelectionAPI)(), list);
8
8
  bindKeymapWithCommand(moveLeft.common, arrowLeftFromTable(editorSelectionAPI)(), list);
9
+ if (getBooleanFF('platform.editor.a11y.table-selection_9uv33')) {
10
+ bindKeymapArrayWithCommand(selectColumn, selectColumns(editorSelectionAPI)(), list);
11
+ bindKeymapArrayWithCommand(selectRow, selectRows(editorSelectionAPI)(), list);
12
+ }
9
13
  if (getBooleanFF('platform.editor.table.shift-arrowup-fix')) {
10
14
  bindKeymapWithCommand(shiftArrowUp.common, shiftArrowUpFromTable(editorSelectionAPI)(), list);
11
15
  }
@@ -100,7 +100,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
100
100
  if (direction === 'row') {
101
101
  insertRow(index + offset, true)(state, dispatch);
102
102
  } else {
103
- insertColumn(getEditorContainerWidth)(index + offset)(state, dispatch);
103
+ insertColumn(getEditorContainerWidth)(index + offset)(state, dispatch, editorView);
104
104
  }
105
105
  return true;
106
106
  },
@@ -2,7 +2,8 @@ import { GapCursorSelection, isSelectionAtEndOfNode, isSelectionAtStartOfNode, R
2
2
  import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
4
  import { TableMap } from '@atlaskit/editor-tables/table-map';
5
- import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
5
+ import { findTable, isColumnSelected, isRowSelected, isTableSelected, selectedRect } from '@atlaskit/editor-tables/utils';
6
+ import { selectColumn, selectRow } from '../commands/misc';
6
7
  import { getClosestSelectionRect } from '../toolbar';
7
8
  export var TableSelectionDirection = /*#__PURE__*/function (TableSelectionDirection) {
8
9
  TableSelectionDirection["TopToBottom"] = "TopToBottom";
@@ -77,6 +78,46 @@ var arrowRightFromCellSelection = function arrowRightFromCellSelection(editorSel
77
78
  };
78
79
  };
79
80
  };
81
+ export var selectColumns = function selectColumns(editorSelectionAPI) {
82
+ return function () {
83
+ return function (state, dispatch) {
84
+ var selection = state.selection;
85
+ var table = findTable(selection);
86
+ var rect = selectedRect(state);
87
+ if (table && isRowSelected(rect.top)(selection)) {
88
+ return selectFullTable(editorSelectionAPI)({
89
+ node: table.node,
90
+ startPos: table.start,
91
+ dir: TableSelectionDirection.BottomToTop
92
+ })(state, dispatch);
93
+ }
94
+ if (table && rect) {
95
+ return selectColumn(rect.left)(state, dispatch);
96
+ }
97
+ return false;
98
+ };
99
+ };
100
+ };
101
+ export var selectRows = function selectRows(editorSelectionAPI) {
102
+ return function () {
103
+ return function (state, dispatch) {
104
+ var selection = state.selection;
105
+ var table = findTable(selection);
106
+ var rect = selectedRect(state);
107
+ if (table && isColumnSelected(rect.left)(selection)) {
108
+ return selectFullTable(editorSelectionAPI)({
109
+ node: table.node,
110
+ startPos: table.start,
111
+ dir: TableSelectionDirection.BottomToTop
112
+ })(state, dispatch);
113
+ }
114
+ if (table && rect) {
115
+ return selectRow(rect.top)(state, dispatch);
116
+ }
117
+ return false;
118
+ };
119
+ };
120
+ };
80
121
  var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(editorSelectionAPI) {
81
122
  return function (selection) {
82
123
  return function (state, dispatch) {
@@ -1,11 +1,15 @@
1
- import { bindKeymapWithCommand, moveLeft, moveRight, shiftArrowUp } from '@atlaskit/editor-common/keymaps';
1
+ import { bindKeymapArrayWithCommand, bindKeymapWithCommand, moveLeft, moveRight, selectColumn, selectRow, shiftArrowUp } from '@atlaskit/editor-common/keymaps';
2
2
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
3
3
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
- import { arrowLeftFromTable, arrowRightFromTable, shiftArrowUpFromTable } from '../commands/selection';
4
+ import { arrowLeftFromTable, arrowRightFromTable, selectColumns, selectRows, shiftArrowUpFromTable } from '../commands/selection';
5
5
  export function tableSelectionKeymapPlugin(editorSelectionAPI) {
6
6
  var list = {};
7
7
  bindKeymapWithCommand(moveRight.common, arrowRightFromTable(editorSelectionAPI)(), list);
8
8
  bindKeymapWithCommand(moveLeft.common, arrowLeftFromTable(editorSelectionAPI)(), list);
9
+ if (getBooleanFF('platform.editor.a11y.table-selection_9uv33')) {
10
+ bindKeymapArrayWithCommand(selectColumn, selectColumns(editorSelectionAPI)(), list);
11
+ bindKeymapArrayWithCommand(selectRow, selectRows(editorSelectionAPI)(), list);
12
+ }
9
13
  if (getBooleanFF('platform.editor.table.shift-arrowup-fix')) {
10
14
  bindKeymapWithCommand(shiftArrowUp.common, shiftArrowUpFromTable(editorSelectionAPI)(), list);
11
15
  }
@@ -111,7 +111,7 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
111
111
  if (direction === 'row') {
112
112
  insertRow(index + offset, true)(state, dispatch);
113
113
  } else {
114
- insertColumn(getEditorContainerWidth)(index + offset)(state, dispatch);
114
+ insertColumn(getEditorContainerWidth)(index + offset)(state, dispatch, editorView);
115
115
  }
116
116
  return true;
117
117
  },
@@ -6,4 +6,6 @@ export declare enum TableSelectionDirection {
6
6
  }
7
7
  export declare const arrowLeftFromTable: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => () => Command;
8
8
  export declare const arrowRightFromTable: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => () => Command;
9
+ export declare const selectColumns: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => () => Command;
10
+ export declare const selectRows: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => () => Command;
9
11
  export declare const shiftArrowUpFromTable: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => () => Command;
@@ -6,4 +6,6 @@ export declare enum TableSelectionDirection {
6
6
  }
7
7
  export declare const arrowLeftFromTable: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => () => Command;
8
8
  export declare const arrowRightFromTable: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => () => Command;
9
+ export declare const selectColumns: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => () => Command;
10
+ export declare const selectRows: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => () => Command;
9
11
  export declare const shiftArrowUpFromTable: (editorSelectionAPI: ExtractInjectionAPI<typeof tablePlugin>['selection'] | undefined) => () => Command;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.6.3",
3
+ "version": "5.6.5",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -138,6 +138,9 @@
138
138
  },
139
139
  "platform.editor.a11y-table-resizing_uapcv": {
140
140
  "type": "boolean"
141
+ },
142
+ "platform.editor.a11y.table-selection_9uv33": {
143
+ "type": "boolean"
141
144
  }
142
145
  }
143
146
  }
@@ -17,8 +17,15 @@ import type {
17
17
  import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
18
18
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
19
19
  import { TableMap } from '@atlaskit/editor-tables/table-map';
20
- import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
21
-
20
+ import {
21
+ findTable,
22
+ isColumnSelected,
23
+ isRowSelected,
24
+ isTableSelected,
25
+ selectedRect,
26
+ } from '@atlaskit/editor-tables/utils';
27
+
28
+ import { selectColumn, selectRow } from '../commands/misc';
22
29
  import type tablePlugin from '../index';
23
30
  import { getClosestSelectionRect } from '../toolbar';
24
31
 
@@ -142,6 +149,54 @@ const arrowRightFromCellSelection =
142
149
  return false;
143
150
  };
144
151
 
152
+ export const selectColumns =
153
+ (
154
+ editorSelectionAPI:
155
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
156
+ | undefined,
157
+ ) =>
158
+ (): Command =>
159
+ (state, dispatch) => {
160
+ const { selection } = state;
161
+ const table = findTable(selection);
162
+ const rect = selectedRect(state);
163
+ if (table && isRowSelected(rect.top)(selection)) {
164
+ return selectFullTable(editorSelectionAPI)({
165
+ node: table.node,
166
+ startPos: table.start,
167
+ dir: TableSelectionDirection.BottomToTop,
168
+ })(state, dispatch);
169
+ }
170
+ if (table && rect) {
171
+ return selectColumn(rect.left)(state, dispatch);
172
+ }
173
+ return false;
174
+ };
175
+
176
+ export const selectRows =
177
+ (
178
+ editorSelectionAPI:
179
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
180
+ | undefined,
181
+ ) =>
182
+ (): Command =>
183
+ (state, dispatch) => {
184
+ const { selection } = state;
185
+ const table = findTable(selection);
186
+ const rect = selectedRect(state);
187
+ if (table && isColumnSelected(rect.left)(selection)) {
188
+ return selectFullTable(editorSelectionAPI)({
189
+ node: table.node,
190
+ startPos: table.start,
191
+ dir: TableSelectionDirection.BottomToTop,
192
+ })(state, dispatch);
193
+ }
194
+ if (table && rect) {
195
+ return selectRow(rect.top)(state, dispatch);
196
+ }
197
+ return false;
198
+ };
199
+
145
200
  const arrowLeftFromGapCursor =
146
201
  (
147
202
  editorSelectionAPI:
@@ -1,7 +1,10 @@
1
1
  import {
2
+ bindKeymapArrayWithCommand,
2
3
  bindKeymapWithCommand,
3
4
  moveLeft,
4
5
  moveRight,
6
+ selectColumn,
7
+ selectRow,
5
8
  shiftArrowUp,
6
9
  } from '@atlaskit/editor-common/keymaps';
7
10
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
@@ -12,6 +15,8 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
15
  import {
13
16
  arrowLeftFromTable,
14
17
  arrowRightFromTable,
18
+ selectColumns,
19
+ selectRows,
15
20
  shiftArrowUpFromTable,
16
21
  } from '../commands/selection';
17
22
  import type tablePlugin from '../index';
@@ -35,6 +40,20 @@ export function tableSelectionKeymapPlugin(
35
40
  list,
36
41
  );
37
42
 
43
+ if (getBooleanFF('platform.editor.a11y.table-selection_9uv33')) {
44
+ bindKeymapArrayWithCommand(
45
+ selectColumn,
46
+ selectColumns(editorSelectionAPI)(),
47
+ list,
48
+ );
49
+
50
+ bindKeymapArrayWithCommand(
51
+ selectRow,
52
+ selectRows(editorSelectionAPI)(),
53
+ list,
54
+ );
55
+ }
56
+
38
57
  if (getBooleanFF('platform.editor.table.shift-arrowup-fix')) {
39
58
  bindKeymapWithCommand(
40
59
  shiftArrowUp.common!,
@@ -173,6 +173,7 @@ export const getDragMenuConfig = (
173
173
  insertColumn(getEditorContainerWidth)(index! + offset)(
174
174
  state,
175
175
  dispatch,
176
+ editorView,
176
177
  );
177
178
  }
178
179
  return true;