@atlaskit/editor-core 185.2.5 → 185.2.8

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 (38) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/block-type/index.js +12 -9
  3. package/dist/cjs/ui/ElementBrowser/ElementBrowser.js +4 -2
  4. package/dist/cjs/ui/ElementBrowser/InsertMenu.js +11 -30
  5. package/dist/cjs/ui/ElementBrowser/ViewMore.js +39 -0
  6. package/dist/cjs/ui/ElementBrowser/components/StatelessElementBrowser.js +16 -6
  7. package/dist/cjs/ui/ElementBrowser/hooks/use-select-and-focus-on-arrow-navigation.js +98 -26
  8. package/dist/cjs/version-wrapper.js +1 -1
  9. package/dist/cjs/version.json +1 -1
  10. package/dist/es2019/plugins/block-type/index.js +12 -9
  11. package/dist/es2019/ui/ElementBrowser/ElementBrowser.js +4 -2
  12. package/dist/es2019/ui/ElementBrowser/InsertMenu.js +5 -35
  13. package/dist/es2019/ui/ElementBrowser/ViewMore.js +40 -0
  14. package/dist/es2019/ui/ElementBrowser/components/StatelessElementBrowser.js +16 -6
  15. package/dist/es2019/ui/ElementBrowser/hooks/use-select-and-focus-on-arrow-navigation.js +104 -26
  16. package/dist/es2019/version-wrapper.js +1 -1
  17. package/dist/es2019/version.json +1 -1
  18. package/dist/esm/plugins/block-type/index.js +12 -9
  19. package/dist/esm/ui/ElementBrowser/ElementBrowser.js +4 -2
  20. package/dist/esm/ui/ElementBrowser/InsertMenu.js +12 -31
  21. package/dist/esm/ui/ElementBrowser/ViewMore.js +31 -0
  22. package/dist/esm/ui/ElementBrowser/components/StatelessElementBrowser.js +16 -6
  23. package/dist/esm/ui/ElementBrowser/hooks/use-select-and-focus-on-arrow-navigation.js +98 -26
  24. package/dist/esm/version-wrapper.js +1 -1
  25. package/dist/esm/version.json +1 -1
  26. package/dist/types/plugins/block-type/index.d.ts +3 -1
  27. package/dist/types/ui/ElementBrowser/ElementBrowser.d.ts +1 -0
  28. package/dist/types/ui/ElementBrowser/ViewMore.d.ts +6 -0
  29. package/dist/types/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +2 -1
  30. package/dist/types/ui/ElementBrowser/hooks/use-select-and-focus-on-arrow-navigation.d.ts +7 -3
  31. package/dist/types/ui/ElementBrowser/types.d.ts +1 -1
  32. package/dist/types-ts4.5/plugins/block-type/index.d.ts +5 -1
  33. package/dist/types-ts4.5/ui/ElementBrowser/ElementBrowser.d.ts +1 -0
  34. package/dist/types-ts4.5/ui/ElementBrowser/ViewMore.d.ts +6 -0
  35. package/dist/types-ts4.5/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +2 -1
  36. package/dist/types-ts4.5/ui/ElementBrowser/hooks/use-select-and-focus-on-arrow-navigation.d.ts +7 -3
  37. package/dist/types-ts4.5/ui/ElementBrowser/types.d.ts +1 -1
  38. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 185.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [`af998742600`](https://bitbucket.org/atlassian/atlassian-frontend/commits/af998742600) - [ux] ED-18059 Updated arrow key navigation within insert menu and element browser.
8
+
9
+ ## 185.2.7
10
+
11
+ ### Patch Changes
12
+
13
+ - [`1259df9a9ef`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1259df9a9ef) - converted some of block-type's analytics to use new EditorAnalyticsAPI
14
+
3
15
  ## 185.2.5
4
16
 
5
17
  ### Patch Changes
@@ -21,14 +21,14 @@ var _inputRule = _interopRequireDefault(require("./pm-plugins/input-rule"));
21
21
  var _ToolbarBlockType = _interopRequireDefault(require("./ui/ToolbarBlockType"));
22
22
  var _WithPluginState = _interopRequireDefault(require("../../ui/WithPluginState"));
23
23
  var _commands = require("./commands");
24
- var _analytics = require("../analytics");
24
+ var _analytics = require("@atlaskit/editor-common/analytics");
25
25
  var keymaps = _interopRequireWildcard(require("../../keymaps"));
26
26
  var _assets = require("../quick-insert/assets");
27
27
  var _messages = require("./messages");
28
28
  var _types = require("../../ui/Toolbar/types");
29
29
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
30
30
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
- var headingPluginOptions = function headingPluginOptions(_ref, isAllowed) {
31
+ var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editorAnalyticsApi) {
32
32
  var formatMessage = _ref.formatMessage;
33
33
  if (!isAllowed) {
34
34
  return [];
@@ -56,7 +56,7 @@ var headingPluginOptions = function headingPluginOptions(_ref, isAllowed) {
56
56
  var tr = insert(state.schema.nodes.heading.createChecked({
57
57
  level: level
58
58
  }));
59
- return (0, _analytics.addAnalytics)(state, tr, {
59
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
60
60
  action: _analytics.ACTION.FORMATTED,
61
61
  actionSubject: _analytics.ACTION_SUBJECT.TEXT,
62
62
  eventType: _analytics.EVENT_TYPE.TRACK,
@@ -65,12 +65,13 @@ var headingPluginOptions = function headingPluginOptions(_ref, isAllowed) {
65
65
  inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT,
66
66
  newHeadingLevel: level
67
67
  }
68
- });
68
+ })(tr);
69
+ return tr;
69
70
  }
70
71
  };
