@atlaskit/editor-plugin-type-ahead 1.10.4 → 1.10.5
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 +9 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/{api.js → pm-plugins/api.js} +2 -2
- package/dist/cjs/{transforms → pm-plugins/commands}/close-type-ahead.js +2 -2
- package/dist/cjs/{commands → pm-plugins/commands}/insert-type-ahead-item.js +4 -4
- package/dist/cjs/{transforms → pm-plugins/commands}/open-typeahead-at-cursor.js +2 -2
- package/dist/cjs/{commands → pm-plugins/commands}/update-list-items.js +2 -2
- package/dist/cjs/{commands → pm-plugins/commands}/update-query.js +2 -2
- package/dist/cjs/{commands → pm-plugins/commands}/update-selected-index.js +2 -2
- package/dist/cjs/pm-plugins/decorations.js +4 -4
- package/dist/cjs/pm-plugins/input-rules.js +1 -1
- package/dist/cjs/pm-plugins/insert-item-plugin.js +2 -2
- package/dist/cjs/pm-plugins/isInsertionTransaction.js +18 -0
- package/dist/cjs/pm-plugins/main.js +3 -3
- package/dist/cjs/pm-plugins/reducer.js +1 -1
- package/dist/cjs/pm-plugins/utils.js +120 -9
- package/dist/cjs/{plugin.js → typeAheadPlugin.js} +5 -5
- package/dist/cjs/types/index.js +5 -0
- package/dist/cjs/ui/InputQuery.js +2 -2
- package/dist/cjs/ui/TypeAheadList.js +3 -3
- package/dist/cjs/ui/TypeAheadMenu.js +1 -1
- package/dist/cjs/ui/TypeAheadPopup.js +1 -1
- package/dist/cjs/ui/WrapperTypeAhead.js +2 -2
- package/dist/cjs/ui/hooks/use-item-insert.js +4 -4
- package/dist/cjs/ui/hooks/use-load-items.js +1 -1
- package/dist/cjs/ui/hooks/use-on-force-select.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/{api.js → pm-plugins/api.js} +2 -2
- package/dist/es2019/{transforms → pm-plugins/commands}/close-type-ahead.js +2 -2
- package/dist/es2019/{commands → pm-plugins/commands}/insert-type-ahead-item.js +4 -4
- package/dist/es2019/{transforms → pm-plugins/commands}/open-typeahead-at-cursor.js +2 -2
- package/dist/es2019/{commands → pm-plugins/commands}/update-list-items.js +2 -2
- package/dist/es2019/{commands → pm-plugins/commands}/update-query.js +2 -2
- package/dist/es2019/{commands → pm-plugins/commands}/update-selected-index.js +2 -2
- package/dist/es2019/pm-plugins/decorations.js +4 -4
- package/dist/es2019/pm-plugins/input-rules.js +1 -1
- package/dist/es2019/pm-plugins/insert-item-plugin.js +1 -1
- package/dist/es2019/pm-plugins/isInsertionTransaction.js +12 -0
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/es2019/pm-plugins/reducer.js +1 -1
- package/dist/es2019/pm-plugins/utils.js +122 -9
- package/dist/es2019/{plugin.js → typeAheadPlugin.js} +5 -5
- package/dist/es2019/ui/InputQuery.js +2 -2
- package/dist/es2019/ui/TypeAheadList.js +3 -3
- package/dist/es2019/ui/TypeAheadMenu.js +1 -1
- package/dist/es2019/ui/TypeAheadPopup.js +1 -1
- package/dist/es2019/ui/WrapperTypeAhead.js +2 -2
- package/dist/es2019/ui/hooks/use-item-insert.js +4 -4
- package/dist/es2019/ui/hooks/use-load-items.js +1 -1
- package/dist/es2019/ui/hooks/use-on-force-select.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/{api.js → pm-plugins/api.js} +2 -2
- package/dist/esm/{transforms → pm-plugins/commands}/close-type-ahead.js +2 -2
- package/dist/esm/{commands → pm-plugins/commands}/insert-type-ahead-item.js +4 -4
- package/dist/esm/{transforms → pm-plugins/commands}/open-typeahead-at-cursor.js +2 -2
- package/dist/esm/{commands → pm-plugins/commands}/update-list-items.js +2 -2
- package/dist/esm/{commands → pm-plugins/commands}/update-query.js +2 -2
- package/dist/esm/{commands → pm-plugins/commands}/update-selected-index.js +2 -2
- package/dist/esm/pm-plugins/decorations.js +4 -4
- package/dist/esm/pm-plugins/input-rules.js +1 -1
- package/dist/esm/pm-plugins/insert-item-plugin.js +1 -1
- package/dist/esm/pm-plugins/isInsertionTransaction.js +12 -0
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/esm/pm-plugins/reducer.js +1 -1
- package/dist/esm/pm-plugins/utils.js +120 -9
- package/dist/esm/{plugin.js → typeAheadPlugin.js} +5 -5
- package/dist/esm/typeAheadPluginType.js +1 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/ui/InputQuery.js +2 -2
- package/dist/esm/ui/TypeAheadList.js +3 -3
- package/dist/esm/ui/TypeAheadMenu.js +1 -1
- package/dist/esm/ui/TypeAheadPopup.js +1 -1
- package/dist/esm/ui/WrapperTypeAhead.js +2 -2
- package/dist/esm/ui/hooks/use-item-insert.js +4 -4
- package/dist/esm/ui/hooks/use-load-items.js +1 -1
- package/dist/esm/ui/hooks/use-on-force-select.js +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/{types-ts4.5 → types/pm-plugins}/api.d.ts +1 -1
- package/dist/{types-ts4.5 → types/pm-plugins}/commands/insert-type-ahead-item.d.ts +1 -1
- package/dist/types/{transforms → pm-plugins/commands}/open-typeahead-at-cursor.d.ts +1 -1
- package/dist/types/{commands → pm-plugins/commands}/update-list-items.d.ts +1 -1
- package/dist/types/pm-plugins/isInsertionTransaction.d.ts +4 -0
- package/dist/types/{stats-modifier.d.ts → pm-plugins/stats-modifier.d.ts} +1 -1
- package/dist/types/pm-plugins/utils.d.ts +27 -4
- package/dist/types/{plugin.d.ts → typeAheadPlugin.d.ts} +1 -1
- package/dist/types/typeAheadPluginType.d.ts +41 -0
- package/dist/{types-ts4.5/types.d.ts → types/types/index.d.ts} +2 -41
- package/dist/types/ui/ContentComponent.d.ts +2 -1
- package/dist/types/ui/InputQuery.d.ts +1 -1
- package/dist/types/ui/TypeAheadMenu.d.ts +2 -1
- package/dist/types/ui/TypeAheadPopup.d.ts +3 -2
- package/dist/types-ts4.5/index.d.ts +3 -2
- package/dist/{types → types-ts4.5/pm-plugins}/api.d.ts +1 -1
- package/dist/{types → types-ts4.5/pm-plugins}/commands/insert-type-ahead-item.d.ts +1 -1
- package/dist/types-ts4.5/{transforms → pm-plugins/commands}/open-typeahead-at-cursor.d.ts +1 -1
- package/dist/types-ts4.5/{commands → pm-plugins/commands}/update-list-items.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/isInsertionTransaction.d.ts +4 -0
- package/dist/types-ts4.5/{stats-modifier.d.ts → pm-plugins/stats-modifier.d.ts} +1 -1
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +27 -4
- package/dist/types-ts4.5/{plugin.d.ts → typeAheadPlugin.d.ts} +1 -1
- package/dist/types-ts4.5/typeAheadPluginType.d.ts +44 -0
- package/dist/{types/types.d.ts → types-ts4.5/types/index.d.ts} +2 -38
- package/dist/types-ts4.5/ui/ContentComponent.d.ts +2 -1
- package/dist/types-ts4.5/ui/InputQuery.d.ts +1 -1
- package/dist/types-ts4.5/ui/TypeAheadMenu.d.ts +2 -1
- package/dist/types-ts4.5/ui/TypeAheadPopup.d.ts +3 -2
- package/package.json +7 -4
- package/dist/cjs/utils.js +0 -129
- package/dist/es2019/utils.js +0 -125
- package/dist/esm/utils.js +0 -123
- package/dist/types/utils.d.ts +0 -27
- package/dist/types-ts4.5/utils.d.ts +0 -27
- /package/dist/cjs/{insert-utils.js → pm-plugins/commands/insert-utils.js} +0 -0
- /package/dist/cjs/{transforms → pm-plugins/commands}/set-selection-before-query.js +0 -0
- /package/dist/cjs/{constants.js → pm-plugins/constants.js} +0 -0
- /package/dist/cjs/{stats-modifier.js → pm-plugins/stats-modifier.js} +0 -0
- /package/dist/cjs/{types.js → typeAheadPluginType.js} +0 -0
- /package/dist/es2019/{insert-utils.js → pm-plugins/commands/insert-utils.js} +0 -0
- /package/dist/es2019/{transforms → pm-plugins/commands}/set-selection-before-query.js +0 -0
- /package/dist/es2019/{constants.js → pm-plugins/constants.js} +0 -0
- /package/dist/es2019/{stats-modifier.js → pm-plugins/stats-modifier.js} +0 -0
- /package/dist/es2019/{types.js → typeAheadPluginType.js} +0 -0
- /package/dist/{esm/types.js → es2019/types/index.js} +0 -0
- /package/dist/esm/{insert-utils.js → pm-plugins/commands/insert-utils.js} +0 -0
- /package/dist/esm/{transforms → pm-plugins/commands}/set-selection-before-query.js +0 -0
- /package/dist/esm/{constants.js → pm-plugins/constants.js} +0 -0
- /package/dist/esm/{stats-modifier.js → pm-plugins/stats-modifier.js} +0 -0
- /package/dist/types/{transforms → pm-plugins/commands}/close-type-ahead.d.ts +0 -0
- /package/dist/types/{insert-utils.d.ts → pm-plugins/commands/insert-utils.d.ts} +0 -0
- /package/dist/types/{transforms → pm-plugins/commands}/set-selection-before-query.d.ts +0 -0
- /package/dist/types/{commands → pm-plugins/commands}/update-query.d.ts +0 -0
- /package/dist/types/{commands → pm-plugins/commands}/update-selected-index.d.ts +0 -0
- /package/dist/types/{constants.d.ts → pm-plugins/constants.d.ts} +0 -0
- /package/dist/types-ts4.5/{transforms → pm-plugins/commands}/close-type-ahead.d.ts +0 -0
- /package/dist/types-ts4.5/{insert-utils.d.ts → pm-plugins/commands/insert-utils.d.ts} +0 -0
- /package/dist/types-ts4.5/{transforms → pm-plugins/commands}/set-selection-before-query.d.ts +0 -0
- /package/dist/types-ts4.5/{commands → pm-plugins/commands}/update-query.d.ts +0 -0
- /package/dist/types-ts4.5/{commands → pm-plugins/commands}/update-selected-index.d.ts +0 -0
- /package/dist/types-ts4.5/{constants.d.ts → pm-plugins/constants.d.ts} +0 -0
|
@@ -2,12 +2,12 @@ import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
|
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { closest } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import { TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE } from '../constants';
|
|
6
5
|
import { ACTIONS } from './actions';
|
|
6
|
+
import { TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE } from './constants';
|
|
7
7
|
import { factoryDecorations } from './decorations';
|
|
8
|
+
import { isInsertionTransaction } from './isInsertionTransaction';
|
|
8
9
|
import { pluginKey } from './key';
|
|
9
10
|
import { createReducer } from './reducer';
|
|
10
|
-
import { isInsertionTransaction } from './utils';
|
|
11
11
|
const hasValidTypeAheadStep = tr => {
|
|
12
12
|
const steps = tr.steps.filter(step => step instanceof InsertTypeAheadStep);
|
|
13
13
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { InsertTypeAheadStages, InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
import { isTypeAheadHandler } from '../utils';
|
|
5
4
|
import { ACTIONS } from './actions';
|
|
6
5
|
import { pluginKey } from './key';
|
|
6
|
+
import { isTypeAheadHandler } from './utils';
|
|
7
7
|
const shouldForceOpen = step => {
|
|
8
8
|
if (!(step instanceof InsertTypeAheadStep)) {
|
|
9
9
|
return false;
|
|
@@ -1,12 +1,125 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { TypeAheadAvailableNodes, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
2
|
+
import { updateSelectedIndex } from './commands/update-selected-index';
|
|
3
|
+
import { pluginKey as typeAheadPluginKey } from './key';
|
|
4
|
+
import { StatsModifier } from './stats-modifier';
|
|
5
|
+
export const isTypeAheadHandler = handler => {
|
|
6
|
+
return handler && Object.values(TypeAheadAvailableNodes).includes(handler.id) && typeof handler.trigger === 'string' && typeof handler.selectItem === 'function' && typeof handler.getItems === 'function';
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/** Is a typeahead plugin open? */
|
|
10
|
+
export const isTypeAheadOpen = editorState => {
|
|
11
|
+
var _typeAheadPluginKey$g, _typeAheadPluginKey$g2;
|
|
12
|
+
return !!(typeAheadPluginKey !== null && typeAheadPluginKey !== void 0 && (_typeAheadPluginKey$g = typeAheadPluginKey.getState(editorState)) !== null && _typeAheadPluginKey$g !== void 0 && (_typeAheadPluginKey$g2 = _typeAheadPluginKey$g.decorationSet) !== null && _typeAheadPluginKey$g2 !== void 0 && _typeAheadPluginKey$g2.find().length);
|
|
13
|
+
};
|
|
14
|
+
export const getPluginState = editorState => {
|
|
15
|
+
return typeAheadPluginKey.getState(editorState);
|
|
16
|
+
};
|
|
17
|
+
export const getTypeAheadHandler = editorState => {
|
|
18
|
+
var _typeAheadPluginKey$g3;
|
|
19
|
+
return (_typeAheadPluginKey$g3 = typeAheadPluginKey.getState(editorState)) === null || _typeAheadPluginKey$g3 === void 0 ? void 0 : _typeAheadPluginKey$g3.triggerHandler;
|
|
20
|
+
};
|
|
21
|
+
export const getTypeAheadQuery = editorState => {
|
|
22
|
+
var _typeAheadPluginKey$g4;
|
|
23
|
+
return (_typeAheadPluginKey$g4 = typeAheadPluginKey.getState(editorState)) === null || _typeAheadPluginKey$g4 === void 0 ? void 0 : _typeAheadPluginKey$g4.query;
|
|
24
|
+
};
|
|
25
|
+
export const isTypeAheadAllowed = state => {
|
|
26
|
+
const isOpen = isTypeAheadOpen(state);
|
|
27
|
+
// if the TypeAhead is open
|
|
28
|
+
// we should not allow it
|
|
29
|
+
return !isOpen;
|
|
30
|
+
};
|
|
31
|
+
export const findHandler = (id, state) => {
|
|
32
|
+
const pluginState = typeAheadPluginKey.getState(state);
|
|
33
|
+
if (!pluginState || !pluginState.typeAheadHandlers || pluginState.typeAheadHandlers.length === 0) {
|
|
9
34
|
return null;
|
|
10
35
|
}
|
|
11
|
-
|
|
36
|
+
const {
|
|
37
|
+
typeAheadHandlers
|
|
38
|
+
} = pluginState;
|
|
39
|
+
return typeAheadHandlers.find(h => h.id === id) || null;
|
|
40
|
+
};
|
|
41
|
+
export const findHandlerByTrigger = ({
|
|
42
|
+
trigger,
|
|
43
|
+
editorState
|
|
44
|
+
}) => {
|
|
45
|
+
const pluginState = typeAheadPluginKey.getState(editorState);
|
|
46
|
+
if (!pluginState || !pluginState.typeAheadHandlers || pluginState.typeAheadHandlers.length === 0) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const {
|
|
50
|
+
typeAheadHandlers
|
|
51
|
+
} = pluginState;
|
|
52
|
+
return typeAheadHandlers.find(h => h.trigger === trigger) || null;
|
|
53
|
+
};
|
|
54
|
+
export const moveSelectedIndex = ({
|
|
55
|
+
editorView,
|
|
56
|
+
direction
|
|
57
|
+
}) => () => {
|
|
58
|
+
const typeAheadState = getPluginState(editorView.state);
|
|
59
|
+
if (!typeAheadState) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const {
|
|
63
|
+
selectedIndex,
|
|
64
|
+
items
|
|
65
|
+
} = typeAheadState;
|
|
66
|
+
const stats = typeAheadState.stats instanceof StatsModifier ? typeAheadState.stats : new StatsModifier();
|
|
67
|
+
let nextIndex;
|
|
68
|
+
if (direction === 'next') {
|
|
69
|
+
stats.increaseArrowDown();
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* See: https://product-fabric.atlassian.net/browse/ED-17200
|
|
73
|
+
* `selectedIndex` is forced to -1 now to not immediately focus the typeahead
|
|
74
|
+
* and only do so when there is explicit logic to focus into the typeahead
|
|
75
|
+
* options.
|
|
76
|
+
*
|
|
77
|
+
* This check for "set index to 1 when -1"
|
|
78
|
+
* - is a temporary workaround to get back the previous behaviour without
|
|
79
|
+
* entirely reverting the a11y improvements
|
|
80
|
+
*
|
|
81
|
+
*/
|
|
82
|
+
if (selectedIndex === -1 && items.length > 1) {
|
|
83
|
+
nextIndex = 1;
|
|
84
|
+
} else {
|
|
85
|
+
nextIndex = selectedIndex >= items.length - 1 ? 0 : selectedIndex + 1;
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
stats.increaseArrowUp();
|
|
89
|
+
nextIndex = selectedIndex <= 0 ? items.length - 1 : selectedIndex - 1;
|
|
90
|
+
}
|
|
91
|
+
updateSelectedIndex(nextIndex)(editorView.state, editorView.dispatch);
|
|
92
|
+
};
|
|
93
|
+
export const getTypeAheadListAriaLabels = (trigger, intl, item) => {
|
|
94
|
+
var _item$mention, _item$mention2, _item$emoji, _item$emoji2, _item$emoji3;
|
|
95
|
+
switch (trigger) {
|
|
96
|
+
case '@':
|
|
97
|
+
return {
|
|
98
|
+
popupAriaLabel: intl.formatMessage(typeAheadListMessages.mentionPopupLabel),
|
|
99
|
+
listItemAriaLabel: intl.formatMessage(typeAheadListMessages.metionListItemLabel, {
|
|
100
|
+
name: (item === null || item === void 0 ? void 0 : (_item$mention = item.mention) === null || _item$mention === void 0 ? void 0 : _item$mention.name) || '',
|
|
101
|
+
shortName: (item === null || item === void 0 ? void 0 : (_item$mention2 = item.mention) === null || _item$mention2 === void 0 ? void 0 : _item$mention2.mentionName) || ''
|
|
102
|
+
})
|
|
103
|
+
};
|
|
104
|
+
case '/':
|
|
105
|
+
return {
|
|
106
|
+
popupAriaLabel: intl.formatMessage(typeAheadListMessages.quickInsertPopupLabel),
|
|
107
|
+
listItemAriaLabel: intl.formatMessage(typeAheadListMessages.emojiListItemLabel, {
|
|
108
|
+
name: (item === null || item === void 0 ? void 0 : item.title) || '',
|
|
109
|
+
shortcut: (item === null || item === void 0 ? void 0 : (_item$emoji = item.emoji) === null || _item$emoji === void 0 ? void 0 : _item$emoji.shortName) || ''
|
|
110
|
+
})
|
|
111
|
+
};
|
|
112
|
+
case ':':
|
|
113
|
+
return {
|
|
114
|
+
popupAriaLabel: intl.formatMessage(typeAheadListMessages.emojiPopupLabel),
|
|
115
|
+
listItemAriaLabel: intl.formatMessage(typeAheadListMessages.emojiListItemLabel, {
|
|
116
|
+
name: (item === null || item === void 0 ? void 0 : (_item$emoji2 = item.emoji) === null || _item$emoji2 === void 0 ? void 0 : _item$emoji2.name) || '',
|
|
117
|
+
shortcut: (item === null || item === void 0 ? void 0 : (_item$emoji3 = item.emoji) === null || _item$emoji3 === void 0 ? void 0 : _item$emoji3.shortName) || ''
|
|
118
|
+
})
|
|
119
|
+
};
|
|
120
|
+
default:
|
|
121
|
+
return {
|
|
122
|
+
popupAriaLabel: intl.formatMessage(typeAheadListMessages.typeAheadPopupLabel)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
12
125
|
};
|
|
@@ -12,16 +12,16 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/edit
|
|
|
12
12
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
13
13
|
import { SelectItemMode, TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
14
14
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
15
|
-
import {
|
|
15
|
+
import { closeTypeAhead } from './pm-plugins/commands/close-type-ahead';
|
|
16
|
+
import { insertTypeAheadItem } from './pm-plugins/commands/insert-type-ahead-item';
|
|
17
|
+
import { openTypeAheadAtCursor } from './pm-plugins/commands/open-typeahead-at-cursor';
|
|
16
18
|
import { inputRulePlugin } from './pm-plugins/input-rules';
|
|
17
19
|
import { createPlugin as createInsertItemPlugin } from './pm-plugins/insert-item-plugin';
|
|
18
20
|
import { pluginKey as typeAheadPluginKey } from './pm-plugins/key';
|
|
19
21
|
import { createPlugin } from './pm-plugins/main';
|
|
20
|
-
import { StatsModifier } from './stats-modifier';
|
|
21
|
-
import {
|
|
22
|
-
import { openTypeAheadAtCursor } from './transforms/open-typeahead-at-cursor';
|
|
22
|
+
import { StatsModifier } from './pm-plugins/stats-modifier';
|
|
23
|
+
import { findHandler, getPluginState, getTypeAheadHandler, getTypeAheadQuery, isTypeAheadAllowed, isTypeAheadOpen } from './pm-plugins/utils';
|
|
23
24
|
import { ContentComponent } from './ui/ContentComponent';
|
|
24
|
-
import { findHandler, getPluginState, getTypeAheadHandler, getTypeAheadQuery, isTypeAheadAllowed, isTypeAheadOpen } from './utils';
|
|
25
25
|
const createOpenAtTransaction = editorAnalyticsAPI => props => tr => {
|
|
26
26
|
const {
|
|
27
27
|
triggerHandler,
|
|
@@ -11,8 +11,8 @@ import { keyName as keyNameNormalized } from 'w3c-keyname';
|
|
|
11
11
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
12
12
|
import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
13
13
|
import { blockNodesVerticalMargin } from '@atlaskit/editor-shared-styles';
|
|
14
|
-
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_ELEMENT_ID, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../constants';
|
|
15
|
-
import { getPluginState } from '../utils';
|
|
14
|
+
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_ELEMENT_ID, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../pm-plugins/constants';
|
|
15
|
+
import { getPluginState } from '../pm-plugins/utils';
|
|
16
16
|
import { AssistiveText } from './AssistiveText';
|
|
17
17
|
const querySpanStyles = css({
|
|
18
18
|
outline: 'none',
|
|
@@ -12,9 +12,9 @@ import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs
|
|
|
12
12
|
import { List } from 'react-virtualized/dist/commonjs/List';
|
|
13
13
|
import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
14
14
|
import { MenuGroup } from '@atlaskit/menu';
|
|
15
|
-
import { updateSelectedIndex } from '../commands/update-selected-index';
|
|
16
|
-
import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../constants';
|
|
17
|
-
import { getTypeAheadListAriaLabels, moveSelectedIndex } from '../utils';
|
|
15
|
+
import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
|
|
16
|
+
import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
|
|
17
|
+
import { getTypeAheadListAriaLabels, moveSelectedIndex } from '../pm-plugins/utils';
|
|
18
18
|
import { AssistiveText } from './AssistiveText';
|
|
19
19
|
import { TypeAheadListItem } from './TypeAheadListItem';
|
|
20
20
|
const LIST_ITEM_ESTIMATED_HEIGHT = 64;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
3
|
-
import { updateSelectedIndex } from '../commands/update-selected-index';
|
|
3
|
+
import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
|
|
4
4
|
import { useItemInsert } from './hooks/use-item-insert';
|
|
5
5
|
import { TypeAheadPopup } from './TypeAheadPopup';
|
|
6
6
|
export const TypeAheadMenu = /*#__PURE__*/React.memo(({
|
|
@@ -13,7 +13,7 @@ import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
|
13
13
|
import { findOverflowScrollParent, Popup } from '@atlaskit/editor-common/ui';
|
|
14
14
|
import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
|
|
15
15
|
import { N0, N50A, N60A } from '@atlaskit/theme/colors';
|
|
16
|
-
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../constants';
|
|
16
|
+
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../pm-plugins/constants';
|
|
17
17
|
import { TypeAheadList } from './TypeAheadList';
|
|
18
18
|
const DEFAULT_TYPEAHEAD_MENU_HEIGHT = 380;
|
|
19
19
|
const DEFAULT_TYPEAHEAD_MENU_HEIGHT_NEW = 480;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
3
|
-
import { updateQuery } from '../commands/update-query';
|
|
4
|
-
import { getPluginState, moveSelectedIndex } from '../utils';
|
|
3
|
+
import { updateQuery } from '../pm-plugins/commands/update-query';
|
|
4
|
+
import { getPluginState, moveSelectedIndex } from '../pm-plugins/utils';
|
|
5
5
|
import { useItemInsert } from './hooks/use-item-insert';
|
|
6
6
|
import { useLoadItems } from './hooks/use-load-items';
|
|
7
7
|
import { useOnForceSelect } from './hooks/use-on-force-select';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useCallback, useLayoutEffect, useRef } from 'react';
|
|
2
2
|
import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { closeTypeAhead } from '../../pm-plugins/commands/close-type-ahead';
|
|
4
|
+
import { insertTypeAheadItem } from '../../pm-plugins/commands/insert-type-ahead-item';
|
|
5
|
+
import { setSelectionBeforeQuery } from '../../pm-plugins/commands/set-selection-before-query';
|
|
6
|
+
import { CloseSelectionOptions } from '../../pm-plugins/constants';
|
|
7
7
|
const insertRawQuery = ({
|
|
8
8
|
view,
|
|
9
9
|
setSelectionAt,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { updateListItem } from '../../commands/update-list-items';
|
|
2
|
+
import { updateListItem } from '../../pm-plugins/commands/update-list-items';
|
|
3
3
|
const EMPTY_LIST_ITEM = [];
|
|
4
4
|
export const useLoadItems = (triggerHandler, editorView, query) => {
|
|
5
5
|
const [items, setItems] = useState(EMPTY_LIST_ITEM);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useLayoutEffect, useRef } from 'react';
|
|
2
2
|
import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
3
|
-
import { insertTypeAheadItem } from '../../commands/insert-type-ahead-item';
|
|
3
|
+
import { insertTypeAheadItem } from '../../pm-plugins/commands/insert-type-ahead-item';
|
|
4
4
|
export const useOnForceSelect = ({
|
|
5
5
|
triggerHandler,
|
|
6
6
|
items,
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { typeAheadPlugin } from './
|
|
1
|
+
export { typeAheadPlugin } from './typeAheadPlugin';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { SelectItemMode, TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
3
|
+
import { closeTypeAhead } from './commands/close-type-ahead';
|
|
3
4
|
import { insertTypeAheadItem } from './commands/insert-type-ahead-item';
|
|
5
|
+
import { openTypeAheadAtCursor } from './commands/open-typeahead-at-cursor';
|
|
4
6
|
import { updateQuery } from './commands/update-query';
|
|
5
|
-
import { closeTypeAhead } from './transforms/close-type-ahead';
|
|
6
|
-
import { openTypeAheadAtCursor } from './transforms/open-typeahead-at-cursor';
|
|
7
7
|
import { findHandler, getTypeAheadHandler, getTypeAheadQuery, isTypeAheadOpen } from './utils';
|
|
8
8
|
var open = function open(_ref) {
|
|
9
9
|
var editorView = _ref.editorView;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ACTIONS } from '../
|
|
2
|
-
import { pluginKey } from '../
|
|
1
|
+
import { ACTIONS } from '../actions';
|
|
2
|
+
import { pluginKey } from '../key';
|
|
3
3
|
export var closeTypeAhead = function closeTypeAhead(tr) {
|
|
4
4
|
return tr.setMeta(pluginKey, {
|
|
5
5
|
action: ACTIONS.CLOSE_TYPE_AHEAD
|
|
@@ -4,12 +4,12 @@ import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
|
4
4
|
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
5
5
|
import { Fragment, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { pluginKey } from '../pm-plugins/key';
|
|
7
|
+
import { ACTIONS } from '../actions';
|
|
8
|
+
import { pluginKey } from '../key';
|
|
10
9
|
import { StatsModifier } from '../stats-modifier';
|
|
11
|
-
import { closeTypeAhead } from '../transforms/close-type-ahead';
|
|
12
10
|
import { getPluginState } from '../utils';
|
|
11
|
+
import { closeTypeAhead } from './close-type-ahead';
|
|
12
|
+
import { insertBlockNode, insertInlineNodeOrFragment } from './insert-utils';
|
|
13
13
|
var validateNode = function validateNode(_ref) {
|
|
14
14
|
var schema = _ref.schema,
|
|
15
15
|
maybeNode = _ref.maybeNode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
2
2
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { ACTIONS } from '../
|
|
4
|
-
import { pluginKey } from '../
|
|
3
|
+
import { ACTIONS } from '../actions';
|
|
4
|
+
import { pluginKey } from '../key';
|
|
5
5
|
export var openTypeAhead = function openTypeAhead(props) {
|
|
6
6
|
return function (tr) {
|
|
7
7
|
var triggerHandler = props.triggerHandler,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ACTIONS } from '../
|
|
2
|
-
import { pluginKey as typeAheadPluginKey } from '../
|
|
1
|
+
import { ACTIONS } from '../actions';
|
|
2
|
+
import { pluginKey as typeAheadPluginKey } from '../key';
|
|
3
3
|
export var updateListItem = function updateListItem(items) {
|
|
4
4
|
return function (state, dispatch) {
|
|
5
5
|
var tr = state.tr;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ACTIONS } from '../
|
|
2
|
-
import { pluginKey as typeAheadPluginKey } from '../
|
|
1
|
+
import { ACTIONS } from '../actions';
|
|
2
|
+
import { pluginKey as typeAheadPluginKey } from '../key';
|
|
3
3
|
export var updateQuery = function updateQuery(query) {
|
|
4
4
|
return function (state, dispatch) {
|
|
5
5
|
var pluginState = typeAheadPluginKey.getState(state);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ACTIONS } from '../
|
|
2
|
-
import { pluginKey as typeAheadPluginKey } from '../
|
|
1
|
+
import { ACTIONS } from '../actions';
|
|
2
|
+
import { pluginKey as typeAheadPluginKey } from '../key';
|
|
3
3
|
export var updateSelectedIndex = function updateSelectedIndex(selectedIndex) {
|
|
4
4
|
return function (state, dispatch) {
|
|
5
5
|
var pluginState = typeAheadPluginKey.getState(state);
|
|
@@ -7,11 +7,11 @@ import { redo, undo } from '@atlaskit/editor-prosemirror/history';
|
|
|
7
7
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import { B400 } from '@atlaskit/theme/colors';
|
|
10
|
-
import { TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, TYPE_AHEAD_DECORATION_KEY } from '../constants';
|
|
11
|
-
import { StatsModifier } from '../stats-modifier';
|
|
12
|
-
import { closeTypeAhead } from '../transforms/close-type-ahead';
|
|
13
10
|
import { WrapperTypeAhead } from '../ui/WrapperTypeAhead';
|
|
14
|
-
import {
|
|
11
|
+
import { closeTypeAhead } from './commands/close-type-ahead';
|
|
12
|
+
import { TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE, TYPE_AHEAD_DECORATION_KEY } from './constants';
|
|
13
|
+
import { StatsModifier } from './stats-modifier';
|
|
14
|
+
import { getTypeAheadQuery } from './utils';
|
|
15
15
|
export var factoryDecorations = function factoryDecorations(_ref) {
|
|
16
16
|
var intl = _ref.intl,
|
|
17
17
|
popupMountRef = _ref.popupMountRef;
|
|
@@ -2,7 +2,7 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { createRule } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
5
|
-
import { openTypeAheadAtCursor } from '../
|
|
5
|
+
import { openTypeAheadAtCursor } from '../pm-plugins/commands/open-typeahead-at-cursor';
|
|
6
6
|
export function inputRulePlugin(schema, typeAheads, featureFlags) {
|
|
7
7
|
if (!typeAheads || typeAheads.length === 0) {
|
|
8
8
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { ACTIONS } from './actions';
|
|
3
|
-
import { isInsertionTransaction } from './
|
|
3
|
+
import { isInsertionTransaction } from './isInsertionTransaction';
|
|
4
4
|
export function createPlugin() {
|
|
5
5
|
return new SafePlugin({
|
|
6
6
|
appendTransaction: function appendTransaction(transactions, _oldState, newState) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { pluginKey } from './key';
|
|
2
|
+
export var isInsertionTransaction = function isInsertionTransaction(transactions, action) {
|
|
3
|
+
var _tr$getMeta2;
|
|
4
|
+
var tr = transactions.find(function (tr) {
|
|
5
|
+
var _tr$getMeta;
|
|
6
|
+
return ((_tr$getMeta = tr.getMeta(pluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.action) === action;
|
|
7
|
+
});
|
|
8
|
+
if (!tr) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return (_tr$getMeta2 = tr.getMeta(pluginKey)) === null || _tr$getMeta2 === void 0 ? void 0 : _tr$getMeta2.params;
|
|
12
|
+
};
|
|
@@ -2,12 +2,12 @@ import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
|
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { closest } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import { TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE } from '../constants';
|
|
6
5
|
import { ACTIONS } from './actions';
|
|
6
|
+
import { TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE } from './constants';
|
|
7
7
|
import { factoryDecorations } from './decorations';
|
|
8
|
+
import { isInsertionTransaction } from './isInsertionTransaction';
|
|
8
9
|
import { pluginKey } from './key';
|
|
9
10
|
import { createReducer } from './reducer';
|
|
10
|
-
import { isInsertionTransaction } from './utils';
|
|
11
11
|
var hasValidTypeAheadStep = function hasValidTypeAheadStep(tr) {
|
|
12
12
|
var steps = tr.steps.filter(function (step) {
|
|
13
13
|
return step instanceof InsertTypeAheadStep;
|
|
@@ -4,9 +4,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { InsertTypeAheadStages, InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
|
|
5
5
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
-
import { isTypeAheadHandler } from '../utils';
|
|
8
7
|
import { ACTIONS } from './actions';
|
|
9
8
|
import { pluginKey } from './key';
|
|
9
|
+
import { isTypeAheadHandler } from './utils';
|
|
10
10
|
var shouldForceOpen = function shouldForceOpen(step) {
|
|
11
11
|
if (!(step instanceof InsertTypeAheadStep)) {
|
|
12
12
|
return false;
|
|
@@ -1,12 +1,123 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { TypeAheadAvailableNodes, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
2
|
+
import { updateSelectedIndex } from './commands/update-selected-index';
|
|
3
|
+
import { pluginKey as typeAheadPluginKey } from './key';
|
|
4
|
+
import { StatsModifier } from './stats-modifier';
|
|
5
|
+
export var isTypeAheadHandler = function isTypeAheadHandler(handler) {
|
|
6
|
+
return handler && Object.values(TypeAheadAvailableNodes).includes(handler.id) && typeof handler.trigger === 'string' && typeof handler.selectItem === 'function' && typeof handler.getItems === 'function';
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/** Is a typeahead plugin open? */
|
|
10
|
+
export var isTypeAheadOpen = function isTypeAheadOpen(editorState) {
|
|
11
|
+
var _typeAheadPluginKey$g;
|
|
12
|
+
return !!(typeAheadPluginKey !== null && typeAheadPluginKey !== void 0 && (_typeAheadPluginKey$g = typeAheadPluginKey.getState(editorState)) !== null && _typeAheadPluginKey$g !== void 0 && (_typeAheadPluginKey$g = _typeAheadPluginKey$g.decorationSet) !== null && _typeAheadPluginKey$g !== void 0 && _typeAheadPluginKey$g.find().length);
|
|
13
|
+
};
|
|
14
|
+
export var getPluginState = function getPluginState(editorState) {
|
|
15
|
+
return typeAheadPluginKey.getState(editorState);
|
|
16
|
+
};
|
|
17
|
+
export var getTypeAheadHandler = function getTypeAheadHandler(editorState) {
|
|
18
|
+
var _typeAheadPluginKey$g2;
|
|
19
|
+
return (_typeAheadPluginKey$g2 = typeAheadPluginKey.getState(editorState)) === null || _typeAheadPluginKey$g2 === void 0 ? void 0 : _typeAheadPluginKey$g2.triggerHandler;
|
|
20
|
+
};
|
|
21
|
+
export var getTypeAheadQuery = function getTypeAheadQuery(editorState) {
|
|
22
|
+
var _typeAheadPluginKey$g3;
|
|
23
|
+
return (_typeAheadPluginKey$g3 = typeAheadPluginKey.getState(editorState)) === null || _typeAheadPluginKey$g3 === void 0 ? void 0 : _typeAheadPluginKey$g3.query;
|
|
24
|
+
};
|
|
25
|
+
export var isTypeAheadAllowed = function isTypeAheadAllowed(state) {
|
|
26
|
+
var isOpen = isTypeAheadOpen(state);
|
|
27
|
+
// if the TypeAhead is open
|
|
28
|
+
// we should not allow it
|
|
29
|
+
return !isOpen;
|
|
30
|
+
};
|
|
31
|
+
export var findHandler = function findHandler(id, state) {
|
|
32
|
+
var pluginState = typeAheadPluginKey.getState(state);
|
|
33
|
+
if (!pluginState || !pluginState.typeAheadHandlers || pluginState.typeAheadHandlers.length === 0) {
|
|
9
34
|
return null;
|
|
10
35
|
}
|
|
11
|
-
|
|
36
|
+
var typeAheadHandlers = pluginState.typeAheadHandlers;
|
|
37
|
+
return typeAheadHandlers.find(function (h) {
|
|
38
|
+
return h.id === id;
|
|
39
|
+
}) || null;
|
|
40
|
+
};
|
|
41
|
+
export var findHandlerByTrigger = function findHandlerByTrigger(_ref) {
|
|
42
|
+
var trigger = _ref.trigger,
|
|
43
|
+
editorState = _ref.editorState;
|
|
44
|
+
var pluginState = typeAheadPluginKey.getState(editorState);
|
|
45
|
+
if (!pluginState || !pluginState.typeAheadHandlers || pluginState.typeAheadHandlers.length === 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
var typeAheadHandlers = pluginState.typeAheadHandlers;
|
|
49
|
+
return typeAheadHandlers.find(function (h) {
|
|
50
|
+
return h.trigger === trigger;
|
|
51
|
+
}) || null;
|
|
52
|
+
};
|
|
53
|
+
export var moveSelectedIndex = function moveSelectedIndex(_ref2) {
|
|
54
|
+
var editorView = _ref2.editorView,
|
|
55
|
+
direction = _ref2.direction;
|
|
56
|
+
return function () {
|
|
57
|
+
var typeAheadState = getPluginState(editorView.state);
|
|
58
|
+
if (!typeAheadState) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
var selectedIndex = typeAheadState.selectedIndex,
|
|
62
|
+
items = typeAheadState.items;
|
|
63
|
+
var stats = typeAheadState.stats instanceof StatsModifier ? typeAheadState.stats : new StatsModifier();
|
|
64
|
+
var nextIndex;
|
|
65
|
+
if (direction === 'next') {
|
|
66
|
+
stats.increaseArrowDown();
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* See: https://product-fabric.atlassian.net/browse/ED-17200
|
|
70
|
+
* `selectedIndex` is forced to -1 now to not immediately focus the typeahead
|
|
71
|
+
* and only do so when there is explicit logic to focus into the typeahead
|
|
72
|
+
* options.
|
|
73
|
+
*
|
|
74
|
+
* This check for "set index to 1 when -1"
|
|
75
|
+
* - is a temporary workaround to get back the previous behaviour without
|
|
76
|
+
* entirely reverting the a11y improvements
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
if (selectedIndex === -1 && items.length > 1) {
|
|
80
|
+
nextIndex = 1;
|
|
81
|
+
} else {
|
|
82
|
+
nextIndex = selectedIndex >= items.length - 1 ? 0 : selectedIndex + 1;
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
stats.increaseArrowUp();
|
|
86
|
+
nextIndex = selectedIndex <= 0 ? items.length - 1 : selectedIndex - 1;
|
|
87
|
+
}
|
|
88
|
+
updateSelectedIndex(nextIndex)(editorView.state, editorView.dispatch);
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export var getTypeAheadListAriaLabels = function getTypeAheadListAriaLabels(trigger, intl, item) {
|
|
92
|
+
var _item$mention, _item$mention2, _item$emoji, _item$emoji2, _item$emoji3;
|
|
93
|
+
switch (trigger) {
|
|
94
|
+
case '@':
|
|
95
|
+
return {
|
|
96
|
+
popupAriaLabel: intl.formatMessage(typeAheadListMessages.mentionPopupLabel),
|
|
97
|
+
listItemAriaLabel: intl.formatMessage(typeAheadListMessages.metionListItemLabel, {
|
|
98
|
+
name: (item === null || item === void 0 || (_item$mention = item.mention) === null || _item$mention === void 0 ? void 0 : _item$mention.name) || '',
|
|
99
|
+
shortName: (item === null || item === void 0 || (_item$mention2 = item.mention) === null || _item$mention2 === void 0 ? void 0 : _item$mention2.mentionName) || ''
|
|
100
|
+
})
|
|
101
|
+
};
|
|
102
|
+
case '/':
|
|
103
|
+
return {
|
|
104
|
+
popupAriaLabel: intl.formatMessage(typeAheadListMessages.quickInsertPopupLabel),
|
|
105
|
+
listItemAriaLabel: intl.formatMessage(typeAheadListMessages.emojiListItemLabel, {
|
|
106
|
+
name: (item === null || item === void 0 ? void 0 : item.title) || '',
|
|
107
|
+
shortcut: (item === null || item === void 0 || (_item$emoji = item.emoji) === null || _item$emoji === void 0 ? void 0 : _item$emoji.shortName) || ''
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
case ':':
|
|
111
|
+
return {
|
|
112
|
+
popupAriaLabel: intl.formatMessage(typeAheadListMessages.emojiPopupLabel),
|
|
113
|
+
listItemAriaLabel: intl.formatMessage(typeAheadListMessages.emojiListItemLabel, {
|
|
114
|
+
name: (item === null || item === void 0 || (_item$emoji2 = item.emoji) === null || _item$emoji2 === void 0 ? void 0 : _item$emoji2.name) || '',
|
|
115
|
+
shortcut: (item === null || item === void 0 || (_item$emoji3 = item.emoji) === null || _item$emoji3 === void 0 ? void 0 : _item$emoji3.shortName) || ''
|
|
116
|
+
})
|
|
117
|
+
};
|
|
118
|
+
default:
|
|
119
|
+
return {
|
|
120
|
+
popupAriaLabel: intl.formatMessage(typeAheadListMessages.typeAheadPopupLabel)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
12
123
|
};
|
|
@@ -12,16 +12,16 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/edit
|
|
|
12
12
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
13
13
|
import { SelectItemMode, TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
14
14
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
15
|
-
import {
|
|
15
|
+
import { closeTypeAhead } from './pm-plugins/commands/close-type-ahead';
|
|
16
|
+
import { insertTypeAheadItem } from './pm-plugins/commands/insert-type-ahead-item';
|
|
17
|
+
import { openTypeAheadAtCursor } from './pm-plugins/commands/open-typeahead-at-cursor';
|
|
16
18
|
import { inputRulePlugin } from './pm-plugins/input-rules';
|
|
17
19
|
import { createPlugin as createInsertItemPlugin } from './pm-plugins/insert-item-plugin';
|
|
18
20
|
import { pluginKey as typeAheadPluginKey } from './pm-plugins/key';
|
|
19
21
|
import { createPlugin } from './pm-plugins/main';
|
|
20
|
-
import { StatsModifier } from './stats-modifier';
|
|
21
|
-
import {
|
|
22
|
-
import { openTypeAheadAtCursor } from './transforms/open-typeahead-at-cursor';
|
|
22
|
+
import { StatsModifier } from './pm-plugins/stats-modifier';
|
|
23
|
+
import { findHandler, getPluginState, getTypeAheadHandler, getTypeAheadQuery, isTypeAheadAllowed, isTypeAheadOpen } from './pm-plugins/utils';
|
|
23
24
|
import { ContentComponent } from './ui/ContentComponent';
|
|
24
|
-
import { findHandler, getPluginState, getTypeAheadHandler, getTypeAheadQuery, isTypeAheadAllowed, isTypeAheadOpen } from './utils';
|
|
25
25
|
var createOpenAtTransaction = function createOpenAtTransaction(editorAnalyticsAPI) {
|
|
26
26
|
return function (props) {
|
|
27
27
|
return function (tr) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,8 +12,8 @@ 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
14
|
import { blockNodesVerticalMargin } from '@atlaskit/editor-shared-styles';
|
|
15
|
-
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_ELEMENT_ID, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../constants';
|
|
16
|
-
import { getPluginState } from '../utils';
|
|
15
|
+
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_ELEMENT_ID, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../pm-plugins/constants';
|
|
16
|
+
import { getPluginState } from '../pm-plugins/utils';
|
|
17
17
|
import { AssistiveText } from './AssistiveText';
|
|
18
18
|
var querySpanStyles = css({
|
|
19
19
|
outline: 'none',
|