@atlaskit/editor-plugin-type-ahead 2.7.4 → 2.7.5

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,15 @@
1
1
  # @atlaskit/editor-plugin-type-ahead
2
2
 
3
+ ## 2.7.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#154311](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/154311)
8
+ [`a9aff3b749e22`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a9aff3b749e22) -
9
+ [ux] EDITOR-730 Fix bug with typeaheads and legacy content extension that resulted in typeahead
10
+ text remaining in the inserted element
11
+ - Updated dependencies
12
+
3
13
  ## 2.7.4
4
14
 
5
15
  ### Patch Changes
@@ -242,34 +242,21 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
242
242
  // Handles cases like emoji (:) and mention (@) typeaheads that open new typeaheads
243
243
  var isTextSelected = ((_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.type) === 'Range';
244
244
  if ((0, _platformFeatureFlags.fg)('platform_editor_legacy_content_macro_typeahead_fix')) {
245
- var _window$getSelection2;
246
- // Check if new focus point is inside the current editor. If it is not we
247
- // want to close the typeahead popup regardless of text selection state
248
- var currentFocus = (_window$getSelection2 = window.getSelection()) === null || _window$getSelection2 === void 0 ? void 0 : _window$getSelection2.focusNode; // the focusNode is either TextNode, ElementNode
249
- // if currentFocus is not HTMLElement, take its parent node as focusNode
250
- var focusNode = currentFocus instanceof HTMLElement ? currentFocus : currentFocus === null || currentFocus === void 0 ? void 0 : currentFocus.parentNode;
251
- if (focusNode instanceof HTMLElement) {
252
- var innerEditor = focusNode.closest('.extension-editable-area');
253
- if (innerEditor) {
254
- // When there is no related target, we default to not closing the popup
255
- var newFocusInsideCurrentEditor = !relatedTarget;
256
- if (relatedTarget instanceof HTMLElement) {
257
- if (innerEditor) {
258
- // check if the new focus is inside inner editor, keep popup opens
259
- newFocusInsideCurrentEditor = innerEditor.contains(relatedTarget);
260
- } else {
261
- // if the new focus contains current focus node, the popup won't close
262
- newFocusInsideCurrentEditor = relatedTarget.contains(focusNode);
263
- }
264
- }
265
- if (!isTextSelected && newFocusInsideCurrentEditor) {
266
- return;
267
- }
268
- } else {
269
- // if the current focus in outer editor, keep the existing behaviour, do not close the pop up if text is not selected
270
- if (!isTextSelected) {
271
- return;
272
- }
245
+ var innerEditor = anchorElement.closest('.extension-editable-area');
246
+ if (innerEditor) {
247
+ // When there is no related target, we default to not closing the popup
248
+ var newFocusInsideCurrentEditor = !relatedTarget;
249
+ if (relatedTarget instanceof HTMLElement) {
250
+ // check if the new focus is inside inner editor, keep popup opens
251
+ newFocusInsideCurrentEditor = innerEditor.contains(relatedTarget);
252
+ }
253
+ if (!isTextSelected && newFocusInsideCurrentEditor) {
254
+ return;
255
+ }
256
+ } else {
257
+ // if the current focus in outer editor, keep the existing behaviour, do not close the pop up if text is not selected
258
+ if (!isTextSelected) {
259
+ return;
273
260
  }
274
261
  }
275
262
  } else {
@@ -292,7 +279,7 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
292
279
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
293
280
  element === null || element === void 0 || element.removeEventListener('focusout', focusOut);
294
281
  };
295
- }, [ref, cancel, editorView.state, isEditorControlsPatch2Enabled]);
282
+ }, [ref, cancel, editorView.state, isEditorControlsPatch2Enabled, anchorElement]);
296
283
 
297
284
  // TODO: ED-17443 - When you press escape on typeahead panel, it should remove focus and close the panel
298
285
  // This is the expected keyboard behaviour advised by the Accessibility team
@@ -205,34 +205,21 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
205
205
  // Handles cases like emoji and @ typeaheads that open new typeaheads
