@atlaskit/editor-plugin-expand 7.4.4 → 7.4.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,22 @@
1
1
  # @atlaskit/editor-plugin-expand
2
2
 
3
+ ## 7.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4d676bbdb3ce6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4d676bbdb3ce6) -
8
+ ts-ignore added temporarily to unblock local consumption for help-center, will be removed once
9
+ project refs are setup
10
+ - Updated dependencies
11
+
12
+ ## 7.4.5
13
+
14
+ ### Patch Changes
15
+
16
+ - [`15164638b4d1a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/15164638b4d1a) -
17
+ [ux] [EDITOR-2461] handle ArrowUp navigation out of the Expand title
18
+ - Updated dependencies
19
+
3
20
  ## 7.4.4
4
21
 
5
22
  ### Patch Changes
@@ -193,7 +193,11 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
193
193
  _this.handleArrowLeftFromTitle(event);
194
194
  break;
195
195
  case 'ArrowUp':
196
- _this.setLeftGapCursor(event);
196
+ if ((0, _expValEquals.expValEquals)('platform_editor_lovability_navigation_fixes', 'isEnabled', true)) {
197
+ _this.moveToPreviousLine(event);
198
+ } else {
199
+ _this.setLeftGapCursor(event);
200
+ }
197
201
  break;
198
202
  case 'Backspace':
199
203
  _this.deleteExpand(event);
@@ -315,7 +319,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
315
319
  dispatch(state.tr.setSelection(new _selection.GapCursorSelection(state.doc.resolve(_this.node.nodeSize + pos), _selection.Side.RIGHT)));
316
320
  }
317
321
  });
318
- (0, _defineProperty2.default)(this, "setLeftGapCursor", function (event) {
322
+ (0, _defineProperty2.default)(this, "moveToPreviousLine", function (event) {
319
323
  if (!_this.input) {
320
324
  return;
321
325
  }
@@ -331,12 +335,23 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
331
335
  var _this$view7 = _this.view,
332
336
  state = _this$view7.state,
333
337
  dispatch = _this$view7.dispatch;
334
- _this.view.focus();
335
- dispatch(state.tr.setSelection(new _selection.GapCursorSelection(state.doc.resolve(pos), _selection.Side.LEFT)));
338
+ var resolvedPos = state.doc.resolve(pos);
339
+ if (!resolvedPos) {
340
+ return;
341
+ }
342
+ if (resolvedPos.pos === 0) {
343
+ _this.setLeftGapCursor(event);
344
+ return;
345
+ }
346
+ var sel = _state.Selection.findFrom(resolvedPos, -1);
347
+ if (sel) {
348
+ _this.view.focus();
349
+ dispatch(state.tr.setSelection(sel));
350
+ }
336
351
  }
337
352
  });
338
- (0, _defineProperty2.default)(this, "handleArrowRightFromTitle", function (event) {
339
- if (!_this.input || !_this.selectNearNode) {
353
+ (0, _defineProperty2.default)(this, "setLeftGapCursor", function (event) {
354
+ if (!_this.input) {
340
355
  return;
341
356
  }
342
357
  var pos = _this.getPos();
@@ -344,15 +359,35 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
344
359
  return;
345
360
  }
346
361
  var _this$input4 = _this.input,
347
- value = _this$input4.value,
348
362
  selectionStart = _this$input4.selectionStart,
349
363
  selectionEnd = _this$input4.selectionEnd;
350
- if (selectionStart === selectionEnd && selectionStart === value.length) {
364
+ if (selectionStart === selectionEnd && selectionStart === 0) {
351
365
  event.preventDefault();
352
366
  var _this$view8 = _this.view,
353
367
  state = _this$view8.state,
354
368
  dispatch = _this$view8.dispatch;
355
369
  _this.view.focus();
370
+ dispatch(state.tr.setSelection(new _selection.GapCursorSelection(state.doc.resolve(pos), _selection.Side.LEFT)));
371
+ }
372
+ });
373
+ (0, _defineProperty2.default)(this, "handleArrowRightFromTitle", function (event) {
374
+ if (!_this.input || !_this.selectNearNode) {
375
+ return;
376
+ }
377
+ var pos = _this.getPos();
378
+ if (typeof pos !== 'number') {
379
+ return;
380
+ }
381
+ var _this$input5 = _this.input,
382
+ value = _this$input5.value,
383
+ selectionStart = _this$input5.selectionStart,
384
+ selectionEnd = _this$input5.selectionEnd;
385
+ if (selectionStart === selectionEnd && selectionStart === value.length) {
386
+ event.preventDefault();
387
+ var _this$view9 = _this.view,
388
+ state = _this$view9.state,
389
+ dispatch = _this$view9.dispatch;
390
+ _this.view.focus();
356
391
  var tr = _this.selectNearNode({
357
392
  selectionRelativeToNode: _selection.RelativeSelectionPos.End,
358
393
  selection: _state.NodeSelection.create(state.doc, pos)
@@ -370,15 +405,15 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
370
405
  if (typeof pos !== 'number') {
371
406
  return;
372
407
  }
373
- var _this$input5 = _this.input,
374
- selectionStart = _this$input5.selectionStart,
375
- selectionEnd = _this$input5.selectionEnd;
408
+ var _this$input6 = _this.input,
409
+ selectionStart = _this$input6.selectionStart,
410
+ selectionEnd = _this$input6.selectionEnd;
376
411
  if (selectionStart === selectionEnd && selectionStart === 0) {
377
412
  var _this$api5;
378
413
  event.preventDefault();
379
- var _this$view9 = _this.view,
380
- state = _this$view9.state,
381
- dispatch = _this$view9.dispatch;
414
+ var _this$view0 = _this.view,
415
+ state = _this$view0.state,
416
+ dispatch = _this$view0.dispatch;
382
417
  _this.view.focus();
383
418
  var selectionSharedState = ((_this$api5 = _this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.selection) === null || _this$api5 === void 0 ? void 0 : _this$api5.sharedState.currentState()) || {};
384
419
  // selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
@@ -403,17 +438,17 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
403
438
  }
404
439
  });
405
440
  (0, _defineProperty2.default)(this, "handleUndoFromTitle", function (event) {
406
- var _this$view0 = _this.view,
407
- state = _this$view0.state,
408
- dispatch = _this$view0.dispatch;
441
+ var _this$view1 = _this.view,
442
+ state = _this$view1.state,
443
+ dispatch = _this$view1.dispatch;
409
444
  (0, _prosemirrorHistory.undo)(state, dispatch);
410
445
  event.preventDefault();
411
446
  return;
412
447
  });
413
448
  (0, _defineProperty2.default)(this, "handleRedoFromTitle", function (event) {
414
- var _this$view1 = _this.view,
415
- state = _this$view1.state,
416
- dispatch = _this$view1.dispatch;
449
+ var _this$view10 = _this.view,
450
+ state = _this$view10.state,
451
+ dispatch = _this$view10.dispatch;
417
452
  (0, _prosemirrorHistory.redo)(state, dispatch);
418
453
  event.preventDefault();
419
454
  return;
@@ -35,6 +35,8 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
35
35
  state: state,
36
36
  key: _pluginFactory.pluginKey,
37
37
  props: {
38
+ // @ts-ignore - Workaround for help-center local consumption
39
+
38
40
  nodeViews: {
39
41
  expand: (0, _nodeviews.default)({
40
42
  getIntl: getIntl,
@@ -53,9 +55,11 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
53
55
  __livePage: __livePage
54
56
  })
55
57
  },
58
+ // @ts-ignore - Workaround for help-center local consumption
56
59
  handleKeyDown: function handleKeyDown(_view, event) {
57
60
  return containsClass(event.target, _styles.expandClassNames.titleContainer);
58
61
  },
62
+ // @ts-ignore - Workaround for help-center local consumption
59
63
  handleKeyPress: function handleKeyPress(_view, event) {
60
64
  return containsClass(event.target, _styles.expandClassNames.titleContainer);
61
65
  },
@@ -67,11 +71,13 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
67
71
  }, {
68
72
  useLongPressSelection: useLongPressSelection
69
73
  }),
74
+ // @ts-ignore - Workaround for help-center local consumption
70
75
  handleDrop: function handleDrop(view, event, slice, moved) {
71
76
  return handleExpandDrag(view, event, slice);
72
77
  }
73
78
  },
74
79
  // @see ED-8027 to follow up on this work-around
80
+ // @ts-ignore - Workaround for help-center local consumption
75
81
  filterTransaction: function filterTransaction(tr) {
76
82
  if (containsClass(document.activeElement, _styles.expandClassNames.titleInput) && tr.selectionSet && (!tr.steps.length || tr.isGeneric)) {
77
83
  return false;
@@ -109,6 +115,9 @@ function handleExpandDrag(view, event, slice) {
109
115
  to = selection.to;
110
116
  var sliceContainsExpand = false;
111
117
  var sliceContainsNestedExpand = false;
118
+
119
+ // @ts-ignore - Workaround for help-center local consumption
120
+
112
121
  slice.content.forEach(function (node) {
113
122
  if (node.type === state.schema.nodes.expand) {
114
123
  sliceContainsExpand = true;
@@ -151,7 +151,11 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
151
151
  _this.handleArrowLeftFromTitle(event);
152
152
  break;
153
153
  case 'ArrowUp':
154
- _this.setLeftGapCursor(event);
154
+ if ((0, _expValEquals.expValEquals)('platform_editor_lovability_navigation_fixes', 'isEnabled', true)) {
155
+ _this.moveToPreviousLine(event);
156
+ } else {
157
+ _this.setLeftGapCursor(event);
158
+ }
155
159
  break;
156
160
  case 'Backspace':
157
161
  _this.deleteEmptyExpand();
@@ -270,7 +274,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
270
274
  dispatch(state.tr.setSelection(new _selection.GapCursorSelection(state.doc.resolve(_this.node.nodeSize + pos), _selection.Side.RIGHT)));
271
275
  }
272
276
  });
273
- (0, _defineProperty2.default)(this, "setLeftGapCursor", function (event) {
277
+ (0, _defineProperty2.default)(this, "moveToPreviousLine", function (event) {
274
278
  if (!_this.input) {
275
279
  return;
276
280
  }
@@ -286,12 +290,23 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
286
290
  var _this$view6 = _this.view,
287
291
  state = _this$view6.state,
288
292
  dispatch = _this$view6.dispatch;
289
- _this.view.focus();
290
- dispatch(state.tr.setSelection(new _selection.GapCursorSelection(state.doc.resolve(pos), _selection.Side.LEFT)));
293
+ var resolvedPos = state.doc.resolve(pos);
294
+ if (!resolvedPos) {
295
+ return;
296
+ }
297
+ if (resolvedPos.pos === 0) {
298
+ _this.setLeftGapCursor(event);
299
+ return;
300
+ }
301
+ var sel = _state.Selection.findFrom(resolvedPos, -1);
302
+ if (sel) {
303
+ _this.view.focus();
304
+ dispatch(state.tr.setSelection(sel));
305
+ }
291
306
  }
292
307
  });
293
- (0, _defineProperty2.default)(this, "handleArrowRightFromTitle", function (event) {
294
- if (!_this.input || !_this.selectNearNode) {
308
+ (0, _defineProperty2.default)(this, "setLeftGapCursor", function (event) {
309
+ if (!_this.input) {
295
310
  return;
296
311
  }
297
312
  var pos = _this.getPos();
@@ -299,15 +314,35 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
299
314
  return;
300
315
  }
301
316
  var _this$input4 = _this.input,
302
- value = _this$input4.value,
303
317
  selectionStart = _this$input4.selectionStart,
304
318
  selectionEnd = _this$input4.selectionEnd;
305
- if (selectionStart === selectionEnd && selectionStart === value.length) {
319
+ if (selectionStart === selectionEnd && selectionStart === 0) {
306
320
  event.preventDefault();
307
321
  var _this$view7 = _this.view,
308
322
  state = _this$view7.state,
309
323
  dispatch = _this$view7.dispatch;
310
324
  _this.view.focus();
325
+ dispatch(state.tr.setSelection(new _selection.GapCursorSelection(state.doc.resolve(pos), _selection.Side.LEFT)));
326
+ }
327
+ });
328
+ (0, _defineProperty2.default)(this, "handleArrowRightFromTitle", function (event) {
329
+ if (!_this.input || !_this.selectNearNode) {
330
+ return;
331
+ }
332
+ var pos = _this.getPos();
333
+ if (typeof pos !== 'number') {
334
+ return;
335
+ }
336
+ var _this$input5 = _this.input,
337
+ value = _this$input5.value,
338
+ selectionStart = _this$input5.selectionStart,
339
+ selectionEnd = _this$input5.selectionEnd;
340
+ if (selectionStart === selectionEnd && selectionStart === value.length) {
341
+ event.preventDefault();
342
+ var _this$view8 = _this.view,
343
+ state = _this$view8.state,
344
+ dispatch = _this$view8.dispatch;
345
+ _this.view.focus();
311
346
  var tr = _this.selectNearNode({
312
347
  selectionRelativeToNode: _selection.RelativeSelectionPos.End,
313
348
  selection: _state.NodeSelection.create(state.doc, pos)
@@ -325,15 +360,15 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
325
360
  if (typeof pos !== 'number') {
326
361
  return;
327
362
  }
328
- var _this$input5 = _this.input,
329
- selectionStart = _this$input5.selectionStart,
330
- selectionEnd = _this$input5.selectionEnd;
363
+ var _this$input6 = _this.input,
364
+ selectionStart = _this$input6.selectionStart,
365
+ selectionEnd = _this$input6.selectionEnd;
331
366
  if (selectionStart === selectionEnd && selectionStart === 0) {
332
367
  var _this$api5;
333
368
  event.preventDefault();
334
- var _this$view8 = _this.view,
335
- state = _this$view8.state,
336
- dispatch = _this$view8.dispatch;
369
+ var _this$view9 = _this.view,
370
+ state = _this$view9.state,
371
+ dispatch = _this$view9.dispatch;
337
372
  _this.view.focus();
338
373
  var selectionSharedState = ((_this$api5 = _this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.selection) === null || _this$api5 === void 0 ? void 0 : _this$api5.sharedState.currentState()) || {};
339
374
  // selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
@@ -358,17 +393,17 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
358
393
  }
359
394
  });
360
395
  (0, _defineProperty2.default)(this, "handleUndoFromTitle", function (event) {
361
- var _this$view9 = _this.view,
362
- state = _this$view9.state,
363
- dispatch = _this$view9.dispatch;
396
+ var _this$view0 = _this.view,
397
+ state = _this$view0.state,
398
+ dispatch = _this$view0.dispatch;
364
399
  (0, _prosemirrorHistory.undo)(state, dispatch);
365
400
  event.preventDefault();
366
401
  return;
367
402
  });
368
403
  (0, _defineProperty2.default)(this, "handleRedoFromTitle", function (event) {
369
- var _this$view0 = _this.view,
370
- state = _this$view0.state,
371
- dispatch = _this$view0.dispatch;
404
+ var _this$view1 = _this.view,
405
+ state = _this$view1.state,
406
+ dispatch = _this$view1.dispatch;
372
407
  (0, _prosemirrorHistory.redo)(state, dispatch);
373
408
  event.preventDefault();
374
409
  return;
@@ -33,6 +33,8 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
33
33
  return new _safePlugin.SafePlugin({
34
34
  key: pluginKey,
35
35
  props: {
36
+ // @ts-ignore - Workaround for help-center local consumption
37
+
36
38
  nodeViews: {
37
39
  expand: (0, _nodeViews.default)({
38
40
  getIntl: getIntl,
@@ -51,9 +53,11 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
51
53
  __livePage: __livePage
52
54
  })
53
55
  },
56
+ // @ts-ignore - Workaround for help-center local consumption
54
57
  handleKeyDown: function handleKeyDown(_view, event) {
55
58
  return containsClass(event.target, _styles.expandClassNames.titleContainer);
56
59
  },
60
+ // @ts-ignore - Workaround for help-center local consumption
57
61
  handleKeyPress: function handleKeyPress(_view, event) {
58
62
  return containsClass(event.target, _styles.expandClassNames.titleContainer);
59
63
  },
@@ -65,11 +69,13 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
65
69
  }, {
66
70
  useLongPressSelection: useLongPressSelection
67
71
  }),
72
+ // @ts-ignore - Workaround for help-center local consumption
68
73
  handleDrop: function handleDrop(view, event, slice, moved) {
69
74
  return handleExpandDrag(view, event, slice);
70
75
  }
71
76
  },
72
77
  // @see ED-8027 to follow up on this work-around
78
+ // @ts-ignore - Workaround for help-center local consumption
73
79
  filterTransaction: function filterTransaction(tr) {
74
80
  if (containsClass(document.activeElement, _styles.expandClassNames.titleInput) && tr.selectionSet && (!tr.steps.length || tr.isGeneric)) {
75
81
  return false;
@@ -91,6 +97,9 @@ function handleExpandDrag(view, event, slice) {
91
97
  to = selection.to;
92
98
  var sliceContainsExpand = false;
93
99
  var sliceContainsNestedExpand = false;
100
+
101
+ // @ts-ignore - Workaround for help-center local consumption
102
+
94
103
  slice.content.forEach(function (node) {
95
104
  if (node.type === state.schema.nodes.expand) {
96
105
  sliceContainsExpand = true;
@@ -179,7 +179,11 @@ export class ExpandNodeView {
179
179
  this.handleArrowLeftFromTitle(event);
180
180
  break;
181
181
  case 'ArrowUp':
182
- this.setLeftGapCursor(event);
182
+ if (expValEquals('platform_editor_lovability_navigation_fixes', 'isEnabled', true)) {
183
+ this.moveToPreviousLine(event);
184
+ } else {
185
+ this.setLeftGapCursor(event);
186
+ }
183
187
  break;
184
188
  case 'Backspace':
185
189
  this.deleteExpand(event);
@@ -308,6 +312,39 @@ export class ExpandNodeView {
308
312
  dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(this.node.nodeSize + pos), Side.RIGHT)));
309
313
  }
310
314
  });
315
+ _defineProperty(this, "moveToPreviousLine", event => {
316
+ if (!this.input) {
317
+ return;
318
+ }
319
+ const pos = this.getPos();
320
+ if (typeof pos !== 'number') {
321
+ return;
322
+ }
323
+ const {
324
+ selectionStart,
325
+ selectionEnd
326
+ } = this.input;
327
+ if (selectionStart === selectionEnd && selectionStart === 0) {
328
+ event.preventDefault();
329
+ const {
330
+ state,
331
+ dispatch
332
+ } = this.view;
333
+ const resolvedPos = state.doc.resolve(pos);
334
+ if (!resolvedPos) {
335
+ return;
336
+ }
337
+ if (resolvedPos.pos === 0) {
338
+ this.setLeftGapCursor(event);
339
+ return;
340
+ }
341
+ const sel = Selection.findFrom(resolvedPos, -1);
342
+ if (sel) {
343
+ this.view.focus();
344
+ dispatch(state.tr.setSelection(sel));
345
+ }
346
+ }
347
+ });
311
348
  _defineProperty(this, "setLeftGapCursor", event => {
312
349
  if (!this.input) {
313
350
  return;
@@ -19,6 +19,8 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
19
19
  state: state,
20
20
  key: pluginKey,
21
21
  props: {
22
+ // @ts-ignore - Workaround for help-center local consumption
23
+
22
24
  nodeViews: {
23
25
  expand: ExpandNodeView({
24
26
  getIntl,
@@ -37,9 +39,13 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
37
39
  __livePage
38
40
  })
39
41
  },
42
+ // @ts-ignore - Workaround for help-center local consumption
43
+
40
44
  handleKeyDown(_view, event) {
41
45
  return containsClass(event.target, expandClassNames.titleContainer);
42
46
  },
47
+ // @ts-ignore - Workaround for help-center local consumption
48
+
43
49
  handleKeyPress(_view, event) {
44
50
  return containsClass(event.target, expandClassNames.titleContainer);
45
51
  },
@@ -49,11 +55,15 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
49
55
  handleClickOn: createSelectionClickHandler(['expand', 'nestedExpand'], target => target.classList.contains(expandClassNames.prefix), {
50
56
  useLongPressSelection
51
57
  }),
58
+ // @ts-ignore - Workaround for help-center local consumption
59
+
52
60
  handleDrop(view, event, slice, moved) {
53
61
  return handleExpandDrag(view, event, slice);
54
62
  }
55
63
  },
56
64
  // @see ED-8027 to follow up on this work-around
65
+ // @ts-ignore - Workaround for help-center local consumption
66
+
57
67
  filterTransaction(tr) {
58
68
  if (containsClass(document.activeElement, expandClassNames.titleInput) && tr.selectionSet && (!tr.steps.length || tr.isGeneric)) {
59
69
  return false;
@@ -99,6 +109,9 @@ export function handleExpandDrag(view, event, slice) {
99
109
  } = selection;
100
110
  let sliceContainsExpand = false;
101
111
  let sliceContainsNestedExpand = false;
112
+
113
+ // @ts-ignore - Workaround for help-center local consumption
114
+
102
115
  slice.content.forEach(node => {
103
116
  if (node.type === state.schema.nodes.expand) {
104
117
  sliceContainsExpand = true;
@@ -136,7 +136,11 @@ export class ExpandNodeView {
136
136
  this.handleArrowLeftFromTitle(event);
137
137
  break;
138
138
  case 'ArrowUp':
139
- this.setLeftGapCursor(event);
139
+ if (expValEquals('platform_editor_lovability_navigation_fixes', 'isEnabled', true)) {
140
+ this.moveToPreviousLine(event);
141
+ } else {
142
+ this.setLeftGapCursor(event);
143
+ }
140
144
  break;
141
145
  case 'Backspace':
142
146
  this.deleteEmptyExpand();
@@ -262,6 +266,39 @@ export class ExpandNodeView {
262
266
  dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(this.node.nodeSize + pos), Side.RIGHT)));
263
267
  }
264
268
  });
269
+ _defineProperty(this, "moveToPreviousLine", event => {
270
+ if (!this.input) {
271
+ return;
272
+ }
273
+ const pos = this.getPos();
274
+ if (typeof pos !== 'number') {
275
+ return;
276
+ }
277
+ const {
278
+ selectionStart,
279
+ selectionEnd
280
+ } = this.input;
281
+ if (selectionStart === selectionEnd && selectionStart === 0) {
282
+ event.preventDefault();
283
+ const {
284
+ state,
285
+ dispatch
286
+ } = this.view;
287
+ const resolvedPos = state.doc.resolve(pos);
288
+ if (!resolvedPos) {
289
+ return;
290
+ }
291
+ if (resolvedPos.pos === 0) {
292
+ this.setLeftGapCursor(event);
293
+ return;
294
+ }
295
+ const sel = Selection.findFrom(resolvedPos, -1);
296
+ if (sel) {
297
+ this.view.focus();
298
+ dispatch(state.tr.setSelection(sel));
299
+ }
300
+ }
301
+ });
265
302
  _defineProperty(this, "setLeftGapCursor", event => {
266
303
  if (!this.input) {
267
304
  return;
@@ -16,6 +16,8 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
16
16
  return new SafePlugin({
17
17
  key: pluginKey,
18
18
  props: {
19
+ // @ts-ignore - Workaround for help-center local consumption
20
+
19
21
  nodeViews: {
20
22
  expand: ExpandNodeView({
21
23
  getIntl,
@@ -34,9 +36,13 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
34
36
  __livePage
35
37
  })
36
38
  },
39
+ // @ts-ignore - Workaround for help-center local consumption
40
+
37
41
  handleKeyDown(_view, event) {
38
42
  return containsClass(event.target, expandClassNames.titleContainer);
39
43
  },
44
+ // @ts-ignore - Workaround for help-center local consumption
45
+
40
46
  handleKeyPress(_view, event) {
41
47
  return containsClass(event.target, expandClassNames.titleContainer);
42
48
  },
@@ -46,11 +52,15 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
46
52
  handleClickOn: createSelectionClickHandler(['expand', 'nestedExpand'], target => target.classList.contains(expandClassNames.prefix), {
47
53
  useLongPressSelection
48
54
  }),
55
+ // @ts-ignore - Workaround for help-center local consumption
56
+
49
57
  handleDrop(view, event, slice, moved) {
50
58
  return handleExpandDrag(view, event, slice);
51
59
  }
52
60
  },
53
61
  // @see ED-8027 to follow up on this work-around
62
+ // @ts-ignore - Workaround for help-center local consumption
63
+
54
64
  filterTransaction(tr) {
55
65
  if (containsClass(document.activeElement, expandClassNames.titleInput) && tr.selectionSet && (!tr.steps.length || tr.isGeneric)) {
56
66
  return false;
@@ -78,6 +88,9 @@ export function handleExpandDrag(view, event, slice) {
78
88
  } = selection;
79
89
  let sliceContainsExpand = false;
80
90
  let sliceContainsNestedExpand = false;
91
+
92
+ // @ts-ignore - Workaround for help-center local consumption
93
+
81
94
  slice.content.forEach(node => {
82
95
  if (node.type === state.schema.nodes.expand) {
83
96
  sliceContainsExpand = true;
@@ -186,7 +186,11 @@ export var ExpandNodeView = /*#__PURE__*/function () {
186
186
  _this.handleArrowLeftFromTitle(event);
187
187
  break;
188
188
  case 'ArrowUp':
189
- _this.setLeftGapCursor(event);
189
+ if (expValEquals('platform_editor_lovability_navigation_fixes', 'isEnabled', true)) {
190
+ _this.moveToPreviousLine(event);
191
+ } else {
192
+ _this.setLeftGapCursor(event);
193
+ }
190
194
  break;
191
195
  case 'Backspace':
192
196
  _this.deleteExpand(event);
@@ -308,7 +312,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
308
312
  dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(_this.node.nodeSize + pos), Side.RIGHT)));
309
313
  }
310
314
  });
311
- _defineProperty(this, "setLeftGapCursor", function (event) {
315
+ _defineProperty(this, "moveToPreviousLine", function (event) {
312
316
  if (!_this.input) {
313
317
  return;
314
318
  }
@@ -324,12 +328,23 @@ export var ExpandNodeView = /*#__PURE__*/function () {
324
328
  var _this$view7 = _this.view,
325
329
  state = _this$view7.state,
326
330
  dispatch = _this$view7.dispatch;
327
- _this.view.focus();
328
- dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(pos), Side.LEFT)));
331
+ var resolvedPos = state.doc.resolve(pos);
332
+ if (!resolvedPos) {
333
+ return;
334
+ }
335
+ if (resolvedPos.pos === 0) {
336
+ _this.setLeftGapCursor(event);
337
+ return;
338
+ }
339
+ var sel = Selection.findFrom(resolvedPos, -1);
340
+ if (sel) {
341
+ _this.view.focus();
342
+ dispatch(state.tr.setSelection(sel));
343
+ }
329
344
  }
330
345
  });
331
- _defineProperty(this, "handleArrowRightFromTitle", function (event) {
332
- if (!_this.input || !_this.selectNearNode) {
346
+ _defineProperty(this, "setLeftGapCursor", function (event) {
347
+ if (!_this.input) {
333
348
  return;
334
349
  }
335
350
  var pos = _this.getPos();
@@ -337,15 +352,35 @@ export var ExpandNodeView = /*#__PURE__*/function () {
337
352
  return;
338
353
  }
339
354
  var _this$input4 = _this.input,
340
- value = _this$input4.value,
341
355
  selectionStart = _this$input4.selectionStart,
342
356
  selectionEnd = _this$input4.selectionEnd;
343
- if (selectionStart === selectionEnd && selectionStart === value.length) {
357
+ if (selectionStart === selectionEnd && selectionStart === 0) {
344
358
  event.preventDefault();
345
359
  var _this$view8 = _this.view,
346
360
  state = _this$view8.state,
347
361
  dispatch = _this$view8.dispatch;
348
362
  _this.view.focus();
363
+ dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(pos), Side.LEFT)));
364
+ }
365
+ });
366
+ _defineProperty(this, "handleArrowRightFromTitle", function (event) {
367
+ if (!_this.input || !_this.selectNearNode) {
368
+ return;
369
+ }
370
+ var pos = _this.getPos();
371
+ if (typeof pos !== 'number') {
372
+ return;
373
+ }
374
+ var _this$input5 = _this.input,
375
+ value = _this$input5.value,
376
+ selectionStart = _this$input5.selectionStart,
377
+ selectionEnd = _this$input5.selectionEnd;
378
+ if (selectionStart === selectionEnd && selectionStart === value.length) {
379
+ event.preventDefault();
380
+ var _this$view9 = _this.view,
381
+ state = _this$view9.state,
382
+ dispatch = _this$view9.dispatch;
383
+ _this.view.focus();
349
384
  var tr = _this.selectNearNode({
350
385
  selectionRelativeToNode: RelativeSelectionPos.End,
351
386
  selection: NodeSelection.create(state.doc, pos)
@@ -363,15 +398,15 @@ export var ExpandNodeView = /*#__PURE__*/function () {
363
398
  if (typeof pos !== 'number') {
364
399
  return;
365
400
  }
366
- var _this$input5 = _this.input,
367
- selectionStart = _this$input5.selectionStart,
368
- selectionEnd = _this$input5.selectionEnd;
401
+ var _this$input6 = _this.input,
402
+ selectionStart = _this$input6.selectionStart,
403
+ selectionEnd = _this$input6.selectionEnd;
369
404
  if (selectionStart === selectionEnd && selectionStart === 0) {
370
405
  var _this$api5;
371
406
  event.preventDefault();
372
- var _this$view9 = _this.view,
373
- state = _this$view9.state,
374
- dispatch = _this$view9.dispatch;
407
+ var _this$view0 = _this.view,
408
+ state = _this$view0.state,
409
+ dispatch = _this$view0.dispatch;
375
410
  _this.view.focus();
376
411
  var selectionSharedState = ((_this$api5 = _this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.selection) === null || _this$api5 === void 0 ? void 0 : _this$api5.sharedState.currentState()) || {};
377
412
  // selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
@@ -396,17 +431,17 @@ export var ExpandNodeView = /*#__PURE__*/function () {
396
431
  }
397
432
  });
398
433
  _defineProperty(this, "handleUndoFromTitle", function (event) {
399
- var _this$view0 = _this.view,
400
- state = _this$view0.state,
401
- dispatch = _this$view0.dispatch;
434
+ var _this$view1 = _this.view,
435
+ state = _this$view1.state,
436
+ dispatch = _this$view1.dispatch;
402
437
  undo(state, dispatch);
403
438
  event.preventDefault();
404
439
  return;
405
440
  });
406
441
  _defineProperty(this, "handleRedoFromTitle", function (event) {
407
- var _this$view1 = _this.view,
408
- state = _this$view1.state,
409
- dispatch = _this$view1.dispatch;
442
+ var _this$view10 = _this.view,
443
+ state = _this$view10.state,
444
+ dispatch = _this$view10.dispatch;
410
445
  redo(state, dispatch);
411
446
  event.preventDefault();
412
447
  return;
@@ -25,6 +25,8 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
25
25
  state: state,
26
26
  key: pluginKey,
27
27
  props: {
28
+ // @ts-ignore - Workaround for help-center local consumption
29
+
28
30
  nodeViews: {
29
31
  expand: ExpandNodeView({
30
32
  getIntl: getIntl,
@@ -43,9 +45,11 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
43
45
  __livePage: __livePage
44
46
  })
45
47
  },
48
+ // @ts-ignore - Workaround for help-center local consumption
46
49
  handleKeyDown: function handleKeyDown(_view, event) {
47
50
  return containsClass(event.target, expandClassNames.titleContainer);
48
51
  },
52
+ // @ts-ignore - Workaround for help-center local consumption
49
53
  handleKeyPress: function handleKeyPress(_view, event) {
50
54
  return containsClass(event.target, expandClassNames.titleContainer);
51
55
  },
@@ -57,11 +61,13 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
57
61
  }, {
58
62
  useLongPressSelection: useLongPressSelection
59
63
  }),
64
+ // @ts-ignore - Workaround for help-center local consumption
60
65
  handleDrop: function handleDrop(view, event, slice, moved) {
61
66
  return handleExpandDrag(view, event, slice);
62
67
  }
63
68
  },
64
69
  // @see ED-8027 to follow up on this work-around
70
+ // @ts-ignore - Workaround for help-center local consumption
65
71
  filterTransaction: function filterTransaction(tr) {
66
72
  if (containsClass(document.activeElement, expandClassNames.titleInput) && tr.selectionSet && (!tr.steps.length || tr.isGeneric)) {
67
73
  return false;
@@ -99,6 +105,9 @@ export function handleExpandDrag(view, event, slice) {
99
105
  to = selection.to;
100
106
  var sliceContainsExpand = false;
101
107
  var sliceContainsNestedExpand = false;
108
+
109
+ // @ts-ignore - Workaround for help-center local consumption
110
+
102
111
  slice.content.forEach(function (node) {
103
112
  if (node.type === state.schema.nodes.expand) {
104
113
  sliceContainsExpand = true;
@@ -143,7 +143,11 @@ export var ExpandNodeView = /*#__PURE__*/function () {
143
143
  _this.handleArrowLeftFromTitle(event);
144
144
  break;
145
145
  case 'ArrowUp':
146
- _this.setLeftGapCursor(event);
146
+ if (expValEquals('platform_editor_lovability_navigation_fixes', 'isEnabled', true)) {
147
+ _this.moveToPreviousLine(event);
148
+ } else {
149
+ _this.setLeftGapCursor(event);
150
+ }
147
151
  break;
148
152
  case 'Backspace':
149
153
  _this.deleteEmptyExpand();
@@ -262,7 +266,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
262
266
  dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(_this.node.nodeSize + pos), Side.RIGHT)));
263
267
  }
264
268
  });
265
- _defineProperty(this, "setLeftGapCursor", function (event) {
269
+ _defineProperty(this, "moveToPreviousLine", function (event) {
266
270
  if (!_this.input) {
267
271
  return;
268
272
  }
@@ -278,12 +282,23 @@ export var ExpandNodeView = /*#__PURE__*/function () {
278
282
  var _this$view6 = _this.view,
279
283
  state = _this$view6.state,
280
284
  dispatch = _this$view6.dispatch;
281
- _this.view.focus();
282
- dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(pos), Side.LEFT)));
285
+ var resolvedPos = state.doc.resolve(pos);
286
+ if (!resolvedPos) {
287
+ return;
288
+ }
289
+ if (resolvedPos.pos === 0) {
290
+ _this.setLeftGapCursor(event);
291
+ return;
292
+ }
293
+ var sel = Selection.findFrom(resolvedPos, -1);
294
+ if (sel) {
295
+ _this.view.focus();
296
+ dispatch(state.tr.setSelection(sel));
297
+ }
283
298
  }
284
299
  });
285
- _defineProperty(this, "handleArrowRightFromTitle", function (event) {
286
- if (!_this.input || !_this.selectNearNode) {
300
+ _defineProperty(this, "setLeftGapCursor", function (event) {
301
+ if (!_this.input) {
287
302
  return;
288
303
  }
289
304
  var pos = _this.getPos();
@@ -291,15 +306,35 @@ export var ExpandNodeView = /*#__PURE__*/function () {
291
306
  return;
292
307
  }
293
308
  var _this$input4 = _this.input,
294
- value = _this$input4.value,
295
309
  selectionStart = _this$input4.selectionStart,
296
310
  selectionEnd = _this$input4.selectionEnd;
297
- if (selectionStart === selectionEnd && selectionStart === value.length) {
311
+ if (selectionStart === selectionEnd && selectionStart === 0) {
298
312
  event.preventDefault();
299
313
  var _this$view7 = _this.view,
300
314
  state = _this$view7.state,
301
315
  dispatch = _this$view7.dispatch;
302
316
  _this.view.focus();
317
+ dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(pos), Side.LEFT)));
318
+ }
319
+ });
320
+ _defineProperty(this, "handleArrowRightFromTitle", function (event) {
321
+ if (!_this.input || !_this.selectNearNode) {
322
+ return;
323
+ }
324
+ var pos = _this.getPos();
325
+ if (typeof pos !== 'number') {
326
+ return;
327
+ }
328
+ var _this$input5 = _this.input,
329
+ value = _this$input5.value,
330
+ selectionStart = _this$input5.selectionStart,
331
+ selectionEnd = _this$input5.selectionEnd;
332
+ if (selectionStart === selectionEnd && selectionStart === value.length) {
333
+ event.preventDefault();
334
+ var _this$view8 = _this.view,
335
+ state = _this$view8.state,
336
+ dispatch = _this$view8.dispatch;
337
+ _this.view.focus();
303
338
  var tr = _this.selectNearNode({
304
339
  selectionRelativeToNode: RelativeSelectionPos.End,
305
340
  selection: NodeSelection.create(state.doc, pos)
@@ -317,15 +352,15 @@ export var ExpandNodeView = /*#__PURE__*/function () {
317
352
  if (typeof pos !== 'number') {
318
353
  return;
319
354
  }
320
- var _this$input5 = _this.input,
321
- selectionStart = _this$input5.selectionStart,
322
- selectionEnd = _this$input5.selectionEnd;
355
+ var _this$input6 = _this.input,
356
+ selectionStart = _this$input6.selectionStart,
357
+ selectionEnd = _this$input6.selectionEnd;
323
358
  if (selectionStart === selectionEnd && selectionStart === 0) {
324
359
  var _this$api5;
325
360
  event.preventDefault();
326
- var _this$view8 = _this.view,
327
- state = _this$view8.state,
328
- dispatch = _this$view8.dispatch;
361
+ var _this$view9 = _this.view,
362
+ state = _this$view9.state,
363
+ dispatch = _this$view9.dispatch;
329
364
  _this.view.focus();
330
365
  var selectionSharedState = ((_this$api5 = _this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.selection) === null || _this$api5 === void 0 ? void 0 : _this$api5.sharedState.currentState()) || {};
331
366
  // selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
@@ -350,17 +385,17 @@ export var ExpandNodeView = /*#__PURE__*/function () {
350
385
  }
351
386
  });
352
387
  _defineProperty(this, "handleUndoFromTitle", function (event) {
353
- var _this$view9 = _this.view,
354
- state = _this$view9.state,
355
- dispatch = _this$view9.dispatch;
388
+ var _this$view0 = _this.view,
389
+ state = _this$view0.state,
390
+ dispatch = _this$view0.dispatch;
356
391
  undo(state, dispatch);
357
392
  event.preventDefault();
358
393
  return;
359
394
  });
360
395
  _defineProperty(this, "handleRedoFromTitle", function (event) {
361
- var _this$view0 = _this.view,
362
- state = _this$view0.state,
363
- dispatch = _this$view0.dispatch;
396
+ var _this$view1 = _this.view,
397
+ state = _this$view1.state,
398
+ dispatch = _this$view1.dispatch;
364
399
  redo(state, dispatch);
365
400
  event.preventDefault();
366
401
  return;
@@ -22,6 +22,8 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
22
22
  return new SafePlugin({
23
23
  key: pluginKey,
24
24
  props: {
25
+ // @ts-ignore - Workaround for help-center local consumption
26
+
25
27
  nodeViews: {
26
28
  expand: ExpandNodeView({
27
29
  getIntl: getIntl,
@@ -40,9 +42,11 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
40
42
  __livePage: __livePage
41
43
  })
42
44
  },
45
+ // @ts-ignore - Workaround for help-center local consumption
43
46
  handleKeyDown: function handleKeyDown(_view, event) {
44
47
  return containsClass(event.target, expandClassNames.titleContainer);
45
48
  },
49
+ // @ts-ignore - Workaround for help-center local consumption
46
50
  handleKeyPress: function handleKeyPress(_view, event) {
47
51
  return containsClass(event.target, expandClassNames.titleContainer);
48
52
  },
@@ -54,11 +58,13 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
54
58
  }, {
55
59
  useLongPressSelection: useLongPressSelection
56
60
  }),
61
+ // @ts-ignore - Workaround for help-center local consumption
57
62
  handleDrop: function handleDrop(view, event, slice, moved) {
58
63
  return handleExpandDrag(view, event, slice);
59
64
  }
60
65
  },
61
66
  // @see ED-8027 to follow up on this work-around
67
+ // @ts-ignore - Workaround for help-center local consumption
62
68
  filterTransaction: function filterTransaction(tr) {
63
69
  if (containsClass(document.activeElement, expandClassNames.titleInput) && tr.selectionSet && (!tr.steps.length || tr.isGeneric)) {
64
70
  return false;
@@ -80,6 +86,9 @@ export function handleExpandDrag(view, event, slice) {
80
86
  to = selection.to;
81
87
  var sliceContainsExpand = false;
82
88
  var sliceContainsNestedExpand = false;
89
+
90
+ // @ts-ignore - Workaround for help-center local consumption
91
+
83
92
  slice.content.forEach(function (node) {
84
93
  if (node.type === state.schema.nodes.expand) {
85
94
  sliceContainsExpand = true;
@@ -42,6 +42,7 @@ export declare class ExpandNodeView implements NodeView {
42
42
  private moveToOutsideOfTitle;
43
43
  private isCollapsed;
44
44
  private setRightGapCursor;
45
+ private moveToPreviousLine;
45
46
  private setLeftGapCursor;
46
47
  private handleArrowRightFromTitle;
47
48
  private handleArrowLeftFromTitle;
@@ -40,6 +40,7 @@ export declare class ExpandNodeView implements NodeView {
40
40
  private moveToOutsideOfTitle;
41
41
  private isCollapsed;
42
42
  private setRightGapCursor;
43
+ private moveToPreviousLine;
43
44
  private setLeftGapCursor;
44
45
  private handleArrowRightFromTitle;
45
46
  private handleArrowLeftFromTitle;
@@ -42,6 +42,7 @@ export declare class ExpandNodeView implements NodeView {
42
42
  private moveToOutsideOfTitle;
43
43
  private isCollapsed;
44
44
  private setRightGapCursor;
45
+ private moveToPreviousLine;
45
46
  private setLeftGapCursor;
46
47
  private handleArrowRightFromTitle;
47
48
  private handleArrowLeftFromTitle;
@@ -40,6 +40,7 @@ export declare class ExpandNodeView implements NodeView {
40
40
  private moveToOutsideOfTitle;
41
41
  private isCollapsed;
42
42
  private setRightGapCursor;
43
+ private moveToPreviousLine;
43
44
  private setLeftGapCursor;
44
45
  private handleArrowRightFromTitle;
45
46
  private handleArrowLeftFromTitle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-expand",
3
- "version": "7.4.4",
3
+ "version": "7.4.6",
4
4
  "description": "Expand plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -48,16 +48,16 @@
48
48
  "@atlaskit/icon-lab": "^5.12.0",
49
49
  "@atlaskit/platform-feature-flags": "^1.1.0",
50
50
  "@atlaskit/prosemirror-history": "^0.2.0",
51
- "@atlaskit/tmp-editor-statsig": "^13.38.0",
52
- "@atlaskit/tokens": "^8.0.0",
53
- "@atlaskit/tooltip": "^20.9.0",
51
+ "@atlaskit/tmp-editor-statsig": "^13.42.0",
52
+ "@atlaskit/tokens": "^8.3.0",
53
+ "@atlaskit/tooltip": "^20.10.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@emotion/react": "^11.7.1",
56
56
  "uuid": "^3.1.0",
57
57
  "w3c-keyname": "^2.1.8"
58
58
  },
59
59
  "peerDependencies": {
60
- "@atlaskit/editor-common": "^110.32.0",
60
+ "@atlaskit/editor-common": "^110.34.0",
61
61
  "react": "^18.2.0",
62
62
  "react-dom": "^18.2.0",
63
63
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -67,7 +67,7 @@
67
67
  "@atlaskit/editor-plugin-content-insertion": "^6.0.0",
68
68
  "@atlaskit/editor-plugin-guideline": "^6.0.0",
69
69
  "@atlaskit/editor-plugin-quick-insert": "^6.0.0",
70
- "@atlaskit/editor-plugin-table": "^15.3.0",
70
+ "@atlaskit/editor-plugin-table": "^15.4.0",
71
71
  "@atlaskit/editor-plugin-type-ahead": "^6.5.0",
72
72
  "@atlaskit/editor-plugin-width": "^7.0.0",
73
73
  "@testing-library/react": "^13.4.0",