@atlaskit/editor-plugin-type-ahead 6.5.11 → 6.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-type-ahead
2
2
 
3
+ ## 6.5.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 6.5.12
10
+
11
+ ### Patch Changes
12
+
13
+ - [`0d661119b4293`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0d661119b4293) -
14
+ Clean up platform_editor_insertion experiment by shipping control variant. Remove modern TypeAhead
15
+ components and experiment infrastructure while preserving all existing functionality.
16
+ - Updated dependencies
17
+
3
18
  ## 6.5.11
4
19
 
5
20
  ### Patch Changes
@@ -19,6 +19,8 @@ var _closeTypeAhead = require("./commands/close-type-ahead");
19
19
  var _constants = require("./constants");
20
20
  var _statsModifier = require("./stats-modifier");
21
21
  var _utils = require("./utils");
22
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
23
+
22
24
  var factoryDecorations = exports.factoryDecorations = function factoryDecorations(_ref) {
23
25
  var intl = _ref.intl,
24
26
  popupMountRef = _ref.popupMountRef,
@@ -36,6 +38,8 @@ var factoryDecorations = exports.factoryDecorations = function factoryDecoration
36
38
  decorationElement: null
37
39
  };
38
40
  }
41
+
42
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
39
43
  var decorationId = "decoration_id_".concat(_constants.TYPE_AHEAD_DECORATION_KEY, "_").concat((0, _uuid.default)());
40
44
  var $cursor = selection.$cursor;
41
45
  var typeaheadComponent = document.createElement('mark');
