@atlaskit/editor-plugin-tasks-and-decisions 8.4.6 → 8.4.7

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
+ ## 8.4.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`99f97d44476b4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/99f97d44476b4) -
8
+ [EDITOR-1632] When backspacing multi-line blockTaskItems with a paragraph as the first line in the
9
+ blockTaskItem and extensions/ other content subsequent then make sure all the content in the
10
+ blockTaskItem is preserved when it's moved out of the blockTaskItem
11
+
3
12
  ## 8.4.6
4
13
 
5
14
  ### Patch Changes
@@ -170,10 +170,41 @@ var backspaceFrom = function backspaceFrom(editorAnalyticsAPI) {
170
170
  }
171
171
 
172
172
  // If nested in a taskList, unindent
173
- var parentDepth = isInBlockTaskItemParagraph ? $from.depth - 3 : $from.depth - 2;
173
+ var depthFromSelectionToBlockTaskItem = isInBlockTaskItemParagraph ? 2 : 1;
174
+ var depthFromSelectionToNestedTaskList = depthFromSelectionToBlockTaskItem + 1;
175
+ var parentDepth = $from.depth - depthFromSelectionToNestedTaskList;
174
176
  if ($from.node(parentDepth).type === taskList) {
175
177
  return getUnindentCommand(editorAnalyticsAPI)()(state, dispatch);
176
178
  }
