@atlaskit/editor-plugin-expand 2.7.4 → 2.7.6

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.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#144606](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/144606)
8
+ [`20ab1284d9880`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/20ab1284d9880) -
9
+ ED-24990 - Bugfix: cursor was going outside of parent expand and table cell when nested expand was
10
+ deleted.
11
+
12
+ ## 2.7.5
13
+
14
+ ### Patch Changes
15
+
16
+ - [#143199](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/143199)
17
+ [`2c7282d335256`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2c7282d335256) -
18
+ [ux] [ED-24799] This change allows users to navigate using Tab when there are multiple expands on
19
+ the page. Previously, users could only navigate around the 1st expand on the page with Tab.
20
+ - Updated dependencies
21
+
3
22
  ## 2.7.4
4
23
 
5
24
  ### Patch Changes
@@ -15,6 +15,7 @@ var _state2 = require("@atlaskit/editor-prosemirror/state");
15
15
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
16
16
  var _utils3 = require("@atlaskit/editor-tables/utils");
17
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
19
  var _utils4 = require("../utils");
19
20
  var _pluginFactory = require("./pm-plugins/plugin-factory");
20
21
  var _utils5 = require("./utils");
@@ -48,6 +49,14 @@ var deleteExpandAtPos = exports.deleteExpandAtPos = function deleteExpandAtPos(e
48
49
  var tr = state.tr;
49
50
  tr.delete(expandNodePos, expandNodePos + expandNode.nodeSize);
50
51
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
52
+ if ((0, _experiments.editorExperiment)('nested-expand-in-expand', true)) {
53
+ if (expandNode.type === state.schema.nodes.nestedExpand) {
54
+ var resolvedPos = tr.doc.resolve(expandNodePos + 1);
55
+ if (resolvedPos) {
56
+ tr.setSelection(_state2.Selection.near(resolvedPos, -1));
57
+ }
58
+ }
59
+ }
51
60
  dispatch(tr);
52
61
  }
53
62
  return true;
@@ -198,9 +207,11 @@ var focusTitle = exports.focusTitle = function focusTitle(pos) {
198
207
  };
199
208
  var focusIcon = exports.focusIcon = function focusIcon(expand) {
200
209
  return function (state, dispatch, editorView) {
201
- if (!expand || !(expand instanceof HTMLElement)) {
210
+ if (!(expand instanceof HTMLElement)) {
202
211
  return false;
203
212
  }
213
+
214
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
204
215
  var iconContainer = expand.querySelector(".".concat(_styles.expandClassNames.iconContainer));
205
216
  if (iconContainer && iconContainer.focus) {
206
217
  var tr = state.tr;
@@ -28,7 +28,7 @@ function buildExpandClassName(type, expanded) {
28
28
  var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditable) {
29
29
  return ['div', {
30
30
  // prettier-ignore
31
- 'class': buildExpandClassName(node.type.name, (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
31
+ 'class': buildExpandClassName(node.type.name, __livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') ? !node.attrs.__expanded : node.attrs.__expanded),
32
32
  'data-node-type': node.type.name,
33
33
  'data-title': node.attrs.title
34
34
  }, ['div', {
@@ -52,11 +52,11 @@ var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditabl
52
52
  value: node.attrs.title,
53
53
  placeholder: intl && intl.formatMessage(_ui.expandMessages.expandPlaceholderText) || _ui.expandMessages.expandPlaceholderText.defaultMessage,
54
54
  type: 'text',
55
- readonly: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && titleReadOnly ? 'true' : undefined
55
+ readonly: titleReadOnly && (0, _platformFeatureFlags.fg)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? 'true' : undefined
56
56
  }]]], ['div', {
57
57
  // prettier-ignore
58
58
  class: _styles.expandClassNames.content,
59
- contenteditable: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && contentEditable ? contentEditable ? 'true' : 'false' : undefined
59
+ contenteditable: contentEditable && (0, _platformFeatureFlags.fg)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : undefined
60
60
  }, 0]];
61
61
  };
62
62
  var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
@@ -267,7 +267,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
267
267
  }
268
268
  });
269
269
  (0, _defineProperty2.default)(this, "isCollapsed", function () {
270
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && _this.__livePage) {
270
+ if (_this.__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence')) {
271
271
  return _this.node.attrs.__expanded;
272
272
  }
273
273
  return !_this.node.attrs.__expanded;
@@ -397,8 +397,8 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
397
397
  return;
398
398
  });
399
399
  (0, _defineProperty2.default)(this, "getContentEditable", function (node) {
400
- var contentEditable = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && _this.__livePage ? !node.attrs.__expanded : node.attrs.__expanded;
401
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && _this.api && _this.api.editorDisabled) {
400
+ var contentEditable = _this.__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') ? !node.attrs.__expanded : node.attrs.__expanded;
401
+ if (_this.api && _this.api.editorDisabled && (0, _platformFeatureFlags.fg)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
402
402
  var _this$api$editorDisab;
403
403
  return !((_this$api$editorDisab = _this.api.editorDisabled.sharedState.currentState()) !== null && _this$api$editorDisab !== void 0 && _this$api$editorDisab.editorDisabled) && contentEditable;
404
404
  }
@@ -455,7 +455,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
455
455
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
456
456
  this.icon.addEventListener('keydown', this.handleIconKeyDown);
457
457
  }
458
- if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
458
+ if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && (0, _platformFeatureFlags.fg)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
459
459
  this.cleanUpEditorDisabledOnChange = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
460
460
  var editorDisabled = sharedState.nextSharedState.editorDisabled;
461
461
  if (_this2.input) {
@@ -482,7 +482,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
482
482
  _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_ExpandIconButton.ExpandIconButton, {
483
483
  intl: intl,
484
484
  allowInteractiveExpand: this.allowInteractiveExpand,
485
- expanded: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && this.__livePage ? !__expanded : __expanded
485
+ expanded: this.__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') ? !__expanded : __expanded
486
486
  }), this.icon);
487
487
  }
488
488
  }, {
@@ -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)) {
@@ -16,6 +16,7 @@ var _utils = require("@atlaskit/editor-common/utils");
16
16
  var _state2 = require("@atlaskit/editor-prosemirror/state");
17
17
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
18
18
  var _utils3 = require("@atlaskit/editor-tables/utils");
19
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
19
20
  var _utils4 = require("../utils");
20
21
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
22
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -105,6 +106,14 @@ var deleteExpandAtPos = exports.deleteExpandAtPos = function deleteExpandAtPos(e
105
106
  var tr = state.tr;
106
107
  tr.delete(expandNodePos, expandNodePos + expandNode.nodeSize);
107
108
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
109
+ if ((0, _experiments.editorExperiment)('nested-expand-in-expand', true)) {
110
+ if (expandNode.type === state.schema.nodes.nestedExpand) {
111
+ var resolvedPos = tr.doc.resolve(expandNodePos + 1);
112
+ if (resolvedPos) {
113
+ tr.setSelection(_state2.Selection.near(resolvedPos, -1));
114
+ }
115
+ }
116
+ }
108
117
  dispatch(tr);
109
118
  }
110
119
  return true;
@@ -200,9 +209,11 @@ var focusTitle = exports.focusTitle = function focusTitle(pos) {
200
209
  };
201
210
  var focusIcon = exports.focusIcon = function focusIcon(expand) {
202
211
  return function (state, dispatch, editorView) {
203
- if (!expand || !(expand instanceof HTMLElement)) {
212
+ if (!(expand instanceof HTMLElement)) {
204
213
  return false;
205
214
  }
215
+
216
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
206
217
  var iconContainer = expand.querySelector(".".concat(_styles.expandClassNames.iconContainer));
207
218
  if (iconContainer && iconContainer.focus) {
208
219
  var tr = state.tr;
@@ -354,7 +354,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
354
354
  });
355
355
  (0, _defineProperty2.default)(this, "getContentEditable", function (node) {
356
356
  var contentEditable = !(0, _expand.isExpandCollapsed)(node);
357
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && _this.api && _this.api.editorDisabled) {
357
+ if (_this.api && _this.api.editorDisabled && (0, _platformFeatureFlags.fg)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
358
358
  var _this$api$editorDisab;
359
359
  return !((_this$api$editorDisab = _this.api.editorDisabled.sharedState.currentState()) !== null && _this$api$editorDisab !== void 0 && _this$api$editorDisab.editorDisabled) && contentEditable;
360
360
  }
@@ -398,7 +398,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
398
398
  // Prevent ProseMirror from getting a focus event (causes weird selection issues).
399
399
  this.titleContainer.addEventListener('focus', this.handleFocus);
400
400
  this.icon.addEventListener('keydown', this.handleIconKeyDown);
401
- if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
401
+ if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && (0, _platformFeatureFlags.fg)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
402
402
  this.cleanUpEditorDisabledOnChange = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
403
403
  var editorDisabled = sharedState.nextSharedState.editorDisabled;
404
404
  if (_this.input) {
@@ -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;
@@ -7,6 +7,7 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
8
8
  import { findTable } from '@atlaskit/editor-tables/utils';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
11
  import { isNestedInExpand } from '../utils';
11
12
  import { createCommand } from './pm-plugins/plugin-factory';
12
13
  import { findExpand } from './utils';
@@ -34,6 +35,14 @@ export const deleteExpandAtPos = editorAnalyticsAPI => (expandNodePos, expandNod
34
35
  } = state;
35
36
  tr.delete(expandNodePos, expandNodePos + expandNode.nodeSize);
36
37
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
38
+ if (editorExperiment('nested-expand-in-expand', true)) {
39
+ if (expandNode.type === state.schema.nodes.nestedExpand) {
40
+ const resolvedPos = tr.doc.resolve(expandNodePos + 1);
41
+ if (resolvedPos) {
42
+ tr.setSelection(Selection.near(resolvedPos, -1));
43
+ }
44
+ }
45
+ }
37
46
  dispatch(tr);
38
47
  }
39
48
  return true;
@@ -178,9 +187,11 @@ export const focusTitle = pos => (state, dispatch, editorView) => {
178
187
  return false;
179
188
  };
180
189
  export const focusIcon = expand => (state, dispatch, editorView) => {
181
- if (!expand || !(expand instanceof HTMLElement)) {
190
+ if (!(expand instanceof HTMLElement)) {
182
191
  return false;
183
192
  }
193
+
194
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
184
195
  const iconContainer = expand.querySelector(`.${expandClassNames.iconContainer}`);
185
196
  if (iconContainer && iconContainer.focus) {
186
197
  const {
@@ -9,7 +9,7 @@ import { closestElement, isEmptyNode } from '@atlaskit/editor-common/utils';
9
9
  import { redo, undo } from '@atlaskit/editor-prosemirror/history';
10
10
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
11
11
  import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
12
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
13
13
  import { deleteExpandAtPos, setSelectionInsideExpand, toggleExpandExpanded, updateExpandTitle } from '../commands';
14
14
  import { ExpandIconButton } from '../ui/ExpandIconButton';
15
15
  function buildExpandClassName(type, expanded) {
@@ -17,7 +17,7 @@ function buildExpandClassName(type, expanded) {
17
17
  }
18
18
  const toDOM = (node, __livePage, intl, titleReadOnly, contentEditable) => ['div', {
19
19
  // prettier-ignore
20
- 'class': buildExpandClassName(node.type.name, getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
20
+ 'class': buildExpandClassName(node.type.name, __livePage && fg('platform.editor.live-pages-expand-divergence') ? !node.attrs.__expanded : node.attrs.__expanded),
21
21
  'data-node-type': node.type.name,
22
22
  'data-title': node.attrs.title
23
23
  }, ['div', {
@@ -41,11 +41,11 @@ const toDOM = (node, __livePage, intl, titleReadOnly, contentEditable) => ['div'
41
41
  value: node.attrs.title,
42
42
  placeholder: intl && intl.formatMessage(expandMessages.expandPlaceholderText) || expandMessages.expandPlaceholderText.defaultMessage,
43
43
  type: 'text',
44
- readonly: getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && titleReadOnly ? 'true' : undefined
44
+ readonly: titleReadOnly && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? 'true' : undefined
45
45
  }]]], ['div', {
46
46
  // prettier-ignore
47
47
  class: expandClassNames.content,
48
- contenteditable: getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && contentEditable ? contentEditable ? 'true' : 'false' : undefined
48
+ contenteditable: contentEditable && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : undefined
49
49
  }, 0]];
50
50
  export class ExpandNodeView {
51
51
  constructor(_node, view, getPos, getIntl, isMobile, selectNearNode, api, allowInteractiveExpand = true, __livePage = false, cleanUpEditorDisabledOnChange) {
@@ -258,7 +258,7 @@ export class ExpandNodeView {
258
258
  }
259
259
  });
260
260
  _defineProperty(this, "isCollapsed", () => {
261
- if (getBooleanFF('platform.editor.live-pages-expand-divergence') && this.__livePage) {
261
+ if (this.__livePage && fg('platform.editor.live-pages-expand-divergence')) {
262
262
  return this.node.attrs.__expanded;
263
263
  }
264
264
  return !this.node.attrs.__expanded;
@@ -398,8 +398,8 @@ export class ExpandNodeView {
398
398
  return;
399
399
  });
400
400
  _defineProperty(this, "getContentEditable", node => {
401
- const contentEditable = getBooleanFF('platform.editor.live-pages-expand-divergence') && this.__livePage ? !node.attrs.__expanded : node.attrs.__expanded;
402
- if (getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && this.api && this.api.editorDisabled) {
401
+ const contentEditable = this.__livePage && fg('platform.editor.live-pages-expand-divergence') ? !node.attrs.__expanded : node.attrs.__expanded;
402
+ if (this.api && this.api.editorDisabled && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
403
403
  var _this$api$editorDisab;
404
404
  return !((_this$api$editorDisab = this.api.editorDisabled.sharedState.currentState()) !== null && _this$api$editorDisab !== void 0 && _this$api$editorDisab.editorDisabled) && contentEditable;
405
405
  }
@@ -454,7 +454,7 @@ export class ExpandNodeView {
454
454
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
455
455
  this.icon.addEventListener('keydown', this.handleIconKeyDown);
456
456
  }
457
- if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
457
+ if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
458
458
  this.cleanUpEditorDisabledOnChange = this.api.editorDisabled.sharedState.onChange(sharedState => {
459
459
  const editorDisabled = sharedState.nextSharedState.editorDisabled;
460
460
  if (this.input) {
@@ -480,7 +480,7 @@ export class ExpandNodeView {
480
480
  ReactDOM.render( /*#__PURE__*/React.createElement(ExpandIconButton, {
481
481
  intl: intl,
482
482
  allowInteractiveExpand: this.allowInteractiveExpand,
483
- expanded: getBooleanFF('platform.editor.live-pages-expand-divergence') && this.__livePage ? !__expanded : __expanded
483
+ expanded: this.__livePage && fg('platform.editor.live-pages-expand-divergence') ? !__expanded : __expanded
484
484
  }), this.icon);
485
485
  }
486
486
  stopEvent(event) {
@@ -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;
@@ -8,6 +8,7 @@ import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
8
8
  import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
9
9
  import { findParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
10
10
  import { findTable } from '@atlaskit/editor-tables/utils';
11
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
12
  import { isNestedInExpand } from '../utils';
12
13
 
13
14
  // Creates either an expand or a nestedExpand node based on the current selection
@@ -87,6 +88,14 @@ export const deleteExpandAtPos = editorAnalyticsAPI => (expandNodePos, expandNod
87
88
  } = state;
88
89
  tr.delete(expandNodePos, expandNodePos + expandNode.nodeSize);
89
90
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
91
+ if (editorExperiment('nested-expand-in-expand', true)) {
92
+ if (expandNode.type === state.schema.nodes.nestedExpand) {
93
+ const resolvedPos = tr.doc.resolve(expandNodePos + 1);
94
+ if (resolvedPos) {
95
+ tr.setSelection(Selection.near(resolvedPos, -1));
96
+ }
97
+ }
98
+ }
90
99
  dispatch(tr);
91
100
  }
92
101
  return true;
@@ -178,9 +187,11 @@ export const focusTitle = pos => (state, dispatch, editorView) => {
178
187
  return false;
179
188
  };
180
189
  export const focusIcon = expand => (state, dispatch, editorView) => {
181
- if (!expand || !(expand instanceof HTMLElement)) {
190
+ if (!(expand instanceof HTMLElement)) {
182
191
  return false;
183
192
  }
193
+
194
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
184
195
  const iconContainer = expand.querySelector(`.${expandClassNames.iconContainer}`);
185
196
  if (iconContainer && iconContainer.focus) {
186
197
  const {
@@ -8,7 +8,7 @@ import { closestElement, isEmptyNode } from '@atlaskit/editor-common/utils';
8
8
  import { redo, undo } from '@atlaskit/editor-prosemirror/history';
9
9
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
10
10
  import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
11
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
12
12
  import { deleteExpand, setSelectionInsideExpand, toggleExpandExpanded, updateExpandTitle } from '../commands';
13
13
  import { buildExpandClassName, renderIcon, toDOM } from '../ui/NodeView';
14
14
  export class ExpandNodeView {
@@ -355,7 +355,7 @@ export class ExpandNodeView {
355
355
  });
356
356
  _defineProperty(this, "getContentEditable", node => {
357
357
  const contentEditable = !isExpandCollapsed(node);
358
- if (getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && this.api && this.api.editorDisabled) {
358
+ if (this.api && this.api.editorDisabled && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
359
359
  var _this$api$editorDisab;
360
360
  return !((_this$api$editorDisab = this.api.editorDisabled.sharedState.currentState()) !== null && _this$api$editorDisab !== void 0 && _this$api$editorDisab.editorDisabled) && contentEditable;
361
361
  }
@@ -400,7 +400,7 @@ export class ExpandNodeView {
400
400
  // Prevent ProseMirror from getting a focus event (causes weird selection issues).
401
401
  this.titleContainer.addEventListener('focus', this.handleFocus);
402
402
  this.icon.addEventListener('keydown', this.handleIconKeyDown);
403
- if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
403
+ if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
404
404
  this.cleanUpEditorDisabledOnChange = this.api.editorDisabled.sharedState.onChange(sharedState => {
405
405
  const editorDisabled = sharedState.nextSharedState.editorDisabled;
406
406
  if (this.input) {
@@ -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;
@@ -10,6 +10,7 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
10
10
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
11
11
  import { findTable } from '@atlaskit/editor-tables/utils';
12
12
  import { fg } from '@atlaskit/platform-feature-flags';
13
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
14
  import { isNestedInExpand } from '../utils';
14
15
  import { createCommand } from './pm-plugins/plugin-factory';
15
16
  import { findExpand } from './utils';
@@ -41,6 +42,14 @@ export var deleteExpandAtPos = function deleteExpandAtPos(editorAnalyticsAPI) {
41
42
  var tr = state.tr;
42
43
  tr.delete(expandNodePos, expandNodePos + expandNode.nodeSize);
43
44
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
45
+ if (editorExperiment('nested-expand-in-expand', true)) {
46
+ if (expandNode.type === state.schema.nodes.nestedExpand) {
47
+ var resolvedPos = tr.doc.resolve(expandNodePos + 1);
48
+ if (resolvedPos) {
49
+ tr.setSelection(Selection.near(resolvedPos, -1));
50
+ }
51
+ }
52
+ }
44
53
  dispatch(tr);
45
54
  }
46
55
  return true;
@@ -191,9 +200,11 @@ export var focusTitle = function focusTitle(pos) {
191
200
  };
192
201
  export var focusIcon = function focusIcon(expand) {
193
202
  return function (state, dispatch, editorView) {
194
- if (!expand || !(expand instanceof HTMLElement)) {
203
+ if (!(expand instanceof HTMLElement)) {
195
204
  return false;
196
205
  }
206
+
207
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
197
208
  var iconContainer = expand.querySelector(".".concat(expandClassNames.iconContainer));
198
209
  if (iconContainer && iconContainer.focus) {
199
210
  var tr = state.tr;
@@ -11,7 +11,7 @@ import { closestElement, isEmptyNode } from '@atlaskit/editor-common/utils';
11
11
  import { redo, undo } from '@atlaskit/editor-prosemirror/history';
12
12
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
13
13
  import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
14
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
14
+ import { fg } from '@atlaskit/platform-feature-flags';
15
15
  import { deleteExpandAtPos, setSelectionInsideExpand, toggleExpandExpanded, updateExpandTitle } from '../commands';
16
16
  import { ExpandIconButton } from '../ui/ExpandIconButton';
17
17
  function buildExpandClassName(type, expanded) {
@@ -20,7 +20,7 @@ function buildExpandClassName(type, expanded) {
20
20
  var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditable) {
21
21
  return ['div', {
22
22
  // prettier-ignore
23
- 'class': buildExpandClassName(node.type.name, getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
23
+ 'class': buildExpandClassName(node.type.name, __livePage && fg('platform.editor.live-pages-expand-divergence') ? !node.attrs.__expanded : node.attrs.__expanded),
24
24
  'data-node-type': node.type.name,
25
25
  'data-title': node.attrs.title
26
26
  }, ['div', {
@@ -44,11 +44,11 @@ var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditabl
44
44
  value: node.attrs.title,
45
45
  placeholder: intl && intl.formatMessage(expandMessages.expandPlaceholderText) || expandMessages.expandPlaceholderText.defaultMessage,
46
46
  type: 'text',
47
- readonly: getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && titleReadOnly ? 'true' : undefined
47
+ readonly: titleReadOnly && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? 'true' : undefined
48
48
  }]]], ['div', {
49
49
  // prettier-ignore
50
50
  class: expandClassNames.content,
51
- contenteditable: getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && contentEditable ? contentEditable ? 'true' : 'false' : undefined
51
+ contenteditable: contentEditable && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : undefined
52
52
  }, 0]];
53
53
  };
54
54
  export var ExpandNodeView = /*#__PURE__*/function () {
@@ -259,7 +259,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
259
259
  }
260
260
  });
261
261
  _defineProperty(this, "isCollapsed", function () {
262
- if (getBooleanFF('platform.editor.live-pages-expand-divergence') && _this.__livePage) {
262
+ if (_this.__livePage && fg('platform.editor.live-pages-expand-divergence')) {
263
263
  return _this.node.attrs.__expanded;
264
264
  }
265
265
  return !_this.node.attrs.__expanded;
@@ -389,8 +389,8 @@ export var ExpandNodeView = /*#__PURE__*/function () {
389
389
  return;
390
390
  });
391
391
  _defineProperty(this, "getContentEditable", function (node) {
392
- var contentEditable = getBooleanFF('platform.editor.live-pages-expand-divergence') && _this.__livePage ? !node.attrs.__expanded : node.attrs.__expanded;
393
- if (getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && _this.api && _this.api.editorDisabled) {
392
+ var contentEditable = _this.__livePage && fg('platform.editor.live-pages-expand-divergence') ? !node.attrs.__expanded : node.attrs.__expanded;
393
+ if (_this.api && _this.api.editorDisabled && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
394
394
  var _this$api$editorDisab;
395
395
  return !((_this$api$editorDisab = _this.api.editorDisabled.sharedState.currentState()) !== null && _this$api$editorDisab !== void 0 && _this$api$editorDisab.editorDisabled) && contentEditable;
396
396
  }
@@ -447,7 +447,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
447
447
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
448
448
  this.icon.addEventListener('keydown', this.handleIconKeyDown);
449
449
  }
450
- if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
450
+ if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
451
451
  this.cleanUpEditorDisabledOnChange = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
452
452
  var editorDisabled = sharedState.nextSharedState.editorDisabled;
453
453
  if (_this2.input) {
@@ -474,7 +474,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
474
474
  ReactDOM.render( /*#__PURE__*/React.createElement(ExpandIconButton, {
475
475
  intl: intl,
476
476
  allowInteractiveExpand: this.allowInteractiveExpand,
477
- expanded: getBooleanFF('platform.editor.live-pages-expand-divergence') && this.__livePage ? !__expanded : __expanded
477
+ expanded: this.__livePage && fg('platform.editor.live-pages-expand-divergence') ? !__expanded : __expanded
478
478
  }), this.icon);
479
479
  }
480
480
  }, {
@@ -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;
@@ -11,6 +11,7 @@ import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
11
11
  import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
12
12
  import { findParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
13
13
  import { findTable } from '@atlaskit/editor-tables/utils';
14
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
15
  import { isNestedInExpand } from '../utils';
15
16
 
16
17
  // Creates either an expand or a nestedExpand node based on the current selection
@@ -99,6 +100,14 @@ export var deleteExpandAtPos = function deleteExpandAtPos(editorAnalyticsAPI) {
99
100
  var tr = state.tr;
100
101
  tr.delete(expandNodePos, expandNodePos + expandNode.nodeSize);
101
102
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
103
+ if (editorExperiment('nested-expand-in-expand', true)) {
104
+ if (expandNode.type === state.schema.nodes.nestedExpand) {
105
+ var resolvedPos = tr.doc.resolve(expandNodePos + 1);
106
+ if (resolvedPos) {
107
+ tr.setSelection(Selection.near(resolvedPos, -1));
108
+ }
109
+ }
110
+ }
102
111
  dispatch(tr);
103
112
  }
104
113
  return true;
@@ -194,9 +203,11 @@ export var focusTitle = function focusTitle(pos) {
194
203
  };
195
204
  export var focusIcon = function focusIcon(expand) {
196
205
  return function (state, dispatch, editorView) {
197
- if (!expand || !(expand instanceof HTMLElement)) {
206
+ if (!(expand instanceof HTMLElement)) {
198
207
  return false;
199
208
  }
209
+
210
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
200
211
  var iconContainer = expand.querySelector(".".concat(expandClassNames.iconContainer));
201
212
  if (iconContainer && iconContainer.focus) {
202
213
  var tr = state.tr;
@@ -10,7 +10,7 @@ import { closestElement, isEmptyNode } from '@atlaskit/editor-common/utils';
10
10
  import { redo, undo } from '@atlaskit/editor-prosemirror/history';
11
11
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
12
12
  import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
13
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
14
14
  import { deleteExpand, setSelectionInsideExpand, toggleExpandExpanded, updateExpandTitle } from '../commands';
15
15
  import { buildExpandClassName, renderIcon, toDOM } from '../ui/NodeView';
16
16
  export var ExpandNodeView = /*#__PURE__*/function () {
@@ -346,7 +346,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
346
346
  });
347
347
  _defineProperty(this, "getContentEditable", function (node) {
348
348
  var contentEditable = !isExpandCollapsed(node);
349
- if (getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && _this.api && _this.api.editorDisabled) {
349
+ if (_this.api && _this.api.editorDisabled && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
350
350
  var _this$api$editorDisab;
351
351
  return !((_this$api$editorDisab = _this.api.editorDisabled.sharedState.currentState()) !== null && _this$api$editorDisab !== void 0 && _this$api$editorDisab.editorDisabled) && contentEditable;
352
352
  }
@@ -390,7 +390,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
390
390
  // Prevent ProseMirror from getting a focus event (causes weird selection issues).
391
391
  this.titleContainer.addEventListener('focus', this.handleFocus);
392
392
  this.icon.addEventListener('keydown', this.handleIconKeyDown);
393
- if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
393
+ if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
394
394
  this.cleanUpEditorDisabledOnChange = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
395
395
  var editorDisabled = sharedState.nextSharedState.editorDisabled;
396
396
  if (_this.input) {
@@ -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.6",
4
4
  "description": "Expand plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^40.9.0",
35
- "@atlaskit/button": "^20.1.0",
36
- "@atlaskit/editor-common": "^90.1.0",
35
+ "@atlaskit/button": "^20.2.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",
@@ -60,7 +60,7 @@
60
60
  "@atlaskit/editor-plugin-content-insertion": "^1.8.0",
61
61
  "@atlaskit/editor-plugin-guideline": "^1.2.0",
62
62
  "@atlaskit/editor-plugin-quick-insert": "^1.4.0",
63
- "@atlaskit/editor-plugin-table": "^7.27.0",
63
+ "@atlaskit/editor-plugin-table": "^7.28.0",
64
64
  "@atlaskit/editor-plugin-type-ahead": "^1.8.0",
65
65
  "@atlaskit/editor-plugin-width": "^1.3.0",
66
66
  "@testing-library/react": "^12.1.5",