@atlaskit/editor-plugin-list 1.3.7 → 1.4.0

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,31 @@
1
1
  # @atlaskit/editor-plugin-list
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#56675](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/56675) [`772ad8f687be`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/772ad8f687be) - [ux] [ED-20249] If `platform.editor.ordered-list-auto-join-improvements_mrlv5`` is enabled only auto-join lists together if the order numbers match up.
8
+
9
+ Eg.
10
+
11
+ 1. A list item
12
+
13
+ -
14
+
15
+ 50. Another list item
16
+
17
+ Should NOT auto join to be 1 & 2 in a single list however...
18
+
19
+ 49. A list item
20
+
21
+ -
22
+
23
+ 50. Another list item
24
+
25
+ Should join to be 49 & 50 in a single list.
26
+
27
+ This also only applies when the `restartNumberedLists` feature flag is enabled.
28
+
3
29
  ## 1.3.7
4
30
 
5
31
  ### Patch Changes
@@ -7,6 +7,7 @@ exports.createWrappingJoinRule = void 0;
7
7
  var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _transform = require("@atlaskit/editor-prosemirror/transform");
9
9
  var _utils = require("@atlaskit/editor-prosemirror/utils");
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
11
  var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
11
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
13
 
@@ -35,12 +36,24 @@ var createWrappingJoinRule = exports.createWrappingJoinRule = function createWra
35
36
  tr.setNodeMarkup(parentNodePosMapped, parentNode.type, parentNode.attrs, allowedMarks);
36
37
  }
37
38
  tr.wrap(range, wrapping);
