@atlaskit/editor-plugin-list 17.0.1 → 17.0.2

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,12 @@
1
1
  # @atlaskit/editor-plugin-list
2
2
 
3
+ ## 17.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`86f1891483b7f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/86f1891483b7f) -
8
+ Prevent list deletion commands from skipping synced blocks behind platform_editor_blocks_patch_7.
9
+
3
10
  ## 17.0.1
4
11
 
5
12
  ### Patch Changes
@@ -15,6 +15,7 @@ var _utils = require("@atlaskit/editor-common/utils");
15
15
  var _commands2 = require("@atlaskit/editor-prosemirror/commands");
16
16
  var _model = require("@atlaskit/editor-prosemirror/model");
17
17
  var _state = require("@atlaskit/editor-prosemirror/state");
18
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
18
19
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
19
20
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
20
21
  var _conversions = require("../actions/conversions");
@@ -59,6 +60,17 @@ var enterKeyCommand = exports.enterKeyCommand = function enterKeyCommand(editorA
59
60
  var backspaceKeyCommand = exports.backspaceKeyCommand = function backspaceKeyCommand(editorAnalyticsAPI) {
60
61
  return function () {
61
62
  return function (state, dispatch) {
63
+ // Select an adjacent syncBlock before the list command chain can outdent the current list.
64
+ if ((0, _utils.isEmptySelectionAtStart)(state) && (0, _fg.fg)('platform_editor_blocks_patch_7')) {
65
+ var _$cut$nodeBefore;
66
+ var $cut = (0, _commands.findCutBefore)(state.selection.$from);
67
+ if (($cut === null || $cut === void 0 || (_$cut$nodeBefore = $cut.nodeBefore) === null || _$cut$nodeBefore === void 0 ? void 0 : _$cut$nodeBefore.type.name) === 'syncBlock') {
68
+ if (dispatch) {
69
+ dispatch(state.tr.setSelection(_state.NodeSelection.create(state.doc, $cut.pos - $cut.nodeBefore.nodeSize)).scrollIntoView());
70
+ }
71
+ return true;
72
+ }
73
+ }
62
74
  return (0, _commands2.chainCommands)((0, _listBackspace.listBackspace)(editorAnalyticsAPI),
63
75
  // if we're at the start of a list item, we need to either backspace
64
76
  // directly to an empty list item above, or outdent this node
@@ -8,7 +8,9 @@ exports.joinListItemForward = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _utils = require("@atlaskit/editor-common/utils");
11
+ var _state = require("@atlaskit/editor-prosemirror/state");
11
12
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
13
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
12
14
  var _joinListItemsForward = require("../actions/join-list-items-forward");
13
15
  var joinListItemForward = exports.joinListItemForward = function joinListItemForward(editorAnalyticsAPI) {
14
16
  return function (state, dispatch) {
@@ -18,6 +20,23 @@ var joinListItemForward = exports.joinListItemForward = function joinListItemFor
18
20
  if (!(0, _utils.isEmptySelectionAtEnd)(state)) {
19
21
  return false;
20
22
  }
23
+ if ((0, _fg.fg)('platform_editor_blocks_patch_7')) {
24
+ var interveningSyncBlockPos;
25
+ // walkNextNode can skip leaf nodes because they have no resolvable content position.
26
+ state.doc.nodesBetween($head.pos, walkNode.$pos.pos, function (node, pos) {
27
+ if (interveningSyncBlockPos === undefined && node.type.name === 'syncBlock') {
28
+ interveningSyncBlockPos = pos;
29
+ }
30
+ return interveningSyncBlockPos === undefined;
31
+ });
32
+ if (interveningSyncBlockPos !== undefined) {
33
+ if (dispatch) {
34
+ var selection = _state.NodeSelection.create(state.doc, interveningSyncBlockPos);
35
+ dispatch(tr.setSelection(selection).scrollIntoView());
36
+ }
37
+ return true;
38
+ }
39
+ }
21
40
  var scenarios = (0, _joinListItemsForward.calcJoinListScenario)(walkNode, $head);
22
41
  if (!scenarios) {
23
42
  return false;
@@ -7,6 +7,7 @@ import { filterCommand as filter, hasVisibleContent, isEmptySelectionAtStart } f
7
7
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
8
8
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
9
9
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
10
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
10
11
  import { findParentNodeOfTypeClosestToPos, findPositionOfNodeBefore, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
11
12
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
13
  import { convertListType } from '../actions/conversions';
@@ -48,6 +49,17 @@ export const enterKeyCommand = editorAnalyticsAPI => () => (state, dispatch) =>
48
49
  return false;
49
50
  };
50
51
  export const backspaceKeyCommand = editorAnalyticsAPI => () => (state, dispatch) => {
52
+ // Select an adjacent syncBlock before the list command chain can outdent the current list.
53
+ if (isEmptySelectionAtStart(state) && fg('platform_editor_blocks_patch_7')) {
54
+ var _$cut$nodeBefore;
55
+ const $cut = findCutBefore(state.selection.$from);
56
+ if (($cut === null || $cut === void 0 ? void 0 : (_$cut$nodeBefore = $cut.nodeBefore) === null || _$cut$nodeBefore === void 0 ? void 0 : _$cut$nodeBefore.type.name) === 'syncBlock') {
57
+ if (dispatch) {
58
+ dispatch(state.tr.setSelection(NodeSelection.create(state.doc, $cut.pos - $cut.nodeBefore.nodeSize)).scrollIntoView());
59
+ }
60
+ return true;
61
+ }
62
+ }
51
63
  return chainCommands(listBackspace(editorAnalyticsAPI),
52
64
  // if we're at the start of a list item, we need to either backspace
53
65
  // directly to an empty list item above, or outdent this node
@@ -1,6 +1,8 @@
1
1
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, DELETE_DIRECTION, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { isEmptySelectionAtEnd, walkNextNode } from '@atlaskit/editor-common/utils';
3
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
4
6
  import { calcJoinListScenario } from '../actions/join-list-items-forward';
5
7
  export const joinListItemForward = editorAnalyticsAPI => (state, dispatch) => {
6
8
  const {
@@ -13,6 +15,23 @@ export const joinListItemForward = editorAnalyticsAPI => (state, dispatch) => {
13
15
  if (!isEmptySelectionAtEnd(state)) {
14
16
  return false;
15
17
  }
18
+ if (fg('platform_editor_blocks_patch_7')) {
19
+ let interveningSyncBlockPos;
20
+ // walkNextNode can skip leaf nodes because they have no resolvable content position.
21
+ state.doc.nodesBetween($head.pos, walkNode.$pos.pos, (node, pos) => {
22
+ if (interveningSyncBlockPos === undefined && node.type.name === 'syncBlock') {
23
+ interveningSyncBlockPos = pos;
24
+ }
25
+ return interveningSyncBlockPos === undefined;
26
+ });
27
+ if (interveningSyncBlockPos !== undefined) {
28
+ if (dispatch) {
29
+ const selection = NodeSelection.create(state.doc, interveningSyncBlockPos);
30
+ dispatch(tr.setSelection(selection).scrollIntoView());
31
+ }
32
+ return true;
33
+ }
34
+ }
16
35
  const scenarios = calcJoinListScenario(walkNode, $head);
17
36
  if (!scenarios) {
18
37
  return false;
@@ -10,6 +10,7 @@ import { filterCommand as filter, hasVisibleContent, isEmptySelectionAtStart } f
10
10
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
11
11
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
12
12
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
13
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
13
14
  import { findParentNodeOfTypeClosestToPos, findPositionOfNodeBefore, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
14
15
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
15
16
  import { convertListType } from '../actions/conversions';
@@ -52,6 +53,17 @@ export var enterKeyCommand = function enterKeyCommand(editorAnalyticsAPI) {
52
53
  export var backspaceKeyCommand = function backspaceKeyCommand(editorAnalyticsAPI) {
53
54
  return function () {
54
55
  return function (state, dispatch) {
56
+ // Select an adjacent syncBlock before the list command chain can outdent the current list.
57
+ if (isEmptySelectionAtStart(state) && fg('platform_editor_blocks_patch_7')) {
58
+ var _$cut$nodeBefore;
59
+ var $cut = findCutBefore(state.selection.$from);
60
+ if (($cut === null || $cut === void 0 || (_$cut$nodeBefore = $cut.nodeBefore) === null || _$cut$nodeBefore === void 0 ? void 0 : _$cut$nodeBefore.type.name) === 'syncBlock') {
61
+ if (dispatch) {
62
+ dispatch(state.tr.setSelection(NodeSelection.create(state.doc, $cut.pos - $cut.nodeBefore.nodeSize)).scrollIntoView());
63
+ }
64
+ return true;
65
+ }
66
+ }
55
67
  return chainCommands(listBackspace(editorAnalyticsAPI),
56
68
  // if we're at the start of a list item, we need to either backspace
57
69
  // directly to an empty list item above, or outdent this node
@@ -1,7 +1,9 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, DELETE_DIRECTION, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { isEmptySelectionAtEnd, walkNextNode } from '@atlaskit/editor-common/utils';
4
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
5
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
5
7
  import { calcJoinListScenario } from '../actions/join-list-items-forward';
6
8
  export var joinListItemForward = function joinListItemForward(editorAnalyticsAPI) {
7
9
  return function (state, dispatch) {
@@ -11,6 +13,23 @@ export var joinListItemForward = function joinListItemForward(editorAnalyticsAPI
11
13
  if (!isEmptySelectionAtEnd(state)) {
12
14
  return false;
13
15
  }
16
+ if (fg('platform_editor_blocks_patch_7')) {
17
+ var interveningSyncBlockPos;
18
+ // walkNextNode can skip leaf nodes because they have no resolvable content position.
19
+ state.doc.nodesBetween($head.pos, walkNode.$pos.pos, function (node, pos) {
20
+ if (interveningSyncBlockPos === undefined && node.type.name === 'syncBlock') {
21
+ interveningSyncBlockPos = pos;
22
+ }
23
+ return interveningSyncBlockPos === undefined;
24
+ });
25
+ if (interveningSyncBlockPos !== undefined) {
26
+ if (dispatch) {
27
+ var selection = NodeSelection.create(state.doc, interveningSyncBlockPos);
28
+ dispatch(tr.setSelection(selection).scrollIntoView());
29
+ }
30
+ return true;
31
+ }
32
+ }
14
33
  var scenarios = calcJoinListScenario(walkNode, $head);
15
34
  if (!scenarios) {
16
35
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-list",
3
- "version": "17.0.1",
3
+ "version": "17.0.2",
4
4
  "description": "List plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -27,7 +27,7 @@
27
27
  "@atlaskit/editor-plugin-ui-control-registry": "^9.0.0",
28
28
  "@atlaskit/editor-prosemirror": "^8.0.0",
29
29
  "@atlaskit/editor-toolbar": "^2.4.0",
30
- "@atlaskit/editor-ui-control-model": "^2.6.0",
30
+ "@atlaskit/editor-ui-control-model": "^2.7.0",
31
31
  "@atlaskit/icon": "^37.3.0",
32
32
  "@atlaskit/platform-feature-experiments": "^0.3.0",
33
33
  "@atlaskit/platform-feature-flags": "^2.1.0",
@@ -82,6 +82,10 @@
82
82
  },
83
83
  "platform_editor_flexible_list_normalization_fix": {
84
84
  "type": "boolean"
85
+ },
86
+ "platform_editor_blocks_patch_7": {
87
+ "type": "boolean",
88
+ "referenceOnly": true
85
89
  }
86
90
  },
87
91
  "devDependencies": {