@atlaskit/editor-plugin-type-ahead 2.2.4 → 2.3.1
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 +22 -0
- package/dist/cjs/pm-plugins/commands/open-typeahead-at-cursor.js +8 -4
- package/dist/cjs/pm-plugins/main.js +2 -1
- package/dist/cjs/pm-plugins/reducer.js +8 -4
- package/dist/cjs/typeAheadPlugin.js +4 -2
- package/dist/cjs/ui/InputQuery.js +14 -9
- package/dist/cjs/ui/TypeAheadList.js +2 -2
- package/dist/cjs/ui/TypeAheadPopup.js +11 -4
- package/dist/es2019/pm-plugins/commands/open-typeahead-at-cursor.js +8 -4
- package/dist/es2019/pm-plugins/main.js +2 -1
- package/dist/es2019/pm-plugins/reducer.js +8 -4
- package/dist/es2019/typeAheadPlugin.js +4 -2
- package/dist/es2019/ui/InputQuery.js +14 -8
- package/dist/es2019/ui/TypeAheadList.js +1 -1
- package/dist/es2019/ui/TypeAheadPopup.js +13 -4
- package/dist/esm/pm-plugins/commands/open-typeahead-at-cursor.js +8 -4
- package/dist/esm/pm-plugins/main.js +2 -1
- package/dist/esm/pm-plugins/reducer.js +8 -4
- package/dist/esm/typeAheadPlugin.js +4 -2
- package/dist/esm/ui/InputQuery.js +13 -8
- package/dist/esm/ui/TypeAheadList.js +1 -1
- package/dist/esm/ui/TypeAheadPopup.js +11 -4
- package/dist/types/pm-plugins/commands/open-typeahead-at-cursor.d.ts +3 -9
- package/dist/types/typeAheadPluginType.d.ts +1 -6
- package/dist/types/types/index.d.ts +10 -0
- package/dist/types-ts4.5/pm-plugins/commands/open-typeahead-at-cursor.d.ts +3 -9
- package/dist/types-ts4.5/typeAheadPluginType.d.ts +1 -6
- package/dist/types-ts4.5/types/index.d.ts +10 -0
- package/package.json +9 -6
- package/dist/cjs/ui/AssistiveText.js +0 -94
- package/dist/es2019/ui/AssistiveText.js +0 -68
- package/dist/esm/ui/AssistiveText.js +0 -87
- package/dist/types/ui/AssistiveText.d.ts +0 -14
- package/dist/types-ts4.5/ui/AssistiveText.d.ts +0 -14
|
@@ -44,7 +44,8 @@ export var createReducer = function createReducer(_ref) {
|
|
|
44
44
|
triggerHandler = _ref2.triggerHandler,
|
|
45
45
|
inputMethod = _ref2.inputMethod,
|
|
46
46
|
reopenQuery = _ref2.reopenQuery,
|
|
47
|
-
selectedIndex = _ref2.selectedIndex
|
|
47
|
+
selectedIndex = _ref2.selectedIndex,
|
|
48
|
+
removePrefixTriggerOnCancel = _ref2.removePrefixTriggerOnCancel;
|
|
48
49
|
removeDecorations(currentPluginState.decorationSet);
|
|
49
50
|
var _createDecorations = createDecorations(tr, {
|
|
50
51
|
triggerHandler: triggerHandler,
|
|
@@ -62,7 +63,8 @@ export var createReducer = function createReducer(_ref) {
|
|
|
62
63
|
inputMethod: inputMethod,
|
|
63
64
|
selectedIndex: typeof selectedIndex === 'number' ? selectedIndex : -1,
|
|
64
65
|
items: [],
|
|
65
|
-
query: reopenQuery || ''
|
|
66
|
+
query: reopenQuery || '',
|
|
67
|
+
removePrefixTriggerOnCancel: removePrefixTriggerOnCancel
|
|
66
68
|
});
|
|
67
69
|
};
|
|
68
70
|
var closeMenu = function closeMenu(currentPluginState) {
|
|
@@ -74,7 +76,8 @@ export var createReducer = function createReducer(_ref) {
|
|
|
74
76
|
decorationSet: DecorationSet.empty,
|
|
75
77
|
stats: null,
|
|
76
78
|
triggerHandler: undefined,
|
|
77
|
-
items: []
|
|
79
|
+
items: [],
|
|
80
|
+
removePrefixTriggerOnCancel: undefined
|
|
78
81
|
});
|
|
79
82
|
};
|
|
80
83
|
return function (tr, currentPluginState, typeAheadStepOverride) {
|
|
@@ -109,7 +112,8 @@ export var createReducer = function createReducer(_ref) {
|
|
|
109
112
|
tr: tr,
|
|
110
113
|
triggerHandler: params.triggerHandler,
|
|
111
114
|
inputMethod: params.inputMethod,
|
|
112
|
-
reopenQuery: params.query
|
|
115
|
+
reopenQuery: params.query,
|
|
116
|
+
removePrefixTriggerOnCancel: params.removePrefixTriggerOnCancel
|
|
113
117
|
});
|
|
114
118
|
} else if (shouldCloseMenu) {
|
|
115
119
|
return closeMenu(currentPluginState);
|
|
@@ -27,11 +27,13 @@ var createOpenAtTransaction = function createOpenAtTransaction(editorAnalyticsAP
|
|
|
27
27
|
return function (tr) {
|
|
28
28
|
var triggerHandler = props.triggerHandler,
|
|
29
29
|
inputMethod = props.inputMethod,
|
|
30
|
-
query = props.query
|
|
30
|
+
query = props.query,
|
|
31
|
+
removePrefixTriggerOnCancel = props.removePrefixTriggerOnCancel;
|
|
31
32
|
openTypeAheadAtCursor({
|
|
32
33
|
triggerHandler: triggerHandler,
|
|
33
34
|
inputMethod: inputMethod,
|
|
34
|
-
query: query
|
|
35
|
+
query: query,
|
|
36
|
+
removePrefixTriggerOnCancel: removePrefixTriggerOnCancel
|
|
35
37
|
})({
|
|
36
38
|
tr: tr
|
|
37
39
|
});
|
|
@@ -11,11 +11,12 @@ import { useIntl } from 'react-intl-next';
|
|
|
11
11
|
import { keyName as keyNameNormalized } from 'w3c-keyname';
|
|
12
12
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
13
13
|
import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
14
|
+
import { AssistiveText } from '@atlaskit/editor-common/ui';
|
|
14
15
|
import { blockNodesVerticalMargin } from '@atlaskit/editor-shared-styles';
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
17
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
16
18
|
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_ELEMENT_ID, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../pm-plugins/constants';
|
|
17
19
|
import { getPluginState } from '../pm-plugins/utils';
|
|
18
|
-
import { AssistiveText } from './AssistiveText';
|
|
19
20
|
var placeholderStyles = css({
|
|
20
21
|
'&::after': {
|
|
21
22
|
content: 'attr(data-place-holder)',
|
|
@@ -98,6 +99,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
98
99
|
query = _useState2[0],
|
|
99
100
|
setQuery = _useState2[1];
|
|
100
101
|
var isEditorControlsEnabled = editorExperiment('platform_editor_insertion', 'variant1');
|
|
102
|
+
var isEditorControlsPatch2Enabled = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2');
|
|
101
103
|
var _useState3 = useState(isEditorControlsEnabled && triggerQueryPrefix === '/'),
|
|
102
104
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
103
105
|
showPlaceholder = _useState4[0],
|
|
@@ -128,7 +130,8 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
128
130
|
var text = cleanedInputContent();
|
|
129
131
|
var stopDefault = false;
|
|
130
132
|
var _ref2 = getPluginState(editorView.state) || {},
|
|
131
|
-
selectedIndex = _ref2.selectedIndex
|
|
133
|
+
selectedIndex = _ref2.selectedIndex,
|
|
134
|
+
removePrefixTriggerOnCancel = _ref2.removePrefixTriggerOnCancel;
|
|
132
135
|
setInFocus(true);
|
|
133
136
|
switch (key) {
|
|
134
137
|
case ' ':
|
|
@@ -137,7 +140,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
137
140
|
cancel({
|
|
138
141
|
forceFocusOnEditor: true,
|
|
139
142
|
text: ' ',
|
|
140
|
-
addPrefixTrigger: true,
|
|
143
|
+
addPrefixTrigger: isEditorControlsPatch2Enabled ? !removePrefixTriggerOnCancel : true,
|
|
141
144
|
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED
|
|
142
145
|
});
|
|
143
146
|
stopDefault = true;
|
|
@@ -150,7 +153,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
150
153
|
cancel({
|
|
151
154
|
text: text,
|
|
152
155
|
forceFocusOnEditor: true,
|
|
153
|
-
addPrefixTrigger: true,
|
|
156
|
+
addPrefixTrigger: isEditorControlsPatch2Enabled ? !removePrefixTriggerOnCancel : true,
|
|
154
157
|
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED
|
|
155
158
|
});
|
|
156
159
|
stopDefault = true;
|
|
@@ -222,7 +225,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
222
225
|
event.preventDefault();
|
|
223
226
|
return false;
|
|
224
227
|
}
|
|
225
|
-
}, [onUndoRedo, onItemSelect, selectNextItem, selectPreviousItem, cancel, cleanedInputContent, editorView.state]);
|
|
228
|
+
}, [onUndoRedo, onItemSelect, selectNextItem, selectPreviousItem, cancel, cleanedInputContent, editorView.state, isEditorControlsPatch2Enabled]);
|
|
226
229
|
var onClick = useCallback(function (event) {
|
|
227
230
|
var _inputRef$current;
|
|
228
231
|
event.stopPropagation();
|
|
@@ -236,6 +239,8 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
236
239
|
return;
|
|
237
240
|
}
|
|
238
241
|
var element = ref.current;
|
|
242
|
+
var _ref3 = getPluginState(editorView.state) || {},
|
|
243
|
+
removePrefixTriggerOnCancel = _ref3.removePrefixTriggerOnCancel;
|
|
239
244
|
var onFocusIn = function onFocusIn(event) {
|
|
240
245
|
onQueryFocus();
|
|
241
246
|
};
|
|
@@ -252,7 +257,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
252
257
|
}
|
|
253
258
|
cancel({
|
|
254
259
|
forceFocusOnEditor: true,
|
|
255
|
-
addPrefixTrigger: true,
|
|
260
|
+
addPrefixTrigger: isEditorControlsPatch2Enabled ? !removePrefixTriggerOnCancel : true,
|
|
256
261
|
text: cleanedInputContent(),
|
|
257
262
|
setSelectionAt: isMovingRight ? CloseSelectionOptions.AFTER_TEXT_INSERTED : CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
258
263
|
});
|
|
@@ -282,7 +287,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
282
287
|
return;
|
|
283
288
|
}
|
|
284
289
|
cancel({
|
|
285
|
-
addPrefixTrigger: true,
|
|
290
|
+
addPrefixTrigger: isEditorControlsPatch2Enabled ? !removePrefixTriggerOnCancel : true,
|
|
286
291
|
text: cleanedInputContent(),
|
|
287
292
|
setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED,
|
|
288
293
|
forceFocusOnEditor: false
|
|
@@ -382,7 +387,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
382
387
|
element.removeEventListener('input', onInput);
|
|
383
388
|
}
|
|
384
389
|
};
|
|
385
|
-
}, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent, editorView.state]);
|
|
390
|
+
}, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent, editorView.state, isEditorControlsPatch2Enabled]);
|
|
386
391
|
useLayoutEffect(function () {
|
|
387
392
|
var hasReopenQuery = typeof reopenQuery === 'string' && reopenQuery.trim().length > 0;
|
|
388
393
|
if (ref.current && forceFocus) {
|
|
@@ -13,13 +13,13 @@ import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs
|
|
|
13
13
|
import { List } from 'react-virtualized/dist/commonjs/List';
|
|
14
14
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
15
15
|
import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
16
|
+
import { AssistiveText } from '@atlaskit/editor-common/ui';
|
|
16
17
|
import { MenuGroup } from '@atlaskit/menu';
|
|
17
18
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
19
|
import { Text, Box } from '@atlaskit/primitives';
|
|
19
20
|
import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
|
|
20
21
|
import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
|
|
21
22
|
import { getTypeAheadListAriaLabels, moveSelectedIndex } from '../pm-plugins/utils';
|
|
22
|
-
import { AssistiveText } from './AssistiveText';
|
|
23
23
|
import { ListRow } from './ListRow';
|
|
24
24
|
import { TypeAheadListItem } from './TypeAheadListItem';
|
|
25
25
|
import { ViewMore } from './ViewMore';
|
|
@@ -15,8 +15,10 @@ import { findOverflowScrollParent, Popup } from '@atlaskit/editor-common/ui';
|
|
|
15
15
|
import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
|
|
16
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
17
|
import { N0, N50A, N60A } from '@atlaskit/theme/colors';
|
|
18
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
18
19
|
import { closeTypeAhead } from '../pm-plugins/commands/close-type-ahead';
|
|
19
20
|
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../pm-plugins/constants';
|
|
21
|
+
import { getPluginState } from '../pm-plugins/utils';
|
|
20
22
|
import { TypeAheadErrorFallback } from './TypeAheadErrorFallback';
|
|
21
23
|
import { TypeAheadList } from './TypeAheadList';
|
|
22
24
|
var DEFAULT_TYPEAHEAD_MENU_HEIGHT = 380;
|
|
@@ -69,6 +71,7 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
69
71
|
var _useSharedPluginState = useSharedPluginState(api, ['featureFlags']),
|
|
70
72
|
featureFlagsState = _useSharedPluginState.featureFlagsState;
|
|
71
73
|
var moreElementsInQuickInsertViewEnabled = (featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.moreElementsInQuickInsertView) && triggerHandler.id === TypeAheadAvailableNodes.QUICK_INSERT;
|
|
74
|
+
var isEditorControlsPatch2Enabled = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2');
|
|
72
75
|
var defaultMenuHeight = useMemo(function () {
|
|
73
76
|
return moreElementsInQuickInsertViewEnabled ? DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW : DEFAULT_TYPEAHEAD_MENU_HEIGHT;
|
|
74
77
|
}, [moreElementsInQuickInsertViewEnabled]);
|
|
@@ -193,6 +196,8 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
193
196
|
};
|
|
194
197
|
}, [anchorElement, popupsScrollableElement, getFitHeightDebounced, getFitHeight]);
|
|
195
198
|
useLayoutEffect(function () {
|
|
199
|
+
var _ref2 = getPluginState(editorView.state) || {},
|
|
200
|
+
removePrefixTriggerOnCancel = _ref2.removePrefixTriggerOnCancel;
|
|
196
201
|
var focusOut = function focusOut(event) {
|
|
197
202
|
var _window$getSelection;
|
|
198
203
|
var relatedTarget = event.relatedTarget;
|
|
@@ -242,7 +247,7 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
242
247
|
}
|
|
243
248
|
}
|
|
244
249
|
cancel({
|
|
245
|
-
addPrefixTrigger: true,
|
|
250
|
+
addPrefixTrigger: isEditorControlsPatch2Enabled ? !removePrefixTriggerOnCancel : true,
|
|
246
251
|
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
|
|
247
252
|
forceFocusOnEditor: false
|
|
248
253
|
});
|
|
@@ -256,15 +261,17 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
256
261
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
257
262
|
element === null || element === void 0 || element.removeEventListener('focusout', focusOut);
|
|
258
263
|
};
|
|
259
|
-
}, [ref, cancel]);
|
|
264
|
+
}, [ref, cancel, editorView.state, isEditorControlsPatch2Enabled]);
|
|
260
265
|
|
|
261
266
|
// TODO: ED-17443 - When you press escape on typeahead panel, it should remove focus and close the panel
|
|
262
267
|
// This is the expected keyboard behaviour advised by the Accessibility team
|
|
263
268
|
useLayoutEffect(function () {
|
|
269
|
+
var _ref3 = getPluginState(editorView.state) || {},
|
|
270
|
+
removePrefixTriggerOnCancel = _ref3.removePrefixTriggerOnCancel;
|
|
264
271
|
var escape = function escape(event) {
|
|
265
272
|
if (event.key === 'Escape') {
|
|
266
273
|
cancel({
|
|
267
|
-
addPrefixTrigger: true,
|
|
274
|
+
addPrefixTrigger: isEditorControlsPatch2Enabled ? !removePrefixTriggerOnCancel : true,
|
|
268
275
|
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED,
|
|
269
276
|
forceFocusOnEditor: true
|
|
270
277
|
});
|
|
@@ -279,7 +286,7 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
|
|
|
279
286
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
280
287
|
element === null || element === void 0 || element.removeEventListener('keydown', escape);
|
|
281
288
|
};
|
|
282
|
-
}, [ref, cancel]);
|
|
289
|
+
}, [ref, cancel, editorView.state, isEditorControlsPatch2Enabled]);
|
|
283
290
|
|
|
284
291
|
// @ts-ignore
|
|
285
292
|
var openElementBrowserModal = triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.openElementBrowserModal;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { EditorCommand } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
inputMethod: TypeAheadInputMethod;
|
|
7
|
-
query?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const openTypeAhead: (props: Props) => (tr: Transaction) => void;
|
|
10
|
-
export declare const openTypeAheadAtCursor: ({ triggerHandler, inputMethod, query }: Props) => EditorCommand;
|
|
11
|
-
export {};
|
|
3
|
+
import type { OpenTypeAheadProps } from '../../types';
|
|
4
|
+
export declare const openTypeAhead: (props: OpenTypeAheadProps) => (tr: Transaction) => void;
|
|
5
|
+
export declare const openTypeAheadAtCursor: ({ triggerHandler, inputMethod, query, removePrefixTriggerOnCancel, }: OpenTypeAheadProps) => EditorCommand;
|
|
@@ -5,7 +5,7 @@ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
|
5
5
|
import type { ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
|
|
6
6
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
7
7
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
import { type
|
|
8
|
+
import { type TypeAheadPluginOptions, type TypeAheadPluginSharedState, type OpenTypeAheadProps } from './types';
|
|
9
9
|
type InsertTypeAheadItemProps = {
|
|
10
10
|
triggerHandler: TypeAheadHandler;
|
|
11
11
|
contentItem: TypeAheadItem;
|
|
@@ -13,11 +13,6 @@ type InsertTypeAheadItemProps = {
|
|
|
13
13
|
sourceListItem: TypeAheadItem[];
|
|
14
14
|
mode?: SelectItemMode;
|
|
15
15
|
};
|
|
16
|
-
type OpenTypeAheadProps = {
|
|
17
|
-
triggerHandler: TypeAheadHandler;
|
|
18
|
-
inputMethod: TypeAheadInputMethod;
|
|
19
|
-
query?: string;
|
|
20
|
-
};
|
|
21
16
|
type CloseTypeAheadProps = {
|
|
22
17
|
insertCurrentQueryAsRawText: boolean;
|
|
23
18
|
attachCommand?: Command;
|
|
@@ -35,6 +35,10 @@ export type TypeAheadPluginState = {
|
|
|
35
35
|
selectedIndex: number;
|
|
36
36
|
stats: TypeAheadStatsSerializable | null;
|
|
37
37
|
inputMethod: TypeAheadInputMethod | null;
|
|
38
|
+
/**
|
|
39
|
+
* If true, removes the trigger character from query when typeahead is closed
|
|
40
|
+
*/
|
|
41
|
+
removePrefixTriggerOnCancel?: boolean;
|
|
38
42
|
};
|
|
39
43
|
export type OnInsertSelectedItemProps = {
|
|
40
44
|
mode: SelectItemMode;
|
|
@@ -87,3 +91,9 @@ export interface TypeAheadPluginSharedState {
|
|
|
87
91
|
errorInfo: TypeAheadErrorInfo;
|
|
88
92
|
selectedIndex: number;
|
|
89
93
|
}
|
|
94
|
+
export type OpenTypeAheadProps = {
|
|
95
|
+
triggerHandler: TypeAheadHandler;
|
|
96
|
+
inputMethod: TypeAheadInputMethod;
|
|
97
|
+
query?: string;
|
|
98
|
+
removePrefixTriggerOnCancel?: boolean;
|
|
99
|
+
};
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { EditorCommand } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
inputMethod: TypeAheadInputMethod;
|
|
7
|
-
query?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const openTypeAhead: (props: Props) => (tr: Transaction) => void;
|
|
10
|
-
export declare const openTypeAheadAtCursor: ({ triggerHandler, inputMethod, query }: Props) => EditorCommand;
|
|
11
|
-
export {};
|
|
3
|
+
import type { OpenTypeAheadProps } from '../../types';
|
|
4
|
+
export declare const openTypeAhead: (props: OpenTypeAheadProps) => (tr: Transaction) => void;
|
|
5
|
+
export declare const openTypeAheadAtCursor: ({ triggerHandler, inputMethod, query, removePrefixTriggerOnCancel, }: OpenTypeAheadProps) => EditorCommand;
|
|
@@ -5,7 +5,7 @@ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
|
5
5
|
import type { ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
|
|
6
6
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
7
7
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
import { type
|
|
8
|
+
import { type TypeAheadPluginOptions, type TypeAheadPluginSharedState, type OpenTypeAheadProps } from './types';
|
|
9
9
|
type InsertTypeAheadItemProps = {
|
|
10
10
|
triggerHandler: TypeAheadHandler;
|
|
11
11
|
contentItem: TypeAheadItem;
|
|
@@ -13,11 +13,6 @@ type InsertTypeAheadItemProps = {
|
|
|
13
13
|
sourceListItem: TypeAheadItem[];
|
|
14
14
|
mode?: SelectItemMode;
|
|
15
15
|
};
|
|
16
|
-
type OpenTypeAheadProps = {
|
|
17
|
-
triggerHandler: TypeAheadHandler;
|
|
18
|
-
inputMethod: TypeAheadInputMethod;
|
|
19
|
-
query?: string;
|
|
20
|
-
};
|
|
21
16
|
type CloseTypeAheadProps = {
|
|
22
17
|
insertCurrentQueryAsRawText: boolean;
|
|
23
18
|
attachCommand?: Command;
|
|
@@ -35,6 +35,10 @@ export type TypeAheadPluginState = {
|
|
|
35
35
|
selectedIndex: number;
|
|
36
36
|
stats: TypeAheadStatsSerializable | null;
|
|
37
37
|
inputMethod: TypeAheadInputMethod | null;
|
|
38
|
+
/**
|
|
39
|
+
* If true, removes the trigger character from query when typeahead is closed
|
|
40
|
+
*/
|
|
41
|
+
removePrefixTriggerOnCancel?: boolean;
|
|
38
42
|
};
|
|
39
43
|
export type OnInsertSelectedItemProps = {
|
|
40
44
|
mode: SelectItemMode;
|
|
@@ -87,3 +91,9 @@ export interface TypeAheadPluginSharedState {
|
|
|
87
91
|
errorInfo: TypeAheadErrorInfo;
|
|
88
92
|
selectedIndex: number;
|
|
89
93
|
}
|
|
94
|
+
export type OpenTypeAheadProps = {
|
|
95
|
+
triggerHandler: TypeAheadHandler;
|
|
96
|
+
inputMethod: TypeAheadInputMethod;
|
|
97
|
+
query?: string;
|
|
98
|
+
removePrefixTriggerOnCancel?: boolean;
|
|
99
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-type-ahead",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Type-ahead plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
37
|
-
"@atlaskit/editor-common": "^102.
|
|
37
|
+
"@atlaskit/editor-common": "^102.18.0",
|
|
38
38
|
"@atlaskit/editor-element-browser": "^0.1.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
40
40
|
"@atlaskit/editor-plugin-connectivity": "^2.0.0",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
43
43
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
44
44
|
"@atlaskit/heading": "^5.1.0",
|
|
45
|
-
"@atlaskit/icon": "^25.
|
|
45
|
+
"@atlaskit/icon": "^25.5.0",
|
|
46
46
|
"@atlaskit/menu": "^3.2.0",
|
|
47
47
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
48
|
-
"@atlaskit/primitives": "^14.
|
|
48
|
+
"@atlaskit/primitives": "^14.3.0",
|
|
49
49
|
"@atlaskit/prosemirror-input-rules": "^3.3.0",
|
|
50
50
|
"@atlaskit/theme": "^18.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
52
|
-
"@atlaskit/tokens": "^4.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^4.6.0",
|
|
52
|
+
"@atlaskit/tokens": "^4.6.0",
|
|
53
53
|
"@babel/runtime": "^7.0.0",
|
|
54
54
|
"@emotion/react": "^11.7.1",
|
|
55
55
|
"lodash": "^4.17.21",
|
|
@@ -109,6 +109,9 @@
|
|
|
109
109
|
},
|
|
110
110
|
"platform_editor_controls_patch_1": {
|
|
111
111
|
"type": "boolean"
|
|
112
|
+
},
|
|
113
|
+
"platform_editor_controls_patch_2": {
|
|
114
|
+
"type": "boolean"
|
|
112
115
|
}
|
|
113
116
|
}
|
|
114
117
|
}
|
|
@@ -1,94 +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.AssistiveText = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
var _react = require("react");
|
|
10
|
-
var _react2 = require("@emotion/react");
|
|
11
|
-
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
12
|
-
/**
|
|
13
|
-
* @jsxRuntime classic
|
|
14
|
-
* @jsx jsx
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
18
|
-
|
|
19
|
-
var assitiveTextStyles = (0, _react2.css)({
|
|
20
|
-
border: 0,
|
|
21
|
-
clip: 'rect(0 0 0 0)',
|
|
22
|
-
height: '1px',
|
|
23
|
-
marginbottom: '-1px',
|
|
24
|
-
marginright: '-1px',
|
|
25
|
-
overflow: 'hidden',
|
|
26
|
-
padding: 0,
|
|
27
|
-
position: 'absolute',
|
|
28
|
-
whitespace: 'nowrap',
|
|
29
|
-
width: '1px'
|
|
30
|
-
});
|
|
31
|
-
var AssistiveText = exports.AssistiveText = function AssistiveText(_ref) {
|
|
32
|
-
var _ref$assistiveText = _ref.assistiveText,
|
|
33
|
-
assistiveText = _ref$assistiveText === void 0 ? '' : _ref$assistiveText,
|
|
34
|
-
_ref$isInFocus = _ref.isInFocus,
|
|
35
|
-
isInFocus = _ref$isInFocus === void 0 ? false : _ref$isInFocus,
|
|
36
|
-
_ref$id = _ref.id,
|
|
37
|
-
id = _ref$id === void 0 ? '' : _ref$id,
|
|
38
|
-
_ref$statusDebounceMi = _ref.statusDebounceMillis,
|
|
39
|
-
statusDebounceMillis = _ref$statusDebounceMi === void 0 ? 1400 : _ref$statusDebounceMi;
|
|
40
|
-
var _useState = (0, _react.useState)(false),
|
|
41
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
42
|
-
bump = _useState2[0],
|
|
43
|
-
setBump = _useState2[1];
|
|
44
|
-
var _useState3 = (0, _react.useState)(false),
|
|
45
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
46
|
-
debounced = _useState4[0],
|
|
47
|
-
setDebounced = _useState4[1];
|
|
48
|
-
var _useState5 = (0, _react.useState)(false),
|
|
49
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
50
|
-
silenced = _useState6[0],
|
|
51
|
-
setSilenced = _useState6[1];
|
|
52
|
-
var debounceStatusUpdate = (0, _react.useMemo)(function () {
|
|
53
|
-
return (0, _debounce.default)(function () {
|
|
54
|
-
var shouldSilence = !isInFocus;
|
|
55
|
-
setBump(function (prevBump) {
|
|
56
|
-
return !prevBump;
|
|
57
|
-
});
|
|
58
|
-
setDebounced(true);
|
|
59
|
-
setSilenced(shouldSilence);
|
|
60
|
-
});
|
|
61
|
-
}, [isInFocus]);
|
|
62
|
-
(0, _react.useEffect)(function () {
|
|
63
|
-
if (!debounced) {
|
|
64
|
-
debounceStatusUpdate();
|
|
65
|
-
return function () {
|
|
66
|
-
debounceStatusUpdate.cancel();
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}, [assistiveText, isInFocus, debounced, debounceStatusUpdate]);
|
|
70
|
-
(0, _react.useEffect)(function () {
|
|
71
|
-
if (debounced) {
|
|
72
|
-
setBump(function (prevBump) {
|
|
73
|
-
return !prevBump;
|
|
74
|
-
});
|
|
75
|
-
setDebounced(true);
|
|
76
|
-
setSilenced(!isInFocus);
|
|
77
|
-
}
|
|
78
|
-
}, [assistiveText, isInFocus, debounced]);
|
|
79
|
-
return (0, _react2.jsx)("div", {
|
|
80
|
-
css: assitiveTextStyles
|
|
81
|
-
}, (0, _react2.jsx)("div", {
|
|
82
|
-
"data-testid": id + '__status--A',
|
|
83
|
-
id: id + '__status--A',
|
|
84
|
-
role: "status",
|
|
85
|
-
"aria-atomic": "true",
|
|
86
|
-
"aria-live": "polite"
|
|
87
|
-
}, !silenced && debounced && bump ? assistiveText : ''), (0, _react2.jsx)("div", {
|
|
88
|
-
"data-testid": id + '__status--B',
|
|
89
|
-
id: id + '__status--B',
|
|
90
|
-
role: "status",
|
|
91
|
-
"aria-atomic": "true",
|
|
92
|
-
"aria-live": "polite"
|
|
93
|
-
}, !silenced && debounced && !bump ? assistiveText : ''));
|
|
94
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
|
-
import { css, jsx } from '@emotion/react';
|
|
10
|
-
import debounce from 'lodash/debounce';
|
|
11
|
-
const assitiveTextStyles = css({
|
|
12
|
-
border: 0,
|
|
13
|
-
clip: 'rect(0 0 0 0)',
|
|
14
|
-
height: '1px',
|
|
15
|
-
marginbottom: '-1px',
|
|
16
|
-
marginright: '-1px',
|
|
17
|
-
overflow: 'hidden',
|
|
18
|
-
padding: 0,
|
|
19
|
-
position: 'absolute',
|
|
20
|
-
whitespace: 'nowrap',
|
|
21
|
-
width: '1px'
|
|
22
|
-
});
|
|
23
|
-
export const AssistiveText = ({
|
|
24
|
-
assistiveText = '',
|
|
25
|
-
isInFocus = false,
|
|
26
|
-
id = '',
|
|
27
|
-
statusDebounceMillis = 1400
|
|
28
|
-
}) => {
|
|
29
|
-
const [bump, setBump] = useState(false);
|
|
30
|
-
const [debounced, setDebounced] = useState(false);
|
|
31
|
-
const [silenced, setSilenced] = useState(false);
|
|
32
|
-
const debounceStatusUpdate = useMemo(() => debounce(() => {
|
|
33
|
-
const shouldSilence = !isInFocus;
|
|
34
|
-
setBump(prevBump => !prevBump);
|
|
35
|
-
setDebounced(true);
|
|
36
|
-
setSilenced(shouldSilence);
|
|
37
|
-
}), [isInFocus]);
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (!debounced) {
|
|
40
|
-
debounceStatusUpdate();
|
|
41
|
-
return () => {
|
|
42
|
-
debounceStatusUpdate.cancel();
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}, [assistiveText, isInFocus, debounced, debounceStatusUpdate]);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (debounced) {
|
|
48
|
-
setBump(prevBump => !prevBump);
|
|
49
|
-
setDebounced(true);
|
|
50
|
-
setSilenced(!isInFocus);
|
|
51
|
-
}
|
|
52
|
-
}, [assistiveText, isInFocus, debounced]);
|
|
53
|
-
return jsx("div", {
|
|
54
|
-
css: assitiveTextStyles
|
|
55
|
-
}, jsx("div", {
|
|
56
|
-
"data-testid": id + '__status--A',
|
|
57
|
-
id: id + '__status--A',
|
|
58
|
-
role: "status",
|
|
59
|
-
"aria-atomic": "true",
|
|
60
|
-
"aria-live": "polite"
|
|
61
|
-
}, !silenced && debounced && bump ? assistiveText : ''), jsx("div", {
|
|
62
|
-
"data-testid": id + '__status--B',
|
|
63
|
-
id: id + '__status--B',
|
|
64
|
-
role: "status",
|
|
65
|
-
"aria-atomic": "true",
|
|
66
|
-
"aria-live": "polite"
|
|
67
|
-
}, !silenced && debounced && !bump ? assistiveText : ''));
|
|
68
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
/**
|
|
3
|
-
* @jsxRuntime classic
|
|
4
|
-
* @jsx jsx
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
8
|
-
|
|
9
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
|
-
import { css, jsx } from '@emotion/react';
|
|
11
|
-
import debounce from 'lodash/debounce';
|
|
12
|
-
var assitiveTextStyles = css({
|
|
13
|
-
border: 0,
|
|
14
|
-
clip: 'rect(0 0 0 0)',
|
|
15
|
-
height: '1px',
|
|
16
|
-
marginbottom: '-1px',
|
|
17
|
-
marginright: '-1px',
|
|
18
|
-
overflow: 'hidden',
|
|
19
|
-
padding: 0,
|
|
20
|
-
position: 'absolute',
|
|
21
|
-
whitespace: 'nowrap',
|
|
22
|
-
width: '1px'
|
|
23
|
-
});
|
|
24
|
-
export var AssistiveText = function AssistiveText(_ref) {
|
|
25
|
-
var _ref$assistiveText = _ref.assistiveText,
|
|
26
|
-
assistiveText = _ref$assistiveText === void 0 ? '' : _ref$assistiveText,
|
|
27
|
-
_ref$isInFocus = _ref.isInFocus,
|
|
28
|
-
isInFocus = _ref$isInFocus === void 0 ? false : _ref$isInFocus,
|
|
29
|
-
_ref$id = _ref.id,
|
|
30
|
-
id = _ref$id === void 0 ? '' : _ref$id,
|
|
31
|
-
_ref$statusDebounceMi = _ref.statusDebounceMillis,
|
|
32
|
-
statusDebounceMillis = _ref$statusDebounceMi === void 0 ? 1400 : _ref$statusDebounceMi;
|
|
33
|
-
var _useState = useState(false),
|
|
34
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
-
bump = _useState2[0],
|
|
36
|
-
setBump = _useState2[1];
|
|
37
|
-
var _useState3 = useState(false),
|
|
38
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
39
|
-
debounced = _useState4[0],
|
|
40
|
-
setDebounced = _useState4[1];
|
|
41
|
-
var _useState5 = useState(false),
|
|
42
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
43
|
-
silenced = _useState6[0],
|
|
44
|
-
setSilenced = _useState6[1];
|
|
45
|
-
var debounceStatusUpdate = useMemo(function () {
|
|
46
|
-
return debounce(function () {
|
|
47
|
-
var shouldSilence = !isInFocus;
|
|
48
|
-
setBump(function (prevBump) {
|
|
49
|
-
return !prevBump;
|
|
50
|
-
});
|
|
51
|
-
setDebounced(true);
|
|
52
|
-
setSilenced(shouldSilence);
|
|
53
|
-
});
|
|
54
|
-
}, [isInFocus]);
|
|
55
|
-
useEffect(function () {
|
|
56
|
-
if (!debounced) {
|
|
57
|
-
debounceStatusUpdate();
|
|
58
|
-
return function () {
|
|
59
|
-
debounceStatusUpdate.cancel();
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}, [assistiveText, isInFocus, debounced, debounceStatusUpdate]);
|
|
63
|
-
useEffect(function () {
|
|
64
|
-
if (debounced) {
|
|
65
|
-
setBump(function (prevBump) {
|
|
66
|
-
return !prevBump;
|
|
67
|
-
});
|
|
68
|
-
setDebounced(true);
|
|
69
|
-
setSilenced(!isInFocus);
|
|
70
|
-
}
|
|
71
|
-
}, [assistiveText, isInFocus, debounced]);
|
|
72
|
-
return jsx("div", {
|
|
73
|
-
css: assitiveTextStyles
|
|
74
|
-
}, jsx("div", {
|
|
75
|
-
"data-testid": id + '__status--A',
|
|
76
|
-
id: id + '__status--A',
|
|
77
|
-
role: "status",
|
|
78
|
-
"aria-atomic": "true",
|
|
79
|
-
"aria-live": "polite"
|
|
80
|
-
}, !silenced && debounced && bump ? assistiveText : ''), jsx("div", {
|
|
81
|
-
"data-testid": id + '__status--B',
|
|
82
|
-
id: id + '__status--B',
|
|
83
|
-
role: "status",
|
|
84
|
-
"aria-atomic": "true",
|
|
85
|
-
"aria-live": "polite"
|
|
86
|
-
}, !silenced && debounced && !bump ? assistiveText : ''));
|
|
87
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import { jsx } from '@emotion/react';
|
|
6
|
-
type AssistiveTextProps = {
|
|
7
|
-
assistiveText: string;
|
|
8
|
-
isInFocus: boolean;
|
|
9
|
-
id: string;
|
|
10
|
-
statusDebounceMillis?: number;
|
|
11
|
-
debounce?: boolean;
|
|
12
|
-
};
|
|
13
|
-
export declare const AssistiveText: ({ assistiveText, isInFocus, id, statusDebounceMillis, }: AssistiveTextProps) => jsx.JSX.Element;
|
|
14
|
-
export {};
|