@atlaskit/editor-core 172.3.2 → 173.0.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.
Files changed (189) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/cjs/index.js +0 -6
  3. package/dist/cjs/plugins/base/index.js +8 -0
  4. package/dist/cjs/plugins/base/pm-plugins/composition.js +60 -0
  5. package/dist/cjs/plugins/breakout/index.js +5 -4
  6. package/dist/cjs/plugins/breakout/ui/LayoutButton.js +1 -3
  7. package/dist/cjs/plugins/card/pm-plugins/doc.js +8 -1
  8. package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +2 -36
  9. package/dist/cjs/plugins/collab-edit/plugin-state.js +16 -9
  10. package/dist/cjs/plugins/collab-edit/utils.js +16 -2
  11. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
  12. package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +20 -15
  13. package/dist/cjs/plugins/floating-toolbar/ui/DropdownMenu.js +8 -5
  14. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +3 -3
  15. package/dist/cjs/plugins/paste/actions.js +13 -0
  16. package/dist/cjs/plugins/paste/commands.js +44 -0
  17. package/dist/cjs/plugins/paste/handlers.js +48 -7
  18. package/dist/cjs/plugins/paste/index.js +3 -2
  19. package/dist/cjs/plugins/paste/pm-plugins/main.js +34 -9
  20. package/dist/cjs/plugins/paste/pm-plugins/plugin-factory.js +62 -0
  21. package/dist/cjs/plugins/paste/reducer.js +47 -0
  22. package/dist/cjs/plugins/paste/types.js +5 -0
  23. package/dist/cjs/plugins/placeholder/index.js +3 -1
  24. package/dist/cjs/plugins/placeholder-text/index.js +9 -3
  25. package/dist/cjs/plugins/status/ui/statusPicker.js +4 -1
  26. package/dist/cjs/plugins/table/commands-with-analytics.js +59 -52
  27. package/dist/cjs/plugins/table/index.js +53 -36
  28. package/dist/cjs/plugins/table/toolbar.js +136 -20
  29. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  30. package/dist/cjs/plugins/tasks-and-decisions/commands.js +1 -16
  31. package/dist/cjs/plugins/type-ahead/constants.js +3 -1
  32. package/dist/cjs/plugins/type-ahead/messages.js +16 -1
  33. package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +1 -1
  34. package/dist/cjs/plugins/type-ahead/pm-plugins/reducer.js +2 -2
  35. package/dist/cjs/plugins/type-ahead/ui/AssistiveText.js +143 -0
  36. package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +59 -11
  37. package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +156 -31
  38. package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +55 -29
  39. package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
  40. package/dist/cjs/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
  41. package/dist/cjs/plugins/type-ahead/utils.js +1 -1
  42. package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +8 -0
  43. package/dist/cjs/ui/PortalProvider/PortalProviderThemesProvider.js +2 -6
  44. package/dist/cjs/ui/PortalProvider/index.js +26 -32
  45. package/dist/cjs/utils/index.js +8 -1
  46. package/dist/cjs/version-wrapper.js +1 -1
  47. package/dist/cjs/version.json +1 -1
  48. package/dist/es2019/index.js +1 -1
  49. package/dist/es2019/plugins/base/index.js +5 -0
  50. package/dist/es2019/plugins/base/pm-plugins/composition.js +45 -0
  51. package/dist/es2019/plugins/breakout/index.js +5 -4
  52. package/dist/es2019/plugins/breakout/ui/LayoutButton.js +1 -3
  53. package/dist/es2019/plugins/card/pm-plugins/doc.js +10 -1
  54. package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +3 -40
  55. package/dist/es2019/plugins/collab-edit/plugin-state.js +9 -3
  56. package/dist/es2019/plugins/collab-edit/utils.js +17 -3
  57. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
  58. package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +15 -7
  59. package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +9 -5
  60. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +3 -3
  61. package/dist/es2019/plugins/paste/actions.js +6 -0
  62. package/dist/es2019/plugins/paste/commands.js +27 -0
  63. package/dist/es2019/plugins/paste/handlers.js +50 -8
  64. package/dist/es2019/plugins/paste/index.js +3 -2
  65. package/dist/es2019/plugins/paste/pm-plugins/main.js +29 -6
  66. package/dist/es2019/plugins/paste/pm-plugins/plugin-factory.js +33 -0
  67. package/dist/es2019/plugins/paste/reducer.js +24 -0
  68. package/dist/es2019/plugins/paste/types.js +1 -0
  69. package/dist/es2019/plugins/placeholder/index.js +2 -1
  70. package/dist/es2019/plugins/placeholder-text/index.js +13 -3
  71. package/dist/es2019/plugins/status/ui/statusPicker.js +5 -1
  72. package/dist/es2019/plugins/table/commands-with-analytics.js +6 -3
  73. package/dist/es2019/plugins/table/index.js +22 -4
  74. package/dist/es2019/plugins/table/toolbar.js +118 -14
  75. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  76. package/dist/es2019/plugins/tasks-and-decisions/commands.js +0 -9
  77. package/dist/es2019/plugins/type-ahead/constants.js +1 -0
  78. package/dist/es2019/plugins/type-ahead/messages.js +16 -1
  79. package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +1 -1
  80. package/dist/es2019/plugins/type-ahead/pm-plugins/reducer.js +2 -2
  81. package/dist/es2019/plugins/type-ahead/ui/AssistiveText.js +95 -0
  82. package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +49 -12
  83. package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +143 -29
  84. package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +64 -31
  85. package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
  86. package/dist/es2019/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
  87. package/dist/es2019/plugins/type-ahead/utils.js +1 -1
  88. package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +17 -0
  89. package/dist/es2019/ui/PortalProvider/PortalProviderThemesProvider.js +2 -5
  90. package/dist/es2019/ui/PortalProvider/index.js +5 -8
  91. package/dist/es2019/utils/index.js +6 -0
  92. package/dist/es2019/version-wrapper.js +1 -1
  93. package/dist/es2019/version.json +1 -1
  94. package/dist/esm/index.js +1 -1
  95. package/dist/esm/plugins/base/index.js +7 -0
  96. package/dist/esm/plugins/base/pm-plugins/composition.js +45 -0
  97. package/dist/esm/plugins/breakout/index.js +5 -4
  98. package/dist/esm/plugins/breakout/ui/LayoutButton.js +1 -3
  99. package/dist/esm/plugins/card/pm-plugins/doc.js +8 -1
  100. package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +3 -37
  101. package/dist/esm/plugins/collab-edit/plugin-state.js +9 -3
  102. package/dist/esm/plugins/collab-edit/utils.js +17 -3
  103. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
  104. package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +20 -15
  105. package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +8 -5
  106. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +3 -3
  107. package/dist/esm/plugins/paste/actions.js +6 -0
  108. package/dist/esm/plugins/paste/commands.js +31 -0
  109. package/dist/esm/plugins/paste/handlers.js +46 -8
  110. package/dist/esm/plugins/paste/index.js +3 -2
  111. package/dist/esm/plugins/paste/pm-plugins/main.js +27 -6
  112. package/dist/esm/plugins/paste/pm-plugins/plugin-factory.js +46 -0
  113. package/dist/esm/plugins/paste/reducer.js +34 -0
  114. package/dist/esm/plugins/paste/types.js +1 -0
  115. package/dist/esm/plugins/placeholder/index.js +2 -1
  116. package/dist/esm/plugins/placeholder-text/index.js +9 -3
  117. package/dist/esm/plugins/status/ui/statusPicker.js +4 -1
  118. package/dist/esm/plugins/table/commands-with-analytics.js +56 -49
  119. package/dist/esm/plugins/table/index.js +54 -37
  120. package/dist/esm/plugins/table/toolbar.js +124 -15
  121. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  122. package/dist/esm/plugins/tasks-and-decisions/commands.js +0 -12
  123. package/dist/esm/plugins/type-ahead/constants.js +1 -0
  124. package/dist/esm/plugins/type-ahead/messages.js +16 -1
  125. package/dist/esm/plugins/type-ahead/pm-plugins/main.js +1 -1
  126. package/dist/esm/plugins/type-ahead/pm-plugins/reducer.js +2 -2
  127. package/dist/esm/plugins/type-ahead/ui/AssistiveText.js +129 -0
  128. package/dist/esm/plugins/type-ahead/ui/InputQuery.js +56 -12
  129. package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +151 -32
  130. package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +54 -31
  131. package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
  132. package/dist/esm/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
  133. package/dist/esm/plugins/type-ahead/utils.js +1 -1
  134. package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +7 -0
  135. package/dist/esm/ui/PortalProvider/PortalProviderThemesProvider.js +2 -5
  136. package/dist/esm/ui/PortalProvider/index.js +26 -35
  137. package/dist/esm/utils/index.js +4 -0
  138. package/dist/esm/version-wrapper.js +1 -1
  139. package/dist/esm/version.json +1 -1
  140. package/dist/types/index.d.ts +1 -1
  141. package/dist/types/plugins/base/pm-plugins/composition.d.ts +8 -0
  142. package/dist/types/plugins/code-block/pm-plugins/ide-ux.d.ts +1 -4
  143. package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +2 -0
  144. package/dist/types/plugins/floating-toolbar/ui/DropdownMenu.d.ts +1 -0
  145. package/dist/types/plugins/paste/actions.d.ts +15 -0
  146. package/dist/types/plugins/paste/commands.d.ts +16 -0
  147. package/dist/types/plugins/paste/handlers.d.ts +1 -1
  148. package/dist/types/plugins/paste/pm-plugins/main.d.ts +3 -3
  149. package/dist/types/plugins/paste/pm-plugins/plugin-factory.d.ts +3 -0
  150. package/dist/types/plugins/paste/reducer.d.ts +3 -0
  151. package/dist/types/plugins/paste/types.d.ts +6 -0
  152. package/dist/types/plugins/table/commands-with-analytics.d.ts +5 -5
  153. package/dist/types/plugins/tasks-and-decisions/commands.d.ts +0 -2
  154. package/dist/types/plugins/type-ahead/constants.d.ts +1 -0
  155. package/dist/types/plugins/type-ahead/messages.d.ts +15 -0
  156. package/dist/types/plugins/type-ahead/ui/AssistiveText.d.ts +33 -0
  157. package/dist/types/plugins/type-ahead/ui/InputQuery.d.ts +3 -0
  158. package/dist/types/plugins/type-ahead/ui/TypeAheadList.d.ts +6 -3
  159. package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +2 -2
  160. package/dist/types/plugins/type-ahead/ui/TypeAheadPopup.d.ts +1 -1
  161. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  162. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  163. package/dist/types/utils/index.d.ts +1 -0
  164. package/dist/types-ts4.0/index.d.ts +1 -1
  165. package/dist/types-ts4.0/plugins/base/pm-plugins/composition.d.ts +8 -0
  166. package/dist/types-ts4.0/plugins/code-block/pm-plugins/ide-ux.d.ts +1 -4
  167. package/dist/types-ts4.0/plugins/floating-toolbar/ui/Dropdown.d.ts +2 -0
  168. package/dist/types-ts4.0/plugins/floating-toolbar/ui/DropdownMenu.d.ts +1 -0
  169. package/dist/types-ts4.0/plugins/paste/actions.d.ts +15 -0
  170. package/dist/types-ts4.0/plugins/paste/commands.d.ts +16 -0
  171. package/dist/types-ts4.0/plugins/paste/handlers.d.ts +1 -1
  172. package/dist/types-ts4.0/plugins/paste/pm-plugins/main.d.ts +3 -3
  173. package/dist/types-ts4.0/plugins/paste/pm-plugins/plugin-factory.d.ts +3 -0
  174. package/dist/types-ts4.0/plugins/paste/reducer.d.ts +3 -0
  175. package/dist/types-ts4.0/plugins/paste/types.d.ts +6 -0
  176. package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +5 -5
  177. package/dist/types-ts4.0/plugins/tasks-and-decisions/commands.d.ts +0 -2
  178. package/dist/types-ts4.0/plugins/type-ahead/constants.d.ts +1 -0
  179. package/dist/types-ts4.0/plugins/type-ahead/messages.d.ts +15 -0
  180. package/dist/types-ts4.0/plugins/type-ahead/ui/AssistiveText.d.ts +33 -0
  181. package/dist/types-ts4.0/plugins/type-ahead/ui/InputQuery.d.ts +3 -0
  182. package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadList.d.ts +6 -3
  183. package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadListItem.d.ts +2 -2
  184. package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadPopup.d.ts +1 -1
  185. package/dist/types-ts4.0/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  186. package/dist/types-ts4.0/ui/ContentStyles/index.d.ts +2 -2
  187. package/dist/types-ts4.0/utils/index.d.ts +1 -0
  188. package/package.json +30 -31
  189. package/report.api.md +161 -49
