@atlaskit/editor-common 121.4.0 → 121.4.2

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 +26 -0
  2. package/dist/cjs/monitoring/error.js +1 -1
  3. package/dist/cjs/quick-insert/{TypeAheadQuickInsertMenuItem.js → CompactQuickInsertMenuItem.js} +4 -4
  4. package/dist/cjs/quick-insert/QuickInsertMenuItem.js +2 -2
  5. package/dist/cjs/quick-insert/build-quick-insert-menu-model.js +75 -0
  6. package/dist/cjs/quick-insert/get-matching-quick-insert-components.js +117 -0
  7. package/dist/cjs/quick-insert/registered-menu-model.js +19 -0
  8. package/dist/cjs/ui/DropList/index.js +1 -1
  9. package/dist/es2019/monitoring/error.js +1 -1
  10. package/dist/es2019/quick-insert/{TypeAheadQuickInsertMenuItem.js → CompactQuickInsertMenuItem.js} +3 -3
  11. package/dist/es2019/quick-insert/QuickInsertMenuItem.js +2 -2
  12. package/dist/es2019/quick-insert/build-quick-insert-menu-model.js +52 -0
  13. package/dist/es2019/quick-insert/get-matching-quick-insert-components.js +78 -0
  14. package/dist/es2019/quick-insert/registered-menu-model.js +3 -0
  15. package/dist/es2019/ui/DropList/index.js +1 -1
  16. package/dist/esm/monitoring/error.js +1 -1
  17. package/dist/esm/quick-insert/{TypeAheadQuickInsertMenuItem.js → CompactQuickInsertMenuItem.js} +3 -3
  18. package/dist/esm/quick-insert/QuickInsertMenuItem.js +2 -2
  19. package/dist/esm/quick-insert/build-quick-insert-menu-model.js +68 -0
  20. package/dist/esm/quick-insert/get-matching-quick-insert-components.js +111 -0
  21. package/dist/esm/quick-insert/registered-menu-model.js +3 -0
  22. package/dist/esm/ui/DropList/index.js +1 -1
  23. package/dist/types/analytics/types/insert-events.d.ts +1 -1
  24. package/dist/types/analytics/types/list-events.d.ts +1 -1
  25. package/dist/types/provider-factory/quick-insert-provider.d.ts +1 -1
  26. package/dist/types/quick-insert/CompactQuickInsertMenuItem.d.ts +3 -0
  27. package/dist/types/quick-insert/QuickInsertContext.d.ts +2 -2
  28. package/dist/types/quick-insert/QuickInsertMenuItem.d.ts +1 -1
  29. package/dist/types/quick-insert/build-quick-insert-menu-model.d.ts +9 -0
  30. package/dist/types/quick-insert/get-matching-quick-insert-components.d.ts +15 -0
  31. package/dist/types/quick-insert/registered-menu-model.d.ts +3 -0
  32. package/dist/types/styles/shared/headings.d.ts +1 -1
  33. package/package.json +5 -5
  34. package/quick-insert/registered-menu-model/package.json +10 -0
  35. package/dist/types/quick-insert/TypeAheadQuickInsertMenuItem.d.ts +0 -3
  36. /package/dist/cjs/quick-insert/{TypeAheadQuickInsertMenuItem.compiled.css → CompactQuickInsertMenuItem.compiled.css} +0 -0
  37. /package/dist/es2019/quick-insert/{TypeAheadQuickInsertMenuItem.compiled.css → CompactQuickInsertMenuItem.compiled.css} +0 -0
  38. /package/dist/esm/quick-insert/{TypeAheadQuickInsertMenuItem.compiled.css → CompactQuickInsertMenuItem.compiled.css} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 121.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 121.4.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`df59babd59961`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/df59babd59961) -
14
+ Use registered Quick Insert items in both primary toolbar implementations when
15
+ `platform_editor_slash_command` is enabled, independently of the controls and AIFC experiments.
16
+ Share the registered menu model through an explicit editor-common subpath and use compact
17
+ presentation for typeahead and toolbar items.
18
+
19
+ Virtualize the toolbar menu, keep keyboard-selected items visible, and restore the bounded popup's
20
+ themed background and scrolling. Dismiss the popup on outside clicks and inset the search field
21
+ from its edges. When the experiment is enabled, ignore absent legacy Quick Insert handlers to
22
+ prevent suggestion crashes.
23
+
24
+ Provide persisted toolbar docking preferences in editor examples to support testing the primary
25
+ toolbar Insert menu.
26
+
27
+ - Updated dependencies
28
+
3
29
  ## 121.4.0
4
30
 
5
31
  ### Minor Changes
@@ -27,7 +27,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
27
27
  var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
28
28
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
29
29
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
30
- var packageVersion = "121.3.1";
30
+ var packageVersion = "121.4.2";
31
31
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
32
32
  // Remove URL as it has UGC
33
33
  // Ignored via go/ees007
