@atlaskit/editor-plugin-tasks-and-decisions 15.2.5 → 15.2.6

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,14 @@
1
1
  # @atlaskit/editor-plugin-tasks-and-decisions
2
2
 
3
+ ## 15.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`3c4994f354f5f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3c4994f354f5f) -
8
+ [ux] Fix content order being corrupted when indenting or outdenting a list item that has content
9
+ placed between its sub-lists (e.g. `li(p, ul, p, ul)`).
10
+ - Updated dependencies
11
+
3
12
  ## 15.2.5
4
13
 
5
14
  ### Patch Changes
@@ -7,16 +7,79 @@ exports.flattenTaskList = flattenTaskList;
7
7
  exports.rebuildTaskList = rebuildTaskList;
8
8
  var _adfSchema = require("@atlaskit/adf-schema");
9
9
  var _lists = require("@atlaskit/editor-common/lists");
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
11
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
11
12
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
13
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
+ /**
15
+ * Flattens a taskList into one item per task item, recording which items the
16
+ * selection touches.
17
+ */
18
+ function flattenTaskListImpl(options) {
19
+ var doc = options.doc,
20
+ rootListStart = options.rootListStart,
21
+ rootListEnd = options.rootListEnd,
22
+ selectionFrom = options.selectionFrom,
23
+ selectionTo = options.selectionTo,
24
+ indentDelta = options.indentDelta,
25
+ maxDepth = options.maxDepth;
26
+ var _doc$type$schema$node = doc.type.schema.nodes,
27
+ taskList = _doc$type$schema$node.taskList,
28
+ taskItem = _doc$type$schema$node.taskItem,
29
+ blockTaskItem = _doc$type$schema$node.blockTaskItem;
30
+ var items = [];
31
+ var startIndex = -1;
32
+ var endIndex = -1;
33
+ var exceedsMaxDepth = false;
34
+ var rootDepth = doc.resolve(rootListStart).depth;
35
+ var isPointSelection = selectionFrom === selectionTo;
36
+ doc.nodesBetween(rootListStart, rootListEnd, function (node, pos, parent) {
37
+ var isTaskItemType = node.type === taskItem || blockTaskItem != null && node.type === blockTaskItem;
38
+ if (!isTaskItemType || parent == null || parent.type !== taskList) {
39
+ return true;
40
+ }
41
+ var start = pos;
42
+ var end = pos + node.nodeSize;
43
+ var isSelected = isPointSelection ? selectionFrom >= start && selectionFrom <= end : start < selectionTo && end > selectionFrom;
44
+ var depth = doc.resolve(pos).depth - rootDepth - 1 + (isSelected ? indentDelta : 0);
45
+ items.push({
46
+ node: node,
47
+ pos: pos,
48
+ depth: depth,
49
+ isSelected: isSelected,
50
+ listType: parent.type.name,
51
+ parentListAttrs: parent.attrs
52
+ });
53
+ if (isSelected) {
54
+ var index = items.length - 1;
55
+ if (startIndex === -1) {
56
+ startIndex = index;
57
+ }
58
+ endIndex = index;
59
+ if (maxDepth != null && depth >= maxDepth) {
60
+ exceedsMaxDepth = true;
61
+ }
62
+ }
63
+ return true;
64
+ });
65
+ if (items.length === 0 || startIndex === -1 || exceedsMaxDepth) {
66
+ return null;
67
+ }
68
+ return {
69
+ items: items,
70
+ startIndex: startIndex,
71
+ endIndex: endIndex
72
+ };
73
+ }
74
+
13
75
  /**
14
76
  * Flattens a taskList tree into an array of task items with computed depths.
15
77
  * Only selected items have their depth adjusted by indentDelta.
16
- *
17
- * Delegates to the shared `flattenList` with task-list-specific callbacks.
18
78
  */