@@ -7,10 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.ContentComponent = ContentComponent;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _hooks = require("@atlaskit/editor-common/hooks");
10
- var _typeAhead = require("@atlaskit/editor-common/type-ahead");
11
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
12
- var _TypeAheadMenu = require("./modern/TypeAheadMenu");
13
- var _TypeAheadMenu2 = require("./TypeAheadMenu");
10
+ var _TypeAheadMenu = require("./TypeAheadMenu");
14
11
  function ContentComponent(_ref) {
15
12
  var api = _ref.api,
16
13
  editorView = _ref.editorView,
@@ -37,36 +34,18 @@ function ContentComponent(_ref) {
37
34
  if (items === undefined || decorationSet === undefined || errorInfo === undefined || decorationElement === undefined || query === undefined || selectedIndex === undefined) {
38
35
  return null;
39
36
  }
40
- if (
41
- // TODO: ED-26959 - Also requires a check for editor appearance (needs to be enabled for full-page/full-width editor only ?)
42
- !(0, _experiments.editorExperiment)('platform_editor_insertion', 'control') && (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === _typeAhead.TypeAheadAvailableNodes.QUICK_INSERT) {
43
- return /*#__PURE__*/_react.default.createElement(_TypeAheadMenu.TypeAheadMenu, {
44
- editorView: editorView,
45
- popupMountRef: popupMountRef,
46
- typeAheadState: {
47
- triggerHandler: triggerHandler,
48
- items: items,
49
- errorInfo: errorInfo,
50
- decorationElement: decorationElement,
51
- decorationSet: decorationSet,
52
- query: query
53
- },
54
- api: api
55
- });
56
- } else {
57
- return /*#__PURE__*/_react.default.createElement(_TypeAheadMenu2.TypeAheadMenu, {
58
- editorView: editorView,
59
- popupMountRef: popupMountRef,
60
- typeAheadState: {
61
- triggerHandler: triggerHandler,
62
- items: items,
63
- errorInfo: errorInfo,
64
- decorationElement: decorationElement,
65
- decorationSet: decorationSet,
66
- query: query
67
- },
68
- selectedIndex: selectedIndex,
69
- api: api
70
- });
71
- }
37
+ return /*#__PURE__*/_react.default.createElement(_TypeAheadMenu.TypeAheadMenu, {
38
+ editorView: editorView,
39
+ popupMountRef: popupMountRef,
40
+ typeAheadState: {
41
+ triggerHandler: triggerHandler,
42
+ items: items,
43
+ errorInfo: errorInfo,
44
+ decorationElement: decorationElement,
45
+ decorationSet: decorationSet,
46
+ query: query
47
+ },
48
+ selectedIndex: selectedIndex,
49
+ api: api
50
+ });
72
51
  }
@@ -32,11 +32,11 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
32
32
  var placeholderStyles = (0, _react2.css)({
33
33
  '&::after': {
34
34
  content: 'attr(data-place-holder)',
35
- color: "var(--ds-text-subtlest, #626F86)",
35
+ color: "var(--ds-text-subtlest, #6B6E76)",
36
36
  position: 'relative',
37
37
  padding: "var(--ds-space-025, 2px)",
38
38
  left: "var(--ds-space-negative-050, -4px)",
39
- backgroundColor: "var(--ds-background-neutral, #091E420F)",
39
+ backgroundColor: "var(--ds-background-neutral, #0515240F)",
40
40
  // eslint-disable-next-line @atlaskit/design-system/no-unsafe-design-token-usage
41
41
  borderRadius: "var(--ds-radius-small, 3px)"
42
42
  }
@@ -111,9 +111,8 @@ var InputQuery = exports.InputQuery = /*#__PURE__*/_react.default.memo(function
111
111
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
112
112
  query = _useState2[0],
113
113
  setQuery = _useState2[1];
114
- var isEditorInsertionEnabled = (0, _experiments.editorExperiment)('platform_editor_insertion', 'variant1');
115
114
  var isEditorControlsEnabled = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1');
116
- var isSearchPlaceholderEnabled = isEditorInsertionEnabled || (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_quick_insert_placeholder');
115
+ var isSearchPlaceholderEnabled = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_quick_insert_placeholder');
117
116
  var selection = editorView.state.selection;
118
117
  var table = editorView.state.schema.nodes.table;
119
118
  var _useState3 = (0, _react.useState)(isSearchPlaceholderEnabled && triggerQueryPrefix === '/' &&
@@ -77,7 +77,7 @@ var itemDescription = (0, _react2.css)({
77
77
  // when cleaning up FG `platform_editor_typeahead_description_text_colour`
78
78
  // replace above color with this and delete itemDescriptionColor
79
79
  var itemDescriptionColor = (0, _react2.css)({
80
- color: "var(--ds-text-subtle, #44546F)".concat(";")
80
+ color: "var(--ds-text-subtle, #505258)".concat(";")
81
81
  });
82
82
  var itemDescriptionOverride = (0, _react2.css)({
83
83
  font: "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
@@ -113,7 +113,7 @@ var selectionFrame = {
113
113
  // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- Ignored via go/DSP-18766
114
114
  var selectedStyle = (0, _react2.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n\tbackground-color: ", ";\n\tbox-shadow: inset 2px 0px 0px ", ";\n"])), "var(--ds-background-neutral-subtle-hovered, ".concat(_colors.N30, ")"), "var(--ds-border-focused, ".concat(_colors.B400, ")"));
115
115
  var disabledStyle = (0, _react2.css)({
116
- color: "var(--ds-text-disabled, #091E424F)"
116
+ color: "var(--ds-text-disabled, #080F214A)"
117
117
  });
118
118
  var FallbackIcon = /*#__PURE__*/_react.default.memo(function (_ref) {
119
119
  var label = _ref.label;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IntlProvider } from 'react-intl-next';
3
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
3
4
  import uuid from 'uuid';
4
5
  import { keyName as keyNameNormalized } from 'w3c-keyname';
5
6
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
@@ -33,6 +34,8 @@ export const factoryDecorations = ({
33
34
  decorationElement: null
34
35
  };
35
36
  }
37
+
38
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
36
39
  const decorationId = `decoration_id_${TYPE_AHEAD_DECORATION_KEY}_${uuid()}`;
37
40
  const {
38
41
  $cursor
@@ -1,8 +1,5 @@
1
1
  import React from 'react';
2
2
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
- import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
4
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
- import { TypeAheadMenu as TypeAheadMenuModern } from './modern/TypeAheadMenu';
6
3
  import { TypeAheadMenu } from './TypeAheadMenu';
7
4
  export function ContentComponent({
8
5
  api,
@@ -32,36 +29,18 @@ export function ContentComponent({
32
29
  if (items === undefined || decorationSet === undefined || errorInfo === undefined || decorationElement === undefined || query === undefined || selectedIndex === undefined) {
33
30
  return null;
34
31
  }
35
- if (
36
- // TODO: ED-26959 - Also requires a check for editor appearance (needs to be enabled for full-page/full-width editor only ?)
37
- !editorExperiment('platform_editor_insertion', 'control') && (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === TypeAheadAvailableNodes.QUICK_INSERT) {
38
- return /*#__PURE__*/React.createElement(TypeAheadMenuModern, {
39
- editorView: editorView,
40
- popupMountRef: popupMountRef,
41
- typeAheadState: {
42
- triggerHandler,
43
- items,
44
- errorInfo,
45
- decorationElement,
46
- decorationSet,
47
- query
48
- },
49
- api: api
50
- });
51
- } else {
52
- return /*#__PURE__*/React.createElement(TypeAheadMenu, {
53
- editorView: editorView,
54
- popupMountRef: popupMountRef,
55
- typeAheadState: {
56
- triggerHandler,
57
- items,
58
- errorInfo,
59
- decorationElement,
60
- decorationSet,
61
- query
62
- },
63
- selectedIndex: selectedIndex,
64
- api: api
65
- });
66
- }
32
+ return /*#__PURE__*/React.createElement(TypeAheadMenu, {
33
+ editorView: editorView,
34
+ popupMountRef: popupMountRef,
35
+ typeAheadState: {
36
+ triggerHandler,
37
+ items,
38
+ errorInfo,
39
+ decorationElement,
40
+ decorationSet,
41
+ query
42
+ },
43
+ selectedIndex: selectedIndex,
44
+ api: api
45
+ });
67
46
  }
@@ -21,11 +21,11 @@ import { getPluginState } from '../pm-plugins/utils';
21
21
  const placeholderStyles = css({
22
22
  '&::after': {
23
23
  content: 'attr(data-place-holder)',
24
- color: "var(--ds-text-subtlest, #626F86)",
24
+ color: "var(--ds-text-subtlest, #6B6E76)",
25
25
  position: 'relative',
26
26
  padding: "var(--ds-space-025, 2px)",
27
27
  left: "var(--ds-space-negative-050, -4px)",
28
- backgroundColor: "var(--ds-background-neutral, #091E420F)",
28
+ backgroundColor: "var(--ds-background-neutral, #0515240F)",
29
29
  // eslint-disable-next-line @atlaskit/design-system/no-unsafe-design-token-usage
30
30
  borderRadius: "var(--ds-radius-small, 3px)"
31
31
  }
@@ -98,9 +98,8 @@ export const InputQuery = /*#__PURE__*/React.memo(({
98
98
  const ref = useRef(document.createElement('span'));
99
99
  const inputRef = useRef(null);
100
100
  const [query, setQuery] = useState(null);
101
- const isEditorInsertionEnabled = editorExperiment('platform_editor_insertion', 'variant1');
102
101
  const isEditorControlsEnabled = editorExperiment('platform_editor_controls', 'variant1');
103
- const isSearchPlaceholderEnabled = isEditorInsertionEnabled || editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_quick_insert_placeholder');
102
+ const isSearchPlaceholderEnabled = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_quick_insert_placeholder');
104
103
  const selection = editorView.state.selection;
105
104
  const {
106
105
  table
@@ -72,7 +72,7 @@ const itemDescription = css({
72
72
  // when cleaning up FG `platform_editor_typeahead_description_text_colour`
73
73
  // replace above color with this and delete itemDescriptionColor
74
74
  const itemDescriptionColor = css({
75
- color: `${"var(--ds-text-subtle, #44546F)"};`
75
+ color: `${"var(--ds-text-subtle, #505258)"};`
76
76
  });
77
77
  const itemDescriptionOverride = css({
78
78
  font: "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
@@ -120,7 +120,7 @@ const selectedStyle = css`
120
120
  box-shadow: inset 2px 0px 0px ${`var(--ds-border-focused, ${B400})`};
121
121
  `;
122
122
  const disabledStyle = css({
123
- color: "var(--ds-text-disabled, #091E424F)"
123
+ color: "var(--ds-text-disabled, #080F214A)"
124
124
  });
125
125
  const FallbackIcon = /*#__PURE__*/React.memo(({
126
126
  label
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IntlProvider } from 'react-intl-next';
3
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
3
4
  import uuid from 'uuid';
4
5
  import { keyName as keyNameNormalized } from 'w3c-keyname';
5
6
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
@@ -29,6 +30,8 @@ export var factoryDecorations = function factoryDecorations(_ref) {
29
30
  decorationElement: null
30
31
  };
31
32
  }
33
+
34
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
32
35
  var decorationId = "decoration_id_".concat(TYPE_AHEAD_DECORATION_KEY, "_").concat(uuid());
33
36
  var $cursor = selection.$cursor;
34
37
  var typeaheadComponent = document.createElement('mark');
@@ -1,8 +1,5 @@
1
1
  import React from 'react';
2
2
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
- import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
4
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
- import { TypeAheadMenu as TypeAheadMenuModern } from './modern/TypeAheadMenu';
6
3
  import { TypeAheadMenu } from './TypeAheadMenu';
7
4
  export function ContentComponent(_ref) {
8
5
  var api = _ref.api,
@@ -30,36 +27,18 @@ export function ContentComponent(_ref) {
30
27
  if (items === undefined || decorationSet === undefined || errorInfo === undefined || decorationElement === undefined || query === undefined || selectedIndex === undefined) {
31
28
  return null;
32
29
  }
33
- if (
34
- // TODO: ED-26959 - Also requires a check for editor appearance (needs to be enabled for full-page/full-width editor only ?)
35
- !editorExperiment('platform_editor_insertion', 'control') && (triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.id) === TypeAheadAvailableNodes.QUICK_INSERT) {
36
- return /*#__PURE__*/React.createElement(TypeAheadMenuModern, {
37
- editorView: editorView,
38
- popupMountRef: popupMountRef,
39
- typeAheadState: {
40
- triggerHandler: triggerHandler,
41
- items: items,
42
- errorInfo: errorInfo,
43
- decorationElement: decorationElement,
44
- decorationSet: decorationSet,
45
- query: query
46
- },
47
- api: api
48
- });
49
- } else {
50
- return /*#__PURE__*/React.createElement(TypeAheadMenu, {
51
- editorView: editorView,
52
- popupMountRef: popupMountRef,
53
- typeAheadState: {
54
- triggerHandler: triggerHandler,
55
- items: items,
56
- errorInfo: errorInfo,
57
- decorationElement: decorationElement,
58
- decorationSet: decorationSet,
59
- query: query
60
- },
61
- selectedIndex: selectedIndex,
62
- api: api
63
- });
64
- }
30
+ return /*#__PURE__*/React.createElement(TypeAheadMenu, {
31
+ editorView: editorView,
32
+ popupMountRef: popupMountRef,
33
+ typeAheadState: {
34
+ triggerHandler: triggerHandler,
35
+ items: items,
36
+ errorInfo: errorInfo,
37
+ decorationElement: decorationElement,
38
+ decorationSet: decorationSet,
39
+ query: query
40
+ },
41
+ selectedIndex: selectedIndex,
42
+ api: api
43
+ });
65
44
  }
@@ -22,11 +22,11 @@ import { getPluginState } from '../pm-plugins/utils';
22
22
  var placeholderStyles = css({
23
23
  '&::after': {
24
24
  content: 'attr(data-place-holder)',
25
- color: "var(--ds-text-subtlest, #626F86)",
25
+ color: "var(--ds-text-subtlest, #6B6E76)",
26
26
  position: 'relative',
27
27
  padding: "var(--ds-space-025, 2px)",
28
28
  left: "var(--ds-space-negative-050, -4px)",
29
- backgroundColor: "var(--ds-background-neutral, #091E420F)",
29
+ backgroundColor: "var(--ds-background-neutral, #0515240F)",
30
30
  // eslint-disable-next-line @atlaskit/design-system/no-unsafe-design-token-usage
31
31
  borderRadius: "var(--ds-radius-small, 3px)"
32
32
  }
@@ -101,9 +101,8 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
101
101
  _useState2 = _slicedToArray(_useState, 2),
102
102
  query = _useState2[0],
103
103
  setQuery = _useState2[1];
104
- var isEditorInsertionEnabled = editorExperiment('platform_editor_insertion', 'variant1');
105
104
  var isEditorControlsEnabled = editorExperiment('platform_editor_controls', 'variant1');
106
- var isSearchPlaceholderEnabled = isEditorInsertionEnabled || editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_quick_insert_placeholder');
105
+ var isSearchPlaceholderEnabled = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_quick_insert_placeholder');
107
106
  var selection = editorView.state.selection;
108
107
  var table = editorView.state.schema.nodes.table;
109
108
  var _useState3 = useState(isSearchPlaceholderEnabled && triggerQueryPrefix === '/' &&
@@ -69,7 +69,7 @@ var itemDescription = css({
69
69
  // when cleaning up FG `platform_editor_typeahead_description_text_colour`
70
70
  // replace above color with this and delete itemDescriptionColor
71
71
  var itemDescriptionColor = css({
72
- color: "var(--ds-text-subtle, #44546F)".concat(";")
72
+ color: "var(--ds-text-subtle, #505258)".concat(";")
73
73
  });
74
74
  var itemDescriptionOverride = css({
75
75
  font: "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
@@ -105,7 +105,7 @@ var selectionFrame = {
105
105
  // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- Ignored via go/DSP-18766
106
106
  var selectedStyle = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n\tbackground-color: ", ";\n\tbox-shadow: inset 2px 0px 0px ", ";\n"])), "var(--ds-background-neutral-subtle-hovered, ".concat(N30, ")"), "var(--ds-border-focused, ".concat(B400, ")"));
107
107
  var disabledStyle = css({
108
- color: "var(--ds-text-disabled, #091E424F)"
108
+ color: "var(--ds-text-disabled, #080F214A)"
109
109
  });
110
110
  var FallbackIcon = /*#__PURE__*/React.memo(function (_ref) {
111
111
  var label = _ref.label;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "6.5.11",
3
+ "version": "6.5.13",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -36,18 +36,18 @@
36
36
  "@atlaskit/editor-plugin-context-panel": "^8.0.0",
37
37
  "@atlaskit/editor-plugin-metrics": "^7.1.0",
38
38
  "@atlaskit/editor-prosemirror": "7.0.0",
39
- "@atlaskit/editor-shared-styles": "^3.8.0",
39
+ "@atlaskit/editor-shared-styles": "^3.9.0",
40
40
  "@atlaskit/heading": "^5.2.0",
41
- "@atlaskit/icon": "^28.5.0",
41
+ "@atlaskit/icon": "^29.0.0",
42
42
  "@atlaskit/insm": "^0.2.0",
43
43
  "@atlaskit/menu": "^8.4.0",
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/primitives": "^16.1.0",
46
46
  "@atlaskit/prosemirror-history": "^0.2.0",
47
- "@atlaskit/prosemirror-input-rules": "^3.5.0",
47
+ "@atlaskit/prosemirror-input-rules": "^3.6.0",
48
48
  "@atlaskit/theme": "^21.0.0",
49
- "@atlaskit/tmp-editor-statsig": "^13.26.0",
50
- "@atlaskit/tokens": "^7.1.0",
49
+ "@atlaskit/tmp-editor-statsig": "^13.35.0",
50
+ "@atlaskit/tokens": "^8.0.0",
51
51
  "@atlaskit/visually-hidden": "^3.0.0",
52
52
  "@babel/runtime": "^7.0.0",
53
53
  "@emotion/react": "^11.7.1",
@@ -58,7 +58,7 @@
58
58
  "w3c-keyname": "^2.1.8"
59
59
  },
60
60
  "peerDependencies": {
61
- "@atlaskit/editor-common": "^110.22.0",
61
+ "@atlaskit/editor-common": "^110.27.0",
62
62
  "react": "^18.2.0",
63
63
  "react-dom": "^18.2.0",
64
64
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -1,84 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.TypeAheadMenu = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _react = _interopRequireDefault(require("react"));
10
- var _typeAhead = require("@atlaskit/editor-common/type-ahead");
11
- var _updateSelectedIndex = require("../../pm-plugins/commands/update-selected-index");
12
- var _useItemInsert3 = require("../hooks/use-item-insert");
13
- var _TypeAheadPopup = require("./TypeAheadPopup");
14
- var TypeAheadMenu = exports.TypeAheadMenu = /*#__PURE__*/_react.default.memo(function (_ref) {
15
- var _popupMountRef$curren, _popupMountRef$curren2, _popupMountRef$curren3;
16
- var editorView = _ref.editorView,
17
- popupMountRef = _ref.popupMountRef,
18
- typeAheadState = _ref.typeAheadState,
19
- api = _ref.api;
20
- var isOpen = typeAheadState.decorationSet.find().length > 0;
21
- var triggerHandler = typeAheadState.triggerHandler,
22
- items = typeAheadState.items,
23
- errorInfo = typeAheadState.errorInfo,
24
- decorationElement = typeAheadState.decorationElement,
25
- decorationSet = typeAheadState.decorationSet,
26
- query = typeAheadState.query;
27
- var _useItemInsert = (0, _useItemInsert3.useItemInsert)(
28
- // Ignored via go/ees005
29
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
30
- triggerHandler, editorView, items, api),
31
- _useItemInsert2 = (0, _slicedToArray2.default)(_useItemInsert, 2),
32
- onItemInsert = _useItemInsert2[0],
33
- onTextInsert = _useItemInsert2[1];
34
- var setSelectedItem = _react.default.useCallback(function (_ref2) {
35
- var nextIndex = _ref2.index;
36
- queueMicrotask(function () {
37
- (0, _updateSelectedIndex.updateSelectedIndex)(nextIndex, api)(editorView.state, editorView.dispatch);
38
- });
39
- }, [editorView, api]);
40
- var insertItem = _react.default.useCallback(function () {
41
- var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _typeAhead.SelectItemMode.SELECTED;
42
- var index = arguments.length > 1 ? arguments[1] : undefined;
43
- queueMicrotask(function () {
44
- onItemInsert({
45
- mode: mode,
46
- index: index,
47
- query: query
48
- });
49
- });
50
- }, [onItemInsert, query]);
51
- var cancel = _react.default.useCallback(function (_ref3) {
52
- var setSelectionAt = _ref3.setSelectionAt,
53
- addPrefixTrigger = _ref3.addPrefixTrigger,
54
- forceFocusOnEditor = _ref3.forceFocusOnEditor;
55
- var fullQuery = addPrefixTrigger ? "".concat(triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.trigger).concat(query) : query;
56
- onTextInsert({
57
- forceFocusOnEditor: forceFocusOnEditor,
58
- setSelectionAt: setSelectionAt,
59
- text: fullQuery
60
- });
61
- }, [triggerHandler, onTextInsert, query]);
62
- if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || items.length === 0 && !errorInfo) {
63
- return null;
64
- }
65
- return /*#__PURE__*/_react.default.createElement(_TypeAheadPopup.TypeAheadPopup, {
66
- editorView: editorView,
67
- popupsMountPoint: (_popupMountRef$curren = popupMountRef.current) === null || _popupMountRef$curren === void 0 ? void 0 : _popupMountRef$curren.popupsMountPoint,
68
- popupsBoundariesElement: (_popupMountRef$curren2 = popupMountRef.current) === null || _popupMountRef$curren2 === void 0 ? void 0 : _popupMountRef$curren2.popupsBoundariesElement,
69
- popupsScrollableElement: (_popupMountRef$curren3 = popupMountRef.current) === null || _popupMountRef$curren3 === void 0 ? void 0 : _popupMountRef$curren3.popupsScrollableElement,
70
- anchorElement: decorationElement,
71
- triggerHandler: triggerHandler,
72
- items: items,
73
- errorInfo: errorInfo
74
- // selectedIndex={selectedIndex}
75
- ,
76
- setSelectedItem: setSelectedItem,
77
- onItemInsert: insertItem,
78
- decorationSet: decorationSet,
79
- isEmptyQuery: !query,
80
- query: query,
81
- cancel: cancel,
82
- api: api
83
- });
84
- });