@atlaskit/editor-plugin-tasks-and-decisions 0.2.13 → 0.2.15

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-tasks-and-decisions
2
2
 
3
+ ## 0.2.15
4
+
5
+ ### Patch Changes
6
+
7
+ - [#66823](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/66823) [`a190e988a6b1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a190e988a6b1) - [ux] ED-21614: Correctly create action list inside a listItem using keyboard shortcut '[] '
8
+ - Updated dependencies
9
+
10
+ ## 0.2.14
11
+
12
+ ### Patch Changes
13
+
14
+ - [#65802](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65802) [`438ead060875`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/438ead060875) - Ensure all editor plugins are marked as singletons
15
+
3
16
  ## 0.2.13
4
17
 
5
18
  ### Patch Changes
@@ -31,6 +31,19 @@ var createListRule = function createListRule(editorAnalyticsAPI) {
31
31
  });
32
32
  };
33
33
  };
34
+ var isCursorInsideList = function isCursorInsideList($pos) {
35
+ var _$pos$node;
36
+ return ((_$pos$node = $pos.node($pos.depth - 1)) === null || _$pos$node === void 0 ? void 0 : _$pos$node.type.name) === 'listItem';
37
+ };
38
+ var processShortcutForNestedTask = function processShortcutForNestedTask(content, $from, tr, list, item, listLocalId, itemLocalId, itemAttrs) {
39
+ //Extracting the content into the 'contentWithoutShortcut' from 'content' after removing the keyboard shortcut text, i.e., '[] '.
40
+ var contentWithoutShortcut = content.cut($from.pos - $from.start(), content.size);
41
+ tr.insert($from.after(), list.create({
42
+ localId: listLocalId
43
+ }, [item.create(_objectSpread({
44
+ localId: itemLocalId
45
+ }, itemAttrs), contentWithoutShortcut)])).setSelection(new _state.TextSelection(tr.doc.resolve($from.after()))).delete($from.start(), $from.end());
46
+ };
34
47
  var addItem = function addItem(start, end) {
35
48
  return function (_ref) {
36
49
  var tr = _ref.tr,
@@ -51,21 +64,25 @@ var addItem = function addItem(start, end) {
51
64
  }
52
65
  });
53
66
  if (!shouldBreakNode) {
67
+ if (isCursorInsideList($from)) {
68
+ processShortcutForNestedTask(content, $from, tr, list, item, listLocalId, itemLocalId, itemAttrs);
69
+ return tr;
70
+ }
54
71
  tr.replaceRangeWith($from.before(), $from.after(), list.create({
55
72
  localId: listLocalId
56
73
  }, [item.create(_objectSpread({
57
74
  localId: itemLocalId
58
75
  }, itemAttrs), content)])).delete(start + 1, end + 1).setSelection(new _state.TextSelection(tr.doc.resolve(start + 1)));
59
- } else {
60
- var depthAdjustment = (0, _commands.changeInDepth)($from, tr.selection.$from);
61
- tr.split($from.pos).setSelection(new _state.NodeSelection(tr.doc.resolve($from.pos + 1))).replaceSelectionWith(list.create({
62
- localId: listLocalId
63
- }, [item.create(_objectSpread({
64
- localId: itemLocalId
65
- }, itemAttrs),
66
- // TODO: [ts30] handle void and null properly
67
- tr.doc.nodeAt($from.pos + 1).content)])).setSelection(new _state.TextSelection(tr.doc.resolve($from.pos + depthAdjustment))).delete(start, end + 1);
76
+ return tr;
68
77
  }
78
+ var depthAdjustment = (0, _commands.changeInDepth)($from, tr.selection.$from);
79
+ tr.split($from.pos).setSelection(new _state.NodeSelection(tr.doc.resolve($from.pos + 1))).replaceSelectionWith(list.create({
80
+ localId: listLocalId
81
+ }, [item.create(_objectSpread({
82
+ localId: itemLocalId
83
+ }, itemAttrs),
84
+ // TODO: [ts30] handle void and null properly
85
+ tr.doc.nodeAt($from.pos + 1).content)])).setSelection(new _state.TextSelection(tr.doc.resolve($from.pos + depthAdjustment))).delete(start, end + 1);
69
86
  return tr;
70
87
  };
71
88
  };
@@ -22,6 +22,20 @@ const createListRule = editorAnalyticsAPI => (regex, listType, itemAttrs) => {
22
22
  return insertTr;
23
23
  });
24
24
  };