206
206
  var isTextSelected = ((_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.type) === 'Range';
207
207
  if ((0, _platformFeatureFlags.fg)('platform_editor_legacy_content_macro_typeahead_fix')) {
208
- var _window$getSelection2;
209
- // Check if new focus point is inside the current editor. If it is not we
210
- // want to close the typeahead popup regardless of text selection state
211
- var currentFocus = (_window$getSelection2 = window.getSelection()) === null || _window$getSelection2 === void 0 ? void 0 : _window$getSelection2.focusNode; // the focusNode is either TextNode, ElementNode
212
- // if currentFocus is not HTMLElement, take its parent node as focusNode
213
- var focusNode = currentFocus instanceof HTMLElement ? currentFocus : currentFocus === null || currentFocus === void 0 ? void 0 : currentFocus.parentNode;
214
- if (focusNode instanceof HTMLElement) {
215
- var innerEditor = focusNode.closest('.extension-editable-area');
216
- if (innerEditor) {
217
- // When there is no related target, we default to not closing the popup
218
- var newFocusInsideCurrentEditor = !relatedTarget;
219
- if (relatedTarget instanceof HTMLElement) {
220
- if (innerEditor) {
221
- // check if the new focus is inside inner editor, keep popup opens
222
- newFocusInsideCurrentEditor = innerEditor.contains(relatedTarget);
223
- } else {
224
- // if the new focus contains current focus node, the popup won't close
225
- newFocusInsideCurrentEditor = relatedTarget.contains(focusNode);
226
- }
227
- }
228
- if (!isTextSelected && newFocusInsideCurrentEditor) {
229
- return;
230
- }
231
- } else {
232
- // if the current focus in outer editor, keep the existing behaviour, do not close the pop up if text is not selected
233
- if (!isTextSelected) {
234
- return;
235
- }
208
+ var innerEditor = anchorElement.closest('.extension-editable-area');
209
+ if (innerEditor) {
210
+ // When there is no related target, we default to not closing the popup
211
+ var newFocusInsideCurrentEditor = !relatedTarget;
212
+ if (relatedTarget instanceof HTMLElement) {
213
+ // check if the new focus is inside inner editor, keep popup opens
214
+ newFocusInsideCurrentEditor = innerEditor.contains(relatedTarget);
215
+ }
216
+ if (!isTextSelected && newFocusInsideCurrentEditor) {
217
+ return;
218
+ }
219
+ } else {
220
+ // if the current focus in outer editor, keep the existing behaviour, do not close the pop up if text is not selected
221
+ if (!isTextSelected) {
222
+ return;
236
223
  }
237
224
  }
238
225
  } else {
@@ -255,7 +242,7 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
255
242
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
256
243
  element === null || element === void 0 || element.removeEventListener('focusout', focusOut);
257
244
  };
258
- }, [ref, cancel]);
245
+ }, [ref, cancel, anchorElement]);
259
246
 
260
247
  // TODO: ED-17443 - When you press escape on typeahead panel, it should remove focus and close the panel
261
248
  // This is the expected keyboard behaviour advised by the Accessibility team
@@ -233,34 +233,21 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
233
233
  // Handles cases like emoji (:) and mention (@) typeaheads that open new typeaheads