@@ -293,14 +293,14 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
293
293
  break;
294
294
 
295
295
  case 'merge':
296
- mergeCellsWithAnalytics(editorAnalyticsAPI)(state, dispatch);
296
+ mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU)(state, dispatch);
297
297
 
298
298
  _this.toggleOpen();
299
299
 
300
300
  break;
301
301
 
302
302
  case 'split':
303
- splitCellWithAnalytics(editorAnalyticsAPI)(state, dispatch);
303
+ splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU)(state, dispatch);
304
304
 
305
305
  _this.toggleOpen();
306
306
 
@@ -448,7 +448,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
448
448
 
449
449
  var state = editorView.state,
450
450
  dispatch = editorView.dispatch;
451
- setColorWithAnalytics(editorAnalyticsAPI)(color, targetCellPosition)(state, dispatch);
451
+ setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, color, targetCellPosition)(state, dispatch);
452
452
 
453
453
  _this.toggleOpen();
454
454
  });
@@ -68,18 +68,6 @@ export var getListTypes = function getListTypes(listType, schema) {
68
68
  item: decisionItem
69
69
  };
70
70
  };
71
- /*
72
- * @deprecated - [ED-13182] insertTaskDecision has been depreciated in favor of insertTaskDecisionCommand
73
- */
74
-
75
- export var insertTaskDecision = function insertTaskDecision(view, listType) {
76
- var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INPUT_METHOD.TOOLBAR;
77
- var listLocalId = arguments.length > 3 ? arguments[3] : undefined;
78
- var itemLocalId = arguments.length > 4 ? arguments[4] : undefined;
79
- // eslint-disable-next-line no-console
80
- console.warn('insertTaskDecision has been depreciated in favor of insertTaskDecisionCommand');
81
- return insertTaskDecisionCommand(listType, inputMethod, undefined, listLocalId, itemLocalId);
82
- };
83
71
  export var insertTaskDecisionAction = function insertTaskDecisionAction(state, listType) {
84
72
  var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INPUT_METHOD.TOOLBAR;
85
73
  var addItem = arguments.length > 3 ? arguments[3] : undefined;
@@ -1,6 +1,7 @@
1
1
  export var TYPE_AHEAD_DECORATION_KEY = 'typeahead_decoration_key';
2
2
  export var TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE = 'typeaheadDecoration';
3
3
  export var TYPE_AHEAD_POPUP_CONTENT_CLASS = 'fabric-editor-typeahead';
4
+ export var TYPE_AHEAD_DECORATION_ELEMENT_ID = 'typeahaed_decoration_element_id';
4
5
  export var NavigationDirection;
5
6
 
6
7
  (function (NavigationDirection) {
@@ -3,6 +3,21 @@ export var typeAheadListMessages = defineMessages({
3
3
  typeAheadResultLabel: {
4
4
  id: 'fabric.editor.typeAheadResultLabel',
5
5
  defaultMessage: 'TypeAhead results',
6
- description: 'the result of a typehead, similar to autocomplete results+'
6
+ description: 'the result of a typeahead, similar to autocomplete results+'
7
+ },
8
+ inputQueryAssistiveLabel: {
9
+ id: 'fabric.editor.inputQueryAssistiveTxt',
10
+ defaultMessage: 'When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.',
11
+ description: 'Assitive text to the user when using typeahead shortcut'
12
+ },
13
+ searchResultsLabel: {
14
+ id: 'fabric.editor.searchResults',
15
+ defaultMessage: '{itemsLength, plural, one {# search result} other {# search results}} available',
16
+ description: 'Assitive text to the user when using typeahead shortcut and it preceeds with a number - Ex: 10 search results available'
17
+ },
18
+ noSearchResultsLabel: {
19
+ id: 'fabric.editor.noSearchResults',
20
+ defaultMessage: 'No search results',
21
+ description: 'Assitive text to the user when using typeahead shortcut'
7
22
  }
8
23
  });
@@ -54,7 +54,7 @@ export function createPlugin(_ref) {
54
54
  decorationSet: DecorationSet.empty,
55
55
  decorationElement: null,
56
56
  items: [],
57
- selectedIndex: 0,
57
+ selectedIndex: -1,
58
58
  stats: null,
59
59
  inputMethod: null
60
60
  };
@@ -73,7 +73,7 @@ export var createReducer = function createReducer(_ref) {
73
73
  triggerHandler: triggerHandler,
74
74
  decorationElement: decorationElement,
75
75
  inputMethod: inputMethod,
76
- selectedIndex: typeof selectedIndex === 'number' ? selectedIndex : 0,
76
+ selectedIndex: typeof selectedIndex === 'number' ? selectedIndex : -1,
77
77
  items: [],
78
78
  query: reopenQuery || ''
79
79
  });
@@ -138,7 +138,7 @@ export var createReducer = function createReducer(_ref) {
138
138
  var selectedIndex = currentPluginState.selectedIndex;
139
139
  return _objectSpread(_objectSpread({}, currentPluginState), {}, {
140
140
  items: items,
141
- selectedIndex: Math.max(selectedIndex >= items.length ? items.length - 1 : selectedIndex, 0)
141
+ selectedIndex: Math.max(selectedIndex >= items.length ? items.length - 1 : selectedIndex, -1)
142
142
  });
143
143
  } else if (shouldUpdateSelectedIndex) {
144
144
  return _objectSpread(_objectSpread({}, currentPluginState), {}, {
@@ -0,0 +1,129 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+
9
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
+
11
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
+
13
+ /** @jsx jsx */
14
+ import debounce from 'lodash/debounce';
15
+ import React from 'react';
16
+ import { css, jsx } from '@emotion/react';
17
+ var statusDebounceMillis = 1400;
18
+ var assitiveTextStyles = css({
19
+ border: 0,
20
+ clip: 'rect(0 0 0 0)',
21
+ height: '1px',
22
+ marginbottom: '-1px',
23
+ marginright: '-1px',
24
+ overflow: 'hidden',
25
+ padding: 0,
26
+ position: 'absolute',
27
+ whitespace: 'nowrap',
28
+ width: '1px'
29
+ });
30
+
31
+ var AssistveTextComponent = /*#__PURE__*/function (_React$Component) {
32
+ _inherits(AssistveTextComponent, _React$Component);
33
+
34
+ var _super = _createSuper(AssistveTextComponent);
35
+
36
+ function AssistveTextComponent() {
37
+ var _this;
38
+
39
+ _classCallCheck(this, AssistveTextComponent);
40
+
41
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
42
+ args[_key] = arguments[_key];
43
+ }
44
+
45
+ _this = _super.call.apply(_super, [this].concat(args));
46
+
47
+ _defineProperty(_assertThisInitialized(_this), "state", {
48
+ bump: false,
49
+ //when the same text needs to be read again, Hence it needs to be toggled between __status--A and __status--B
50
+ debounced: false,
51
+ silenced: false
52
+ });
53
+
54
+ return _this;
55
+ }
56
+
57
+ _createClass(AssistveTextComponent, [{
58
+ key: "componentWillMount",
59
+ value: function componentWillMount() {
60
+ var _this2 = this;
61
+
62
+ this.debounceStatusUpdate = debounce(function () {
63
+ if (!_this2.state.debounced) {
64
+ var shouldSilence = !_this2.props.isInFocus;
65
+
66
+ _this2.setState(function (_ref) {
67
+ var bump = _ref.bump;
68
+ return {
69
+ bump: !bump,
70
+ debounced: true,
71
+ silenced: shouldSilence
72
+ };
73
+ });
74
+ }
75
+ }, statusDebounceMillis);
76
+ }
77
+ }, {
78
+ key: "componentWillUnmount",
79
+ value: function componentWillUnmount() {}
80
+ }, {
81
+ key: "componentWillReceiveProps",
82
+ value: function componentWillReceiveProps() {
83
+ this.setState(function (_ref2) {
84
+ var bump = _ref2.bump;
85
+ return {
86
+ bump: !bump,
87
+ debounced: false
88
+ };
89
+ });
90
+ }
91
+ }, {
92
+ key: "render",
93
+ value: function render() {
94
+ var _this$props = this.props,
95
+ assistiveText = _this$props.assistiveText,
96
+ id = _this$props.id;
97
+ var _this$state = this.state,
98
+ bump = _this$state.bump,
99
+ debounced = _this$state.debounced,
100
+ silenced = _this$state.silenced;
101
+ this.debounceStatusUpdate();
102
+ return jsx("div", {
103
+ css: assitiveTextStyles
104
+ }, jsx("div", {
105
+ id: id + '__status--A',
106
+ role: "status",
107
+ "aria-atomic": "true",
108
+ "aria-live": "polite"
109
+ }, "".concat(!silenced && debounced && bump ? assistiveText : '')), jsx("div", {
110
+ id: id + '__status--B',
111
+ role: "status",
112
+ "aria-atomic": "true",
113
+ "aria-live": "polite"
114
+ }, "".concat(!silenced && debounced && !bump ? assistiveText : '')));
115
+ }
116
+ }]);
117
+
118
+ return AssistveTextComponent;
119
+ }(React.Component);
120
+
121
+ _defineProperty(AssistveTextComponent, "defaultProps", {
122
+ statusDebounceMillis: 1400,
123
+ debounce: true,
124
+ assistiveText: '',
125
+ isInFocus: false,
126
+ id: ''
127
+ });
128
+
129
+ export var AssistiveText = AssistveTextComponent;
@@ -1,14 +1,20 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
2
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
3
 
3
4
  var _templateObject;
4
5
 
5
6
  /** @jsx jsx */
6
- import React, { useRef, useCallback, Fragment, useLayoutEffect } from 'react';
7
+ import React, { useRef, useCallback, Fragment, useLayoutEffect, useState } from 'react';
7
8
  import { css, jsx } from '@emotion/react';
8
9
  import { keyName as keyNameNormalized } from 'w3c-keyname';
9
10
  import { browser, ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
11
+ import { getPluginState } from '../utils';
10
12
  import { CloseSelectionOptions, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../constants';
11
13
  import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
14
+ import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../constants';
15
+ import { AssistiveText } from './AssistiveText';
16
+ import { typeAheadListMessages } from '../messages';
17
+ import { useIntl } from 'react-intl-next';
12
18
  var querySpan = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n outline: none;\n"])));
13
19
 
14
20
  var isNavigationKey = function isNavigationKey(event) {
@@ -43,7 +49,9 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
43
49
  forceFocus = _ref.forceFocus,
44
50
  reopenQuery = _ref.reopenQuery,
45
51
  onQueryFocus = _ref.onQueryFocus,
46
- onUndoRedo = _ref.onUndoRedo;
52
+ onUndoRedo = _ref.onUndoRedo,
53
+ editorView = _ref.editorView,
54
+ items = _ref.items;
47
55
  var ref = useRef(document.createElement('span'));
48
56
  var cleanedInputContent = useCallback(function () {
49
57
  var _ref$current;
@@ -55,6 +63,12 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
55
63
  var text = cleanedInputContent();
56
64
  onQueryChange(text);
57
65
  }, [onQueryChange, cleanedInputContent]);
66
+
67
+ var _useState = useState(false),
68
+ _useState2 = _slicedToArray(_useState, 2),
69
+ isInFocus = _useState2[0],
70
+ setInFocus = _useState2[1];
71
+
58
72
  var checkKeyEvent = useCallback(function (event) {
59
73
  var _ref$current2;
60
74
 
@@ -64,6 +78,11 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
64
78
  var text = cleanedInputContent();
65
79
  var stopDefault = false;
66
80
 
81
+ var _getPluginState = getPluginState(editorView.state),
82
+ selectedIndex = _getPluginState.selectedIndex;
83
+
84
+ setInFocus(true);
85
+
67
86
  switch (key) {
68
87
  case ' ':
69
88
  // space key
@@ -107,23 +126,29 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
107
126
  // ED-14758 - Under the W3C specification, any keycode sent under IME would return a keycode 229
108
127
  // event.isComposing can't be used alone as this also included a virtual keyboard under a keyboardless device, therefore, it seems the best practice would be intercepting the event as below.
109
128
  // Some suggested the other workaround maybe listen on`keypress` instead of `keydown`
110
- if (event.isComposing && (event.which === 229 || event.keyCode === 229)) {
111
- break;
129
+ if (!event.isComposing || event.which !== 229 && event.keyCode !== 229) {
130
+ if (selectedIndex === -1) {
131
+ selectNextItem();
132
+ }
133
+
134
+ onItemSelect(event.shiftKey ? SelectItemMode.SHIFT_ENTER : SelectItemMode.ENTER);
112
135
  }
113
136
 
114
- onItemSelect(event.shiftKey ? SelectItemMode.SHIFT_ENTER : SelectItemMode.ENTER);
115
137
  break;
116
138
 
117
139
  case 'Tab':
140
+ if (selectedIndex === -1) {
141
+ selectNextItem();
142
+ }
143
+
118
144
  onItemSelect(SelectItemMode.TAB);
119
145
  break;
120
146
 
121
147
  case 'ArrowDown':
122
- selectNextItem();
123
- break;
148
+ if (selectedIndex === -1) {
149
+ selectNextItem();
150
+ }
124
151
 
125
- case 'ArrowUp':
126
- selectPreviousItem();
127
152
  break;
128
153
  }
129
154
 
@@ -138,7 +163,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
138
163
  event.preventDefault();
139
164
  return false;
140
165
  }
141
- }, [onUndoRedo, onItemSelect, selectNextItem, cancel, selectPreviousItem, cleanedInputContent]);
166
+ }, [onUndoRedo, onItemSelect, selectNextItem, cancel, cleanedInputContent, editorView.state]);
142
167
  var onClick = useCallback(function (event) {
143
168
  var _ref$current3;
144
169
 
@@ -229,6 +254,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
229
254
  var beforeinput = function beforeinput(e) {
230
255
  var _target$textContent;
231
256
 
257
+ setInFocus(false);
232
258
  var target = e.target;
233
259
 
234
260
  if (e.isComposing || !(target instanceof HTMLElement)) {
@@ -300,7 +326,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
300
326
  element.removeEventListener('input', onInput);
301
327
  }
302
328
  };
303
- }, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent]);
329
+ }, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent, editorView.state]);
304
330
  useLayoutEffect(function () {
305
331
  var hasReopenQuery = typeof reopenQuery === 'string' && reopenQuery.trim().length > 0;
306
332
 
@@ -323,9 +349,12 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
323
349
  }
324
350
 
325
351
  ref.current.focus();
352
+ setInFocus(true);
326
353
  });