@@ -1,12 +1,12 @@
1
- /* TypeAheadQuickInsertMenuItem.tsx generated by @compiled/babel-plugin v3.0.1 */
1
+ /* CompactQuickInsertMenuItem.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.TypeAheadQuickInsertMenuItem = void 0;
9
- require("./TypeAheadQuickInsertMenuItem.compiled.css");
8
+ exports.CompactQuickInsertMenuItem = void 0;
9
+ require("./CompactQuickInsertMenuItem.compiled.css");
10
10
  var _runtime = require("@compiled/react/runtime");
11
11
  var _react = _interopRequireDefault(require("react"));
12
12
  var _buttonItem = _interopRequireDefault(require("@atlaskit/menu/button-item"));
@@ -75,7 +75,7 @@ var disabledItemStyles = (0, _primitives.xcss)({
75
75
  textAlign: 'start',
76
76
  width: '100%'
77
77
  });
78
- var TypeAheadQuickInsertMenuItem = exports.TypeAheadQuickInsertMenuItem = function TypeAheadQuickInsertMenuItem(_ref) {
78
+ var CompactQuickInsertMenuItem = exports.CompactQuickInsertMenuItem = function CompactQuickInsertMenuItem(_ref) {
79
79
  var ariaLabel = _ref.ariaLabel,
80
80
  iconBefore = _ref.iconBefore,
81
81
  isDisabled = _ref.isDisabled,
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.QuickInsertMenuItem = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _ElementBrowserQuickInsertMenuItem = require("./ElementBrowserQuickInsertMenuItem");
10
- var _TypeAheadQuickInsertMenuItem = require("./TypeAheadQuickInsertMenuItem");
10
+ var _CompactQuickInsertMenuItem = require("./CompactQuickInsertMenuItem");
11
11
  var _useQuickInsertContext = require("./useQuickInsertContext");
12
12
  var QuickInsertMenuItem = exports.QuickInsertMenuItem = function QuickInsertMenuItem(_ref) {
13
13
  var ariaLabel = _ref.ariaLabel,
@@ -29,7 +29,7 @@ var QuickInsertMenuItem = exports.QuickInsertMenuItem = function QuickInsertMenu
29
29
  shortcut: shortcut,
30
30
  shouldWrapIcon: shouldWrapIcon,
31
31
  title: title
32
- }) : /*#__PURE__*/_react.default.createElement(_TypeAheadQuickInsertMenuItem.TypeAheadQuickInsertMenuItem, {
32
+ }) : /*#__PURE__*/_react.default.createElement(_CompactQuickInsertMenuItem.CompactQuickInsertMenuItem, {
33
33
  ariaLabel: ariaLabel,
34
34
  description: description,
35
35
  iconBefore: iconBefore,
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.buildQuickInsertMenuModel = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _isMenuFooterSectionKey = require("../type-ahead/isMenuFooterSectionKey");
10
+ var _isSectionOverflowItemKey = require("../type-ahead/isSectionOverflowItemKey");
11
+ var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
12
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
13
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
14
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
15
+ var buildQuickInsertMenuModel = exports.buildQuickInsertMenuModel = function buildQuickInsertMenuModel(components, rootComponent, sectionOverflowLimit, surfaceContext) {
16
+ var _resolveSurface = (0, _surfaceRenderer.resolveSurface)(components, rootComponent),
17
+ root = _resolveSurface.root,
18
+ childrenMap = _resolveSurface.childrenMap,
19
+ topLevelChildren = _resolveSurface.topLevelChildren;
20
+ if (!root || !(0, _surfaceRenderer.willComponentRender)(root, childrenMap, surfaceContext)) {
21
+ return {
22
+ footer: undefined,
23
+ root: undefined,
24
+ sections: []
25
+ };
26
+ }
27
+ var sections = [];
28
+ var footer;
29
+ var _iterator = _createForOfIteratorHelper(topLevelChildren !== null && topLevelChildren !== void 0 ? topLevelChildren : []),
30
+ _step;
31
+ try {
32
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
33
+ var _childrenMap$get;
34
+ var section = _step.value;
35
+ if (section.type !== 'menu-section' || !(0, _surfaceRenderer.willComponentRender)(section, childrenMap, surfaceContext)) {
36
+ continue;
37
+ }
38
+ var children = (_childrenMap$get = childrenMap.get((0, _surfaceRenderer.getComponentIdentity)(section))) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : [];
39
+ if ((0, _isMenuFooterSectionKey.isMenuFooterSectionKey)(section.key)) {
40
+ footer = children.find(function (child) {
41
+ return child.type === 'menu-item' && (0, _surfaceRenderer.willComponentRender)(child, childrenMap, surfaceContext);
42
+ });
43
+ continue;
44
+ }
45
+ var viewMoreItem = void 0;
46
+ for (var index = children.length - 1; index >= 0; index--) {
47
+ var child = children[index];
48
+ if ((child === null || child === void 0 ? void 0 : child.type) === 'menu-item' && (0, _isSectionOverflowItemKey.isSectionOverflowItemKey)(child.key) && (0, _surfaceRenderer.willComponentRender)(child, childrenMap, surfaceContext)) {
49
+ viewMoreItem = child;
50
+ break;
51
+ }
52
+ }
53
+ var items = children.filter(function (child) {
54
+ return child.type === 'menu-item' && !(0, _isSectionOverflowItemKey.isSectionOverflowItemKey)(child.key) && (0, _surfaceRenderer.willComponentRender)(child, childrenMap, surfaceContext);
55
+ });
56
+ if (items.length === 0) {
57
+ continue;
58
+ }
59
+ if (sectionOverflowLimit !== undefined && viewMoreItem !== undefined && items.length > sectionOverflowLimit) {
60
+ sections.push([section].concat((0, _toConsumableArray2.default)(items.slice(0, sectionOverflowLimit)), [viewMoreItem]));
61
+ continue;
62
+ }
63
+ sections.push([section].concat((0, _toConsumableArray2.default)(items)));
64
+ }
65
+ } catch (err) {
66
+ _iterator.e(err);
67
+ } finally {
68
+ _iterator.f();
69
+ }
70
+ return {
71
+ footer: footer,
72
+ root: root,
73
+ sections: sections
74
+ };
75
+ };
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getMatchingQuickInsertComponents = void 0;
7
+ var _isMenuFooterSectionKey = require("../type-ahead/isMenuFooterSectionKey");
8
+ var _isSectionOverflowItemKey = require("../type-ahead/isSectionOverflowItemKey");
9
+ var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
10
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
11
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
13
+ var getRank = function getRank(component, parentKey) {
14
+ var _component$parents$fi, _component$parents;
15
+ return (_component$parents$fi = (_component$parents = component.parents) === null || _component$parents === void 0 || (_component$parents = _component$parents.find(function (parent) {
16
+ return parent.key === parentKey;
17
+ })) === null || _component$parents === void 0 ? void 0 : _component$parents.rank) !== null && _component$parents$fi !== void 0 ? _component$parents$fi : Number.MAX_SAFE_INTEGER;
18
+ };
19
+ var compareMatchedItems = function compareMatchedItems(a, b) {
20
+ return a.score - b.score || a.sectionRank - b.sectionRank || a.itemRank - b.itemRank || a.identity.localeCompare(b.identity);
21
+ };
22
+
23
+ /**
24
+ * Resolves registered menu items for a non-empty query. This intentionally has
25
+ * no empty-query path so browse behavior remains owned by buildQuickInsertMenuModel.
26
+ */
27
+ var getMatchingQuickInsertComponents = exports.getMatchingQuickInsertComponents = function getMatchingQuickInsertComponents(_ref) {
28
+ var components = _ref.components,
29
+ rootComponent = _ref.rootComponent,
30
+ query = _ref.query,
31
+ formatMessage = _ref.formatMessage,
32
+ surfaceContext = _ref.surfaceContext;
33
+ var _resolveSurface = (0, _surfaceRenderer.resolveSurface)(components, rootComponent),
34
+ childrenMap = _resolveSurface.childrenMap,
35
+ root = _resolveSurface.root,
36
+ topLevelChildren = _resolveSurface.topLevelChildren;
37
+ if (!root || !(0, _surfaceRenderer.willComponentRender)(root, childrenMap, surfaceContext) || !topLevelChildren) {
38
+ return {
39
+ footer: undefined,
40
+ root: undefined,
41
+ sections: []
42
+ };
43
+ }
44
+ var matches = new Map();
45
+ var _iterator = _createForOfIteratorHelper(topLevelChildren),
46
+ _step;
47
+ try {
48
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
49
+ var _childrenMap$get;
50
+ var section = _step.value;
51
+ if (section.type !== 'menu-section' || (0, _isMenuFooterSectionKey.isMenuFooterSectionKey)(section.key) || !(0, _surfaceRenderer.willComponentRender)(section, childrenMap, surfaceContext)) {
52
+ continue;
53
+ }
54
+ var _iterator3 = _createForOfIteratorHelper((_childrenMap$get = childrenMap.get((0, _surfaceRenderer.getComponentIdentity)(section))) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : []),
55
+ _step3;
56
+ try {
57
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
58
+ var _item$match, _match$score;
59
+ var item = _step3.value;
60
+ if (item.type !== 'menu-item' || (0, _isSectionOverflowItemKey.isSectionOverflowItemKey)(item.key) || !(0, _surfaceRenderer.willComponentRender)(item, childrenMap, surfaceContext)) {
61
+ continue;
62
+ }
63
+ var match = (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.call(item, {
64
+ formatMessage: formatMessage,
65
+ query: query
66
+ });
67
+ if (item.match && match === null) {
68
+ continue;
69
+ }
70
+ var candidate = {
71
+ identity: "".concat(item.type, ":").concat(item.key),
72
+ item: item,
73
+ itemRank: getRank(item, section.key),
74
+ score: Math.min(1, Math.max(0, (_match$score = match === null || match === void 0 ? void 0 : match.score) !== null && _match$score !== void 0 ? _match$score : 0)),
75
+ section: section,
76
+ sectionRank: getRank(section, root.key)
77
+ };
78
+ var existing = matches.get(candidate.identity);
79
+ if (!existing || compareMatchedItems(candidate, existing) < 0) {
80
+ matches.set(candidate.identity, candidate);
81
+ }
82
+ }
83
+ } catch (err) {
84
+ _iterator3.e(err);
85
+ } finally {
86
+ _iterator3.f();
87
+ }
88
+ }
89
+ } catch (err) {
90
+ _iterator.e(err);
91
+ } finally {
92
+ _iterator.f();
93
+ }
94
+ var sectionsByKey = new Map();
95
+ var _iterator2 = _createForOfIteratorHelper(Array.from(matches.values()).sort(compareMatchedItems)),
96
+ _step2;
97
+ try {
98
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
99
+ var _match = _step2.value;
100
+ var _existing = sectionsByKey.get(_match.section.key);
101
+ if (_existing) {
102
+ _existing.push(_match.item);
103
+ } else {
104
+ sectionsByKey.set(_match.section.key, [_match.section, _match.item]);
105
+ }
106
+ }
107
+ } catch (err) {
108
+ _iterator2.e(err);
109
+ } finally {
110
+ _iterator2.f();
111
+ }
112
+ return {
113
+ footer: undefined,
114
+ root: root,
115
+ sections: Array.from(sectionsByKey.values())
116
+ };
117
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "buildQuickInsertMenuModel", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _buildQuickInsertMenuModel.buildQuickInsertMenuModel;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "getMatchingQuickInsertComponents", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _getMatchingQuickInsertComponents.getMatchingQuickInsertComponents;
16
+ }
17
+ });
18
+ var _buildQuickInsertMenuModel = require("./build-quick-insert-menu-model");
19
+ var _getMatchingQuickInsertComponents = require("./get-matching-quick-insert-components");
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
24
24
  * @jsx jsx