234
234
  const isTextSelected = ((_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.type) === 'Range';
235
235
  if (fg('platform_editor_legacy_content_macro_typeahead_fix')) {
236
- var _window$getSelection2;
237
- // Check if new focus point is inside the current editor. If it is not we
238
- // want to close the typeahead popup regardless of text selection state
239
- const currentFocus = (_window$getSelection2 = window.getSelection()) === null || _window$getSelection2 === void 0 ? void 0 : _window$getSelection2.focusNode; // the focusNode is either TextNode, ElementNode
240
- // if currentFocus is not HTMLElement, take its parent node as focusNode
241
- const focusNode = currentFocus instanceof HTMLElement ? currentFocus : currentFocus === null || currentFocus === void 0 ? void 0 : currentFocus.parentNode;
242
- if (focusNode instanceof HTMLElement) {
243
- const innerEditor = focusNode.closest('.extension-editable-area');
244
- if (innerEditor) {
245
- // When there is no related target, we default to not closing the popup
246
- let newFocusInsideCurrentEditor = !relatedTarget;
247
- if (relatedTarget instanceof HTMLElement) {
248
- if (innerEditor) {
249
- // check if the new focus is inside inner editor, keep popup opens
250
- newFocusInsideCurrentEditor = innerEditor.contains(relatedTarget);
251
- } else {
252
- // if the new focus contains current focus node, the popup won't close
253
- newFocusInsideCurrentEditor = relatedTarget.contains(focusNode);
254
- }
255
- }
256
- if (!isTextSelected && newFocusInsideCurrentEditor) {
257
- return;
258
- }
259
- } else {
260
- // if the current focus in outer editor, keep the existing behaviour, do not close the pop up if text is not selected
261
- if (!isTextSelected) {
262
- return;
263
- }
236
+ const innerEditor = anchorElement.closest('.extension-editable-area');
237
+ if (innerEditor) {
238
+ // When there is no related target, we default to not closing the popup
239
+ let newFocusInsideCurrentEditor = !relatedTarget;
240
+ if (relatedTarget instanceof HTMLElement) {
241
+ // check if the new focus is inside inner editor, keep popup opens
242
+ newFocusInsideCurrentEditor = innerEditor.contains(relatedTarget);
243
+ }
244
+ if (!isTextSelected && newFocusInsideCurrentEditor) {
245
+ return;
246
+ }
247
+ } else {
248
+ // if the current focus in outer editor, keep the existing behaviour, do not close the pop up if text is not selected
249
+ if (!isTextSelected) {
250
+ return;
264
251
  }
265
252
  }
266
253
  } else {
@@ -285,7 +272,7 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
285
272
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
286
273
  element === null || element === void 0 ? void 0 : element.removeEventListener('focusout', focusOut);
287
274
  };
288
- }, [ref, cancel, editorView.state, isEditorControlsPatch2Enabled]);
275
+ }, [ref, cancel, editorView.state, isEditorControlsPatch2Enabled, anchorElement]);
289
276
 
290
277
  // TODO: ED-17443 - When you press escape on typeahead panel, it should remove focus and close the panel
291
278
  // This is the expected keyboard behaviour advised by the Accessibility team
@@ -196,34 +196,21 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
196
196
  // Handles cases like emoji and @ typeaheads that open new typeaheads
197
197
  const isTextSelected = ((_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.type) === 'Range';
198
198
  if (fg('platform_editor_legacy_content_macro_typeahead_fix')) {
199
- var _window$getSelection2;
200
- // Check if new focus point is inside the current editor. If it is not we
201
- // want to close the typeahead popup regardless of text selection state
202
- const currentFocus = (_window$getSelection2 = window.getSelection()) === null || _window$getSelection2 === void 0 ? void 0 : _window$getSelection2.focusNode; // the focusNode is either TextNode, ElementNode
203
- // if currentFocus is not HTMLElement, take its parent node as focusNode
204
- const focusNode = currentFocus instanceof HTMLElement ? currentFocus : currentFocus === null || currentFocus === void 0 ? void 0 : currentFocus.parentNode;
205
- if (focusNode instanceof HTMLElement) {
206
- const innerEditor = focusNode.closest('.extension-editable-area');
207
- if (innerEditor) {
208
- // When there is no related target, we default to not closing the popup
209
- let newFocusInsideCurrentEditor = !relatedTarget;
210
- if (relatedTarget instanceof HTMLElement) {
211
- if (innerEditor) {
212
- // check if the new focus is inside inner editor, keep popup opens
213
- newFocusInsideCurrentEditor = innerEditor.contains(relatedTarget);
214
- } else {
215
- // if the new focus contains current focus node, the popup won't close
216
- newFocusInsideCurrentEditor = relatedTarget.contains(focusNode);
217
- }
218
- }
219
- if (!isTextSelected && newFocusInsideCurrentEditor) {
220
- return;
221
- }
222
- } else {
223
- // if the current focus in outer editor, keep the existing behaviour, do not close the pop up if text is not selected
224
- if (!isTextSelected) {
225
- return;
226
- }
199
+ const innerEditor = anchorElement.closest('.extension-editable-area');
200
+ if (innerEditor) {
201
+ // When there is no related target, we default to not closing the popup
202
+ let newFocusInsideCurrentEditor = !relatedTarget;
203
+ if (relatedTarget instanceof HTMLElement) {
204
+ // check if the new focus is inside inner editor, keep popup opens
205
+ newFocusInsideCurrentEditor = innerEditor.contains(relatedTarget);
206
+ }
207
+ if (!isTextSelected && newFocusInsideCurrentEditor) {
208
+ return;
209
+ }
210
+ } else {
211
+ // if the current focus in outer editor, keep the existing behaviour, do not close the pop up if text is not selected
212
+ if (!isTextSelected) {
213
+ return;
227
214
  }
228
215
  }
229
216
  } else {
@@ -248,7 +235,7 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
248
235
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
249
236
  element === null || element === void 0 ? void 0 : element.removeEventListener('focusout', focusOut);
250
237
  };
251
- }, [ref, cancel]);
238
+ }, [ref, cancel, anchorElement]);
252
239
 