327
354
  }
328
355
  }, [forceFocus, reopenQuery]);
356
+ var assistiveHintID = TYPE_AHEAD_DECORATION_ELEMENT_ID + '__assistiveHint';
357
+ var intl = useIntl();
329
358
  /**
330
359
  When we migrated to emotion from styled component, we started getting this error.
331
360
  jsx-a11y/interactive-supports-focus
@@ -338,9 +367,24 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
338
367
  ref: ref,
339
368
  onKeyUp: onKeyUp,
340
369
  onClick: onClick,
341
- role: "textbox",
370
+ role: "combobox",
371
+ "aria-controls": TYPE_AHEAD_DECORATION_ELEMENT_ID,
372
+ "aria-autocomplete": "list",
373
+ "aria-expanded": items.length !== 0,
374
+ "aria-labelledby": assistiveHintID,
342
375
  suppressContentEditableWarning: true,
343
376
  "data-query-prefix": triggerQueryPrefix
377
+ }), jsx("span", {
378
+ id: assistiveHintID,
379
+ style: {
380
+ display: 'none'
381
+ }
382
+ }, intl.formatMessage(typeAheadListMessages.inputQueryAssistiveLabel)), jsx(AssistiveText, {
383
+ assistiveText: items.length === 0 ? intl.formatMessage(typeAheadListMessages.noSearchResultsLabel, {
384
+ itemsLength: items.length
385
+ }) : '',
386
+ isInFocus: items.length === 0 || isInFocus,
387
+ id: TYPE_AHEAD_DECORATION_ELEMENT_ID
344
388
  }));
345
389
  });
346
390
  InputQuery.displayName = 'InputQuery';
@@ -7,21 +7,42 @@ var _templateObject;
7
7
  import React, { useMemo, useRef, useCallback, useLayoutEffect, useState } from 'react';
8
8
  import { jsx, css } from '@emotion/react';
9
9
  import { MenuGroup } from '@atlaskit/menu';
10
+ import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
10
11
  import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
11
12
  import { List } from 'react-virtualized/dist/commonjs/List';
12
13
  import { ICON_HEIGHT, ITEM_PADDING, TypeAheadListItem } from './TypeAheadListItem';
13
- import { injectIntl } from 'react-intl-next';
14
+ import { injectIntl, useIntl } from 'react-intl-next';
14
15
  import { typeAheadListMessages } from '../messages';
16
+ import { moveSelectedIndex } from '../utils';
17
+ import { updateSelectedIndex } from '../commands/update-selected-index';
18
+ import { AssistiveText } from './AssistiveText';
19
+ import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../constants';
15
20
  var LIST_ITEM_ESTIMATED_HEIGHT = ICON_HEIGHT + ITEM_PADDING * 2;
16
21
  var LIST_WIDTH = 320;
17
- var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref) {
18
- var items = _ref.items,
19
- selectedIndex = _ref.selectedIndex,
20
- onItemHover = _ref.onItemHover,
21
- onItemClick = _ref.onItemClick,
22
- intl = _ref.intl,
23
- fitHeight = _ref.fitHeight;
22
+ var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/React.memo(function (_ref) {
23
+ var numberOfResults = _ref.numberOfResults;
24
+ var intl = useIntl();
25
+ return jsx(AssistiveText, {
26
+ assistiveText: intl.formatMessage(typeAheadListMessages.searchResultsLabel, {
27
+ itemsLength: numberOfResults
28
+ }) // when the popup is open its always in focus
29
+ ,
30
+ isInFocus: true,
31
+ id: TYPE_AHEAD_DECORATION_ELEMENT_ID + '__popup'
32
+ });
33
+ });
34
+ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
35
+ var _decorationElement$qu2;
36
+
37
+ var items = _ref2.items,
38
+ selectedIndex = _ref2.selectedIndex,
39
+ editorView = _ref2.editorView,
40
+ onItemClick = _ref2.onItemClick,
41
+ intl = _ref2.intl,
42
+ fitHeight = _ref2.fitHeight,
43
+ decorationElement = _ref2.decorationElement;
24
44
  var listRef = useRef();
45
+ var listContainerRef = useRef(null);
25
46
  var lastVisibleIndexes = useRef({
26
47
  overscanStartIndex: 0,
27
48
  overscanStopIndex: 0,
@@ -48,12 +69,38 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref) {
48
69
  }, []);
49
70
  var actions = useMemo(function () {
50
71
  return {
51
- onItemClick: onItemClick,
52
- onItemHover: onItemHover
72
+ onItemClick: onItemClick
53
73
  };
54
- }, [onItemClick, onItemHover]);
55
- var onScroll = useCallback(function (_ref2) {
56
- var scrollUpdateWasRequested = _ref2.scrollUpdateWasRequested;
74
+ }, [onItemClick]);
75
+
76
+ var isNavigationKey = function isNavigationKey(event) {
77
+ return ['ArrowDown', 'ArrowUp', 'Tab', 'Enter'].includes(event.key);
78
+ };
79
+
80
+ var focusTargetElement = useCallback(function () {
81
+ var _decorationElement$qu;
82
+
83
+ //To reset the selected index
84
+ updateSelectedIndex(-1)(editorView.state, editorView.dispatch);
85
+ listRef.current.scrollToRow(0);
86
+ decorationElement === null || decorationElement === void 0 ? void 0 : (_decorationElement$qu = decorationElement.querySelector("[role='combobox']")) === null || _decorationElement$qu === void 0 ? void 0 : _decorationElement$qu.focus();
87
+ }, [editorView, listRef, decorationElement]);
88
+ var selectNextItem = useMemo(function () {
89
+ return moveSelectedIndex({
90
+ editorView: editorView,
91
+ direction: 'next'
92
+ });
93
+ }, [editorView]);
94
+ var selectPreviousItem = useMemo(function () {
95
+ return moveSelectedIndex({
96
+ editorView: editorView,
97
+ direction: 'previous'
98
+ });
99
+ }, [editorView]);
100
+ var lastVisibleStartIndex = lastVisibleIndexes.current.startIndex;
101
+ var lastVisibleStopIndex = lastVisibleIndexes.current.stopIndex;
102
+ var onScroll = useCallback(function (_ref3) {
103
+ var scrollUpdateWasRequested = _ref3.scrollUpdateWasRequested;
57
104
 
58
105
  if (!scrollUpdateWasRequested) {
59
106
  return;
@@ -71,27 +118,29 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref) {
71
118
 
72
119
  requestAnimationFrame(function () {
73
120
  requestAnimationFrame(function () {
74
- var indexes = lastVisibleIndexes.current;
75
- var isSelectedItemVisible = selectedIndex >= indexes.startIndex && selectedIndex <= indexes.stopIndex;
121
+ var isSelectedItemVisible = selectedIndex >= lastVisibleStartIndex && selectedIndex <= lastVisibleStopIndex; //Should scroll to the list item only when the selectedIndex >= 0 and item is not visible
76
122
 
77
- if (!isSelectedItemVisible) {
123
+ if (!isSelectedItemVisible && selectedIndex !== -1) {
78
124
  listRef.current.scrollToRow(selectedIndex);
125
+ } else if (selectedIndex === -1) {
126
+ listRef.current.scrollToRow(0);
79
127
  }
80
128
  });
81
129
  });
82
- }, [selectedIndex, lastVisibleIndexes]);
130
+ }, [selectedIndex, lastVisibleStartIndex, lastVisibleStopIndex]);
83
131
  useLayoutEffect(function () {
84
132
  if (!listRef.current) {
85
133
  return;
86
134
  }
87
135
 
88
- var indexes = lastVisibleIndexes.current;
89
- var isSelectedItemVisible = selectedIndex >= indexes.startIndex && selectedIndex <= indexes.stopIndex;
136
+ var isSelectedItemVisible = selectedIndex >= lastVisibleStartIndex && selectedIndex <= lastVisibleStopIndex; //Should scroll to the list item only when the selectedIndex >= 0 and item is not visible
90
137
 
91
- if (!isSelectedItemVisible) {
138
+ if (!isSelectedItemVisible && selectedIndex !== -1) {
92
139
  listRef.current.scrollToRow(selectedIndex);
140
+ } else if (selectedIndex === -1) {
141
+ listRef.current.scrollToRow(0);
93
142
  }
94
- }, [selectedIndex, lastVisibleIndexes]);
143
+ }, [selectedIndex, lastVisibleStartIndex, lastVisibleStopIndex]);
95
144
  useLayoutEffect(function () {
96
145
  setCache(new CellMeasurerCache({
97
146
  fixedWidth: true,
@@ -106,12 +155,76 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref) {
106
155
  }, 0), fitHeight);
107
156
  setHeight(height);
108
157
  }, [items, cache, fitHeight]);
158
+ useLayoutEffect(function () {
159
+ if (!listContainerRef.current) {
160
+ return;
161
+ }
162
+
163
+ var element = listContainerRef.current;
164
+ /**
165
+ * To handle the key events on the list
166
+ * @param event
167
+ */
168
+
169
+ var handleKeyDown = function handleKeyDown(event) {
170
+ if (isNavigationKey(event)) {
171
+ switch (event.key) {
172
+ case 'ArrowDown':
173
+ if (selectedIndex === items.length - 1) {
174
+ event.stopPropagation();
175
+ } else {
176
+ selectNextItem();
177
+ }
109
178
 
110
- var renderRow = function renderRow(_ref3) {
111
- var index = _ref3.index,
112
- key = _ref3.key,
113
- style = _ref3.style,
114
- parent = _ref3.parent;
179
+ event.preventDefault();
180
+ break;
181
+
182
+ case 'ArrowUp':
183
+ if (selectedIndex === 0) {
184
+ //To set focus on target element when up arrow is pressed on first option of list
185
+ focusTargetElement();
186
+ } else {
187
+ selectPreviousItem();
188
+ }
189
+
190
+ event.preventDefault();
191
+ break;
192
+
193
+ case 'Tab':
194
+ //Tab key quick inserts the selected item.
195
+ onItemClick(SelectItemMode.TAB, selectedIndex);
196
+ event.preventDefault();
197
+ break;
198
+
199
+ case 'Enter':
200
+ //Enter key quick inserts the selected item.
201
+ if (!event.isComposing || event.which !== 229 && event.keyCode !== 229) {
202
+ onItemClick(event.shiftKey ? SelectItemMode.SHIFT_ENTER : SelectItemMode.ENTER, selectedIndex);
203
+ event.preventDefault();
204
+ }
205
+
206
+ break;
207
+
208
+ default:
209
+ event.preventDefault();
210
+ }
211
+ } else {
212
+ //All the remaining keys sets focus on the typeahead query(inputQuery.tsx))
213
+ focusTargetElement();
214
+ }
215
+ };
216
+
217
+ element === null || element === void 0 ? void 0 : element.addEventListener('keydown', handleKeyDown);
218
+ return function () {
219
+ element === null || element === void 0 ? void 0 : element.removeEventListener('keydown', handleKeyDown);
220
+ };
221
+ }, [editorView.state, focusTargetElement, selectNextItem, selectPreviousItem, selectedIndex, onItemClick, items.length]);
222
+
223
+ var renderRow = function renderRow(_ref4) {
224
+ var index = _ref4.index,
225
+ key = _ref4.key,
226
+ style = _ref4.style,
227
+ parent = _ref4.parent;
115
228
  return jsx(CellMeasurer, {
116
229
  key: key,
117
230
  cache: cache,
@@ -126,10 +239,10 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref) {
126
239
  }, jsx(TypeAheadListItem, {
127
240
  key: items[index].title,
128
241
  item: items[index],
242
+ itemsLength: items.length,
129
243
  itemIndex: index,
130
244
  selectedIndex: selectedIndex,
131
- onItemClick: actions.onItemClick,
132
- onItemHover: actions.onItemHover
245
+ onItemClick: actions.onItemClick
133
246
  }))));
