@atlaskit/editor-plugin-block-type 3.0.19 → 3.0.21

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,17 @@
1
1
  # @atlaskit/editor-plugin-block-type
2
2
 
3
+ ## 3.0.21
4
+
5
+ ### Patch Changes
6
+
7
+ - [#70152](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70152) [`53ed3673df28`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/53ed3673df28) - Updating adf-schema version to 35.5.1
8
+
9
+ ## 3.0.20
10
+
11
+ ### Patch Changes
12
+
13
+ - [#68217](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68217) [`bfd8d2ded4aa`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bfd8d2ded4aa) - [ux] correctly delete the decision list inside panel having only one decision item.
14
+
3
15
  ## 3.0.19
4
16
 
5
17
  ### Patch Changes
@@ -4,6 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.deleteBlockContent = deleteBlockContent;
7
+ var _state = require("@atlaskit/editor-prosemirror/state");
8
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
9
+ // function to check whether the selected node is the sole decision item in the decision list
10
+ var isSelectedNodeSoleDecisionItem = function isSelectedNodeSoleDecisionItem(state) {
11
+ var _findParentNodeOfType;
12
+ var isDecisionItemNodeSelected = state.selection instanceof _state.NodeSelection && state.selection.node.type.name === 'decisionItem';
13
+ if (!isDecisionItemNodeSelected) {
14
+ return false;
15
+ }
16
+ var decisionList = (_findParentNodeOfType = (0, _utils.findParentNodeOfType)([state.schema.nodes.decisionList])(state.selection)) === null || _findParentNodeOfType === void 0 ? void 0 : _findParentNodeOfType.node;
17
+ return (decisionList === null || decisionList === void 0 ? void 0 : decisionList.childCount) === 1;
18
+ };
19
+
7
20
  /**
8
21
  * Prevent removing the block when deleting block content
9
22
  *
@@ -25,9 +38,6 @@ function deleteBlockContent(isNodeAWrappingBlockNode) {
25
38
  doc.nodesBetween($from.pos, $to.pos, function (node, pos) {
26
39
  // Optimisation. If selection crosses wrapping block node
27
40
  // short circuit the loop by returning false
28
- if (selectionCrossesWrappingBlockNode) {
29
- return false;
30
- }
31
41
  if (isNodeAWrappingBlockNode(node)) {
32
42
  selectionCrossesWrappingBlockNode = true;
33
43
  return false;
@@ -36,7 +46,15 @@ function deleteBlockContent(isNodeAWrappingBlockNode) {
36
46
  if (!selectionCrossesWrappingBlockNode) {
37
47
  return false;
38
48
  }
39
- tr.delete($from.pos, $to.pos);
49
+ var decisionIsInsidePanel = (0, _utils.hasParentNodeOfType)([state.schema.nodes.panel])(state.selection);
50
+
51
+ // If decision is inside panel and the decision list have only one decision item which is selected,
52
+ // delete the whole decision list.
53
+ if (decisionIsInsidePanel && isSelectedNodeSoleDecisionItem(state)) {
54
+ tr.setSelection(new _state.TextSelection(tr.doc.resolve($from.before()))).delete($from.before(), $from.after());
55
+ } else {
56
+ tr.delete($from.pos, $to.pos);
57
+ }
40
58
  if (dispatch) {
41
59
  dispatch(tr);
42
60
  }
@@ -1,3 +1,17 @@
1
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
+ import { findParentNodeOfType, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
+
4
+ // function to check whether the selected node is the sole decision item in the decision list
5
+ const isSelectedNodeSoleDecisionItem = state => {
6
+ var _findParentNodeOfType;
7
+ const isDecisionItemNodeSelected = state.selection instanceof NodeSelection && state.selection.node.type.name === 'decisionItem';
8
+ if (!isDecisionItemNodeSelected) {
9
+ return false;
10
+ }
11
+ const decisionList = (_findParentNodeOfType = findParentNodeOfType([state.schema.nodes.decisionList])(state.selection)) === null || _findParentNodeOfType === void 0 ? void 0 : _findParentNodeOfType.node;
12
+ return (decisionList === null || decisionList === void 0 ? void 0 : decisionList.childCount) === 1;
13
+ };
14
+
1
15
  /**
2
16
  * Prevent removing the block when deleting block content
3
17
  *
@@ -22,9 +36,6 @@ export function deleteBlockContent(isNodeAWrappingBlockNode) {
22
36
  doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
23
37
  // Optimisation. If selection crosses wrapping block node
24
38
  // short circuit the loop by returning false
25
- if (selectionCrossesWrappingBlockNode) {
26
- return false;
27
- }
28
39
  if (isNodeAWrappingBlockNode(node)) {
29
40
  selectionCrossesWrappingBlockNode = true;
30
41
  return false;
@@ -33,7 +44,15 @@ export function deleteBlockContent(isNodeAWrappingBlockNode) {
33
44
  if (!selectionCrossesWrappingBlockNode) {
34
45
  return false;
35
46
  }
36
- tr.delete($from.pos, $to.pos);
47
+ const decisionIsInsidePanel = hasParentNodeOfType([state.schema.nodes.panel])(state.selection);
48
+
49
+ // If decision is inside panel and the decision list have only one decision item which is selected,
50
+ // delete the whole decision list.
51
+ if (decisionIsInsidePanel && isSelectedNodeSoleDecisionItem(state)) {
52
+ tr.setSelection(new TextSelection(tr.doc.resolve($from.before()))).delete($from.before(), $from.after());
53
+ } else {
54
+ tr.delete($from.pos, $to.pos);
55
+ }
37
56
  if (dispatch) {
38
57
  dispatch(tr);
39
58
  }
@@ -1,3 +1,17 @@
1
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
+ import { findParentNodeOfType, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
+
4
+ // function to check whether the selected node is the sole decision item in the decision list
5
+ var isSelectedNodeSoleDecisionItem = function isSelectedNodeSoleDecisionItem(state) {
6
+ var _findParentNodeOfType;
7
+ var isDecisionItemNodeSelected = state.selection instanceof NodeSelection && state.selection.node.type.name === 'decisionItem';
8
+ if (!isDecisionItemNodeSelected) {
9
+ return false;
10
+ }
11
+ var decisionList = (_findParentNodeOfType = findParentNodeOfType([state.schema.nodes.decisionList])(state.selection)) === null || _findParentNodeOfType === void 0 ? void 0 : _findParentNodeOfType.node;
12
+ return (decisionList === null || decisionList === void 0 ? void 0 : decisionList.childCount) === 1;
13
+ };
14
+
1
15
  /**
2
16
  * Prevent removing the block when deleting block content
3
17
  *
@@ -19,9 +33,6 @@ export function deleteBlockContent(isNodeAWrappingBlockNode) {
19
33
  doc.nodesBetween($from.pos, $to.pos, function (node, pos) {
20
34
  // Optimisation. If selection crosses wrapping block node
21
35
  // short circuit the loop by returning false
22
- if (selectionCrossesWrappingBlockNode) {
23
- return false;
24
- }
25
36
  if (isNodeAWrappingBlockNode(node)) {
26
37
  selectionCrossesWrappingBlockNode = true;
27
38
  return false;
@@ -30,7 +41,15 @@ export function deleteBlockContent(isNodeAWrappingBlockNode) {
30
41
  if (!selectionCrossesWrappingBlockNode) {
31
42
  return false;
32
43
  }
33
- tr.delete($from.pos, $to.pos);
44
+ var decisionIsInsidePanel = hasParentNodeOfType([state.schema.nodes.panel])(state.selection);
45
+
46
+ // If decision is inside panel and the decision list have only one decision item which is selected,
47
+ // delete the whole decision list.
48
+ if (decisionIsInsidePanel && isSelectedNodeSoleDecisionItem(state)) {
49
+ tr.setSelection(new TextSelection(tr.doc.resolve($from.before()))).delete($from.before(), $from.after());
50
+ } else {
51
+ tr.delete($from.pos, $to.pos);
52
+ }
34
53
  if (dispatch) {
35
54
  dispatch(tr);
36
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-type",
3
- "version": "3.0.19",
3
+ "version": "3.0.21",
4
4
  "description": "BlockType plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,17 +35,17 @@
35
35
  "./styles": "./src/styles.ts"
36
36
  },
37
37
  "dependencies": {
38
- "@atlaskit/adf-schema": "^35.3.0",
39
- "@atlaskit/editor-common": "^77.0.0",
38
+ "@atlaskit/adf-schema": "^35.5.1",
39
+ "@atlaskit/editor-common": "^77.2.0",
40
40
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
41
41
  "@atlaskit/editor-prosemirror": "1.1.0",
42
42
  "@atlaskit/editor-shared-styles": "^2.9.0",
43
- "@atlaskit/editor-tables": "^2.4.0",
43
+ "@atlaskit/editor-tables": "^2.5.0",
44
44
  "@atlaskit/icon": "^22.0.0",
45
45
  "@atlaskit/platform-feature-flags": "^0.2.5",
46
46
  "@atlaskit/prosemirror-input-rules": "^2.4.0",
47
47
  "@atlaskit/theme": "^12.6.0",
48
- "@atlaskit/tokens": "^1.34.0",
48
+ "@atlaskit/tokens": "^1.35.0",
49
49
  "@babel/runtime": "^7.0.0",
50
50
  "@emotion/react": "^11.7.1"
51
51
  },