25
+ const isCursorInsideList = $pos => {
26
+ var _$pos$node;
27
+ return ((_$pos$node = $pos.node($pos.depth - 1)) === null || _$pos$node === void 0 ? void 0 : _$pos$node.type.name) === 'listItem';
28
+ };
29
+ const processShortcutForNestedTask = (content, $from, tr, list, item, listLocalId, itemLocalId, itemAttrs) => {
30
+ //Extracting the content into the 'contentWithoutShortcut' from 'content' after removing the keyboard shortcut text, i.e., '[] '.
31
+ const contentWithoutShortcut = content.cut($from.pos - $from.start(), content.size);
32
+ tr.insert($from.after(), list.create({
33
+ localId: listLocalId
34
+ }, [item.create({
35
+ localId: itemLocalId,
36
+ ...itemAttrs
37
+ }, contentWithoutShortcut)])).setSelection(new TextSelection(tr.doc.resolve($from.after()))).delete($from.start(), $from.end());
38
+ };
25
39
  const addItem = (start, end) => ({
26
40
  tr,
27
41
  state,
@@ -48,23 +62,27 @@ const addItem = (start, end) => ({
48
62
  }
49
63
  });
50
64
  if (!shouldBreakNode) {
65
+ if (isCursorInsideList($from)) {
66
+ processShortcutForNestedTask(content, $from, tr, list, item, listLocalId, itemLocalId, itemAttrs);
67
+ return tr;
68
+ }
51
69
  tr.replaceRangeWith($from.before(), $from.after(), list.create({
52
70
  localId: listLocalId
53
71
  }, [item.create({
54
72
  localId: itemLocalId,
55
73
  ...itemAttrs
56
74
  }, content)])).delete(start + 1, end + 1).setSelection(new TextSelection(tr.doc.resolve(start + 1)));
57
- } else {
58
- const depthAdjustment = changeInDepth($from, tr.selection.$from);
59
- tr.split($from.pos).setSelection(new NodeSelection(tr.doc.resolve($from.pos + 1))).replaceSelectionWith(list.create({
60
- localId: listLocalId
61
- }, [item.create({
62
- localId: itemLocalId,
63
- ...itemAttrs
64
- },
65
- // TODO: [ts30] handle void and null properly
66
- tr.doc.nodeAt($from.pos + 1).content)])).setSelection(new TextSelection(tr.doc.resolve($from.pos + depthAdjustment))).delete(start, end + 1);
75
+ return tr;
67
76
  }
77
+ const depthAdjustment = changeInDepth($from, tr.selection.$from);
78
+ tr.split($from.pos).setSelection(new NodeSelection(tr.doc.resolve($from.pos + 1))).replaceSelectionWith(list.create({
79
+ localId: listLocalId
80
+ }, [item.create({
81
+ localId: itemLocalId,
82
+ ...itemAttrs
83
+ },
84
+ // TODO: [ts30] handle void and null properly
85
+ tr.doc.nodeAt($from.pos + 1).content)])).setSelection(new TextSelection(tr.doc.resolve($from.pos + depthAdjustment))).delete(start, end + 1);
68
86
  return tr;
69
87
  };
70
88
  export const inputRulePlugin = editorAnalyticsAPI => (schema, featureFlags) => {
@@ -24,6 +24,19 @@ var createListRule = function createListRule(editorAnalyticsAPI) {
24
24
  });
25
25
  };
26
26
  };
27
+ var isCursorInsideList = function isCursorInsideList($pos) {
28
+ var _$pos$node;
29
+ return ((_$pos$node = $pos.node($pos.depth - 1)) === null || _$pos$node === void 0 ? void 0 : _$pos$node.type.name) === 'listItem';
30
+ };
31
+ var processShortcutForNestedTask = function processShortcutForNestedTask(content, $from, tr, list, item, listLocalId, itemLocalId, itemAttrs) {
32
+ //Extracting the content into the 'contentWithoutShortcut' from 'content' after removing the keyboard shortcut text, i.e., '[] '.
33
+ var contentWithoutShortcut = content.cut($from.pos - $from.start(), content.size);
34
+ tr.insert($from.after(), list.create({
35
+ localId: listLocalId
36
+ }, [item.create(_objectSpread({
37
+ localId: itemLocalId
38
+ }, itemAttrs), contentWithoutShortcut)])).setSelection(new TextSelection(tr.doc.resolve($from.after()))).delete($from.start(), $from.end());
39
+ };
27
40
  var addItem = function addItem(start, end) {
28
41
  return function (_ref) {
29
42
  var tr = _ref.tr,
@@ -44,21 +57,25 @@ var addItem = function addItem(start, end) {
44
57
  }
45
58
  });
