@atlaskit/editor-plugin-tasks-and-decisions 11.3.1 → 11.3.2
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 +6 -0
- package/dist/cjs/pm-plugins/helpers.js +2 -3
- package/dist/cjs/pm-plugins/keymaps.js +87 -127
- package/dist/cjs/ui/Task/RequestToEditPopup.js +1 -1
- package/dist/cjs/ui/Task/task-item-with-providers.js +1 -1
- package/dist/es2019/pm-plugins/helpers.js +2 -3
- package/dist/es2019/pm-plugins/keymaps.js +88 -128
- package/dist/es2019/ui/Task/RequestToEditPopup.js +1 -1
- package/dist/es2019/ui/Task/task-item-with-providers.js +1 -1
- package/dist/esm/pm-plugins/helpers.js +2 -3
- package/dist/esm/pm-plugins/keymaps.js +87 -127
- package/dist/esm/ui/Task/RequestToEditPopup.js +1 -1
- package/dist/esm/ui/Task/task-item-with-providers.js +1 -1
- package/package.json +2 -5
package/CHANGELOG.md
CHANGED
|
@@ -22,7 +22,6 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
22
22
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
23
23
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
24
24
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
25
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
26
25
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
27
26
|
var _pluginKey = require("./plugin-key");
|
|
28
27
|
var _types = require("./types");
|
|
@@ -254,7 +253,7 @@ var subtreeHeight = exports.subtreeHeight = function subtreeHeight($from, $to, t
|
|
|
254
253
|
// and get the max height from the current position to the
|
|
255
254
|
// deepest leaf node
|
|
256
255
|
var maxChildDepth = $from.depth;
|
|
257
|
-
$from.doc.nodesBetween(blockRange.start, blockRange.end, function (descendent, relPos,
|
|
256
|
+
$from.doc.nodesBetween(blockRange.start, blockRange.end, function (descendent, relPos, _parent) {
|
|
258
257
|
maxChildDepth = Math.max($from.doc.resolve(relPos).depth, maxChildDepth);
|
|
259
258
|
|
|
260
259
|
// keep descending down the tree if we can
|
|
@@ -288,7 +287,7 @@ var isEmptyTaskDecision = exports.isEmptyTaskDecision = function isEmptyTaskDeci
|
|
|
288
287
|
// If in an empty paragraph that's not at the doc level
|
|
289
288
|
node.content.size === 0 && node.type === paragraph && $from.depth > 0 &&
|
|
290
289
|
// and it's parent is a blockTaskItem with only this paragraph inside it
|
|
291
|
-
$from.node($from.depth - 1).type === blockTaskItem && $from.node($from.depth - 1).childCount === 1
|
|
290
|
+
$from.node($from.depth - 1).type === blockTaskItem && $from.node($from.depth - 1).childCount === 1;
|
|
292
291
|
return isEmptyTaskOrDecisionItem || isInEmptyBlockTaskItem;
|
|
293
292
|
};
|
|
294
293
|
|
|
@@ -19,7 +19,6 @@ var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
|
19
19
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
20
20
|
var _state2 = require("@atlaskit/editor-prosemirror/state");
|
|
21
21
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
22
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
23
22
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
24
23
|
var _moveSelectedTaskListItems = require("./actions/move-selected-task-list-items");
|
|
25
24
|
var _commands2 = require("./commands");
|
|
@@ -247,6 +246,7 @@ var backspace = function backspace(editorAnalyticsAPI) {
|
|
|
247
246
|
})), ['taskList', 'decisionList']));
|
|
248
247
|
};
|
|
249
248
|
var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTaskDecisionFollowing(state, dispatch) {
|
|
249
|
+
var _$next$node, _$from$node, _$next$node2, _$from$node2, _$next$node3;
|
|
250
250
|
var $from = state.selection.$from,
|
|
251
251
|
_state$schema$nodes4 = state.schema.nodes,
|
|
252
252
|
taskList = _state$schema$nodes4.taskList,
|
|
@@ -255,128 +255,92 @@ var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTas
|
|
|
255
255
|
blockTaskItem = _state$schema$nodes4.blockTaskItem,
|
|
256
256
|
taskItem = _state$schema$nodes4.taskItem,
|
|
257
257
|
tr = state.tr;
|
|
258
|
-
if ((0, _platformFeatureFlags.fg)('platform_editor_blocktaskitem_patch_3')) {
|
|
259
|
-
var _$next$node, _$from$node, _$next$node2, _$from$node2, _$next$node3;
|
|
260
|
-
// only run if cursor is at the end of the node
|
|
261
|
-
if (!(0, _utils.isEmptySelectionAtEnd)(state) || !dispatch) {
|
|
262
|
-
return false;
|
|
263
|
-
}
|
|
264
258
|
|
|
265
|
-
|
|
266
|
-
|
|
259
|
+
// only run if cursor is at the end of the node
|
|
260
|
+
if (!(0, _utils.isEmptySelectionAtEnd)(state) || !dispatch) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
267
263
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
return false;
|
|
271
|
-
}
|
|
264
|
+
// look for the node after this current one
|
|
265
|
+
var $next = (0, _helpers.walkOut)($from);
|
|
272
266
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
267
|
+
// this is a top-level node it wont have $next.before()
|
|
268
|
+
if (!$next.parent || $next.parent.type === doc) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
277
271
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
var resultOfCurrentFindBlockTaskItem = (0, _utils3.findBlockTaskItem)($next);
|
|
283
|
-
var isCurrentEmptyBlockTaskItem = false;
|
|
284
|
-
if (resultOfCurrentFindBlockTaskItem) {
|
|
285
|
-
var _blockTaskItemNode$fi;
|
|
286
|
-
var blockTaskItemNode = resultOfCurrentFindBlockTaskItem.blockTaskItemNode;
|
|
287
|
-
isCurrentEmptyBlockTaskItem = blockTaskItem && blockTaskItemNode && blockTaskItemNode.childCount === 1 && ((_blockTaskItemNode$fi = blockTaskItemNode.firstChild) === null || _blockTaskItemNode$fi === void 0 ? void 0 : _blockTaskItemNode$fi.type) === paragraph && blockTaskItemNode.firstChild.childCount === 0;
|
|
288
|
-
}
|
|
289
|
-
var isEmptyActionOrDecisionItem = currentNode && (0, _helpers.isActionOrDecisionItem)(currentNode) && currentNode.childCount === 0;
|
|
272
|
+
// get resolved position of parent
|
|
273
|
+
var $parentPos = $from.doc.resolve($from.start($from.depth - 1));
|
|
274
|
+
var currentNode = $from.node();
|
|
275
|
+
var parentNode = $parentPos.node();
|
|
290
276
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
277
|
+
// if current position isn't an action or decision item, return false
|
|
278
|
+
if (!(0, _helpers.isActionOrDecisionItem)(currentNode) && !(0, _helpers.isActionOrDecisionItem)(parentNode)) {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
var resultOfCurrentFindBlockTaskItem = (0, _utils3.findBlockTaskItem)($next);
|
|
282
|
+
var isCurrentEmptyBlockTaskItem = false;
|
|
283
|
+
if (resultOfCurrentFindBlockTaskItem) {
|
|
284
|
+
var _blockTaskItemNode$fi;
|
|
285
|
+
var blockTaskItemNode = resultOfCurrentFindBlockTaskItem.blockTaskItemNode;
|
|
286
|
+
isCurrentEmptyBlockTaskItem = blockTaskItem && blockTaskItemNode && blockTaskItemNode.childCount === 1 && ((_blockTaskItemNode$fi = blockTaskItemNode.firstChild) === null || _blockTaskItemNode$fi === void 0 ? void 0 : _blockTaskItemNode$fi.type) === paragraph && blockTaskItemNode.firstChild.childCount === 0;
|
|
287
|
+
}
|
|
288
|
+
var isEmptyActionOrDecisionItem = currentNode && (0, _helpers.isActionOrDecisionItem)(currentNode) && currentNode.childCount === 0;
|
|
295
289
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
290
|
+
// If empty item, use default handler
|
|
291
|
+
if (isEmptyActionOrDecisionItem || isCurrentEmptyBlockTaskItem) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
299
294
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
295
|
+
// Check if next node is a blockTaskItem paragraph
|
|
296
|
+
var resultOfNextFindBlockTaskItem = (0, _utils3.findBlockTaskItem)($next);
|
|
297
|
+
var isNextInBlockTaskItemParagraph = resultOfNextFindBlockTaskItem && (resultOfNextFindBlockTaskItem === null || resultOfNextFindBlockTaskItem === void 0 ? void 0 : resultOfNextFindBlockTaskItem.hasParagraph);
|
|
298
|
+
|
|
299
|
+
// if nested, just unindent
|
|
300
|
+
if ($next.node($next.depth - 2).type === taskList ||
|
|
301
|
+
// this is for the case when we are on a non-nested item and next one is nested
|
|
302
|
+
$next.node($next.depth - 1).type === taskList && $next.parent.type === taskList) {
|
|
303
|
+
(0, _helpers.liftBlock)(tr, $next, $next);
|
|
304
|
+
dispatch(tr);
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
var isNextCompatibleWithBlockTaskItem = blockTaskItem && (($next === null || $next === void 0 || (_$next$node = $next.node()) === null || _$next$node === void 0 ? void 0 : _$next$node.type) === taskItem && ($from === null || $from === void 0 || (_$from$node = $from.node()) === null || _$from$node === void 0 ? void 0 : _$from$node.type) === blockTaskItem || ($next === null || $next === void 0 || (_$next$node2 = $next.node()) === null || _$next$node2 === void 0 ? void 0 : _$next$node2.type) === blockTaskItem && ($from === null || $from === void 0 || (_$from$node2 = $from.node()) === null || _$from$node2 === void 0 ? void 0 : _$from$node2.type) === taskItem || [taskItem, blockTaskItem].includes($next === null || $next === void 0 || (_$next$node3 = $next.node()) === null || _$next$node3 === void 0 ? void 0 : _$next$node3.type) && resultOfCurrentFindBlockTaskItem && resultOfCurrentFindBlockTaskItem.blockTaskItemNode);
|
|
308
|
+
|
|
309
|
+
// if next node is of same type or compatible type, remove the node wrapping and create paragraph
|
|
310
|
+
if (!(0, _helpers.isTable)($next.nodeAfter) && (0, _helpers.isActionOrDecisionItem)($from.parent) || resultOfCurrentFindBlockTaskItem && resultOfCurrentFindBlockTaskItem.blockTaskItemNode && actionDecisionFollowsOrNothing($from) && (
|
|
311
|
+
// only forward delete if the node is same type or compatible
|
|
312
|
+
$next.node().type.name === $from.node().type.name || isNextCompatibleWithBlockTaskItem)) {
|
|
313
|
+
if (dispatch) {
|
|
314
|
+
// If next node is in a blockTaskItem paragraph, we need to get the content of the whole blockTaskItem
|
|
315
|
+
// So we reduce the depth by 1 to get to the blockTaskItem node content
|
|
316
|
+
var taskContent = isNextInBlockTaskItemParagraph ? state.doc.slice($next.start($next.depth - 1), $next.end($next.depth - 1)).content : state.doc.slice($next.start(), $next.end()).content;
|
|
317
|
+
var slice;
|
|
318
|
+
try {
|
|
319
|
+
slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
|
|
320
|
+
|
|
321
|
+
// might be end of document after
|
|
322
|
+
var _tr2 = splitListItemWith(state.tr, slice, $next, false);
|
|
323
|
+
dispatch(_tr2);
|
|
324
|
+
return true;
|
|
325
|
+
} catch (_unused2) {
|
|
326
|
+
// If there's an error creating a paragraph, check if we are in a blockTaskItem
|
|
327
|
+
// Block task item's can have non-text content that cannot be wrapped in a paragraph
|
|
328
|
+
// So if the selection is in a blockTaskItem, just pass the content as is
|
|
329
|
+
if (resultOfNextFindBlockTaskItem && resultOfNextFindBlockTaskItem.blockTaskItemNode) {
|
|
330
|
+
var _$next$node$firstChil;
|
|
331
|
+
// Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
|
|
332
|
+
slice = Array.from(taskContent.content);
|
|
333
|
+
var $splitPos = $next;
|
|
334
|
+
if ((_$next$node$firstChil = $next.node().firstChild) !== null && _$next$node$firstChil !== void 0 && _$next$node$firstChil.isTextblock) {
|
|
335
|
+
// set $next to the resolved position of inside the textblock
|
|
336
|
+
$splitPos = $next.doc.resolve($next.pos + 1);
|
|
342
337
|
}
|
|
338
|
+
var _tr3 = splitListItemWith(state.tr, slice, $splitPos, false);
|
|
339
|
+
dispatch(_tr3);
|
|
340
|
+
return true;
|
|
343
341
|
}
|
|
344
342
|
}
|
|
345
343
|
}
|
|
346
|
-
} else {
|
|
347
|
-
// only run if cursor is at the end of the node
|
|
348
|
-
if (!(0, _utils.isEmptySelectionAtEnd)(state) || !dispatch) {
|
|
349
|
-
return false;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// look for the node after this current one
|
|
353
|
-
var _$next = (0, _helpers.walkOut)($from);
|
|
354
|
-
|
|
355
|
-
// this is a top-level node it wont have $next.before()
|
|
356
|
-
if (!_$next.parent || _$next.parent.type === doc) {
|
|
357
|
-
return false;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// if nested, just unindent
|
|
361
|
-
if (_$next.node(_$next.depth - 2).type === taskList ||
|
|
362
|
-
// this is for the case when we are on a non-nested item and next one is nested
|
|
363
|
-
_$next.node(_$next.depth - 1).type === taskList && _$next.parent.type === taskList) {
|
|
364
|
-
(0, _helpers.liftBlock)(tr, _$next, _$next);
|
|
365
|
-
dispatch(tr);
|
|
366
|
-
return true;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// if next node is of same type, remove the node wrapping and create paragraph
|
|
370
|
-
if (!(0, _helpers.isTable)(_$next.nodeAfter) && (0, _helpers.isActionOrDecisionItem)($from.parent) && actionDecisionFollowsOrNothing($from) &&
|
|
371
|
-
// only forward delete if the node is same type
|
|
372
|
-
_$next.node().type.name === $from.node().type.name) {
|
|
373
|
-
var _taskContent = state.doc.slice(_$next.start(), _$next.end()).content;
|
|
374
|
-
|
|
375
|
-
// might be end of document after
|
|
376
|
-
var _slice = _taskContent.size ? paragraph.createChecked(undefined, _taskContent) : [];
|
|
377
|
-
dispatch(splitListItemWith(tr, _slice, _$next, false));
|
|
378
|
-
return true;
|
|
379
|
-
}
|
|
380
344
|
}
|
|
381
345
|
return false;
|
|
382
346
|
};
|
|
@@ -430,7 +394,7 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
|
|
|
430
394
|
if (result) {
|
|
431
395
|
var blockTaskItemNode = result.blockTaskItemNode,
|
|
432
396
|
hasParagraph = result.hasParagraph;
|
|
433
|
-
hasBlockTaskItem =
|
|
397
|
+
hasBlockTaskItem = !!blockTaskItemNode;
|
|
434
398
|
if (blockTaskItemNode) {
|
|
435
399
|
var _$oldAfter$nodeAfter, _$posPreviousSibling$;
|
|
436
400
|
// If the case there is a paragraph in the block task item we need to
|
|
@@ -476,9 +440,7 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
|
|
|
476
440
|
if (shouldSplit && !isNestedActionInsideLists) {
|
|
477
441
|
// this only splits a node to delete it, so we probably don't need a random uuid
|
|
478
442
|
// but generate one anyway for correctness
|
|
479
|
-
tr = tr.split($from.pos,
|
|
480
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
481
|
-
(0, _platformFeatureFlags.fg)('platform_editor_blocktaskitem_patch_3') && hasBlockTaskItem ? 0 : 1, [{
|
|
443
|
+
tr = tr.split($from.pos, hasBlockTaskItem ? 0 : 1, [{
|
|
482
444
|
type: $from.parent.type,
|
|
483
445
|
attrs: {
|
|
484
446
|
localId: _adfSchema.uuid.generate()
|
|
@@ -545,17 +507,15 @@ var splitListItem = function splitListItem(state, dispatch) {
|
|
|
545
507
|
paragraph = _state$schema$nodes5.paragraph;
|
|
546
508
|
if (actionDecisionFollowsOrNothing($from)) {
|
|
547
509
|
if (dispatch) {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
if (
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
return true;
|
|
558
|
-
}
|
|
510
|
+
// If previous node is a blockTaskItem we just want to delete the existing node and replace it with a paragraph
|
|
511
|
+
var nodeBefore = state.doc.resolve($from.pos - 1).nodeBefore;
|
|
512
|
+
if (blockTaskItem && (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type) === blockTaskItem) {
|
|
513
|
+
if ($from.parent.type === taskItem) {
|
|
514
|
+
var nodeSize = $from.parent.nodeSize;
|
|
515
|
+
tr.delete($from.pos - Math.floor(nodeSize / 2), $from.pos + Math.ceil(nodeSize / 2));
|
|
516
|
+
tr.insert($from.pos, paragraph.createChecked());
|
|
517
|
+
dispatch(tr);
|
|
518
|
+
return true;
|
|
559
519
|
}
|
|
560
520
|
}
|
|
561
521
|
if ((0, _utils2.hasParentNodeOfType)(listItem)(tr.selection)) {
|
|
@@ -171,7 +171,7 @@ var RequestToEditPopup = exports.RequestToEditPopup = function RequestToEditPopu
|
|
|
171
171
|
}), /*#__PURE__*/React.createElement("div", {
|
|
172
172
|
className: (0, _runtime.ax)(["_19pku2gc _otyru2gc _18u0u2gc _2hwxu2gc _1e0c1o8l _1bsbyh40 _4t3iyh40 _bfhk16e3", "_2rko1rr0"])
|
|
173
173
|
}), /*#__PURE__*/React.createElement(_compiled.Box, null, /*#__PURE__*/React.createElement(_compiled.Pressable
|
|
174
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
174
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
175
175
|
, {
|
|
176
176
|
onClick: function onClick() {
|
|
177
177
|
var _api$analytics2;
|
|
@@ -123,7 +123,7 @@ var TaskItemWithProviders = exports.default = /*#__PURE__*/function (_Component)
|
|
|
123
123
|
objectId = _ref.objectId;
|
|
124
124
|
var userContext = objectId ? 'edit' : 'new';
|
|
125
125
|
return /*#__PURE__*/_react.default.createElement(_analyticsNamespacedContext.FabricElementsAnalyticsContext
|
|
126
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
126
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
127
127
|
, {
|
|
128
128
|
data: {
|
|
129
129
|
userContext: userContext
|
|
@@ -4,7 +4,6 @@ import { NodeRange } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
|
|
6
6
|
import { findParentNodeClosestToPos, findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
8
|
import { stateKey } from './plugin-key';
|
|
10
9
|
import { ACTIONS } from './types';
|
|
@@ -242,7 +241,7 @@ export const subtreeHeight = ($from, $to, types) => {
|
|
|
242
241
|
// and get the max height from the current position to the
|
|
243
242
|
// deepest leaf node
|
|
244
243
|
let maxChildDepth = $from.depth;
|
|
245
|
-
$from.doc.nodesBetween(blockRange.start, blockRange.end, (descendent, relPos,
|
|
244
|
+
$from.doc.nodesBetween(blockRange.start, blockRange.end, (descendent, relPos, _parent) => {
|
|
246
245
|
maxChildDepth = Math.max($from.doc.resolve(relPos).depth, maxChildDepth);
|
|
247
246
|
|
|
248
247
|
// keep descending down the tree if we can
|
|
@@ -281,7 +280,7 @@ export const isEmptyTaskDecision = state => {
|
|
|
281
280
|
// If in an empty paragraph that's not at the doc level
|
|
282
281
|
node.content.size === 0 && node.type === paragraph && $from.depth > 0 &&
|
|
283
282
|
// and it's parent is a blockTaskItem with only this paragraph inside it
|
|
284
|
-
$from.node($from.depth - 1).type === blockTaskItem && $from.node($from.depth - 1).childCount === 1
|
|
283
|
+
$from.node($from.depth - 1).type === blockTaskItem && $from.node($from.depth - 1).childCount === 1;
|
|
285
284
|
return isEmptyTaskOrDecisionItem || isInEmptyBlockTaskItem;
|
|
286
285
|
};
|
|
287
286
|
|
|
@@ -10,7 +10,6 @@ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
|
10
10
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
11
11
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
12
|
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
13
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
13
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
14
|
import { moveSelectedTaskListItems } from './actions/move-selected-task-list-items';
|
|
16
15
|
import { joinAtCut, liftSelection, wrapSelectionInTaskList } from './commands';
|
|
@@ -215,6 +214,7 @@ const backspaceFrom = editorAnalyticsAPI => $from => (state, dispatch) => {
|
|
|
215
214
|
};
|
|
216
215
|
const backspace = editorAnalyticsAPI => filter(isEmptySelectionAtStart, autoJoin(chainCommands((state, dispatch) => joinAtCut(state.selection.$from)(state, dispatch), filter(isInsideTaskOrDecisionItem, (state, dispatch) => backspaceFrom(editorAnalyticsAPI)(state.selection.$from)(state, dispatch))), ['taskList', 'decisionList']));
|
|
217
216
|
const unindentTaskOrUnwrapTaskDecisionFollowing = (state, dispatch) => {
|
|
217
|
+
var _$next$node, _$from$node, _$next$node2, _$from$node2, _$next$node3;
|
|
218
218
|
const {
|
|
219
219
|
selection: {
|
|
220
220
|
$from
|
|
@@ -230,130 +230,94 @@ const unindentTaskOrUnwrapTaskDecisionFollowing = (state, dispatch) => {
|
|
|
230
230
|
},
|
|
231
231
|
tr
|
|
232
232
|
} = state;
|
|
233
|
-
if (fg('platform_editor_blocktaskitem_patch_3')) {
|
|
234
|
-
var _$next$node, _$from$node, _$next$node2, _$from$node2, _$next$node3;
|
|
235
|
-
// only run if cursor is at the end of the node
|
|
236
|
-
if (!isEmptySelectionAtEnd(state) || !dispatch) {
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
233
|
|
|
240
|
-
|
|
241
|
-
|
|
234
|
+
// only run if cursor is at the end of the node
|
|
235
|
+
if (!isEmptySelectionAtEnd(state) || !dispatch) {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
242
238
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
239
|
+
// look for the node after this current one
|
|
240
|
+
const $next = walkOut($from);
|
|
247
241
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
242
|
+
// this is a top-level node it wont have $next.before()
|
|
243
|
+
if (!$next.parent || $next.parent.type === doc) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
252
246
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const resultOfCurrentFindBlockTaskItem = findBlockTaskItem($next);
|
|
258
|
-
let isCurrentEmptyBlockTaskItem = false;
|
|
259
|
-
if (resultOfCurrentFindBlockTaskItem) {
|
|
260
|
-
var _blockTaskItemNode$fi;
|
|
261
|
-
const {
|
|
262
|
-
blockTaskItemNode
|
|
263
|
-
} = resultOfCurrentFindBlockTaskItem;
|
|
264
|
-
isCurrentEmptyBlockTaskItem = blockTaskItem && blockTaskItemNode && blockTaskItemNode.childCount === 1 && ((_blockTaskItemNode$fi = blockTaskItemNode.firstChild) === null || _blockTaskItemNode$fi === void 0 ? void 0 : _blockTaskItemNode$fi.type) === paragraph && blockTaskItemNode.firstChild.childCount === 0;
|
|
265
|
-
}
|
|
266
|
-
const isEmptyActionOrDecisionItem = currentNode && isActionOrDecisionItem(currentNode) && currentNode.childCount === 0;
|
|
247
|
+
// get resolved position of parent
|
|
248
|
+
const $parentPos = $from.doc.resolve($from.start($from.depth - 1));
|
|
249
|
+
const currentNode = $from.node();
|
|
250
|
+
const parentNode = $parentPos.node();
|
|
267
251
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
252
|
+
// if current position isn't an action or decision item, return false
|
|
253
|
+
if (!isActionOrDecisionItem(currentNode) && !isActionOrDecisionItem(parentNode)) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
const resultOfCurrentFindBlockTaskItem = findBlockTaskItem($next);
|
|
257
|
+
let isCurrentEmptyBlockTaskItem = false;
|
|
258
|
+
if (resultOfCurrentFindBlockTaskItem) {
|
|
259
|
+
var _blockTaskItemNode$fi;
|
|
260
|
+
const {
|
|
261
|
+
blockTaskItemNode
|
|
262
|
+
} = resultOfCurrentFindBlockTaskItem;
|
|
263
|
+
isCurrentEmptyBlockTaskItem = blockTaskItem && blockTaskItemNode && blockTaskItemNode.childCount === 1 && ((_blockTaskItemNode$fi = blockTaskItemNode.firstChild) === null || _blockTaskItemNode$fi === void 0 ? void 0 : _blockTaskItemNode$fi.type) === paragraph && blockTaskItemNode.firstChild.childCount === 0;
|
|
264
|
+
}
|
|
265
|
+
const isEmptyActionOrDecisionItem = currentNode && isActionOrDecisionItem(currentNode) && currentNode.childCount === 0;
|
|
266
|
+
|
|
267
|
+
// If empty item, use default handler
|
|
268
|
+
if (isEmptyActionOrDecisionItem || isCurrentEmptyBlockTaskItem) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
272
271
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
272
|
+
// Check if next node is a blockTaskItem paragraph
|
|
273
|
+
const resultOfNextFindBlockTaskItem = findBlockTaskItem($next);
|
|
274
|
+
const isNextInBlockTaskItemParagraph = resultOfNextFindBlockTaskItem && (resultOfNextFindBlockTaskItem === null || resultOfNextFindBlockTaskItem === void 0 ? void 0 : resultOfNextFindBlockTaskItem.hasParagraph);
|
|
276
275
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
276
|
+
// if nested, just unindent
|
|
277
|
+
if ($next.node($next.depth - 2).type === taskList ||
|
|
278
|
+
// this is for the case when we are on a non-nested item and next one is nested
|
|
279
|
+
$next.node($next.depth - 1).type === taskList && $next.parent.type === taskList) {
|
|
280
|
+
liftBlock(tr, $next, $next);
|
|
281
|
+
dispatch(tr);
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
const isNextCompatibleWithBlockTaskItem = blockTaskItem && (($next === null || $next === void 0 ? void 0 : (_$next$node = $next.node()) === null || _$next$node === void 0 ? void 0 : _$next$node.type) === taskItem && ($from === null || $from === void 0 ? void 0 : (_$from$node = $from.node()) === null || _$from$node === void 0 ? void 0 : _$from$node.type) === blockTaskItem || ($next === null || $next === void 0 ? void 0 : (_$next$node2 = $next.node()) === null || _$next$node2 === void 0 ? void 0 : _$next$node2.type) === blockTaskItem && ($from === null || $from === void 0 ? void 0 : (_$from$node2 = $from.node()) === null || _$from$node2 === void 0 ? void 0 : _$from$node2.type) === taskItem || [taskItem, blockTaskItem].includes($next === null || $next === void 0 ? void 0 : (_$next$node3 = $next.node()) === null || _$next$node3 === void 0 ? void 0 : _$next$node3.type) && resultOfCurrentFindBlockTaskItem && resultOfCurrentFindBlockTaskItem.blockTaskItemNode);
|
|
285
|
+
|
|
286
|
+
// if next node is of same type or compatible type, remove the node wrapping and create paragraph
|
|
287
|
+
if (!isTable($next.nodeAfter) && isActionOrDecisionItem($from.parent) || resultOfCurrentFindBlockTaskItem && resultOfCurrentFindBlockTaskItem.blockTaskItemNode && actionDecisionFollowsOrNothing($from) && (
|
|
288
|
+
// only forward delete if the node is same type or compatible
|
|
289
|
+
$next.node().type.name === $from.node().type.name || isNextCompatibleWithBlockTaskItem)) {
|
|
290
|
+
if (dispatch) {
|
|
291
|
+
// If next node is in a blockTaskItem paragraph, we need to get the content of the whole blockTaskItem
|
|
292
|
+
// So we reduce the depth by 1 to get to the blockTaskItem node content
|
|
293
|
+
const taskContent = isNextInBlockTaskItemParagraph ? state.doc.slice($next.start($next.depth - 1), $next.end($next.depth - 1)).content : state.doc.slice($next.start(), $next.end()).content;
|
|
294
|
+
let slice;
|
|
295
|
+
try {
|
|
296
|
+
slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
|
|
297
|
+
|
|
298
|
+
// might be end of document after
|
|
299
|
+
const tr = splitListItemWith(state.tr, slice, $next, false);
|
|
300
|
+
dispatch(tr);
|
|
301
|
+
return true;
|
|
302
|
+
} catch {
|
|
303
|
+
// If there's an error creating a paragraph, check if we are in a blockTaskItem
|
|
304
|
+
// Block task item's can have non-text content that cannot be wrapped in a paragraph
|
|
305
|
+
// So if the selection is in a blockTaskItem, just pass the content as is
|
|
306
|
+
if (resultOfNextFindBlockTaskItem && resultOfNextFindBlockTaskItem.blockTaskItemNode) {
|
|
307
|
+
var _$next$node$firstChil;
|
|
308
|
+
// Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
|
|
309
|
+
slice = Array.from(taskContent.content);
|
|
310
|
+
let $splitPos = $next;
|
|
311
|
+
if ((_$next$node$firstChil = $next.node().firstChild) !== null && _$next$node$firstChil !== void 0 && _$next$node$firstChil.isTextblock) {
|
|
312
|
+
// set $next to the resolved position of inside the textblock
|
|
313
|
+
$splitPos = $next.doc.resolve($next.pos + 1);
|
|
314
|
+
}
|
|
315
|
+
const tr = splitListItemWith(state.tr, slice, $splitPos, false);
|
|
301
316
|
dispatch(tr);
|
|
302
317
|
return true;
|
|
303
|
-
} catch {
|
|
304
|
-
// If there's an error creating a paragraph, check if we are in a blockTaskItem
|
|
305
|
-
// Block task item's can have non-text content that cannot be wrapped in a paragraph
|
|
306
|
-
// So if the selection is in a blockTaskItem, just pass the content as is
|
|
307
|
-
if (resultOfNextFindBlockTaskItem && resultOfNextFindBlockTaskItem.blockTaskItemNode) {
|
|
308
|
-
var _$next$node$firstChil;
|
|
309
|
-
// Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
|
|
310
|
-
slice = Array.from(taskContent.content);
|
|
311
|
-
let $splitPos = $next;
|
|
312
|
-
if ((_$next$node$firstChil = $next.node().firstChild) !== null && _$next$node$firstChil !== void 0 && _$next$node$firstChil.isTextblock) {
|
|
313
|
-
// set $next to the resolved position of inside the textblock
|
|
314
|
-
$splitPos = $next.doc.resolve($next.pos + 1);
|
|
315
|
-
}
|
|
316
|
-
const tr = splitListItemWith(state.tr, slice, $splitPos, false);
|
|
317
|
-
dispatch(tr);
|
|
318
|
-
return true;
|
|
319
|
-
}
|
|
320
318
|
}
|
|
321
319
|
}
|
|
322
320
|
}
|
|
323
|
-
} else {
|
|
324
|
-
// only run if cursor is at the end of the node
|
|
325
|
-
if (!isEmptySelectionAtEnd(state) || !dispatch) {
|
|
326
|
-
return false;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// look for the node after this current one
|
|
330
|
-
const $next = walkOut($from);
|
|
331
|
-
|
|
332
|
-
// this is a top-level node it wont have $next.before()
|
|
333
|
-
if (!$next.parent || $next.parent.type === doc) {
|
|
334
|
-
return false;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// if nested, just unindent
|
|
338
|
-
if ($next.node($next.depth - 2).type === taskList ||
|
|
339
|
-
// this is for the case when we are on a non-nested item and next one is nested
|
|
340
|
-
$next.node($next.depth - 1).type === taskList && $next.parent.type === taskList) {
|
|
341
|
-
liftBlock(tr, $next, $next);
|
|
342
|
-
dispatch(tr);
|
|
343
|
-
return true;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// if next node is of same type, remove the node wrapping and create paragraph
|
|
347
|
-
if (!isTable($next.nodeAfter) && isActionOrDecisionItem($from.parent) && actionDecisionFollowsOrNothing($from) &&
|
|
348
|
-
// only forward delete if the node is same type
|
|
349
|
-
$next.node().type.name === $from.node().type.name) {
|
|
350
|
-
const taskContent = state.doc.slice($next.start(), $next.end()).content;
|
|
351
|
-
|
|
352
|
-
// might be end of document after
|
|
353
|
-
const slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : [];
|
|
354
|
-
dispatch(splitListItemWith(tr, slice, $next, false));
|
|
355
|
-
return true;
|
|
356
|
-
}
|
|
357
321
|
}
|
|
358
322
|
return false;
|
|
359
323
|
};
|
|
@@ -410,7 +374,7 @@ const splitListItemWith = (tr, content, $from, setSelection) => {
|
|
|
410
374
|
blockTaskItemNode,
|
|
411
375
|
hasParagraph
|
|
412
376
|
} = result;
|
|
413
|
-
hasBlockTaskItem =
|
|
377
|
+
hasBlockTaskItem = !!blockTaskItemNode;
|
|
414
378
|
if (blockTaskItemNode) {
|
|
415
379
|
var _$oldAfter$nodeAfter, _$posPreviousSibling$;
|
|
416
380
|
// If the case there is a paragraph in the block task item we need to
|
|
@@ -456,9 +420,7 @@ const splitListItemWith = (tr, content, $from, setSelection) => {
|
|
|
456
420
|
if (shouldSplit && !isNestedActionInsideLists) {
|
|
457
421
|
// this only splits a node to delete it, so we probably don't need a random uuid
|
|
458
422
|
// but generate one anyway for correctness
|
|
459
|
-
tr = tr.split($from.pos,
|
|
460
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
461
|
-
fg('platform_editor_blocktaskitem_patch_3') && hasBlockTaskItem ? 0 : 1, [{
|
|
423
|
+
tr = tr.split($from.pos, hasBlockTaskItem ? 0 : 1, [{
|
|
462
424
|
type: $from.parent.type,
|
|
463
425
|
attrs: {
|
|
464
426
|
localId: uuid.generate()
|
|
@@ -530,17 +492,15 @@ const splitListItem = (state, dispatch) => {
|
|
|
530
492
|
} = state.schema.nodes;
|
|
531
493
|
if (actionDecisionFollowsOrNothing($from)) {
|
|
532
494
|
if (dispatch) {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
if (
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
return true;
|
|
543
|
-
}
|
|
495
|
+
// If previous node is a blockTaskItem we just want to delete the existing node and replace it with a paragraph
|
|
496
|
+
const nodeBefore = state.doc.resolve($from.pos - 1).nodeBefore;
|
|
497
|
+
if (blockTaskItem && (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type) === blockTaskItem) {
|
|
498
|
+
if ($from.parent.type === taskItem) {
|
|
499
|
+
const nodeSize = $from.parent.nodeSize;
|
|
500
|
+
tr.delete($from.pos - Math.floor(nodeSize / 2), $from.pos + Math.ceil(nodeSize / 2));
|
|
501
|
+
tr.insert($from.pos, paragraph.createChecked());
|
|
502
|
+
dispatch(tr);
|
|
503
|
+
return true;
|
|
544
504
|
}
|
|
545
505
|
}
|
|
546
506
|
if (hasParentNodeOfType(listItem)(tr.selection)) {
|
|
@@ -156,7 +156,7 @@ export const RequestToEditPopup = ({
|
|
|
156
156
|
}), /*#__PURE__*/React.createElement("div", {
|
|
157
157
|
className: ax(["_19pku2gc _otyru2gc _18u0u2gc _2hwxu2gc _1e0c1o8l _1bsbyh40 _4t3iyh40 _bfhk16e3", "_2rko1rr0"])
|
|
158
158
|
}), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Pressable
|
|
159
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
159
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
160
160
|
, {
|
|
161
161
|
onClick: () => {
|
|
162
162
|
var _api$analytics2;
|
|
@@ -62,7 +62,7 @@ export default class TaskItemWithProviders extends Component {
|
|
|
62
62
|
} = this.state.resolvedContextProvider || {};
|
|
63
63
|
const userContext = objectId ? 'edit' : 'new';
|
|
64
64
|
return /*#__PURE__*/React.createElement(FabricElementsAnalyticsContext
|
|
65
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
65
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
66
66
|
, {
|
|
67
67
|
data: {
|
|
68
68
|
userContext
|
|
@@ -4,7 +4,6 @@ import { NodeRange } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
|
|
6
6
|
import { findParentNodeClosestToPos, findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
8
|
import { stateKey } from './plugin-key';
|
|
10
9
|
import { ACTIONS } from './types';
|
|
@@ -236,7 +235,7 @@ export var subtreeHeight = function subtreeHeight($from, $to, types) {
|
|
|
236
235
|
// and get the max height from the current position to the
|
|
237
236
|
// deepest leaf node
|
|
238
237
|
var maxChildDepth = $from.depth;
|
|
239
|
-
$from.doc.nodesBetween(blockRange.start, blockRange.end, function (descendent, relPos,
|
|
238
|
+
$from.doc.nodesBetween(blockRange.start, blockRange.end, function (descendent, relPos, _parent) {
|
|
240
239
|
maxChildDepth = Math.max($from.doc.resolve(relPos).depth, maxChildDepth);
|
|
241
240
|
|
|
242
241
|
// keep descending down the tree if we can
|
|
@@ -270,7 +269,7 @@ export var isEmptyTaskDecision = function isEmptyTaskDecision(state) {
|
|
|
270
269
|
// If in an empty paragraph that's not at the doc level
|
|
271
270
|
node.content.size === 0 && node.type === paragraph && $from.depth > 0 &&
|
|
272
271
|
// and it's parent is a blockTaskItem with only this paragraph inside it
|
|
273
|
-
$from.node($from.depth - 1).type === blockTaskItem && $from.node($from.depth - 1).childCount === 1
|
|
272
|
+
$from.node($from.depth - 1).type === blockTaskItem && $from.node($from.depth - 1).childCount === 1;
|
|
274
273
|
return isEmptyTaskOrDecisionItem || isInEmptyBlockTaskItem;
|
|
275
274
|
};
|
|
276
275
|
|
|
@@ -13,7 +13,6 @@ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
|
13
13
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
14
14
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
15
15
|
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
16
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
16
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
18
17
|
import { moveSelectedTaskListItems } from './actions/move-selected-task-list-items';
|
|
19
18
|
import { joinAtCut, liftSelection, wrapSelectionInTaskList } from './commands';
|
|
@@ -239,6 +238,7 @@ var backspace = function backspace(editorAnalyticsAPI) {
|
|
|
239
238
|
})), ['taskList', 'decisionList']));
|
|
240
239
|
};
|
|
241
240
|
var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTaskDecisionFollowing(state, dispatch) {
|
|
241
|
+
var _$next$node, _$from$node, _$next$node2, _$from$node2, _$next$node3;
|
|
242
242
|
var $from = state.selection.$from,
|
|
243
243
|
_state$schema$nodes4 = state.schema.nodes,
|
|
244
244
|
taskList = _state$schema$nodes4.taskList,
|
|
@@ -247,128 +247,92 @@ var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTas
|
|
|
247
247
|
blockTaskItem = _state$schema$nodes4.blockTaskItem,
|
|
248
248
|
taskItem = _state$schema$nodes4.taskItem,
|
|
249
249
|
tr = state.tr;
|
|
250
|
-
if (fg('platform_editor_blocktaskitem_patch_3')) {
|
|
251
|
-
var _$next$node, _$from$node, _$next$node2, _$from$node2, _$next$node3;
|
|
252
|
-
// only run if cursor is at the end of the node
|
|
253
|
-
if (!isEmptySelectionAtEnd(state) || !dispatch) {
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
250
|
|
|
257
|
-
|
|
258
|
-
|
|
251
|
+
// only run if cursor is at the end of the node
|
|
252
|
+
if (!isEmptySelectionAtEnd(state) || !dispatch) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
259
255
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return false;
|
|
263
|
-
}
|
|
256
|
+
// look for the node after this current one
|
|
257
|
+
var $next = walkOut($from);
|
|
264
258
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
259
|
+
// this is a top-level node it wont have $next.before()
|
|
260
|
+
if (!$next.parent || $next.parent.type === doc) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
269
263
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
var resultOfCurrentFindBlockTaskItem = findBlockTaskItem($next);
|
|
275
|
-
var isCurrentEmptyBlockTaskItem = false;
|
|
276
|
-
if (resultOfCurrentFindBlockTaskItem) {
|
|
277
|
-
var _blockTaskItemNode$fi;
|
|
278
|
-
var blockTaskItemNode = resultOfCurrentFindBlockTaskItem.blockTaskItemNode;
|
|
279
|
-
isCurrentEmptyBlockTaskItem = blockTaskItem && blockTaskItemNode && blockTaskItemNode.childCount === 1 && ((_blockTaskItemNode$fi = blockTaskItemNode.firstChild) === null || _blockTaskItemNode$fi === void 0 ? void 0 : _blockTaskItemNode$fi.type) === paragraph && blockTaskItemNode.firstChild.childCount === 0;
|
|
280
|
-
}
|
|
281
|
-
var isEmptyActionOrDecisionItem = currentNode && isActionOrDecisionItem(currentNode) && currentNode.childCount === 0;
|
|
264
|
+
// get resolved position of parent
|
|
265
|
+
var $parentPos = $from.doc.resolve($from.start($from.depth - 1));
|
|
266
|
+
var currentNode = $from.node();
|
|
267
|
+
var parentNode = $parentPos.node();
|
|
282
268
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
269
|
+
// if current position isn't an action or decision item, return false
|
|
270
|
+
if (!isActionOrDecisionItem(currentNode) && !isActionOrDecisionItem(parentNode)) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
var resultOfCurrentFindBlockTaskItem = findBlockTaskItem($next);
|
|
274
|
+
var isCurrentEmptyBlockTaskItem = false;
|
|
275
|
+
if (resultOfCurrentFindBlockTaskItem) {
|
|
276
|
+
var _blockTaskItemNode$fi;
|
|
277
|
+
var blockTaskItemNode = resultOfCurrentFindBlockTaskItem.blockTaskItemNode;
|
|
278
|
+
isCurrentEmptyBlockTaskItem = blockTaskItem && blockTaskItemNode && blockTaskItemNode.childCount === 1 && ((_blockTaskItemNode$fi = blockTaskItemNode.firstChild) === null || _blockTaskItemNode$fi === void 0 ? void 0 : _blockTaskItemNode$fi.type) === paragraph && blockTaskItemNode.firstChild.childCount === 0;
|
|
279
|
+
}
|
|
280
|
+
var isEmptyActionOrDecisionItem = currentNode && isActionOrDecisionItem(currentNode) && currentNode.childCount === 0;
|
|
287
281
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
282
|
+
// If empty item, use default handler
|
|
283
|
+
if (isEmptyActionOrDecisionItem || isCurrentEmptyBlockTaskItem) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
291
286
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
287
|
+
// Check if next node is a blockTaskItem paragraph
|
|
288
|
+
var resultOfNextFindBlockTaskItem = findBlockTaskItem($next);
|
|
289
|
+
var isNextInBlockTaskItemParagraph = resultOfNextFindBlockTaskItem && (resultOfNextFindBlockTaskItem === null || resultOfNextFindBlockTaskItem === void 0 ? void 0 : resultOfNextFindBlockTaskItem.hasParagraph);
|
|
290
|
+
|
|
291
|
+
// if nested, just unindent
|
|
292
|
+
if ($next.node($next.depth - 2).type === taskList ||
|
|
293
|
+
// this is for the case when we are on a non-nested item and next one is nested
|
|
294
|
+
$next.node($next.depth - 1).type === taskList && $next.parent.type === taskList) {
|
|
295
|
+
liftBlock(tr, $next, $next);
|
|
296
|
+
dispatch(tr);
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
var isNextCompatibleWithBlockTaskItem = blockTaskItem && (($next === null || $next === void 0 || (_$next$node = $next.node()) === null || _$next$node === void 0 ? void 0 : _$next$node.type) === taskItem && ($from === null || $from === void 0 || (_$from$node = $from.node()) === null || _$from$node === void 0 ? void 0 : _$from$node.type) === blockTaskItem || ($next === null || $next === void 0 || (_$next$node2 = $next.node()) === null || _$next$node2 === void 0 ? void 0 : _$next$node2.type) === blockTaskItem && ($from === null || $from === void 0 || (_$from$node2 = $from.node()) === null || _$from$node2 === void 0 ? void 0 : _$from$node2.type) === taskItem || [taskItem, blockTaskItem].includes($next === null || $next === void 0 || (_$next$node3 = $next.node()) === null || _$next$node3 === void 0 ? void 0 : _$next$node3.type) && resultOfCurrentFindBlockTaskItem && resultOfCurrentFindBlockTaskItem.blockTaskItemNode);
|
|
300
|
+
|
|
301
|
+
// if next node is of same type or compatible type, remove the node wrapping and create paragraph
|
|
302
|
+
if (!isTable($next.nodeAfter) && isActionOrDecisionItem($from.parent) || resultOfCurrentFindBlockTaskItem && resultOfCurrentFindBlockTaskItem.blockTaskItemNode && actionDecisionFollowsOrNothing($from) && (
|
|
303
|
+
// only forward delete if the node is same type or compatible
|
|
304
|
+
$next.node().type.name === $from.node().type.name || isNextCompatibleWithBlockTaskItem)) {
|
|
305
|
+
if (dispatch) {
|
|
306
|
+
// If next node is in a blockTaskItem paragraph, we need to get the content of the whole blockTaskItem
|
|
307
|
+
// So we reduce the depth by 1 to get to the blockTaskItem node content
|
|
308
|
+
var taskContent = isNextInBlockTaskItemParagraph ? state.doc.slice($next.start($next.depth - 1), $next.end($next.depth - 1)).content : state.doc.slice($next.start(), $next.end()).content;
|
|
309
|
+
var slice;
|
|
310
|
+
try {
|
|
311
|
+
slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
|
|
312
|
+
|
|
313
|
+
// might be end of document after
|
|
314
|
+
var _tr2 = splitListItemWith(state.tr, slice, $next, false);
|
|
315
|
+
dispatch(_tr2);
|
|
316
|
+
return true;
|
|
317
|
+
} catch (_unused2) {
|
|
318
|
+
// If there's an error creating a paragraph, check if we are in a blockTaskItem
|
|
319
|
+
// Block task item's can have non-text content that cannot be wrapped in a paragraph
|
|
320
|
+
// So if the selection is in a blockTaskItem, just pass the content as is
|
|
321
|
+
if (resultOfNextFindBlockTaskItem && resultOfNextFindBlockTaskItem.blockTaskItemNode) {
|
|
322
|
+
var _$next$node$firstChil;
|
|
323
|
+
// Create an array from the fragment to pass into splitListItemWith, as the `content` property is readonly
|
|
324
|
+
slice = Array.from(taskContent.content);
|
|
325
|
+
var $splitPos = $next;
|
|
326
|
+
if ((_$next$node$firstChil = $next.node().firstChild) !== null && _$next$node$firstChil !== void 0 && _$next$node$firstChil.isTextblock) {
|
|
327
|
+
// set $next to the resolved position of inside the textblock
|
|
328
|
+
$splitPos = $next.doc.resolve($next.pos + 1);
|
|
334
329
|
}
|
|
330
|
+
var _tr3 = splitListItemWith(state.tr, slice, $splitPos, false);
|
|
331
|
+
dispatch(_tr3);
|
|
332
|
+
return true;
|
|
335
333
|
}
|
|
336
334
|
}
|
|
337
335
|
}
|
|
338
|
-
} else {
|
|
339
|
-
// only run if cursor is at the end of the node
|
|
340
|
-
if (!isEmptySelectionAtEnd(state) || !dispatch) {
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// look for the node after this current one
|
|
345
|
-
var _$next = walkOut($from);
|
|
346
|
-
|
|
347
|
-
// this is a top-level node it wont have $next.before()
|
|
348
|
-
if (!_$next.parent || _$next.parent.type === doc) {
|
|
349
|
-
return false;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// if nested, just unindent
|
|
353
|
-
if (_$next.node(_$next.depth - 2).type === taskList ||
|
|
354
|
-
// this is for the case when we are on a non-nested item and next one is nested
|
|
355
|
-
_$next.node(_$next.depth - 1).type === taskList && _$next.parent.type === taskList) {
|
|
356
|
-
liftBlock(tr, _$next, _$next);
|
|
357
|
-
dispatch(tr);
|
|
358
|
-
return true;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// if next node is of same type, remove the node wrapping and create paragraph
|
|
362
|
-
if (!isTable(_$next.nodeAfter) && isActionOrDecisionItem($from.parent) && actionDecisionFollowsOrNothing($from) &&
|
|
363
|
-
// only forward delete if the node is same type
|
|
364
|
-
_$next.node().type.name === $from.node().type.name) {
|
|
365
|
-
var _taskContent = state.doc.slice(_$next.start(), _$next.end()).content;
|
|
366
|
-
|
|
367
|
-
// might be end of document after
|
|
368
|
-
var _slice = _taskContent.size ? paragraph.createChecked(undefined, _taskContent) : [];
|
|
369
|
-
dispatch(splitListItemWith(tr, _slice, _$next, false));
|
|
370
|
-
return true;
|
|
371
|
-
}
|
|
372
336
|
}
|
|
373
337
|
return false;
|
|
374
338
|
};
|
|
@@ -422,7 +386,7 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
|
|
|
422
386
|
if (result) {
|
|
423
387
|
var blockTaskItemNode = result.blockTaskItemNode,
|
|
424
388
|
hasParagraph = result.hasParagraph;
|
|
425
|
-
hasBlockTaskItem =
|
|
389
|
+
hasBlockTaskItem = !!blockTaskItemNode;
|
|
426
390
|
if (blockTaskItemNode) {
|
|
427
391
|
var _$oldAfter$nodeAfter, _$posPreviousSibling$;
|
|
428
392
|
// If the case there is a paragraph in the block task item we need to
|
|
@@ -468,9 +432,7 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
|
|
|
468
432
|
if (shouldSplit && !isNestedActionInsideLists) {
|
|
469
433
|
// this only splits a node to delete it, so we probably don't need a random uuid
|
|
470
434
|
// but generate one anyway for correctness
|
|
471
|
-
tr = tr.split($from.pos,
|
|
472
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
473
|
-
fg('platform_editor_blocktaskitem_patch_3') && hasBlockTaskItem ? 0 : 1, [{
|
|
435
|
+
tr = tr.split($from.pos, hasBlockTaskItem ? 0 : 1, [{
|
|
474
436
|
type: $from.parent.type,
|
|
475
437
|
attrs: {
|
|
476
438
|
localId: uuid.generate()
|
|
@@ -537,17 +499,15 @@ var splitListItem = function splitListItem(state, dispatch) {
|
|
|
537
499
|
paragraph = _state$schema$nodes5.paragraph;
|
|
538
500
|
if (actionDecisionFollowsOrNothing($from)) {
|
|
539
501
|
if (dispatch) {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
if (
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
return true;
|
|
550
|
-
}
|
|
502
|
+
// If previous node is a blockTaskItem we just want to delete the existing node and replace it with a paragraph
|
|
503
|
+
var nodeBefore = state.doc.resolve($from.pos - 1).nodeBefore;
|
|
504
|
+
if (blockTaskItem && (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type) === blockTaskItem) {
|
|
505
|
+
if ($from.parent.type === taskItem) {
|
|
506
|
+
var nodeSize = $from.parent.nodeSize;
|
|
507
|
+
tr.delete($from.pos - Math.floor(nodeSize / 2), $from.pos + Math.ceil(nodeSize / 2));
|
|
508
|
+
tr.insert($from.pos, paragraph.createChecked());
|
|
509
|
+
dispatch(tr);
|
|
510
|
+
return true;
|
|
551
511
|
}
|
|
552
512
|
}
|
|
553
513
|
if (hasParentNodeOfType(listItem)(tr.selection)) {
|
|
@@ -162,7 +162,7 @@ export var RequestToEditPopup = function RequestToEditPopup(_ref2) {
|
|
|
162
162
|
}), /*#__PURE__*/React.createElement("div", {
|
|
163
163
|
className: ax(["_19pku2gc _otyru2gc _18u0u2gc _2hwxu2gc _1e0c1o8l _1bsbyh40 _4t3iyh40 _bfhk16e3", "_2rko1rr0"])
|
|
164
164
|
}), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Pressable
|
|
165
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
165
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
166
166
|
, {
|
|
167
167
|
onClick: function onClick() {
|
|
168
168
|
var _api$analytics2;
|
|
@@ -114,7 +114,7 @@ var TaskItemWithProviders = /*#__PURE__*/function (_Component) {
|
|
|
114
114
|
objectId = _ref.objectId;
|
|
115
115
|
var userContext = objectId ? 'edit' : 'new';
|
|
116
116
|
return /*#__PURE__*/React.createElement(FabricElementsAnalyticsContext
|
|
117
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
117
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
118
118
|
, {
|
|
119
119
|
data: {
|
|
120
120
|
userContext: userContext
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-tasks-and-decisions",
|
|
3
|
-
"version": "11.3.
|
|
3
|
+
"version": "11.3.2",
|
|
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": "^18.0.0",
|
|
50
50
|
"@atlaskit/prosemirror-input-rules": "^3.6.0",
|
|
51
51
|
"@atlaskit/task-decision": "^19.3.0",
|
|
52
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
52
|
+
"@atlaskit/tmp-editor-statsig": "^45.0.0",
|
|
53
53
|
"@atlaskit/tokens": "^11.1.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
55
55
|
"@compiled/react": "^0.20.0",
|
|
@@ -104,9 +104,6 @@
|
|
|
104
104
|
"platform_editor_element_browser_analytic": {
|
|
105
105
|
"type": "boolean"
|
|
106
106
|
},
|
|
107
|
-
"platform_editor_blocktaskitem_patch_3": {
|
|
108
|
-
"type": "boolean"
|
|
109
|
-
},
|
|
110
107
|
"platform_editor_block_menu_v2_patch_3": {
|
|
111
108
|
"type": "boolean"
|
|
112
109
|
},
|