71
72
  });
72
73
  };
73
- var blockquotePluginOptions = function blockquotePluginOptions(_ref2, isAllowed) {
74
+ var blockquotePluginOptions = function blockquotePluginOptions(_ref2, isAllowed, editorAnalyticsApi) {
74
75
  var formatMessage = _ref2.formatMessage;
75
76
  if (!isAllowed) {
76
77
  return [];
@@ -86,7 +87,7 @@ var blockquotePluginOptions = function blockquotePluginOptions(_ref2, isAllowed)
86
87
  },
87
88
  action: function action(insert, state) {
88
89
  var tr = insert(state.schema.nodes.blockquote.createChecked({}, state.schema.nodes.paragraph.createChecked()));
89
- return (0, _analytics.addAnalytics)(state, tr, {
90
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
90
91
  action: _analytics.ACTION.FORMATTED,
91
92
  actionSubject: _analytics.ACTION_SUBJECT.TEXT,
92
93
  eventType: _analytics.EVENT_TYPE.TRACK,
@@ -94,11 +95,12 @@ var blockquotePluginOptions = function blockquotePluginOptions(_ref2, isAllowed)
94
95
  attributes: {
95
96
  inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
96
97
  }
97
- });
98
+ })(tr);
99
+ return tr;
98
100
  }
99
101
  }];
100
102
  };
101
- var blockTypePlugin = function blockTypePlugin(options) {
103
+ var blockTypePlugin = function blockTypePlugin(options, api) {
102
104
  return {
103
105
  name: 'blockType',
104
106
  nodes: function nodes() {
@@ -182,8 +184,9 @@ var blockTypePlugin = function blockTypePlugin(options) {
182
184
  },
183
185
  pluginsOptions: {
184
186
  quickInsert: function quickInsert(intl) {
187
+ var _api$dependencies$ana, _api$dependencies$ana2;
185
188
  var exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
186
- return [].concat((0, _toConsumableArray2.default)(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1)), (0, _toConsumableArray2.default)(headingPluginOptions(intl, exclude.indexOf('heading') === -1)));
189
+ return [].concat((0, _toConsumableArray2.default)(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions)), (0, _toConsumableArray2.default)(headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions)));
187
190
  }
188
191
  }
189
192
  };
@@ -119,7 +119,8 @@ var ElementBrowser = /*#__PURE__*/function (_PureComponent) {
119
119
  showSearch = _this$props.showSearch,
120
120
  showCategories = _this$props.showCategories,
121
121
  mode = _this$props.mode,
122
- emptyStateHandler = _this$props.emptyStateHandler;
122
+ emptyStateHandler = _this$props.emptyStateHandler,
123
+ viewMoreItem = _this$props.viewMoreItem;
123
124
  var _this$state2 = this.state,
124
125
  categories = _this$state2.categories,
125
126
  searchTerm = _this$state2.searchTerm,
@@ -137,7 +138,8 @@ var ElementBrowser = /*#__PURE__*/function (_PureComponent) {
137
138
  showCategories: showCategories,
138
139
  mode: mode,
139
140
  searchTerm: searchTerm,
140
- emptyStateHandler: emptyStateHandler
141
+ emptyStateHandler: emptyStateHandler,
142
+ viewMoreItem: viewMoreItem
141
143
  });
142
144
  }
143
145
  }]);
@@ -11,7 +11,6 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
11
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
12
  var _react = require("react");
13
13
  var _react2 = require("@emotion/react");
14
- var _menu = require("@atlaskit/menu");
15
14
  var _theme = require("@atlaskit/theme");
