@atlaskit/editor-plugin-table 18.1.22 → 18.1.24

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,20 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 18.1.24
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 18.1.23
10
+
11
+ ### Patch Changes
12
+
13
+ - [`bd6a75f50c1e9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bd6a75f50c1e9) -
14
+ [ux] [EDITOR-6267] add support to SelectAll table keymap to first select the active table cell
15
+ behind experiment `platform_editor_lovability_select_all_shortcut`
16
+ - Updated dependencies
17
+
3
18
  ## 18.1.22
4
19
 
5
20
  ### Patch Changes
@@ -10,6 +10,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
10
10
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
11
11
  var _tableMap = require("@atlaskit/editor-tables/table-map");
12
12
  var _utils = require("@atlaskit/editor-tables/utils");
13
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
14
  var _toolbar = require("../../ui/toolbar");
14
15
  var _pluginFactory = require("../plugin-factory");
15
16
  var _misc = require("./misc");
@@ -272,6 +273,21 @@ var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
272
273
  };
273
274
  };
274
275
 
276
+ /**
277
+ * sets a cell selection over the table cell in which the selection is inside of
278
+ */
279
+ var selectTableCell = function selectTableCell(state, dispatch) {
280
+ var $cell = (0, _utils.cellAround)(state.selection.$from);
281
+ if (!$cell) {
282
+ return false;
283
+ }
284
+ if (dispatch) {
285
+ dispatch(state.tr.setSelection(new _cellSelection.CellSelection($cell)));
286
+ return true;
287
+ }
288
+ return false;
289
+ };
290
+
275
291
  /**
276
292
  * Sets a cell selection over all the cells in the table node
277
293
  * We use this instead of selectTable from prosemirror-utils so we can control which
@@ -451,7 +467,14 @@ var modASelectTable = exports.modASelectTable = function modASelectTable(editorS
451
467
  var $from = selection.$from,
452
468
  $to = selection.$to;
453
469
  var tableSelected = (0, _utils.isTableSelected)(selection);
454
- if (!tableSelected && $from.pos > table.start + 1 && $to.pos < table.start + table.node.nodeSize) {
470
+ var isCellSelection = selection instanceof _cellSelection.CellSelection;
471
+
472
+ // if no cells are selected
473
+ if (!isCellSelection && (0, _expValEquals.expValEquals)('platform_editor_lovability_select_all_shortcut', 'isEnabled', true)) {
474
+ return selectTableCell(state, dispatch);
475
+ }
476
+ // else if any number of cells are selected but not the full table
477
+ else if (!tableSelected && $from.pos > table.start + 1 && $to.pos < table.start + table.node.nodeSize) {
455
478
  return selectFullTable(editorSelectionAPI)({
456
479
  node: table.node,
457
480
  startPos: table.start,
@@ -3,7 +3,8 @@ import { GapCursorSelection, isSelectionAtEndOfNode, isSelectionAtStartOfNode, R
3
3
  import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
5
5
  import { TableMap } from '@atlaskit/editor-tables/table-map';
6
- import { findTable, isColumnSelected, isRowSelected, isTableSelected, selectedRect } from '@atlaskit/editor-tables/utils';
6
+ import { cellAround, findTable, isColumnSelected, isRowSelected, isTableSelected, selectedRect } from '@atlaskit/editor-tables/utils';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
8
  import { getClosestSelectionRect } from '../../ui/toolbar';
8
9
  import { getPluginState } from '../plugin-factory';
9
10
  import { selectColumn, selectRow } from './misc';
@@ -243,6 +244,21 @@ const arrowRightFromText = editorSelectionAPI => selection => (state, dispatch)
243
244
  return false;
244
245
  };
245
246
 
247
+ /**
248
+ * sets a cell selection over the table cell in which the selection is inside of
249
+ */
250
+ const selectTableCell = (state, dispatch) => {
251
+ const $cell = cellAround(state.selection.$from);
252
+ if (!$cell) {
253
+ return false;
254
+ }
255
+ if (dispatch) {
256
+ dispatch(state.tr.setSelection(new CellSelection($cell)));
257
+ return true;
258
+ }
259
+ return false;
260
+ };
261
+
246
262
  /**
247
263
  * Sets a cell selection over all the cells in the table node
248
264
  * We use this instead of selectTable from prosemirror-utils so we can control which
@@ -410,7 +426,14 @@ export const modASelectTable = editorSelectionAPI => () => (state, dispatch) =>
410
426
  $to
411
427
  } = selection;
412
428
  const tableSelected = isTableSelected(selection);
413
- if (!tableSelected && $from.pos > table.start + 1 && $to.pos < table.start + table.node.nodeSize) {
429
+ const isCellSelection = selection instanceof CellSelection;
430
+
431
+ // if no cells are selected
432
+ if (!isCellSelection && expValEquals('platform_editor_lovability_select_all_shortcut', 'isEnabled', true)) {
433
+ return selectTableCell(state, dispatch);
434
+ }
435
+ // else if any number of cells are selected but not the full table
436
+ else if (!tableSelected && $from.pos > table.start + 1 && $to.pos < table.start + table.node.nodeSize) {
414
437
  return selectFullTable(editorSelectionAPI)({
415
438
  node: table.node,
416
439
  startPos: table.start,
@@ -3,7 +3,8 @@ import { GapCursorSelection, isSelectionAtEndOfNode, isSelectionAtStartOfNode, R
3
3
  import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
5
5
  import { TableMap } from '@atlaskit/editor-tables/table-map';
6
- import { findTable, isColumnSelected, isRowSelected, isTableSelected, selectedRect } from '@atlaskit/editor-tables/utils';
6
+ import { cellAround, findTable, isColumnSelected, isRowSelected, isTableSelected, selectedRect } from '@atlaskit/editor-tables/utils';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
8
  import { getClosestSelectionRect } from '../../ui/toolbar';
8
9
  import { getPluginState } from '../plugin-factory';
9
10
  import { selectColumn, selectRow } from './misc';
@@ -266,6 +267,21 @@ var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
266
267
  };
267
268
  };
268
269
 
270
+ /**
271
+ * sets a cell selection over the table cell in which the selection is inside of
272
+ */
273
+ var selectTableCell = function selectTableCell(state, dispatch) {
274
+ var $cell = cellAround(state.selection.$from);
275
+ if (!$cell) {
276
+ return false;
277
+ }
278
+ if (dispatch) {
279
+ dispatch(state.tr.setSelection(new CellSelection($cell)));
280
+ return true;
281
+ }
282
+ return false;
283
+ };
284
+
269
285
  /**
270
286
  * Sets a cell selection over all the cells in the table node
271
287
  * We use this instead of selectTable from prosemirror-utils so we can control which
@@ -445,7 +461,14 @@ export var modASelectTable = function modASelectTable(editorSelectionAPI) {
445
461
  var $from = selection.$from,
446
462
  $to = selection.$to;
447
463
  var tableSelected = isTableSelected(selection);
448
- if (!tableSelected && $from.pos > table.start + 1 && $to.pos < table.start + table.node.nodeSize) {
464
+ var isCellSelection = selection instanceof CellSelection;
465
+
466
+ // if no cells are selected
467
+ if (!isCellSelection && expValEquals('platform_editor_lovability_select_all_shortcut', 'isEnabled', true)) {
468
+ return selectTableCell(state, dispatch);
469
+ }
470
+ // else if any number of cells are selected but not the full table
471
+ else if (!tableSelected && $from.pos > table.start + 1 && $to.pos < table.start + table.node.nodeSize) {
449
472
  return selectFullTable(editorSelectionAPI)({
450
473
  node: table.node,
451
474
  startPos: table.start,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "18.1.22",
3
+ "version": "18.1.24",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^52.4.0",
32
- "@atlaskit/button": "^23.10.0",
32
+ "@atlaskit/button": "^23.11.0",
33
33
  "@atlaskit/custom-steps": "^0.16.0",
34
34
  "@atlaskit/editor-palette": "^2.1.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^8.0.0",
@@ -37,7 +37,7 @@
37
37
  "@atlaskit/editor-plugin-batch-attribute-updates": "^8.0.0",
38
38
  "@atlaskit/editor-plugin-content-insertion": "^8.0.0",
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^10.0.0",
40
- "@atlaskit/editor-plugin-extension": "11.0.24",
40
+ "@atlaskit/editor-plugin-extension": "11.0.25",
41
41
  "@atlaskit/editor-plugin-guideline": "^8.0.0",
42
42
  "@atlaskit/editor-plugin-interaction": "^15.0.0",
43
43
  "@atlaskit/editor-plugin-limited-mode": "^5.0.0",
@@ -56,8 +56,8 @@
56
56
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
57
57
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
58
58
  "@atlaskit/primitives": "^18.1.0",
59
- "@atlaskit/tmp-editor-statsig": "^54.0.0",
60
- "@atlaskit/toggle": "^15.2.0",
59
+ "@atlaskit/tmp-editor-statsig": "^55.0.0",
60
+ "@atlaskit/toggle": "^15.3.0",
61
61
  "@atlaskit/tokens": "^11.4.0",
62
62
  "@atlaskit/tooltip": "^21.1.0",
63
63
  "@babel/runtime": "^7.0.0",
@@ -69,7 +69,7 @@
69
69
  "uuid": "^3.1.0"
70
70
  },
71
71
  "peerDependencies": {
72
- "@atlaskit/editor-common": "^112.16.0",
72
+ "@atlaskit/editor-common": "^112.18.0",
73
73
  "react": "^18.2.0",
74
74
  "react-dom": "^18.2.0",
75
75
  "react-intl-next": "npm:react-intl@^5.18.1"