179
+
180
+ // If at the end of an item, unwrap contents into a paragraph
181
+ // we achieve this by slicing the content out, and replacing
182
+ if (actionDecisionFollowsOrNothing($from)) {
183
+ if (dispatch) {
184
+ // If we are in a blockTaskItem paragraph, we need to get the content of the whole blockTaskItem
185
+ // So we reduce the depth by 1 to get to the blockTaskItem node content
186
+ var taskContent = isInBlockTaskItemParagraph ? state.doc.slice($from.start($from.depth - 1), $from.end($from.depth - 1)).content : state.doc.slice($from.start(), $from.end()).content;
187
+ var slice;
188
+ try {
189
+ slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
190
+ // might be end of document after
191
+ var tr = splitListItemWith(state.tr, slice, $from, true);
192
+ dispatch(tr);
193
+ return true;
194
+ } catch (error) {
195
+ // If there's an error creating a paragraph, check if we are in a blockTaskItem
196
+ // Block task item's can have non-text content that cannot be wrapped in a paragraph
197
+ // So if the selection is in a blockTaskItem, just pass the content as is
198
+ if (resultOfFindBlockTaskItem && resultOfFindBlockTaskItem.blockTaskItemNode) {
199
+ // Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
200
+ slice = Array.from(taskContent.content);
201
+ var _tr = splitListItemWith(state.tr, slice, $from, true);
202
+ dispatch(_tr);
203
+ return true;
204
+ }
205
+ }
206
+ }
207
+ }
177
208
  } else {
178
209
  // previous was empty, just delete backwards
179
210
  var taskBefore = $from.doc.resolve($from.before());
@@ -185,29 +216,29 @@ var backspaceFrom = function backspaceFrom(editorAnalyticsAPI) {
185
216
  if ($from.node($from.depth - 2).type === taskList) {
186
217
  return getUnindentCommand(editorAnalyticsAPI)()(state, dispatch);
187
218
  }
188
- }
189
219
 
190
- // If at the end of an item, unwrap contents into a paragraph
191
- // we achieve this by slicing the content out, and replacing
192
- if (actionDecisionFollowsOrNothing($from)) {
193
- if (dispatch) {
194
- var taskContent = state.doc.slice($from.start(), $from.end()).content;
195
- var slice;
196
- try {
197
- slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
198
- // might be end of document after
199
- var tr = splitListItemWith(state.tr, slice, $from, true);
200
- dispatch(tr);
201
- return true;
202
- } catch (error) {
203
- // If there's an error creating a paragraph, then just pass the content as is
204
- // Block task item's can have non-text content that cannot be wrapped in a paragraph
205
- if (blockTaskItem) {
206
- // Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
207
- slice = Array.from(taskContent.content);
208
- var _tr = splitListItemWith(state.tr, slice, $from, true);
209
- dispatch(_tr);
220
+ // If at the end of an item, unwrap contents into a paragraph
221
+ // we achieve this by slicing the content out, and replacing
222
+ if (actionDecisionFollowsOrNothing($from)) {
223
+ if (dispatch) {
224
+ var _taskContent = state.doc.slice($from.start(), $from.end()).content;
225
+ var _slice;
226
+ try {
227
+ _slice = _taskContent.size ? paragraph.createChecked(undefined, _taskContent) : paragraph.createChecked();
228
+ // might be end of document after
229
+ var _tr2 = splitListItemWith(state.tr, _slice, $from, true);
230
+ dispatch(_tr2);
210
231
  return true;
232
+ } catch (error) {
233
+ // If there's an error creating a paragraph, then just pass the content as is
234
+ // Block task item's can have non-text content that cannot be wrapped in a paragraph
235
+ if (blockTaskItem) {
236
+ // Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
237
+ _slice = Array.from(_taskContent.content);
238
+ var _tr3 = splitListItemWith(state.tr, _slice, $from, true);
239
+ dispatch(_tr3);
240
+ return true;
241
+ }
211
242
  }
212
243
  }
213
244
  }
@@ -307,8 +338,8 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
307
338
  var $oldAfter = origDoc.resolve($from.after());
308
339
  var textSelectionModifier = 0;
309
340
  var replaceFromModifier = 0;
310
- var replaceToModifier = 0;
311
341
  var deleteBlockModifier = 0;
342
+ var shouldSplitBlockTaskItem = true;
312
343
  var isGapCursorSelection = false;
313
344
  if (blockTaskItem) {
314
345
  var result = (0, _utils3.findBlockTaskItem)($from);
@@ -321,10 +352,10 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
321
352
  // adjust some calculations
322
353
  if (hasParagraph) {
323
354
  baseDepth = $from.depth - 1;
324
- $oldAfter = origDoc.resolve($from.after() + 1);
355
+ $oldAfter = origDoc.resolve($from.after(baseDepth));
325
356
 
326
357
  // When we're removing the extra empty task item we need to reduce the range a bit
327
- deleteBlockModifier = 2;
358
+ deleteBlockModifier = 1;
328
359
  } else {
329
360
  textSelectionModifier = 1;
330
361
  isGapCursorSelection = true;
@@ -332,14 +363,13 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
332
363
  textSelectionModifier = 1;
333
364
  var hasSiblingTaskList = ((_$oldAfter$nodeAfter = $oldAfter.nodeAfter) === null || _$oldAfter$nodeAfter === void 0 ? void 0 : _$oldAfter$nodeAfter.type) === taskList;
334
365
  if (hasSiblingTaskList) {
335
- // Make sure we're wrapping around the whole list
336
- replaceToModifier = hasParagraph ? 3 : 1;
366
+ // Don't use the split command if there is a sibling taskList
367
+ shouldSplitBlockTaskItem = false;
337
368
  }
338
369
  var posPreviousSibling = $from.start(hasParagraph ? $from.depth - 1 : $from.depth) - 1;
339
370
  var $posPreviousSibling = tr.doc.resolve(posPreviousSibling);
340
371
  var hasPreviousTaskItem = ((_$posPreviousSibling$ = $posPreviousSibling.nodeBefore) === null || _$posPreviousSibling$ === void 0 ? void 0 : _$posPreviousSibling$.type) === blockTaskItem;
341
- if (!hasPreviousTaskItem && hasParagraph) {
342
- // Go down one step to get to the doc node
372
+ if (hasPreviousTaskItem && hasParagraph) {
343
373
  replaceFromModifier = 1;
344
374
  }
345
375
  }
@@ -350,7 +380,7 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
350
380
  // we can only split if there was a list item before us
351
381
  var container = $from.node(baseDepth - 2);
352
382
  var posInList = $from.index(baseDepth - 1);
353
- var shouldSplit = !(!(0, _helpers.isActionOrDecisionList)(container) && posInList === 0);
383
+ var shouldSplit = !(!(0, _helpers.isActionOrDecisionList)(container) && posInList === 0) && shouldSplitBlockTaskItem;
354
384
  var frag = _model.Fragment.from(content);
355
385
  var isNestedActionInsideLists = frag.childCount === 1 && ((_frag$firstChild = frag.firstChild) === null || _frag$firstChild === void 0 ? void 0 : _frag$firstChild.type.name) === 'listItem';
356
386
 
@@ -376,7 +406,7 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
376
406
  * (The cursor can be placed easily next to list item)
377
407
  */
378
408
  var previousListItemPos = isNestedActionInsideLists ? $from.start(baseDepth - 2) : 0;
379
- tr = tr.replace(tr.mapping.map($from.start() - (2 + replaceFromModifier)), tr.mapping.map($from.end() + (2 + replaceToModifier)), frag.size ? new _model.Slice(frag, 0, 0) : _model.Slice.empty);
409
+ tr = tr.replace(tr.mapping.map($from.start(baseDepth) - 2 + replaceFromModifier), tr.mapping.map($from.end(baseDepth) + 2), frag.size ? new _model.Slice(frag, 0, 0) : _model.Slice.empty);
380
410
  if (setSelection && !isNestedActionInsideLists) {
381
411
  var newPos = $from.pos + 1 - ((shouldSplit ? 0 : 2) + textSelectionModifier);
382
412
  if (isGapCursorSelection) {
@@ -146,10 +146,41 @@ const backspaceFrom = editorAnalyticsAPI => $from => (state, dispatch) => {
146
146
  }
147
147
 
148
148
  // If nested in a taskList, unindent
149
- const parentDepth = isInBlockTaskItemParagraph ? $from.depth - 3 : $from.depth - 2;
149
+ const depthFromSelectionToBlockTaskItem = isInBlockTaskItemParagraph ? 2 : 1;
150
+ const depthFromSelectionToNestedTaskList = depthFromSelectionToBlockTaskItem + 1;
151
+ const parentDepth = $from.depth - depthFromSelectionToNestedTaskList;
150
152
  if ($from.node(parentDepth).type === taskList) {
151
153
  return getUnindentCommand(editorAnalyticsAPI)()(state, dispatch);
152
154
  }
155
+
156
+ // If at the end of an item, unwrap contents into a paragraph
157
+ // we achieve this by slicing the content out, and replacing
158
+ if (actionDecisionFollowsOrNothing($from)) {
159
+ if (dispatch) {
160
+ // If we are in a blockTaskItem paragraph, we need to get the content of the whole blockTaskItem
161
+ // So we reduce the depth by 1 to get to the blockTaskItem node content
162
+ const taskContent = isInBlockTaskItemParagraph ? state.doc.slice($from.start($from.depth - 1), $from.end($from.depth - 1)).content : state.doc.slice($from.start(), $from.end()).content;
163
+ let slice;
164
+ try {
165
+ slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
166
+ // might be end of document after
167
+ const tr = splitListItemWith(state.tr, slice, $from, true);
168
+ dispatch(tr);
169
+ return true;
170
+ } catch (error) {
171
+ // If there's an error creating a paragraph, check if we are in a blockTaskItem
172
+ // Block task item's can have non-text content that cannot be wrapped in a paragraph
173
+ // So if the selection is in a blockTaskItem, just pass the content as is
174
+ if (resultOfFindBlockTaskItem && resultOfFindBlockTaskItem.blockTaskItemNode) {
175
+ // Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
176
+ slice = Array.from(taskContent.content);
177
+ const tr = splitListItemWith(state.tr, slice, $from, true);
178
+ dispatch(tr);
179
+ return true;
180
+ }
181
+ }
182
+ }
183
+ }
153
184
  } else {
154
185
  // previous was empty, just delete backwards
155
186
  const taskBefore = $from.doc.resolve($from.before());
@@ -161,29 +192,29 @@ const backspaceFrom = editorAnalyticsAPI => $from => (state, dispatch) => {
161
192
  if ($from.node($from.depth - 2).type === taskList) {
162
193
  return getUnindentCommand(editorAnalyticsAPI)()(state, dispatch);
163
194
  }
164
- }
165
195
 
166
- // If at the end of an item, unwrap contents into a paragraph
167
- // we achieve this by slicing the content out, and replacing
168
- if (actionDecisionFollowsOrNothing($from)) {
169
- if (dispatch) {
170
- const taskContent = state.doc.slice($from.start(), $from.end()).content;
171
- let slice;
172
- try {
173
- slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
174
- // might be end of document after
175
- const tr = splitListItemWith(state.tr, slice, $from, true);
176
- dispatch(tr);
177
- return true;
178
- } catch (error) {
179
- // If there's an error creating a paragraph, then just pass the content as is
180
- // Block task item's can have non-text content that cannot be wrapped in a paragraph
181
- if (blockTaskItem) {
182
- // Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
183
- slice = Array.from(taskContent.content);
196
+ // If at the end of an item, unwrap contents into a paragraph
197
+ // we achieve this by slicing the content out, and replacing
198
+ if (actionDecisionFollowsOrNothing($from)) {
199
+ if (dispatch) {
200
+ const taskContent = state.doc.slice($from.start(), $from.end()).content;
201
+ let slice;
202
+ try {
203
+ slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
204
+ // might be end of document after
184
205
  const tr = splitListItemWith(state.tr, slice, $from, true);
185
206
  dispatch(tr);
186
207
  return true;
208
+ } catch (error) {
209
+ // If there's an error creating a paragraph, then just pass the content as is
210
+ // Block task item's can have non-text content that cannot be wrapped in a paragraph
211
+ if (blockTaskItem) {
212
+ // Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
213
+ slice = Array.from(taskContent.content);
214
+ const tr = splitListItemWith(state.tr, slice, $from, true);
215
+ dispatch(tr);
216
+ return true;
217
+ }
187
218
  }
188
219
  }
189
220
  }
@@ -283,8 +314,8 @@ const splitListItemWith = (tr, content, $from, setSelection) => {
283
314
  let $oldAfter = origDoc.resolve($from.after());
284
315
  let textSelectionModifier = 0;
285
316
  let replaceFromModifier = 0;
286
- let replaceToModifier = 0;
287
317
  let deleteBlockModifier = 0;
318
+ let shouldSplitBlockTaskItem = true;
288
319
  let isGapCursorSelection = false;
289
320
  if (blockTaskItem) {
290
321
  const result = findBlockTaskItem($from);
@@ -299,10 +330,10 @@ const splitListItemWith = (tr, content, $from, setSelection) => {
299
330
  // adjust some calculations
300
331
  if (hasParagraph) {
301
332
  baseDepth = $from.depth - 1;
302
- $oldAfter = origDoc.resolve($from.after() + 1);
333
+ $oldAfter = origDoc.resolve($from.after(baseDepth));
303
334
 
304
335
  // When we're removing the extra empty task item we need to reduce the range a bit
305
- deleteBlockModifier = 2;
336
+ deleteBlockModifier = 1;
306
337
  } else {
307
338
  textSelectionModifier = 1;
308
339
  isGapCursorSelection = true;
@@ -310,14 +341,13 @@ const splitListItemWith = (tr, content, $from, setSelection) => {
310
341
  textSelectionModifier = 1;
311
342
  const hasSiblingTaskList = ((_$oldAfter$nodeAfter = $oldAfter.nodeAfter) === null || _$oldAfter$nodeAfter === void 0 ? void 0 : _$oldAfter$nodeAfter.type) === taskList;
312
343
  if (hasSiblingTaskList) {
313
- // Make sure we're wrapping around the whole list
314
- replaceToModifier = hasParagraph ? 3 : 1;
344
+ // Don't use the split command if there is a sibling taskList
345
+ shouldSplitBlockTaskItem = false;
315
346
  }
316
347
  const posPreviousSibling = $from.start(hasParagraph ? $from.depth - 1 : $from.depth) - 1;
317
348
  const $posPreviousSibling = tr.doc.resolve(posPreviousSibling);
318
349
  const hasPreviousTaskItem = ((_$posPreviousSibling$ = $posPreviousSibling.nodeBefore) === null || _$posPreviousSibling$ === void 0 ? void 0 : _$posPreviousSibling$.type) === blockTaskItem;
319
- if (!hasPreviousTaskItem && hasParagraph) {
320
- // Go down one step to get to the doc node
350
+ if (hasPreviousTaskItem && hasParagraph) {
321
351
  replaceFromModifier = 1;
322
352
  }
323
353
  }
@@ -328,7 +358,7 @@ const splitListItemWith = (tr, content, $from, setSelection) => {
328
358
  // we can only split if there was a list item before us
329
359
  const container = $from.node(baseDepth - 2);
330
360
  const posInList = $from.index(baseDepth - 1);
331
- const shouldSplit = !(!isActionOrDecisionList(container) && posInList === 0);
361
+ const shouldSplit = !(!isActionOrDecisionList(container) && posInList === 0) && shouldSplitBlockTaskItem;
332
362
  const frag = Fragment.from(content);
333
363
  const isNestedActionInsideLists = frag.childCount === 1 && ((_frag$firstChild = frag.firstChild) === null || _frag$firstChild === void 0 ? void 0 : _frag$firstChild.type.name) === 'listItem';
334
364
 
@@ -354,7 +384,7 @@ const splitListItemWith = (tr, content, $from, setSelection) => {
354
384
  * (The cursor can be placed easily next to list item)
355
385
  */
356
386
  const previousListItemPos = isNestedActionInsideLists ? $from.start(baseDepth - 2) : 0;
357
- tr = tr.replace(tr.mapping.map($from.start() - (2 + replaceFromModifier)), tr.mapping.map($from.end() + (2 + replaceToModifier)), frag.size ? new Slice(frag, 0, 0) : Slice.empty);
387
+ tr = tr.replace(tr.mapping.map($from.start(baseDepth) - 2 + replaceFromModifier), tr.mapping.map($from.end(baseDepth) + 2), frag.size ? new Slice(frag, 0, 0) : Slice.empty);
358
388
  if (setSelection && !isNestedActionInsideLists) {
359
389
  const newPos = $from.pos + 1 - ((shouldSplit ? 0 : 2) + textSelectionModifier);
360
390
  if (isGapCursorSelection) {
@@ -162,10 +162,41 @@ var backspaceFrom = function backspaceFrom(editorAnalyticsAPI) {
162
162
  }
163
163
 
164
164
  // If nested in a taskList, unindent
165
- var parentDepth = isInBlockTaskItemParagraph ? $from.depth - 3 : $from.depth - 2;
165
+ var depthFromSelectionToBlockTaskItem = isInBlockTaskItemParagraph ? 2 : 1;
166
+ var depthFromSelectionToNestedTaskList = depthFromSelectionToBlockTaskItem + 1;
167
+ var parentDepth = $from.depth - depthFromSelectionToNestedTaskList;
166
168
  if ($from.node(parentDepth).type === taskList) {
167
169
  return getUnindentCommand(editorAnalyticsAPI)()(state, dispatch);
168
170
  }
171
+
172
+ // If at the end of an item, unwrap contents into a paragraph
173
+ // we achieve this by slicing the content out, and replacing
174
+ if (actionDecisionFollowsOrNothing($from)) {
175
+ if (dispatch) {
176
+ // If we are in a blockTaskItem paragraph, we need to get the content of the whole blockTaskItem
177
+ // So we reduce the depth by 1 to get to the blockTaskItem node content
178
+ var taskContent = isInBlockTaskItemParagraph ? state.doc.slice($from.start($from.depth - 1), $from.end($from.depth - 1)).content : state.doc.slice($from.start(), $from.end()).content;
179
+ var slice;
180
+ try {
181
+ slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
182
+ // might be end of document after
183
+ var tr = splitListItemWith(state.tr, slice, $from, true);
184
+ dispatch(tr);
185
+ return true;
186
+ } catch (error) {
187
+ // If there's an error creating a paragraph, check if we are in a blockTaskItem
188
+ // Block task item's can have non-text content that cannot be wrapped in a paragraph
189
+ // So if the selection is in a blockTaskItem, just pass the content as is
190
+ if (resultOfFindBlockTaskItem && resultOfFindBlockTaskItem.blockTaskItemNode) {
191
+ // Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
192
+ slice = Array.from(taskContent.content);
193
+ var _tr = splitListItemWith(state.tr, slice, $from, true);
194
+ dispatch(_tr);
195
+ return true;
196
+ }
197
+ }
198
+ }
199
+ }
169
200
  } else {
170
201
  // previous was empty, just delete backwards
171
202
  var taskBefore = $from.doc.resolve($from.before());
@@ -177,29 +208,29 @@ var backspaceFrom = function backspaceFrom(editorAnalyticsAPI) {
177
208
  if ($from.node($from.depth - 2).type === taskList) {
178
209
  return getUnindentCommand(editorAnalyticsAPI)()(state, dispatch);
179
210
  }
180
- }
181
211
 
182
- // If at the end of an item, unwrap contents into a paragraph
183
- // we achieve this by slicing the content out, and replacing
184
- if (actionDecisionFollowsOrNothing($from)) {
185
- if (dispatch) {
186
- var taskContent = state.doc.slice($from.start(), $from.end()).content;
187
- var slice;
188
- try {
189
- slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
190
- // might be end of document after
191
- var tr = splitListItemWith(state.tr, slice, $from, true);
192
- dispatch(tr);
193
- return true;
194
- } catch (error) {
195
- // If there's an error creating a paragraph, then just pass the content as is
196
- // Block task item's can have non-text content that cannot be wrapped in a paragraph
197
- if (blockTaskItem) {
198
- // Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
199
- slice = Array.from(taskContent.content);
200
- var _tr = splitListItemWith(state.tr, slice, $from, true);
201
- dispatch(_tr);
212
+ // If at the end of an item, unwrap contents into a paragraph
213
+ // we achieve this by slicing the content out, and replacing
214
+ if (actionDecisionFollowsOrNothing($from)) {
215
+ if (dispatch) {
216
+ var _taskContent = state.doc.slice($from.start(), $from.end()).content;
217
+ var _slice;
218
+ try {
219
+ _slice = _taskContent.size ? paragraph.createChecked(undefined, _taskContent) : paragraph.createChecked();
220
+ // might be end of document after
221
+ var _tr2 = splitListItemWith(state.tr, _slice, $from, true);
222
+ dispatch(_tr2);
202
223
  return true;
224
+ } catch (error) {
225
+ // If there's an error creating a paragraph, then just pass the content as is
226
+ // Block task item's can have non-text content that cannot be wrapped in a paragraph
227
+ if (blockTaskItem) {
228
+ // Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
229
+ _slice = Array.from(_taskContent.content);
230
+ var _tr3 = splitListItemWith(state.tr, _slice, $from, true);
231
+ dispatch(_tr3);
232
+ return true;
233
+ }
203
234
  }
204
235
  }
205
236
  }
@@ -299,8 +330,8 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
299
330
  var $oldAfter = origDoc.resolve($from.after());
300
331
  var textSelectionModifier = 0;
301
332
  var replaceFromModifier = 0;
302
- var replaceToModifier = 0;
303
333
  var deleteBlockModifier = 0;
334
+ var shouldSplitBlockTaskItem = true;
304
335
  var isGapCursorSelection = false;
305
336
  if (blockTaskItem) {
306
337
  var result = findBlockTaskItem($from);
@@ -313,10 +344,10 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
313
344
  // adjust some calculations
314
345
  if (hasParagraph) {
315
346
  baseDepth = $from.depth - 1;
316
- $oldAfter = origDoc.resolve($from.after() + 1);
347
+ $oldAfter = origDoc.resolve($from.after(baseDepth));
317
348
 
318
349
  // When we're removing the extra empty task item we need to reduce the range a bit
319
- deleteBlockModifier = 2;
350
+ deleteBlockModifier = 1;
320
351
  } else {
321
352
  textSelectionModifier = 1;
322
353
  isGapCursorSelection = true;
@@ -324,14 +355,13 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
324
355
  textSelectionModifier = 1;
325
356
  var hasSiblingTaskList = ((_$oldAfter$nodeAfter = $oldAfter.nodeAfter) === null || _$oldAfter$nodeAfter === void 0 ? void 0 : _$oldAfter$nodeAfter.type) === taskList;
326
357
  if (hasSiblingTaskList) {
327
- // Make sure we're wrapping around the whole list
328
- replaceToModifier = hasParagraph ? 3 : 1;
358
+ // Don't use the split command if there is a sibling taskList
359
+ shouldSplitBlockTaskItem = false;
329
360
  }
330
361
  var posPreviousSibling = $from.start(hasParagraph ? $from.depth - 1 : $from.depth) - 1;
331
362
  var $posPreviousSibling = tr.doc.resolve(posPreviousSibling);
332
363
  var hasPreviousTaskItem = ((_$posPreviousSibling$ = $posPreviousSibling.nodeBefore) === null || _$posPreviousSibling$ === void 0 ? void 0 : _$posPreviousSibling$.type) === blockTaskItem;
333
- if (!hasPreviousTaskItem && hasParagraph) {
334
- // Go down one step to get to the doc node
364
+ if (hasPreviousTaskItem && hasParagraph) {
335
365
  replaceFromModifier = 1;
336
366
  }
337
367
  }
@@ -342,7 +372,7 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
342
372
  // we can only split if there was a list item before us
343
373
  var container = $from.node(baseDepth - 2);
344
374
  var posInList = $from.index(baseDepth - 1);
345
- var shouldSplit = !(!isActionOrDecisionList(container) && posInList === 0);
375
+ var shouldSplit = !(!isActionOrDecisionList(container) && posInList === 0) && shouldSplitBlockTaskItem;
346
376
  var frag = Fragment.from(content);
347
377
  var isNestedActionInsideLists = frag.childCount === 1 && ((_frag$firstChild = frag.firstChild) === null || _frag$firstChild === void 0 ? void 0 : _frag$firstChild.type.name) === 'listItem';
348
378
 
@@ -368,7 +398,7 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
368
398
  * (The cursor can be placed easily next to list item)
369
399
  */
370
400
  var previousListItemPos = isNestedActionInsideLists ? $from.start(baseDepth - 2) : 0;
371
- tr = tr.replace(tr.mapping.map($from.start() - (2 + replaceFromModifier)), tr.mapping.map($from.end() + (2 + replaceToModifier)), frag.size ? new Slice(frag, 0, 0) : Slice.empty);
401
+ tr = tr.replace(tr.mapping.map($from.start(baseDepth) - 2 + replaceFromModifier), tr.mapping.map($from.end(baseDepth) + 2), frag.size ? new Slice(frag, 0, 0) : Slice.empty);
372
402
  if (setSelection && !isNestedActionInsideLists) {
373
403
  var newPos = $from.pos + 1 - ((shouldSplit ? 0 : 2) + textSelectionModifier);
374
404
  if (isGapCursorSelection) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "8.4.6",
3
+ "version": "8.4.7",
4
4
  "description": "Tasks and decisions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",