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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-tasks-and-decisions
2
2
 
3
+ ## 8.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ee5833cf21736`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ee5833cf21736) -
8
+ [ux] Fix bug with depth calculation used when splitting blockTaskItem nodes on enter key press.
9
+ This caused an error to be thrown to the browser console and the node to not be split.
10
+ - Updated dependencies
11
+
12
+ ## 8.4.5
13
+
14
+ ### Patch Changes
15
+
16
+ - [`980edad1b9b85`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/980edad1b9b85) -
17
+ EDITOR-1635 Ensure new taskItems are only added on enter key press of blockTaskitem if cursor is
18
+ at the start or end of the task item, not the start or the end of any of its child paragraphs.
19
+ - Updated dependencies
20
+
3
21
  ## 8.4.4
4
22
 
5
23
  ### Patch Changes
@@ -12,7 +12,7 @@ exports.getCurrentIndentLevel = exports.getBlockRange = void 0;
12
12
  exports.getCurrentTaskItemIndex = getCurrentTaskItemIndex;
13
13
  exports.getTaskItemDataAtPos = getTaskItemDataAtPos;
14
14
  exports.getTaskItemDataToFocus = getTaskItemDataToFocus;
15
- exports.liftBlock = exports.isTable = exports.isInsideTaskOrDecisionItem = exports.isInsideTask = exports.isInsideDecision = exports.isEmptyTaskDecision = exports.isActionOrDecisionList = exports.isActionOrDecisionItem = exports.getTaskItemIndex = void 0;
15
+ exports.liftBlock = exports.isTable = exports.isInsideTaskOrDecisionItem = exports.isInsideTask = exports.isInsideDecision = exports.isInLastTextblockOfBlockTaskItem = exports.isInFirstTextblockOfBlockTaskItem = exports.isEmptyTaskDecision = exports.isActionOrDecisionList = exports.isActionOrDecisionItem = exports.getTaskItemIndex = void 0;
16
16
  exports.openRequestEditPopupAt = openRequestEditPopupAt;
17
17
  exports.removeCheckboxFocus = removeCheckboxFocus;
18
18
  exports.walkOut = exports.subtreeHeight = void 0;
@@ -486,4 +486,15 @@ function findFirstParentListNode($pos) {
486
486
  node: node,
487
487
  pos: listNodePosition
488
488
  };
489
- }
489
+ }
490
+ var isInFirstTextblockOfBlockTaskItem = exports.isInFirstTextblockOfBlockTaskItem = function isInFirstTextblockOfBlockTaskItem(state) {
491
+ var $from = state.selection.$from;
492
+ var blockTaskItem = state.schema.nodes.blockTaskItem;
493
+ return $from.parent.isTextblock && $from.node($from.depth - 1).type === blockTaskItem && $from.index($from.depth - 1) === 0;
494
+ };
495
+ var isInLastTextblockOfBlockTaskItem = exports.isInLastTextblockOfBlockTaskItem = function isInLastTextblockOfBlockTaskItem(state) {
496
+ var $from = state.selection.$from;
497
+ var blockTaskItem = state.schema.nodes.blockTaskItem;
498
+ var parentNode = $from.node($from.depth - 1);
499
+ return $from.parent.isTextblock && parentNode.type === blockTaskItem && $from.index($from.depth - 1) === parentNode.childCount - 1;
500
+ };
@@ -19,6 +19,7 @@ var _keymap = require("@atlaskit/editor-prosemirror/keymap");
19
19
  var _model = require("@atlaskit/editor-prosemirror/model");
20
20
  var _state = require("@atlaskit/editor-prosemirror/state");
21
21
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
22
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
23
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
23
24
  var _commands2 = require("./commands");
24
25
  var _helpers = require("./helpers");
