@atlaskit/editor-plugin-type-ahead 13.0.0 → 13.0.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.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/pm-plugins/commands/update-section-title.js +1 -2
- package/dist/cjs/pm-plugins/reducer.js +4 -16
- package/dist/cjs/ui/TypeAheadList.js +4 -8
- package/dist/cjs/ui/hooks/build-sectioned-result.js +1 -2
- package/dist/es2019/pm-plugins/commands/update-section-title.js +1 -2
- package/dist/es2019/pm-plugins/reducer.js +4 -16
- package/dist/es2019/ui/TypeAheadList.js +4 -8
- package/dist/es2019/ui/hooks/build-sectioned-result.js +1 -2
- package/dist/esm/pm-plugins/commands/update-section-title.js +1 -2
- package/dist/esm/pm-plugins/reducer.js +4 -16
- package/dist/esm/ui/TypeAheadList.js +4 -8
- package/dist/esm/ui/hooks/build-sectioned-result.js +1 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-type-ahead
|
|
2
2
|
|
|
3
|
+
## 13.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`f8280f6b24eec`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f8280f6b24eec) -
|
|
8
|
+
Allow editor surfaces to control agent mention picker sectioning independently.
|
|
9
|
+
|
|
10
|
+
## 13.0.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`0e797fd81675f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0e797fd81675f) -
|
|
15
|
+
Cleaning up interactivity monitoring experiment
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 13.0.0
|
|
4
19
|
|
|
5
20
|
### Major Changes
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.updateSectionTitle = void 0;
|
|
7
|
-
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
8
7
|
var _actions = require("../actions");
|
|
9
8
|
var _key = require("../key");
|
|
10
9
|
var updateSectionTitle = exports.updateSectionTitle = function updateSectionTitle(_ref) {
|
|
@@ -12,7 +11,7 @@ var updateSectionTitle = exports.updateSectionTitle = function updateSectionTitl
|
|
|
12
11
|
title = _ref.title,
|
|
13
12
|
sectionTitleDisplay = _ref.sectionTitleDisplay;
|
|
14
13
|
return function (state, dispatch) {
|
|
15
|
-
if (!
|
|
14
|
+
if (!dispatch) {
|
|
16
15
|
return false;
|
|
17
16
|
}
|
|
18
17
|
var tr = state.tr;
|
|
@@ -10,8 +10,6 @@ var _steps = require("@atlaskit/adf-schema/steps");
|
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
12
12
|
var _insm = require("@atlaskit/insm");
|
|
13
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
|
-
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
15
13
|
var _actions = require("./actions");
|
|
16
14
|
var _key = require("./key");
|
|
17
15
|
var _utils = require("./utils");
|
|
@@ -36,9 +34,6 @@ var shouldForceClose = function shouldForceClose(step) {
|
|
|
36
34
|
var applySectionTitleUpdates = function applySectionTitleUpdates(_ref) {
|
|
37
35
|
var sections = _ref.sections,
|
|
38
36
|
sectionTitleUpdates = _ref.sectionTitleUpdates;
|
|
39
|
-
if (!(0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
40
|
-
return sections;
|
|
41
|
-
}
|
|
42
37
|
var updatedSections = sections.map(function (section) {
|
|
43
38
|
var update = sectionTitleUpdates[section.id];
|
|
44
39
|
if (!update) {
|
|
@@ -65,6 +60,7 @@ var createReducer = exports.createReducer = function createReducer(_ref2) {
|
|
|
65
60
|
createDecorations = _ref2.createDecorations;
|
|
66
61
|
var findHandler = createFindHandler(typeAheadHandlers);
|
|
67
62
|
var openMenu = function openMenu(currentPluginState, _ref3) {
|
|
63
|
+
var _insm$session;
|
|
68
64
|
var tr = _ref3.tr,
|
|
69
65
|
triggerHandler = _ref3.triggerHandler,
|
|
70
66
|
inputMethod = _ref3.inputMethod,
|
|
@@ -80,10 +76,7 @@ var createReducer = exports.createReducer = function createReducer(_ref2) {
|
|
|
80
76
|
decorationSet = _createDecorations.decorationSet,
|
|
81
77
|
decorationElement = _createDecorations.decorationElement,
|
|
82
78
|
stats = _createDecorations.stats;
|
|
83
|
-
|
|
84
|
-
var _insm$session;
|
|
85
|
-
(_insm$session = _insm.insm.session) === null || _insm$session === void 0 || _insm$session.startFeature('typeaheadOpen');
|
|
86
|
-
}
|
|
79
|
+
(_insm$session = _insm.insm.session) === null || _insm$session === void 0 || _insm$session.startFeature('typeaheadOpen');
|
|
87
80
|
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
88
81
|
stats: stats,
|
|
89
82
|
decorationSet: decorationSet,
|
|
@@ -99,11 +92,9 @@ var createReducer = exports.createReducer = function createReducer(_ref2) {
|
|
|
99
92
|
});
|
|
100
93
|
};
|
|
101
94
|
var closeMenu = function closeMenu(currentPluginState) {
|
|
95
|
+
var _insm$session2;
|
|
102
96
|
removeDecorations(currentPluginState.decorationSet);
|
|
103
|
-
|
|
104
|
-
var _insm$session2;
|
|
105
|
-
(_insm$session2 = _insm.insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('typeaheadOpen');
|
|
106
|
-
}
|
|
97
|
+
(_insm$session2 = _insm.insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('typeaheadOpen');
|
|
107
98
|
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
108
99
|
inputMethod: null,
|
|
109
100
|
query: '',
|
|
@@ -182,9 +173,6 @@ var createReducer = exports.createReducer = function createReducer(_ref2) {
|
|
|
182
173
|
selectedIndex: Math.max(selectedIndex >= items.length ? items.length - 1 : selectedIndex, -1)
|
|
183
174
|
});
|
|
184
175
|
} else if (shouldUpdateSectionTitleState) {
|
|
185
|
-
if (!(0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
186
|
-
return currentPluginState;
|
|
187
|
-
}
|
|
188
176
|
var id = params.id,
|
|
189
177
|
update = params.update;
|
|
190
178
|
var sectionTitleUpdates = _objectSpread(_objectSpread({}, currentPluginState.sectionTitleUpdates), {}, (0, _defineProperty2.default)({}, id, _objectSpread(_objectSpread({}, currentPluginState.sectionTitleUpdates[id]), update)));
|
|
@@ -20,7 +20,6 @@ var _ui = require("@atlaskit/editor-common/ui");
|
|
|
20
20
|
var _menu = require("@atlaskit/menu");
|
|
21
21
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
22
22
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
23
|
-
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
24
23
|
var _closeTypeAhead = require("../pm-plugins/commands/close-type-ahead");
|
|
25
24
|
var _updateSelectedIndex = require("../pm-plugins/commands/update-selected-index");
|
|
26
25
|
var _constants = require("../pm-plugins/constants");
|
|
@@ -56,9 +55,6 @@ var shouldRenderSectionTitle = function shouldRenderSectionTitle(_ref) {
|
|
|
56
55
|
var isEmptyQuery = _ref.isEmptyQuery,
|
|
57
56
|
populatedSectionCount = _ref.populatedSectionCount,
|
|
58
57
|
section = _ref.section;
|
|
59
|
-
if (!(0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
60
|
-
return populatedSectionCount > 1;
|
|
61
|
-
}
|
|
62
58
|
if (!isEmptyQuery && ((_section$sectionTitle = section.sectionTitleDisplay) === null || _section$sectionTitle === void 0 ? void 0 : _section$sectionTitle.showWhenQueryPresent) === false) {
|
|
63
59
|
return false;
|
|
64
60
|
}
|
|
@@ -307,9 +303,10 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref4) {
|
|
|
307
303
|
}
|
|
308
304
|
});
|
|
309
305
|
}, [items, sections]);
|
|
306
|
+
var hasSections = sections && sections.length > 0;
|
|
310
307
|
(0, _react.useLayoutEffect)(function () {
|
|
311
308
|
// Exclude view more item from the count
|
|
312
|
-
var itemsToRender =
|
|
309
|
+
var itemsToRender = hasSections ? listRows : showMoreOptionsButton ? items.slice(0, -1) : items;
|
|
313
310
|
var height = Math.min(
|
|
314
311
|
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
|
|
315
312
|
itemsToRender.reduce(function (prevValue, currentValue, index) {
|
|
@@ -318,7 +315,7 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref4) {
|
|
|
318
315
|
});
|
|
319
316
|
}, 0), fitHeight);
|
|
320
317
|
setHeight(height);
|
|
321
|
-
}, [listRows, items, cache, fitHeight, showMoreOptionsButton]);
|
|
318
|
+
}, [listRows, items, cache, fitHeight, hasSections, showMoreOptionsButton]);
|
|
322
319
|
(0, _react.useLayoutEffect)(function () {
|
|
323
320
|
if (!listContainerRef.current) {
|
|
324
321
|
return;
|
|
@@ -377,7 +374,6 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref4) {
|
|
|
377
374
|
});
|
|
378
375
|
}, [items]);
|
|
379
376
|
var config = triggerHandler === null || triggerHandler === void 0 || (_triggerHandler$getMo = triggerHandler.getMoreOptionsButtonConfig) === null || _triggerHandler$getMo === void 0 ? void 0 : _triggerHandler$getMo.call(triggerHandler, intl);
|
|
380
|
-
var shouldRenderSectionLozenge = (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false);
|
|
381
377
|
var handleClick = function handleClick() {
|
|
382
378
|
if (onMoreOptionsClicked) {
|
|
383
379
|
onMoreOptionsClicked();
|
|
@@ -402,7 +398,7 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref4) {
|
|
|
402
398
|
if (!currentRow) {
|
|
403
399
|
return null;
|
|
404
400
|
}
|
|
405
|
-
var sectionLozenge = currentRow.type === 'section'
|
|
401
|
+
var sectionLozenge = currentRow.type === 'section' ? currentRow.section.lozenge : null;
|
|
406
402
|
return (0, _react2.jsx)(_CellMeasurer.CellMeasurer, {
|
|
407
403
|
key: key,
|
|
408
404
|
cache: cache,
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.buildSectionedResult = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
10
9
|
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
10
|
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
11
|
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,7 +14,7 @@ var buildSectionedResult = exports.buildSectionedResult = function buildSectione
|
|
|
15
14
|
var items = _ref.items,
|
|
16
15
|
triggerHandler = _ref.triggerHandler,
|
|
17
16
|
intl = _ref.intl;
|
|
18
|
-
if (!
|
|
17
|
+
if (!intl) {
|
|
19
18
|
return {
|
|
20
19
|
items: items,
|
|
21
20
|
sections: []
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
2
1
|
import { ACTIONS } from '../actions';
|
|
3
2
|
import { pluginKey as typeAheadPluginKey } from '../key';
|
|
4
3
|
export const updateSectionTitle = ({
|
|
@@ -7,7 +6,7 @@ export const updateSectionTitle = ({
|
|
|
7
6
|
sectionTitleDisplay
|
|
8
7
|
}) => {
|
|
9
8
|
return (state, dispatch) => {
|
|
10
|
-
if (!
|
|
9
|
+
if (!dispatch) {
|
|
11
10
|
return false;
|
|
12
11
|
}
|
|
13
12
|
const tr = state.tr;
|
|
@@ -2,8 +2,6 @@ import { InsertTypeAheadStages, InsertTypeAheadStep } from '@atlaskit/adf-schema
|
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { insm } from '@atlaskit/insm';
|
|
5
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
|
-
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
7
5
|
import { ACTIONS } from './actions';
|
|
8
6
|
import { pluginKey } from './key';
|
|
9
7
|
import { isTypeAheadHandler } from './utils';
|
|
@@ -27,9 +25,6 @@ const applySectionTitleUpdates = ({
|
|
|
27
25
|
sections,
|
|
28
26
|
sectionTitleUpdates
|
|
29
27
|
}) => {
|
|
30
|
-
if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
31
|
-
return sections;
|
|
32
|
-
}
|
|
33
28
|
const updatedSections = sections.map(section => {
|
|
34
29
|
const update = sectionTitleUpdates[section.id];
|
|
35
30
|
if (!update) {
|
|
@@ -63,6 +58,7 @@ export const createReducer = ({
|
|
|
63
58
|
selectedIndex,
|
|
64
59
|
removePrefixTriggerOnCancel
|
|
65
60
|
}) => {
|
|
61
|
+
var _insm$session;
|
|
66
62
|
removeDecorations(currentPluginState.decorationSet);
|
|
67
63
|
const {
|
|
68
64
|
decorationSet,
|
|
@@ -73,10 +69,7 @@ export const createReducer = ({
|
|
|
73
69
|
inputMethod,
|
|
74
70
|
reopenQuery
|
|
75
71
|
});
|
|
76
|
-
|
|
77
|
-
var _insm$session;
|
|
78
|
-
(_insm$session = insm.session) === null || _insm$session === void 0 ? void 0 : _insm$session.startFeature('typeaheadOpen');
|
|
79
|
-
}
|
|
72
|
+
(_insm$session = insm.session) === null || _insm$session === void 0 ? void 0 : _insm$session.startFeature('typeaheadOpen');
|
|
80
73
|
return {
|
|
81
74
|
...currentPluginState,
|
|
82
75
|
stats,
|
|
@@ -93,11 +86,9 @@ export const createReducer = ({
|
|
|
93
86
|
};
|
|
94
87
|
};
|
|
95
88
|
const closeMenu = currentPluginState => {
|
|
89
|
+
var _insm$session2;
|
|
96
90
|
removeDecorations(currentPluginState.decorationSet);
|
|
97
|
-
|
|
98
|
-
var _insm$session2;
|
|
99
|
-
(_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('typeaheadOpen');
|
|
100
|
-
}
|
|
91
|
+
(_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('typeaheadOpen');
|
|
101
92
|
return {
|
|
102
93
|
...currentPluginState,
|
|
103
94
|
inputMethod: null,
|
|
@@ -186,9 +177,6 @@ export const createReducer = ({
|
|
|
186
177
|
selectedIndex: Math.max(selectedIndex >= items.length ? items.length - 1 : selectedIndex, -1)
|
|
187
178
|
};
|
|
188
179
|
} else if (shouldUpdateSectionTitleState) {
|
|
189
|
-
if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
190
|
-
return currentPluginState;
|
|
191
|
-
}
|
|
192
180
|
const {
|
|
193
181
|
id,
|
|
194
182
|
update
|
|
@@ -17,7 +17,6 @@ import { AssistiveText } from '@atlaskit/editor-common/ui';
|
|
|
17
17
|
import { MenuGroup } from '@atlaskit/menu';
|
|
18
18
|
import { Box, Inline, Text } from '@atlaskit/primitives/compiled';
|
|
19
19
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
20
|
-
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
21
20
|
import { closeTypeAhead } from '../pm-plugins/commands/close-type-ahead';
|
|
22
21
|
import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
|
|
23
22
|
import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
|
|
@@ -46,9 +45,6 @@ const shouldRenderSectionTitle = ({
|
|
|
46
45
|
section
|
|
47
46
|
}) => {
|
|
48
47
|
var _section$sectionTitle;
|
|
49
|
-
if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
50
|
-
return populatedSectionCount > 1;
|
|
51
|
-
}
|
|
52
48
|
if (!isEmptyQuery && ((_section$sectionTitle = section.sectionTitleDisplay) === null || _section$sectionTitle === void 0 ? void 0 : _section$sectionTitle.showWhenQueryPresent) === false) {
|
|
53
49
|
return false;
|
|
54
50
|
}
|
|
@@ -280,9 +276,10 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
|
|
|
280
276
|
}
|
|
281
277
|
});
|
|
282
278
|
}, [items, sections]);
|
|
279
|
+
const hasSections = sections && sections.length > 0;
|
|
283
280
|
useLayoutEffect(() => {
|
|
284
281
|
// Exclude view more item from the count
|
|
285
|
-
const itemsToRender =
|
|
282
|
+
const itemsToRender = hasSections ? listRows : showMoreOptionsButton ? items.slice(0, -1) : items;
|
|
286
283
|
const height = Math.min(
|
|
287
284
|
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
|
|
288
285
|
itemsToRender.reduce((prevValue, currentValue, index) => {
|
|
@@ -291,7 +288,7 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
|
|
|
291
288
|
});
|
|
292
289
|
}, 0), fitHeight);
|
|
293
290
|
setHeight(height);
|
|
294
|
-
}, [listRows, items, cache, fitHeight, showMoreOptionsButton]);
|
|
291
|
+
}, [listRows, items, cache, fitHeight, hasSections, showMoreOptionsButton]);
|
|
295
292
|
useLayoutEffect(() => {
|
|
296
293
|
if (!listContainerRef.current) {
|
|
297
294
|
return;
|
|
@@ -350,7 +347,6 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
|
|
|
350
347
|
return items.findIndex(item => item.isDisabledOffline !== true);
|
|
351
348
|
}, [items]);
|
|
352
349
|
const config = triggerHandler === null || triggerHandler === void 0 ? void 0 : (_triggerHandler$getMo = triggerHandler.getMoreOptionsButtonConfig) === null || _triggerHandler$getMo === void 0 ? void 0 : _triggerHandler$getMo.call(triggerHandler, intl);
|
|
353
|
-
const shouldRenderSectionLozenge = expVal('platform_editor_agent_mentions', 'isEnabled', false);
|
|
354
350
|
const handleClick = () => {
|
|
355
351
|
if (onMoreOptionsClicked) {
|
|
356
352
|
onMoreOptionsClicked();
|
|
@@ -377,7 +373,7 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
|
|
|
377
373
|
if (!currentRow) {
|
|
378
374
|
return null;
|
|
379
375
|
}
|
|
380
|
-
const sectionLozenge = currentRow.type === 'section'
|
|
376
|
+
const sectionLozenge = currentRow.type === 'section' ? currentRow.section.lozenge : null;
|
|
381
377
|
return jsx(CellMeasurer, {
|
|
382
378
|
key: key,
|
|
383
379
|
cache: cache,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
2
1
|
export const buildSectionedResult = ({
|
|
3
2
|
items,
|
|
4
3
|
triggerHandler,
|
|
5
4
|
intl
|
|
6
5
|
}) => {
|
|
7
6
|
var _triggerHandler$getSe;
|
|
8
|
-
if (!
|
|
7
|
+
if (!intl) {
|
|
9
8
|
return {
|
|
10
9
|
items,
|
|
11
10
|
sections: []
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
2
1
|
import { ACTIONS } from '../actions';
|
|
3
2
|
import { pluginKey as typeAheadPluginKey } from '../key';
|
|
4
3
|
export var updateSectionTitle = function updateSectionTitle(_ref) {
|
|
@@ -6,7 +5,7 @@ export var updateSectionTitle = function updateSectionTitle(_ref) {
|
|
|
6
5
|
title = _ref.title,
|
|
7
6
|
sectionTitleDisplay = _ref.sectionTitleDisplay;
|
|
8
7
|
return function (state, dispatch) {
|
|
9
|
-
if (!
|
|
8
|
+
if (!dispatch) {
|
|
10
9
|
return false;
|
|
11
10
|
}
|
|
12
11
|
var tr = state.tr;
|
|
@@ -5,8 +5,6 @@ import { InsertTypeAheadStages, InsertTypeAheadStep } from '@atlaskit/adf-schema
|
|
|
5
5
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import { insm } from '@atlaskit/insm';
|
|
8
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
|
-
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
10
8
|
import { ACTIONS } from './actions';
|
|
11
9
|
import { pluginKey } from './key';
|
|
12
10
|
import { isTypeAheadHandler } from './utils';
|
|
@@ -29,9 +27,6 @@ var shouldForceClose = function shouldForceClose(step) {
|
|
|
29
27
|
var applySectionTitleUpdates = function applySectionTitleUpdates(_ref) {
|
|
30
28
|
var sections = _ref.sections,
|
|
31
29
|
sectionTitleUpdates = _ref.sectionTitleUpdates;
|
|
32
|
-
if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
33
|
-
return sections;
|
|
34
|
-
}
|
|
35
30
|
var updatedSections = sections.map(function (section) {
|
|
36
31
|
var update = sectionTitleUpdates[section.id];
|
|
37
32
|
if (!update) {
|
|
@@ -58,6 +53,7 @@ export var createReducer = function createReducer(_ref2) {
|
|
|
58
53
|
createDecorations = _ref2.createDecorations;
|
|
59
54
|
var findHandler = createFindHandler(typeAheadHandlers);
|
|
60
55
|
var openMenu = function openMenu(currentPluginState, _ref3) {
|
|
56
|
+
var _insm$session;
|
|
61
57
|
var tr = _ref3.tr,
|
|
62
58
|
triggerHandler = _ref3.triggerHandler,
|
|
63
59
|
inputMethod = _ref3.inputMethod,
|
|
@@ -73,10 +69,7 @@ export var createReducer = function createReducer(_ref2) {
|
|
|
73
69
|
decorationSet = _createDecorations.decorationSet,
|
|
74
70
|
decorationElement = _createDecorations.decorationElement,
|
|
75
71
|
stats = _createDecorations.stats;
|
|
76
|
-
|
|
77
|
-
var _insm$session;
|
|
78
|
-
(_insm$session = insm.session) === null || _insm$session === void 0 || _insm$session.startFeature('typeaheadOpen');
|
|
79
|
-
}
|
|
72
|
+
(_insm$session = insm.session) === null || _insm$session === void 0 || _insm$session.startFeature('typeaheadOpen');
|
|
80
73
|
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
81
74
|
stats: stats,
|
|
82
75
|
decorationSet: decorationSet,
|
|
@@ -92,11 +85,9 @@ export var createReducer = function createReducer(_ref2) {
|
|
|
92
85
|
});
|
|
93
86
|
};
|
|
94
87
|
var closeMenu = function closeMenu(currentPluginState) {
|
|
88
|
+
var _insm$session2;
|
|
95
89
|
removeDecorations(currentPluginState.decorationSet);
|
|
96
|
-
|
|
97
|
-
var _insm$session2;
|
|
98
|
-
(_insm$session2 = insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('typeaheadOpen');
|
|
99
|
-
}
|
|
90
|
+
(_insm$session2 = insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('typeaheadOpen');
|
|
100
91
|
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
101
92
|
inputMethod: null,
|
|
102
93
|
query: '',
|
|
@@ -175,9 +166,6 @@ export var createReducer = function createReducer(_ref2) {
|
|
|
175
166
|
selectedIndex: Math.max(selectedIndex >= items.length ? items.length - 1 : selectedIndex, -1)
|
|
176
167
|
});
|
|
177
168
|
} else if (shouldUpdateSectionTitleState) {
|
|
178
|
-
if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
179
|
-
return currentPluginState;
|
|
180
|
-
}
|
|
181
169
|
var id = params.id,
|
|
182
170
|
update = params.update;
|
|
183
171
|
var sectionTitleUpdates = _objectSpread(_objectSpread({}, currentPluginState.sectionTitleUpdates), {}, _defineProperty({}, id, _objectSpread(_objectSpread({}, currentPluginState.sectionTitleUpdates[id]), update)));
|
|
@@ -19,7 +19,6 @@ import { AssistiveText } from '@atlaskit/editor-common/ui';
|
|
|
19
19
|
import { MenuGroup } from '@atlaskit/menu';
|
|
20
20
|
import { Box, Inline, Text } from '@atlaskit/primitives/compiled';
|
|
21
21
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
22
|
-
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
23
22
|
import { closeTypeAhead } from '../pm-plugins/commands/close-type-ahead';
|
|
24
23
|
import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
|
|
25
24
|
import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
|
|
@@ -47,9 +46,6 @@ var shouldRenderSectionTitle = function shouldRenderSectionTitle(_ref) {
|
|
|
47
46
|
var isEmptyQuery = _ref.isEmptyQuery,
|
|
48
47
|
populatedSectionCount = _ref.populatedSectionCount,
|
|
49
48
|
section = _ref.section;
|
|
50
|
-
if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
51
|
-
return populatedSectionCount > 1;
|
|
52
|
-
}
|
|
53
49
|
if (!isEmptyQuery && ((_section$sectionTitle = section.sectionTitleDisplay) === null || _section$sectionTitle === void 0 ? void 0 : _section$sectionTitle.showWhenQueryPresent) === false) {
|
|
54
50
|
return false;
|
|
55
51
|
}
|
|
@@ -298,9 +294,10 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref4) {
|
|
|
298
294
|
}
|
|
299
295
|
});
|
|
300
296
|
}, [items, sections]);
|
|
297
|
+
var hasSections = sections && sections.length > 0;
|
|
301
298
|
useLayoutEffect(function () {
|
|
302
299
|
// Exclude view more item from the count
|
|
303
|
-
var itemsToRender =
|
|
300
|
+
var itemsToRender = hasSections ? listRows : showMoreOptionsButton ? items.slice(0, -1) : items;
|
|
304
301
|
var height = Math.min(
|
|
305
302
|
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
|
|
306
303
|
itemsToRender.reduce(function (prevValue, currentValue, index) {
|
|
@@ -309,7 +306,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref4) {
|
|
|
309
306
|
});
|
|
310
307
|
}, 0), fitHeight);
|
|
311
308
|
setHeight(height);
|
|
312
|
-
}, [listRows, items, cache, fitHeight, showMoreOptionsButton]);
|
|
309
|
+
}, [listRows, items, cache, fitHeight, hasSections, showMoreOptionsButton]);
|
|
313
310
|
useLayoutEffect(function () {
|
|
314
311
|
if (!listContainerRef.current) {
|
|
315
312
|
return;
|
|
@@ -368,7 +365,6 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref4) {
|
|
|
368
365
|
});
|
|
369
366
|
}, [items]);
|
|
370
367
|
var config = triggerHandler === null || triggerHandler === void 0 || (_triggerHandler$getMo = triggerHandler.getMoreOptionsButtonConfig) === null || _triggerHandler$getMo === void 0 ? void 0 : _triggerHandler$getMo.call(triggerHandler, intl);
|
|
371
|
-
var shouldRenderSectionLozenge = expVal('platform_editor_agent_mentions', 'isEnabled', false);
|
|
372
368
|
var handleClick = function handleClick() {
|
|
373
369
|
if (onMoreOptionsClicked) {
|
|
374
370
|
onMoreOptionsClicked();
|
|
@@ -393,7 +389,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref4) {
|
|
|
393
389
|
if (!currentRow) {
|
|
394
390
|
return null;
|
|
395
391
|
}
|
|
396
|
-
var sectionLozenge = currentRow.type === 'section'
|
|
392
|
+
var sectionLozenge = currentRow.type === 'section' ? currentRow.section.lozenge : null;
|
|
397
393
|
return jsx(CellMeasurer, {
|
|
398
394
|
key: key,
|
|
399
395
|
cache: cache,
|
|
@@ -2,13 +2,12 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
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
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
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 { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
6
5
|
export var buildSectionedResult = function buildSectionedResult(_ref) {
|
|
7
6
|
var _triggerHandler$getSe;
|
|
8
7
|
var items = _ref.items,
|
|
9
8
|
triggerHandler = _ref.triggerHandler,
|
|
10
9
|
intl = _ref.intl;
|
|
11
|
-
if (!
|
|
10
|
+
if (!intl) {
|
|
12
11
|
return {
|
|
13
12
|
items: items,
|
|
14
13
|
sections: []
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-type-ahead",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.2",
|
|
4
4
|
"description": "Type-ahead plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@atlaskit/primitives": "^20.5.0",
|
|
37
37
|
"@atlaskit/prosemirror-history": "^1.0.0",
|
|
38
38
|
"@atlaskit/prosemirror-input-rules": "^4.0.0",
|
|
39
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
39
|
+
"@atlaskit/tmp-editor-statsig": "^124.1.0",
|
|
40
40
|
"@atlaskit/tokens": "^15.5.0",
|
|
41
41
|
"@atlaskit/visually-hidden": "^4.1.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"w3c-keyname": "^2.1.8"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@atlaskit/editor-common": "^116.
|
|
51
|
+
"@atlaskit/editor-common": "^116.25.0",
|
|
52
52
|
"react": "^18.2.0",
|
|
53
53
|
"react-dom": "^18.2.0",
|
|
54
54
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|