@atlaskit/editor-plugin-tasks-and-decisions 6.4.4 → 6.4.5

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,13 @@
1
1
  # @atlaskit/editor-plugin-tasks-and-decisions
2
2
 
3
+ ## 6.4.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`69ab2a06347c4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/69ab2a06347c4) -
8
+ [EDITOR-1155] Handle shift-tab for blockTaskItems
9
+ - Updated dependencies
10
+
3
11
  ## 6.4.4
4
12
 
5
13
  ### Patch Changes
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.wrapSelectionInTaskList = exports.liftSelection = exports.joinAtCut = void 0;
7
7
  var _commands = require("@atlaskit/editor-common/commands");
8
8
  var _utils = require("@atlaskit/editor-common/utils");
9
- var _model = require("@atlaskit/editor-prosemirror/model");
10
- var _state = require("@atlaskit/editor-prosemirror/state");
11
9
  var _transform = require("@atlaskit/editor-prosemirror/transform");
12
10
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
13
11
  var _helpers = require("./helpers");
@@ -68,20 +66,6 @@ var wrapSelectionInTaskList = exports.wrapSelectionInTaskList = function wrapSel
68
66
  return true;
69
67
  }
70
68
  var blockRange = (0, _helpers.getBlockRange)($from, $to);
71
- if (blockTaskItem && isBlockTaskItem && blockTaskItemNode) {
72
- var startOfNodeInBlockTaskItem = state.doc.resolve(blockTaskItemNode.start);
73
- if (state.selection instanceof _state.TextSelection && state.selection.$to !== state.selection.$from) {
74
- var lastNode = $to.node($to.depth);
75
- var endOfNodeInBlockTaskItem = state.doc.resolve($to.start() + lastNode.nodeSize - 1);
76
- if (lastNode.type === taskItem) {
77
- blockRange = new _model.NodeRange(startOfNodeInBlockTaskItem, endOfNodeInBlockTaskItem, blockTaskItemNode.depth - 1);
78
- }
79
- } else {
80
- // Get the Resolved $from and $to of the node nested inside the blockTaskItem
81
- var _endOfNodeInBlockTaskItem = state.doc.resolve(blockTaskItemNode.start + blockTaskItemNode.node.nodeSize - 1);
82
- blockRange = new _model.NodeRange(startOfNodeInBlockTaskItem, _endOfNodeInBlockTaskItem, blockTaskItemNode.depth - 1);
83
- }
84
- }
85
69
  if (!blockRange) {
86
70
  return true;
87
71
  }
@@ -17,6 +17,7 @@ exports.openRequestEditPopupAt = openRequestEditPopupAt;
17
17
  exports.removeCheckboxFocus = removeCheckboxFocus;
18
18
  exports.walkOut = exports.subtreeHeight = void 0;
19
19
  var _utils = require("@atlaskit/editor-common/utils");
20
+ var _model = require("@atlaskit/editor-prosemirror/model");
20
21
  var _state = require("@atlaskit/editor-prosemirror/state");
21
22
  var _transform = require("@atlaskit/editor-prosemirror/transform");
22
23
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
@@ -27,6 +28,9 @@ var isInsideTaskOrDecisionItem = exports.isInsideTaskOrDecisionItem = function i
27
28
  decisionItem = _state$schema$nodes.decisionItem,
28
29
  taskItem = _state$schema$nodes.taskItem,
29
30
  blockTaskItem = _state$schema$nodes.blockTaskItem;
31
+ if (blockTaskItem) {
32
+ return Boolean((0, _utils2.findParentNodeOfTypeClosestToPos)(state.selection.$from, [decisionItem, taskItem, blockTaskItem]));
33
+ }
30
34
  return (0, _utils2.hasParentNodeOfType)([decisionItem, taskItem, blockTaskItem])(state.selection);
31
35
  };
