@atlaskit/editor-plugin-expand 2.5.4 → 2.6.1

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,26 @@
1
1
  # @atlaskit/editor-plugin-expand
2
2
 
3
+ ## 2.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#138299](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/138299)
8
+ [`7bab5c1cce65c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7bab5c1cce65c) -
9
+ [ED-24860] Split out ADF schema change for nesting nestedExpand in expand
10
+ - [#138118](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/138118)
11
+ [`5e4d9eb1aefe4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5e4d9eb1aefe4) -
12
+ NOISSUE: Upgrades editor React peer dependencies to v18
13
+ - Updated dependencies
14
+
15
+ ## 2.6.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [#134731](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/134731)
20
+ [`07dc34f5168a0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/07dc34f5168a0) -
21
+ [ux] ED-23190 This change allows users to navigate using Tab when there are multiple expands on
22
+ the page. Previously, users could only navigate around the 1st expand on the page with Tab.
23
+
3
24
  ## 2.5.4
4
25
 
5
26
  ### Patch Changes
@@ -4,11 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.updateExpandTitle = exports.toggleExpandExpanded = exports.setSelectionInsideExpand = exports.setExpandRef = exports.insertExpandWithInputMethod = exports.insertExpand = exports.focusTitle = exports.deleteExpandAtPos = exports.deleteExpand = exports.createExpandNode = void 0;
7
+ exports.updateExpandTitle = exports.toggleExpandExpanded = exports.setSelectionInsideExpand = exports.setExpandRef = exports.insertExpandWithInputMethod = exports.insertExpand = exports.focusTitle = exports.focusIcon = exports.deleteExpandAtPos = exports.deleteExpand = exports.createExpandNode = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _steps = require("@atlaskit/adf-schema/steps");
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _selection = require("@atlaskit/editor-common/selection");
12
+ var _styles = require("@atlaskit/editor-common/styles");
12
13
  var _utils = require("@atlaskit/editor-common/utils");
13
14
  var _state2 = require("@atlaskit/editor-prosemirror/state");
14
15
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
@@ -195,6 +196,26 @@ var focusTitle = exports.focusTitle = function focusTitle(pos) {
195
196
  return false;
196
197
  };
197
198
  };
199
+ var focusIcon = exports.focusIcon = function focusIcon(expand) {
200
+ return function (state, dispatch, editorView) {
201
+ if (!expand || !(expand instanceof HTMLElement)) {
202
+ return false;
203
+ }
204
+ var iconContainer = expand.querySelector(".".concat(_styles.expandClassNames.iconContainer));
205
+ if (iconContainer && iconContainer.focus) {
206
+ var tr = state.tr;
207
+ var pos = state.selection.from;
208
+ tr.setSelection(new _state2.TextSelection(tr.doc.resolve(pos)));
209
+ if (dispatch) {
210
+ dispatch(tr);
211
+ }
212
+ editorView === null || editorView === void 0 || editorView.dom.blur();
213
+ iconContainer.focus();
214
+ return true;
215
+ }
216
+ return false;
217
+ };
218
+ };
198
219
 
199
220
  // Used to clear any node or cell selection when expand title is focused
200
221
  var setSelectionInsideExpand = exports.setSelectionInsideExpand = function setSelectionInsideExpand(expandPos) {
@@ -30,13 +30,14 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
30
30
  api = _ref.api;
31
31
  // Confluence is injecting the FF through editor props, from an experiment
32
32
  // Jira is pulling it in through platform feature flags, from a feature gate
33
+ var isNestingExpandsSchemaChanged = (0, _platformFeatureFlags.fg)('platform_editor_nested_expand_in_expand_adf_change') || (0, _platformFeatureFlags.fg)('platform_editor_nest_nested_expand_in_expand_jira');
33
34
  var isNestingExpandsSupported = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 || (_api$featureFlags = _api$featureFlags.sharedState.currentState()) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.nestedExpandInExpandEx) || (0, _platformFeatureFlags.fg)('platform_editor_nest_nested_expand_in_expand_jira');
34
35
  return {
35
36
  name: 'expand',
36
37
  nodes: function nodes() {
37
38
  return [{
38
39
  name: 'expand',
39
- node: isNestingExpandsSupported ? _adfSchema.expandWithNestedExpand : _adfSchema.expand
40
+ node: isNestingExpandsSchemaChanged ? _adfSchema.expandWithNestedExpand : _adfSchema.expand
40
41
  }, {
41
42
  name: 'nestedExpand',
42
43
  node: _adfSchema.nestedExpand
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.expandKeymap = expandKeymap;
7
7
  var _keymaps = require("@atlaskit/editor-common/keymaps");
8
8
  var _selection = require("@atlaskit/editor-common/selection");
9
- var _styles = require("@atlaskit/editor-common/styles");
10
9
  var _utils = require("@atlaskit/editor-common/utils");
11
10
  var _keymap = require("@atlaskit/editor-prosemirror/keymap");
12
11
  var _state = require("@atlaskit/editor-prosemirror/state");
@@ -48,24 +47,23 @@ function expandKeymap(api, options) {
48
47
  return false;
49
48
  }, list);
50
49
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.tab.common, function (state, dispatch, editorView) {
51
- if (state.selection instanceof _state.NodeSelection && state.selection.node.type === state.schema.nodes.expand && editorView && editorView.dom instanceof HTMLElement) {
50
+ if (editorView && editorView.dom instanceof HTMLElement) {
52
51
  var from = state.selection.from;
53
- var expand = editorView.nodeDOM(from);
54
- if (!expand || !(expand instanceof HTMLElement)) {
55
- return false;
56
- }
57
- var iconContainer = expand.querySelector(".".concat(_styles.expandClassNames.iconContainer));
58
- if (iconContainer && iconContainer.focus) {
59
- var tr = state.tr;
60
- var pos = state.selection.from;
61
- tr.setSelection(new _state.TextSelection(tr.doc.resolve(pos)));
62
- if (dispatch) {
63
- dispatch(tr);
52
+ if (isExpandSelected(state.selection)) {
53
+ var expand = editorView.nodeDOM(from);
54
+ if (!expand || !(expand instanceof HTMLElement)) {
55
+ return false;
56
+ }
57
+ 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;
64
64
  }
65
- editorView.dom.blur();
66
- iconContainer.focus();
65
+ return (0, _commands.focusIcon)(_expand)(state, dispatch, editorView);
67
66
  }
68
- return true;
69
67
  }
70
68
  return false;
71
69
  }, list);
@@ -4,12 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.updateExpandTitle = exports.toggleExpandExpanded = exports.setSelectionInsideExpand = exports.insertExpandWithInputMethod = exports.insertExpand = exports.focusTitle = exports.deleteExpandAtPos = exports.deleteExpand = exports.createExpandNode = void 0;
7
+ exports.updateExpandTitle = exports.toggleExpandExpanded = exports.setSelectionInsideExpand = exports.insertExpandWithInputMethod = exports.insertExpand = exports.focusTitle = exports.focusIcon = exports.deleteExpandAtPos = exports.deleteExpand = exports.createExpandNode = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _steps = require("@atlaskit/adf-schema/steps");
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _expand = require("@atlaskit/editor-common/expand");
12
12
  var _selection = require("@atlaskit/editor-common/selection");
13
+ var _styles = require("@atlaskit/editor-common/styles");
13
14
  var _transforms = require("@atlaskit/editor-common/transforms");
14
15
  var _utils = require("@atlaskit/editor-common/utils");
15
16
  var _state2 = require("@atlaskit/editor-prosemirror/state");
@@ -204,4 +205,24 @@ var focusTitle = exports.focusTitle = function focusTitle(pos) {
204
205
  }
205
206
  return false;
206
207
  };
208
+ };
209
+ var focusIcon = exports.focusIcon = function focusIcon(expand) {
210
+ return function (state, dispatch, editorView) {
211
+ if (!expand || !(expand instanceof HTMLElement)) {
212
+ return false;
213
+ }
214
+ var iconContainer = expand.querySelector(".".concat(_styles.expandClassNames.iconContainer));
215
+ if (iconContainer && iconContainer.focus) {
216
+ var tr = state.tr;
217
+ var pos = state.selection.from;
218
+ tr.setSelection(new _state2.TextSelection(tr.doc.resolve(pos)));
219
+ if (dispatch) {
220
+ dispatch(tr);
221
+ }
222
+ editorView === null || editorView === void 0 || editorView.dom.blur();
223
+ iconContainer.focus();
224
+ return true;
225
+ }
226
+ return false;
227
+ };
207
228
  };
@@ -23,13 +23,14 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
23
23
  api = _ref.api;
24
24
  // Confluence is injecting the FF through editor props, from an experiment
25
25
  // Jira is pulling it in through platform feature flags, from a feature gate
26
+ var isNestingExpandsSchemaChanged = (0, _platformFeatureFlags.fg)('platform_editor_nested_expand_in_expand_adf_change') || (0, _platformFeatureFlags.fg)('platform_editor_nest_nested_expand_in_expand_jira');
26
27
  var isNestingExpandsSupported = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 || (_api$featureFlags = _api$featureFlags.sharedState.currentState()) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.nestedExpandInExpandEx) || (0, _platformFeatureFlags.fg)('platform_editor_nest_nested_expand_in_expand_jira');
27
28
  return {
28
29
  name: 'expand',
29
30
  nodes: function nodes() {
30
31
  return [{
31
32
  name: 'expand',
32
- node: isNestingExpandsSupported ? _adfSchema.expandWithNestedExpand : _adfSchema.expand
33
+ node: isNestingExpandsSchemaChanged ? _adfSchema.expandWithNestedExpand : _adfSchema.expand
33
34
  }, {
34
35
  name: 'nestedExpand',
35
36
  node: _adfSchema.nestedExpand
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.expandKeymap = expandKeymap;
7
- var _expand = require("@atlaskit/editor-common/expand");
7
+ var _expand2 = require("@atlaskit/editor-common/expand");
8
8
  var _keymaps = require("@atlaskit/editor-common/keymaps");
9
9
  var _selection = require("@atlaskit/editor-common/selection");
10
10
  var _transforms = require("@atlaskit/editor-common/transforms");
@@ -46,6 +46,27 @@ function expandKeymap(api, options) {
46
46
  }
47
47
  return false;
48
48
  }, list);
49
+ (0, _keymaps.bindKeymapWithCommand)(_keymaps.tab.common, function (state, dispatch, editorView) {
50
+ if (editorView && editorView.dom instanceof HTMLElement) {
51
+ var from = state.selection.from;
52
+ if (isExpandSelected(state.selection)) {
53
+ var expand = editorView.nodeDOM(from);
54
+ if (!expand || !(expand instanceof HTMLElement)) {
55
+ return false;
56
+ }
57
+ 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;
64
+ }
65
+ return (0, _commands.focusIcon)(_expand)(state, dispatch, editorView);
66
+ }
67
+ }
68
+ return false;
69
+ }, list);
49
70
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.moveUp.common, function (state, dispatch, editorView) {
50
71
  if (!editorView) {
51
72
  return false;
@@ -53,7 +74,7 @@ function expandKeymap(api, options) {
53
74
  var selection = state.selection,
54
75
  schema = state.schema;
55
76
  var nodeBefore = selection.$from.nodeBefore;
56
- if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && (0, _expand.isExpandCollapsed)(nodeBefore)) {
77
+ if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && (0, _expand2.isExpandCollapsed)(nodeBefore)) {
57
78
  var _$from = selection.$from;
58
79
  return (0, _commands.focusTitle)(Math.max(_$from.pos - 1, 0))(state, dispatch, editorView);
59
80
  }
@@ -77,7 +98,7 @@ function expandKeymap(api, options) {
77
98
  var expandBefore = (0, _transforms.findExpand)(state, sel);
78
99
  if (sel && expandBefore) {
79
100
  // moving cursor from outside of an expand to the title when it is collapsed
80
- if ((0, _expand.isExpandCollapsed)(expandBefore.node)) {
101
+ if ((0, _expand2.isExpandCollapsed)(expandBefore.node)) {
81
102
  return (0, _commands.focusTitle)(expandBefore.start)(state, dispatch, editorView);
82
103
  }
83
104
  // moving cursor from outside of an expand to the content when it is expanded
@@ -98,7 +119,7 @@ function expandKeymap(api, options) {
98
119
  nestedExpand = _state$schema$nodes.nestedExpand;
99
120
  var selection = state.selection;
100
121
  var nodeAfter = selection.$from.nodeAfter;
101
- if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && (0, _expand.isExpandCollapsed)(nodeAfter)) {
122
+ if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && (0, _expand2.isExpandCollapsed)(nodeAfter)) {
102
123
  var $from = selection.$from;
103
124
  return (0, _commands.focusTitle)($from.pos + 1)(state, dispatch, editorView);
104
125
  }
@@ -128,7 +149,7 @@ function expandKeymap(api, options) {
128
149
  // @see ED-7977
129
150
  var sel = _state.Selection.findFrom(state.doc.resolve(Math.max(selection.$from.pos - 1, 0)), -1);
130
151
  var expandBefore = (0, _transforms.findExpand)(state, sel);
131
- if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && (0, _expand.isExpandCollapsed)(expandBefore.node)) {
152
+ if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && (0, _expand2.isExpandCollapsed)(expandBefore.node)) {
132
153
  return (0, _commands.focusTitle)(expandBefore.start)(state, dispatch, editorView);
133
154
  }
134
155
  return false;
@@ -1,8 +1,9 @@
1
1
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
3
3
  import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
4
+ import { expandClassNames } from '@atlaskit/editor-common/styles';
4
5
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
5
- import { Selection } from '@atlaskit/editor-prosemirror/state';
6
+ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
7
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
7
8
  import { findTable } from '@atlaskit/editor-tables/utils';
8
9
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -176,6 +177,26 @@ export const focusTitle = pos => (state, dispatch, editorView) => {
176
177
  }
177
178
  return false;
178
179
  };
180
+ export const focusIcon = expand => (state, dispatch, editorView) => {
181
+ if (!expand || !(expand instanceof HTMLElement)) {
182
+ return false;
183
+ }
184
+ const iconContainer = expand.querySelector(`.${expandClassNames.iconContainer}`);
185
+ if (iconContainer && iconContainer.focus) {
186
+ const {
187
+ tr
188
+ } = state;
189
+ const pos = state.selection.from;
190
+ tr.setSelection(new TextSelection(tr.doc.resolve(pos)));
191
+ if (dispatch) {
192
+ dispatch(tr);
193
+ }
194
+ editorView === null || editorView === void 0 ? void 0 : editorView.dom.blur();
195
+ iconContainer.focus();
196
+ return true;
197
+ }
198
+ return false;
199
+ };
179
200
 
180
201
  // Used to clear any node or cell selection when expand title is focused
181
202
  export const setSelectionInsideExpand = expandPos => (_state, dispatch, editorView) => {
@@ -17,13 +17,14 @@ export const expandPlugin = ({
17
17
  var _api$featureFlags, _api$featureFlags$sha, _api$analytics, _api$analytics2;
18
18
  // Confluence is injecting the FF through editor props, from an experiment
19
19
  // Jira is pulling it in through platform feature flags, from a feature gate
20
+ const isNestingExpandsSchemaChanged = fg('platform_editor_nested_expand_in_expand_adf_change') || fg('platform_editor_nest_nested_expand_in_expand_jira');
20
21
  const isNestingExpandsSupported = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : (_api$featureFlags$sha = _api$featureFlags.sharedState.currentState()) === null || _api$featureFlags$sha === void 0 ? void 0 : _api$featureFlags$sha.nestedExpandInExpandEx) || fg('platform_editor_nest_nested_expand_in_expand_jira');
21
22
  return {
22
23
  name: 'expand',
23
24
  nodes() {
24
25
  return [{
25
26
  name: 'expand',
26
- node: isNestingExpandsSupported ? expandWithNestedExpand : expand
27
+ node: isNestingExpandsSchemaChanged ? expandWithNestedExpand : expand
27
28
  }, {
28
29
  name: 'nestedExpand',
29
30
  node: nestedExpand
@@ -1,11 +1,10 @@
1
1
  import { backspace, bindKeymapWithCommand, moveDown, moveLeft, moveRight, moveUp, tab } from '@atlaskit/editor-common/keymaps';
2
2
  import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
3
- import { expandClassNames } from '@atlaskit/editor-common/styles';
4
3
  import { isEmptyNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
5
4
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
6
5
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
7
6
  import { fg } from '@atlaskit/platform-feature-flags';
8
- import { deleteExpand, focusTitle } from '../commands';
7
+ import { deleteExpand, focusIcon, focusTitle } from '../commands';
9
8
  import { findExpand } from '../utils';
10
9
  const isExpandNode = node => {
11
10
  return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
@@ -48,28 +47,25 @@ export function expandKeymap(api, options) {
48
47
  return false;
49
48
  }, list);
50
49
  bindKeymapWithCommand(tab.common, (state, dispatch, editorView) => {
51
- if (state.selection instanceof NodeSelection && state.selection.node.type === state.schema.nodes.expand && editorView && editorView.dom instanceof HTMLElement) {
50
+ if (editorView && editorView.dom instanceof HTMLElement) {
52
51
  const {
53
52
  from
54
53
  } = state.selection;
55
- const expand = editorView.nodeDOM(from);
56
- if (!expand || !(expand instanceof HTMLElement)) {
57
- return false;
58
- }
59
- const iconContainer = expand.querySelector(`.${expandClassNames.iconContainer}`);
60
- if (iconContainer && iconContainer.focus) {
61
- const {
62
- tr
63
- } = state;
64
- const pos = state.selection.from;
65
- tr.setSelection(new TextSelection(tr.doc.resolve(pos)));
66
- if (dispatch) {
67
- dispatch(tr);
54
+ if (isExpandSelected(state.selection)) {
55
+ const expand = editorView.nodeDOM(from);
56
+ if (!expand || !(expand instanceof HTMLElement)) {
57
+ return false;
58
+ }
59
+ 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;
68
66
  }
69
- editorView.dom.blur();
70
- iconContainer.focus();
67
+ return focusIcon(expand)(state, dispatch, editorView);
71
68
  }
72
- return true;
73
69
  }
74
70
  return false;
75
71
  }, list);
@@ -2,9 +2,10 @@ import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
3
3
  import { expandedState } from '@atlaskit/editor-common/expand';
4
4
  import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
5
+ import { expandClassNames } from '@atlaskit/editor-common/styles';
5
6
  import { findExpand } from '@atlaskit/editor-common/transforms';
6
7
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
7
- import { Selection } from '@atlaskit/editor-prosemirror/state';
8
+ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
8
9
  import { findParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
9
10
  import { findTable } from '@atlaskit/editor-tables/utils';
10
11
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -183,4 +184,24 @@ export const focusTitle = pos => (state, dispatch, editorView) => {
183
184
  }
184
185
  }
185
186
  return false;
187
+ };
188
+ export const focusIcon = expand => (state, dispatch, editorView) => {
189
+ if (!expand || !(expand instanceof HTMLElement)) {
190
+ return false;
191
+ }
192
+ const iconContainer = expand.querySelector(`.${expandClassNames.iconContainer}`);
193
+ if (iconContainer && iconContainer.focus) {
194
+ const {
195
+ tr
196
+ } = state;
197
+ const pos = state.selection.from;
198
+ tr.setSelection(new TextSelection(tr.doc.resolve(pos)));
199
+ if (dispatch) {
200
+ dispatch(tr);
201
+ }
202
+ editorView === null || editorView === void 0 ? void 0 : editorView.dom.blur();
203
+ iconContainer.focus();
204
+ return true;
205
+ }
206
+ return false;
186
207
  };
@@ -16,13 +16,14 @@ export const expandPlugin = ({
16
16
  var _api$featureFlags, _api$featureFlags$sha, _api$analytics, _api$analytics2;
17
17
  // Confluence is injecting the FF through editor props, from an experiment
18
18
  // Jira is pulling it in through platform feature flags, from a feature gate
19
+ const isNestingExpandsSchemaChanged = fg('platform_editor_nested_expand_in_expand_adf_change') || fg('platform_editor_nest_nested_expand_in_expand_jira');
19
20
  const isNestingExpandsSupported = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : (_api$featureFlags$sha = _api$featureFlags.sharedState.currentState()) === null || _api$featureFlags$sha === void 0 ? void 0 : _api$featureFlags$sha.nestedExpandInExpandEx) || fg('platform_editor_nest_nested_expand_in_expand_jira');
20
21
  return {
21
22
  name: 'expand',
22
23
  nodes() {
23
24
  return [{
24
25
  name: 'expand',
25
- node: isNestingExpandsSupported ? expandWithNestedExpand : expand
26
+ node: isNestingExpandsSchemaChanged ? expandWithNestedExpand : expand
26
27
  }, {
27
28
  name: 'nestedExpand',
28
29
  node: nestedExpand
@@ -1,11 +1,11 @@
1
1
  import { isExpandCollapsed } from '@atlaskit/editor-common/expand';
2
- import { backspace, bindKeymapWithCommand, moveDown, moveLeft, moveRight, moveUp } from '@atlaskit/editor-common/keymaps';
2
+ import { backspace, bindKeymapWithCommand, moveDown, moveLeft, moveRight, moveUp, tab } from '@atlaskit/editor-common/keymaps';
3
3
  import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
4
4
  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
- import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
8
- import { deleteExpand, focusTitle } from '../commands';
7
+ import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
8
+ import { deleteExpand, focusIcon, focusTitle } from '../commands';
9
9
  const isExpandNode = node => {
10
10
  return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
11
11
  };
@@ -46,6 +46,29 @@ export function expandKeymap(api, options) {
46
46
  }
47
47
  return false;
48
48
  }, list);
49
+ bindKeymapWithCommand(tab.common, (state, dispatch, editorView) => {
50
+ if (editorView && editorView.dom instanceof HTMLElement) {
51
+ const {
52
+ from
53
+ } = state.selection;
54
+ if (isExpandSelected(state.selection)) {
55
+ const expand = editorView.nodeDOM(from);
56
+ if (!expand || !(expand instanceof HTMLElement)) {
57
+ return false;
58
+ }
59
+ 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;
66
+ }
67
+ return focusIcon(expand)(state, dispatch, editorView);
68
+ }
69
+ }
70
+ return false;
71
+ }, list);
49
72
  bindKeymapWithCommand(moveUp.common, (state, dispatch, editorView) => {
50
73
  if (!editorView) {
51
74
  return false;
@@ -4,8 +4,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
5
5
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
6
6
  import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
7
+ import { expandClassNames } from '@atlaskit/editor-common/styles';
7
8
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
8
- import { Selection } from '@atlaskit/editor-prosemirror/state';
9
+ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
9
10
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
10
11
  import { findTable } from '@atlaskit/editor-tables/utils';
11
12
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -188,6 +189,26 @@ export var focusTitle = function focusTitle(pos) {
188
189
  return false;
189
190
  };
190
191
  };
192
+ export var focusIcon = function focusIcon(expand) {
193
+ return function (state, dispatch, editorView) {
194
+ if (!expand || !(expand instanceof HTMLElement)) {
195
+ return false;
196
+ }
197
+ var iconContainer = expand.querySelector(".".concat(expandClassNames.iconContainer));
198
+ if (iconContainer && iconContainer.focus) {
199
+ var tr = state.tr;
200
+ var pos = state.selection.from;
201
+ tr.setSelection(new TextSelection(tr.doc.resolve(pos)));
202
+ if (dispatch) {
203
+ dispatch(tr);
204
+ }
205
+ editorView === null || editorView === void 0 || editorView.dom.blur();
206
+ iconContainer.focus();
207
+ return true;
208
+ }
209
+ return false;
210
+ };
211
+ };
191
212
 
192
213
  // Used to clear any node or cell selection when expand title is focused
193
214
  export var setSelectionInsideExpand = function setSelectionInsideExpand(expandPos) {
@@ -17,13 +17,14 @@ export var expandPlugin = function expandPlugin(_ref) {
17
17
  api = _ref.api;
18
18
  // Confluence is injecting the FF through editor props, from an experiment
19
19
  // Jira is pulling it in through platform feature flags, from a feature gate
20
+ var isNestingExpandsSchemaChanged = fg('platform_editor_nested_expand_in_expand_adf_change') || fg('platform_editor_nest_nested_expand_in_expand_jira');
20
21
  var isNestingExpandsSupported = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 || (_api$featureFlags = _api$featureFlags.sharedState.currentState()) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.nestedExpandInExpandEx) || fg('platform_editor_nest_nested_expand_in_expand_jira');
21
22
  return {
22
23
  name: 'expand',
23
24
  nodes: function nodes() {
24
25
  return [{
25
26
  name: 'expand',
26
- node: isNestingExpandsSupported ? expandWithNestedExpand : expand
27
+ node: isNestingExpandsSchemaChanged ? expandWithNestedExpand : expand
27
28
  }, {
28
29
  name: 'nestedExpand',
29
30
  node: nestedExpand
@@ -1,11 +1,10 @@
1
1
  import { backspace, bindKeymapWithCommand, moveDown, moveLeft, moveRight, moveUp, tab } from '@atlaskit/editor-common/keymaps';
2
2
  import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
3
- import { expandClassNames } from '@atlaskit/editor-common/styles';
4
3
  import { isEmptyNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
5
4
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
6
5
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
7
6
  import { fg } from '@atlaskit/platform-feature-flags';
8
- import { deleteExpand, focusTitle } from '../commands';
7
+ import { deleteExpand, focusIcon, focusTitle } from '../commands';
9
8
  import { findExpand } from '../utils';
10
9
  var isExpandNode = function isExpandNode(node) {
11
10
  return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
@@ -42,24 +41,23 @@ export function expandKeymap(api, options) {
42
41
  return false;
43
42
  }, list);
44
43
  bindKeymapWithCommand(tab.common, function (state, dispatch, editorView) {
45
- if (state.selection instanceof NodeSelection && state.selection.node.type === state.schema.nodes.expand && editorView && editorView.dom instanceof HTMLElement) {
44
+ if (editorView && editorView.dom instanceof HTMLElement) {
46
45
  var from = state.selection.from;
47
- var expand = editorView.nodeDOM(from);
48
- if (!expand || !(expand instanceof HTMLElement)) {
49
- return false;
50
- }
51
- var iconContainer = expand.querySelector(".".concat(expandClassNames.iconContainer));
52
- if (iconContainer && iconContainer.focus) {
53
- var tr = state.tr;
54
- var pos = state.selection.from;
55
- tr.setSelection(new TextSelection(tr.doc.resolve(pos)));
56
- if (dispatch) {
57
- dispatch(tr);
46
+ if (isExpandSelected(state.selection)) {
47
+ var expand = editorView.nodeDOM(from);
48
+ if (!expand || !(expand instanceof HTMLElement)) {
49
+ return false;
50
+ }
51
+ 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;
58
58
  }
59
- editorView.dom.blur();
60
- iconContainer.focus();
59
+ return focusIcon(_expand)(state, dispatch, editorView);
61
60
  }
62
- return true;
63
61
  }
64
62
  return false;
65
63
  }, list);
@@ -5,9 +5,10 @@ import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
5
5
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
6
6
  import { expandedState } from '@atlaskit/editor-common/expand';
7
7
  import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
8
+ import { expandClassNames } from '@atlaskit/editor-common/styles';
8
9
  import { findExpand } from '@atlaskit/editor-common/transforms';
9
10
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
10
- import { Selection } from '@atlaskit/editor-prosemirror/state';
11
+ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
11
12
  import { findParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
12
13
  import { findTable } from '@atlaskit/editor-tables/utils';
13
14
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -198,4 +199,24 @@ export var focusTitle = function focusTitle(pos) {
198
199
  }
199
200
  return false;
200
201
  };
202
+ };
203
+ export var focusIcon = function focusIcon(expand) {
204
+ return function (state, dispatch, editorView) {
205
+ if (!expand || !(expand instanceof HTMLElement)) {
206
+ return false;
207
+ }
208
+ var iconContainer = expand.querySelector(".".concat(expandClassNames.iconContainer));
209
+ if (iconContainer && iconContainer.focus) {
210
+ var tr = state.tr;
211
+ var pos = state.selection.from;
212
+ tr.setSelection(new TextSelection(tr.doc.resolve(pos)));
213
+ if (dispatch) {
214
+ dispatch(tr);
215
+ }
216
+ editorView === null || editorView === void 0 || editorView.dom.blur();
217
+ iconContainer.focus();
218
+ return true;
219
+ }
220
+ return false;
221
+ };
201
222
  };
@@ -16,13 +16,14 @@ export var expandPlugin = function expandPlugin(_ref) {
16
16
  api = _ref.api;
17
17
  // Confluence is injecting the FF through editor props, from an experiment
18
18
  // Jira is pulling it in through platform feature flags, from a feature gate
19
+ var isNestingExpandsSchemaChanged = fg('platform_editor_nested_expand_in_expand_adf_change') || fg('platform_editor_nest_nested_expand_in_expand_jira');
19
20
  var isNestingExpandsSupported = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 || (_api$featureFlags = _api$featureFlags.sharedState.currentState()) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.nestedExpandInExpandEx) || fg('platform_editor_nest_nested_expand_in_expand_jira');
20
21
  return {
21
22
  name: 'expand',
22
23
  nodes: function nodes() {
23
24
  return [{
24
25
  name: 'expand',
25
- node: isNestingExpandsSupported ? expandWithNestedExpand : expand
26
+ node: isNestingExpandsSchemaChanged ? expandWithNestedExpand : expand
26
27
  }, {
27
28
  name: 'nestedExpand',
28
29
  node: nestedExpand
@@ -1,11 +1,11 @@
1
1
  import { isExpandCollapsed } from '@atlaskit/editor-common/expand';
2
- import { backspace, bindKeymapWithCommand, moveDown, moveLeft, moveRight, moveUp } from '@atlaskit/editor-common/keymaps';
2
+ import { backspace, bindKeymapWithCommand, moveDown, moveLeft, moveRight, moveUp, tab } from '@atlaskit/editor-common/keymaps';
3
3
  import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
4
4
  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
- import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
8
- import { deleteExpand, focusTitle } from '../commands';
7
+ import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
8
+ import { deleteExpand, focusIcon, focusTitle } from '../commands';
9
9
  var isExpandNode = function isExpandNode(node) {
10
10
  return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
11
11
  };
@@ -40,6 +40,27 @@ export function expandKeymap(api, options) {
40
40
  }
41
41
  return false;
42
42
  }, list);
43
+ bindKeymapWithCommand(tab.common, function (state, dispatch, editorView) {
44
+ if (editorView && editorView.dom instanceof HTMLElement) {
45
+ var from = state.selection.from;
46
+ if (isExpandSelected(state.selection)) {
47
+ var expand = editorView.nodeDOM(from);
48
+ if (!expand || !(expand instanceof HTMLElement)) {
49
+ return false;
50
+ }
51
+ 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;
58
+ }
59
+ return focusIcon(_expand)(state, dispatch, editorView);
60
+ }
61
+ }
62
+ return false;
63
+ }, list);
43
64
  bindKeymapWithCommand(moveUp.common, function (state, dispatch, editorView) {
44
65
  if (!editorView) {
45
66
  return false;
@@ -22,4 +22,5 @@ export declare const createExpandNode: (state: EditorState, isNestingExpandsSupp
22
22
  export declare const insertExpandWithInputMethod: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported?: boolean) => (inputMethod: InsertMethod) => Command;
23
23
  export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported?: boolean) => Command;
24
24
  export declare const focusTitle: (pos: number) => Command;
25
+ export declare const focusIcon: (expand: Node) => Command;
25
26
  export declare const setSelectionInsideExpand: (expandPos: number) => Command;
@@ -20,3 +20,4 @@ export declare const updateExpandTitle: ({ title, nodeType, pos }: {
20
20
  nodeType: NodeType;
21
21
  }) => Command;
22
22
  export declare const focusTitle: (pos: number) => Command;
23
+ export declare const focusIcon: (expand: Node) => Command;
@@ -22,4 +22,5 @@ export declare const createExpandNode: (state: EditorState, isNestingExpandsSupp
22
22
  export declare const insertExpandWithInputMethod: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported?: boolean) => (inputMethod: InsertMethod) => Command;
23
23
  export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported?: boolean) => Command;
24
24
  export declare const focusTitle: (pos: number) => Command;
25
+ export declare const focusIcon: (expand: Node) => Command;
25
26
  export declare const setSelectionInsideExpand: (expandPos: number) => Command;
@@ -20,3 +20,4 @@ export declare const updateExpandTitle: ({ title, nodeType, pos }: {
20
20
  nodeType: NodeType;
21
21
  }) => Command;
22
22
  export declare const focusTitle: (pos: number) => Command;
23
+ export declare const focusIcon: (expand: Node) => Command;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-expand",
3
- "version": "2.5.4",
3
+ "version": "2.6.1",
4
4
  "description": "Expand plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -10,9 +10,7 @@
10
10
  "atlassian": {
11
11
  "team": "Editor: Jenga",
12
12
  "singleton": true,
13
- "inPublicMirror": false,
14
- "releaseModel": "continuous",
15
- "runReact18": false
13
+ "runReact18": true
16
14
  },
17
15
  "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
18
16
  "main": "dist/cjs/index.js",
@@ -35,7 +33,7 @@
35
33
  "dependencies": {
36
34
  "@atlaskit/adf-schema": "^40.9.0",
37
35
  "@atlaskit/button": "^20.1.0",
38
- "@atlaskit/editor-common": "^88.2.0",
36
+ "@atlaskit/editor-common": "^88.12.0",
39
37
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
40
38
  "@atlaskit/editor-plugin-decorations": "^1.3.0",
41
39
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
@@ -44,7 +42,7 @@
44
42
  "@atlaskit/editor-prosemirror": "5.0.1",
45
43
  "@atlaskit/editor-shared-styles": "^2.13.0",
46
44
  "@atlaskit/editor-tables": "^2.8.0",
47
- "@atlaskit/icon": "^22.15.0",
45
+ "@atlaskit/icon": "^22.16.0",
48
46
  "@atlaskit/platform-feature-flags": "^0.3.0",
49
47
  "@atlaskit/tooltip": "^18.7.0",
50
48
  "@babel/runtime": "^7.0.0",
@@ -52,8 +50,8 @@
52
50
  "w3c-keyname": "^2.1.8"
53
51
  },
54
52
  "peerDependencies": {
55
- "react": "^16.8.0",
56
- "react-dom": "^16.8.0",
53
+ "react": "^16.8.0 || ^17.0.0 || ~18.2.0",
54
+ "react-dom": "^16.8.0 || ^17.0.0 || ~18.2.0",
57
55
  "react-intl-next": "npm:react-intl@^5.18.1"
58
56
  },
59
57
  "devDependencies": {
@@ -116,6 +114,9 @@
116
114
  },
117
115
  "platform_editor_nest_nested_expand_in_expand_jira": {
118
116
  "type": "boolean"
117
+ },
118
+ "platform_editor_nested_expand_in_expand_adf_change": {
119
+ "type": "boolean"
119
120
  }
120
121
  }
121
122
  }