@atlaskit/editor-plugin-expand 2.7.4 → 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,15 @@
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
+
3
13
  ## 2.7.4
4
14
 
5
15
  ### 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)) {
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-expand",
3
- "version": "2.7.4",
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.1.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",