@atlaskit/editor-plugin-tasks-and-decisions 7.0.2 → 7.0.4

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,20 @@
1
1
  # @atlaskit/editor-plugin-tasks-and-decisions
2
2
 
3
+ ## 7.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`cfa24f42cfba3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cfa24f42cfba3) -
8
+ [EDITOR-1433] Backspace unindents blockTaskItems
9
+
10
+ ## 7.0.3
11
+
12
+ ### Patch Changes
13
+
14
+ - [`255837cfba315`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/255837cfba315) -
15
+ Internal changes to how border radius is applied.
16
+ - Updated dependencies
17
+
3
18
  ## 7.0.2
4
19
 
5
20
  ### Patch Changes
@@ -74,22 +74,57 @@ var isTable = exports.isTable = function isTable(node) {
74
74
  */
75
75
  var getBlockRange = exports.getBlockRange = function getBlockRange(_ref) {
76
76
  var $from = _ref.$from,
77
- $to = _ref.$to,
78
- _ref$isLifting = _ref.isLifting,
79
- isLifting = _ref$isLifting === void 0 ? false : _ref$isLifting;
77
+ $to = _ref.$to;
80
78
  var _$from$doc$type$schem = $from.doc.type.schema.nodes,
81
79
  taskList = _$from$doc$type$schem.taskList,
82
- blockTaskItem = _$from$doc$type$schem.blockTaskItem;
80
+ taskItem = _$from$doc$type$schem.taskItem,
81
+ blockTaskItem = _$from$doc$type$schem.blockTaskItem,
82
+ paragraph = _$from$doc$type$schem.paragraph;
83
83
  var blockTaskItemNode = (0, _utils.findFarthestParentNode)(function (node) {
84
84
  return node.type === blockTaskItem;
85
85
  })($from);
86
86
  if (blockTaskItem && blockTaskItemNode) {
87
- var startOfNodeInBlockTaskItem = $from.doc.resolve(blockTaskItemNode.start);
87
+ var _$prevNode$nodeBefore;
88
+ var startOfBlockRange = blockTaskItemNode.start - 1;
89
+ var endNode = $to.end();
90
+ var _$after = $to.doc.resolve(endNode + 1);
91
+ var _after = _$after.nodeAfter;
88
92
  var lastNode = $to.node($to.depth);
89
- var endOfNodeInBlockTaskItem = $from.doc.resolve($to.start() + lastNode.nodeSize - 1);
90
- return new _model.NodeRange(startOfNodeInBlockTaskItem, endOfNodeInBlockTaskItem,
91
- // When lifting we want to ignore the potential depth of nested nodes so reduce the depth
92
- isLifting ? blockTaskItemNode.depth - 2 : blockTaskItemNode.depth - 1);
93
+ var rangeDepth = blockTaskItemNode.depth - 1;
94
+ var endOfBlockRange = $to.start() + lastNode.nodeSize;
95
+
96
+ // If the lastNode is a paragraph need to resolve a little bit further to get the node after the block task item
97
+ if (lastNode.type === paragraph) {
98
+ _$after = $to.doc.resolve(endNode + 2);
99
+ _after = _$after.nodeAfter;
100
+ }
101
+ // Otherwise assume it's a block node so increase the range depth
102
+ else {
103
+ rangeDepth = rangeDepth - 1;
104
+ endOfBlockRange = endOfBlockRange - 1;
105
+ }
106
+
107
+ // If the after node is a sibling taskList of the blockTaskItem, then extend the range
108
+ if (_after && _after.type === taskList && _$after.depth === blockTaskItemNode.depth - 1) {
109
+ endOfBlockRange = endOfBlockRange + _after.nodeSize;
110
+ }
111
+
112
+ // Is after another taskItem/ blockTaskItem
113
+ var $prevNode = $from.doc.resolve(startOfBlockRange - 1);
114
+ var prevNodeSize = (_$prevNode$nodeBefore = $prevNode.nodeBefore) === null || _$prevNode$nodeBefore === void 0 ? void 0 : _$prevNode$nodeBefore.nodeSize;
115
+ var $prevNodeParent = $from.doc.resolve($prevNode.pos - (prevNodeSize || 0) - 1);
116
+ var prevNodeParent = $prevNodeParent.nodeAfter;
117
+
118
+ // If after another taskItem/ blockTaskItem
119
+ if (prevNodeParent && [blockTaskItem, taskItem].includes(prevNodeParent.type)) {
120
+ rangeDepth = blockTaskItemNode.depth - 1;
121
+ endOfBlockRange = endOfBlockRange - 2;
122
+ startOfBlockRange = startOfBlockRange + 1;
123
+ }
124
+ var $endOfBlockRange = $to.doc.resolve(endOfBlockRange);
125
+ var $startOfBlockRange = $to.doc.resolve(startOfBlockRange);
126
+ var nodeRange = new _model.NodeRange($startOfBlockRange, $endOfBlockRange, rangeDepth);
127
+ return nodeRange;
93
128
  }
94
129
  var end = $to.end();
95
130
  var $after = $to.doc.resolve(end + 1);
@@ -247,8 +282,7 @@ var isEmptyTaskDecision = exports.isEmptyTaskDecision = function isEmptyTaskDeci
247
282
  var liftBlock = exports.liftBlock = function liftBlock(tr, $from, $to) {
248
283
  var blockRange = getBlockRange({
249
284
  $from: $from,
250
- $to: $to,
251
- isLifting: true
285
+ $to: $to
252
286
  });
253
287
  if (!blockRange) {
254
288
  return null;
@@ -1,6 +1,6 @@
1
1
 
2
- ._2rko1sit{border-radius:var(--ds-border-radius,3px)}
3
2
  ._2rko1ssb{border-radius:50%}
3
+ ._2rkofajl{border-radius:var(--ds-radius-small,3px)}
4
4
  ._zulp1b66{gap:var(--ds-space-050,4px)}._16qs1cd0{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #091e4226,0 0 1px #091e424f)}
5
5
  ._18u0u2gc{margin-left:var(--ds-space-100,8px)}
6
6
  ._19bv1ejb{padding-left:var(--ds-space-300,24px)}
@@ -160,7 +160,7 @@ var RequestToEditPopup = exports.RequestToEditPopup = function RequestToEditPopu
160
160
  }, /*#__PURE__*/React.createElement(_uiReact.OutsideClickTargetRefContext.Consumer, null, function (setOutsideClickTargetRef) {
161
161
  return /*#__PURE__*/React.createElement("div", {
162
162
  ref: setOutsideClickTargetRef,
163
- className: (0, _runtime.ax)(["_2rko1sit _ca0qv77o _n3tdv77o _19bvv77o _u5f3v77o _16qs1cd0 _bfhk1bhr"])
163
+ className: (0, _runtime.ax)(["_2rkofajl _ca0qv77o _n3tdv77o _19bvv77o _u5f3v77o _16qs1cd0 _bfhk1bhr"])
164
164
  }, /*#__PURE__*/React.createElement("div", {
165
165
  className: (0, _runtime.ax)(["_1e0c1txw _2lx21bp4 _p12f1qwj _ca0qpxbi _u5f31ejb _n3tdpxbi _19bv1ejb"])
166
166
  }, /*#__PURE__*/React.createElement(_compiled.Stack, {
@@ -63,21 +63,57 @@ export const isTable = node => {
63
63
  */
64
64
  export const getBlockRange = ({
65
65
  $from,
66
- $to,
67
- isLifting = false
66
+ $to
68
67
  }) => {
69
68
  const {
70
69
  taskList,
71
- blockTaskItem
70
+ taskItem,
71
+ blockTaskItem,
72
+ paragraph
72
73
  } = $from.doc.type.schema.nodes;
73
74
  const blockTaskItemNode = findFarthestParentNode(node => node.type === blockTaskItem)($from);
74
75
  if (blockTaskItem && blockTaskItemNode) {
75
- const startOfNodeInBlockTaskItem = $from.doc.resolve(blockTaskItemNode.start);
76
+ var _$prevNode$nodeBefore;
77
+ let startOfBlockRange = blockTaskItemNode.start - 1;
78
+ const endNode = $to.end();
79
+ let $after = $to.doc.resolve(endNode + 1);
80
+ let after = $after.nodeAfter;
76
81
  const lastNode = $to.node($to.depth);
77
- const endOfNodeInBlockTaskItem = $from.doc.resolve($to.start() + lastNode.nodeSize - 1);
78
- return new NodeRange(startOfNodeInBlockTaskItem, endOfNodeInBlockTaskItem,
79
- // When lifting we want to ignore the potential depth of nested nodes so reduce the depth
80
- isLifting ? blockTaskItemNode.depth - 2 : blockTaskItemNode.depth - 1);
82
+ let rangeDepth = blockTaskItemNode.depth - 1;
83
+ let endOfBlockRange = $to.start() + lastNode.nodeSize;
84
+
85
+ // If the lastNode is a paragraph need to resolve a little bit further to get the node after the block task item
86
+ if (lastNode.type === paragraph) {
87
+ $after = $to.doc.resolve(endNode + 2);
88
+ after = $after.nodeAfter;
89
+ }
90
+ // Otherwise assume it's a block node so increase the range depth
91
+ else {
92
+ rangeDepth = rangeDepth - 1;
93
+ endOfBlockRange = endOfBlockRange - 1;
94
+ }
95
+
96
+ // If the after node is a sibling taskList of the blockTaskItem, then extend the range
97
+ if (after && after.type === taskList && $after.depth === blockTaskItemNode.depth - 1) {
98
+ endOfBlockRange = endOfBlockRange + after.nodeSize;
99
+ }
100
+
101
+ // Is after another taskItem/ blockTaskItem
102
+ const $prevNode = $from.doc.resolve(startOfBlockRange - 1);
103
+ const prevNodeSize = (_$prevNode$nodeBefore = $prevNode.nodeBefore) === null || _$prevNode$nodeBefore === void 0 ? void 0 : _$prevNode$nodeBefore.nodeSize;
104
+ const $prevNodeParent = $from.doc.resolve($prevNode.pos - (prevNodeSize || 0) - 1);
105
+ const prevNodeParent = $prevNodeParent.nodeAfter;
106
+
107
+ // If after another taskItem/ blockTaskItem
108
+ if (prevNodeParent && [blockTaskItem, taskItem].includes(prevNodeParent.type)) {
109
+ rangeDepth = blockTaskItemNode.depth - 1;
110
+ endOfBlockRange = endOfBlockRange - 2;
111
+ startOfBlockRange = startOfBlockRange + 1;
112
+ }
113
+ const $endOfBlockRange = $to.doc.resolve(endOfBlockRange);
114
+ const $startOfBlockRange = $to.doc.resolve(startOfBlockRange);
115
+ const nodeRange = new NodeRange($startOfBlockRange, $endOfBlockRange, rangeDepth);
116
+ return nodeRange;
81
117
  }
82
118
  let end = $to.end();
83
119
  const $after = $to.doc.resolve(end + 1);
@@ -234,8 +270,7 @@ export const isEmptyTaskDecision = state => {
234
270
  export const liftBlock = (tr, $from, $to) => {
235
271
  const blockRange = getBlockRange({
236
272
  $from,
237
- $to,
238
- isLifting: true
273
+ $to
239
274
  });
240
275
  if (!blockRange) {
241
276
  return null;
@@ -1,6 +1,6 @@
1
1
 
2
- ._2rko1sit{border-radius:var(--ds-border-radius,3px)}
3
2
  ._2rko1ssb{border-radius:50%}
3
+ ._2rkofajl{border-radius:var(--ds-radius-small,3px)}
4
4
  ._zulp1b66{gap:var(--ds-space-050,4px)}._16qs1cd0{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #091e4226,0 0 1px #091e424f)}
5
5
  ._18u0u2gc{margin-left:var(--ds-space-100,8px)}
6
6
  ._19bv1ejb{padding-left:var(--ds-space-300,24px)}
@@ -145,7 +145,7 @@ export const RequestToEditPopup = ({
145
145
  captureClick: true
146
146
  }, /*#__PURE__*/React.createElement(OutsideClickTargetRefContext.Consumer, null, setOutsideClickTargetRef => /*#__PURE__*/React.createElement("div", {
147
147
  ref: setOutsideClickTargetRef,
148
- className: ax(["_2rko1sit _ca0qv77o _n3tdv77o _19bvv77o _u5f3v77o _16qs1cd0 _bfhk1bhr"])
148
+ className: ax(["_2rkofajl _ca0qv77o _n3tdv77o _19bvv77o _u5f3v77o _16qs1cd0 _bfhk1bhr"])
149
149
  }, /*#__PURE__*/React.createElement("div", {
150
150
  className: ax(["_1e0c1txw _2lx21bp4 _p12f1qwj _ca0qpxbi _u5f31ejb _n3tdpxbi _19bv1ejb"])
151
151
  }, /*#__PURE__*/React.createElement(Stack, {
@@ -56,22 +56,57 @@ export var isTable = function isTable(node) {
56
56
  */
57
57
  export var getBlockRange = function getBlockRange(_ref) {
58
58
  var $from = _ref.$from,
59
- $to = _ref.$to,
60
- _ref$isLifting = _ref.isLifting,
61
- isLifting = _ref$isLifting === void 0 ? false : _ref$isLifting;
59
+ $to = _ref.$to;
62
60
  var _$from$doc$type$schem = $from.doc.type.schema.nodes,
63
61
  taskList = _$from$doc$type$schem.taskList,
64
- blockTaskItem = _$from$doc$type$schem.blockTaskItem;
62
+ taskItem = _$from$doc$type$schem.taskItem,
63
+ blockTaskItem = _$from$doc$type$schem.blockTaskItem,
64
+ paragraph = _$from$doc$type$schem.paragraph;
65
65
  var blockTaskItemNode = findFarthestParentNode(function (node) {
66
66
  return node.type === blockTaskItem;
67
67
  })($from);
68
68
  if (blockTaskItem && blockTaskItemNode) {
69
- var startOfNodeInBlockTaskItem = $from.doc.resolve(blockTaskItemNode.start);
69
+ var _$prevNode$nodeBefore;
70
+ var startOfBlockRange = blockTaskItemNode.start - 1;
71
+ var endNode = $to.end();
72
+ var _$after = $to.doc.resolve(endNode + 1);
73
+ var _after = _$after.nodeAfter;
70
74
  var lastNode = $to.node($to.depth);
71
- var endOfNodeInBlockTaskItem = $from.doc.resolve($to.start() + lastNode.nodeSize - 1);
72
- return new NodeRange(startOfNodeInBlockTaskItem, endOfNodeInBlockTaskItem,
73
- // When lifting we want to ignore the potential depth of nested nodes so reduce the depth
74
- isLifting ? blockTaskItemNode.depth - 2 : blockTaskItemNode.depth - 1);
75
+ var rangeDepth = blockTaskItemNode.depth - 1;
76
+ var endOfBlockRange = $to.start() + lastNode.nodeSize;
77
+
78
+ // If the lastNode is a paragraph need to resolve a little bit further to get the node after the block task item
79
+ if (lastNode.type === paragraph) {
80
+ _$after = $to.doc.resolve(endNode + 2);
81
+ _after = _$after.nodeAfter;
82
+ }
83
+ // Otherwise assume it's a block node so increase the range depth
84
+ else {
85
+ rangeDepth = rangeDepth - 1;
86
+ endOfBlockRange = endOfBlockRange - 1;
87
+ }
88
+
89
+ // If the after node is a sibling taskList of the blockTaskItem, then extend the range
90
+ if (_after && _after.type === taskList && _$after.depth === blockTaskItemNode.depth - 1) {
91
+ endOfBlockRange = endOfBlockRange + _after.nodeSize;
92
+ }
93
+
94
+ // Is after another taskItem/ blockTaskItem
95
+ var $prevNode = $from.doc.resolve(startOfBlockRange - 1);
96
+ var prevNodeSize = (_$prevNode$nodeBefore = $prevNode.nodeBefore) === null || _$prevNode$nodeBefore === void 0 ? void 0 : _$prevNode$nodeBefore.nodeSize;
97
+ var $prevNodeParent = $from.doc.resolve($prevNode.pos - (prevNodeSize || 0) - 1);
98
+ var prevNodeParent = $prevNodeParent.nodeAfter;
99
+
100
+ // If after another taskItem/ blockTaskItem
101
+ if (prevNodeParent && [blockTaskItem, taskItem].includes(prevNodeParent.type)) {
102
+ rangeDepth = blockTaskItemNode.depth - 1;
103
+ endOfBlockRange = endOfBlockRange - 2;
104
+ startOfBlockRange = startOfBlockRange + 1;
105
+ }
106
+ var $endOfBlockRange = $to.doc.resolve(endOfBlockRange);
107
+ var $startOfBlockRange = $to.doc.resolve(startOfBlockRange);
108
+ var nodeRange = new NodeRange($startOfBlockRange, $endOfBlockRange, rangeDepth);
109
+ return nodeRange;
75
110
  }
76
111
  var end = $to.end();
77
112
  var $after = $to.doc.resolve(end + 1);
@@ -229,8 +264,7 @@ export var isEmptyTaskDecision = function isEmptyTaskDecision(state) {
229
264
  export var liftBlock = function liftBlock(tr, $from, $to) {
230
265
  var blockRange = getBlockRange({
231
266
  $from: $from,
232
- $to: $to,
233
- isLifting: true
267
+ $to: $to
234
268
  });
235
269
  if (!blockRange) {
236
270
  return null;
@@ -1,6 +1,6 @@
1
1
 
2
- ._2rko1sit{border-radius:var(--ds-border-radius,3px)}
3
2
  ._2rko1ssb{border-radius:50%}
3
+ ._2rkofajl{border-radius:var(--ds-radius-small,3px)}
4
4
  ._zulp1b66{gap:var(--ds-space-050,4px)}._16qs1cd0{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #091e4226,0 0 1px #091e424f)}
5
5
  ._18u0u2gc{margin-left:var(--ds-space-100,8px)}
6
6
  ._19bv1ejb{padding-left:var(--ds-space-300,24px)}
@@ -151,7 +151,7 @@ export var RequestToEditPopup = function RequestToEditPopup(_ref2) {
151
151
  }, /*#__PURE__*/React.createElement(OutsideClickTargetRefContext.Consumer, null, function (setOutsideClickTargetRef) {
152
152
  return /*#__PURE__*/React.createElement("div", {
153
153
  ref: setOutsideClickTargetRef,
154
- className: ax(["_2rko1sit _ca0qv77o _n3tdv77o _19bvv77o _u5f3v77o _16qs1cd0 _bfhk1bhr"])
154
+ className: ax(["_2rkofajl _ca0qv77o _n3tdv77o _19bvv77o _u5f3v77o _16qs1cd0 _bfhk1bhr"])
155
155
  }, /*#__PURE__*/React.createElement("div", {
156
156
  className: ax(["_1e0c1txw _2lx21bp4 _p12f1qwj _ca0qpxbi _u5f31ejb _n3tdpxbi _19bv1ejb"])
157
157
  }, /*#__PURE__*/React.createElement(Stack, {
@@ -12,10 +12,9 @@ export declare const isTable: (node?: Node | null) => boolean;
12
12
  * Creates a NodeRange around the given taskItem and the following
13
13
  * ("nested") taskList, if one exists.
14
14
  */
15
- export declare const getBlockRange: ({ $from, $to, isLifting, }: {
15
+ export declare const getBlockRange: ({ $from, $to }: {
16
16
  $from: ResolvedPos;
17
17
  $to: ResolvedPos;
18
- isLifting?: boolean;
19
18
  }) => NodeRange | null;
20
19
  /**
21
20
  * Calculates the current indent level of the selection within a task list in the ProseMirror document.
@@ -12,10 +12,9 @@ export declare const isTable: (node?: Node | null) => boolean;
12
12
  * Creates a NodeRange around the given taskItem and the following
13
13
  * ("nested") taskList, if one exists.
14
14
  */
15
- export declare const getBlockRange: ({ $from, $to, isLifting, }: {
15
+ export declare const getBlockRange: ({ $from, $to }: {
16
16
  $from: ResolvedPos;
17
17
  $to: ResolvedPos;
18
- isLifting?: boolean;
19
18
  }) => NodeRange | null;
20
19
  /**
21
20
  * Calculates the current indent level of the selection within a task list in the ProseMirror document.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "7.0.2",
3
+ "version": "7.0.4",
4
4
  "description": "Tasks and decisions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -49,7 +49,7 @@
49
49
  "@atlaskit/primitives": "^14.12.0",
50
50
  "@atlaskit/prosemirror-input-rules": "^3.4.0",
51
51
  "@atlaskit/task-decision": "^19.2.0",
52
- "@atlaskit/tmp-editor-statsig": "^12.2.0",
52
+ "@atlaskit/tmp-editor-statsig": "^12.3.0",
53
53
  "@atlaskit/tokens": "^6.1.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@compiled/react": "^0.18.3",