16
15
  var _components = require("@atlaskit/theme/components");
17
16
  var _colors = require("@atlaskit/theme/colors");
@@ -24,7 +23,7 @@ var _commands = require("../../plugins/quick-insert/commands");
24
23
  var _ElementBrowserLoader = _interopRequireDefault(require("./components/ElementBrowserLoader"));
25
24
  var _constants = require("./constants");
26
25
  var _excluded = ["children"];
27
- var _templateObject, _templateObject2, _templateObject3, _templateObject4;
26
+ var _templateObject, _templateObject2;
28
27
  /** @jsx jsx */
29
28
  // AFP-2532 TODO: Fix automatic suppressions below
30
29
  // eslint-disable-next-line @atlassian/tangerine/import/entry-points
@@ -59,7 +58,7 @@ var InsertMenu = function InsertMenu(_ref) {
59
58
  };
60
59
  }, [onInsert]);
61
60
  var quickInsertDropdownItems = dropdownItems.map(transform);
62
- var viewMoreItem = showElementBrowserLink && quickInsertDropdownItems.pop();
61
+ var viewMoreItem = showElementBrowserLink ? quickInsertDropdownItems.pop() : undefined;
63
62
  var onInsertItem = (0, _react.useCallback)(function (item) {
64
63
  toggleVisiblity();
65
64
  if (!editorView.hasFocus()) {
@@ -93,9 +92,10 @@ var InsertMenu = function InsertMenu(_ref) {
93
92
  showCategories: false
94
93
  // On page resize we want the InlineElementBrowser to show updated tools/overflow items
95
94
  ,
96
- key: quickInsertDropdownItems.length
95
+ key: quickInsertDropdownItems.length,
96
+ viewMoreItem: viewMoreItem
97
97
  }));
98
- }, [getItems, onInsertItem, quickInsertDropdownItems.length, toggleVisiblity]);
98
+ }, [getItems, onInsertItem, quickInsertDropdownItems.length, toggleVisiblity, viewMoreItem]);
99
99
  return (0, _react2.jsx)("div", {
100
100
  css: function css(theme) {
101
101
  return insertMenuWrapper(theme, itemCount);
@@ -105,28 +105,10 @@ var InsertMenu = function InsertMenu(_ref) {
105
105
  quickInsertState: _pluginKey.pluginKey
106
106
  },
107
107
  render: render
108
- }), itemCount > 0 && viewMoreItem && (0, _react2.jsx)(ViewMore, {
109
- item: viewMoreItem
110
108
  }));
111
109
  };