19
79
  function flattenTaskList(options) {
80
+ if ((0, _platformFeatureFlags.fg)('platform_editor_flexible_list_normalization_fix')) {
81
+ return flattenTaskListImpl(options);
82
+ }
20
83
  var _options$doc$type$sch = options.doc.type.schema.nodes,
21
84
  taskList = _options$doc$type$sch.taskList,
22
85
  taskItem = _options$doc$type$sch.taskItem,
@@ -1,12 +1,79 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
2
  import { flattenList as flattenListBase } from '@atlaskit/editor-common/lists';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
4
+
5
+ /**
6
+ * Flattens a taskList into one item per task item, recording which items the
7
+ * selection touches.
8
+ */
9
+ function flattenTaskListImpl(options) {
10
+ const {
11
+ doc,
12
+ rootListStart,
13
+ rootListEnd,
14
+ selectionFrom,
15
+ selectionTo,
16
+ indentDelta,
17
+ maxDepth
18
+ } = options;
19
+ const {
20
+ taskList,
21
+ taskItem,
22
+ blockTaskItem
23
+ } = doc.type.schema.nodes;
24
+ const items = [];
25
+ let startIndex = -1;
26
+ let endIndex = -1;
27
+ let exceedsMaxDepth = false;
28
+ const rootDepth = doc.resolve(rootListStart).depth;
29
+ const isPointSelection = selectionFrom === selectionTo;
30
+ doc.nodesBetween(rootListStart, rootListEnd, (node, pos, parent) => {
31
+ const isTaskItemType = node.type === taskItem || blockTaskItem != null && node.type === blockTaskItem;
32
+ if (!isTaskItemType || parent == null || parent.type !== taskList) {
33
+ return true;
34
+ }
35
+ const start = pos;
36
+ const end = pos + node.nodeSize;
37
+ const isSelected = isPointSelection ? selectionFrom >= start && selectionFrom <= end : start < selectionTo && end > selectionFrom;
38
+ const depth = doc.resolve(pos).depth - rootDepth - 1 + (isSelected ? indentDelta : 0);
39
+ items.push({
40
+ node,
41
+ pos,
42
+ depth,
43
+ isSelected,
44
+ listType: parent.type.name,
45
+ parentListAttrs: parent.attrs
46
+ });
47
+ if (isSelected) {
48
+ const index = items.length - 1;
49
+ if (startIndex === -1) {
50
+ startIndex = index;
51
+ }
52
+ endIndex = index;
53
+ if (maxDepth != null && depth >= maxDepth) {
54
+ exceedsMaxDepth = true;
55
+ }
56
+ }
57
+ return true;
58
+ });
59
+ if (items.length === 0 || startIndex === -1 || exceedsMaxDepth) {
60
+ return null;
61
+ }
62
+ return {
63
+ items,
64
+ startIndex,
65
+ endIndex
66
+ };
67
+ }
68
+
3
69
  /**
4
70
  * Flattens a taskList tree into an array of task items with computed depths.
5
71
  * Only selected items have their depth adjusted by indentDelta.
6
- *
7
- * Delegates to the shared `flattenList` with task-list-specific callbacks.
8
72
  */
9
73
  export function flattenTaskList(options) {
74
+ if (fg('platform_editor_flexible_list_normalization_fix')) {
75
+ return flattenTaskListImpl(options);
76
+ }
10
77
  const {
11
78
  taskList,
12
79
  taskItem,
@@ -3,13 +3,77 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
3
3
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4
4
  import { uuid } from '@atlaskit/adf-schema';
5
5
  import { flattenList as flattenListBase } from '@atlaskit/editor-common/lists';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
7
+
8
+ /**
9
+ * Flattens a taskList into one item per task item, recording which items the
10
+ * selection touches.
11
+ */
12
+ function flattenTaskListImpl(options) {
13
+ var doc = options.doc,
14
+ rootListStart = options.rootListStart,
15
+ rootListEnd = options.rootListEnd,
16
+ selectionFrom = options.selectionFrom,
17
+ selectionTo = options.selectionTo,
18
+ indentDelta = options.indentDelta,
19
+ maxDepth = options.maxDepth;
20
+ var _doc$type$schema$node = doc.type.schema.nodes,
21
+ taskList = _doc$type$schema$node.taskList,
22
+ taskItem = _doc$type$schema$node.taskItem,
23
+ blockTaskItem = _doc$type$schema$node.blockTaskItem;
24
+ var items = [];
25
+ var startIndex = -1;
26
+ var endIndex = -1;
27
+ var exceedsMaxDepth = false;
28
+ var rootDepth = doc.resolve(rootListStart).depth;
29
+ var isPointSelection = selectionFrom === selectionTo;
30
+ doc.nodesBetween(rootListStart, rootListEnd, function (node, pos, parent) {
31
+ var isTaskItemType = node.type === taskItem || blockTaskItem != null && node.type === blockTaskItem;
32
+ if (!isTaskItemType || parent == null || parent.type !== taskList) {
33
+ return true;
34
+ }
35
+ var start = pos;
36
+ var end = pos + node.nodeSize;
37
+ var isSelected = isPointSelection ? selectionFrom >= start && selectionFrom <= end : start < selectionTo && end > selectionFrom;
38
+ var depth = doc.resolve(pos).depth - rootDepth - 1 + (isSelected ? indentDelta : 0);
39
+ items.push({
40
+ node: node,
41
+ pos: pos,
42
+ depth: depth,
43
+ isSelected: isSelected,
44
+ listType: parent.type.name,
45
+ parentListAttrs: parent.attrs
46
+ });
47
+ if (isSelected) {
48
+ var index = items.length - 1;
49
+ if (startIndex === -1) {
50
+ startIndex = index;
51
+ }
52
+ endIndex = index;
53
+ if (maxDepth != null && depth >= maxDepth) {
54
+ exceedsMaxDepth = true;
55
+ }
56
+ }
57
+ return true;
58
+ });
59
+ if (items.length === 0 || startIndex === -1 || exceedsMaxDepth) {
60
+ return null;
61
+ }
62
+ return {
63
+ items: items,
64
+ startIndex: startIndex,
65
+ endIndex: endIndex
66
+ };
67
+ }
68
+
6
69
  /**
7
70
  * Flattens a taskList tree into an array of task items with computed depths.
8
71
  * Only selected items have their depth adjusted by indentDelta.
9
- *
10
- * Delegates to the shared `flattenList` with task-list-specific callbacks.
11
72
  */
12
73
  export function flattenTaskList(options) {
74
+ if (fg('platform_editor_flexible_list_normalization_fix')) {
75
+ return flattenTaskListImpl(options);
76
+ }
13
77
  var _options$doc$type$sch = options.doc.type.schema.nodes,
14
78
  taskList = _options$doc$type$sch.taskList,
15
79
  taskItem = _options$doc$type$sch.taskItem,
@@ -3,8 +3,6 @@ import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model'
3
3
  /**
4
4
  * Flattens a taskList tree into an array of task items with computed depths.
5
5
  * Only selected items have their depth adjusted by indentDelta.
6
- *
7
- * Delegates to the shared `flattenList` with task-list-specific callbacks.
8
6
  */
9
7
  export declare function flattenTaskList(options: FlattenListOptions): FlattenListResult | null;
10
8
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "15.2.5",
3
+ "version": "15.2.6",
4
4
  "description": "Tasks and decisions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -41,14 +41,14 @@
41
41
  "@atlaskit/primitives": "^22.0.0",
42
42
  "@atlaskit/prosemirror-input-rules": "^4.0.0",
43
43
  "@atlaskit/task-decision": "^21.4.0",
44
- "@atlaskit/tmp-editor-statsig": "^126.2.0",
44
+ "@atlaskit/tmp-editor-statsig": "^127.0.0",
45
45
  "@atlaskit/tokens": "^16.0.0",
46
46
  "@babel/runtime": "^7.0.0",
47
47
  "@compiled/react": "^0.20.0",
48
48
  "bind-event-listener": "^3.0.0"
49
49
  },
50
50
  "peerDependencies": {
51
- "@atlaskit/editor-common": "^116.32.0",
51
+ "@atlaskit/editor-common": "^116.33.0",
52
52
  "react": "^18.2.0",
53
53
  "react-dom": "^18.2.0",
54
54
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -100,6 +100,9 @@
100
100
  "platform_editor_element_browser_analytic": {
101
101
  "type": "boolean"
102
102
  },
103
+ "platform_editor_flexible_list_normalization_fix": {
104
+ "type": "boolean"
105
+ },
103
106
  "platform_editor_markdown_compatible_toolbar": {
104
107
  "type": "boolean"
105
108
  }