39
+
40
+ // if an orderedList node would be inserted by the input rule match, and
41
+ // that orderedList node is being added directly after another orderedList
38
42
  if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && nodeType === state.schema.nodes.orderedList) {
39
- // if an orderedList node would be inserted by the input rule match, and
40
- // that orderedList node is being added directly before another orderedList
41
- // node, then join those nodes
42
43
  var $end = tr.doc.resolve(tr.mapping.map(end));
43
44
  var _node = (0, _utils.findParentNodeOfTypeClosestToPos)($end, nodeType);
45
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.ordered-list-auto-join-improvements_mrlv5')) {
46
+ // if there's a list before & the new list has an order property that does
47
+ // not match to follow the last number on the first list then do NOT merge the lists
48
+ var nodeBeforeSelection = tr.doc.resolve(parentNodePosMapped).nodeBefore;
49
+ var nextExpectedNumberAfterListBefore = (nodeBeforeSelection === null || nodeBeforeSelection === void 0 ? void 0 : nodeBeforeSelection.type.name) === 'orderedList' ? (nodeBeforeSelection === null || nodeBeforeSelection === void 0 ? void 0 : nodeBeforeSelection.attrs.order) + (nodeBeforeSelection === null || nodeBeforeSelection === void 0 ? void 0 : nodeBeforeSelection.childCount) : undefined;
50
+ var listBeforeDoesNotMatchWithNewList = nodeBeforeSelection && typeof attrs.order === 'number' && nextExpectedNumberAfterListBefore && attrs.order !== nextExpectedNumberAfterListBefore;
51
+ if (nodeBeforeSelection && listBeforeDoesNotMatchWithNewList) {
52
+ return tr;
53
+ }
54
+ }
55
+
56
+ // otherwise join the lists
44
57
  if (_node) {
45
58
  var nodeEnd = _node.pos + _node.node.nodeSize;
46
59
  var after = tr.doc.resolve(nodeEnd).nodeAfter;
@@ -1,6 +1,7 @@
1
1
  import { JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST } from '@atlaskit/editor-common/analytics';
2
2
  import { canJoin, findWrapping } from '@atlaskit/editor-prosemirror/transform';
3
3
  import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
4
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
5
  import { createRule } from '@atlaskit/prosemirror-input-rules';
5
6
 
6
7
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -31,12 +32,24 @@ export const createWrappingJoinRule = ({
31
32
  tr.setNodeMarkup(parentNodePosMapped, parentNode.type, parentNode.attrs, allowedMarks);
32
33
  }
33
34
  tr.wrap(range, wrapping);
35
+
36
+ // if an orderedList node would be inserted by the input rule match, and
37
+ // that orderedList node is being added directly after another orderedList
34
38
  if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && nodeType === state.schema.nodes.orderedList) {
35
- // if an orderedList node would be inserted by the input rule match, and
36
- // that orderedList node is being added directly before another orderedList
37
- // node, then join those nodes
38
39
  const $end = tr.doc.resolve(tr.mapping.map(end));
39
40
  const node = findParentNodeOfTypeClosestToPos($end, nodeType);
41
+ if (getBooleanFF('platform.editor.ordered-list-auto-join-improvements_mrlv5')) {
42
+ // if there's a list before & the new list has an order property that does
43
+ // not match to follow the last number on the first list then do NOT merge the lists
44
+ const nodeBeforeSelection = tr.doc.resolve(parentNodePosMapped).nodeBefore;
45
+ const nextExpectedNumberAfterListBefore = (nodeBeforeSelection === null || nodeBeforeSelection === void 0 ? void 0 : nodeBeforeSelection.type.name) === 'orderedList' ? (nodeBeforeSelection === null || nodeBeforeSelection === void 0 ? void 0 : nodeBeforeSelection.attrs.order) + (nodeBeforeSelection === null || nodeBeforeSelection === void 0 ? void 0 : nodeBeforeSelection.childCount) : undefined;
46
+ const listBeforeDoesNotMatchWithNewList = nodeBeforeSelection && typeof attrs.order === 'number' && nextExpectedNumberAfterListBefore && attrs.order !== nextExpectedNumberAfterListBefore;
47
+ if (nodeBeforeSelection && listBeforeDoesNotMatchWithNewList) {
48
+ return tr;
49
+ }
50
+ }
51
+
52
+ // otherwise join the lists
40
53
  if (node) {
41
54
  const nodeEnd = node.pos + node.node.nodeSize;
42
55
  const after = tr.doc.resolve(nodeEnd).nodeAfter;
@@ -1,6 +1,7 @@
1
1
  import { JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST } from '@atlaskit/editor-common/analytics';
2
2
  import { canJoin, findWrapping } from '@atlaskit/editor-prosemirror/transform';
3
3
  import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
4
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
5
  import { createRule } from '@atlaskit/prosemirror-input-rules';
5
6
 
6
7
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -30,12 +31,24 @@ export var createWrappingJoinRule = function createWrappingJoinRule(_ref) {
30
31
  tr.setNodeMarkup(parentNodePosMapped, parentNode.type, parentNode.attrs, allowedMarks);
31
32
  }
32
33
  tr.wrap(range, wrapping);
34
+
35
+ // if an orderedList node would be inserted by the input rule match, and
36
+ // that orderedList node is being added directly after another orderedList
33
37
  if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && nodeType === state.schema.nodes.orderedList) {
34
- // if an orderedList node would be inserted by the input rule match, and
35
- // that orderedList node is being added directly before another orderedList
36
- // node, then join those nodes
37
38
  var $end = tr.doc.resolve(tr.mapping.map(end));
38
39
  var _node = findParentNodeOfTypeClosestToPos($end, nodeType);
40
+ if (getBooleanFF('platform.editor.ordered-list-auto-join-improvements_mrlv5')) {
41
+ // if there's a list before & the new list has an order property that does
42
+ // not match to follow the last number on the first list then do NOT merge the lists
43
+ var nodeBeforeSelection = tr.doc.resolve(parentNodePosMapped).nodeBefore;
44
+ var nextExpectedNumberAfterListBefore = (nodeBeforeSelection === null || nodeBeforeSelection === void 0 ? void 0 : nodeBeforeSelection.type.name) === 'orderedList' ? (nodeBeforeSelection === null || nodeBeforeSelection === void 0 ? void 0 : nodeBeforeSelection.attrs.order) + (nodeBeforeSelection === null || nodeBeforeSelection === void 0 ? void 0 : nodeBeforeSelection.childCount) : undefined;
45
+ var listBeforeDoesNotMatchWithNewList = nodeBeforeSelection && typeof attrs.order === 'number' && nextExpectedNumberAfterListBefore && attrs.order !== nextExpectedNumberAfterListBefore;
46
+ if (nodeBeforeSelection && listBeforeDoesNotMatchWithNewList) {
47
+ return tr;
48
+ }
49
+ }
50
+
51
+ // otherwise join the lists
39
52
  if (_node) {
40
53
  var nodeEnd = _node.pos + _node.node.nodeSize;
41
54
  var after = tr.doc.resolve(nodeEnd).nodeAfter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-list",
3
- "version": "1.3.7",
3
+ "version": "1.4.0",
4
4
  "description": "List plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,10 +32,11 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^34.0.1",
35
- "@atlaskit/editor-common": "^76.23.0",
35
+ "@atlaskit/editor-common": "^76.24.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^0.3.0",
37
37
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",
38
38
  "@atlaskit/editor-prosemirror": "1.1.0",
39
+ "@atlaskit/platform-feature-flags": "^0.2.0",
39
40
  "@atlaskit/prosemirror-input-rules": "^2.4.0",
40
41
  "@babel/runtime": "^7.0.0"
41
42
  },
@@ -86,5 +87,10 @@
86
87
  ]
87
88
  }
88
89
  },
89
- "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
90
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
91
+ "platform-feature-flags": {
92
+ "platform.editor.ordered-list-auto-join-improvements_mrlv5": {
93
+ "type": "boolean"
94
+ }
95
+ }
90
96
  }