253
240
  // TODO: ED-17443 - When you press escape on typeahead panel, it should remove focus and close the panel
254
241
  // This is the expected keyboard behaviour advised by the Accessibility team
@@ -231,34 +231,21 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
231
231
  // Handles cases like emoji (:) and mention (@) typeaheads that open new typeaheads
232
232
  var isTextSelected = ((_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.type) === 'Range';
233
233
  if (fg('platform_editor_legacy_content_macro_typeahead_fix')) {
234
- var _window$getSelection2;
235
- // Check if new focus point is inside the current editor. If it is not we
236
- // want to close the typeahead popup regardless of text selection state
237
- var currentFocus = (_window$getSelection2 = window.getSelection()) === null || _window$getSelection2 === void 0 ? void 0 : _window$getSelection2.focusNode; // the focusNode is either TextNode, ElementNode
238
- // if currentFocus is not HTMLElement, take its parent node as focusNode
239
- var focusNode = currentFocus instanceof HTMLElement ? currentFocus : currentFocus === null || currentFocus === void 0 ? void 0 : currentFocus.parentNode;
240
- if (focusNode instanceof HTMLElement) {
241
- var innerEditor = focusNode.closest('.extension-editable-area');
242
- if (innerEditor) {
243
- // When there is no related target, we default to not closing the popup
244
- var newFocusInsideCurrentEditor = !relatedTarget;
245
- if (relatedTarget instanceof HTMLElement) {
246
- if (innerEditor) {
247
- // check if the new focus is inside inner editor, keep popup opens
248
- newFocusInsideCurrentEditor = innerEditor.contains(relatedTarget);
249
- } else {
250
- // if the new focus contains current focus node, the popup won't close
251
- newFocusInsideCurrentEditor = relatedTarget.contains(focusNode);
252
- }
253
- }
254
- if (!isTextSelected && newFocusInsideCurrentEditor) {
255
- return;
256
- }
257
- } else {
258
- // if the current focus in outer editor, keep the existing behaviour, do not close the pop up if text is not selected
259
- if (!isTextSelected) {
260
- return;
261
- }
234
+ var innerEditor = anchorElement.closest('.extension-editable-area');
235
+ if (innerEditor) {
236
+ // When there is no related target, we default to not closing the popup
237
+ var newFocusInsideCurrentEditor = !relatedTarget;
238
+ if (relatedTarget instanceof HTMLElement) {
239
+ // check if the new focus is inside inner editor, keep popup opens
240
+ newFocusInsideCurrentEditor = innerEditor.contains(relatedTarget);
241
+ }
242
+ if (!isTextSelected && newFocusInsideCurrentEditor) {
243
+ return;
244
+ }
245
+ } else {
246
+ // if the current focus in outer editor, keep the existing behaviour, do not close the pop up if text is not selected
247
+ if (!isTextSelected) {
248
+ return;
262
249
  }
263
250
  }
264
251
  } else {
@@ -281,7 +268,7 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
281
268
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
282
269
  element === null || element === void 0 || element.removeEventListener('focusout', focusOut);
283
270
  };
284
- }, [ref, cancel, editorView.state, isEditorControlsPatch2Enabled]);
271
+ }, [ref, cancel, editorView.state, isEditorControlsPatch2Enabled, anchorElement]);
285
272
 
286
273
  // TODO: ED-17443 - When you press escape on typeahead panel, it should remove focus and close the panel
287
274
  // This is the expected keyboard behaviour advised by the Accessibility team
@@ -195,34 +195,21 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
195
195
  // Handles cases like emoji and @ typeaheads that open new typeaheads
