@atlaskit/editor-plugin-expand 2.7.3 → 2.7.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,24 @@
1
1
  # @atlaskit/editor-plugin-expand
2
2
 
3
+ ## 2.7.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#143199](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/143199)
8
+ [`2c7282d335256`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2c7282d335256) -
9
+ [ux] [ED-24799] This change allows users to navigate using Tab when there are multiple expands on
10
+ the page. Previously, users could only navigate around the 1st expand on the page with Tab.
11
+ - Updated dependencies
12
+
13
+ ## 2.7.4
14
+
15
+ ### Patch Changes
16
+
17
+ - [#142470](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/142470)
18
+ [`3f2dc4e949e05`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3f2dc4e949e05) -
19
+ ED-25000 - Add logic to handle when nested expand dragged into another nested expand.
20
+ - Updated dependencies
21
+
3
22
  ## 2.7.3
4
23
 
5
24
  ### Patch Changes
@@ -198,9 +198,11 @@ var focusTitle = exports.focusTitle = function focusTitle(pos) {
198
198
  };
199
199
  var focusIcon = exports.focusIcon = function focusIcon(expand) {
200
200
  return function (state, dispatch, editorView) {
201
- if (!expand || !(expand instanceof HTMLElement)) {
201
+ if (!(expand instanceof HTMLElement)) {
202
202
  return false;
203
203
  }
204
+
205
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
204
206
  var iconContainer = expand.querySelector(".".concat(_styles.expandClassNames.iconContainer));
205
207
  if (iconContainer && iconContainer.focus) {
206
208
  var tr = state.tr;
@@ -9,9 +9,10 @@ var _selection = require("@atlaskit/editor-common/selection");
9
9
  var _utils = require("@atlaskit/editor-common/utils");
10
10
  var _keymap = require("@atlaskit/editor-prosemirror/keymap");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
+ var _utils2 = require("@atlaskit/editor-tables/utils");
12
13
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _commands = require("../commands");
14
- var _utils2 = require("../utils");
15
+ var _utils3 = require("../utils");
15
16
  var isExpandNode = function isExpandNode(node) {
16
17
  return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
17
18
  };
@@ -49,20 +50,25 @@ function expandKeymap(api, options) {
49
50
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.tab.common, function (state, dispatch, editorView) {
50
51
  if (editorView && editorView.dom instanceof HTMLElement) {
51
52
  var from = state.selection.from;
53
+
54
+ // if the node selected is an expand
52
55
  if (isExpandSelected(state.selection)) {
53
56
  var expand = editorView.nodeDOM(from);
54
- if (!expand || !(expand instanceof HTMLElement)) {
57
+ if (!expand) {
55
58
  return false;
56
59
  }
57
60
  return (0, _commands.focusIcon)(expand)(state, dispatch, editorView);
58
- } else if (state.selection instanceof _state.TextSelection) {
59
- var _dom$node$parentEleme;
60
- var dom = editorView.domAtPos(from);
61
- var _expand = (_dom$node$parentEleme = dom.node.parentElement) === null || _dom$node$parentEleme === void 0 ? void 0 : _dom$node$parentEleme.parentElement;
62
- if (!_expand || !(_expand instanceof HTMLElement)) {
63
- return false;
61
+ }
62
+
63
+ // if the text selection is inside an expand
64
+ else if (state.selection instanceof _state.TextSelection && !(0, _utils2.isInTable)(state)) {
65
+ var _expand = (0, _utils3.findExpand)(state);
66
+ if (_expand) {
67
+ var expandNode = editorView.nodeDOM(_expand.pos);
68
+ if (expandNode) {
69
+ return (0, _commands.focusIcon)(expandNode)(state, dispatch, editorView);
70
+ }
64
71
  }
65
- return (0, _commands.focusIcon)(_expand)(state, dispatch, editorView);
66
72
  }
67
73
  }
68
74
  return false;
@@ -82,7 +88,7 @@ function expandKeymap(api, options) {
82
88
  }
83
89
  var $from = state.selection.$from;
84
90
  if (editorView.endOfTextblock('up')) {
85
- var expand = (0, _utils2.findExpand)(state);
91
+ var expand = (0, _utils3.findExpand)(state);
86
92
 
87
93
  // Moving UP in a table should move the cursor to the row above
88
94
  // however when an expand is in a table cell to the left of the
@@ -97,7 +103,7 @@ function expandKeymap(api, options) {
97
103
  return (0, _commands.focusTitle)(expand.start)(state, dispatch, editorView);
98
104
  }
99
105
  var sel = _state.Selection.findFrom(state.doc.resolve(prevCursorPos), -1);
100
- var expandBefore = (0, _utils2.findExpand)(state, sel);
106
+ var expandBefore = (0, _utils3.findExpand)(state, sel);
101
107
  if (sel && expandBefore) {
102
108
  // moving cursor from outside of an expand to the title when it is collapsed
103
109
  if (
@@ -150,11 +156,11 @@ function expandKeymap(api, options) {
150
156
  var _state$schema$nodes2 = state.schema.nodes,
151
157
  expand = _state$schema$nodes2.expand,
152
158
  nestedExpand = _state$schema$nodes2.nestedExpand;
153
- var expandNode = (0, _utils2.findExpand)(state);
159
+ var expandNode = (0, _utils3.findExpand)(state);
154
160
  if (!expandNode) {
155
161
  // @see ED-7977
156
162
  var sel = _state.Selection.findFrom(state.doc.resolve(Math.max(selection.$from.pos - 1, 0)), -1);
157
- var expandBefore = (0, _utils2.findExpand)(state, sel);
163
+ var expandBefore = (0, _utils3.findExpand)(state, sel);
158
164
  if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && (
159
165
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
160
166
  (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded)) {
@@ -133,6 +133,7 @@ function handleExpandDrag(view, event, slice) {
133
133
  var dropLocationParentNodeType = resolvedPos.depth > 0 ? resolvedPos.node(resolvedPos.depth - 1).type : dropLocationNodeType;
134
134
  var nodesWithNestedExpandSupport = [state.schema.nodes.expand, state.schema.nodes.tableHeader, state.schema.nodes.tableCell];
135
135
  var isNodeAtDropPosInsideNodesWithNestedExpandSupport = nodesWithNestedExpandSupport.includes(dropLocationNodeType) || nodesWithNestedExpandSupport.includes(dropLocationParentNodeType);
136
+ var isNodeBeingDroppedInsideNestedExpand = dropLocationNodeType === state.schema.nodes.nestedExpand || dropLocationParentNodeType === state.schema.nodes.nestedExpand;
136
137
  if ((0, _experiments.editorExperiment)('nested-expand-in-expand', false)) {
137
138
  if ((sliceContainsExpand || sliceContainsNestedExpand) && (dropLocationNodeType === state.schema.nodes.expand || dropLocationParentNodeType === state.schema.nodes.expand)) {
138
139
  event.preventDefault();
@@ -142,7 +143,7 @@ function handleExpandDrag(view, event, slice) {
142
143
  var updatedSlice = slice;
143
144
  if (sliceContainsExpand && isNodeAtDropPosInsideNodesWithNestedExpandSupport) {
144
145
  updatedSlice = (0, _utils2.transformSliceExpandToNestedExpand)(slice);
145
- } else if (sliceContainsNestedExpand && !isNodeAtDropPosInsideNodesWithNestedExpandSupport) {
146
+ } else if (sliceContainsNestedExpand && !isNodeAtDropPosInsideNodesWithNestedExpandSupport && !isNodeBeingDroppedInsideNestedExpand) {
146
147
  updatedSlice = (0, _utils2.transformSliceNestedExpandToExpand)(slice, state.schema);
147
148
  }
148
149
  if (!updatedSlice || updatedSlice.eq(slice)) {
@@ -200,9 +200,11 @@ var focusTitle = exports.focusTitle = function focusTitle(pos) {
200
200
  };
201
201
  var focusIcon = exports.focusIcon = function focusIcon(expand) {
202
202
  return function (state, dispatch, editorView) {
203
- if (!expand || !(expand instanceof HTMLElement)) {
203
+ if (!(expand instanceof HTMLElement)) {
204
204
  return false;
205
205
  }
206
+
207
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
206
208
  var iconContainer = expand.querySelector(".".concat(_styles.expandClassNames.iconContainer));
207
209
  if (iconContainer && iconContainer.focus) {
208
210
  var tr = state.tr;
@@ -11,6 +11,7 @@ var _transforms = require("@atlaskit/editor-common/transforms");
11
11
  var _utils = require("@atlaskit/editor-common/utils");
12
12
  var _keymap = require("@atlaskit/editor-prosemirror/keymap");
13
13
  var _state = require("@atlaskit/editor-prosemirror/state");
14
+ var _utils2 = require("@atlaskit/editor-tables/utils");
14
15
  var _commands = require("../commands");
15
16
  var isExpandNode = function isExpandNode(node) {
16
17
  return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
@@ -49,20 +50,25 @@ function expandKeymap(api, options) {
49
50
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.tab.common, function (state, dispatch, editorView) {
50
51
  if (editorView && editorView.dom instanceof HTMLElement) {
51
52
  var from = state.selection.from;
53
+
54
+ // if the node selected is an expand
52
55
  if (isExpandSelected(state.selection)) {
53
56
  var expand = editorView.nodeDOM(from);
54
- if (!expand || !(expand instanceof HTMLElement)) {
57
+ if (!expand) {
55
58
  return false;
56
59
  }
57
60
  return (0, _commands.focusIcon)(expand)(state, dispatch, editorView);
58
- } else if (state.selection instanceof _state.TextSelection) {
59
- var _dom$node$parentEleme;
60
- var dom = editorView.domAtPos(from);
61
- var _expand = (_dom$node$parentEleme = dom.node.parentElement) === null || _dom$node$parentEleme === void 0 ? void 0 : _dom$node$parentEleme.parentElement;
62
- if (!_expand || !(_expand instanceof HTMLElement)) {
63
- return false;
61
+ }
62
+
63
+ // if the text selection is inside an expand
64
+ else if (state.selection instanceof _state.TextSelection && !(0, _utils2.isInTable)(state)) {
65
+ var _expand = (0, _transforms.findExpand)(state);
66
+ if (_expand) {
67
+ var expandNode = editorView.nodeDOM(_expand.pos);
68
+ if (expandNode) {
69
+ return (0, _commands.focusIcon)(expandNode)(state, dispatch, editorView);
70
+ }
64
71
  }
65
- return (0, _commands.focusIcon)(_expand)(state, dispatch, editorView);
66
72
  }
67
73
  }
68
74
  return false;
@@ -115,6 +115,7 @@ function handleExpandDrag(view, event, slice) {
115
115
  var dropLocationParentNodeType = resolvedPos.depth > 0 ? resolvedPos.node(resolvedPos.depth - 1).type : dropLocationNodeType;
116
116
  var nodesWithNestedExpandSupport = [state.schema.nodes.expand, state.schema.nodes.tableHeader, state.schema.nodes.tableCell];
117
117
  var isNodeAtDropPosInsideNodesWithNestedExpandSupport = nodesWithNestedExpandSupport.includes(dropLocationNodeType) || nodesWithNestedExpandSupport.includes(dropLocationParentNodeType);
118
+ var isNodeBeingDroppedInsideNestedExpand = dropLocationNodeType === state.schema.nodes.nestedExpand || dropLocationParentNodeType === state.schema.nodes.nestedExpand;
118
119
  if ((0, _experiments.editorExperiment)('nested-expand-in-expand', false)) {
119
120
  if ((sliceContainsExpand || sliceContainsNestedExpand) && (dropLocationNodeType === state.schema.nodes.expand || dropLocationParentNodeType === state.schema.nodes.expand)) {
120
121
  event.preventDefault();
@@ -124,7 +125,7 @@ function handleExpandDrag(view, event, slice) {
124
125
  var updatedSlice = slice;
125
126
  if (sliceContainsExpand && isNodeAtDropPosInsideNodesWithNestedExpandSupport) {
126
127
  updatedSlice = (0, _utils.transformSliceExpandToNestedExpand)(slice);
127
- } else if (sliceContainsNestedExpand && !isNodeAtDropPosInsideNodesWithNestedExpandSupport) {
128
+ } else if (sliceContainsNestedExpand && !isNodeAtDropPosInsideNodesWithNestedExpandSupport && !isNodeBeingDroppedInsideNestedExpand) {
128
129
  updatedSlice = (0, _utils.transformSliceNestedExpandToExpand)(slice, state.schema);
129
130
  }
130
131
  if (!updatedSlice || updatedSlice.eq(slice)) {
@@ -178,9 +178,11 @@ export const focusTitle = pos => (state, dispatch, editorView) => {
178
178
  return false;
179
179
  };
180
180
  export const focusIcon = expand => (state, dispatch, editorView) => {
181
- if (!expand || !(expand instanceof HTMLElement)) {
181
+ if (!(expand instanceof HTMLElement)) {
182
182
  return false;
183
183
  }
184
+
185
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
184
186
  const iconContainer = expand.querySelector(`.${expandClassNames.iconContainer}`);
185
187
  if (iconContainer && iconContainer.focus) {
186
188
  const {
@@ -3,6 +3,7 @@ import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor
3
3
  import { isEmptyNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
4
4
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
5
5
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import { isInTable } from '@atlaskit/editor-tables/utils';
6
7
  import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { deleteExpand, focusIcon, focusTitle } from '../commands';
8
9
  import { findExpand } from '../utils';
@@ -51,20 +52,25 @@ export function expandKeymap(api, options) {
51
52
  const {
52
53
  from
53
54
  } = state.selection;
55
+
56
+ // if the node selected is an expand
54
57
  if (isExpandSelected(state.selection)) {
55
58
  const expand = editorView.nodeDOM(from);
56
- if (!expand || !(expand instanceof HTMLElement)) {
59
+ if (!expand) {
57
60
  return false;
58
61
  }
59
62
  return focusIcon(expand)(state, dispatch, editorView);
60
- } else if (state.selection instanceof TextSelection) {
61
- var _dom$node$parentEleme;
62
- const dom = editorView.domAtPos(from);
63
- const expand = (_dom$node$parentEleme = dom.node.parentElement) === null || _dom$node$parentEleme === void 0 ? void 0 : _dom$node$parentEleme.parentElement;
64
- if (!expand || !(expand instanceof HTMLElement)) {
65
- return false;
63
+ }
64
+
65
+ // if the text selection is inside an expand
66
+ else if (state.selection instanceof TextSelection && !isInTable(state)) {
67
+ const expand = findExpand(state);
68
+ if (expand) {
69
+ const expandNode = editorView.nodeDOM(expand.pos);
70
+ if (expandNode) {
71
+ return focusIcon(expandNode)(state, dispatch, editorView);
72
+ }
66
73
  }
67
- return focusIcon(expand)(state, dispatch, editorView);
68
74
  }
69
75
  }
70
76
  return false;
@@ -125,6 +125,7 @@ export function handleExpandDrag(view, event, slice) {
125
125
  const dropLocationParentNodeType = resolvedPos.depth > 0 ? resolvedPos.node(resolvedPos.depth - 1).type : dropLocationNodeType;
126
126
  const nodesWithNestedExpandSupport = [state.schema.nodes.expand, state.schema.nodes.tableHeader, state.schema.nodes.tableCell];
127
127
  const isNodeAtDropPosInsideNodesWithNestedExpandSupport = nodesWithNestedExpandSupport.includes(dropLocationNodeType) || nodesWithNestedExpandSupport.includes(dropLocationParentNodeType);
128
+ const isNodeBeingDroppedInsideNestedExpand = dropLocationNodeType === state.schema.nodes.nestedExpand || dropLocationParentNodeType === state.schema.nodes.nestedExpand;
128
129
  if (editorExperiment('nested-expand-in-expand', false)) {
129
130
  if ((sliceContainsExpand || sliceContainsNestedExpand) && (dropLocationNodeType === state.schema.nodes.expand || dropLocationParentNodeType === state.schema.nodes.expand)) {
130
131
  event.preventDefault();
@@ -134,7 +135,7 @@ export function handleExpandDrag(view, event, slice) {
134
135
  let updatedSlice = slice;
135
136
  if (sliceContainsExpand && isNodeAtDropPosInsideNodesWithNestedExpandSupport) {
136
137
  updatedSlice = transformSliceExpandToNestedExpand(slice);
137
- } else if (sliceContainsNestedExpand && !isNodeAtDropPosInsideNodesWithNestedExpandSupport) {
138
+ } else if (sliceContainsNestedExpand && !isNodeAtDropPosInsideNodesWithNestedExpandSupport && !isNodeBeingDroppedInsideNestedExpand) {
138
139
  updatedSlice = transformSliceNestedExpandToExpand(slice, state.schema);
139
140
  }
140
141
  if (!updatedSlice || updatedSlice.eq(slice)) {
@@ -178,9 +178,11 @@ export const focusTitle = pos => (state, dispatch, editorView) => {
178
178
  return false;
179
179
  };
180
180
  export const focusIcon = expand => (state, dispatch, editorView) => {
181
- if (!expand || !(expand instanceof HTMLElement)) {
181
+ if (!(expand instanceof HTMLElement)) {
182
182
  return false;
183
183
  }
184
+
185
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
184
186
  const iconContainer = expand.querySelector(`.${expandClassNames.iconContainer}`);
185
187
  if (iconContainer && iconContainer.focus) {
186
188
  const {
@@ -5,6 +5,7 @@ import { findExpand } from '@atlaskit/editor-common/transforms';
5
5
  import { isEmptyNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
6
6
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
7
7
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
8
+ import { isInTable } from '@atlaskit/editor-tables/utils';
8
9
  import { deleteExpand, focusIcon, focusTitle } from '../commands';
9
10
  const isExpandNode = node => {
10
11
  return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
@@ -51,20 +52,25 @@ export function expandKeymap(api, options) {
51
52
  const {
52
53
  from
53
54
  } = state.selection;
55
+
56
+ // if the node selected is an expand
54
57
  if (isExpandSelected(state.selection)) {
55
58
  const expand = editorView.nodeDOM(from);
56
- if (!expand || !(expand instanceof HTMLElement)) {
59
+ if (!expand) {
57
60
  return false;
58
61
  }
59
62
  return focusIcon(expand)(state, dispatch, editorView);
60
- } else if (state.selection instanceof TextSelection) {
61
- var _dom$node$parentEleme;
62
- const dom = editorView.domAtPos(from);
63
- const expand = (_dom$node$parentEleme = dom.node.parentElement) === null || _dom$node$parentEleme === void 0 ? void 0 : _dom$node$parentEleme.parentElement;
64
- if (!expand || !(expand instanceof HTMLElement)) {
65
- return false;
63
+ }
64
+
65
+ // if the text selection is inside an expand
66
+ else if (state.selection instanceof TextSelection && !isInTable(state)) {
67
+ const expand = findExpand(state);
68
+ if (expand) {
69
+ const expandNode = editorView.nodeDOM(expand.pos);
70
+ if (expandNode) {
71
+ return focusIcon(expandNode)(state, dispatch, editorView);
72
+ }
66
73
  }
67
- return focusIcon(expand)(state, dispatch, editorView);
68
74
  }
69
75
  }
70
76
  return false;
@@ -104,6 +104,7 @@ export function handleExpandDrag(view, event, slice) {
104
104
  const dropLocationParentNodeType = resolvedPos.depth > 0 ? resolvedPos.node(resolvedPos.depth - 1).type : dropLocationNodeType;
105
105
  const nodesWithNestedExpandSupport = [state.schema.nodes.expand, state.schema.nodes.tableHeader, state.schema.nodes.tableCell];
106
106
  const isNodeAtDropPosInsideNodesWithNestedExpandSupport = nodesWithNestedExpandSupport.includes(dropLocationNodeType) || nodesWithNestedExpandSupport.includes(dropLocationParentNodeType);
107
+ const isNodeBeingDroppedInsideNestedExpand = dropLocationNodeType === state.schema.nodes.nestedExpand || dropLocationParentNodeType === state.schema.nodes.nestedExpand;
107
108
  if (editorExperiment('nested-expand-in-expand', false)) {
108
109
  if ((sliceContainsExpand || sliceContainsNestedExpand) && (dropLocationNodeType === state.schema.nodes.expand || dropLocationParentNodeType === state.schema.nodes.expand)) {
109
110
  event.preventDefault();
@@ -113,7 +114,7 @@ export function handleExpandDrag(view, event, slice) {
113
114
  let updatedSlice = slice;
114
115
  if (sliceContainsExpand && isNodeAtDropPosInsideNodesWithNestedExpandSupport) {
115
116
  updatedSlice = transformSliceExpandToNestedExpand(slice);
116
- } else if (sliceContainsNestedExpand && !isNodeAtDropPosInsideNodesWithNestedExpandSupport) {
117
+ } else if (sliceContainsNestedExpand && !isNodeAtDropPosInsideNodesWithNestedExpandSupport && !isNodeBeingDroppedInsideNestedExpand) {
117
118
  updatedSlice = transformSliceNestedExpandToExpand(slice, state.schema);
118
119
  }
119
120
  if (!updatedSlice || updatedSlice.eq(slice)) {
@@ -191,9 +191,11 @@ export var focusTitle = function focusTitle(pos) {
191
191
  };
192
192
  export var focusIcon = function focusIcon(expand) {
193
193
  return function (state, dispatch, editorView) {
194
- if (!expand || !(expand instanceof HTMLElement)) {
194
+ if (!(expand instanceof HTMLElement)) {
195
195
  return false;
196
196
  }
197
+
198
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
197
199
  var iconContainer = expand.querySelector(".".concat(expandClassNames.iconContainer));
198
200
  if (iconContainer && iconContainer.focus) {
199
201
  var tr = state.tr;
@@ -3,6 +3,7 @@ import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor
3
3
  import { isEmptyNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
4
4
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
5
5
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import { isInTable } from '@atlaskit/editor-tables/utils';
6
7
  import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { deleteExpand, focusIcon, focusTitle } from '../commands';
8
9
  import { findExpand } from '../utils';
@@ -43,20 +44,25 @@ export function expandKeymap(api, options) {
43
44
  bindKeymapWithCommand(tab.common, function (state, dispatch, editorView) {
44
45
  if (editorView && editorView.dom instanceof HTMLElement) {
45
46
  var from = state.selection.from;
47
+
48
+ // if the node selected is an expand
46
49
  if (isExpandSelected(state.selection)) {
47
50
  var expand = editorView.nodeDOM(from);
48
- if (!expand || !(expand instanceof HTMLElement)) {
51
+ if (!expand) {
49
52
  return false;
50
53
  }
51
54
  return focusIcon(expand)(state, dispatch, editorView);
52
- } else if (state.selection instanceof TextSelection) {
53
- var _dom$node$parentEleme;
54
- var dom = editorView.domAtPos(from);
55
- var _expand = (_dom$node$parentEleme = dom.node.parentElement) === null || _dom$node$parentEleme === void 0 ? void 0 : _dom$node$parentEleme.parentElement;
56
- if (!_expand || !(_expand instanceof HTMLElement)) {
57
- return false;
55
+ }
56
+
57
+ // if the text selection is inside an expand
58
+ else if (state.selection instanceof TextSelection && !isInTable(state)) {
59
+ var _expand = findExpand(state);
60
+ if (_expand) {
61
+ var expandNode = editorView.nodeDOM(_expand.pos);
62
+ if (expandNode) {
63
+ return focusIcon(expandNode)(state, dispatch, editorView);
64
+ }
58
65
  }
59
- return focusIcon(_expand)(state, dispatch, editorView);
60
66
  }
61
67
  }
62
68
  return false;
@@ -124,6 +124,7 @@ export function handleExpandDrag(view, event, slice) {
124
124
  var dropLocationParentNodeType = resolvedPos.depth > 0 ? resolvedPos.node(resolvedPos.depth - 1).type : dropLocationNodeType;
125
125
  var nodesWithNestedExpandSupport = [state.schema.nodes.expand, state.schema.nodes.tableHeader, state.schema.nodes.tableCell];
126
126
  var isNodeAtDropPosInsideNodesWithNestedExpandSupport = nodesWithNestedExpandSupport.includes(dropLocationNodeType) || nodesWithNestedExpandSupport.includes(dropLocationParentNodeType);
127
+ var isNodeBeingDroppedInsideNestedExpand = dropLocationNodeType === state.schema.nodes.nestedExpand || dropLocationParentNodeType === state.schema.nodes.nestedExpand;
127
128
  if (editorExperiment('nested-expand-in-expand', false)) {
128
129
  if ((sliceContainsExpand || sliceContainsNestedExpand) && (dropLocationNodeType === state.schema.nodes.expand || dropLocationParentNodeType === state.schema.nodes.expand)) {
129
130
  event.preventDefault();
@@ -133,7 +134,7 @@ export function handleExpandDrag(view, event, slice) {
133
134
  var updatedSlice = slice;
134
135
  if (sliceContainsExpand && isNodeAtDropPosInsideNodesWithNestedExpandSupport) {
135
136
  updatedSlice = transformSliceExpandToNestedExpand(slice);
136
- } else if (sliceContainsNestedExpand && !isNodeAtDropPosInsideNodesWithNestedExpandSupport) {
137
+ } else if (sliceContainsNestedExpand && !isNodeAtDropPosInsideNodesWithNestedExpandSupport && !isNodeBeingDroppedInsideNestedExpand) {
137
138
  updatedSlice = transformSliceNestedExpandToExpand(slice, state.schema);
138
139
  }
139
140
  if (!updatedSlice || updatedSlice.eq(slice)) {
@@ -194,9 +194,11 @@ export var focusTitle = function focusTitle(pos) {
194
194
  };
195
195
  export var focusIcon = function focusIcon(expand) {
196
196
  return function (state, dispatch, editorView) {
197
- if (!expand || !(expand instanceof HTMLElement)) {
197
+ if (!(expand instanceof HTMLElement)) {
198
198
  return false;
199
199
  }
200
+
201
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
200
202
  var iconContainer = expand.querySelector(".".concat(expandClassNames.iconContainer));
201
203
  if (iconContainer && iconContainer.focus) {
202
204
  var tr = state.tr;
@@ -5,6 +5,7 @@ import { findExpand } from '@atlaskit/editor-common/transforms';
5
5
  import { isEmptyNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
6
6
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
7
7
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
8
+ import { isInTable } from '@atlaskit/editor-tables/utils';
8
9
  import { deleteExpand, focusIcon, focusTitle } from '../commands';
9
10
  var isExpandNode = function isExpandNode(node) {
10
11
  return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
@@ -43,20 +44,25 @@ export function expandKeymap(api, options) {
43
44
  bindKeymapWithCommand(tab.common, function (state, dispatch, editorView) {
44
45
  if (editorView && editorView.dom instanceof HTMLElement) {
45
46
  var from = state.selection.from;
47
+
48
+ // if the node selected is an expand
46
49
  if (isExpandSelected(state.selection)) {
47
50
  var expand = editorView.nodeDOM(from);
48
- if (!expand || !(expand instanceof HTMLElement)) {
51
+ if (!expand) {
49
52
  return false;
50
53
  }
51
54
  return focusIcon(expand)(state, dispatch, editorView);
52
- } else if (state.selection instanceof TextSelection) {
53
- var _dom$node$parentEleme;
54
- var dom = editorView.domAtPos(from);
55
- var _expand = (_dom$node$parentEleme = dom.node.parentElement) === null || _dom$node$parentEleme === void 0 ? void 0 : _dom$node$parentEleme.parentElement;
56
- if (!_expand || !(_expand instanceof HTMLElement)) {
57
- return false;
55
+ }
56
+
57
+ // if the text selection is inside an expand
58
+ else if (state.selection instanceof TextSelection && !isInTable(state)) {
59
+ var _expand = findExpand(state);
60
+ if (_expand) {
61
+ var expandNode = editorView.nodeDOM(_expand.pos);
62
+ if (expandNode) {
63
+ return focusIcon(expandNode)(state, dispatch, editorView);
64
+ }
58
65
  }
59
- return focusIcon(_expand)(state, dispatch, editorView);
60
66
  }
61
67
  }
62
68
  return false;
@@ -105,6 +105,7 @@ export function handleExpandDrag(view, event, slice) {
105
105
  var dropLocationParentNodeType = resolvedPos.depth > 0 ? resolvedPos.node(resolvedPos.depth - 1).type : dropLocationNodeType;
106
106
  var nodesWithNestedExpandSupport = [state.schema.nodes.expand, state.schema.nodes.tableHeader, state.schema.nodes.tableCell];
107
107
  var isNodeAtDropPosInsideNodesWithNestedExpandSupport = nodesWithNestedExpandSupport.includes(dropLocationNodeType) || nodesWithNestedExpandSupport.includes(dropLocationParentNodeType);
108
+ var isNodeBeingDroppedInsideNestedExpand = dropLocationNodeType === state.schema.nodes.nestedExpand || dropLocationParentNodeType === state.schema.nodes.nestedExpand;
108
109
  if (editorExperiment('nested-expand-in-expand', false)) {
109
110
  if ((sliceContainsExpand || sliceContainsNestedExpand) && (dropLocationNodeType === state.schema.nodes.expand || dropLocationParentNodeType === state.schema.nodes.expand)) {
110
111
  event.preventDefault();
@@ -114,7 +115,7 @@ export function handleExpandDrag(view, event, slice) {
114
115
  var updatedSlice = slice;
115
116
  if (sliceContainsExpand && isNodeAtDropPosInsideNodesWithNestedExpandSupport) {
116
117
  updatedSlice = transformSliceExpandToNestedExpand(slice);
117
- } else if (sliceContainsNestedExpand && !isNodeAtDropPosInsideNodesWithNestedExpandSupport) {
118
+ } else if (sliceContainsNestedExpand && !isNodeAtDropPosInsideNodesWithNestedExpandSupport && !isNodeBeingDroppedInsideNestedExpand) {
118
119
  updatedSlice = transformSliceNestedExpandToExpand(slice, state.schema);
119
120
  }
120
121
  if (!updatedSlice || updatedSlice.eq(slice)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-expand",
3
- "version": "2.7.3",
3
+ "version": "2.7.5",
4
4
  "description": "Expand plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^40.9.0",
35
35
  "@atlaskit/button": "^20.1.0",
36
- "@atlaskit/editor-common": "^90.0.0",
36
+ "@atlaskit/editor-common": "^91.0.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
38
38
  "@atlaskit/editor-plugin-decorations": "^1.3.0",
39
39
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",