@@ -462,7 +463,7 @@ var enter = function enter(editorAnalyticsAPI, getContextIdentifier) {
462
463
  var tr = _ref.tr,
463
464
  itemLocalId = _ref.itemLocalId;
464
465
  // ED-8932: When cursor is at the beginning of a task item, instead of split, we insert above.
465
- if ($from.pos === $to.pos && $from.parentOffset === 0) {
466
+ if ($from.pos === $to.pos && $from.parentOffset === 0 && ((0, _platformFeatureFlags.fg)('platform_editor_blocktaskitem_patch_2') ? !$from.parent.isTextblock || (0, _helpers.isInFirstTextblockOfBlockTaskItem)(state) : true)) {
466
467
  var newTask = nodeType.createAndFill({
467
468
  localId: itemLocalId
468
469
  });
@@ -488,6 +489,7 @@ var enter = function enter(editorAnalyticsAPI, getContextIdentifier) {
488
489
  * For blockTaskItem, must handle it differently because it can have a different depth
489
490
  */
490
491
  if (nodeType === blockTaskItem) {
492
+ var _$from$parent;
491
493
  var _blockTaskItemNode = (0, _utils2.findParentNodeOfType)([blockTaskItem])(selection);
492
494
  if (!_blockTaskItemNode) {
493
495
  return tr;
@@ -495,7 +497,7 @@ var enter = function enter(editorAnalyticsAPI, getContextIdentifier) {
495
497
 
496
498
  // If the selection is a gap cursor at the end of the blockTaskItem,
497
499
  // we should insert a new taskItem.
498
- if ($from.parentOffset === $from.parent.nodeSize - 2) {
500
+ if (((0, _platformFeatureFlags.fg)('platform_editor_blocktaskitem_patch_2') ? !$from.parent.isTextblock || (0, _helpers.isInLastTextblockOfBlockTaskItem)(state) : true) && $from.parentOffset === $from.parent.nodeSize - 2) {
499
501
  var _newTaskItem = taskItem.createAndFill({
500
502
  localId: itemLocalId
501
503
  });
@@ -509,7 +511,7 @@ var enter = function enter(editorAnalyticsAPI, getContextIdentifier) {
509
511
  }
510
512
 
511
513
  // Split near the depth of the current selection
512
- return tr.split($from.pos, $from.depth - 1, [{
514
+ return tr.split($from.pos, (0, _platformFeatureFlags.fg)('platform_editor_blocktaskitem_patch_2') ? $from !== null && $from !== void 0 && (_$from$parent = $from.parent) !== null && _$from$parent !== void 0 && _$from$parent.isTextblock ? 2 : 1 : $from.depth - 1, [{
513
515
  type: blockTaskItem,
514
516
  attrs: {
515
517
  localId: itemLocalId
@@ -1,4 +1,4 @@
1
- /* tasksAndDecisionsPlugin.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* tasksAndDecisionsPlugin.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,4 +1,4 @@
1
- /* RequestToEditPopup.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* RequestToEditPopup.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -517,4 +517,23 @@ export function findFirstParentListNode($pos) {
517
517
  node,
518
518
  pos: listNodePosition
519
519
  };
520
- }
520
+ }
521
+ export const isInFirstTextblockOfBlockTaskItem = state => {
522
+ const {
523
+ $from
524
+ } = state.selection;
525
+ const {
526
+ blockTaskItem
527
+ } = state.schema.nodes;
528
+ return $from.parent.isTextblock && $from.node($from.depth - 1).type === blockTaskItem && $from.index($from.depth - 1) === 0;
529
+ };
530
+ export const isInLastTextblockOfBlockTaskItem = state => {
531
+ const {
532
+ $from
533
+ } = state.selection;
534
+ const {
535
+ blockTaskItem
536
+ } = state.schema.nodes;
537
+ const parentNode = $from.node($from.depth - 1);
538
+ return $from.parent.isTextblock && parentNode.type === blockTaskItem && $from.index($from.depth - 1) === parentNode.childCount - 1;
539
+ };
@@ -10,9 +10,10 @@ 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';
13
14
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
15
  import { joinAtCut, liftSelection, wrapSelectionInTaskList } from './commands';
15
- import { findFirstParentListNode, getBlockRange, getCurrentIndentLevel, getTaskItemIndex, isActionOrDecisionItem, isActionOrDecisionList, isEmptyTaskDecision, isInsideDecision, isInsideTask, isInsideTaskOrDecisionItem, isTable, liftBlock, walkOut } from './helpers';
16
+ import { findFirstParentListNode, getBlockRange, getCurrentIndentLevel, getTaskItemIndex, isActionOrDecisionItem, isActionOrDecisionList, isEmptyTaskDecision, isInFirstTextblockOfBlockTaskItem, isInLastTextblockOfBlockTaskItem, isInsideDecision, isInsideTask, isInsideTaskOrDecisionItem, isTable, liftBlock, walkOut } from './helpers';
16
17
  import { insertTaskDecisionWithAnalytics } from './insert-commands';
17
18
  import { findBlockTaskItem, normalizeTaskItemsSelection } from './utils';
18
19
  const indentationAnalytics = (curIndentLevel, direction, inputMethod) => ({
@@ -457,7 +458,7 @@ const enter = (editorAnalyticsAPI, getContextIdentifier) => filter(isInsideTaskO
457
458
  itemLocalId
458
459
  }) => {
459
460
  // ED-8932: When cursor is at the beginning of a task item, instead of split, we insert above.
460
- if ($from.pos === $to.pos && $from.parentOffset === 0) {
461
+ if ($from.pos === $to.pos && $from.parentOffset === 0 && (fg('platform_editor_blocktaskitem_patch_2') ? !$from.parent.isTextblock || isInFirstTextblockOfBlockTaskItem(state) : true)) {
461
462
  const newTask = nodeType.createAndFill({
462
463
  localId: itemLocalId
463
464
  });
@@ -483,6 +484,7 @@ const enter = (editorAnalyticsAPI, getContextIdentifier) => filter(isInsideTaskO
483
484
  * For blockTaskItem, must handle it differently because it can have a different depth
484
485
  */
485
486
  if (nodeType === blockTaskItem) {
487
+ var _$from$parent;
486
488
  const blockTaskItemNode = findParentNodeOfType([blockTaskItem])(selection);
487
489
  if (!blockTaskItemNode) {
488
490
  return tr;
@@ -490,7 +492,7 @@ const enter = (editorAnalyticsAPI, getContextIdentifier) => filter(isInsideTaskO
490
492
 
491
493
  // If the selection is a gap cursor at the end of the blockTaskItem,
492
494
  // we should insert a new taskItem.
493
- if ($from.parentOffset === $from.parent.nodeSize - 2) {
495
+ if ((fg('platform_editor_blocktaskitem_patch_2') ? !$from.parent.isTextblock || isInLastTextblockOfBlockTaskItem(state) : true) && $from.parentOffset === $from.parent.nodeSize - 2) {
494
496
  const newTaskItem = taskItem.createAndFill({
495
497
  localId: itemLocalId
496
498
  });
@@ -504,7 +506,7 @@ const enter = (editorAnalyticsAPI, getContextIdentifier) => filter(isInsideTaskO
504
506
  }
505
507
 
506
508
  // Split near the depth of the current selection
507
- return tr.split($from.pos, $from.depth - 1, [{
509
+ return tr.split($from.pos, fg('platform_editor_blocktaskitem_patch_2') ? $from !== null && $from !== void 0 && (_$from$parent = $from.parent) !== null && _$from$parent !== void 0 && _$from$parent.isTextblock ? 2 : 1 : $from.depth - 1, [{
508
510
  type: blockTaskItem,
509
511
  attrs: {
510
512
  localId: itemLocalId
@@ -1,4 +1,4 @@
1
- /* tasksAndDecisionsPlugin.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* tasksAndDecisionsPlugin.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  import "./tasksAndDecisionsPlugin.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,4 +1,4 @@
1
- /* RequestToEditPopup.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* RequestToEditPopup.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  // import Popup from '@atlaskit/popup';
3
3
  import "./RequestToEditPopup.compiled.css";
4
4
  import * as React from 'react';
@@ -468,4 +468,15 @@ export function findFirstParentListNode($pos) {
468
468
  node: node,
469
469
  pos: listNodePosition
470
470
  };
471
- }
471
+ }
472
+ export var isInFirstTextblockOfBlockTaskItem = function isInFirstTextblockOfBlockTaskItem(state) {
473
+ var $from = state.selection.$from;
474
+ var blockTaskItem = state.schema.nodes.blockTaskItem;
475
+ return $from.parent.isTextblock && $from.node($from.depth - 1).type === blockTaskItem && $from.index($from.depth - 1) === 0;
476
+ };
477
+ export var isInLastTextblockOfBlockTaskItem = function isInLastTextblockOfBlockTaskItem(state) {
478
+ var $from = state.selection.$from;
479
+ var blockTaskItem = state.schema.nodes.blockTaskItem;
480
+ var parentNode = $from.node($from.depth - 1);
481
+ return $from.parent.isTextblock && parentNode.type === blockTaskItem && $from.index($from.depth - 1) === parentNode.childCount - 1;
482
+ };
@@ -13,9 +13,10 @@ 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';
16
17
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
17
18
  import { joinAtCut, liftSelection, wrapSelectionInTaskList } from './commands';
18
- import { findFirstParentListNode, getBlockRange, getCurrentIndentLevel, getTaskItemIndex, isActionOrDecisionItem, isActionOrDecisionList, isEmptyTaskDecision, isInsideDecision, isInsideTask, isInsideTaskOrDecisionItem, isTable, liftBlock, walkOut } from './helpers';
19
+ import { findFirstParentListNode, getBlockRange, getCurrentIndentLevel, getTaskItemIndex, isActionOrDecisionItem, isActionOrDecisionList, isEmptyTaskDecision, isInFirstTextblockOfBlockTaskItem, isInLastTextblockOfBlockTaskItem, isInsideDecision, isInsideTask, isInsideTaskOrDecisionItem, isTable, liftBlock, walkOut } from './helpers';
19
20
  import { insertTaskDecisionWithAnalytics } from './insert-commands';
20
21
  import { findBlockTaskItem, normalizeTaskItemsSelection } from './utils';
21
22
  var indentationAnalytics = function indentationAnalytics(curIndentLevel, direction, inputMethod) {
@@ -454,7 +455,7 @@ var enter = function enter(editorAnalyticsAPI, getContextIdentifier) {
454
455
  var tr = _ref.tr,
455
456
  itemLocalId = _ref.itemLocalId;
456
457
  // ED-8932: When cursor is at the beginning of a task item, instead of split, we insert above.
457
- if ($from.pos === $to.pos && $from.parentOffset === 0) {
458
+ if ($from.pos === $to.pos && $from.parentOffset === 0 && (fg('platform_editor_blocktaskitem_patch_2') ? !$from.parent.isTextblock || isInFirstTextblockOfBlockTaskItem(state) : true)) {
458
459
  var newTask = nodeType.createAndFill({
459
460
  localId: itemLocalId
460
461
  });
@@ -480,6 +481,7 @@ var enter = function enter(editorAnalyticsAPI, getContextIdentifier) {
480
481
  * For blockTaskItem, must handle it differently because it can have a different depth
481
482
  */
482
483
  if (nodeType === blockTaskItem) {
484
+ var _$from$parent;
483
485
  var _blockTaskItemNode = findParentNodeOfType([blockTaskItem])(selection);
484
486
  if (!_blockTaskItemNode) {
485
487
  return tr;
@@ -487,7 +489,7 @@ var enter = function enter(editorAnalyticsAPI, getContextIdentifier) {
487
489
 
488
490
  // If the selection is a gap cursor at the end of the blockTaskItem,
489
491
  // we should insert a new taskItem.
490
- if ($from.parentOffset === $from.parent.nodeSize - 2) {
492
+ if ((fg('platform_editor_blocktaskitem_patch_2') ? !$from.parent.isTextblock || isInLastTextblockOfBlockTaskItem(state) : true) && $from.parentOffset === $from.parent.nodeSize - 2) {
491
493
  var _newTaskItem = taskItem.createAndFill({
492
494
  localId: itemLocalId
493
495
  });
@@ -501,7 +503,7 @@ var enter = function enter(editorAnalyticsAPI, getContextIdentifier) {
501
503
  }
502
504
 
503
505
  // Split near the depth of the current selection
504
- return tr.split($from.pos, $from.depth - 1, [{
506
+ return tr.split($from.pos, fg('platform_editor_blocktaskitem_patch_2') ? $from !== null && $from !== void 0 && (_$from$parent = $from.parent) !== null && _$from$parent !== void 0 && _$from$parent.isTextblock ? 2 : 1 : $from.depth - 1, [{
505
507
  type: blockTaskItem,
506
508
  attrs: {
507
509
  localId: itemLocalId
@@ -1,4 +1,4 @@
1
- /* tasksAndDecisionsPlugin.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* tasksAndDecisionsPlugin.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
4
  import "./tasksAndDecisionsPlugin.compiled.css";
@@ -1,4 +1,4 @@
1
- /* RequestToEditPopup.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* RequestToEditPopup.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import "./RequestToEditPopup.compiled.css";
4
4
  import * as React from 'react';
@@ -95,3 +95,5 @@ export declare function findFirstParentListNode($pos: ResolvedPos): {
95
95
  node: Node;
96
96
  pos: number;
97
97
  } | null;
98
+ export declare const isInFirstTextblockOfBlockTaskItem: (state: EditorState) => boolean;
99
+ export declare const isInLastTextblockOfBlockTaskItem: (state: EditorState) => boolean;
@@ -95,3 +95,5 @@ export declare function findFirstParentListNode($pos: ResolvedPos): {
95
95
  node: Node;
96
96
  pos: number;
97
97
  } | null;
98
+ export declare const isInFirstTextblockOfBlockTaskItem: (state: EditorState) => boolean;
99
+ export declare const isInLastTextblockOfBlockTaskItem: (state: EditorState) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "8.4.4",
3
+ "version": "8.4.6",
4
4
  "description": "Tasks and decisions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  "@atlaskit/analytics-next": "^11.1.0",
35
35
  "@atlaskit/css": "^0.14.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^5.2.0",
37
- "@atlaskit/editor-plugin-block-menu": "^3.1.0",
37
+ "@atlaskit/editor-plugin-block-menu": "^3.2.0",
38
38
  "@atlaskit/editor-plugin-context-identifier": "^5.0.0",
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^7.0.0",
40
40
  "@atlaskit/editor-plugin-selection": "^5.0.0",
@@ -46,17 +46,17 @@
46
46
  "@atlaskit/icon": "^28.2.0",
47
47
  "@atlaskit/platform-feature-flags": "^1.1.0",
48
48
  "@atlaskit/popup": "^4.4.0",
49
- "@atlaskit/primitives": "^14.14.0",
49
+ "@atlaskit/primitives": "^14.15.0",
50
50
  "@atlaskit/prosemirror-input-rules": "^3.4.0",
51
51
  "@atlaskit/task-decision": "^19.2.0",
52
- "@atlaskit/tmp-editor-statsig": "^12.23.0",
52
+ "@atlaskit/tmp-editor-statsig": "^12.27.0",
53
53
  "@atlaskit/tokens": "^6.3.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@compiled/react": "^0.18.3",
56
56
  "bind-event-listener": "^3.0.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^109.8.0",
59
+ "@atlaskit/editor-common": "^109.11.0",
60
60
  "react": "^18.2.0",
61
61
  "react-dom": "^18.2.0",
62
62
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -110,6 +110,9 @@
110
110
  },
111
111
  "platform_editor_task_check_status_fix": {
112
112
  "type": "boolean"
113
+ },
114
+ "platform_editor_blocktaskitem_patch_2": {
115
+ "type": "boolean"
113
116
  }
114
117
  }
115
118
  }