196
196
  var isTextSelected = ((_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.type) === 'Range';
197
197
  if (fg('platform_editor_legacy_content_macro_typeahead_fix')) {
198
- var _window$getSelection2;
199
- // Check if new focus point is inside the current editor. If it is not we
200
- // want to close the typeahead popup regardless of text selection state
201
- var currentFocus = (_window$getSelection2 = window.getSelection()) === null || _window$getSelection2 === void 0 ? void 0 : _window$getSelection2.focusNode; // the focusNode is either TextNode, ElementNode
202
- // if currentFocus is not HTMLElement, take its parent node as focusNode
203
- var focusNode = currentFocus instanceof HTMLElement ? currentFocus : currentFocus === null || currentFocus === void 0 ? void 0 : currentFocus.parentNode;
204
- if (focusNode instanceof HTMLElement) {
205
- var innerEditor = focusNode.closest('.extension-editable-area');
206
- if (innerEditor) {
207
- // When there is no related target, we default to not closing the popup
208
- var newFocusInsideCurrentEditor = !relatedTarget;
209
- if (relatedTarget instanceof HTMLElement) {
210
- if (innerEditor) {
211
- // check if the new focus is inside inner editor, keep popup opens
212
- newFocusInsideCurrentEditor = innerEditor.contains(relatedTarget);
213
- } else {
214
- // if the new focus contains current focus node, the popup won't close
215
- newFocusInsideCurrentEditor = relatedTarget.contains(focusNode);
216
- }
217
- }
218
- if (!isTextSelected && newFocusInsideCurrentEditor) {
219
- return;
220
- }
221
- } else {
222
- // if the current focus in outer editor, keep the existing behaviour, do not close the pop up if text is not selected
223
- if (!isTextSelected) {
224
- return;
225
- }
198
+ var innerEditor = anchorElement.closest('.extension-editable-area');
199
+ if (innerEditor) {
200
+ // When there is no related target, we default to not closing the popup
201
+ var newFocusInsideCurrentEditor = !relatedTarget;
202
+ if (relatedTarget instanceof HTMLElement) {
203
+ // check if the new focus is inside inner editor, keep popup opens
204
+ newFocusInsideCurrentEditor = innerEditor.contains(relatedTarget);
205
+ }
206
+ if (!isTextSelected && newFocusInsideCurrentEditor) {
207
+ return;
208
+ }
209
+ } else {
210
+ // if the current focus in outer editor, keep the existing behaviour, do not close the pop up if text is not selected
211
+ if (!isTextSelected) {
212
+ return;
226
213
  }
227
214
  }
228
215
  } else {
@@ -245,7 +232,7 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
245
232
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
246
233
  element === null || element === void 0 || element.removeEventListener('focusout', focusOut);
247
234
  };
248
- }, [ref, cancel]);
235
+ }, [ref, cancel, anchorElement]);
249
236
 
250
237
  // TODO: ED-17443 - When you press escape on typeahead panel, it should remove focus and close the panel
251
238
  // This is the expected keyboard behaviour advised by the Accessibility team
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "2.7.4",
3
+ "version": "2.7.5",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^47.6.0",
37
- "@atlaskit/editor-common": "^105.5.0",
37
+ "@atlaskit/editor-common": "^105.6.0",
38
38
  "@atlaskit/editor-element-browser": "^0.1.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^2.3.0",
40
40
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
@@ -43,14 +43,14 @@
43
43
  "@atlaskit/editor-prosemirror": "7.0.0",
44
44
  "@atlaskit/editor-shared-styles": "^3.4.0",
45
45
  "@atlaskit/heading": "^5.2.0",
46
- "@atlaskit/icon": "^26.0.0",
46
+ "@atlaskit/icon": "^26.1.0",
47
47
  "@atlaskit/menu": "^7.0.0",
48
48
  "@atlaskit/platform-feature-flags": "^1.1.0",
49
49
  "@atlaskit/primitives": "^14.7.0",
50
50
  "@atlaskit/prosemirror-input-rules": "^3.3.0",
51
51
  "@atlaskit/theme": "^18.0.0",
52
52
  "@atlaskit/tmp-editor-statsig": "^4.22.0",
53
- "@atlaskit/tokens": "^4.8.0",
53
+ "@atlaskit/tokens": "^4.9.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@emotion/react": "^11.7.1",
56
56
  "lodash": "^4.17.21",