32
36
  var isActionOrDecisionList = exports.isActionOrDecisionList = function isActionOrDecisionList(node) {
@@ -68,7 +72,18 @@ var isTable = exports.isTable = function isTable(node) {
68
72
  * ("nested") taskList, if one exists.
69
73
  */
70
74
  var getBlockRange = exports.getBlockRange = function getBlockRange($from, $to) {
71
- var taskList = $from.doc.type.schema.nodes.taskList;
75
+ var _$from$doc$type$schem = $from.doc.type.schema.nodes,
76
+ taskList = _$from$doc$type$schem.taskList,
77
+ blockTaskItem = _$from$doc$type$schem.blockTaskItem;
78
+ var blockTaskItemNode = (0, _utils.findFarthestParentNode)(function (node) {
79
+ return node.type === blockTaskItem;
80
+ })($from);
81
+ if (blockTaskItem && blockTaskItemNode) {
82
+ var startOfNodeInBlockTaskItem = $from.doc.resolve(blockTaskItemNode.start);
83
+ var lastNode = $to.node($to.depth);
84
+ var endOfNodeInBlockTaskItem = $from.doc.resolve($to.start() + lastNode.nodeSize - 1);
85
+ return new _model.NodeRange(startOfNodeInBlockTaskItem, endOfNodeInBlockTaskItem, blockTaskItemNode.depth - 1);
86
+ }
72
87
  var end = $to.end();
73
88
  var $after = $to.doc.resolve(end + 1);
74
89
  var after = $after.nodeAfter;
@@ -98,9 +113,9 @@ var getBlockRange = exports.getBlockRange = function getBlockRange($from, $to) {
98
113
  */
99
114
  var getCurrentIndentLevel = exports.getCurrentIndentLevel = function getCurrentIndentLevel(selection) {
100
115
  var $from = selection.$from;
101
- var _$from$doc$type$schem = $from.doc.type.schema.nodes,
102
- taskList = _$from$doc$type$schem.taskList,
103
- blockTaskItem = _$from$doc$type$schem.blockTaskItem;
116
+ var _$from$doc$type$schem2 = $from.doc.type.schema.nodes,
117
+ taskList = _$from$doc$type$schem2.taskList,
118
+ blockTaskItem = _$from$doc$type$schem2.blockTaskItem;
104
119
  var furthestParent = (0, _utils.findFarthestParentNode)(function (node) {
105
120
  return node.type === taskList;
106
121
  })($from);
@@ -1,7 +1,5 @@
1
1
  import { findCutBefore } from '@atlaskit/editor-common/commands';
2
2
  import { findFarthestParentNode } from '@atlaskit/editor-common/utils';
3
- import { NodeRange } from '@atlaskit/editor-prosemirror/model';
4
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
3
  import { findWrapping, ReplaceAroundStep } from '@atlaskit/editor-prosemirror/transform';
6
4
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
5
  import { getBlockRange, isActionOrDecisionItem, isActionOrDecisionList, liftBlock, subtreeHeight } from './helpers';
@@ -63,21 +61,7 @@ export const wrapSelectionInTaskList = (state, dispatch) => {
63
61
  if (maxDepth >= 6) {
64
62
  return true;
65
63
  }
66
- let blockRange = getBlockRange($from, $to);
67
- if (blockTaskItem && isBlockTaskItem && blockTaskItemNode) {
68
- const startOfNodeInBlockTaskItem = state.doc.resolve(blockTaskItemNode.start);
69
- if (state.selection instanceof TextSelection && state.selection.$to !== state.selection.$from) {
70
- const lastNode = $to.node($to.depth);
71
- const endOfNodeInBlockTaskItem = state.doc.resolve($to.start() + lastNode.nodeSize - 1);
72
- if (lastNode.type === taskItem) {
73
- blockRange = new NodeRange(startOfNodeInBlockTaskItem, endOfNodeInBlockTaskItem, blockTaskItemNode.depth - 1);
74
- }
75
- } else {
76
- // Get the Resolved $from and $to of the node nested inside the blockTaskItem
77
- const endOfNodeInBlockTaskItem = state.doc.resolve(blockTaskItemNode.start + blockTaskItemNode.node.nodeSize - 1);
78
- blockRange = new NodeRange(startOfNodeInBlockTaskItem, endOfNodeInBlockTaskItem, blockTaskItemNode.depth - 1);
79
- }
80
- }
64
+ const blockRange = getBlockRange($from, $to);
81
65
  if (!blockRange) {
82
66
  return true;
83
67
  }
@@ -1,7 +1,8 @@
1
1
  import { findFarthestParentNode, isListNode } from '@atlaskit/editor-common/utils';
2
+ import { NodeRange } from '@atlaskit/editor-prosemirror/model';
2
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
4
- import { findParentNodeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
+ import { findParentNodeClosestToPos, findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
6
  import { stateKey } from './plugin-key';
6
7
  import { ACTIONS } from './types';
7
8
  export const isInsideTaskOrDecisionItem = state => {
@@ -10,6 +11,9 @@ export const isInsideTaskOrDecisionItem = state => {
10
11
  taskItem,
11
12
  blockTaskItem
12
13
  } = state.schema.nodes;
14
+ if (blockTaskItem) {
15
+ return Boolean(findParentNodeOfTypeClosestToPos(state.selection.$from, [decisionItem, taskItem, blockTaskItem]));
16
+ }
13
17
  return hasParentNodeOfType([decisionItem, taskItem, blockTaskItem])(state.selection);
14
18
  };
15
19
  export const isActionOrDecisionList = node => {
@@ -58,8 +62,16 @@ export const isTable = node => {
58
62
  */
59
63
  export const getBlockRange = ($from, $to) => {
60
64
  const {
61
- taskList
65
+ taskList,
66
+ blockTaskItem
62
67
  } = $from.doc.type.schema.nodes;
68
+ const blockTaskItemNode = findFarthestParentNode(node => node.type === blockTaskItem)($from);
69
+ if (blockTaskItem && blockTaskItemNode) {
70
+ const startOfNodeInBlockTaskItem = $from.doc.resolve(blockTaskItemNode.start);
71
+ const lastNode = $to.node($to.depth);
72
+ const endOfNodeInBlockTaskItem = $from.doc.resolve($to.start() + lastNode.nodeSize - 1);
73
+ return new NodeRange(startOfNodeInBlockTaskItem, endOfNodeInBlockTaskItem, blockTaskItemNode.depth - 1);
74
+ }
63
75
  let end = $to.end();
64
76
  const $after = $to.doc.resolve(end + 1);
65
77
  const after = $after.nodeAfter;
@@ -1,7 +1,5 @@
1
1
  import { findCutBefore } from '@atlaskit/editor-common/commands';
2
2
  import { findFarthestParentNode } from '@atlaskit/editor-common/utils';
3
- import { NodeRange } from '@atlaskit/editor-prosemirror/model';
4
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
3
  import { findWrapping, ReplaceAroundStep } from '@atlaskit/editor-prosemirror/transform';
6
4
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
5
  import { getBlockRange, isActionOrDecisionItem, isActionOrDecisionList, liftBlock, subtreeHeight } from './helpers';
@@ -62,20 +60,6 @@ export var wrapSelectionInTaskList = function wrapSelectionInTaskList(state, dis
62
60
  return true;
63
61
  }
64
62
  var blockRange = getBlockRange($from, $to);
65
- if (blockTaskItem && isBlockTaskItem && blockTaskItemNode) {
66
- var startOfNodeInBlockTaskItem = state.doc.resolve(blockTaskItemNode.start);
67
- if (state.selection instanceof TextSelection && state.selection.$to !== state.selection.$from) {
68
- var lastNode = $to.node($to.depth);
69
- var endOfNodeInBlockTaskItem = state.doc.resolve($to.start() + lastNode.nodeSize - 1);
70
- if (lastNode.type === taskItem) {
71
- blockRange = new NodeRange(startOfNodeInBlockTaskItem, endOfNodeInBlockTaskItem, blockTaskItemNode.depth - 1);
72
- }
73
- } else {
74
- // Get the Resolved $from and $to of the node nested inside the blockTaskItem
75
- var _endOfNodeInBlockTaskItem = state.doc.resolve(blockTaskItemNode.start + blockTaskItemNode.node.nodeSize - 1);
76
- blockRange = new NodeRange(startOfNodeInBlockTaskItem, _endOfNodeInBlockTaskItem, blockTaskItemNode.depth - 1);
77
- }
78
- }
79
63
  if (!blockRange) {
80
64
  return true;
81
65
  }
@@ -1,7 +1,8 @@
1
1
  import { findFarthestParentNode, isListNode } from '@atlaskit/editor-common/utils';
2
+ import { NodeRange } from '@atlaskit/editor-prosemirror/model';
2
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
4
- import { findParentNodeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
+ import { findParentNodeClosestToPos, findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
6
  import { stateKey } from './plugin-key';
6
7
  import { ACTIONS } from './types';
7
8
  export var isInsideTaskOrDecisionItem = function isInsideTaskOrDecisionItem(state) {
@@ -9,6 +10,9 @@ export var isInsideTaskOrDecisionItem = function isInsideTaskOrDecisionItem(stat
9
10
  decisionItem = _state$schema$nodes.decisionItem,
10
11
  taskItem = _state$schema$nodes.taskItem,
11
12
  blockTaskItem = _state$schema$nodes.blockTaskItem;
13
+ if (blockTaskItem) {
14
+ return Boolean(findParentNodeOfTypeClosestToPos(state.selection.$from, [decisionItem, taskItem, blockTaskItem]));
15
+ }
12
16
  return hasParentNodeOfType([decisionItem, taskItem, blockTaskItem])(state.selection);
13
17
  };
14
18
  export var isActionOrDecisionList = function isActionOrDecisionList(node) {
@@ -50,7 +54,18 @@ export var isTable = function isTable(node) {
50
54
  * ("nested") taskList, if one exists.
51
55
  */
52
56
  export var getBlockRange = function getBlockRange($from, $to) {
53
- var taskList = $from.doc.type.schema.nodes.taskList;
57
+ var _$from$doc$type$schem = $from.doc.type.schema.nodes,
58
+ taskList = _$from$doc$type$schem.taskList,
59
+ blockTaskItem = _$from$doc$type$schem.blockTaskItem;
60
+ var blockTaskItemNode = findFarthestParentNode(function (node) {
61
+ return node.type === blockTaskItem;
62
+ })($from);
63
+ if (blockTaskItem && blockTaskItemNode) {
64
+ var startOfNodeInBlockTaskItem = $from.doc.resolve(blockTaskItemNode.start);
65
+ var lastNode = $to.node($to.depth);
66
+ var endOfNodeInBlockTaskItem = $from.doc.resolve($to.start() + lastNode.nodeSize - 1);
67
+ return new NodeRange(startOfNodeInBlockTaskItem, endOfNodeInBlockTaskItem, blockTaskItemNode.depth - 1);
68
+ }
54
69
  var end = $to.end();
55
70
  var $after = $to.doc.resolve(end + 1);
56
71
  var after = $after.nodeAfter;
@@ -80,9 +95,9 @@ export var getBlockRange = function getBlockRange($from, $to) {
80
95
  */
81
96
  export var getCurrentIndentLevel = function getCurrentIndentLevel(selection) {
82
97
  var $from = selection.$from;
83
- var _$from$doc$type$schem = $from.doc.type.schema.nodes,
84
- taskList = _$from$doc$type$schem.taskList,
85
- blockTaskItem = _$from$doc$type$schem.blockTaskItem;
98
+ var _$from$doc$type$schem2 = $from.doc.type.schema.nodes,
99
+ taskList = _$from$doc$type$schem2.taskList,
100
+ blockTaskItem = _$from$doc$type$schem2.blockTaskItem;
86
101
  var furthestParent = findFarthestParentNode(function (node) {
87
102
  return node.type === taskList;
88
103
  })($from);
@@ -1,4 +1,4 @@
1
- import type { Node, NodeType, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
1
+ import { NodeRange, type Node, type NodeType, type ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { TaskItemData } from './types';
@@ -12,7 +12,7 @@ export declare const isTable: (node?: Node | null) => boolean;
12
12
  * Creates a NodeRange around the given taskItem and the following
13
13
  * ("nested") taskList, if one exists.
14
14
  */
15
- export declare const getBlockRange: ($from: ResolvedPos, $to: ResolvedPos) => import("prosemirror-model").NodeRange | null;
15
+ export declare const getBlockRange: ($from: ResolvedPos, $to: ResolvedPos) => NodeRange | null;
16
16
  /**
17
17
  * Calculates the current indent level of the selection within a task list in the ProseMirror document.
18
18
  *
@@ -1,4 +1,4 @@
1
- import type { Node, NodeType, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
1
+ import { NodeRange, type Node, type NodeType, type ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { TaskItemData } from './types';
@@ -12,7 +12,7 @@ export declare const isTable: (node?: Node | null) => boolean;
12
12
  * Creates a NodeRange around the given taskItem and the following
13
13
  * ("nested") taskList, if one exists.
14
14
  */
15
- export declare const getBlockRange: ($from: ResolvedPos, $to: ResolvedPos) => import("prosemirror-model").NodeRange | null;
15
+ export declare const getBlockRange: ($from: ResolvedPos, $to: ResolvedPos) => NodeRange | null;
16
16
  /**
17
17
  * Calculates the current indent level of the selection within a task list in the ProseMirror document.
18
18
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "6.4.4",
3
+ "version": "6.4.5",
4
4
  "description": "Tasks and decisions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  ".": "./src/index.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@atlaskit/adf-schema": "^50.2.1",
35
+ "@atlaskit/adf-schema": "^50.2.2",
36
36
  "@atlaskit/analytics-namespaced-context": "^7.0.0",
37
37
  "@atlaskit/analytics-next": "^11.1.0",
38
38
  "@atlaskit/css": "^0.12.0",
@@ -49,14 +49,14 @@
49
49
  "@atlaskit/primitives": "^14.11.0",
50
50
  "@atlaskit/prosemirror-input-rules": "^3.4.0",
51
51
  "@atlaskit/task-decision": "^19.2.0",
52
- "@atlaskit/tmp-editor-statsig": "^11.5.0",
52
+ "@atlaskit/tmp-editor-statsig": "^11.6.0",
53
53
  "@atlaskit/tokens": "^6.0.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": "^107.28.0",
59
+ "@atlaskit/editor-common": "^107.30.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"