@atlaskit/editor-plugin-expand 1.0.1 → 1.2.0

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.
@@ -5,13 +5,14 @@ import { isPositionNearTableRow } from '@atlaskit/editor-common/utils';
5
5
  import { isEmptyNode } 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 { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { deleteExpand, focusTitle } from '../commands';
9
10
  import { findExpand } from '../utils';
10
11
  const isExpandNode = node => {
11
12
  return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
12
13
  };
13
14
  const isExpandSelected = selection => selection instanceof NodeSelection && isExpandNode(selection.node);
14
- export function expandKeymap(api) {
15
+ export function expandKeymap(api, options) {
15
16
  const list = {};
16
17
  bindKeymapWithCommand(moveRight.common, (state, dispatch, editorView) => {
17
18
  var _api$selection;
@@ -84,7 +85,7 @@ export function expandKeymap(api) {
84
85
  const {
85
86
  nodeBefore
86
87
  } = selection.$from;
87
- if (selection instanceof GapCursorSelection && selection.side === Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && !nodeBefore.attrs.__expanded) {
88
+ 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)) {
88
89
  const {
89
90
  $from
90
91
  } = selection;
@@ -112,7 +113,7 @@ export function expandKeymap(api) {
112
113
  const expandBefore = findExpand(state, sel);
113
114
  if (sel && expandBefore) {
114
115
  // moving cursor from outside of an expand to the title when it is collapsed
115
- if (!expandBefore.node.attrs.__expanded) {
116
+ if (getBooleanFF('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded) {
116
117
  return focusTitle(expandBefore.start)(state, dispatch, editorView);
117
118
  }
118
119
  // moving cursor from outside of an expand to the content when it is expanded
@@ -138,7 +139,7 @@ export function expandKeymap(api) {
138
139
  const {
139
140
  nodeAfter
140
141
  } = selection.$from;
141
- if (selection instanceof GapCursorSelection && selection.side === Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && !nodeAfter.attrs.__expanded) {
142
+ 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)) {
142
143
  const {
143
144
  $from
144
145
  } = selection;
@@ -177,7 +178,7 @@ export function expandKeymap(api) {
177
178
  // @see ED-7977
178
179
  const sel = Selection.findFrom(state.doc.resolve(Math.max(selection.$from.pos - 1, 0)), -1);
179
180
  const expandBefore = findExpand(state, sel);
180
- if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && !expandBefore.node.attrs.__expanded) {
181
+ 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)) {
181
182
  return focusTitle(expandBefore.start)(state, dispatch, editorView);
182
183
  }
183
184
  return false;
@@ -10,7 +10,7 @@ export function containsClass(element, className) {
10
10
  var _element$classList;
11
11
  return Boolean(element === null || element === void 0 ? void 0 : (_element$classList = element.classList) === null || _element$classList === void 0 ? void 0 : _element$classList.contains(className));
12
12
  }
13
- export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLongPressSelection = false, api, allowInteractiveExpand = true) => {
13
+ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLongPressSelection = false, api, allowInteractiveExpand = true, __livePage = false) => {
14
14
  const state = createPluginState(dispatch, {});
15
15
  const isMobile = appearance === 'mobile';
16
16
  return new SafePlugin({
@@ -22,13 +22,15 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
22
22
  getIntl,
23
23
  isMobile,
24
24
  api,
25
- allowInteractiveExpand
25
+ allowInteractiveExpand,
26
+ __livePage
26
27
  }),
27
28
  nestedExpand: ExpandNodeView({
28
29
  getIntl,
29
30
  isMobile,
30
31
  api,
31
- allowInteractiveExpand
32
+ allowInteractiveExpand,
33
+ __livePage
32
34
  })
33
35
  },
34
36
  handleKeyDown(_view, event) {
@@ -1 +1 @@
1
- export { findExpand, transformSliceToRemoveOpenExpand, transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
1
+ export { findExpand, transformSliceToRemoveOpenExpand, transformSliceToRemoveOpenNestedExpand, transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
@@ -1,12 +1,14 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
3
3
  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) { _defineProperty(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; }
4
+ import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
4
5
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
5
6
  import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
6
7
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
7
8
  import { Selection } from '@atlaskit/editor-prosemirror/state';
8
9
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
9
10
  import { findTable } from '@atlaskit/editor-tables/utils';
11
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
12
  import { createCommand } from './pm-plugins/plugin-factory';
11
13
  import { findExpand } from './utils';
12
14
  export var setExpandRef = function setExpandRef(ref) {
@@ -52,58 +54,76 @@ export var deleteExpand = function deleteExpand(editorAnalyticsAPI) {
52
54
  return deleteExpandAtPos(editorAnalyticsAPI)(expandNode.pos, expandNode.node)(state, dispatch);
53
55
  };
54
56
  };
55
- export var updateExpandTitle = function updateExpandTitle(title, pos, nodeType) {
57
+ export var updateExpandTitle = function updateExpandTitle(_ref) {
58
+ var title = _ref.title,
59
+ nodeType = _ref.nodeType,
60
+ pos = _ref.pos,
61
+ __livePage = _ref.__livePage;
56
62
  return function (state, dispatch) {
57
63
  var node = state.doc.nodeAt(pos);
58
64
  if (node && node.type === nodeType && dispatch) {
59
65
  var tr = state.tr;
60
- tr.setNodeMarkup(pos, node.type, _objectSpread(_objectSpread({}, node.attrs), {}, {
61
- title: title
62
- }), node.marks);
66
+ if (getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage) {
67
+ tr.step(new SetAttrsStep(pos, _objectSpread(_objectSpread({}, node.attrs), {}, {
68
+ title: title
69
+ })));
70
+ } else {
71
+ tr.setNodeMarkup(pos, node.type, _objectSpread(_objectSpread({}, node.attrs), {}, {
72
+ title: title
73
+ }), node.marks);
74
+ }
63
75
  dispatch(tr);
64
76
  }
65
77
  return true;
66
78
  };
67
79
  };
68
- export var toggleExpandExpanded = function toggleExpandExpanded(editorAnalyticsAPI) {
69
- return function (pos, nodeType) {
70
- return function (state, dispatch) {
71
- var node = state.doc.nodeAt(pos);
72
- if (node && node.type === nodeType && dispatch) {
73
- var tr = state.tr;
74
- var isExpandedNext = !node.attrs.__expanded;
80
+ export var toggleExpandExpanded = function toggleExpandExpanded(_ref2) {
81
+ var editorAnalyticsAPI = _ref2.editorAnalyticsAPI,
82
+ pos = _ref2.pos,
83
+ nodeType = _ref2.nodeType,
84
+ __livePage = _ref2.__livePage;
85
+ return function (state, dispatch) {
86
+ var node = state.doc.nodeAt(pos);
87
+ if (node && node.type === nodeType && dispatch) {
88
+ var tr = state.tr;
89
+ var isExpandedNext = !node.attrs.__expanded;
90
+ if (getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage) {
91
+ tr.step(new SetAttrsStep(pos, _objectSpread(_objectSpread({}, node.attrs), {}, {
92
+ __expanded: isExpandedNext
93
+ })));
94
+ } else {
75
95
  tr.setNodeMarkup(pos, node.type, _objectSpread(_objectSpread({}, node.attrs), {}, {
76
96
  __expanded: isExpandedNext
77
97
  }), node.marks);
98
+ }
78
99
 
79
- // If we're going to collapse the expand and our cursor is currently inside
80
- // Move to a right gap cursor, if the toolbar is interacted (or an API),
81
- // it will insert below rather than inside (which will be invisible).
82
- if (isExpandedNext === false && findExpand(state)) {
83
- tr.setSelection(new GapCursorSelection(tr.doc.resolve(pos + node.nodeSize), Side.RIGHT));
84
- }
100
+ // If we're going to collapse the expand and our cursor is currently inside
101
+ // Move to a right gap cursor, if the toolbar is interacted (or an API),
102
+ // it will insert below rather than inside (which will be invisible).
103
+ if (getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage ? isExpandedNext === true : isExpandedNext === false && findExpand(state)) {
104
+ tr.setSelection(new GapCursorSelection(tr.doc.resolve(pos + node.nodeSize), Side.RIGHT));
105
+ }
85
106
 
86
- // log when people open/close expands
87
- // TODO: ED-8523 make platform/mode global attributes?
88
- var payload = {
89
- action: ACTION.TOGGLE_EXPAND,
90
- actionSubject: nodeType === state.schema.nodes.expand ? ACTION_SUBJECT.EXPAND : ACTION_SUBJECT.NESTED_EXPAND,
91
- attributes: {
92
- platform: PLATFORMS.WEB,
93
- mode: MODE.EDITOR,
94
- expanded: isExpandedNext
95
- },
96
- eventType: EVENT_TYPE.TRACK
97
- };
107
+ // log when people open/close expands
108
+ // TODO: ED-8523 make platform/mode global attributes?
109
+ var payload = {
110
+ action: ACTION.TOGGLE_EXPAND,
111
+ actionSubject: nodeType === state.schema.nodes.expand ? ACTION_SUBJECT.EXPAND : ACTION_SUBJECT.NESTED_EXPAND,
112
+ attributes: {
113
+ platform: PLATFORMS.WEB,
114
+ mode: MODE.EDITOR,
115
+ expanded: getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage ? !isExpandedNext : isExpandedNext
116
+ },
117
+ eventType: EVENT_TYPE.TRACK
118
+ };
98
119
 
99
- // `isRemote` meta prevents this step from being
100
- // sync'd between sessions in collab edit
101
- tr.setMeta('isRemote', true);
102
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
103
- dispatch(tr);
104
- }
105
- return true;
106
- };
120
+ // `isRemote` meta prevents this step from being
121
+ // sync'd between sessions in synchrony collab edit
122
+ tr.setMeta('isRemote', true);
123
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
124
+ dispatch(tr);
125
+ }
126
+ return true;
107
127
  };
108
128
  };
109
129
 
@@ -10,15 +10,16 @@ import { expandMessages } from '@atlaskit/editor-common/ui';
10
10
  import { closestElement, isEmptyNode } from '@atlaskit/editor-common/utils';
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
14
  import { deleteExpandAtPos, setSelectionInsideExpand, toggleExpandExpanded, updateExpandTitle } from '../commands';
14
15
  import { ExpandIconButton } from '../ui/ExpandIconButton';
15
16
  function buildExpandClassName(type, expanded) {
16
17
  return "".concat(expandClassNames.prefix, " ").concat(expandClassNames.type(type), " ").concat(expanded ? expandClassNames.expanded : '');
17
18
  }
18
- var toDOM = function toDOM(node, intl) {
19
+ var toDOM = function toDOM(node, __livePage, intl) {
19
20
  return ['div', {
20
21
  // prettier-ignore
21
- 'class': buildExpandClassName(node.type.name, node.attrs.__expanded),
22
+ 'class': buildExpandClassName(node.type.name, getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
22
23
  'data-node-type': node.type.name,
23
24
  'data-title': node.attrs.title
24
25
  }, ['div', {
@@ -52,6 +53,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
52
53
  function ExpandNodeView(node, view, getPos, getIntl, isMobile, selectNearNode, api) {
53
54
  var _this = this;
54
55
  var allowInteractiveExpand = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
56
+ var __livePage = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
55
57
  _classCallCheck(this, ExpandNodeView);
56
58
  _defineProperty(this, "allowInteractiveExpand", true);
57
59
  _defineProperty(this, "isMobile", false);
@@ -108,7 +110,12 @@ export var ExpandNodeView = /*#__PURE__*/function () {
108
110
  if (_this.view.dom instanceof HTMLElement) {
109
111
  _this.view.dom.blur();
110
112
  }
111
- toggleExpandExpanded((_this$api = _this.api) === null || _this$api === void 0 || (_this$api = _this$api.analytics) === null || _this$api === void 0 ? void 0 : _this$api.actions)(pos, _this.node.type)(state, dispatch);
113
+ toggleExpandExpanded({
114
+ editorAnalyticsAPI: (_this$api = _this.api) === null || _this$api === void 0 || (_this$api = _this$api.analytics) === null || _this$api === void 0 ? void 0 : _this$api.actions,
115
+ pos: pos,
116
+ nodeType: _this.node.type,
117
+ __livePage: _this.__livePage
118
+ })(state, dispatch);
112
119
  return;
113
120
  }
114
121
  if (target === _this.input) {
@@ -128,7 +135,12 @@ export var ExpandNodeView = /*#__PURE__*/function () {
128
135
  var _this$view3 = _this.view,
129
136
  state = _this$view3.state,
130
137
  dispatch = _this$view3.dispatch;
131
- updateExpandTitle(target.value, pos, _this.node.type)(state, dispatch);
138
+ updateExpandTitle({
139
+ title: target.value,
140
+ pos: pos,
141
+ nodeType: _this.node.type,
142
+ __livePage: _this.__livePage
143
+ })(state, dispatch);
132
144
  }
133
145
  });
134
146
  _defineProperty(this, "handleFocus", function (event) {
@@ -188,7 +200,12 @@ export var ExpandNodeView = /*#__PURE__*/function () {
188
200
  var _this$view4 = _this.view,
189
201
  state = _this$view4.state,
190
202
  dispatch = _this$view4.dispatch;
191
- toggleExpandExpanded((_this$api3 = _this.api) === null || _this$api3 === void 0 || (_this$api3 = _this$api3.analytics) === null || _this$api3 === void 0 ? void 0 : _this$api3.actions)(pos, _this.node.type)(state, dispatch);
203
+ toggleExpandExpanded({
204
+ editorAnalyticsAPI: (_this$api3 = _this.api) === null || _this$api3 === void 0 || (_this$api3 = _this$api3.analytics) === null || _this$api3 === void 0 ? void 0 : _this$api3.actions,
205
+ pos: pos,
206
+ nodeType: _this.node.type,
207
+ __livePage: _this.__livePage
208
+ })(state, dispatch);
192
209
  }
193
210
  });
194
211
  _defineProperty(this, "moveToOutsideOfTitle", function (event) {
@@ -220,6 +237,9 @@ export var ExpandNodeView = /*#__PURE__*/function () {
220
237
  }
221
238
  });
222
239
  _defineProperty(this, "isCollapsed", function () {
240
+ if (getBooleanFF('platform.editor.live-pages-expand-divergence') && _this.__livePage) {
241
+ return _this.node.attrs.__expanded;
242
+ }
223
243
  return !_this.node.attrs.__expanded;
224
244
  });
225
245
  _defineProperty(this, "setRightGapCursor", function (event) {
@@ -331,8 +351,9 @@ export var ExpandNodeView = /*#__PURE__*/function () {
331
351
  }
332
352
  });
333
353
  this.selectNearNode = selectNearNode;
354
+ this.__livePage = __livePage;
334
355
  this.intl = getIntl();
335
- var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(node, this.intl)),
356
+ var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(node, this.__livePage, this.intl)),
336
357
  dom = _DOMSerializer$render.dom,
337
358
  contentDOM = _DOMSerializer$render.contentDOM;
338
359
  this.allowInteractiveExpand = allowInteractiveExpand;
@@ -385,7 +406,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
385
406
  ReactDOM.render( /*#__PURE__*/React.createElement(ExpandIconButton, {
386
407
  intl: intl,
387
408
  allowInteractiveExpand: this.allowInteractiveExpand,
388
- expanded: __expanded
409
+ expanded: getBooleanFF('platform.editor.live-pages-expand-divergence') && this.__livePage ? !__expanded : __expanded
389
410
  }), this.icon);
390
411
  }
391
412
  }, {
@@ -421,7 +442,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
421
442
  }
422
443
  if (this.content) {
423
444
  // Disallow interaction/selection inside when collapsed.
424
- this.content.setAttribute('contenteditable', node.attrs.__expanded);
445
+ this.content.setAttribute('contenteditable', getBooleanFF('platform.editor.live-pages-expand-divergence') && this.__livePage ? !node.attrs.__expanded : node.attrs.__expanded);
425
446
  }
426
447
  }
427
448
 
@@ -477,9 +498,10 @@ export default function (_ref2) {
477
498
  isMobile = _ref2.isMobile,
478
499
  api = _ref2.api,
479
500
  _ref2$allowInteractiv = _ref2.allowInteractiveExpand,
480
- allowInteractiveExpand = _ref2$allowInteractiv === void 0 ? true : _ref2$allowInteractiv;
501
+ allowInteractiveExpand = _ref2$allowInteractiv === void 0 ? true : _ref2$allowInteractiv,
502
+ __livePage = _ref2.__livePage;
481
503
  return function (node, view, getPos) {
482
504
  var _api$selection;
483
- return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.actions) === null || _api$selection === void 0 ? void 0 : _api$selection.selectNearNode, api, allowInteractiveExpand);
505
+ return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.actions) === null || _api$selection === void 0 ? void 0 : _api$selection.selectNearNode, api, allowInteractiveExpand, __livePage);
484
506
  };
485
507
  }
@@ -36,12 +36,14 @@ export var expandPlugin = function expandPlugin(_ref) {
36
36
  var _options$allowInterac;
37
37
  var dispatch = _ref2.dispatch,
38
38
  getIntl = _ref2.getIntl;
39
- return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true);
39
+ return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true, options.__livePage);
40
40
  }
41
41
  }, {
42
42
  name: 'expandKeymap',
43
43
  plugin: function plugin() {
44
- return expandKeymap(api);
44
+ return expandKeymap(api, {
45
+ __livePage: options.__livePage
46
+ });
45
47
  }
46
48
  }];
47
49
  },
@@ -5,6 +5,7 @@ import { isPositionNearTableRow } from '@atlaskit/editor-common/utils';
5
5
  import { isEmptyNode } 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 { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { deleteExpand, focusTitle } from '../commands';
9
10
  import { findExpand } from '../utils';
10
11
  var isExpandNode = function isExpandNode(node) {
@@ -13,7 +14,7 @@ var isExpandNode = function isExpandNode(node) {
13
14
  var isExpandSelected = function isExpandSelected(selection) {
14
15
  return selection instanceof NodeSelection && isExpandNode(selection.node);
15
16
  };
16
- export function expandKeymap(api) {
17
+ export function expandKeymap(api, options) {
17
18
  var list = {};
18
19
  bindKeymapWithCommand(moveRight.common, function (state, dispatch, editorView) {
19
20
  var _api$selection;
@@ -70,7 +71,7 @@ export function expandKeymap(api) {
70
71
  var selection = state.selection,
71
72
  schema = state.schema;
72
73
  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) && !nodeBefore.attrs.__expanded) {
74
+ 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)) {
74
75
  var _$from = selection.$from;
75
76
  return focusTitle(Math.max(_$from.pos - 1, 0))(state, dispatch, editorView);
76
77
  }
@@ -94,7 +95,7 @@ export function expandKeymap(api) {
94
95
  var expandBefore = findExpand(state, sel);
95
96
  if (sel && expandBefore) {
96
97
  // moving cursor from outside of an expand to the title when it is collapsed
97
- if (!expandBefore.node.attrs.__expanded) {
98
+ if (getBooleanFF('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded) {
98
99
  return focusTitle(expandBefore.start)(state, dispatch, editorView);
99
100
  }
100
101
  // moving cursor from outside of an expand to the content when it is expanded
@@ -115,7 +116,7 @@ export function expandKeymap(api) {
115
116
  nestedExpand = _state$schema$nodes.nestedExpand;
116
117
  var selection = state.selection;
117
118
  var nodeAfter = selection.$from.nodeAfter;
118
- if (selection instanceof GapCursorSelection && selection.side === Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && !nodeAfter.attrs.__expanded) {
119
+ 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)) {
119
120
  var $from = selection.$from;
120
121
  return focusTitle($from.pos + 1)(state, dispatch, editorView);
121
122
  }
@@ -145,7 +146,7 @@ export function expandKeymap(api) {
145
146
  // @see ED-7977
146
147
  var sel = Selection.findFrom(state.doc.resolve(Math.max(selection.$from.pos - 1, 0)), -1);
147
148
  var expandBefore = findExpand(state, sel);
148
- if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && !expandBefore.node.attrs.__expanded) {
149
+ 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)) {
149
150
  return focusTitle(expandBefore.start)(state, dispatch, editorView);
150
151
  }
151
152
  return false;
@@ -15,6 +15,7 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
15
15
  var useLongPressSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
16
16
  var api = arguments.length > 4 ? arguments[4] : undefined;
17
17
  var allowInteractiveExpand = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
18
+ var __livePage = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
18
19
  var state = createPluginState(dispatch, {});
19
20
  var isMobile = appearance === 'mobile';
20
21
  return new SafePlugin({
@@ -26,13 +27,15 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
26
27
  getIntl: getIntl,
27
28
  isMobile: isMobile,
28
29
  api: api,
29
- allowInteractiveExpand: allowInteractiveExpand
30
+ allowInteractiveExpand: allowInteractiveExpand,
31
+ __livePage: __livePage
30
32
  }),
31
33
  nestedExpand: ExpandNodeView({
32
34
  getIntl: getIntl,
33
35
  isMobile: isMobile,
34
36
  api: api,
35
- allowInteractiveExpand: allowInteractiveExpand
37
+ allowInteractiveExpand: allowInteractiveExpand,
38
+ __livePage: __livePage
36
39
  })
37
40
  },
38
41
  handleKeyDown: function handleKeyDown(_view, event) {
package/dist/esm/utils.js CHANGED
@@ -1 +1 @@
1
- export { findExpand, transformSliceToRemoveOpenExpand, transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
1
+ export { findExpand, transformSliceToRemoveOpenExpand, transformSliceToRemoveOpenNestedExpand, transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
@@ -5,8 +5,18 @@ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
5
  export declare const setExpandRef: (ref?: HTMLDivElement | null) => Command;
6
6
  export declare const deleteExpandAtPos: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (expandNodePos: number, expandNode: PMNode) => Command;
7
7
  export declare const deleteExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
8
- export declare const updateExpandTitle: (title: string, pos: number, nodeType: NodeType) => Command;
9
- export declare const toggleExpandExpanded: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (pos: number, nodeType: NodeType) => Command;
8
+ export declare const updateExpandTitle: ({ title, nodeType, pos, __livePage, }: {
9
+ title: string;
10
+ pos: number;
11
+ nodeType: NodeType;
12
+ __livePage: boolean;
13
+ }) => Command;
14
+ export declare const toggleExpandExpanded: ({ editorAnalyticsAPI, pos, nodeType, __livePage, }: {
15
+ editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
16
+ pos: number;
17
+ nodeType: NodeType;
18
+ __livePage: boolean;
19
+ }) => Command;
10
20
  export declare const createExpandNode: (state: EditorState) => PMNode | null;
11
21
  export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
12
22
  export declare const focusTitle: (pos: number) => Command;
@@ -7,6 +7,7 @@ import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemir
7
7
  import type { ExpandPlugin } from '../types';
8
8
  export declare class ExpandNodeView implements NodeView {
9
9
  private selectNearNode;
10
+ private __livePage;
10
11
  node: PmNode;
11
12
  view: EditorView;
12
13
  dom: HTMLElement;
@@ -20,7 +21,7 @@ export declare class ExpandNodeView implements NodeView {
20
21
  allowInteractiveExpand: boolean;
21
22
  isMobile: boolean;
22
23
  api: ExtractInjectionAPI<ExpandPlugin> | undefined;
23
- constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean, selectNearNode: SetSelectionRelativeToNode | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean);
24
+ constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean, selectNearNode: SetSelectionRelativeToNode | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean, __livePage?: boolean);
24
25
  private initHandlers;
25
26
  private focusTitle;
26
27
  private handleIconKeyDown;
@@ -45,9 +46,10 @@ export declare class ExpandNodeView implements NodeView {
45
46
  update(node: PmNode, _decorations: readonly Decoration[]): boolean;
46
47
  destroy(): void;
47
48
  }
48
- export default function ({ getIntl, isMobile, api, allowInteractiveExpand, }: {
49
+ export default function ({ getIntl, isMobile, api, allowInteractiveExpand, __livePage, }: {
49
50
  getIntl: () => IntlShape;
50
51
  isMobile: boolean;
51
52
  api: ExtractInjectionAPI<ExpandPlugin> | undefined;
52
53
  allowInteractiveExpand: boolean;
54
+ __livePage: boolean;
53
55
  }): (node: PmNode, view: EditorView, getPos: getPosHandler) => NodeView;
@@ -1,4 +1,6 @@
1
1
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { ExpandPlugin } from '../types';
4
- export declare function expandKeymap(api: ExtractInjectionAPI<ExpandPlugin> | undefined): SafePlugin;
4
+ export declare function expandKeymap(api: ExtractInjectionAPI<ExpandPlugin> | undefined, options: {
5
+ __livePage?: boolean;
6
+ }): SafePlugin;
@@ -4,4 +4,4 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
5
  import type { ExpandPlugin } from '../types';
6
6
  export declare function containsClass(element: Element | null, className: string): boolean;
7
- export declare const createPlugin: (dispatch: Dispatch, getIntl: () => IntlShape, appearance: EditorAppearance | undefined, useLongPressSelection: boolean | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean) => SafePlugin<import("../types").ExpandPluginState>;
7
+ export declare const createPlugin: (dispatch: Dispatch, getIntl: () => IntlShape, appearance: EditorAppearance | undefined, useLongPressSelection: boolean | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean, __livePage?: boolean) => SafePlugin<import("../types").ExpandPluginState>;
@@ -21,6 +21,16 @@ export interface ExpandPluginOptions extends LongPressSelectionPluginOptions {
21
21
  */
22
22
  allowInteractiveExpand?: boolean;
23
23
  appearance?: EditorAppearance;
24
+ /**
25
+ * There is expected to be temporary divergence between Live Page editor expand behaviour and the standard expand behaviour.
26
+ *
27
+ * This is expected to be removed in Q4 as Editor and Live Page teams align on a singular behaviour.
28
+ *
29
+ * It is only supported for use by Confluence.
30
+ *
31
+ * @default false
32
+ */
33
+ __livePage?: boolean;
24
34
  }
25
35
  export type ExpandPlugin = NextEditorPlugin<'expand', {
26
36
  pluginConfiguration: ExpandPluginOptions | undefined;
@@ -1 +1 @@
1
- export { findExpand, transformSliceToRemoveOpenExpand, transformSliceNestedExpandToExpand, } from '@atlaskit/editor-common/transforms';
1
+ export { findExpand, transformSliceToRemoveOpenExpand, transformSliceToRemoveOpenNestedExpand, transformSliceNestedExpandToExpand, } from '@atlaskit/editor-common/transforms';
@@ -5,8 +5,18 @@ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
5
  export declare const setExpandRef: (ref?: HTMLDivElement | null) => Command;
6
6
  export declare const deleteExpandAtPos: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (expandNodePos: number, expandNode: PMNode) => Command;
7
7
  export declare const deleteExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
8
- export declare const updateExpandTitle: (title: string, pos: number, nodeType: NodeType) => Command;
9
- export declare const toggleExpandExpanded: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (pos: number, nodeType: NodeType) => Command;
8
+ export declare const updateExpandTitle: ({ title, nodeType, pos, __livePage, }: {
9
+ title: string;
10
+ pos: number;
11
+ nodeType: NodeType;
12
+ __livePage: boolean;
13
+ }) => Command;
14
+ export declare const toggleExpandExpanded: ({ editorAnalyticsAPI, pos, nodeType, __livePage, }: {
15
+ editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
16
+ pos: number;
17
+ nodeType: NodeType;
18
+ __livePage: boolean;
19
+ }) => Command;
10
20
  export declare const createExpandNode: (state: EditorState) => PMNode | null;
11
21
  export declare const insertExpand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
12
22
  export declare const focusTitle: (pos: number) => Command;
@@ -7,6 +7,7 @@ import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemir
7
7
  import type { ExpandPlugin } from '../types';
8
8
  export declare class ExpandNodeView implements NodeView {
9
9
  private selectNearNode;
10
+ private __livePage;
10
11
  node: PmNode;
11
12
  view: EditorView;
12
13
  dom: HTMLElement;
@@ -20,7 +21,7 @@ export declare class ExpandNodeView implements NodeView {
20
21
  allowInteractiveExpand: boolean;
21
22
  isMobile: boolean;
22
23
  api: ExtractInjectionAPI<ExpandPlugin> | undefined;
23
- constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean, selectNearNode: SetSelectionRelativeToNode | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean);
24
+ constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean, selectNearNode: SetSelectionRelativeToNode | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean, __livePage?: boolean);
24
25
  private initHandlers;
25
26
  private focusTitle;
26
27
  private handleIconKeyDown;
@@ -45,9 +46,10 @@ export declare class ExpandNodeView implements NodeView {
45
46
  update(node: PmNode, _decorations: readonly Decoration[]): boolean;
46
47
  destroy(): void;
47
48
  }
48
- export default function ({ getIntl, isMobile, api, allowInteractiveExpand, }: {
49
+ export default function ({ getIntl, isMobile, api, allowInteractiveExpand, __livePage, }: {
49
50
  getIntl: () => IntlShape;
50
51
  isMobile: boolean;
51
52
  api: ExtractInjectionAPI<ExpandPlugin> | undefined;
52
53
  allowInteractiveExpand: boolean;
54
+ __livePage: boolean;
53
55
  }): (node: PmNode, view: EditorView, getPos: getPosHandler) => NodeView;
@@ -1,4 +1,6 @@
1
1
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { ExpandPlugin } from '../types';
4
- export declare function expandKeymap(api: ExtractInjectionAPI<ExpandPlugin> | undefined): SafePlugin;
4
+ export declare function expandKeymap(api: ExtractInjectionAPI<ExpandPlugin> | undefined, options: {
5
+ __livePage?: boolean;
6
+ }): SafePlugin;
@@ -4,4 +4,4 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
5
  import type { ExpandPlugin } from '../types';
6
6
  export declare function containsClass(element: Element | null, className: string): boolean;
7
- export declare const createPlugin: (dispatch: Dispatch, getIntl: () => IntlShape, appearance: EditorAppearance | undefined, useLongPressSelection: boolean | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean) => SafePlugin<import("../types").ExpandPluginState>;
7
+ export declare const createPlugin: (dispatch: Dispatch, getIntl: () => IntlShape, appearance: EditorAppearance | undefined, useLongPressSelection: boolean | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean, __livePage?: boolean) => SafePlugin<import("../types").ExpandPluginState>;
@@ -21,6 +21,16 @@ export interface ExpandPluginOptions extends LongPressSelectionPluginOptions {
21
21
  */
22
22
  allowInteractiveExpand?: boolean;
23
23
  appearance?: EditorAppearance;
24
+ /**
25
+ * There is expected to be temporary divergence between Live Page editor expand behaviour and the standard expand behaviour.
26
+ *
27
+ * This is expected to be removed in Q4 as Editor and Live Page teams align on a singular behaviour.
28
+ *
29
+ * It is only supported for use by Confluence.
30
+ *
31
+ * @default false
32
+ */
33
+ __livePage?: boolean;
24
34
  }
25
35
  export type ExpandPlugin = NextEditorPlugin<'expand', {
26
36
  pluginConfiguration: ExpandPluginOptions | undefined;
@@ -1 +1 @@
1
- export { findExpand, transformSliceToRemoveOpenExpand, transformSliceNestedExpandToExpand, } from '@atlaskit/editor-common/transforms';
1
+ export { findExpand, transformSliceToRemoveOpenExpand, transformSliceToRemoveOpenNestedExpand, transformSliceNestedExpandToExpand, } from '@atlaskit/editor-common/transforms';