25
25
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "121.3.1";
27
+ var packageVersion = "121.4.2";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -13,7 +13,7 @@ const NETWORK_FAILURE_REGEX = /^network failure/i;
13
13
  const RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
14
14
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
15
15
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
16
- const packageVersion = "121.3.1";
16
+ const packageVersion = "121.4.2";
17
17
  const sanitiseSentryEvents = (data, _hint) => {
18
18
  // Remove URL as it has UGC
19
19
  // Ignored via go/ees007
@@ -1,5 +1,5 @@
1
- /* TypeAheadQuickInsertMenuItem.tsx generated by @compiled/babel-plugin v3.0.1 */
2
- import "./TypeAheadQuickInsertMenuItem.compiled.css";
1
+ /* CompactQuickInsertMenuItem.tsx generated by @compiled/babel-plugin v3.0.1 */
2
+ import "./CompactQuickInsertMenuItem.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
5
5
  import ButtonItem from '@atlaskit/menu/button-item';
@@ -68,7 +68,7 @@ const disabledItemStyles = xcss({
68
68
  textAlign: 'start',
69
69
  width: '100%'
70
70
  });
71
- export const TypeAheadQuickInsertMenuItem = ({
71
+ export const CompactQuickInsertMenuItem = ({
72
72
  ariaLabel,
73
73
  iconBefore,
74
74
  isDisabled,
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ElementBrowserQuickInsertMenuItem } from './ElementBrowserQuickInsertMenuItem';
3
- import { TypeAheadQuickInsertMenuItem } from './TypeAheadQuickInsertMenuItem';
3
+ import { CompactQuickInsertMenuItem } from './CompactQuickInsertMenuItem';
4
4
  import { useQuickInsertContext } from './useQuickInsertContext';
5
5
  export const QuickInsertMenuItem = ({
6
6
  ariaLabel,
@@ -24,7 +24,7 @@ export const QuickInsertMenuItem = ({
24
24
  shortcut: shortcut,
25
25
  shouldWrapIcon: shouldWrapIcon,
26
26
  title: title
27
- }) : /*#__PURE__*/React.createElement(TypeAheadQuickInsertMenuItem, {
27
+ }) : /*#__PURE__*/React.createElement(CompactQuickInsertMenuItem, {
28
28
  ariaLabel: ariaLabel,
29
29
  description: description,
30
30
  iconBefore: iconBefore,
@@ -0,0 +1,52 @@
1
+ import { isMenuFooterSectionKey } from '../type-ahead/isMenuFooterSectionKey';
2
+ import { isSectionOverflowItemKey } from '../type-ahead/isSectionOverflowItemKey';
3
+ import { getComponentIdentity, resolveSurface, willComponentRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
4
+ export const buildQuickInsertMenuModel = (components, rootComponent, sectionOverflowLimit, surfaceContext) => {
5
+ const {
6
+ root,
7
+ childrenMap,
8
+ topLevelChildren
9
+ } = resolveSurface(components, rootComponent);
10
+ if (!root || !willComponentRender(root, childrenMap, surfaceContext)) {
11
+ return {
12
+ footer: undefined,
13
+ root: undefined,
14
+ sections: []
15
+ };
16
+ }
17
+ const sections = [];
18
+ let footer;
19
+ for (const section of topLevelChildren !== null && topLevelChildren !== void 0 ? topLevelChildren : []) {
20
+ var _childrenMap$get;
21
+ if (section.type !== 'menu-section' || !willComponentRender(section, childrenMap, surfaceContext)) {
22
+ continue;
23
+ }
24
+ const children = (_childrenMap$get = childrenMap.get(getComponentIdentity(section))) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : [];
25
+ if (isMenuFooterSectionKey(section.key)) {
26
+ footer = children.find(child => child.type === 'menu-item' && willComponentRender(child, childrenMap, surfaceContext));
27
+ continue;
28
+ }
29
+ let viewMoreItem;
30
+ for (let index = children.length - 1; index >= 0; index--) {
31
+ const child = children[index];
32
+ if ((child === null || child === void 0 ? void 0 : child.type) === 'menu-item' && isSectionOverflowItemKey(child.key) && willComponentRender(child, childrenMap, surfaceContext)) {
33
+ viewMoreItem = child;
34
+ break;
35
+ }
36
+ }
37
+ const items = children.filter(child => child.type === 'menu-item' && !isSectionOverflowItemKey(child.key) && willComponentRender(child, childrenMap, surfaceContext));
38
+ if (items.length === 0) {
39
+ continue;
40
+ }
41
+ if (sectionOverflowLimit !== undefined && viewMoreItem !== undefined && items.length > sectionOverflowLimit) {
42
+ sections.push([section, ...items.slice(0, sectionOverflowLimit), viewMoreItem]);
43
+ continue;
44
+ }
45
+ sections.push([section, ...items]);
46
+ }
47
+ return {
48
+ footer,
49
+ root,
50
+ sections
51
+ };
52
+ };
@@ -0,0 +1,78 @@
1
+ import { isMenuFooterSectionKey } from '../type-ahead/isMenuFooterSectionKey';
2
+ import { isSectionOverflowItemKey } from '../type-ahead/isSectionOverflowItemKey';
3
+ import { getComponentIdentity, resolveSurface, willComponentRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
4
+ const getRank = (component, parentKey) => {
5
+ var _component$parents$fi, _component$parents, _component$parents$fi2;
6
+ return (_component$parents$fi = (_component$parents = component.parents) === null || _component$parents === void 0 ? void 0 : (_component$parents$fi2 = _component$parents.find(parent => parent.key === parentKey)) === null || _component$parents$fi2 === void 0 ? void 0 : _component$parents$fi2.rank) !== null && _component$parents$fi !== void 0 ? _component$parents$fi : Number.MAX_SAFE_INTEGER;
7
+ };
8
+ const compareMatchedItems = (a, b) => a.score - b.score || a.sectionRank - b.sectionRank || a.itemRank - b.itemRank || a.identity.localeCompare(b.identity);
9
+
10
+ /**
11
+ * Resolves registered menu items for a non-empty query. This intentionally has
12
+ * no empty-query path so browse behavior remains owned by buildQuickInsertMenuModel.
13
+ */
14
+ export const getMatchingQuickInsertComponents = ({
15
+ components,
16
+ rootComponent,
17
+ query,
18
+ formatMessage,
19
+ surfaceContext
20
+ }) => {
21
+ const {
22
+ childrenMap,
23
+ root,
24
+ topLevelChildren
25
+ } = resolveSurface(components, rootComponent);
26
+ if (!root || !willComponentRender(root, childrenMap, surfaceContext) || !topLevelChildren) {
27
+ return {
28
+ footer: undefined,
29
+ root: undefined,
30
+ sections: []
31
+ };
32
+ }
33
+ const matches = new Map();
34
+ for (const section of topLevelChildren) {
35
+ if (section.type !== 'menu-section' || isMenuFooterSectionKey(section.key) || !willComponentRender(section, childrenMap, surfaceContext)) {
36
+ continue;
37
+ }
38
+ for (const item of (_childrenMap$get = childrenMap.get(getComponentIdentity(section))) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : []) {
39
+ var _childrenMap$get, _item$match, _match$score;
40
+ if (item.type !== 'menu-item' || isSectionOverflowItemKey(item.key) || !willComponentRender(item, childrenMap, surfaceContext)) {
41
+ continue;
42
+ }
43
+ const match = (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.call(item, {
44
+ formatMessage,
45
+ query
46
+ });
47
+ if (item.match && match === null) {
48
+ continue;
49
+ }
50
+ const candidate = {
51
+ identity: `${item.type}:${item.key}`,
52
+ item,
53
+ itemRank: getRank(item, section.key),
54
+ score: Math.min(1, Math.max(0, (_match$score = match === null || match === void 0 ? void 0 : match.score) !== null && _match$score !== void 0 ? _match$score : 0)),
55
+ section,
56
+ sectionRank: getRank(section, root.key)
57
+ };
58
+ const existing = matches.get(candidate.identity);
59
+ if (!existing || compareMatchedItems(candidate, existing) < 0) {
60
+ matches.set(candidate.identity, candidate);
61
+ }
62
+ }
63
+ }
64
+ const sectionsByKey = new Map();
65
+ for (const match of Array.from(matches.values()).sort(compareMatchedItems)) {
66
+ const existing = sectionsByKey.get(match.section.key);
67
+ if (existing) {
68
+ existing.push(match.item);
69
+ } else {
70
+ sectionsByKey.set(match.section.key, [match.section, match.item]);
71
+ }
72
+ }
73
+ return {
74
+ footer: undefined,
75
+ root,
76
+ sections: Array.from(sectionsByKey.values())
77
+ };
78
+ };
@@ -0,0 +1,3 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ export { buildQuickInsertMenuModel } from './build-quick-insert-menu-model';
3
+ export { getMatchingQuickInsertComponents } from './get-matching-quick-insert-components';
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import { fg } from '@atlaskit/platform-feature-flags/fg';
15
15
  import Layer from '../Layer';
16
16
  const packageName = "@atlaskit/editor-common";
17
- const packageVersion = "121.3.1";
17
+ const packageVersion = "121.4.2";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -19,7 +19,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
19
19
  var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
20
20
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
21
21
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
22
- var packageVersion = "121.3.1";
22
+ var packageVersion = "121.4.2";
23
23
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
24
24
  // Remove URL as it has UGC
25
25
  // Ignored via go/ees007
@@ -1,5 +1,5 @@
1
- /* TypeAheadQuickInsertMenuItem.tsx generated by @compiled/babel-plugin v3.0.1 */
2
- import "./TypeAheadQuickInsertMenuItem.compiled.css";
1
+ /* CompactQuickInsertMenuItem.tsx generated by @compiled/babel-plugin v3.0.1 */
2
+ import "./CompactQuickInsertMenuItem.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
5
5
  import ButtonItem from '@atlaskit/menu/button-item';
@@ -68,7 +68,7 @@ var disabledItemStyles = xcss({
68
68
  textAlign: 'start',
69
69
  width: '100%'
70
70
  });
71
- export var TypeAheadQuickInsertMenuItem = function TypeAheadQuickInsertMenuItem(_ref) {
71
+ export var CompactQuickInsertMenuItem = function CompactQuickInsertMenuItem(_ref) {
72
72
  var ariaLabel = _ref.ariaLabel,
73
73
  iconBefore = _ref.iconBefore,
74
74
  isDisabled = _ref.isDisabled,
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ElementBrowserQuickInsertMenuItem } from './ElementBrowserQuickInsertMenuItem';
3
- import { TypeAheadQuickInsertMenuItem } from './TypeAheadQuickInsertMenuItem';
3
+ import { CompactQuickInsertMenuItem } from './CompactQuickInsertMenuItem';
4
4
  import { useQuickInsertContext } from './useQuickInsertContext';
5
5
  export var QuickInsertMenuItem = function QuickInsertMenuItem(_ref) {
6
6
  var ariaLabel = _ref.ariaLabel,
@@ -22,7 +22,7 @@ export var QuickInsertMenuItem = function QuickInsertMenuItem(_ref) {
22
22
  shortcut: shortcut,
23
23
  shouldWrapIcon: shouldWrapIcon,
24
24
  title: title
25
- }) : /*#__PURE__*/React.createElement(TypeAheadQuickInsertMenuItem, {
25
+ }) : /*#__PURE__*/React.createElement(CompactQuickInsertMenuItem, {
26
26
  ariaLabel: ariaLabel,
27
27
  description: description,
28
28
  iconBefore: iconBefore,
@@ -0,0 +1,68 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ import { isMenuFooterSectionKey } from '../type-ahead/isMenuFooterSectionKey';
6
+ import { isSectionOverflowItemKey } from '../type-ahead/isSectionOverflowItemKey';
7
+ import { getComponentIdentity, resolveSurface, willComponentRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
8
+ export var buildQuickInsertMenuModel = function buildQuickInsertMenuModel(components, rootComponent, sectionOverflowLimit, surfaceContext) {
9
+ var _resolveSurface = resolveSurface(components, rootComponent),
10
+ root = _resolveSurface.root,
11
+ childrenMap = _resolveSurface.childrenMap,
12
+ topLevelChildren = _resolveSurface.topLevelChildren;
13
+ if (!root || !willComponentRender(root, childrenMap, surfaceContext)) {
14
+ return {
15
+ footer: undefined,
16
+ root: undefined,
17
+ sections: []
18
+ };
19
+ }
20
+ var sections = [];
21
+ var footer;
22
+ var _iterator = _createForOfIteratorHelper(topLevelChildren !== null && topLevelChildren !== void 0 ? topLevelChildren : []),
23
+ _step;
24
+ try {
25
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
26
+ var _childrenMap$get;
27
+ var section = _step.value;
28
+ if (section.type !== 'menu-section' || !willComponentRender(section, childrenMap, surfaceContext)) {
29
+ continue;
30
+ }
31
+ var children = (_childrenMap$get = childrenMap.get(getComponentIdentity(section))) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : [];
32
+ if (isMenuFooterSectionKey(section.key)) {
33
+ footer = children.find(function (child) {
34
+ return child.type === 'menu-item' && willComponentRender(child, childrenMap, surfaceContext);
35
+ });
36
+ continue;
37
+ }
38
+ var viewMoreItem = void 0;
39
+ for (var index = children.length - 1; index >= 0; index--) {
40
+ var child = children[index];
41
+ if ((child === null || child === void 0 ? void 0 : child.type) === 'menu-item' && isSectionOverflowItemKey(child.key) && willComponentRender(child, childrenMap, surfaceContext)) {
42
+ viewMoreItem = child;
43
+ break;
44
+ }
45
+ }
46
+ var items = children.filter(function (child) {
47
+ return child.type === 'menu-item' && !isSectionOverflowItemKey(child.key) && willComponentRender(child, childrenMap, surfaceContext);
48
+ });
49
+ if (items.length === 0) {
50
+ continue;
51
+ }
52
+ if (sectionOverflowLimit !== undefined && viewMoreItem !== undefined && items.length > sectionOverflowLimit) {
53
+ sections.push([section].concat(_toConsumableArray(items.slice(0, sectionOverflowLimit)), [viewMoreItem]));
54
+ continue;
55
+ }
56
+ sections.push([section].concat(_toConsumableArray(items)));
57
+ }
58
+ } catch (err) {
59
+ _iterator.e(err);
60
+ } finally {
61
+ _iterator.f();
62
+ }
63
+ return {
64
+ footer: footer,
65
+ root: root,
66
+ sections: sections
67
+ };
68
+ };
@@ -0,0 +1,111 @@
1
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
2
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4
+ import { isMenuFooterSectionKey } from '../type-ahead/isMenuFooterSectionKey';
5
+ import { isSectionOverflowItemKey } from '../type-ahead/isSectionOverflowItemKey';
6
+ import { getComponentIdentity, resolveSurface, willComponentRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
7
+ var getRank = function getRank(component, parentKey) {
8
+ var _component$parents$fi, _component$parents;
9
+ return (_component$parents$fi = (_component$parents = component.parents) === null || _component$parents === void 0 || (_component$parents = _component$parents.find(function (parent) {
10
+ return parent.key === parentKey;
11
+ })) === null || _component$parents === void 0 ? void 0 : _component$parents.rank) !== null && _component$parents$fi !== void 0 ? _component$parents$fi : Number.MAX_SAFE_INTEGER;
12
+ };
13
+ var compareMatchedItems = function compareMatchedItems(a, b) {
14
+ return a.score - b.score || a.sectionRank - b.sectionRank || a.itemRank - b.itemRank || a.identity.localeCompare(b.identity);
15
+ };
16
+
17
+ /**
18
+ * Resolves registered menu items for a non-empty query. This intentionally has
19
+ * no empty-query path so browse behavior remains owned by buildQuickInsertMenuModel.
20
+ */
21
+ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertComponents(_ref) {
22
+ var components = _ref.components,
23
+ rootComponent = _ref.rootComponent,
24
+ query = _ref.query,
25
+ formatMessage = _ref.formatMessage,
26
+ surfaceContext = _ref.surfaceContext;
27
+ var _resolveSurface = resolveSurface(components, rootComponent),
28
+ childrenMap = _resolveSurface.childrenMap,
29
+ root = _resolveSurface.root,
30
+ topLevelChildren = _resolveSurface.topLevelChildren;
31
+ if (!root || !willComponentRender(root, childrenMap, surfaceContext) || !topLevelChildren) {
32
+ return {
33
+ footer: undefined,
34
+ root: undefined,
35
+ sections: []
36
+ };
37
+ }
38
+ var matches = new Map();
39
+ var _iterator = _createForOfIteratorHelper(topLevelChildren),
40
+ _step;
41
+ try {
42
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
43
+ var _childrenMap$get;
44
+ var section = _step.value;
45
+ if (section.type !== 'menu-section' || isMenuFooterSectionKey(section.key) || !willComponentRender(section, childrenMap, surfaceContext)) {
46
+ continue;
47
+ }
48
+ var _iterator3 = _createForOfIteratorHelper((_childrenMap$get = childrenMap.get(getComponentIdentity(section))) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : []),
49
+ _step3;
50
+ try {
51
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
52
+ var _item$match, _match$score;
53
+ var item = _step3.value;
54
+ if (item.type !== 'menu-item' || isSectionOverflowItemKey(item.key) || !willComponentRender(item, childrenMap, surfaceContext)) {
55
+ continue;
56
+ }
57
+ var match = (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.call(item, {
58
+ formatMessage: formatMessage,
59
+ query: query
60
+ });
61
+ if (item.match && match === null) {
62
+ continue;
63
+ }
64
+ var candidate = {
65
+ identity: "".concat(item.type, ":").concat(item.key),
66
+ item: item,
67
+ itemRank: getRank(item, section.key),
68
+ score: Math.min(1, Math.max(0, (_match$score = match === null || match === void 0 ? void 0 : match.score) !== null && _match$score !== void 0 ? _match$score : 0)),
69
+ section: section,
70
+ sectionRank: getRank(section, root.key)
71
+ };
72
+ var existing = matches.get(candidate.identity);
73
+ if (!existing || compareMatchedItems(candidate, existing) < 0) {
74
+ matches.set(candidate.identity, candidate);
75
+ }
76
+ }
77
+ } catch (err) {
78
+ _iterator3.e(err);
79
+ } finally {
80
+ _iterator3.f();
81
+ }
82
+ }
83
+ } catch (err) {
84
+ _iterator.e(err);
85
+ } finally {
86
+ _iterator.f();
87
+ }
88
+ var sectionsByKey = new Map();
89
+ var _iterator2 = _createForOfIteratorHelper(Array.from(matches.values()).sort(compareMatchedItems)),
90
+ _step2;
91
+ try {
92
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
93
+ var _match = _step2.value;
94
+ var _existing = sectionsByKey.get(_match.section.key);
95
+ if (_existing) {
96
+ _existing.push(_match.item);
97
+ } else {
98
+ sectionsByKey.set(_match.section.key, [_match.section, _match.item]);
99
+ }
100
+ }
101
+ } catch (err) {
102
+ _iterator2.e(err);
103
+ } finally {
104
+ _iterator2.f();
105
+ }
106
+ return {
107
+ footer: undefined,
108
+ root: root,
109
+ sections: Array.from(sectionsByKey.values())
110
+ };
111
+ };
@@ -0,0 +1,3 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ export { buildQuickInsertMenuModel } from './build-quick-insert-menu-model';
3
+ export { getMatchingQuickInsertComponents } from './get-matching-quick-insert-components';
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import { fg } from '@atlaskit/platform-feature-flags/fg';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "121.3.1";
24
+ var packageVersion = "121.4.2";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -129,7 +129,7 @@ export type InsertDateAEP = InsertAEP<ACTION_SUBJECT_ID.DATE, {
129
129
  type InsertExtensionAEP = InsertAEP<ACTION_SUBJECT_ID.EXTENSION, {
130
130
  extensionKey: string;
131
131
  extensionType: string;
132
- inputMethod: INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR | INPUT_METHOD.ELEMENT_BROWSER;
132
+ inputMethod: INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.ELEMENT_BROWSER;
133
133
  key: string;
134
134
  }, any>;
135
135
  type InsertNodeViaExtensionAPIAEP = InsertAEP<undefined, {
@@ -53,7 +53,7 @@ type ListOutdentedAEP = TrackAEP<ACTION.OUTDENTED, ACTION_SUBJECT.LIST, ACTION_S
53
53
  inputMethod: INPUT_METHOD;
54
54
  } & CommonListAnalyticsAttributes & RestartListsAttributesForListOutdented, undefined>;
55
55
  type ListInsertedAEP = TrackAEP<ACTION.INSERTED, ACTION_SUBJECT.LIST, ACTION_SUBJECT_ID.FORMAT_LIST_BULLET | ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER, {
56
- inputMethod: INPUT_METHOD.FORMATTING | INPUT_METHOD.KEYBOARD | INPUT_METHOD.TOOLBAR | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.ELEMENT_BROWSER | INPUT_METHOD.FLOATING_TB;
56
+ inputMethod: INPUT_METHOD.FORMATTING | INPUT_METHOD.KEYBOARD | INPUT_METHOD.TOOLBAR | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.ELEMENT_BROWSER | INPUT_METHOD.FLOATING_TB;
57
57
  joinScenario?: JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST;
58
58
  listStartNumber?: number;
59
59
  }, undefined, NonRequiredAttributes>;
@@ -16,7 +16,7 @@ export type QuickInsertItem = TypeAheadItem & {
16
16
  * If a search occurs -- then a separate insert action is called
17
17
  * @see packages/editor/editor-core/src/plugins/insert-block/ui/ToolbarInsertBlock/index.tsx for details
18
18
  */
19
- action: (insert: QuickInsertActionInsert, state: EditorState, source?: INPUT_METHOD.TOOLBAR | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.ELEMENT_BROWSER) => Transaction | false;
19
+ action: (insert: QuickInsertActionInsert, state: EditorState, source?: INPUT_METHOD.TOOLBAR | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.ELEMENT_BROWSER) => Transaction | false;
20
20
  /** App contributing this item. */
21
21
  app?: ExtensionApp;
22
22
  /** categories where to find the item */
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { QuickInsertMenuItemProps } from './QuickInsertMenuItem';
3
+ export declare const CompactQuickInsertMenuItem: ({ ariaLabel, iconBefore, isDisabled, onSelect, shortcut, shouldWrapIcon, title, }: QuickInsertMenuItemProps) => React.JSX.Element;
@@ -6,7 +6,7 @@ import type { INPUT_METHOD } from '../analytics';
6
6
  import type { TypeAheadInsert } from '../types';
7
7
  export type QuickInsertSelectionHandler = (context: {
8
8
  insert: TypeAheadInsert;
9
- source: INPUT_METHOD.ELEMENT_BROWSER | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR;
9
+ source: INPUT_METHOD.ELEMENT_BROWSER | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR;
10
10
  }) => Transaction | false | void;
11
11
  export type QuickInsertContextValue = {
12
12
  editorView: EditorView;
@@ -18,7 +18,7 @@ export type QuickInsertContextValue = {
18
18
  };
19
19
  menuOpenId?: symbol;
20
20
  select: (selectionHandler: QuickInsertSelectionHandler) => void;
21
- surface: 'typeahead' | 'element-browser';
21
+ surface: 'typeahead' | 'toolbar' | 'element-browser';
22
22
  surfaceContext?: SurfaceContext;
23
23
  };
24
24
  export declare const QuickInsertContext: Context<QuickInsertContextValue | null>;
@@ -6,7 +6,7 @@ import type { TypeAheadInsert } from '../types';
6
6
  export type OnSelectContext = {
7
7
  editorView: EditorView;
8
8
  insert: TypeAheadInsert;
9
- source: INPUT_METHOD.ELEMENT_BROWSER | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR;
9
+ source: INPUT_METHOD.ELEMENT_BROWSER | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR;
10
10
  };
11
11
  export type QuickInsertMenuItemProps = {
12
12
  ariaLabel?: string;
@@ -0,0 +1,9 @@
1
+ import type { SurfaceIdentifier } from '@atlaskit/editor-ui-control-model/surface-renderer/types';
2
+ import type { RegisterComponent, RegisterMenuItem, RegisterMenuSection, SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
3
+ export type QuickInsertMenuSection = [RegisterMenuSection, ...RegisterMenuItem[]];
4
+ export type QuickInsertMenuModel = {
5
+ footer: RegisterMenuItem | undefined;
6
+ root: RegisterComponent | undefined;
7
+ sections: QuickInsertMenuSection[];
8
+ };
9
+ export declare const buildQuickInsertMenuModel: (components: RegisterComponent[], rootComponent: SurfaceIdentifier, sectionOverflowLimit?: number, surfaceContext?: SurfaceContext) => QuickInsertMenuModel;
@@ -0,0 +1,15 @@
1
+ import type { IntlShape } from 'react-intl';
2
+ import type { SurfaceIdentifier } from '@atlaskit/editor-ui-control-model/surface-renderer/types';
3
+ import type { RegisterComponent, SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
4
+ import type { QuickInsertMenuModel } from './build-quick-insert-menu-model';
5
+ /**
6
+ * Resolves registered menu items for a non-empty query. This intentionally has
7
+ * no empty-query path so browse behavior remains owned by buildQuickInsertMenuModel.
8
+ */
9
+ export declare const getMatchingQuickInsertComponents: ({ components, rootComponent, query, formatMessage, surfaceContext, }: {
10
+ components: RegisterComponent[];
11
+ formatMessage: IntlShape['formatMessage'];
12
+ query: string;
13
+ rootComponent: SurfaceIdentifier;
14
+ surfaceContext?: SurfaceContext;
15
+ }) => QuickInsertMenuModel;
@@ -0,0 +1,3 @@
1
+ export { buildQuickInsertMenuModel } from './build-quick-insert-menu-model';
2
+ export { getMatchingQuickInsertComponents } from './get-matching-quick-insert-components';
3
+ export type { QuickInsertMenuModel, QuickInsertMenuSection } from './build-quick-insert-menu-model';
@@ -1,3 +1,3 @@
1
1
  import type { SerializedStyles } from '@emotion/react';
2
- import type { ThemeState } from '@atlaskit/tokens/theme-config';
2
+ import type { ThemeState } from '@atlaskit/tokens/theme-state';
3
3
  export declare const headingsSharedStyles: (_typographyTheme?: ThemeState['typography']) => SerializedStyles;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "121.4.0",
3
+ "version": "121.4.2",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -45,7 +45,7 @@
45
45
  "@atlaskit/editor-json-transformer": "^9.8.0",
46
46
  "@atlaskit/editor-palette": "^3.5.0",
47
47
  "@atlaskit/editor-prosemirror": "^8.0.0",
48
- "@atlaskit/editor-shared-styles": "^4.1.0",
48
+ "@atlaskit/editor-shared-styles": "^4.2.0",
49
49
  "@atlaskit/editor-tables": "^3.2.0",
50
50
  "@atlaskit/editor-toolbar": "^2.6.0",
51
51
  "@atlaskit/editor-toolbar-model": "^1.2.0",
@@ -76,7 +76,7 @@
76
76
  "@atlaskit/profilecard": "^26.22.0",
77
77
  "@atlaskit/prosemirror-history": "^1.2.0",
78
78
  "@atlaskit/react-compiler-gating": "^0.2.0",
79
- "@atlaskit/react-ufo": "^7.8.0",
79
+ "@atlaskit/react-ufo": "^7.9.0",
80
80
  "@atlaskit/section-message": "^10.2.0",
81
81
  "@atlaskit/smart-card": "^45.21.0",
82
82
  "@atlaskit/smart-user-picker": "^11.8.0",
@@ -84,8 +84,8 @@
84
84
  "@atlaskit/task-decision": "^21.9.0",
85
85
  "@atlaskit/teams-app-config": "^3.1.0",
86
86
  "@atlaskit/textfield": "^10.2.0",
87
- "@atlaskit/tmp-editor-statsig": "^185.0.0",
88
- "@atlaskit/tokens": "^16.11.0",
87
+ "@atlaskit/tmp-editor-statsig": "^187.0.0",
88
+ "@atlaskit/tokens": "^16.12.0",
89
89
  "@atlaskit/tooltip": "^24.3.0",
90
90
  "@atlaskit/width-detector": "^7.2.0",
91
91
  "@babel/runtime": "^7.0.0",
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/quick-insert/registered-menu-model",
3
+ "main": "../../dist/cjs/quick-insert/registered-menu-model.js",
4
+ "module": "../../dist/esm/quick-insert/registered-menu-model.js",
5
+ "module:es2019": "../../dist/es2019/quick-insert/registered-menu-model.js",
6
+ "sideEffects": [
7
+ "**/*.compiled.css"
8
+ ],
9
+ "types": "../../dist/types/quick-insert/registered-menu-model.d.ts"
10
+ }
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- import type { QuickInsertMenuItemProps } from './QuickInsertMenuItem';
3
- export declare const TypeAheadQuickInsertMenuItem: ({ ariaLabel, iconBefore, isDisabled, onSelect, shortcut, shouldWrapIcon, title, }: QuickInsertMenuItemProps) => React.JSX.Element;