46
59
  if (!shouldBreakNode) {
60
+ if (isCursorInsideList($from)) {
61
+ processShortcutForNestedTask(content, $from, tr, list, item, listLocalId, itemLocalId, itemAttrs);
62
+ return tr;
63
+ }
47
64
  tr.replaceRangeWith($from.before(), $from.after(), list.create({
48
65
  localId: listLocalId
49
66
  }, [item.create(_objectSpread({
50
67
  localId: itemLocalId
51
68
  }, itemAttrs), content)])).delete(start + 1, end + 1).setSelection(new TextSelection(tr.doc.resolve(start + 1)));
52
- } else {
53
- var depthAdjustment = changeInDepth($from, tr.selection.$from);
54
- tr.split($from.pos).setSelection(new NodeSelection(tr.doc.resolve($from.pos + 1))).replaceSelectionWith(list.create({
55
- localId: listLocalId
56
- }, [item.create(_objectSpread({
57
- localId: itemLocalId
58
- }, itemAttrs),
59
- // TODO: [ts30] handle void and null properly
60
- tr.doc.nodeAt($from.pos + 1).content)])).setSelection(new TextSelection(tr.doc.resolve($from.pos + depthAdjustment))).delete(start, end + 1);
69
+ return tr;
61
70
  }
71
+ var depthAdjustment = changeInDepth($from, tr.selection.$from);
72
+ tr.split($from.pos).setSelection(new NodeSelection(tr.doc.resolve($from.pos + 1))).replaceSelectionWith(list.create({
73
+ localId: listLocalId
74
+ }, [item.create(_objectSpread({
75
+ localId: itemLocalId
76
+ }, itemAttrs),
77
+ // TODO: [ts30] handle void and null properly
78
+ tr.doc.nodeAt($from.pos + 1).content)])).setSelection(new TextSelection(tr.doc.resolve($from.pos + depthAdjustment))).delete(start, end + 1);
62
79
  return tr;
63
80
  };
64
81
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "Tasks and decisions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -9,11 +9,12 @@
9
9
  },
10
10
  "atlassian": {
11
11
  "team": "Editor: AI",
12
+ "singleton": true,
12
13
  "inPublicMirror": false,
13
14
  "releaseModel": "continuous",
14
15
  "runReact18": false
15
16
  },
16
- "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
17
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
17
18
  "main": "dist/cjs/index.js",
18
19
  "module": "dist/esm/index.js",
19
20
  "module:es2019": "dist/es2019/index.js",
@@ -33,9 +34,9 @@
33
34
  },
34
35
  "dependencies": {
35
36
  "@atlaskit/adf-schema": "^35.3.0",
36
- "@atlaskit/analytics-namespaced-context": "^6.7.0",
37
+ "@atlaskit/analytics-namespaced-context": "^6.9.0",
37
38
  "@atlaskit/analytics-next": "^9.1.0",
38
- "@atlaskit/editor-common": "^76.35.0",
39
+ "@atlaskit/editor-common": "^76.41.0",
39
40
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
40
41
  "@atlaskit/editor-plugin-type-ahead": "^0.9.0",
41
42
  "@atlaskit/editor-prosemirror": "1.1.0",
@@ -52,11 +53,12 @@
52
53
  "devDependencies": {
53
54
  "@af/integration-testing": "*",
54
55
  "@af/visual-regression": "*",
56
+ "@atlaskit/platform-feature-flags": "^0.2.5",
55
57
  "@atlaskit/ssr": "*",
56
58
  "@atlaskit/util-data-test": "^17.8.0",
57
59
  "@atlaskit/visual-regression": "*",
58
- "@atlaskit/webdriver-runner": "*",
59
60
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
61
+ "@atlassian/feature-flags-test-utils": "^0.1.1",
60
62
  "@testing-library/react": "^12.1.5",
61
63
  "react-dom": "^16.8.0",
62
64
  "typescript": "~4.9.5",
@@ -97,5 +99,10 @@
97
99
  ]
98
100
  }
99
101
  },
100
- "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
102
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
103
+ "platform-feature-flags": {
104
+ "platform.editor.allow-action-in-list": {
105
+ "type": "boolean"
106
+ }
107
+ }
101
108
  }