@atlaskit/editor-plugin-type-ahead 2.7.13 → 2.7.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-type-ahead
2
2
 
3
+ ## 2.7.15
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 2.7.14
10
+
11
+ ### Patch Changes
12
+
13
+ - [#169326](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/169326)
14
+ [`f93af5ddb6981`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f93af5ddb6981) -
15
+ [ED-28214] Fix a bug where in quick insert, editor loses focus and query disappears after pressing
16
+ space when there's no matching result
17
+
3
18
  ## 2.7.13
4
19
 
5
20
  ### Patch Changes
@@ -6,11 +6,16 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useItemInsert = void 0;
7
7
  var _react = require("react");
8
8
  var _typeAhead = require("@atlaskit/editor-common/type-ahead");
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
10
  var _closeTypeAhead = require("../../pm-plugins/commands/close-type-ahead");
10
11
  var _insertTypeAheadItem = require("../../pm-plugins/commands/insert-type-ahead-item");
11
12
  var _setSelectionBeforeQuery = require("../../pm-plugins/commands/set-selection-before-query");
12
13
  var _constants = require("../../pm-plugins/constants");
13
14
  var _itemIsDisabled = require("../../pm-plugins/item-is-disabled");
15
+ var onlyHasViewMoreItem = function onlyHasViewMoreItem(items) {
16
+ var _items$at;
17
+ return ((_items$at = items.at(0)) === null || _items$at === void 0 ? void 0 : _items$at.title) === 'View more';
18
+ };
14
19
  var insertRawQuery = function insertRawQuery(_ref) {
15
20
  var view = _ref.view,
16
21
  setSelectionAt = _ref.setSelectionAt,
@@ -54,7 +59,9 @@ var useItemInsert = exports.useItemInsert = function useItemInsert(triggerHandle
54
59
  index = _ref3.index,
55
60
  query = _ref3.query;
56
61
  var sourceListItem = itemsRef.current;
57
- if (sourceListItem.length === 0 || !triggerHandler) {
62
+ if (sourceListItem.length === 0 || !triggerHandler ||
63
+ // View more item is only added for keyboard navigation and should not be considered as a valid item to be inserted
64
+ onlyHasViewMoreItem(sourceListItem) && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_13')) {
58
65
  var text = "".concat(triggerHandler.trigger).concat(query);
59
66
  onTextInsert({
60
67
  forceFocusOnEditor: true,
@@ -87,7 +94,9 @@ var useItemInsert = exports.useItemInsert = function useItemInsert(triggerHandle
87
94
  if (_items && _items.length > 1) {
88
95
  return false;
89
96
  }
90
- if (_items.length === 1) {
97
+ if (_items.length === 1 && (
98
+ // View more item is only added for keyboard navigation and should not be considered as a valid item to be inserted
99
+ !onlyHasViewMoreItem(_items) || !(0, _platformFeatureFlags.fg)('platform_editor_controls_patch_13'))) {
91
100
  queueMicrotask(function () {
92
101
  onItemInsert({
93
102
  mode: mode,
@@ -34,6 +34,8 @@ var useLoadItems = exports.useLoadItems = function useLoadItems(triggerHandler,
34
34
  if (componentIsMounted.current) {
35
35
  setItems(list);
36
36
  }
37
+
38
+ // Add a placeholder item for view more button so that it can be traversed with arrow keys
37
39
  var viewMoreItem = {
38
40
  title: 'View more'
39
41
  };
@@ -1,10 +1,15 @@
1
1
  import { useCallback, useLayoutEffect, useRef } from 'react';
2
2
  import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { closeTypeAhead } from '../../pm-plugins/commands/close-type-ahead';
4
5
  import { insertTypeAheadItem } from '../../pm-plugins/commands/insert-type-ahead-item';
5
6
  import { setSelectionBeforeQuery } from '../../pm-plugins/commands/set-selection-before-query';
6
7
  import { CloseSelectionOptions } from '../../pm-plugins/constants';
7
8
  import { itemIsDisabled } from '../../pm-plugins/item-is-disabled';
9
+ const onlyHasViewMoreItem = items => {
10
+ var _items$at;
11
+ return ((_items$at = items.at(0)) === null || _items$at === void 0 ? void 0 : _items$at.title) === 'View more';
12
+ };
8
13
  const insertRawQuery = ({
9
14
  view,
10
15
  setSelectionAt,
@@ -54,7 +59,9 @@ export const useItemInsert = (triggerHandler, editorView, items, api) => {
54
59
  query
55
60
  }) => {
56
61
  const sourceListItem = itemsRef.current;
57
- if (sourceListItem.length === 0 || !triggerHandler) {
62
+ if (sourceListItem.length === 0 || !triggerHandler ||
63
+ // View more item is only added for keyboard navigation and should not be considered as a valid item to be inserted
64
+ onlyHasViewMoreItem(sourceListItem) && fg('platform_editor_controls_patch_13')) {
58
65
  const text = `${triggerHandler.trigger}${query}`;
59
66
  onTextInsert({
60
67
  forceFocusOnEditor: true,
@@ -90,7 +97,9 @@ export const useItemInsert = (triggerHandler, editorView, items, api) => {
90
97
  if (_items && _items.length > 1) {
91
98
  return false;
92
99
  }
93
- if (_items.length === 1) {
100
+ if (_items.length === 1 && (
101
+ // View more item is only added for keyboard navigation and should not be considered as a valid item to be inserted
102
+ !onlyHasViewMoreItem(_items) || !fg('platform_editor_controls_patch_13'))) {
94
103
  queueMicrotask(() => {
95
104
  onItemInsert({
96
105
  mode,
@@ -25,6 +25,8 @@ export const useLoadItems = (triggerHandler, editorView, query, showViewMore) =>
25
25
  if (componentIsMounted.current) {
26
26
  setItems(list);
27
27
  }
28
+
29
+ // Add a placeholder item for view more button so that it can be traversed with arrow keys
28
30
  const viewMoreItem = {
29
31
  title: 'View more'
30
32
  };
@@ -1,10 +1,15 @@
1
1
  import { useCallback, useLayoutEffect, useRef } from 'react';
2
2
  import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { closeTypeAhead } from '../../pm-plugins/commands/close-type-ahead';
4
5
  import { insertTypeAheadItem } from '../../pm-plugins/commands/insert-type-ahead-item';
5
6
  import { setSelectionBeforeQuery } from '../../pm-plugins/commands/set-selection-before-query';
6
7
  import { CloseSelectionOptions } from '../../pm-plugins/constants';
7
8
  import { itemIsDisabled } from '../../pm-plugins/item-is-disabled';
9
+ var onlyHasViewMoreItem = function onlyHasViewMoreItem(items) {
10
+ var _items$at;
11
+ return ((_items$at = items.at(0)) === null || _items$at === void 0 ? void 0 : _items$at.title) === 'View more';
12
+ };
8
13
  var insertRawQuery = function insertRawQuery(_ref) {
9
14
  var view = _ref.view,
10
15
  setSelectionAt = _ref.setSelectionAt,
@@ -48,7 +53,9 @@ export var useItemInsert = function useItemInsert(triggerHandler, editorView, it
48
53
  index = _ref3.index,
49
54
  query = _ref3.query;
50
55
  var sourceListItem = itemsRef.current;
51
- if (sourceListItem.length === 0 || !triggerHandler) {
56
+ if (sourceListItem.length === 0 || !triggerHandler ||
57
+ // View more item is only added for keyboard navigation and should not be considered as a valid item to be inserted
58
+ onlyHasViewMoreItem(sourceListItem) && fg('platform_editor_controls_patch_13')) {
52
59
  var text = "".concat(triggerHandler.trigger).concat(query);
53
60
  onTextInsert({
54
61
  forceFocusOnEditor: true,
@@ -81,7 +88,9 @@ export var useItemInsert = function useItemInsert(triggerHandler, editorView, it
81
88
  if (_items && _items.length > 1) {
82
89
  return false;
83
90
  }
84
- if (_items.length === 1) {
91
+ if (_items.length === 1 && (
92
+ // View more item is only added for keyboard navigation and should not be considered as a valid item to be inserted
93
+ !onlyHasViewMoreItem(_items) || !fg('platform_editor_controls_patch_13'))) {
85
94
  queueMicrotask(function () {
86
95
  onItemInsert({
87
96
  mode: mode,
@@ -27,6 +27,8 @@ export var useLoadItems = function useLoadItems(triggerHandler, editorView, quer
27
27
  if (componentIsMounted.current) {
28
28
  setItems(list);
29
29
  }
30
+
31
+ // Add a placeholder item for view more button so that it can be traversed with arrow keys
30
32
  var viewMoreItem = {
31
33
  title: 'View more'
32
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "2.7.13",
3
+ "version": "2.7.15",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,12 +34,12 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^47.6.0",
37
- "@atlaskit/editor-common": "^106.5.0",
37
+ "@atlaskit/editor-common": "^106.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",
41
41
  "@atlaskit/editor-plugin-context-panel": "^4.1.0",
42
- "@atlaskit/editor-plugin-metrics": "^3.4.0",
42
+ "@atlaskit/editor-plugin-metrics": "^3.5.0",
43
43
  "@atlaskit/editor-prosemirror": "7.0.0",
44
44
  "@atlaskit/editor-shared-styles": "^3.4.0",
45
45
  "@atlaskit/heading": "^5.2.0",
@@ -49,7 +49,7 @@
49
49
  "@atlaskit/primitives": "^14.8.0",
50
50
  "@atlaskit/prosemirror-input-rules": "^3.3.0",
51
51
  "@atlaskit/theme": "^18.0.0",
52
- "@atlaskit/tmp-editor-statsig": "^6.0.0",
52
+ "@atlaskit/tmp-editor-statsig": "^7.0.0",
53
53
  "@atlaskit/tokens": "^5.1.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@emotion/react": "^11.7.1",
@@ -125,6 +125,9 @@
125
125
  },
126
126
  "platform_editor_controls_patch_12": {
127
127
  "type": "boolean"
128
+ },
129
+ "platform_editor_controls_patch_13": {
130
+ "type": "boolean"
128
131
  }
129
132
  }
130
133
  }