@atlaskit/editor-plugin-expand 2.5.0 → 2.5.2

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,20 @@
1
1
  # @atlaskit/editor-plugin-expand
2
2
 
3
+ ## 2.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 2.5.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#129932](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/129932)
14
+ [`d6a093f919beb`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d6a093f919beb) -
15
+ [ED-24588] When inserting an expand with an existing expand selected, insert expand below the
16
+ expand
17
+
3
18
  ## 2.5.0
4
19
 
5
20
  ### Minor Changes
@@ -14,8 +14,9 @@ var _state2 = require("@atlaskit/editor-prosemirror/state");
14
14
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
15
15
  var _utils3 = require("@atlaskit/editor-tables/utils");
16
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
+ var _utils4 = require("../utils");
17
18
  var _pluginFactory = require("./pm-plugins/plugin-factory");
18
- var _utils4 = require("./utils");
19
+ var _utils5 = require("./utils");
19
20
  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; }
20
21
  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; }
21
22
  var setExpandRef = exports.setExpandRef = function setExpandRef(ref) {
@@ -54,7 +55,7 @@ var deleteExpandAtPos = exports.deleteExpandAtPos = function deleteExpandAtPos(e
54
55
  };
55
56
  var deleteExpand = exports.deleteExpand = function deleteExpand(editorAnalyticsAPI) {
56
57
  return function (state, dispatch) {
57
- var expandNode = (0, _utils4.findExpand)(state);
58
+ var expandNode = (0, _utils5.findExpand)(state);
58
59
  if (!expandNode) {
59
60
  return false;
60
61
  }
@@ -107,7 +108,7 @@ var toggleExpandExpanded = exports.toggleExpandExpanded = function toggleExpandE
107
108
  // If we're going to collapse the expand and our cursor is currently inside
108
109
  // Move to a right gap cursor, if the toolbar is interacted (or an API),
109
110
  // it will insert below rather than inside (which will be invisible).
110
- if (__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') ? isExpandedNext === true : isExpandedNext === false && (0, _utils4.findExpand)(state)) {
111
+ if (__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') ? isExpandedNext === true : isExpandedNext === false && (0, _utils5.findExpand)(state)) {
111
112
  tr.setSelection(new _selection.GapCursorSelection(tr.doc.resolve(pos + node.nodeSize), _selection.Side.RIGHT));
112
113
  }
113
114
 
@@ -140,7 +141,7 @@ var createExpandNode = exports.createExpandNode = function createExpandNode(stat
140
141
  expand = _state$schema$nodes.expand,
141
142
  nestedExpand = _state$schema$nodes.nestedExpand;
142
143
  var isSelectionInTable = !!(0, _utils3.findTable)(state.selection);
143
- var isSelectionInExpand = isNestingExpandsSupported && !!(0, _utils4.findExpand)(state, state.selection);
144
+ var isSelectionInExpand = isNestingExpandsSupported && (0, _utils4.isNestedInExpand)(state);
144
145
  var expandType = isSelectionInTable || isSelectionInExpand ? nestedExpand : expand;
145
146
  return expandType.createAndFill({});
146
147
  };
@@ -76,7 +76,9 @@ function expandKeymap(api, options) {
76
76
  var selection = state.selection,
77
77
  schema = state.schema;
78
78
  var nodeBefore = selection.$from.nodeBefore;
79
- if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeBefore.attrs.__expanded : !nodeBefore.attrs.__expanded)) {
79
+ if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && (
80
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
81
+ (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeBefore.attrs.__expanded : !nodeBefore.attrs.__expanded)) {
80
82
  var _$from = selection.$from;
81
83
  return (0, _commands.focusTitle)(Math.max(_$from.pos - 1, 0))(state, dispatch, editorView);
82
84
  }
@@ -100,7 +102,9 @@ function expandKeymap(api, options) {
100
102
  var expandBefore = (0, _utils2.findExpand)(state, sel);
101
103
  if (sel && expandBefore) {
102
104
  // moving cursor from outside of an expand to the title when it is collapsed
103
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded) {
105
+ if (
106
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
107
+ (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded) {
104
108
  return (0, _commands.focusTitle)(expandBefore.start)(state, dispatch, editorView);
105
109
  }
106
110
  // moving cursor from outside of an expand to the content when it is expanded
@@ -121,7 +125,9 @@ function expandKeymap(api, options) {
121
125
  nestedExpand = _state$schema$nodes.nestedExpand;
122
126
  var selection = state.selection;
123
127
  var nodeAfter = selection.$from.nodeAfter;
124
- if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeAfter.attrs.__expanded : !nodeAfter.attrs.__expanded)) {
128
+ if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && (
129
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
130
+ (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeAfter.attrs.__expanded : !nodeAfter.attrs.__expanded)) {
125
131
  var $from = selection.$from;
126
132
  return (0, _commands.focusTitle)($from.pos + 1)(state, dispatch, editorView);
127
133
  }
@@ -151,7 +157,9 @@ function expandKeymap(api, options) {
151
157
  // @see ED-7977
152
158
  var sel = _state.Selection.findFrom(state.doc.resolve(Math.max(selection.$from.pos - 1, 0)), -1);
153
159
  var expandBefore = (0, _utils2.findExpand)(state, sel);
154
- if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded)) {
160
+ if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && (
161
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
162
+ (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded)) {
155
163
  return (0, _commands.focusTitle)(expandBefore.start)(state, dispatch, editorView);
156
164
  }
157
165
  return false;
@@ -12,10 +12,11 @@ var _expand = require("@atlaskit/editor-common/expand");
12
12
  var _selection = require("@atlaskit/editor-common/selection");
13
13
  var _transforms = require("@atlaskit/editor-common/transforms");
14
14
  var _utils = require("@atlaskit/editor-common/utils");
15
- var _state = require("@atlaskit/editor-prosemirror/state");
15
+ var _state2 = require("@atlaskit/editor-prosemirror/state");
16
16
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
17
17
  var _utils3 = require("@atlaskit/editor-tables/utils");
18
18
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
+ var _utils4 = require("../utils");
19
20
  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; }
20
21
  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; }
21
22
  // Creates either an expand or a nestedExpand node based on the current selection
@@ -26,7 +27,7 @@ var createExpandNode = exports.createExpandNode = function createExpandNode(stat
26
27
  expand = _state$schema$nodes.expand,
27
28
  nestedExpand = _state$schema$nodes.nestedExpand;
28
29
  var isSelectionInTable = !!(0, _utils3.findTable)(state.selection);
29
- var isSelectionInExpand = isNestingExpandsSupported && !!(0, _transforms.findExpand)(state, state.selection);
30
+ var isSelectionInExpand = isNestingExpandsSupported && (0, _utils4.isNestedInExpand)(state);
30
31
  var expandType = isSelectionInTable || isSelectionInExpand ? nestedExpand : expand;
31
32
  var expandNode = expandType.createAndFill({});
32
33
  if (setExpandedState) {
@@ -120,12 +121,12 @@ var deleteExpandAtPos = exports.deleteExpandAtPos = function deleteExpandAtPos(e
120
121
 
121
122
  // Used to clear any node or cell selection when expand title is focused
122
123
  var setSelectionInsideExpand = exports.setSelectionInsideExpand = function setSelectionInsideExpand(expandPos) {
123
- return function (state, dispatch, editorView) {
124
+ return function (_state, dispatch, editorView) {
124
125
  if (editorView) {
125
126
  if (!editorView.hasFocus()) {
126
127
  editorView.focus();
127
128
  }
128
- var sel = _state.Selection.findFrom(editorView.state.doc.resolve(expandPos), 1, true);
129
+ var sel = _state2.Selection.findFrom(editorView.state.doc.resolve(expandPos), 1, true);
129
130
  if (sel && dispatch) {
130
131
  dispatch(editorView.state.tr.setSelection(sel));
131
132
  }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isNestedInExpand = void 0;
7
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
8
+ var isNestedInExpand = exports.isNestedInExpand = function isNestedInExpand(state) {
9
+ return (0, _utils.hasParentNode)(function (node) {
10
+ return node.type === state.schema.nodes.expand || node.type === state.schema.nodes.nestedExpand;
11
+ })(state.selection);
12
+ };
@@ -6,6 +6,7 @@ import { Selection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { findTable } from '@atlaskit/editor-tables/utils';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
+ import { isNestedInExpand } from '../utils';
9
10
  import { createCommand } from './pm-plugins/plugin-factory';
10
11
  import { findExpand } from './utils';
11
12
  export const setExpandRef = ref => createCommand({
@@ -129,7 +130,7 @@ export const createExpandNode = (state, isNestingExpandsSupported) => {
129
130
  nestedExpand
130
131
  } = state.schema.nodes;
131
132
  const isSelectionInTable = !!findTable(state.selection);
132
- const isSelectionInExpand = isNestingExpandsSupported && !!findExpand(state, state.selection);
133
+ const isSelectionInExpand = isNestingExpandsSupported && isNestedInExpand(state);
133
134
  const expandType = isSelectionInTable || isSelectionInExpand ? nestedExpand : expand;
134
135
  return expandType.createAndFill({});
135
136
  };
@@ -4,7 +4,7 @@ import { expandClassNames } from '@atlaskit/editor-common/styles';
4
4
  import { isEmptyNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
5
5
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
6
6
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
7
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
8
8
  import { deleteExpand, focusTitle } from '../commands';
9
9
  import { findExpand } from '../utils';
10
10
  const isExpandNode = node => {
@@ -84,7 +84,9 @@ export function expandKeymap(api, options) {
84
84
  const {
85
85
  nodeBefore
86
86
  } = selection.$from;
87
- if (selection instanceof GapCursorSelection && selection.side === Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && (getBooleanFF('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeBefore.attrs.__expanded : !nodeBefore.attrs.__expanded)) {
87
+ if (selection instanceof GapCursorSelection && selection.side === Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && (
88
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
89
+ fg('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeBefore.attrs.__expanded : !nodeBefore.attrs.__expanded)) {
88
90
  const {
89
91
  $from
90
92
  } = selection;
@@ -112,7 +114,9 @@ export function expandKeymap(api, options) {
112
114
  const expandBefore = findExpand(state, sel);
113
115
  if (sel && expandBefore) {
114
116
  // moving cursor from outside of an expand to the title when it is collapsed
115
- if (getBooleanFF('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded) {
117
+ if (
118
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
119
+ fg('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded) {
116
120
  return focusTitle(expandBefore.start)(state, dispatch, editorView);
117
121
  }
118
122
  // moving cursor from outside of an expand to the content when it is expanded
@@ -138,7 +142,9 @@ export function expandKeymap(api, options) {
138
142
  const {
139
143
  nodeAfter
140
144
  } = selection.$from;
141
- if (selection instanceof GapCursorSelection && selection.side === Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && (getBooleanFF('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeAfter.attrs.__expanded : !nodeAfter.attrs.__expanded)) {
145
+ if (selection instanceof GapCursorSelection && selection.side === Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && (
146
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
147
+ fg('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeAfter.attrs.__expanded : !nodeAfter.attrs.__expanded)) {
142
148
  const {
143
149
  $from
144
150
  } = selection;
@@ -177,7 +183,9 @@ export function expandKeymap(api, options) {
177
183
  // @see ED-7977
178
184
  const sel = Selection.findFrom(state.doc.resolve(Math.max(selection.$from.pos - 1, 0)), -1);
179
185
  const expandBefore = findExpand(state, sel);
180
- if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && (getBooleanFF('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded)) {
186
+ if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && (
187
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
188
+ fg('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded)) {
181
189
  return focusTitle(expandBefore.start)(state, dispatch, editorView);
182
190
  }
183
191
  return false;
@@ -8,6 +8,8 @@ import { Selection } from '@atlaskit/editor-prosemirror/state';
8
8
  import { findParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { findTable } from '@atlaskit/editor-tables/utils';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { isNestedInExpand } from '../utils';
12
+
11
13
  // Creates either an expand or a nestedExpand node based on the current selection
12
14
  export const createExpandNode = (state, setExpandedState = true, isNestingExpandsSupported) => {
13
15
  const {
@@ -15,7 +17,7 @@ export const createExpandNode = (state, setExpandedState = true, isNestingExpand
15
17
  nestedExpand
16
18
  } = state.schema.nodes;
17
19
  const isSelectionInTable = !!findTable(state.selection);
18
- const isSelectionInExpand = isNestingExpandsSupported && !!findExpand(state, state.selection);
20
+ const isSelectionInExpand = isNestingExpandsSupported && isNestedInExpand(state);
19
21
  const expandType = isSelectionInTable || isSelectionInExpand ? nestedExpand : expand;
20
22
  const expandNode = expandType.createAndFill({});
21
23
  if (setExpandedState) {
@@ -98,7 +100,7 @@ export const deleteExpandAtPos = editorAnalyticsAPI => (expandNodePos, expandNod
98
100
  };
99
101
 
100
102
  // Used to clear any node or cell selection when expand title is focused
101
- export const setSelectionInsideExpand = expandPos => (state, dispatch, editorView) => {
103
+ export const setSelectionInsideExpand = expandPos => (_state, dispatch, editorView) => {
102
104
  if (editorView) {
103
105
  if (!editorView.hasFocus()) {
104
106
  editorView.focus();
@@ -0,0 +1,2 @@
1
+ import { hasParentNode } from '@atlaskit/editor-prosemirror/utils';
2
+ export const isNestedInExpand = state => hasParentNode(node => node.type === state.schema.nodes.expand || node.type === state.schema.nodes.nestedExpand)(state.selection);
@@ -9,6 +9,7 @@ import { Selection } from '@atlaskit/editor-prosemirror/state';
9
9
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
10
10
  import { findTable } from '@atlaskit/editor-tables/utils';
11
11
  import { fg } from '@atlaskit/platform-feature-flags';
12
+ import { isNestedInExpand } from '../utils';
12
13
  import { createCommand } from './pm-plugins/plugin-factory';
13
14
  import { findExpand } from './utils';
14
15
  export var setExpandRef = function setExpandRef(ref) {
@@ -133,7 +134,7 @@ export var createExpandNode = function createExpandNode(state, isNestingExpandsS
133
134
  expand = _state$schema$nodes.expand,
134
135
  nestedExpand = _state$schema$nodes.nestedExpand;
135
136
  var isSelectionInTable = !!findTable(state.selection);
136
- var isSelectionInExpand = isNestingExpandsSupported && !!findExpand(state, state.selection);
137
+ var isSelectionInExpand = isNestingExpandsSupported && isNestedInExpand(state);
137
138
  var expandType = isSelectionInTable || isSelectionInExpand ? nestedExpand : expand;
138
139
  return expandType.createAndFill({});
139
140
  };
@@ -4,7 +4,7 @@ import { expandClassNames } from '@atlaskit/editor-common/styles';
4
4
  import { isEmptyNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
5
5
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
6
6
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
7
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
8
8
  import { deleteExpand, focusTitle } from '../commands';
9
9
  import { findExpand } from '../utils';
10
10
  var isExpandNode = function isExpandNode(node) {
@@ -70,7 +70,9 @@ export function expandKeymap(api, options) {
70
70
  var selection = state.selection,
71
71
  schema = state.schema;
72
72
  var nodeBefore = selection.$from.nodeBefore;
73
- if (selection instanceof GapCursorSelection && selection.side === Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && (getBooleanFF('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeBefore.attrs.__expanded : !nodeBefore.attrs.__expanded)) {
73
+ if (selection instanceof GapCursorSelection && selection.side === Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && (
74
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
75
+ fg('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeBefore.attrs.__expanded : !nodeBefore.attrs.__expanded)) {
74
76
  var _$from = selection.$from;
75
77
  return focusTitle(Math.max(_$from.pos - 1, 0))(state, dispatch, editorView);
76
78
  }
@@ -94,7 +96,9 @@ export function expandKeymap(api, options) {
94
96
  var expandBefore = findExpand(state, sel);
95
97
  if (sel && expandBefore) {
96
98
  // moving cursor from outside of an expand to the title when it is collapsed
97
- if (getBooleanFF('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded) {
99
+ if (
100
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
101
+ fg('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded) {
98
102
  return focusTitle(expandBefore.start)(state, dispatch, editorView);
99
103
  }
100
104
  // moving cursor from outside of an expand to the content when it is expanded
@@ -115,7 +119,9 @@ export function expandKeymap(api, options) {
115
119
  nestedExpand = _state$schema$nodes.nestedExpand;
116
120
  var selection = state.selection;
117
121
  var nodeAfter = selection.$from.nodeAfter;
118
- if (selection instanceof GapCursorSelection && selection.side === Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && (getBooleanFF('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeAfter.attrs.__expanded : !nodeAfter.attrs.__expanded)) {
122
+ if (selection instanceof GapCursorSelection && selection.side === Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && (
123
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
124
+ fg('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeAfter.attrs.__expanded : !nodeAfter.attrs.__expanded)) {
119
125
  var $from = selection.$from;
120
126
  return focusTitle($from.pos + 1)(state, dispatch, editorView);
121
127
  }
@@ -145,7 +151,9 @@ export function expandKeymap(api, options) {
145
151
  // @see ED-7977
146
152
  var sel = Selection.findFrom(state.doc.resolve(Math.max(selection.$from.pos - 1, 0)), -1);
147
153
  var expandBefore = findExpand(state, sel);
148
- if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && (getBooleanFF('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded)) {
154
+ if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && (
155
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
156
+ fg('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded)) {
149
157
  return focusTitle(expandBefore.start)(state, dispatch, editorView);
150
158
  }
151
159
  return false;
@@ -11,6 +11,8 @@ import { Selection } from '@atlaskit/editor-prosemirror/state';
11
11
  import { findParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
12
12
  import { findTable } from '@atlaskit/editor-tables/utils';
13
13
  import { fg } from '@atlaskit/platform-feature-flags';
14
+ import { isNestedInExpand } from '../utils';
15
+
14
16
  // Creates either an expand or a nestedExpand node based on the current selection
15
17
  export var createExpandNode = function createExpandNode(state) {
16
18
  var setExpandedState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
@@ -19,7 +21,7 @@ export var createExpandNode = function createExpandNode(state) {
19
21
  expand = _state$schema$nodes.expand,
20
22
  nestedExpand = _state$schema$nodes.nestedExpand;
21
23
  var isSelectionInTable = !!findTable(state.selection);
22
- var isSelectionInExpand = isNestingExpandsSupported && !!findExpand(state, state.selection);
24
+ var isSelectionInExpand = isNestingExpandsSupported && isNestedInExpand(state);
23
25
  var expandType = isSelectionInTable || isSelectionInExpand ? nestedExpand : expand;
24
26
  var expandNode = expandType.createAndFill({});
25
27
  if (setExpandedState) {
@@ -113,7 +115,7 @@ export var deleteExpandAtPos = function deleteExpandAtPos(editorAnalyticsAPI) {
113
115
 
114
116
  // Used to clear any node or cell selection when expand title is focused
115
117
  export var setSelectionInsideExpand = function setSelectionInsideExpand(expandPos) {
116
- return function (state, dispatch, editorView) {
118
+ return function (_state, dispatch, editorView) {
117
119
  if (editorView) {
118
120
  if (!editorView.hasFocus()) {
119
121
  editorView.focus();
@@ -0,0 +1,6 @@
1
+ import { hasParentNode } from '@atlaskit/editor-prosemirror/utils';
2
+ export var isNestedInExpand = function isNestedInExpand(state) {
3
+ return hasParentNode(function (node) {
4
+ return node.type === state.schema.nodes.expand || node.type === state.schema.nodes.nestedExpand;
5
+ })(state.selection);
6
+ };
@@ -2,7 +2,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { Command } from '@atlaskit/editor-common/types';
3
3
  import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
- import { type InsertMethod } from '../types';
5
+ import type { InsertMethod } from '../types';
6
6
  export declare const setExpandRef: (ref?: HTMLDivElement | null) => Command;
7
7
  export declare const deleteExpandAtPos: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (expandNodePos: number, expandNode: PMNode) => Command;
8
8
  export declare const deleteExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
@@ -2,7 +2,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { Command } from '@atlaskit/editor-common/types';
3
3
  import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
- import { type InsertMethod } from '../types';
5
+ import type { InsertMethod } from '../types';
6
6
  export declare const createExpandNode: (state: EditorState, setExpandedState?: boolean, isNestingExpandsSupported?: boolean) => PMNode | null;
7
7
  export declare const insertExpandWithInputMethod: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported?: boolean) => (inputMethod: InsertMethod) => Command;
8
8
  export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported?: boolean) => Command;
@@ -0,0 +1,2 @@
1
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
+ export declare const isNestedInExpand: (state: EditorState) => boolean;
@@ -2,7 +2,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { Command } from '@atlaskit/editor-common/types';
3
3
  import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
- import { type InsertMethod } from '../types';
5
+ import type { InsertMethod } from '../types';
6
6
  export declare const setExpandRef: (ref?: HTMLDivElement | null) => Command;
7
7
  export declare const deleteExpandAtPos: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (expandNodePos: number, expandNode: PMNode) => Command;
8
8
  export declare const deleteExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
@@ -2,7 +2,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { Command } from '@atlaskit/editor-common/types';
3
3
  import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
- import { type InsertMethod } from '../types';
5
+ import type { InsertMethod } from '../types';
6
6
  export declare const createExpandNode: (state: EditorState, setExpandedState?: boolean, isNestingExpandsSupported?: boolean) => PMNode | null;
7
7
  export declare const insertExpandWithInputMethod: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported?: boolean) => (inputMethod: InsertMethod) => Command;
8
8
  export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported?: boolean) => Command;
@@ -0,0 +1,2 @@
1
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
+ export declare const isNestedInExpand: (state: EditorState) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-expand",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "description": "Expand plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,17 +34,17 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^40.8.1",
37
- "@atlaskit/button": "^20.0.0",
38
- "@atlaskit/editor-common": "^87.12.0",
39
- "@atlaskit/editor-plugin-analytics": "^1.7.0",
40
- "@atlaskit/editor-plugin-decorations": "^1.2.0",
41
- "@atlaskit/editor-plugin-editor-disabled": "^1.2.0",
42
- "@atlaskit/editor-plugin-selection": "^1.3.0",
43
- "@atlaskit/editor-plugin-selection-marker": "^1.4.0",
37
+ "@atlaskit/button": "^20.1.0",
38
+ "@atlaskit/editor-common": "^88.0.0",
39
+ "@atlaskit/editor-plugin-analytics": "^1.8.0",
40
+ "@atlaskit/editor-plugin-decorations": "^1.3.0",
41
+ "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
42
+ "@atlaskit/editor-plugin-selection": "^1.4.0",
43
+ "@atlaskit/editor-plugin-selection-marker": "^1.5.0",
44
44
  "@atlaskit/editor-prosemirror": "5.0.1",
45
45
  "@atlaskit/editor-shared-styles": "^2.13.0",
46
46
  "@atlaskit/editor-tables": "^2.8.0",
47
- "@atlaskit/icon": "^22.13.0",
47
+ "@atlaskit/icon": "^22.14.0",
48
48
  "@atlaskit/platform-feature-flags": "^0.3.0",
49
49
  "@atlaskit/tooltip": "^18.7.0",
50
50
  "@babel/runtime": "^7.0.0",
@@ -58,12 +58,12 @@
58
58
  },
59
59
  "devDependencies": {
60
60
  "@atlaskit/analytics-next": "^10.1.0",
61
- "@atlaskit/editor-plugin-content-insertion": "^1.7.0",
61
+ "@atlaskit/editor-plugin-content-insertion": "^1.8.0",
62
62
  "@atlaskit/editor-plugin-guideline": "^1.2.0",
63
- "@atlaskit/editor-plugin-quick-insert": "^1.2.0",
63
+ "@atlaskit/editor-plugin-quick-insert": "^1.3.0",
64
64
  "@atlaskit/editor-plugin-table": "^7.25.0",
65
- "@atlaskit/editor-plugin-type-ahead": "^1.7.0",
66
- "@atlaskit/editor-plugin-width": "^1.2.0",
65
+ "@atlaskit/editor-plugin-type-ahead": "^1.8.0",
66
+ "@atlaskit/editor-plugin-width": "^1.3.0",
67
67
  "@testing-library/react": "^12.1.5",
68
68
  "react-test-renderer": "^16.8.0",
69
69
  "typescript": "~5.4.2"