134
247
  };
135
248
 
@@ -137,11 +250,13 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref) {
137
250
  return null;
138
251
  }
139
252
 
253
+ var menuGroupId = ((_decorationElement$qu2 = decorationElement.querySelector("[role='combobox']")) === null || _decorationElement$qu2 === void 0 ? void 0 : _decorationElement$qu2.getAttribute('aria-controls')) || TYPE_AHEAD_DECORATION_ELEMENT_ID;
140
254
  return jsx(MenuGroup, {
141
- role: "listbox",
142
- "aria-live": "polite",
143
255
  "aria-label": intl.formatMessage(typeAheadListMessages.typeAheadResultLabel),
144
256
  "aria-relevant": "additions removals"
257
+ }, jsx("div", {
258
+ id: menuGroupId,
259
+ ref: listContainerRef
145
260
  }, jsx(List, {
146
261
  rowRenderer: renderRow,
147
262
  ref: listRef,
@@ -152,8 +267,12 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref) {
152
267
  onScroll: onScroll,
153
268
  height: height,
154
269
  overscanRowCount: 3,
155
- css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n button {\n padding: 12px 12px 11px;\n span:last-child span:last-child {\n white-space: normal;\n }\n }\n "])))
156
- }));
270
+ containerRole: "presentation",
271
+ role: "listbox",
272
+ css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n button {\n padding: 12px 12px 11px;\n span:last-child span:last-child {\n white-space: normal;\n }\n }\n "])))
273
+ }), jsx(TypeaheadAssistiveTextPureComponent, {
274
+ numberOfResults: items.length.toString()
275
+ })));
157
276
  });
158
277
  export var TypeAheadList = injectIntl(TypeAheadListComponent);
159
278
  TypeAheadList.displayName = 'TypeAheadList';