112
- var ViewMore = function ViewMore(_ref3) {
113
- var item = _ref3.item;
114
- return (0, _react2.jsx)(_menu.Section, {
115
- hasSeparator: true
116
- }, (0, _react2.jsx)(_menu.ButtonItem, {
117
- onClick: item.action,
118
- iconBefore: (0, _react2.jsx)("div", {
119
- css: itemBefore
120
- }, item.icon()),
121
- "aria-describedby": item.title,
122
- "data-testid": "view-more-elements-item"
123
- // @ts-ignore Overriding Menu styles is not supported
124
- ,
125
- css: (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n padding: 0px 12px;\n "])))
126
- }, item.title));
127
- };
128
- var getSvgIconForItem = function getSvgIconForItem(_ref4) {
129
- var name = _ref4.name;
110
+ var getSvgIconForItem = function getSvgIconForItem(_ref3) {
111
+ var name = _ref3.name;
130
112
  var Icon = {
131
113
  codeblock: _assets.IconCode,
132
114
  panel: _assets.IconPanel,
@@ -141,8 +123,8 @@ var getSvgIconForItem = function getSvgIconForItem(_ref4) {
141
123
  label: ""
142
124
  }) : undefined;
143
125
  };
144
- var getInsertMenuHeight = function getInsertMenuHeight(_ref5) {
145
- var itemCount = _ref5.itemCount;
126
+ var getInsertMenuHeight = function getInsertMenuHeight(_ref4) {
127
+ var itemCount = _ref4.itemCount;
146
128
  // Figure based on visuals to exclude the searchbar, padding/margin, and the ViewMore item.
147
129
  var EXTRA_SPACE_EXCLUDING_ELEMENTLIST = 112;
148
130
  if (itemCount > 0 && itemCount < 6) {
@@ -152,15 +134,14 @@ var getInsertMenuHeight = function getInsertMenuHeight(_ref5) {
152
134
  };
153
135
 
154
136
  var insertMenuWrapper = function insertMenuWrapper(theme, itemCount) {
155
- return (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n width: 320px;\n height: ", "px;\n background-color: ", ";\n border-radius: ", "px;\n box-shadow: ", ";\n"])), getInsertMenuHeight({
137
+ return (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n width: 320px;\n height: ", "px;\n background-color: ", ";\n border-radius: ", "px;\n box-shadow: ", ";\n"])), getInsertMenuHeight({
156
138
  itemCount: itemCount
157
139
  }), (0, _components.themed)({
158
140
  light: "var(--ds-surface-overlay, ".concat(_colors.N0, ")"),
159
141
  dark: "var(--ds-surface-overlay, ".concat(_colors.DN50, ")")
160
142
  })(theme), (0, _theme.borderRadius)(), "var(--ds-shadow-overlay, ".concat("0 0 0 1px ".concat(_colors.N30A, ",\n 0 2px 1px ").concat(_colors.N30A, ",\n 0 0 20px -6px ").concat(_colors.N60A), ")"));
161
143
  };
162
- var itemBefore = (0, _react2.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n width: 40px;\n height: 40px;\n box-sizing: border-box;\n display: flex;\n justify-content: center;\n align-items: center;\n margin-right: ", ";\n"])), "var(--ds-space-050, 4px)");
163
- var flexWrapperStyles = (0, _react2.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex: 1;\n box-sizing: border-box;\n overflow: hidden;\n"])));
144
+ var flexWrapperStyles = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex: 1;\n box-sizing: border-box;\n overflow: hidden;\n"])));
164
145
  var FlexWrapper = function FlexWrapper(props) {
165
146
  var children = props.children,
166
147
  divProps = (0, _objectWithoutProperties2.default)(props, _excluded);
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ViewMore = void 0;
8
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
+ var _react = require("react");
10
+ var _react2 = require("@emotion/react");
11
+ var _menu = require("@atlaskit/menu");
12
+ var _templateObject, _templateObject2;
13
+ /** @jsx jsx */
14
+ var itemBefore = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: 40px;\n height: 40px;\n box-sizing: border-box;\n display: flex;\n justify-content: center;\n align-items: center;\n margin-right: ", ";\n"])), "var(--ds-space-050, 4px)");
15
+ var ViewMore = function ViewMore(_ref) {
16
+ var item = _ref.item,
17
+ focus = _ref.focus;
18
+ var ref = (0, _react.useRef)(null);
19
+ (0, _react.useEffect)(function () {
20
+ if (ref.current && focus) {
21
+ ref.current.focus();
22
+ }
23
+ }, [focus]);
24
+ return (0, _react2.jsx)(_menu.Section, {
25
+ hasSeparator: true
26
+ }, (0, _react2.jsx)(_menu.ButtonItem, {
27
+ onClick: item.action,
28
+ iconBefore: (0, _react2.jsx)("div", {
29
+ css: itemBefore
30
+ }, item.icon()),
31
+ "aria-describedby": item.title,
32
+ "data-testid": "view-more-elements-item"
33
+ // @ts-ignore Overriding Menu styles is not supported
34
+ ,
35
+ css: (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n padding: 0px 12px;\n "]))),
36
+ ref: ref
37
+ }, item.title));
38
+ };
39
+ exports.ViewMore = ViewMore;
@@ -20,6 +20,7 @@ var _ElementSearch = _interopRequireDefault(require("./ElementSearch"));
20
20
  var _constants = require("../constants");
21
21
  var _useContainerWidth2 = _interopRequireDefault(require("../hooks/use-container-width"));
22
22
  var _useSelectAndFocusOnArrowNavigation = _interopRequireDefault(require("../hooks/use-select-and-focus-on-arrow-navigation"));
23
+ var _ViewMore = require("../ViewMore");
23
24
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15;
24
25
  /** @jsx jsx */
25
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -41,7 +42,8 @@ var mobileCategoryListWrapper = (0, _react2.css)(_templateObject14 || (_template
41
42
  var categoryListWrapper = (0, _react2.css)(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n padding: 0;\n margin-top: ", "px;\n flex-direction: column;\n"])), mobileCategoryListWrapper, _constants.GRID_SIZE * 3);
42
43
  function StatelessElementBrowser(props) {
43
44
  var items = props.items,
44
- onSelectItem = props.onSelectItem;
45
+ onSelectItem = props.onSelectItem,
46
+ viewMoreItem = props.viewMoreItem;
45
47
  var _useContainerWidth = (0, _useContainerWidth2.default)(),
46
48
  containerWidth = _useContainerWidth.containerWidth,
47
49
  ContainerWidthMonitor = _useContainerWidth.ContainerWidthMonitor;
@@ -49,11 +51,12 @@ function StatelessElementBrowser(props) {
49
51
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
50
52
  columnCount = _useState2[0],
51
53
  setColumnCount = _useState2[1];
52
- var _useSelectAndFocusOnA = (0, _useSelectAndFocusOnArrowNavigation.default)(items.length - 1, columnCount),
54
+ var _useSelectAndFocusOnA = (0, _useSelectAndFocusOnArrowNavigation.default)(items.length - 1, columnCount, !!viewMoreItem),
53
55
  selectedItemIndex = _useSelectAndFocusOnA.selectedItemIndex,
54
56
  focusedItemIndex = _useSelectAndFocusOnA.focusedItemIndex,
55
57
  setFocusedItemIndex = _useSelectAndFocusOnA.setFocusedItemIndex,
56
58
  focusOnSearch = _useSelectAndFocusOnA.focusOnSearch,
59
+ focusOnViewMore = _useSelectAndFocusOnA.focusOnViewMore,
57
60
  onKeyDown = _useSelectAndFocusOnA.onKeyDown,
58
61
  setFocusOnSearch = _useSelectAndFocusOnA.setFocusOnSearch;
59
62
  (0, _react.useEffect)(function () {
@@ -84,7 +87,7 @@ function StatelessElementBrowser(props) {
84
87
  /* Only for hitting enter to select item when focused on search bar,
85
88
  * The actual enter key press is handled on individual items level.
86
89
  */
87
- var selectedItem = items[selectedItemIndex];
90
+ var selectedItem = selectedItemIndex !== undefined ? items[selectedItemIndex] : null;
88
91
  var onItemsEnterKeyPress = (0, _react.useCallback)(function (e) {
89
92
  if (e.key !== 'Enter') {
90
93
  return;
@@ -114,7 +117,9 @@ function StatelessElementBrowser(props) {
114
117
  setColumnCount: setColumnCount,
115
118
  setFocusOnSearch: setFocusOnSearch,
116
119
  onKeyPress: onItemsEnterKeyPress,
117
- onKeyDown: onKeyDown
120
+ onKeyDown: onKeyDown,
121
+ viewMoreItem: viewMoreItem,
122
+ focusOnViewMore: focusOnViewMore
118
123
  })) : (0, _react2.jsx)(DesktopBrowser, (0, _extends2.default)({}, props, {
119
124
  selectedItemIndex: selectedItemIndex,
120
125
  focusedItemIndex: focusedItemIndex,
@@ -140,13 +145,15 @@ function MobileBrowser(_ref) {
140
145
  focusedItemIndex = _ref.focusedItemIndex,
141
146
  setFocusedItemIndex = _ref.setFocusedItemIndex,
142
147
  focusOnSearch = _ref.focusOnSearch,
148
+ focusOnViewMore = _ref.focusOnViewMore,
143
149
  setColumnCount = _ref.setColumnCount,
144
150
  setFocusOnSearch = _ref.setFocusOnSearch,
145
151
  onKeyPress = _ref.onKeyPress,
146
152
  onKeyDown = _ref.onKeyDown,
147
153
  searchTerm = _ref.searchTerm,
148
154
  createAnalyticsEvent = _ref.createAnalyticsEvent,
149
- emptyStateHandler = _ref.emptyStateHandler;
155
+ emptyStateHandler = _ref.emptyStateHandler,
156
+ viewMoreItem = _ref.viewMoreItem;
150
157
  return (0, _react2.jsx)("div", {
151
158
  css: mobileElementBrowserContainer,
152
159
  onKeyPress: onKeyPress,
@@ -181,7 +188,10 @@ function MobileBrowser(_ref) {
181
188
  emptyStateHandler: emptyStateHandler,
182
189
  selectedCategory: selectedCategory,
183
190
  searchTerm: searchTerm
184
- })));
191
+ })), viewMoreItem && (0, _react2.jsx)(_ViewMore.ViewMore, {
192
+ item: viewMoreItem,
193
+ focus: focusOnViewMore
194
+ }));
185
195
  }
186
196
  function DesktopBrowser(_ref2) {
187
197
  var showCategories = _ref2.showCategories,
@@ -23,6 +23,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
23
23
  * selectedItemIndex,
24
24
  * focusedItemIndex,
25
25
  * focusOnSearch,
26
+ * focusOnViewMore,
26
27
  * setFocusedItemIndex,
27
28
  * onKeyDown
28
29
  * } = useSelectAndFocusOnArrowNavigation(list.length - 1, 1);
@@ -62,7 +63,8 @@ var reducer = function reducer(state, action) {
62
63
  case ACTIONS.FOCUS_SEARCH:
63
64
  return _objectSpread(_objectSpread({}, state), {}, {
64
65
  focusedItemIndex: undefined,
65
- focusOnSearch: true
66
+ focusOnSearch: true,
67
+ focusOnViewMore: false
66
68
  });
67
69
  case ACTIONS.MOVE:
68
70
  return moveReducer(state, action);
@@ -70,55 +72,123 @@ var reducer = function reducer(state, action) {
70
72
  return state;
71
73
  };
72
74
  var moveReducer = function moveReducer(state, action) {
73
- var newIndex = state.selectedItemIndex + action.payload.positions;
74
-
75
- // The step payload is only sent for up arrow.
76
- // When user presses up arrow on first row, focus on search bar.
77
- if (action.payload.step && state.selectedItemIndex < action.payload.step) {
75
+ var listSize = state.listSize,
76
+ canFocusViewMore = state.canFocusViewMore;
77
+ if (state.focusOnSearch) {
78
+ // up arrow
79
+ if (action.payload.positions && action.payload.positions <= -1) {
80
+ return _objectSpread(_objectSpread({}, state), {}, {
81
+ focusOnSearch: false,
82
+ focusOnViewMore: !!canFocusViewMore,
83
+ focusedItemIndex: canFocusViewMore ? undefined : listSize,
84
+ selectedItemIndex: canFocusViewMore ? undefined : listSize
85
+ });
86
+ } else {
87
+ return _objectSpread(_objectSpread({}, state), {}, {
88
+ focusOnSearch: false,
89
+ focusOnViewMore: false,
90
+ focusedItemIndex: 0,
91
+ selectedItemIndex: 0
92
+ });
93
+ }
94
+ }
95
+ if (state.focusOnViewMore) {
96
+ // down arrow
97
+ if (action.payload.positions === 1) {
98
+ return _objectSpread(_objectSpread({}, state), {}, {
99
+ focusOnSearch: true,
100
+ focusOnViewMore: false,
101
+ focusedItemIndex: undefined,
102
+ // if search is focused then select first item.
103
+ selectedItemIndex: 0
104
+ });
105
+ } else {
106
+ return _objectSpread(_objectSpread({}, state), {}, {
107
+ focusOnSearch: false,
108
+ focusOnViewMore: false,
109
+ focusedItemIndex: listSize,
110
+ selectedItemIndex: listSize
111
+ });
112
+ }
113
+ }
114
+ var newIndex = state.selectedItemIndex ? state.selectedItemIndex + action.payload.positions : action.payload.positions;
115
+ var safeIndex = ensureSafeIndex(newIndex, state.listSize);
116
+ // down arrow key is pressed or right arrow key is pressed.
117
+ if (state.focusedItemIndex !== undefined && action.payload.positions && action.payload.positions >= 1) {
118
+ // when multi column element browser is open and we are in last
119
+ // row then newIndex will be greater than listSize when
120
+ // down arrow key is pressed.
121
+ // Or when last item is focused and down or right arrow key is pressed.
122
+ var isLastItemFocused = newIndex > listSize;
123
+ var focusOnSearch = isLastItemFocused && !canFocusViewMore;
124
+ var focusOnViewMore = isLastItemFocused && !!canFocusViewMore;
125
+ // if search is focused, then select first item.
126
+ // otherwise if view more is focused then select item should be undefined.
127
+ var selectedItemIndex = focusOnSearch ? 0 : focusOnViewMore ? undefined : safeIndex;
78
128
  return _objectSpread(_objectSpread({}, state), {}, {
79
- focusOnSearch: true,
80
- focusedItemIndex: undefined
129
+ focusOnSearch: focusOnSearch,
130
+ focusOnViewMore: focusOnViewMore,
131
+ selectedItemIndex: selectedItemIndex,
132
+ focusedItemIndex: isLastItemFocused ? undefined : safeIndex
81
133
  });
82
134
  }
83
- if (newIndex < 0) {
84
- return state;
85
- }
86
135
 
87
- // Set focus position to first item when moving forward or backward from searchbar
88
- if (state.focusedItemIndex == null || state.focusOnSearch) {
136
+ // up arrow key is pressed or left arrow key is pressed.
137
+ if (state.focusedItemIndex !== undefined && action.payload.positions && action.payload.positions <= -1) {
138
+ // if arrow up key is pressed when focus is in first row,
139
+ // or, arrow left key is pressed when first item is focused,
140
+ // then newIndex will become less than zero.
141
+ // In this case, focus search, and, kept previously selected item.
142
+ var isFirstRowFocused = newIndex < 0;
143
+ // if focus goes to search then kept last selected item in first row.
144
+ var _selectedItemIndex = isFirstRowFocused ? state.selectedItemIndex : safeIndex;
89
145
  return _objectSpread(_objectSpread({}, state), {}, {
90
- focusOnSearch: false,
91
- focusedItemIndex: 0,
92
- selectedItemIndex: 0
146
+ // focus search if first item is focused on up or left arrow key
147
+ focusOnSearch: isFirstRowFocused,
148
+ focusOnViewMore: false,
149
+ focusedItemIndex: isFirstRowFocused ? undefined : safeIndex,
150
+ selectedItemIndex: _selectedItemIndex
93
151
  });
94
152
  }
95
- var safeIndex = ensureSafeIndex(newIndex, state.listSize);
96
153
  return _objectSpread(_objectSpread({}, state), {}, {
97
- focusedItemIndex: safeIndex,
98
- selectedItemIndex: safeIndex
154
+ focusOnSearch: false,
155
+ focusOnViewMore: false,
156
+ selectedItemIndex: safeIndex,
157
+ focusedItemIndex: safeIndex
99
158
  });
100
159
  };
101
160
  var initialState = {
102
161
  focusOnSearch: true,
162
+ focusOnViewMore: false,
103
163
  selectedItemIndex: 0,
104
164
  focusedItemIndex: undefined,
105
165
  listSize: 0
106
166
  };
107
- var getInitialState = function getInitialState(listSize) {
167
+ var getInitialState = function getInitialState(listSize, canFocusViewMore) {
108
168
  return function (initialState) {
109
169
  return _objectSpread(_objectSpread({}, initialState), {}, {
110
- listSize: listSize
170
+ listSize: listSize,
171
+ canFocusViewMore: canFocusViewMore
111
172
  });
112
173
  };
113
174
  };
114
- function useSelectAndFocusOnArrowNavigation(listSize, step) {
115
- var _useReducer = (0, _react.useReducer)(reducer, initialState, getInitialState(listSize)),
175
+ function useSelectAndFocusOnArrowNavigation(listSize, step, canFocusViewMore) {
176
+ var _useReducer = (0, _react.useReducer)(reducer, initialState, getInitialState(listSize, canFocusViewMore)),
116
177
  _useReducer2 = (0, _slicedToArray2.default)(_useReducer, 2),
117
178
  state = _useReducer2[0],
118
179
  dispatch = _useReducer2[1];
180
+ (0, _react.useEffect)(function () {
181
+ dispatch({
182
+ type: ACTIONS.UPDATE_STATE,
183
+ payload: {
184
+ canFocusViewMore: canFocusViewMore
185
+ }
186
+ });
187
+ }, [canFocusViewMore]);
119
188
  var selectedItemIndex = state.selectedItemIndex,
120
189
  focusedItemIndex = state.focusedItemIndex,
121
- focusOnSearch = state.focusOnSearch;
190
+ focusOnSearch = state.focusOnSearch,
191
+ focusOnViewMore = state.focusOnViewMore;
122
192
  var reset = (0, _react.useCallback)(function (listSize) {
123
193
  var payload = _objectSpread(_objectSpread({}, initialState), {}, {
124
194
  listSize: listSize
@@ -132,7 +202,8 @@ function useSelectAndFocusOnArrowNavigation(listSize, step) {
132
202
  var payload = {
133
203
  focusedItemIndex: index,
134
204
  selectedItemIndex: index,
135
- focusOnSearch: false
205
+ focusOnSearch: false,
206
+ focusOnViewMore: false
136
207
  };
137
208
  dispatch({
138
209
  type: ACTIONS.UPDATE_STATE,
@@ -168,7 +239,7 @@ function useSelectAndFocusOnArrowNavigation(listSize, step) {
168
239
  var onKeyDown = (0, _react.useCallback)(function (e) {
169
240
  var avoidKeysWhileSearching = ['/',
170
241
  // While already focused on search bar, let users type in.
171
- 'ArrowRight', 'ArrowLeft', 'ArrowUp'];
242
+ 'ArrowRight', 'ArrowLeft'];
172
243
  if (focusOnSearch && avoidKeysWhileSearching.includes(e.key)) {
173
244
  return;
174
245
  }
@@ -195,6 +266,7 @@ function useSelectAndFocusOnArrowNavigation(listSize, step) {
195
266
  selectedItemIndex: selectedItemIndex,
196
267
  onKeyDown: onKeyDown,
197
268
  focusOnSearch: focusOnSearch,
269
+ focusOnViewMore: focusOnViewMore,
198
270
  setFocusOnSearch: setFocusOnSearch,
199
271
  focusedItemIndex: focusedItemIndex,
200
272
  setFocusedItemIndex: removeFocusFromSearchAndSetOnItem
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "185.2.5";
9
+ var version = "185.2.8";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.2.5",
3
+ "version": "185.2.8",
4
4
  "sideEffects": false
5
5
  }
@@ -6,14 +6,14 @@ import inputRulePlugin from './pm-plugins/input-rule';
6
6
  import ToolbarBlockType from './ui/ToolbarBlockType';
7
7
  import WithPluginState from '../../ui/WithPluginState';
8
8
  import { setBlockTypeWithAnalytics } from './commands';
9
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, INPUT_METHOD } from '../analytics';
9
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
10
10
  import * as keymaps from '../../keymaps';
11
11
  import { IconHeading, IconQuote } from '../quick-insert/assets';
12
12
  import { messages } from './messages';
13
13
  import { ToolbarSize } from '../../ui/Toolbar/types';
14
14
  const headingPluginOptions = ({
15
15
  formatMessage
16
- }, isAllowed) => {
16
+ }, isAllowed, editorAnalyticsApi) => {
17
17
  if (!isAllowed) {
18
18
  return [];
19
19
  }
@@ -38,7 +38,7 @@ const headingPluginOptions = ({
38
38
  const tr = insert(state.schema.nodes.heading.createChecked({
39
39
  level
40
40
  }));
41
- return addAnalytics(state, tr, {
41
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
42
42
  action: ACTION.FORMATTED,
43
43
  actionSubject: ACTION_SUBJECT.TEXT,
44
44
  eventType: EVENT_TYPE.TRACK,
@@ -47,14 +47,15 @@ const headingPluginOptions = ({
47
47
  inputMethod: INPUT_METHOD.QUICK_INSERT,
48
48
  newHeadingLevel: level
49
49
  }
50
- });
50
+ })(tr);
51
+ return tr;
51
52
  }
52
53
  };
53
54
  });
54
55
  };
55
56
  const blockquotePluginOptions = ({
56
57
  formatMessage
57
- }, isAllowed) => {
58
+ }, isAllowed, editorAnalyticsApi) => {
58
59
  if (!isAllowed) {
59
60
  return [];
60
61
  }
@@ -67,7 +68,7 @@ const blockquotePluginOptions = ({
67
68
  icon: () => /*#__PURE__*/React.createElement(IconQuote, null),
68
69
  action(insert, state) {
69
70
  const tr = insert(state.schema.nodes.blockquote.createChecked({}, state.schema.nodes.paragraph.createChecked()));
70
- return addAnalytics(state, tr, {
71
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
71
72
  action: ACTION.FORMATTED,
72
73
  actionSubject: ACTION_SUBJECT.TEXT,
73
74
  eventType: EVENT_TYPE.TRACK,
@@ -75,11 +76,12 @@ const blockquotePluginOptions = ({
75
76
  attributes: {
76
77
  inputMethod: INPUT_METHOD.QUICK_INSERT
77
78
  }
78
- });
79
+ })(tr);
80
+ return tr;
79
81
  }
80
82
  }];
81
83
  };
82
- const blockTypePlugin = options => ({
84
+ const blockTypePlugin = (options, api) => ({
83
85
  name: 'blockType',
84
86
  nodes() {
85
87
  const nodes = [{
@@ -157,8 +159,9 @@ const blockTypePlugin = options => ({
157
159
  },
158
160
  pluginsOptions: {
159
161
  quickInsert: intl => {
162
+ var _api$dependencies$ana, _api$dependencies$ana2;
160
163
  const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
161
- return [...blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1), ...headingPluginOptions(intl, exclude.indexOf('heading') === -1)];
164
+ return [...blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions), ...headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions)];
162
165
  }
163
166
  }
164
167
  });
@@ -85,7 +85,8 @@ export default class ElementBrowser extends PureComponent {
85
85
  showSearch,
86
86
  showCategories,
87
87
  mode,
88
- emptyStateHandler
88
+ emptyStateHandler,
89
+ viewMoreItem
89
90
  } = this.props;
90
91
  const {
91
92
  categories,
@@ -105,7 +106,8 @@ export default class ElementBrowser extends PureComponent {
105
106
  showCategories: showCategories,
106
107
  mode: mode,
107
108
  searchTerm: searchTerm,
108
- emptyStateHandler: emptyStateHandler
109
+ emptyStateHandler: emptyStateHandler,
110
+ viewMoreItem: viewMoreItem
109
111
  });
110
112
  }
111
113
  }