@atlaskit/editor-plugin-list 17.0.0 → 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,18 @@
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
+
10
+ ## 17.0.1
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
3
16
  ## 17.0.0
4
17
 
5
18
  ### Patch Changes
@@ -137,7 +137,6 @@ var convertAroundList = function convertAroundList(_ref3) {
137
137
  nextListNodeType = _ref3.nextListNodeType,
138
138
  nodeRange = _ref3.nodeRange;
139
139
  for (var i = nodeRange.endIndex - 1; i >= nodeRange.startIndex; i--) {
140
- // @ts-ignore posAtIndex is a public API but has no type yet
141
140
  var position = nodeRange.$from.posAtIndex(i, nodeRange.depth);
142
141
  var resolvedPos = tr.doc.resolve(position + 1);
143
142
  var range = resolvedPos.blockRange(resolvedPos);
@@ -36,7 +36,6 @@ var indentListItemsSelected = exports.indentListItemsSelected = function indentL
36
36
  }
37
37
  var resolvedPos = tr.doc.resolve(listItemsSelected.from.pos);
38
38
  var listItemIndex = resolvedPos.index();
39
- // @ts-ignore
40
39
  var positionListItemPosition = resolvedPos.posAtIndex(listItemIndex - 1);
41
40
  var currentListItemPosition = resolvedPos.posAtIndex(listItemIndex);
42
41
  var previousListItem = tr.doc.nodeAt(positionListItemPosition);
@@ -46,9 +46,7 @@ function wrapInList(listType, attrs) {
46
46
  return false;
47
47
  }
48
48
  // This is at the top of an existing list item
49
- if (range.depth >= 2 &&
50
- // @ts-ignore - missing type for compatibleContent
51
- $from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex === 0) {
49
+ if (range.depth >= 2 && $from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex === 0) {
52
50
  // Don't do anything if this is the top of the list
53
51
  if ($from.index(range.depth - 1) === 0) {
54
52
  return false;
@@ -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;
@@ -144,7 +144,6 @@ const convertAroundList = ({
144
144
  nodeRange
145
145
  }) => {
146
146
  for (let i = nodeRange.endIndex - 1; i >= nodeRange.startIndex; i--) {
147
- // @ts-ignore posAtIndex is a public API but has no type yet
148
147
  const position = nodeRange.$from.posAtIndex(i, nodeRange.depth);
149
148
  const resolvedPos = tr.doc.resolve(position + 1);
150
149
  const range = resolvedPos.blockRange(resolvedPos);
@@ -30,7 +30,6 @@ export const indentListItemsSelected = tr => {
30
30
  }
31
31
  const resolvedPos = tr.doc.resolve(listItemsSelected.from.pos);
32
32
  const listItemIndex = resolvedPos.index();
33
- // @ts-ignore
34
33
  const positionListItemPosition = resolvedPos.posAtIndex(listItemIndex - 1);
35
34
  const currentListItemPosition = resolvedPos.posAtIndex(listItemIndex);
36
35
  const previousListItem = tr.doc.nodeAt(positionListItemPosition);
@@ -39,9 +39,7 @@ export function wrapInList(listType, attrs) {
39
39
  return false;
40
40
  }
41
41
  // This is at the top of an existing list item
42
- if (range.depth >= 2 &&
43
- // @ts-ignore - missing type for compatibleContent
44
- $from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex === 0) {
42
+ if (range.depth >= 2 && $from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex === 0) {
45
43
  // Don't do anything if this is the top of the list
46
44
  if ($from.index(range.depth - 1) === 0) {
47
45
  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;
@@ -131,7 +131,6 @@ var convertAroundList = function convertAroundList(_ref3) {
131
131
  nextListNodeType = _ref3.nextListNodeType,
132
132
  nodeRange = _ref3.nodeRange;
133
133
  for (var i = nodeRange.endIndex - 1; i >= nodeRange.startIndex; i--) {
134
- // @ts-ignore posAtIndex is a public API but has no type yet
135
134
  var position = nodeRange.$from.posAtIndex(i, nodeRange.depth);
136
135
  var resolvedPos = tr.doc.resolve(position + 1);
137
136
  var range = resolvedPos.blockRange(resolvedPos);
@@ -29,7 +29,6 @@ export var indentListItemsSelected = function indentListItemsSelected(tr) {
29
29
  }
30
30
  var resolvedPos = tr.doc.resolve(listItemsSelected.from.pos);
31
31
  var listItemIndex = resolvedPos.index();
32
- // @ts-ignore
33
32
  var positionListItemPosition = resolvedPos.posAtIndex(listItemIndex - 1);
34
33
  var currentListItemPosition = resolvedPos.posAtIndex(listItemIndex);
35
34
  var previousListItem = tr.doc.nodeAt(positionListItemPosition);
@@ -40,9 +40,7 @@ export function wrapInList(listType, attrs) {
40
40
  return false;
41
41
  }
42
42
  // This is at the top of an existing list item
43
- if (range.depth >= 2 &&
44
- // @ts-ignore - missing type for compatibleContent
45
- $from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex === 0) {
43
+ if (range.depth >= 2 && $from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex === 0) {
46
44
  // Don't do anything if this is the top of the list
47
45
  if ($from.index(range.depth - 1) === 0) {
48
46
  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.0",
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",
@@ -19,7 +19,7 @@
19
19
  "sideEffects": false,
20
20
  "atlaskit:src": "src/index.ts",
21
21
  "dependencies": {
22
- "@atlaskit/adf-schema": "^56.7.0",
22
+ "@atlaskit/adf-schema": "^57.0.0",
23
23
  "@atlaskit/editor-plugin-analytics": "^15.0.0",
24
24
  "@atlaskit/editor-plugin-block-menu": "^14.0.0",
25
25
  "@atlaskit/editor-plugin-feature-flags": "^14.0.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",
@@ -37,7 +37,7 @@
37
37
  "@babel/runtime": "^7.0.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "@atlaskit/editor-common": "^119.0.0",
40
+ "@atlaskit/editor-common": "^119.4.0",
41
41
  "react": "^18.2.0 || ^19.2.0",
42
42
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
43
43
  },
@@ -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": {